diff --git a/lib/ai/agent/tools/index.js b/lib/ai/agent/tools/index.js new file mode 100644 index 0000000..186290a --- /dev/null +++ b/lib/ai/agent/tools/index.js @@ -0,0 +1,14 @@ +import { createRegistry } from '../registry.js'; +import { searchTool } from './search.js'; +import { readTool } from './read.js'; +import { contextTool } from './context.js'; +import { proposeChangeTool } from './propose_change.js'; + +// The shared registry. Adding a tool later is a one-line registerTool() call +// here (see spec §7 — extensible tool registry). A future MCP server can +// import this same registry and re-expose toAnthropicTools(). +export const companionRegistry = createRegistry(); +companionRegistry.registerTool(searchTool); +companionRegistry.registerTool(readTool); +companionRegistry.registerTool(contextTool); +companionRegistry.registerTool(proposeChangeTool); diff --git a/tests/ai/agent/tools/index.test.js b/tests/ai/agent/tools/index.test.js new file mode 100644 index 0000000..2a9a5cf --- /dev/null +++ b/tests/ai/agent/tools/index.test.js @@ -0,0 +1,13 @@ +import { describe, it, expect } from 'vitest'; +import { companionRegistry } from '../../../../lib/ai/agent/tools/index.js'; + +describe('companion registry', () => { + it('registers exactly the four v1 tools', () => { + expect(companionRegistry.listTools().map(t => t.name).sort()) + .toEqual(['context', 'propose_change', 'read', 'search']); + }); + it('exposes them in Anthropic shape', () => { + const tools = companionRegistry.toAnthropicTools(); + expect(tools.every(t => t.name && t.input_schema && !('handler' in t))).toBe(true); + }); +});