Phase 3: get_wiki_article tool wraps codesight_get_wiki_article MCP (cached, persistent codebase wiki). DCP compress toggle on get_codebase_overview (compress=true for large projects >50 files). Phase 4: Deprecation markers on Go codecontext sidecar. Warning log in callCodecontext(), deprecation comments in factory.ts and docker-compose.yml. Sidecar remains functional — removal deferred.
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { z } from 'zod';
|
|
import type { ToolDef } from '../types.js';
|
|
import { callCodecontext, type CodecontextResponse } from '../../codecontext_client.js';
|
|
|
|
// DEPRECATED (Phase 4, Domain 2, v2.8.14): This factory builds ToolDefs that
|
|
// route through the Go codecontext sidecar via callCodecontext(). Superseded
|
|
// by direct boocontext MCP tool wrappers. Keep functional for backward
|
|
// compatibility — old codecontext tools still use HTTP. New tools should use
|
|
// the boocontext MCP server instead of adding entries here.
|
|
//
|
|
// Shared factory for the 12 codecontext shim ToolDefs.
|
|
// Each shim provides name/schema/description/jsonParameters/mapArgs; the
|
|
// factory builds the ToolDef and returns both the ToolDef and the standalone
|
|
// execute function (used by tests that inject a custom fetcher).
|
|
export function makeCodecontextTool<TInput>(opts: {
|
|
name: string;
|
|
schema: z.ZodType<TInput>;
|
|
description: string;
|
|
jsonParameters: Record<string, unknown>;
|
|
mapArgs: (input: TInput) => Record<string, unknown>;
|
|
}): {
|
|
toolDef: ToolDef<TInput>;
|
|
execute: (input: TInput, projectPath: string, fetcher?: typeof fetch) => Promise<CodecontextResponse>;
|
|
} {
|
|
const { name, schema, description, jsonParameters, mapArgs } = opts;
|
|
|
|
async function execute(
|
|
input: TInput,
|
|
projectPath: string,
|
|
fetcher: typeof fetch = fetch,
|
|
): Promise<CodecontextResponse> {
|
|
return callCodecontext({ toolName: name, args: mapArgs(input), projectPath }, fetcher);
|
|
}
|
|
|
|
const toolDef: ToolDef<TInput> = {
|
|
name,
|
|
description,
|
|
inputSchema: schema,
|
|
jsonSchema: {
|
|
type: 'function',
|
|
function: { name, description, parameters: jsonParameters },
|
|
},
|
|
async execute(input, projectRoot) {
|
|
return execute(input, projectRoot);
|
|
},
|
|
};
|
|
|
|
return { toolDef, execute };
|
|
}
|