@colbymchenry/codegraph 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +122 -57
  2. package/dist/bin/codegraph.d.ts +25 -0
  3. package/dist/bin/node-version-check.d.ts +37 -0
  4. package/dist/bin/uninstall.d.ts +14 -0
  5. package/dist/context/formatter.d.ts +30 -0
  6. package/dist/context/index.d.ts +110 -0
  7. package/dist/db/index.d.ts +101 -0
  8. package/dist/db/migrations.d.ts +44 -0
  9. package/dist/db/queries.d.ts +344 -0
  10. package/dist/db/sqlite-adapter.d.ts +46 -0
  11. package/dist/directory.d.ts +57 -0
  12. package/dist/errors.d.ts +136 -0
  13. package/dist/extraction/dfm-extractor.d.ts +31 -0
  14. package/dist/extraction/generated-detection.d.ts +30 -0
  15. package/dist/extraction/grammars.d.ts +100 -0
  16. package/dist/extraction/index.d.ts +138 -0
  17. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  18. package/dist/extraction/languages/csharp.d.ts +3 -0
  19. package/dist/extraction/languages/dart.d.ts +3 -0
  20. package/dist/extraction/languages/go.d.ts +3 -0
  21. package/dist/extraction/languages/index.d.ts +10 -0
  22. package/dist/extraction/languages/java.d.ts +3 -0
  23. package/dist/extraction/languages/javascript.d.ts +3 -0
  24. package/dist/extraction/languages/kotlin.d.ts +3 -0
  25. package/dist/extraction/languages/lua.d.ts +3 -0
  26. package/dist/extraction/languages/luau.d.ts +3 -0
  27. package/dist/extraction/languages/objc.d.ts +3 -0
  28. package/dist/extraction/languages/pascal.d.ts +3 -0
  29. package/dist/extraction/languages/php.d.ts +3 -0
  30. package/dist/extraction/languages/python.d.ts +3 -0
  31. package/dist/extraction/languages/ruby.d.ts +3 -0
  32. package/dist/extraction/languages/rust.d.ts +3 -0
  33. package/dist/extraction/languages/scala.d.ts +3 -0
  34. package/dist/extraction/languages/swift.d.ts +3 -0
  35. package/dist/extraction/languages/typescript.d.ts +3 -0
  36. package/dist/extraction/liquid-extractor.d.ts +52 -0
  37. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  38. package/dist/extraction/parse-worker.d.ts +8 -0
  39. package/dist/extraction/svelte-extractor.d.ts +56 -0
  40. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  41. package/dist/extraction/tree-sitter-types.d.ts +193 -0
  42. package/dist/extraction/tree-sitter.d.ts +291 -0
  43. package/dist/extraction/vue-extractor.d.ts +36 -0
  44. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  45. package/dist/graph/index.d.ts +8 -0
  46. package/dist/graph/queries.d.ts +106 -0
  47. package/dist/graph/traversal.d.ts +127 -0
  48. package/dist/index.d.ts +492 -0
  49. package/dist/installer/config-writer.d.ts +28 -0
  50. package/dist/installer/index.d.ts +100 -0
  51. package/dist/installer/instructions-template.d.ts +18 -0
  52. package/dist/installer/targets/antigravity.d.ts +57 -0
  53. package/dist/installer/targets/claude.d.ts +56 -0
  54. package/dist/installer/targets/codex.d.ts +18 -0
  55. package/dist/installer/targets/cursor.d.ts +35 -0
  56. package/dist/installer/targets/gemini.d.ts +26 -0
  57. package/dist/installer/targets/hermes.d.ts +18 -0
  58. package/dist/installer/targets/kiro.d.ts +27 -0
  59. package/dist/installer/targets/opencode.d.ts +30 -0
  60. package/dist/installer/targets/registry.d.ts +35 -0
  61. package/dist/installer/targets/shared.d.ts +77 -0
  62. package/dist/installer/targets/toml.d.ts +52 -0
  63. package/dist/installer/targets/types.d.ts +101 -0
  64. package/dist/mcp/daemon-paths.d.ts +46 -0
  65. package/dist/mcp/daemon.d.ts +161 -0
  66. package/dist/mcp/engine.d.ts +105 -0
  67. package/dist/mcp/index.d.ts +112 -0
  68. package/dist/mcp/proxy.d.ts +81 -0
  69. package/dist/mcp/server-instructions.d.ts +19 -0
  70. package/dist/mcp/session.d.ts +77 -0
  71. package/dist/mcp/tools.d.ts +423 -0
  72. package/dist/mcp/transport.d.ts +188 -0
  73. package/dist/mcp/version.d.ts +19 -0
  74. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  75. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  76. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  77. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  78. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  79. package/dist/resolution/frameworks/express.d.ts +8 -0
  80. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  81. package/dist/resolution/frameworks/go.d.ts +8 -0
  82. package/dist/resolution/frameworks/index.d.ts +48 -0
  83. package/dist/resolution/frameworks/java.d.ts +8 -0
  84. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  85. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  86. package/dist/resolution/frameworks/play.d.ts +19 -0
  87. package/dist/resolution/frameworks/python.d.ts +10 -0
  88. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  89. package/dist/resolution/frameworks/react.d.ts +8 -0
  90. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  91. package/dist/resolution/frameworks/rust.d.ts +8 -0
  92. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  93. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  94. package/dist/resolution/frameworks/swift.d.ts +10 -0
  95. package/dist/resolution/frameworks/vue.d.ts +9 -0
  96. package/dist/resolution/go-module.d.ts +26 -0
  97. package/dist/resolution/import-resolver.d.ts +68 -0
  98. package/dist/resolution/index.d.ts +116 -0
  99. package/dist/resolution/lru-cache.d.ts +24 -0
  100. package/dist/resolution/name-matcher.d.ts +32 -0
  101. package/dist/resolution/path-aliases.d.ts +68 -0
  102. package/dist/resolution/strip-comments.d.ts +27 -0
  103. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  104. package/dist/resolution/types.d.ts +209 -0
  105. package/dist/search/query-parser.d.ts +57 -0
  106. package/dist/search/query-utils.d.ts +53 -0
  107. package/dist/sync/git-hooks.d.ts +45 -0
  108. package/dist/sync/index.d.ts +19 -0
  109. package/dist/sync/watch-policy.d.ts +48 -0
  110. package/dist/sync/watcher.d.ts +191 -0
  111. package/dist/sync/worktree.d.ts +54 -0
  112. package/dist/types.d.ts +369 -0
  113. package/dist/ui/glyphs.d.ts +42 -0
  114. package/dist/ui/shimmer-progress.d.ts +11 -0
  115. package/dist/ui/shimmer-worker.d.ts +2 -0
  116. package/dist/ui/types.d.ts +17 -0
  117. package/dist/utils.d.ts +205 -0
  118. package/npm-sdk.js +75 -0
  119. package/package.json +18 -7
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Graph Traversal Algorithms
3
+ *
4
+ * BFS and DFS traversal for the code knowledge graph.
5
+ */
6
+ import { Node, Edge, Subgraph, TraversalOptions, EdgeKind } from '../types';
7
+ import { QueryBuilder } from '../db/queries';
8
+ /**
9
+ * Graph traverser for BFS and DFS traversal
10
+ */
11
+ export declare class GraphTraverser {
12
+ private queries;
13
+ constructor(queries: QueryBuilder);
14
+ /**
15
+ * Traverse the graph using breadth-first search
16
+ *
17
+ * @param startId - Starting node ID
18
+ * @param options - Traversal options
19
+ * @returns Subgraph containing traversed nodes and edges
20
+ */
21
+ traverseBFS(startId: string, options?: TraversalOptions): Subgraph;
22
+ /**
23
+ * Traverse the graph using depth-first search
24
+ *
25
+ * @param startId - Starting node ID
26
+ * @param options - Traversal options
27
+ * @returns Subgraph containing traversed nodes and edges
28
+ */
29
+ traverseDFS(startId: string, options?: TraversalOptions): Subgraph;
30
+ /**
31
+ * Recursive DFS helper
32
+ */
33
+ private dfsRecursive;
34
+ /**
35
+ * Get adjacent edges based on direction
36
+ */
37
+ private getAdjacentEdges;
38
+ /**
39
+ * Find all callers of a function/method
40
+ *
41
+ * @param nodeId - ID of the function/method node
42
+ * @param maxDepth - Maximum depth to traverse (default: 1)
43
+ * @returns Array of nodes that call this function
44
+ */
45
+ getCallers(nodeId: string, maxDepth?: number): Array<{
46
+ node: Node;
47
+ edge: Edge;
48
+ }>;
49
+ private getCallersRecursive;
50
+ /**
51
+ * Find all functions/methods called by a function
52
+ *
53
+ * @param nodeId - ID of the function/method node
54
+ * @param maxDepth - Maximum depth to traverse (default: 1)
55
+ * @returns Array of nodes called by this function
56
+ */
57
+ getCallees(nodeId: string, maxDepth?: number): Array<{
58
+ node: Node;
59
+ edge: Edge;
60
+ }>;
61
+ private getCalleesRecursive;
62
+ /**
63
+ * Get the call graph for a function (both callers and callees)
64
+ *
65
+ * @param nodeId - ID of the function/method node
66
+ * @param depth - Maximum depth in each direction (default: 2)
67
+ * @returns Subgraph containing the call graph
68
+ */
69
+ getCallGraph(nodeId: string, depth?: number): Subgraph;
70
+ /**
71
+ * Get the type hierarchy for a class/interface
72
+ *
73
+ * @param nodeId - ID of the class/interface node
74
+ * @returns Subgraph containing the type hierarchy
75
+ */
76
+ getTypeHierarchy(nodeId: string): Subgraph;
77
+ private getTypeAncestors;
78
+ private getTypeDescendants;
79
+ /**
80
+ * Find all usages of a symbol
81
+ *
82
+ * @param nodeId - ID of the symbol node
83
+ * @returns Array of nodes and edges that reference this symbol
84
+ */
85
+ findUsages(nodeId: string): Array<{
86
+ node: Node;
87
+ edge: Edge;
88
+ }>;
89
+ /**
90
+ * Calculate the impact radius of a node
91
+ *
92
+ * Returns all nodes that could be affected by changes to this node.
93
+ *
94
+ * @param nodeId - ID of the node
95
+ * @param maxDepth - Maximum depth to traverse (default: 3)
96
+ * @returns Subgraph containing potentially impacted nodes
97
+ */
98
+ getImpactRadius(nodeId: string, maxDepth?: number): Subgraph;
99
+ private getImpactRecursive;
100
+ /**
101
+ * Find the shortest path between two nodes
102
+ *
103
+ * @param fromId - Starting node ID
104
+ * @param toId - Target node ID
105
+ * @param edgeKinds - Edge types to consider (all if empty)
106
+ * @returns Array of nodes and edges forming the path, or null if no path exists
107
+ */
108
+ findPath(fromId: string, toId: string, edgeKinds?: EdgeKind[]): Array<{
109
+ node: Node;
110
+ edge: Edge | null;
111
+ }> | null;
112
+ /**
113
+ * Get the containment hierarchy for a node (ancestors)
114
+ *
115
+ * @param nodeId - ID of the node
116
+ * @returns Array of ancestor nodes from immediate parent to root
117
+ */
118
+ getAncestors(nodeId: string): Node[];
119
+ /**
120
+ * Get immediate children of a node
121
+ *
122
+ * @param nodeId - ID of the node
123
+ * @returns Array of child nodes
124
+ */
125
+ getChildren(nodeId: string): Node[];
126
+ }
127
+ //# sourceMappingURL=traversal.d.ts.map
@@ -0,0 +1,492 @@
1
+ /**
2
+ * CodeGraph
3
+ *
4
+ * A local-first code intelligence system that builds a semantic
5
+ * knowledge graph from any codebase.
6
+ */
7
+ import { Node, Edge, FileRecord, ExtractionResult, Subgraph, TraversalOptions, SearchOptions, SearchResult, Context, GraphStats, TaskInput, TaskContext, BuildContextOptions, FindRelevantContextOptions } from './types';
8
+ import { IndexProgress, IndexResult, SyncResult } from './extraction';
9
+ import { ResolutionResult } from './resolution';
10
+ import { WatchOptions, PendingFile } from './sync';
11
+ export * from './types';
12
+ export { getDatabasePath, DatabaseConnection } from './db';
13
+ export { QueryBuilder } from './db/queries';
14
+ export { getCodeGraphDir, isInitialized, findNearestCodeGraphRoot, CODEGRAPH_DIR, } from './directory';
15
+ export { IndexProgress, IndexResult, SyncResult } from './extraction';
16
+ export { detectLanguage, isLanguageSupported, isGrammarLoaded, getSupportedLanguages, initGrammars, loadGrammarsForLanguages, loadAllGrammars } from './extraction';
17
+ export { ResolutionResult } from './resolution';
18
+ export { CodeGraphError, FileError, ParseError, DatabaseError, SearchError, VectorError, ConfigError, Logger, setLogger, getLogger, silentLogger, defaultLogger, } from './errors';
19
+ export { Mutex, FileLock, processInBatches, debounce, throttle, MemoryMonitor } from './utils';
20
+ export { FileWatcher, WatchOptions, PendingFile, LockUnavailableError } from './sync';
21
+ export { MCPServer } from './mcp';
22
+ /**
23
+ * Options for initializing a new CodeGraph project
24
+ */
25
+ export interface InitOptions {
26
+ /** Whether to run initial indexing after init */
27
+ index?: boolean;
28
+ /** Progress callback for indexing */
29
+ onProgress?: (progress: IndexProgress) => void;
30
+ }
31
+ /**
32
+ * Options for opening an existing CodeGraph project
33
+ */
34
+ export interface OpenOptions {
35
+ /** Whether to run sync if files have changed */
36
+ sync?: boolean;
37
+ /** Whether to run in read-only mode */
38
+ readOnly?: boolean;
39
+ }
40
+ /**
41
+ * Options for indexing
42
+ */
43
+ export interface IndexOptions {
44
+ /** Progress callback */
45
+ onProgress?: (progress: IndexProgress) => void;
46
+ /** Abort signal for cancellation */
47
+ signal?: AbortSignal;
48
+ /** Enable verbose logging (worker lifecycle, memory, timeouts) */
49
+ verbose?: boolean;
50
+ }
51
+ /**
52
+ * Main CodeGraph class
53
+ *
54
+ * Provides the primary interface for interacting with the code knowledge graph.
55
+ */
56
+ export declare class CodeGraph {
57
+ private db;
58
+ private queries;
59
+ private projectRoot;
60
+ private orchestrator;
61
+ private resolver;
62
+ private graphManager;
63
+ private traverser;
64
+ private contextBuilder;
65
+ private indexMutex;
66
+ private fileLock;
67
+ private watcher;
68
+ private constructor();
69
+ /**
70
+ * Initialize a new CodeGraph project
71
+ *
72
+ * Creates the .CodeGraph directory, database, and configuration.
73
+ *
74
+ * @param projectRoot - Path to the project root directory
75
+ * @param options - Initialization options
76
+ * @returns A new CodeGraph instance
77
+ */
78
+ static init(projectRoot: string, options?: InitOptions): Promise<CodeGraph>;
79
+ /**
80
+ * Initialize synchronously (without indexing)
81
+ */
82
+ static initSync(projectRoot: string): CodeGraph;
83
+ /**
84
+ * Open an existing CodeGraph project
85
+ *
86
+ * @param projectRoot - Path to the project root directory
87
+ * @param options - Open options
88
+ * @returns A CodeGraph instance
89
+ */
90
+ static open(projectRoot: string, options?: OpenOptions): Promise<CodeGraph>;
91
+ /**
92
+ * Open synchronously (without sync)
93
+ */
94
+ static openSync(projectRoot: string): CodeGraph;
95
+ /**
96
+ * Check if a directory has been initialized as a CodeGraph project
97
+ */
98
+ static isInitialized(projectRoot: string): boolean;
99
+ /**
100
+ * Close the CodeGraph instance and release resources
101
+ */
102
+ close(): void;
103
+ /**
104
+ * Get the project root directory
105
+ */
106
+ getProjectRoot(): string;
107
+ /**
108
+ * Index all files in the project
109
+ *
110
+ * Uses a mutex to prevent concurrent indexing operations.
111
+ */
112
+ indexAll(options?: IndexOptions): Promise<IndexResult>;
113
+ /**
114
+ * Index specific files
115
+ *
116
+ * Uses a mutex to prevent concurrent indexing operations.
117
+ */
118
+ indexFiles(filePaths: string[]): Promise<IndexResult>;
119
+ /**
120
+ * Sync with current file state (incremental update)
121
+ *
122
+ * Uses a mutex to prevent concurrent indexing operations.
123
+ */
124
+ sync(options?: IndexOptions): Promise<SyncResult>;
125
+ /**
126
+ * Check if an indexing operation is currently in progress
127
+ */
128
+ isIndexing(): boolean;
129
+ /**
130
+ * Start watching for file changes and auto-syncing.
131
+ *
132
+ * Uses native OS file events (FSEvents on macOS, inotify on Linux 19+,
133
+ * ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing.
134
+ *
135
+ * @param options - Watch options (debounce delay, callbacks)
136
+ * @returns true if watching started successfully
137
+ */
138
+ watch(options?: WatchOptions): boolean;
139
+ /**
140
+ * Stop watching for file changes.
141
+ */
142
+ unwatch(): void;
143
+ /**
144
+ * Check if the file watcher is active.
145
+ */
146
+ isWatching(): boolean;
147
+ /**
148
+ * Files seen by the file watcher since the last successful sync —
149
+ * the per-file "stale" signal MCP tools attach to responses so an agent
150
+ * can fall back to {@link Read} for just the affected file without
151
+ * waiting for a debounced sync to complete (issue #403).
152
+ *
153
+ * Returns an empty list when the watcher isn't active, or no events have
154
+ * arrived. Each entry includes `firstSeenMs` and `lastSeenMs` (wall-clock
155
+ * `Date.now()` values) so callers can render "edited Nms ago", plus an
156
+ * `indexing` flag indicating whether the in-flight sync (if any) will
157
+ * absorb that file.
158
+ */
159
+ getPendingFiles(): PendingFile[];
160
+ /**
161
+ * Resolves once the file watcher has finished its initial chokidar scan.
162
+ * Useful for tests that need a deterministic boundary before asserting on
163
+ * `getPendingFiles()`. Resolves immediately when no watcher is active.
164
+ */
165
+ waitUntilWatcherReady(timeoutMs?: number): Promise<void>;
166
+ /**
167
+ * Get files that have changed since last index
168
+ */
169
+ getChangedFiles(): {
170
+ added: string[];
171
+ modified: string[];
172
+ removed: string[];
173
+ };
174
+ /**
175
+ * Extract nodes and edges from source code (without storing)
176
+ */
177
+ extractFromSource(filePath: string, source: string): ExtractionResult;
178
+ /**
179
+ * Resolve unresolved references and create edges
180
+ *
181
+ * This method takes unresolved references from extraction and attempts
182
+ * to resolve them using multiple strategies:
183
+ * - Framework-specific patterns (React, Express, Laravel)
184
+ * - Import-based resolution
185
+ * - Name-based symbol matching
186
+ */
187
+ resolveReferences(onProgress?: (current: number, total: number) => void): ResolutionResult;
188
+ /**
189
+ * Resolve references in batches to keep memory bounded on large codebases.
190
+ * Processes chunks of unresolved refs, persisting results after each batch.
191
+ */
192
+ resolveReferencesBatched(onProgress?: (current: number, total: number) => void): Promise<ResolutionResult>;
193
+ /**
194
+ * Get detected frameworks in the project
195
+ */
196
+ getDetectedFrameworks(): string[];
197
+ /**
198
+ * Re-initialize the resolver (useful after adding new files)
199
+ */
200
+ reinitializeResolver(): void;
201
+ /**
202
+ * Get statistics about the knowledge graph
203
+ */
204
+ getStats(): GraphStats;
205
+ /**
206
+ * Active SQLite backend for this project's connection (`node-sqlite` — Node's
207
+ * built-in real-SQLite module). Surfaced via `codegraph status` and the
208
+ * `codegraph_status` MCP tool alongside the effective journal mode.
209
+ */
210
+ getBackend(): import('./db').SqliteBackend;
211
+ /**
212
+ * The journal mode actually in effect ('wal', 'delete', …). 'wal' means
213
+ * readers never block on a concurrent writer; anything else means they can,
214
+ * which is the precondition for the "database is locked" failures in issue
215
+ * #238. Surfaced via `codegraph status` and the `codegraph_status` MCP tool.
216
+ */
217
+ getJournalMode(): string;
218
+ /**
219
+ * Get a node by ID
220
+ */
221
+ getNode(id: string): Node | null;
222
+ /**
223
+ * Get all nodes in a file
224
+ */
225
+ getNodesInFile(filePath: string): Node[];
226
+ /**
227
+ * Get all nodes of a specific kind
228
+ */
229
+ getNodesByKind(kind: Node['kind']): Node[];
230
+ /**
231
+ * Search nodes by text
232
+ */
233
+ searchNodes(query: string, options?: SearchOptions): SearchResult[];
234
+ /**
235
+ * Find the project's "primary route file" — the file with the densest
236
+ * concentration of framework-emitted `route` nodes (≥3 routes, ≥30%
237
+ * of all non-test routes). Used to inline the routing config in
238
+ * `codegraph_context` responses on small realworld template repos
239
+ * (rails-realworld, laravel-realworld, drupal-admintoolbar, …) where
240
+ * Glob+Read of `routes.rb`/`urls.py`/etc. otherwise beats codegraph.
241
+ */
242
+ getTopRouteFile(): {
243
+ filePath: string;
244
+ routeCount: number;
245
+ totalRoutes: number;
246
+ } | null;
247
+ /**
248
+ * Build a URL → handler routing manifest from the index. Each entry
249
+ * pairs a route node (URL + method) with its handler function/method
250
+ * via the `references` edge that framework resolvers emit. Returns
251
+ * null when fewer than 3 valid (non-test) routes exist.
252
+ */
253
+ getRoutingManifest(limit?: number): {
254
+ entries: Array<{
255
+ url: string;
256
+ handler: string;
257
+ handlerFile: string;
258
+ handlerLine: number;
259
+ handlerKind: string;
260
+ }>;
261
+ topHandlerFile: string | null;
262
+ topHandlerFileCount: number;
263
+ totalRoutes: number;
264
+ } | null;
265
+ /**
266
+ * Get outgoing edges from a node
267
+ */
268
+ getOutgoingEdges(nodeId: string): Edge[];
269
+ /**
270
+ * Get incoming edges to a node
271
+ */
272
+ getIncomingEdges(nodeId: string): Edge[];
273
+ /**
274
+ * Get a file record by path
275
+ */
276
+ getFile(filePath: string): FileRecord | null;
277
+ /**
278
+ * Get all tracked files
279
+ */
280
+ getFiles(): FileRecord[];
281
+ /**
282
+ * Get the context for a node (ancestors, children, references)
283
+ *
284
+ * Returns comprehensive context about a node including its containment
285
+ * hierarchy, children, incoming/outgoing references, type information,
286
+ * and relevant imports.
287
+ *
288
+ * @param nodeId - ID of the focal node
289
+ * @returns Context object with all related information
290
+ */
291
+ getContext(nodeId: string): Context;
292
+ /**
293
+ * Traverse the graph from a starting node
294
+ *
295
+ * Uses breadth-first search by default. Supports filtering by edge types,
296
+ * node types, and traversal direction.
297
+ *
298
+ * @param startId - Starting node ID
299
+ * @param options - Traversal options
300
+ * @returns Subgraph containing traversed nodes and edges
301
+ */
302
+ traverse(startId: string, options?: TraversalOptions): Subgraph;
303
+ /**
304
+ * Get the call graph for a function
305
+ *
306
+ * Returns both callers (functions that call this function) and
307
+ * callees (functions called by this function) up to the specified depth.
308
+ *
309
+ * @param nodeId - ID of the function/method node
310
+ * @param depth - Maximum depth in each direction (default: 2)
311
+ * @returns Subgraph containing the call graph
312
+ */
313
+ getCallGraph(nodeId: string, depth?: number): Subgraph;
314
+ /**
315
+ * Get the type hierarchy for a class/interface
316
+ *
317
+ * Returns both ancestors (types this extends/implements) and
318
+ * descendants (types that extend/implement this).
319
+ *
320
+ * @param nodeId - ID of the class/interface node
321
+ * @returns Subgraph containing the type hierarchy
322
+ */
323
+ getTypeHierarchy(nodeId: string): Subgraph;
324
+ /**
325
+ * Find all usages of a symbol
326
+ *
327
+ * Returns all nodes that reference the specified symbol through
328
+ * any edge type (calls, references, type_of, etc.).
329
+ *
330
+ * @param nodeId - ID of the symbol node
331
+ * @returns Array of nodes and edges that reference this symbol
332
+ */
333
+ findUsages(nodeId: string): Array<{
334
+ node: Node;
335
+ edge: Edge;
336
+ }>;
337
+ /**
338
+ * Get callers of a function/method
339
+ *
340
+ * @param nodeId - ID of the function/method node
341
+ * @param maxDepth - Maximum depth to traverse (default: 1)
342
+ * @returns Array of nodes that call this function
343
+ */
344
+ getCallers(nodeId: string, maxDepth?: number): Array<{
345
+ node: Node;
346
+ edge: Edge;
347
+ }>;
348
+ /**
349
+ * Get callees of a function/method
350
+ *
351
+ * @param nodeId - ID of the function/method node
352
+ * @param maxDepth - Maximum depth to traverse (default: 1)
353
+ * @returns Array of nodes called by this function
354
+ */
355
+ getCallees(nodeId: string, maxDepth?: number): Array<{
356
+ node: Node;
357
+ edge: Edge;
358
+ }>;
359
+ /**
360
+ * Calculate the impact radius of a node
361
+ *
362
+ * Returns all nodes that could be affected by changes to this node.
363
+ *
364
+ * @param nodeId - ID of the node
365
+ * @param maxDepth - Maximum depth to traverse (default: 3)
366
+ * @returns Subgraph containing potentially impacted nodes
367
+ */
368
+ getImpactRadius(nodeId: string, maxDepth?: number): Subgraph;
369
+ /**
370
+ * Find the shortest path between two nodes
371
+ *
372
+ * @param fromId - Starting node ID
373
+ * @param toId - Target node ID
374
+ * @param edgeKinds - Edge types to consider (all if empty)
375
+ * @returns Array of nodes and edges forming the path, or null if no path exists
376
+ */
377
+ findPath(fromId: string, toId: string, edgeKinds?: Edge['kind'][]): Array<{
378
+ node: Node;
379
+ edge: Edge | null;
380
+ }> | null;
381
+ /**
382
+ * Get ancestors of a node in the containment hierarchy
383
+ *
384
+ * @param nodeId - ID of the node
385
+ * @returns Array of ancestor nodes from immediate parent to root
386
+ */
387
+ getAncestors(nodeId: string): Node[];
388
+ /**
389
+ * Get immediate children of a node
390
+ *
391
+ * @param nodeId - ID of the node
392
+ * @returns Array of child nodes
393
+ */
394
+ getChildren(nodeId: string): Node[];
395
+ /**
396
+ * Get dependencies of a file
397
+ *
398
+ * @param filePath - Path to the file
399
+ * @returns Array of file paths this file depends on
400
+ */
401
+ getFileDependencies(filePath: string): string[];
402
+ /**
403
+ * Get dependents of a file
404
+ *
405
+ * @param filePath - Path to the file
406
+ * @returns Array of file paths that depend on this file
407
+ */
408
+ getFileDependents(filePath: string): string[];
409
+ /**
410
+ * Find circular dependencies in the codebase
411
+ *
412
+ * @returns Array of cycles, each cycle is an array of file paths
413
+ */
414
+ findCircularDependencies(): string[][];
415
+ /**
416
+ * Find dead code (unreferenced symbols)
417
+ *
418
+ * @param kinds - Node kinds to check (default: functions, methods, classes)
419
+ * @returns Array of unreferenced nodes
420
+ */
421
+ findDeadCode(kinds?: Node['kind'][]): Node[];
422
+ /**
423
+ * Get complexity metrics for a node
424
+ *
425
+ * @param nodeId - ID of the node
426
+ * @returns Object containing various complexity metrics
427
+ */
428
+ getNodeMetrics(nodeId: string): {
429
+ incomingEdgeCount: number;
430
+ outgoingEdgeCount: number;
431
+ callCount: number;
432
+ callerCount: number;
433
+ childCount: number;
434
+ depth: number;
435
+ };
436
+ /**
437
+ * Get the source code for a node
438
+ *
439
+ * Reads the file and extracts the code between startLine and endLine.
440
+ *
441
+ * @param nodeId - ID of the node
442
+ * @returns Code string or null if not found
443
+ */
444
+ getCode(nodeId: string): Promise<string | null>;
445
+ /**
446
+ * Find relevant subgraph for a query
447
+ *
448
+ * Combines semantic search with graph traversal to find the most
449
+ * relevant nodes and their relationships for a given query.
450
+ *
451
+ * @param query - Natural language query describing the task
452
+ * @param options - Search and traversal options
453
+ * @returns Subgraph of relevant nodes and edges
454
+ */
455
+ findRelevantContext(query: string, options?: FindRelevantContextOptions): Promise<Subgraph>;
456
+ /**
457
+ * Build context for a task
458
+ *
459
+ * Creates comprehensive context by:
460
+ * 1. Running FTS search to find entry points
461
+ * 2. Expanding the graph around entry points
462
+ * 3. Extracting code blocks for key nodes
463
+ * 4. Formatting output for Claude
464
+ *
465
+ * @param input - Task description (string or {title, description})
466
+ * @param options - Build options (maxNodes, includeCode, format, etc.)
467
+ * @returns TaskContext object or formatted string (markdown/JSON)
468
+ */
469
+ buildContext(input: TaskInput, options?: BuildContextOptions): Promise<TaskContext | string>;
470
+ /**
471
+ * Optimize the database (vacuum and analyze)
472
+ */
473
+ optimize(): void;
474
+ /**
475
+ * Clear all data from the graph
476
+ */
477
+ clear(): void;
478
+ /**
479
+ * Alias for close() for backwards compatibility.
480
+ * @deprecated Use close() instead
481
+ */
482
+ destroy(): void;
483
+ /**
484
+ * Completely remove CodeGraph from the project.
485
+ * This closes the database and deletes the .CodeGraph directory.
486
+ *
487
+ * WARNING: This permanently deletes all CodeGraph data for the project.
488
+ */
489
+ uninitialize(): void;
490
+ }
491
+ export default CodeGraph;
492
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Backwards-compat shim — original Claude-only writer functions.
3
+ *
4
+ * The installer now uses the multi-target architecture in
5
+ * `./targets/`. This file is preserved so existing imports (the test
6
+ * suite, downstream tooling) keep working unchanged. Each function
7
+ * delegates to the Claude target. New code should import the target
8
+ * registry from `./targets/registry` directly.
9
+ *
10
+ * @deprecated Use `targets/registry.ts` and the `AgentTarget`
11
+ * abstraction instead.
12
+ */
13
+ export type InstallLocation = 'global' | 'local';
14
+ /**
15
+ * Each shim calls ONLY the named per-file helper — writeMcpConfig
16
+ * writes only the MCP JSON, writePermissions only settings.json. The
17
+ * full multi-file install lives in `claudeTarget.install()` which the
18
+ * new orchestrator uses.
19
+ *
20
+ * There is no `writeClaudeMd` shim anymore: codegraph stopped writing a
21
+ * CLAUDE.md instructions block (issue #529) now that the MCP server's
22
+ * `initialize` instructions are the single source of truth.
23
+ */
24
+ export declare function writeMcpConfig(location: InstallLocation): void;
25
+ export declare function writePermissions(location: InstallLocation): void;
26
+ export declare function hasMcpConfig(location: InstallLocation): boolean;
27
+ export declare function hasPermissions(location: InstallLocation): boolean;
28
+ //# sourceMappingURL=config-writer.d.ts.map