@colbymchenry/codegraph 0.9.7 → 0.9.9

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 (120) hide show
  1. package/README.md +116 -32
  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 +119 -0
  7. package/dist/context/markers.d.ts +19 -0
  8. package/dist/db/index.d.ts +101 -0
  9. package/dist/db/migrations.d.ts +44 -0
  10. package/dist/db/queries.d.ts +344 -0
  11. package/dist/db/sqlite-adapter.d.ts +46 -0
  12. package/dist/directory.d.ts +57 -0
  13. package/dist/errors.d.ts +136 -0
  14. package/dist/extraction/dfm-extractor.d.ts +31 -0
  15. package/dist/extraction/generated-detection.d.ts +30 -0
  16. package/dist/extraction/grammars.d.ts +100 -0
  17. package/dist/extraction/index.d.ts +138 -0
  18. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  19. package/dist/extraction/languages/csharp.d.ts +3 -0
  20. package/dist/extraction/languages/dart.d.ts +3 -0
  21. package/dist/extraction/languages/go.d.ts +3 -0
  22. package/dist/extraction/languages/index.d.ts +10 -0
  23. package/dist/extraction/languages/java.d.ts +3 -0
  24. package/dist/extraction/languages/javascript.d.ts +3 -0
  25. package/dist/extraction/languages/kotlin.d.ts +3 -0
  26. package/dist/extraction/languages/lua.d.ts +3 -0
  27. package/dist/extraction/languages/luau.d.ts +3 -0
  28. package/dist/extraction/languages/objc.d.ts +3 -0
  29. package/dist/extraction/languages/pascal.d.ts +3 -0
  30. package/dist/extraction/languages/php.d.ts +3 -0
  31. package/dist/extraction/languages/python.d.ts +3 -0
  32. package/dist/extraction/languages/ruby.d.ts +3 -0
  33. package/dist/extraction/languages/rust.d.ts +3 -0
  34. package/dist/extraction/languages/scala.d.ts +3 -0
  35. package/dist/extraction/languages/swift.d.ts +3 -0
  36. package/dist/extraction/languages/typescript.d.ts +3 -0
  37. package/dist/extraction/liquid-extractor.d.ts +52 -0
  38. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  39. package/dist/extraction/parse-worker.d.ts +8 -0
  40. package/dist/extraction/svelte-extractor.d.ts +56 -0
  41. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  42. package/dist/extraction/tree-sitter-types.d.ts +193 -0
  43. package/dist/extraction/tree-sitter.d.ts +317 -0
  44. package/dist/extraction/vue-extractor.d.ts +36 -0
  45. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  46. package/dist/graph/index.d.ts +8 -0
  47. package/dist/graph/queries.d.ts +106 -0
  48. package/dist/graph/traversal.d.ts +127 -0
  49. package/dist/index.d.ts +498 -0
  50. package/dist/installer/config-writer.d.ts +28 -0
  51. package/dist/installer/index.d.ts +100 -0
  52. package/dist/installer/instructions-template.d.ts +18 -0
  53. package/dist/installer/targets/antigravity.d.ts +57 -0
  54. package/dist/installer/targets/claude.d.ts +56 -0
  55. package/dist/installer/targets/codex.d.ts +18 -0
  56. package/dist/installer/targets/cursor.d.ts +35 -0
  57. package/dist/installer/targets/gemini.d.ts +26 -0
  58. package/dist/installer/targets/hermes.d.ts +18 -0
  59. package/dist/installer/targets/kiro.d.ts +27 -0
  60. package/dist/installer/targets/opencode.d.ts +30 -0
  61. package/dist/installer/targets/registry.d.ts +35 -0
  62. package/dist/installer/targets/shared.d.ts +77 -0
  63. package/dist/installer/targets/toml.d.ts +52 -0
  64. package/dist/installer/targets/types.d.ts +101 -0
  65. package/dist/mcp/daemon-paths.d.ts +46 -0
  66. package/dist/mcp/daemon.d.ts +161 -0
  67. package/dist/mcp/engine.d.ts +105 -0
  68. package/dist/mcp/index.d.ts +112 -0
  69. package/dist/mcp/proxy.d.ts +81 -0
  70. package/dist/mcp/server-instructions.d.ts +19 -0
  71. package/dist/mcp/session.d.ts +77 -0
  72. package/dist/mcp/tools.d.ts +413 -0
  73. package/dist/mcp/transport.d.ts +188 -0
  74. package/dist/mcp/version.d.ts +19 -0
  75. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  76. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  77. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  78. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  79. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  80. package/dist/resolution/frameworks/express.d.ts +8 -0
  81. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  82. package/dist/resolution/frameworks/go.d.ts +8 -0
  83. package/dist/resolution/frameworks/index.d.ts +48 -0
  84. package/dist/resolution/frameworks/java.d.ts +8 -0
  85. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  86. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  87. package/dist/resolution/frameworks/play.d.ts +19 -0
  88. package/dist/resolution/frameworks/python.d.ts +10 -0
  89. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  90. package/dist/resolution/frameworks/react.d.ts +8 -0
  91. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  92. package/dist/resolution/frameworks/rust.d.ts +8 -0
  93. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  94. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  95. package/dist/resolution/frameworks/swift.d.ts +10 -0
  96. package/dist/resolution/frameworks/vue.d.ts +9 -0
  97. package/dist/resolution/go-module.d.ts +26 -0
  98. package/dist/resolution/import-resolver.d.ts +68 -0
  99. package/dist/resolution/index.d.ts +116 -0
  100. package/dist/resolution/lru-cache.d.ts +24 -0
  101. package/dist/resolution/name-matcher.d.ts +32 -0
  102. package/dist/resolution/path-aliases.d.ts +68 -0
  103. package/dist/resolution/strip-comments.d.ts +27 -0
  104. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  105. package/dist/resolution/types.d.ts +209 -0
  106. package/dist/search/query-parser.d.ts +57 -0
  107. package/dist/search/query-utils.d.ts +71 -0
  108. package/dist/sync/git-hooks.d.ts +45 -0
  109. package/dist/sync/index.d.ts +19 -0
  110. package/dist/sync/watch-policy.d.ts +48 -0
  111. package/dist/sync/watcher.d.ts +191 -0
  112. package/dist/sync/worktree.d.ts +54 -0
  113. package/dist/types.d.ts +377 -0
  114. package/dist/ui/glyphs.d.ts +42 -0
  115. package/dist/ui/shimmer-progress.d.ts +11 -0
  116. package/dist/ui/shimmer-worker.d.ts +2 -0
  117. package/dist/ui/types.d.ts +17 -0
  118. package/dist/utils.d.ts +205 -0
  119. package/npm-sdk.js +75 -0
  120. package/package.json +18 -7
@@ -0,0 +1,498 @@
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
+ * Get ALL nodes with an exact name (direct index lookup, not FTS-ranked/capped).
232
+ * Used to enumerate every overload of a heavily-overloaded name so the specific
233
+ * definition the caller wants is never dropped below a search cut.
234
+ */
235
+ getNodesByName(name: string): Node[];
236
+ /**
237
+ * Search nodes by text
238
+ */
239
+ searchNodes(query: string, options?: SearchOptions): SearchResult[];
240
+ /**
241
+ * Find the project's "primary route file" — the file with the densest
242
+ * concentration of framework-emitted `route` nodes (≥3 routes, ≥30%
243
+ * of all non-test routes). Used to inline the routing config in
244
+ * `codegraph_explore` responses on small realworld template repos
245
+ * (rails-realworld, laravel-realworld, drupal-admintoolbar, …) where
246
+ * Glob+Read of `routes.rb`/`urls.py`/etc. otherwise beats codegraph.
247
+ */
248
+ getTopRouteFile(): {
249
+ filePath: string;
250
+ routeCount: number;
251
+ totalRoutes: number;
252
+ } | null;
253
+ /**
254
+ * Build a URL → handler routing manifest from the index. Each entry
255
+ * pairs a route node (URL + method) with its handler function/method
256
+ * via the `references` edge that framework resolvers emit. Returns
257
+ * null when fewer than 3 valid (non-test) routes exist.
258
+ */
259
+ getRoutingManifest(limit?: number): {
260
+ entries: Array<{
261
+ url: string;
262
+ handler: string;
263
+ handlerFile: string;
264
+ handlerLine: number;
265
+ handlerKind: string;
266
+ }>;
267
+ topHandlerFile: string | null;
268
+ topHandlerFileCount: number;
269
+ totalRoutes: number;
270
+ } | null;
271
+ /**
272
+ * Get outgoing edges from a node
273
+ */
274
+ getOutgoingEdges(nodeId: string): Edge[];
275
+ /**
276
+ * Get incoming edges to a node
277
+ */
278
+ getIncomingEdges(nodeId: string): Edge[];
279
+ /**
280
+ * Get a file record by path
281
+ */
282
+ getFile(filePath: string): FileRecord | null;
283
+ /**
284
+ * Get all tracked files
285
+ */
286
+ getFiles(): FileRecord[];
287
+ /**
288
+ * Get the context for a node (ancestors, children, references)
289
+ *
290
+ * Returns comprehensive context about a node including its containment
291
+ * hierarchy, children, incoming/outgoing references, type information,
292
+ * and relevant imports.
293
+ *
294
+ * @param nodeId - ID of the focal node
295
+ * @returns Context object with all related information
296
+ */
297
+ getContext(nodeId: string): Context;
298
+ /**
299
+ * Traverse the graph from a starting node
300
+ *
301
+ * Uses breadth-first search by default. Supports filtering by edge types,
302
+ * node types, and traversal direction.
303
+ *
304
+ * @param startId - Starting node ID
305
+ * @param options - Traversal options
306
+ * @returns Subgraph containing traversed nodes and edges
307
+ */
308
+ traverse(startId: string, options?: TraversalOptions): Subgraph;
309
+ /**
310
+ * Get the call graph for a function
311
+ *
312
+ * Returns both callers (functions that call this function) and
313
+ * callees (functions called by this function) up to the specified depth.
314
+ *
315
+ * @param nodeId - ID of the function/method node
316
+ * @param depth - Maximum depth in each direction (default: 2)
317
+ * @returns Subgraph containing the call graph
318
+ */
319
+ getCallGraph(nodeId: string, depth?: number): Subgraph;
320
+ /**
321
+ * Get the type hierarchy for a class/interface
322
+ *
323
+ * Returns both ancestors (types this extends/implements) and
324
+ * descendants (types that extend/implement this).
325
+ *
326
+ * @param nodeId - ID of the class/interface node
327
+ * @returns Subgraph containing the type hierarchy
328
+ */
329
+ getTypeHierarchy(nodeId: string): Subgraph;
330
+ /**
331
+ * Find all usages of a symbol
332
+ *
333
+ * Returns all nodes that reference the specified symbol through
334
+ * any edge type (calls, references, type_of, etc.).
335
+ *
336
+ * @param nodeId - ID of the symbol node
337
+ * @returns Array of nodes and edges that reference this symbol
338
+ */
339
+ findUsages(nodeId: string): Array<{
340
+ node: Node;
341
+ edge: Edge;
342
+ }>;
343
+ /**
344
+ * Get callers of a function/method
345
+ *
346
+ * @param nodeId - ID of the function/method node
347
+ * @param maxDepth - Maximum depth to traverse (default: 1)
348
+ * @returns Array of nodes that call this function
349
+ */
350
+ getCallers(nodeId: string, maxDepth?: number): Array<{
351
+ node: Node;
352
+ edge: Edge;
353
+ }>;
354
+ /**
355
+ * Get callees of a function/method
356
+ *
357
+ * @param nodeId - ID of the function/method node
358
+ * @param maxDepth - Maximum depth to traverse (default: 1)
359
+ * @returns Array of nodes called by this function
360
+ */
361
+ getCallees(nodeId: string, maxDepth?: number): Array<{
362
+ node: Node;
363
+ edge: Edge;
364
+ }>;
365
+ /**
366
+ * Calculate the impact radius of a node
367
+ *
368
+ * Returns all nodes that could be affected by changes to this node.
369
+ *
370
+ * @param nodeId - ID of the node
371
+ * @param maxDepth - Maximum depth to traverse (default: 3)
372
+ * @returns Subgraph containing potentially impacted nodes
373
+ */
374
+ getImpactRadius(nodeId: string, maxDepth?: number): Subgraph;
375
+ /**
376
+ * Find the shortest path between two nodes
377
+ *
378
+ * @param fromId - Starting node ID
379
+ * @param toId - Target node ID
380
+ * @param edgeKinds - Edge types to consider (all if empty)
381
+ * @returns Array of nodes and edges forming the path, or null if no path exists
382
+ */
383
+ findPath(fromId: string, toId: string, edgeKinds?: Edge['kind'][]): Array<{
384
+ node: Node;
385
+ edge: Edge | null;
386
+ }> | null;
387
+ /**
388
+ * Get ancestors of a node in the containment hierarchy
389
+ *
390
+ * @param nodeId - ID of the node
391
+ * @returns Array of ancestor nodes from immediate parent to root
392
+ */
393
+ getAncestors(nodeId: string): Node[];
394
+ /**
395
+ * Get immediate children of a node
396
+ *
397
+ * @param nodeId - ID of the node
398
+ * @returns Array of child nodes
399
+ */
400
+ getChildren(nodeId: string): Node[];
401
+ /**
402
+ * Get dependencies of a file
403
+ *
404
+ * @param filePath - Path to the file
405
+ * @returns Array of file paths this file depends on
406
+ */
407
+ getFileDependencies(filePath: string): string[];
408
+ /**
409
+ * Get dependents of a file
410
+ *
411
+ * @param filePath - Path to the file
412
+ * @returns Array of file paths that depend on this file
413
+ */
414
+ getFileDependents(filePath: string): string[];
415
+ /**
416
+ * Find circular dependencies in the codebase
417
+ *
418
+ * @returns Array of cycles, each cycle is an array of file paths
419
+ */
420
+ findCircularDependencies(): string[][];
421
+ /**
422
+ * Find dead code (unreferenced symbols)
423
+ *
424
+ * @param kinds - Node kinds to check (default: functions, methods, classes)
425
+ * @returns Array of unreferenced nodes
426
+ */
427
+ findDeadCode(kinds?: Node['kind'][]): Node[];
428
+ /**
429
+ * Get complexity metrics for a node
430
+ *
431
+ * @param nodeId - ID of the node
432
+ * @returns Object containing various complexity metrics
433
+ */
434
+ getNodeMetrics(nodeId: string): {
435
+ incomingEdgeCount: number;
436
+ outgoingEdgeCount: number;
437
+ callCount: number;
438
+ callerCount: number;
439
+ childCount: number;
440
+ depth: number;
441
+ };
442
+ /**
443
+ * Get the source code for a node
444
+ *
445
+ * Reads the file and extracts the code between startLine and endLine.
446
+ *
447
+ * @param nodeId - ID of the node
448
+ * @returns Code string or null if not found
449
+ */
450
+ getCode(nodeId: string): Promise<string | null>;
451
+ /**
452
+ * Find relevant subgraph for a query
453
+ *
454
+ * Combines semantic search with graph traversal to find the most
455
+ * relevant nodes and their relationships for a given query.
456
+ *
457
+ * @param query - Natural language query describing the task
458
+ * @param options - Search and traversal options
459
+ * @returns Subgraph of relevant nodes and edges
460
+ */
461
+ findRelevantContext(query: string, options?: FindRelevantContextOptions): Promise<Subgraph>;
462
+ /**
463
+ * Build context for a task
464
+ *
465
+ * Creates comprehensive context by:
466
+ * 1. Running FTS search to find entry points
467
+ * 2. Expanding the graph around entry points
468
+ * 3. Extracting code blocks for key nodes
469
+ * 4. Formatting output for Claude
470
+ *
471
+ * @param input - Task description (string or {title, description})
472
+ * @param options - Build options (maxNodes, includeCode, format, etc.)
473
+ * @returns TaskContext object or formatted string (markdown/JSON)
474
+ */
475
+ buildContext(input: TaskInput, options?: BuildContextOptions): Promise<TaskContext | string>;
476
+ /**
477
+ * Optimize the database (vacuum and analyze)
478
+ */
479
+ optimize(): void;
480
+ /**
481
+ * Clear all data from the graph
482
+ */
483
+ clear(): void;
484
+ /**
485
+ * Alias for close() for backwards compatibility.
486
+ * @deprecated Use close() instead
487
+ */
488
+ destroy(): void;
489
+ /**
490
+ * Completely remove CodeGraph from the project.
491
+ * This closes the database and deletes the .CodeGraph directory.
492
+ *
493
+ * WARNING: This permanently deletes all CodeGraph data for the project.
494
+ */
495
+ uninitialize(): void;
496
+ }
497
+ export default CodeGraph;
498
+ //# 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
@@ -0,0 +1,100 @@
1
+ /**
2
+ * CodeGraph Interactive Installer
3
+ *
4
+ * Multi-target: writes MCP server config + instructions for the
5
+ * agents the user picks (Claude Code, Cursor, Codex CLI, opencode,
6
+ * Hermes Agent, Gemini CLI, Antigravity IDE).
7
+ * Defaults to the Claude-only behavior for backwards compatibility
8
+ * when no targets are explicitly chosen and nothing else is detected.
9
+ *
10
+ * Uses @clack/prompts for the interactive UI; `runInstallerWithOptions`
11
+ * is the non-interactive entry point used by the `--target` /
12
+ * `--print-config` CLI flags.
13
+ */
14
+ import type { AgentTarget, Location, TargetId } from './targets/types';
15
+ export { writeMcpConfig, writePermissions, hasMcpConfig, hasPermissions, } from './config-writer';
16
+ export type { InstallLocation } from './config-writer';
17
+ export interface RunInstallerOptions {
18
+ /** Comma-separated target list, or `auto` / `all` / `none`. */
19
+ target?: string;
20
+ /** Skip the location prompt; use this value directly. */
21
+ location?: Location;
22
+ /** Skip the auto-allow prompt; use this value directly. */
23
+ autoAllow?: boolean;
24
+ /**
25
+ * Skip every confirm and use defaults: location=global,
26
+ * autoAllow=true, target=auto. For scripting / CI.
27
+ */
28
+ yes?: boolean;
29
+ }
30
+ /**
31
+ * Interactive entry point — preserves the historical UX (`codegraph
32
+ * install` with no args goes through the prompts), but now starts
33
+ * the targets multi-select pre-populated with detected agents.
34
+ */
35
+ export declare function runInstaller(): Promise<void>;
36
+ export declare function runInstallerWithOptions(opts: RunInstallerOptions): Promise<void>;
37
+ export interface RunUninstallerOptions {
38
+ /**
39
+ * Comma-separated target list, or `auto` / `all` / `none`. Defaults
40
+ * to `all` — uninstall sweeps every known agent and reports which
41
+ * ones it actually touched, so the user doesn't have to know where
42
+ * they configured it.
43
+ */
44
+ target?: string;
45
+ /** Skip the location prompt; use this value directly. */
46
+ location?: Location;
47
+ /** Non-interactive: location=global, target=all, no prompts. */
48
+ yes?: boolean;
49
+ }
50
+ export type UninstallStatus = 'removed' | 'not-configured' | 'unsupported';
51
+ /**
52
+ * Per-target outcome of an uninstall sweep. `removed` means we deleted
53
+ * at least one thing; `not-configured` means the agent had no codegraph
54
+ * config at this location (nothing to do); `unsupported` means the
55
+ * agent has no config concept for this location (e.g. Codex is
56
+ * global-only, so a `local` uninstall skips it).
57
+ */
58
+ export interface UninstallReport {
59
+ id: TargetId;
60
+ displayName: string;
61
+ status: UninstallStatus;
62
+ /** Absolute paths we actually edited/removed (action === 'removed'). */
63
+ removedPaths: string[];
64
+ /** Verbatim notes from the target (rare for uninstall). */
65
+ notes: string[];
66
+ }
67
+ /**
68
+ * Pure uninstall sweep — no prompts, no I/O beyond the targets' own
69
+ * file edits. Exposed (and unit-tested) separately from the clack UI in
70
+ * `runUninstaller` so the aggregation logic can be asserted directly.
71
+ *
72
+ * Each target's `uninstall()` is already safe to call when nothing was
73
+ * installed (it returns `not-found` actions), so this is safe to run
74
+ * across every target unconditionally.
75
+ */
76
+ export declare function uninstallTargets(targets: readonly AgentTarget[], location: Location): UninstallReport[];
77
+ /**
78
+ * Interactive uninstaller — the inverse of `runInstallerWithOptions`.
79
+ * Asks global-vs-local first (unless `--location`/`--yes` is given),
80
+ * then sweeps every agent target (or the `--target` subset) and prints
81
+ * one block per agent so the user sees exactly which providers it hit.
82
+ *
83
+ * Removes only what install wrote (MCP server entry, instructions
84
+ * block, permissions) — never the `.codegraph/` index, which `codegraph
85
+ * uninit` owns.
86
+ */
87
+ export declare function runUninstaller(opts: RunUninstallerOptions): Promise<void>;
88
+ /**
89
+ * When the live file watcher will be disabled for this project (e.g. WSL2
90
+ * /mnt drives, or CODEGRAPH_NO_WATCH), the index would silently go stale.
91
+ * Explain that, and offer to keep it fresh automatically via git hooks
92
+ * (commit / pull / checkout) instead of manual `codegraph sync`.
93
+ *
94
+ * No-op on environments where the watcher runs normally, so it's safe to
95
+ * call unconditionally after init.
96
+ */
97
+ export declare function offerWatchFallback(clack: typeof import('@clack/prompts'), projectPath: string, opts?: {
98
+ yes?: boolean;
99
+ }): Promise<void>;
100
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Marker constants for the legacy agent-instructions block.
3
+ *
4
+ * Codegraph used to write a `## CodeGraph` usage guide into each
5
+ * agent's instructions file (CLAUDE.md / AGENTS.md / GEMINI.md /
6
+ * codegraph.mdc / Kiro steering doc). That duplicated the guidance the
7
+ * MCP server already emits in its `initialize` response — every agent
8
+ * read the same playbook twice each turn (issue #529). The installer no
9
+ * longer writes an instructions file; the MCP server instructions in
10
+ * `mcp/server-instructions.ts` are the single source of truth.
11
+ *
12
+ * These markers are retained so install (self-heal on upgrade) and
13
+ * uninstall can find and strip the block a previous install wrote.
14
+ */
15
+ /** Markers used by the marker-based section removal. */
16
+ export declare const CODEGRAPH_SECTION_START = "<!-- CODEGRAPH_START -->";
17
+ export declare const CODEGRAPH_SECTION_END = "<!-- CODEGRAPH_END -->";
18
+ //# sourceMappingURL=instructions-template.d.ts.map