5364a9bfd0
- Removed deprecated MCP-specific type aliases and functions from tool-discovery module, consolidating to unified generic tool discovery API. - Migrated session and SDK code to use generic filterBySource() and collectDiscoverableTools() instead of MCP-specific variants. - Removed deprecated interface members including hasQueuedMessages(), FocusPane, AcpBuiltinCommandRuntime, and legacy settings methods. - Updated test suites to use renamed generic discovery methods and removed back-compat test coverage for legacy MCP shapes.
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import type { DiscoverableTool } from "../../src/tool-discovery/tool-index";
|
|
import { buildDiscoverableToolSearchIndex } from "../../src/tool-discovery/tool-index";
|
|
|
|
describe("generic index: DiscoverableTool round-trip", () => {
|
|
const tools: DiscoverableTool[] = [
|
|
{
|
|
name: "find",
|
|
label: "find",
|
|
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 { searchDiscoverableTools } = require("../../src/tool-discovery/tool-index");
|
|
const index = buildDiscoverableToolSearchIndex(tools);
|
|
expect(index.documents).toHaveLength(2);
|
|
|
|
const findResults = searchDiscoverableTools(index, "find files", 3);
|
|
expect(findResults.some((r: any) => r.tool.name === "find")).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 { searchDiscoverableTools } = require("../../src/tool-discovery/tool-index");
|
|
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");
|
|
});
|
|
});
|