diff --git a/src/lib/copilot/codegraphKnowledge.ts b/src/lib/copilot/codegraphKnowledge.ts index 31e0d23bfa..36919fbac9 100644 --- a/src/lib/copilot/codegraphKnowledge.ts +++ b/src/lib/copilot/codegraphKnowledge.ts @@ -31,27 +31,6 @@ export interface CodeGraphNode { visibility?: string; } -export interface CodeGraphEdge { - id: number; - source: string; - target: string; - kind: string; - line?: number; - metadata?: Record; -} - -export interface CodeGraphFile { - path: string; - language: string; - nodeCount: number; - modifiedAt: number; -} - -export interface CodeGraphSearchResult { - nodes: CodeGraphNode[]; - total: number; -} - // --------------------------------------------------------------------------- // Database access (lazy loaded) // --------------------------------------------------------------------------- @@ -231,30 +210,6 @@ export function listFiles(language?: string, limit = 50): CodeGraphQueryResult { return queryDb(`SELECT * FROM files ORDER BY path LIMIT ?`, [limit]); } -/** - * Get impact analysis: find symbols that depend on a given symbol (transitively). - */ -export function getImpactAnalysis(symbolName: string, depth = 1): CodeGraphQueryResult { - if (depth <= 0) - return { success: false, data: null, error: "Depth must be >= 1", engine: "none" }; - - // Direct callers (depth 1) - const directCallers = findCallers(symbolName); - if (depth === 1) return directCallers; - - // For depth > 1, we'd need recursive CTE or multiple queries. - // For now, just return direct callers with a note. - const result = directCallers; - return { - ...result, - data: (result.data as Record[])?.map((r) => ({ - ...r, - _depth: 1, - _note: `Depth > 1 requires multiple queries. Use searchSymbols() + findCallers() iteratively for deeper analysis.`, - })), - }; -} - /** * Check if CodeGraph DB is available. */ diff --git a/tests/unit/copilot-codegraph-knowledge.test.ts b/tests/unit/copilot-codegraph-knowledge.test.ts new file mode 100644 index 0000000000..fce2886f59 --- /dev/null +++ b/tests/unit/copilot-codegraph-knowledge.test.ts @@ -0,0 +1,34 @@ +import test from "node:test"; +import assert from "node:assert/strict"; + +import { + findCallers, + getCodeGraphStats, + isCodeGraphAvailable, + searchSymbols, +} from "../../src/lib/copilot/codegraphKnowledge.ts"; + +test("CodeGraph knowledge helpers fail closed when the index is unavailable", () => { + assert.equal(isCodeGraphAvailable(), false); + + assert.deepEqual(searchSymbols("handleChatCore"), { + success: false, + data: null, + error: "CodeGraph DB not found", + engine: "none", + }); + + assert.deepEqual(findCallers("handleChatCore"), { + success: false, + data: null, + error: "CodeGraph DB not found", + engine: "none", + }); + + assert.deepEqual(getCodeGraphStats(), { + success: false, + data: null, + error: "CodeGraph DB not found", + engine: "none", + }); +});