Files
oh-my-pi/packages/coding-agent/test/tool-discovery/persistence.test.ts
T
can1357 ae1650d689 refactor: renamed search and find tools to grep and glob
- Renamed the `find` and `search` tools to `glob` and `grep` respectively across the codebase to improve command clarity.
- Implemented full-stack support for the renamed tools, including CLI arguments, system prompts, SDK exports, and tool registration.
- Added automated migration logic in `settings` to transform legacy `find` and `search` configuration keys to their new equivalents.
- Updated the `collab-web` renderer registry to ensure backwards compatibility with legacy tool outputs.
2026-06-27 00:57:55 +02:00

47 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import type { DiscoverableTool } from "@oh-my-pi/pi-coding-agent/tool-discovery/tool-index";
import {
buildDiscoverableToolSearchIndex,
searchDiscoverableTools,
} from "@oh-my-pi/pi-coding-agent/tool-discovery/tool-index";
describe("generic index: DiscoverableTool round-trip", () => {
const tools: DiscoverableTool[] = [
{
name: "glob",
label: "glob",
summary: "Find files matching a glob pattern",
source: "builtin",
schemaKeys: ["pattern", "path"],
},
{
name: "mcp__gh_search",
label: "github/search",
summary: "Search GitHub repositories",
source: "mcp",
serverName: "github",
mcpToolName: "search",
schemaKeys: ["query"],
},
];
it("builds and searches without loss", () => {
const index = buildDiscoverableToolSearchIndex(tools);
expect(index.documents).toHaveLength(2);
const findResults = searchDiscoverableTools(index, "find files", 3);
expect(findResults.some((r: any) => r.tool.name === "glob")).toBe(true);
const ghResults = searchDiscoverableTools(index, "github search", 3);
expect(ghResults.some((r: any) => r.tool.name === "mcp__gh_search")).toBe(true);
});
it("preserves source field in search results", () => {
const index = buildDiscoverableToolSearchIndex(tools);
const results = searchDiscoverableTools(index, "github", 3);
const ghResult = results.find((r: any) => r.tool.name === "mcp__gh_search");
expect(ghResult).toBeDefined();
expect(ghResult!.tool.source).toBe("mcp");
});
});