This commit is contained in:
Colby McHenry
2026-02-10 02:26:47 -06:00
parent 4c983ba082
commit 2ad03d2f7d
5 changed files with 83 additions and 33 deletions
+18 -1
View File
@@ -259,7 +259,21 @@ export class ToolHandler {
// Cache of opened CodeGraph instances for cross-project queries
private projectCache: Map<string, CodeGraph> = new Map();
constructor(private cg: CodeGraph) {}
constructor(private cg: CodeGraph | null) {}
/**
* Update the default CodeGraph instance (e.g. after lazy initialization)
*/
setDefaultCodeGraph(cg: CodeGraph): void {
this.cg = cg;
}
/**
* Whether a default CodeGraph instance is available
*/
hasDefaultCodeGraph(): boolean {
return this.cg !== null;
}
/**
* Get CodeGraph instance for a project
@@ -272,6 +286,9 @@ export class ToolHandler {
*/
private getCodeGraph(projectPath?: string): CodeGraph {
if (!projectPath) {
if (!this.cg) {
throw new Error('CodeGraph not initialized for this project. Run \'codegraph init\' first.');
}
return this.cg;
}