Something went wrong. Try again.
Something went wrong. Try again.
1234567import { Type, type Static } from '@sinclair/typebox';import type { Tool } from '@/contracts/tool';import type { CodeIntelligenceProvider } from '@/contracts/code-intelligence';import { formatSymbol, errorResult, validate } from './common';export const SymbolSchema = Type.Object({ path: Type.String({ minLength: 1 }), name: Type.String({ minLength: 1 }) });export function createSymbolTool(provider: CodeIntelligenceProvider): Tool<typeof SymbolSchema> { return { name: 'code_symbol', description: 'Find exact declaration matches and bounded read coordinates.', inputSchema: SymbolSchema, isReadOnly: true, async execute(input: Static<typeof SymbolSchema>) { const invalid = validate(SymbolSchema, input); if (invalid) return invalid; try { const matches = provider.symbol(input.path, input.name); const text = matches.length === 0 ? `No exact symbol matches for ${input.name}` : matches.map((symbol) => `${formatSymbol(symbol)}${symbol.range ? ` read { path: ${input.path}, offset: ${symbol.range[0] + 1}, limit: ${symbol.range[1] - symbol.range[0] + 1} }` : ''}`).join('\n'); return { content: { kind: 'text', text: text.slice(0, 4000) }, isError: false }; } catch (error) { return errorResult(error); } } }; }