ae1650d689
- 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.
47 lines
1.5 KiB
TypeScript
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");
|
|
});
|
|
});
|