From 0745849ff6e1d92f165fa99acc7c6e82cb104278 Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Sun, 7 Jun 2026 17:57:29 +0000 Subject: [PATCH] feat(server): add boocontext deep analysis tools and synthesis pipeline - get_symbol_details: type signature, definition location, usage count - get_call_graph: callers, callees, transitive references - get_blast_radius added to SYNTHESIS_TOOLS --- apps/server/src/services/synthesisPipeline.ts | 1 + .../tools/codecontext/get_call_graph.ts | 31 +++++++++++++++++++ .../tools/codecontext/get_symbol_details.ts | 31 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 apps/server/src/services/tools/codecontext/get_call_graph.ts create mode 100644 apps/server/src/services/tools/codecontext/get_symbol_details.ts diff --git a/apps/server/src/services/synthesisPipeline.ts b/apps/server/src/services/synthesisPipeline.ts index 7b31da0..1646a89 100644 --- a/apps/server/src/services/synthesisPipeline.ts +++ b/apps/server/src/services/synthesisPipeline.ts @@ -35,6 +35,7 @@ export const SYNTHESIS_TOOLS: ReadonlySet = new Set([ 'get_codebase_overview', 'get_framework_analysis', 'get_semantic_neighborhoods', + 'get_blast_radius', ]); const TOP_N_FILES = 5; diff --git a/apps/server/src/services/tools/codecontext/get_call_graph.ts b/apps/server/src/services/tools/codecontext/get_call_graph.ts new file mode 100644 index 0000000..c6b5b5e --- /dev/null +++ b/apps/server/src/services/tools/codecontext/get_call_graph.ts @@ -0,0 +1,31 @@ +import { z } from 'zod'; +import { makeCodecontextTool } from './factory.js'; + +export const GetCallGraphInput = z.object({ + symbol: z.string().describe('Symbol name to analyze'), + depth: z.number().int().min(1).max(5).optional().describe('Max traversal depth (default 2)'), +}); +export type GetCallGraphInputT = z.infer; + +const DESCRIPTION = + 'Returns a call graph for a function or method: callers, callees, and transitive references. ' + + 'Use to understand how a symbol is invoked and what it depends on.'; + +const { toolDef: getCallGraph, execute: executeGetCallGraph } = + makeCodecontextTool({ + name: 'get_call_graph', + schema: GetCallGraphInput, + description: DESCRIPTION, + jsonParameters: { + type: 'object', + properties: { + symbol: { type: 'string', description: 'Symbol name to analyze' }, + depth: { type: 'number', description: 'Max traversal depth (default 2)' }, + }, + required: ['symbol'], + additionalProperties: false, + }, + mapArgs: (input) => ({ symbol: input.symbol, depth: input.depth ?? 2 }), + }); + +export { getCallGraph, executeGetCallGraph }; diff --git a/apps/server/src/services/tools/codecontext/get_symbol_details.ts b/apps/server/src/services/tools/codecontext/get_symbol_details.ts new file mode 100644 index 0000000..d2bec3d --- /dev/null +++ b/apps/server/src/services/tools/codecontext/get_symbol_details.ts @@ -0,0 +1,31 @@ +import { z } from 'zod'; +import { makeCodecontextTool } from './factory.js'; + +export const GetSymbolDetailsInput = z.object({ + symbol: z.string().describe('Symbol name to resolve'), + file_path: z.string().optional().describe('Optional file path to narrow search'), +}); +export type GetSymbolDetailsInputT = z.infer; + +const DESCRIPTION = + 'Returns type signature, definition location, and usage count for a named symbol. ' + + 'Use after get_codebase_overview to dive deeper into specific functions, classes, or variables.'; + +const { toolDef: getSymbolDetails, execute: executeGetSymbolDetails } = + makeCodecontextTool({ + name: 'get_symbol_details', + schema: GetSymbolDetailsInput, + description: DESCRIPTION, + jsonParameters: { + type: 'object', + properties: { + symbol: { type: 'string', description: 'Symbol name to resolve' }, + file_path: { type: 'string', description: 'Optional file path to narrow search' }, + }, + required: ['symbol'], + additionalProperties: false, + }, + mapArgs: (input) => ({ symbol: input.symbol, file_path: input.file_path }), + }); + +export { getSymbolDetails, executeGetSymbolDetails };