import { type ToolDefinition } from '@opencode-ai/plugin'; /** * Call Graph — Native tool using @ast-grep/napi tree-sitter * * Extracts call relationships from TypeScript/JavaScript files and builds * an in-memory adjacency list for query operations. * * Tools: * - call_graph_extract: Extract all calls from a single file * - call_graph_callees: Who does this function call? * - call_graph_callers: Who calls this function? * - call_graph_path: Shortest call path between two functions */ interface CallSite { callee: string; caller: string; line: number; col: number; type: 'call' | 'method' | 'constructor' | 'require' | 'import'; file: string; } interface SymbolEntry { callers: Set; callees: Set; } interface CallGraph { symbols: Map; fileIndex: Map; } /** * Extract all call sites from a single file. * Uses @ast-grep/napi for AST pattern matching. */ export declare function extractCalls(filePath: string): CallSite[]; /** * Build an in-memory call graph from all source files in a directory. * Returns an adjacency list keyed by symbol name. */ export declare function buildCallGraph(rootPath: string): CallGraph; export interface CalleeInfo { name: string; type: string; line: number; file: string; } /** * Get all functions that `functionName` calls (callees). */ export declare function getCallees(functionName: string, rootPath: string): CalleeInfo[]; /** * Get all functions that call `functionName` (callers). */ export declare function getCallers(functionName: string, rootPath: string): CalleeInfo[]; /** * Find the shortest call path from `from` to `to` using BFS. * Returns array of symbol names representing the path, or null if no path. */ export declare function getCallPath(from: string, to: string, rootPath: string): string[] | null; export declare const callGraphExtractTool: ToolDefinition; export declare const callGraphCalleesTool: ToolDefinition; export declare const callGraphCallersTool: ToolDefinition; export declare const callGraphPathTool: ToolDefinition; export {};