@saluzi/codegraph 0.1.0 → 0.2.0

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 (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +885 -0
  3. package/package.json +42 -10
  4. package/scripts/add-lang/bench.sh +60 -0
  5. package/scripts/add-lang/check-grammar.mjs +75 -0
  6. package/scripts/add-lang/dump-ast.mjs +103 -0
  7. package/scripts/add-lang/verify-extraction.mjs +70 -0
  8. package/scripts/agent-eval/ab-adoption.sh +91 -0
  9. package/scripts/agent-eval/ab-hook.sh +86 -0
  10. package/scripts/agent-eval/ab-impl.sh +78 -0
  11. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
  12. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  13. package/scripts/agent-eval/arms-F.sh +21 -0
  14. package/scripts/agent-eval/arms-matrix.sh +37 -0
  15. package/scripts/agent-eval/audit.sh +68 -0
  16. package/scripts/agent-eval/bench-readme.sh +28 -0
  17. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  18. package/scripts/agent-eval/block-read-hook.sh +19 -0
  19. package/scripts/agent-eval/hook-settings.json +15 -0
  20. package/scripts/agent-eval/itrun.sh +120 -0
  21. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  22. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  23. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  24. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  25. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  26. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  27. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  28. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  29. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  30. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  31. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  32. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  33. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  34. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  35. package/scripts/agent-eval/offload-eval.md +76 -0
  36. package/scripts/agent-eval/parse-arms.mjs +116 -0
  37. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  38. package/scripts/agent-eval/parse-run.mjs +45 -0
  39. package/scripts/agent-eval/parse-session.mjs +93 -0
  40. package/scripts/agent-eval/probe-context.mjs +21 -0
  41. package/scripts/agent-eval/probe-explore.mjs +40 -0
  42. package/scripts/agent-eval/probe-node.mjs +20 -0
  43. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  44. package/scripts/agent-eval/probe-trace.mjs +20 -0
  45. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  46. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  47. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  48. package/scripts/agent-eval/run-agent.sh +34 -0
  49. package/scripts/agent-eval/run-all.sh +75 -0
  50. package/scripts/agent-eval/run-arms.sh +56 -0
  51. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  52. package/scripts/build-bundle.sh +123 -0
  53. package/scripts/extract-release-notes.mjs +130 -0
  54. package/scripts/local-install.sh +41 -0
  55. package/scripts/npm-sdk.js +75 -0
  56. package/scripts/npm-shim.js +275 -0
  57. package/scripts/pack-npm.sh +119 -0
  58. package/scripts/prepare-release.mjs +270 -0
  59. package/dist/bin/codegraph.d.ts +0 -25
  60. package/dist/bin/node-version-check.d.ts +0 -37
  61. package/dist/bin/uninstall.d.ts +0 -14
  62. package/dist/context/formatter.d.ts +0 -33
  63. package/dist/context/formatter.js +0 -244
  64. package/dist/context/index.d.ts +0 -117
  65. package/dist/context/index.js +0 -1050
  66. package/dist/db/index.d.ts +0 -101
  67. package/dist/db/index.js +0 -250
  68. package/dist/db/migrations.d.ts +0 -47
  69. package/dist/db/migrations.js +0 -131
  70. package/dist/db/queries.d.ts +0 -291
  71. package/dist/db/queries.js +0 -1349
  72. package/dist/db/schema.sql +0 -151
  73. package/dist/db/sqlite-adapter.d.ts +0 -49
  74. package/dist/db/sqlite-adapter.js +0 -141
  75. package/dist/directory.d.ts +0 -62
  76. package/dist/directory.js +0 -264
  77. package/dist/errors.d.ts +0 -149
  78. package/dist/errors.js +0 -219
  79. package/dist/extraction/dfm-extractor.d.ts +0 -31
  80. package/dist/extraction/dfm-extractor.js +0 -151
  81. package/dist/extraction/grammars.d.ts +0 -94
  82. package/dist/extraction/grammars.js +0 -357
  83. package/dist/extraction/index.d.ts +0 -148
  84. package/dist/extraction/index.js +0 -1286
  85. package/dist/extraction/languages/c-cpp.d.ts +0 -4
  86. package/dist/extraction/languages/c-cpp.js +0 -126
  87. package/dist/extraction/languages/csharp.d.ts +0 -3
  88. package/dist/extraction/languages/csharp.js +0 -72
  89. package/dist/extraction/languages/dart.d.ts +0 -3
  90. package/dist/extraction/languages/dart.js +0 -192
  91. package/dist/extraction/languages/go.d.ts +0 -3
  92. package/dist/extraction/languages/go.js +0 -58
  93. package/dist/extraction/languages/index.d.ts +0 -10
  94. package/dist/extraction/languages/index.js +0 -49
  95. package/dist/extraction/languages/java.d.ts +0 -3
  96. package/dist/extraction/languages/java.js +0 -64
  97. package/dist/extraction/languages/javascript.d.ts +0 -3
  98. package/dist/extraction/languages/javascript.js +0 -90
  99. package/dist/extraction/languages/kotlin.d.ts +0 -3
  100. package/dist/extraction/languages/kotlin.js +0 -253
  101. package/dist/extraction/languages/lua.d.ts +0 -3
  102. package/dist/extraction/languages/lua.js +0 -150
  103. package/dist/extraction/languages/luau.d.ts +0 -3
  104. package/dist/extraction/languages/luau.js +0 -37
  105. package/dist/extraction/languages/pascal.d.ts +0 -3
  106. package/dist/extraction/languages/pascal.js +0 -66
  107. package/dist/extraction/languages/php.d.ts +0 -3
  108. package/dist/extraction/languages/php.js +0 -107
  109. package/dist/extraction/languages/python.d.ts +0 -3
  110. package/dist/extraction/languages/python.js +0 -56
  111. package/dist/extraction/languages/ruby.d.ts +0 -3
  112. package/dist/extraction/languages/ruby.js +0 -114
  113. package/dist/extraction/languages/rust.d.ts +0 -3
  114. package/dist/extraction/languages/rust.js +0 -109
  115. package/dist/extraction/languages/scala.d.ts +0 -3
  116. package/dist/extraction/languages/scala.js +0 -139
  117. package/dist/extraction/languages/swift.d.ts +0 -3
  118. package/dist/extraction/languages/swift.js +0 -91
  119. package/dist/extraction/languages/typescript.d.ts +0 -3
  120. package/dist/extraction/languages/typescript.js +0 -129
  121. package/dist/extraction/liquid-extractor.d.ts +0 -52
  122. package/dist/extraction/liquid-extractor.js +0 -313
  123. package/dist/extraction/parse-worker.d.ts +0 -8
  124. package/dist/extraction/parse-worker.js +0 -94
  125. package/dist/extraction/svelte-extractor.d.ts +0 -56
  126. package/dist/extraction/svelte-extractor.js +0 -272
  127. package/dist/extraction/tree-sitter-helpers.d.ts +0 -39
  128. package/dist/extraction/tree-sitter-helpers.js +0 -103
  129. package/dist/extraction/tree-sitter-types.d.ts +0 -191
  130. package/dist/extraction/tree-sitter-types.js +0 -10
  131. package/dist/extraction/tree-sitter.d.ts +0 -238
  132. package/dist/extraction/tree-sitter.js +0 -2430
  133. package/dist/extraction/vue-extractor.d.ts +0 -36
  134. package/dist/extraction/vue-extractor.js +0 -163
  135. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  136. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  137. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  138. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  139. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  140. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  141. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  142. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  143. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  144. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  145. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  146. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  147. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  148. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  149. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  150. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  151. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  152. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  153. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  154. package/dist/extraction/wasm-runtime-flags.d.ts +0 -46
  155. package/dist/extraction/wasm-runtime-flags.js +0 -105
  156. package/dist/graph/index.d.ts +0 -8
  157. package/dist/graph/index.js +0 -13
  158. package/dist/graph/queries.d.ts +0 -109
  159. package/dist/graph/queries.js +0 -366
  160. package/dist/graph/traversal.d.ts +0 -137
  161. package/dist/graph/traversal.js +0 -528
  162. package/dist/index.d.ts +0 -509
  163. package/dist/index.js +0 -800
  164. package/dist/installer/claude-md-template.d.ts +0 -19
  165. package/dist/installer/config-writer.d.ts +0 -29
  166. package/dist/installer/index.d.ts +0 -140
  167. package/dist/installer/instructions-template.d.ts +0 -30
  168. package/dist/installer/targets/claude.d.ts +0 -55
  169. package/dist/installer/targets/codex.d.ts +0 -18
  170. package/dist/installer/targets/cursor.d.ts +0 -35
  171. package/dist/installer/targets/hermes.d.ts +0 -18
  172. package/dist/installer/targets/opencode.d.ts +0 -30
  173. package/dist/installer/targets/registry.d.ts +0 -38
  174. package/dist/installer/targets/shared.d.ts +0 -92
  175. package/dist/installer/targets/toml.d.ts +0 -64
  176. package/dist/installer/targets/types.d.ts +0 -122
  177. package/dist/mcp/index.d.ts +0 -98
  178. package/dist/mcp/server-instructions.d.ts +0 -20
  179. package/dist/mcp/tools.d.ts +0 -269
  180. package/dist/mcp/transport.d.ts +0 -117
  181. package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -20
  182. package/dist/resolution/frameworks/cargo-workspace.js +0 -225
  183. package/dist/resolution/frameworks/csharp.d.ts +0 -8
  184. package/dist/resolution/frameworks/csharp.js +0 -213
  185. package/dist/resolution/frameworks/drupal.d.ts +0 -51
  186. package/dist/resolution/frameworks/drupal.js +0 -335
  187. package/dist/resolution/frameworks/express.d.ts +0 -8
  188. package/dist/resolution/frameworks/express.js +0 -225
  189. package/dist/resolution/frameworks/go.d.ts +0 -8
  190. package/dist/resolution/frameworks/go.js +0 -158
  191. package/dist/resolution/frameworks/index.d.ts +0 -52
  192. package/dist/resolution/frameworks/index.js +0 -137
  193. package/dist/resolution/frameworks/java.d.ts +0 -8
  194. package/dist/resolution/frameworks/java.js +0 -177
  195. package/dist/resolution/frameworks/laravel.d.ts +0 -13
  196. package/dist/resolution/frameworks/laravel.js +0 -248
  197. package/dist/resolution/frameworks/nestjs.d.ts +0 -26
  198. package/dist/resolution/frameworks/nestjs.js +0 -374
  199. package/dist/resolution/frameworks/python.d.ts +0 -10
  200. package/dist/resolution/frameworks/python.js +0 -278
  201. package/dist/resolution/frameworks/react.d.ts +0 -8
  202. package/dist/resolution/frameworks/react.js +0 -272
  203. package/dist/resolution/frameworks/ruby.d.ts +0 -8
  204. package/dist/resolution/frameworks/ruby.js +0 -198
  205. package/dist/resolution/frameworks/rust.d.ts +0 -8
  206. package/dist/resolution/frameworks/rust.js +0 -207
  207. package/dist/resolution/frameworks/svelte.d.ts +0 -9
  208. package/dist/resolution/frameworks/svelte.js +0 -249
  209. package/dist/resolution/frameworks/swift.d.ts +0 -10
  210. package/dist/resolution/frameworks/swift.js +0 -376
  211. package/dist/resolution/frameworks/vue.d.ts +0 -9
  212. package/dist/resolution/frameworks/vue.js +0 -306
  213. package/dist/resolution/import-resolver.d.ts +0 -61
  214. package/dist/resolution/import-resolver.js +0 -663
  215. package/dist/resolution/index.d.ts +0 -118
  216. package/dist/resolution/index.js +0 -744
  217. package/dist/resolution/lru-cache.d.ts +0 -24
  218. package/dist/resolution/lru-cache.js +0 -62
  219. package/dist/resolution/name-matcher.d.ts +0 -50
  220. package/dist/resolution/name-matcher.js +0 -384
  221. package/dist/resolution/path-aliases.d.ts +0 -72
  222. package/dist/resolution/path-aliases.js +0 -238
  223. package/dist/resolution/strip-comments.d.ts +0 -40
  224. package/dist/resolution/strip-comments.js +0 -441
  225. package/dist/resolution/types.d.ts +0 -181
  226. package/dist/resolution/types.js +0 -8
  227. package/dist/search/query-parser.d.ts +0 -61
  228. package/dist/search/query-parser.js +0 -177
  229. package/dist/search/query-utils.d.ts +0 -59
  230. package/dist/search/query-utils.js +0 -383
  231. package/dist/sync/git-hooks.d.ts +0 -54
  232. package/dist/sync/git-hooks.js +0 -223
  233. package/dist/sync/index.d.ts +0 -25
  234. package/dist/sync/index.js +0 -28
  235. package/dist/sync/watch-policy.d.ts +0 -51
  236. package/dist/sync/watch-policy.js +0 -124
  237. package/dist/sync/watcher.d.ts +0 -83
  238. package/dist/sync/watcher.js +0 -192
  239. package/dist/types.d.ts +0 -433
  240. package/dist/types.js +0 -75
  241. package/dist/ui/glyphs.d.ts +0 -42
  242. package/dist/ui/shimmer-progress.d.ts +0 -11
  243. package/dist/ui/shimmer-worker.d.ts +0 -2
  244. package/dist/ui/types.d.ts +0 -20
  245. package/dist/utils.d.ts +0 -231
  246. package/dist/utils.js +0 -549
package/dist/index.d.ts DELETED
@@ -1,509 +0,0 @@
1
- /**
2
- * CodeGraph
3
- *
4
- * A local-first code intelligence system that builds a semantic
5
- * knowledge graph from any codebase.
6
- */
7
- import {
8
- Node,
9
- Edge,
10
- FileRecord,
11
- ExtractionResult,
12
- Subgraph,
13
- TraversalOptions,
14
- SearchOptions,
15
- SearchResult,
16
- Context,
17
- GraphStats,
18
- TaskInput,
19
- TaskContext,
20
- BuildContextOptions,
21
- FindRelevantContextOptions,
22
- } from './types'
23
- import { IndexProgress, IndexResult, SyncResult } from './extraction'
24
- import { ResolutionResult } from './resolution'
25
- import { WatchOptions } from './sync'
26
- export * from './types'
27
- export { getDatabasePath } from './db'
28
- export {
29
- getCodeGraphDir,
30
- isInitialized,
31
- findNearestCodeGraphRoot,
32
- CODEGRAPH_DIR,
33
- } from './directory'
34
- export { IndexProgress, IndexResult, SyncResult } from './extraction'
35
- export {
36
- detectLanguage,
37
- isLanguageSupported,
38
- isGrammarLoaded,
39
- getSupportedLanguages,
40
- initGrammars,
41
- loadGrammarsForLanguages,
42
- loadAllGrammars,
43
- } from './extraction'
44
- export { ResolutionResult } from './resolution'
45
- export {
46
- CodeGraphError,
47
- FileError,
48
- ParseError,
49
- DatabaseError,
50
- SearchError,
51
- VectorError,
52
- ConfigError,
53
- Logger,
54
- setLogger,
55
- getLogger,
56
- silentLogger,
57
- defaultLogger,
58
- } from './errors'
59
- export {
60
- Mutex,
61
- FileLock,
62
- processInBatches,
63
- debounce,
64
- throttle,
65
- MemoryMonitor,
66
- } from './utils'
67
- export { FileWatcher, WatchOptions } from './sync'
68
- export { MCPServer } from './mcp'
69
- /**
70
- * Options for initializing a new CodeGraph project
71
- */
72
- export interface InitOptions {
73
- /** Whether to run initial indexing after init */
74
- index?: boolean
75
- /** Progress callback for indexing */
76
- onProgress?: (progress: IndexProgress) => void
77
- }
78
- /**
79
- * Options for opening an existing CodeGraph project
80
- */
81
- export interface OpenOptions {
82
- /** Whether to run sync if files have changed */
83
- sync?: boolean
84
- /** Whether to run in read-only mode */
85
- readOnly?: boolean
86
- }
87
- /**
88
- * Options for indexing
89
- */
90
- export interface IndexOptions {
91
- /** Progress callback */
92
- onProgress?: (progress: IndexProgress) => void
93
- /** Abort signal for cancellation */
94
- signal?: AbortSignal
95
- /** Enable verbose logging (worker lifecycle, memory, timeouts) */
96
- verbose?: boolean
97
- }
98
- /**
99
- * Main CodeGraph class
100
- *
101
- * Provides the primary interface for interacting with the code knowledge graph.
102
- */
103
- export declare class CodeGraph {
104
- private db
105
- private queries
106
- private projectRoot
107
- private orchestrator
108
- private resolver
109
- private graphManager
110
- private traverser
111
- private contextBuilder
112
- private indexMutex
113
- private fileLock
114
- private watcher
115
- private constructor()
116
- /**
117
- * Initialize a new CodeGraph project
118
- *
119
- * Creates the .CodeGraph directory, database, and configuration.
120
- *
121
- * @param projectRoot - Path to the project root directory
122
- * @param options - Initialization options
123
- * @returns A new CodeGraph instance
124
- */
125
- static init(projectRoot: string, options?: InitOptions): Promise<CodeGraph>
126
- /**
127
- * Initialize synchronously (without indexing)
128
- */
129
- static initSync(projectRoot: string): CodeGraph
130
- /**
131
- * Open an existing CodeGraph project
132
- *
133
- * @param projectRoot - Path to the project root directory
134
- * @param options - Open options
135
- * @returns A CodeGraph instance
136
- */
137
- static open(projectRoot: string, options?: OpenOptions): Promise<CodeGraph>
138
- /**
139
- * Open synchronously (without sync)
140
- */
141
- static openSync(projectRoot: string): CodeGraph
142
- /**
143
- * Check if a directory has been initialized as a CodeGraph project
144
- */
145
- static isInitialized(projectRoot: string): boolean
146
- /**
147
- * Close the CodeGraph instance and release resources
148
- */
149
- close(): void
150
- /**
151
- * Get the project root directory
152
- */
153
- getProjectRoot(): string
154
- /**
155
- * Index all files in the project
156
- *
157
- * Uses a mutex to prevent concurrent indexing operations.
158
- */
159
- indexAll(options?: IndexOptions): Promise<IndexResult>
160
- /**
161
- * Index specific files
162
- *
163
- * Uses a mutex to prevent concurrent indexing operations.
164
- */
165
- indexFiles(filePaths: string[]): Promise<IndexResult>
166
- /**
167
- * Sync with current file state (incremental update)
168
- *
169
- * Uses a mutex to prevent concurrent indexing operations.
170
- */
171
- sync(options?: IndexOptions): Promise<SyncResult>
172
- /**
173
- * Check if an indexing operation is currently in progress
174
- */
175
- isIndexing(): boolean
176
- /**
177
- * Start watching for file changes and auto-syncing.
178
- *
179
- * Uses native OS file events (FSEvents on macOS, inotify on Linux 19+,
180
- * ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing.
181
- *
182
- * @param options - Watch options (debounce delay, callbacks)
183
- * @returns true if watching started successfully
184
- */
185
- watch(options?: WatchOptions): boolean
186
- /**
187
- * Stop watching for file changes.
188
- */
189
- unwatch(): void
190
- /**
191
- * Check if the file watcher is active.
192
- */
193
- isWatching(): boolean
194
- /**
195
- * Get files that have changed since last index
196
- */
197
- getChangedFiles(): {
198
- added: string[]
199
- modified: string[]
200
- removed: string[]
201
- }
202
- /**
203
- * Extract nodes and edges from source code (without storing)
204
- */
205
- extractFromSource(filePath: string, source: string): ExtractionResult
206
- /**
207
- * Resolve unresolved references and create edges
208
- *
209
- * This method takes unresolved references from extraction and attempts
210
- * to resolve them using multiple strategies:
211
- * - Framework-specific patterns (React, Express, Laravel)
212
- * - Import-based resolution
213
- * - Name-based symbol matching
214
- */
215
- resolveReferences(
216
- onProgress?: (current: number, total: number) => void,
217
- ): ResolutionResult
218
- /**
219
- * Resolve references in batches to keep memory bounded on large codebases.
220
- * Processes chunks of unresolved refs, persisting results after each batch.
221
- */
222
- resolveReferencesBatched(
223
- onProgress?: (current: number, total: number) => void,
224
- ): Promise<ResolutionResult>
225
- /**
226
- * Get detected frameworks in the project
227
- */
228
- getDetectedFrameworks(): string[]
229
- /**
230
- * Re-initialize the resolver (useful after adding new files)
231
- */
232
- reinitializeResolver(): void
233
- /**
234
- * Get statistics about the knowledge graph
235
- */
236
- getStats(): GraphStats
237
- /**
238
- * Active SQLite backend for this project's connection (`node-sqlite` — Node's
239
- * built-in real-SQLite module). Surfaced via `codegraph status` and the
240
- * `codegraph_status` MCP tool alongside the effective journal mode.
241
- */
242
- getBackend(): import('./db').SqliteBackend
243
- /**
244
- * The journal mode actually in effect ('wal', 'delete', …). 'wal' means
245
- * readers never block on a concurrent writer; anything else means they can,
246
- * which is the precondition for the "database is locked" failures in issue
247
- * #238. Surfaced via `codegraph status` and the `codegraph_status` MCP tool.
248
- */
249
- getJournalMode(): string
250
- /**
251
- * Get a node by ID
252
- */
253
- getNode(id: string): Node | null
254
- /**
255
- * Get all nodes in a file
256
- */
257
- getNodesInFile(filePath: string): Node[]
258
- /**
259
- * Get all nodes of a specific kind
260
- */
261
- getNodesByKind(kind: Node['kind']): Node[]
262
- /**
263
- * Search nodes by text
264
- */
265
- searchNodes(query: string, options?: SearchOptions): SearchResult[]
266
- /**
267
- * Get outgoing edges from a node
268
- */
269
- getOutgoingEdges(nodeId: string): Edge[]
270
- /**
271
- * Get incoming edges to a node
272
- */
273
- getIncomingEdges(nodeId: string): Edge[]
274
- /**
275
- * Get a file record by path
276
- */
277
- getFile(filePath: string): FileRecord | null
278
- /**
279
- * Get all tracked files
280
- */
281
- getFiles(): FileRecord[]
282
- /**
283
- * Get the context for a node (ancestors, children, references)
284
- *
285
- * Returns comprehensive context about a node including its containment
286
- * hierarchy, children, incoming/outgoing references, type information,
287
- * and relevant imports.
288
- *
289
- * @param nodeId - ID of the focal node
290
- * @returns Context object with all related information
291
- */
292
- getContext(nodeId: string): Context
293
- /**
294
- * Traverse the graph from a starting node
295
- *
296
- * Uses breadth-first search by default. Supports filtering by edge types,
297
- * node types, and traversal direction.
298
- *
299
- * @param startId - Starting node ID
300
- * @param options - Traversal options
301
- * @returns Subgraph containing traversed nodes and edges
302
- */
303
- traverse(startId: string, options?: TraversalOptions): Subgraph
304
- /**
305
- * Get the call graph for a function
306
- *
307
- * Returns both callers (functions that call this function) and
308
- * callees (functions called by this function) up to the specified depth.
309
- *
310
- * @param nodeId - ID of the function/method node
311
- * @param depth - Maximum depth in each direction (default: 2)
312
- * @returns Subgraph containing the call graph
313
- */
314
- getCallGraph(nodeId: string, depth?: number): Subgraph
315
- /**
316
- * Get the type hierarchy for a class/interface
317
- *
318
- * Returns both ancestors (types this extends/implements) and
319
- * descendants (types that extend/implement this).
320
- *
321
- * @param nodeId - ID of the class/interface node
322
- * @returns Subgraph containing the type hierarchy
323
- */
324
- getTypeHierarchy(nodeId: string): Subgraph
325
- /**
326
- * Find all usages of a symbol
327
- *
328
- * Returns all nodes that reference the specified symbol through
329
- * any edge type (calls, references, type_of, etc.).
330
- *
331
- * @param nodeId - ID of the symbol node
332
- * @returns Array of nodes and edges that reference this symbol
333
- */
334
- findUsages(nodeId: string): Array<{
335
- node: Node
336
- edge: Edge
337
- }>
338
- /**
339
- * Get callers of a function/method
340
- *
341
- * @param nodeId - ID of the function/method node
342
- * @param maxDepth - Maximum depth to traverse (default: 1)
343
- * @returns Array of nodes that call this function
344
- */
345
- getCallers(
346
- nodeId: string,
347
- maxDepth?: number,
348
- ): Array<{
349
- node: Node
350
- edge: Edge
351
- }>
352
- /**
353
- * Get callees of a function/method
354
- *
355
- * @param nodeId - ID of the function/method node
356
- * @param maxDepth - Maximum depth to traverse (default: 1)
357
- * @returns Array of nodes called by this function
358
- */
359
- getCallees(
360
- nodeId: string,
361
- maxDepth?: number,
362
- ): Array<{
363
- node: Node
364
- edge: Edge
365
- }>
366
- /**
367
- * Calculate the impact radius of a node
368
- *
369
- * Returns all nodes that could be affected by changes to this node.
370
- *
371
- * @param nodeId - ID of the node
372
- * @param maxDepth - Maximum depth to traverse (default: 3)
373
- * @returns Subgraph containing potentially impacted nodes
374
- */
375
- getImpactRadius(nodeId: string, maxDepth?: number): Subgraph
376
- /**
377
- * Find the shortest path between two nodes
378
- *
379
- * @param fromId - Starting node ID
380
- * @param toId - Target node ID
381
- * @param edgeKinds - Edge types to consider (all if empty)
382
- * @returns Array of nodes and edges forming the path, or null if no path exists
383
- */
384
- findPath(
385
- fromId: string,
386
- toId: string,
387
- edgeKinds?: Edge['kind'][],
388
- ): Array<{
389
- node: Node
390
- edge: Edge | null
391
- }> | null
392
- /**
393
- * Get ancestors of a node in the containment hierarchy
394
- *
395
- * @param nodeId - ID of the node
396
- * @returns Array of ancestor nodes from immediate parent to root
397
- */
398
- getAncestors(nodeId: string): Node[]
399
- /**
400
- * Get immediate children of a node
401
- *
402
- * @param nodeId - ID of the node
403
- * @returns Array of child nodes
404
- */
405
- getChildren(nodeId: string): Node[]
406
- /**
407
- * Get dependencies of a file
408
- *
409
- * @param filePath - Path to the file
410
- * @returns Array of file paths this file depends on
411
- */
412
- getFileDependencies(filePath: string): string[]
413
- /**
414
- * Get dependents of a file
415
- *
416
- * @param filePath - Path to the file
417
- * @returns Array of file paths that depend on this file
418
- */
419
- getFileDependents(filePath: string): string[]
420
- /**
421
- * Find circular dependencies in the codebase
422
- *
423
- * @returns Array of cycles, each cycle is an array of file paths
424
- */
425
- findCircularDependencies(): string[][]
426
- /**
427
- * Find dead code (unreferenced symbols)
428
- *
429
- * @param kinds - Node kinds to check (default: functions, methods, classes)
430
- * @returns Array of unreferenced nodes
431
- */
432
- findDeadCode(kinds?: Node['kind'][]): Node[]
433
- /**
434
- * Get complexity metrics for a node
435
- *
436
- * @param nodeId - ID of the node
437
- * @returns Object containing various complexity metrics
438
- */
439
- getNodeMetrics(nodeId: string): {
440
- incomingEdgeCount: number
441
- outgoingEdgeCount: number
442
- callCount: number
443
- callerCount: number
444
- childCount: number
445
- depth: number
446
- }
447
- /**
448
- * Get the source code for a node
449
- *
450
- * Reads the file and extracts the code between startLine and endLine.
451
- *
452
- * @param nodeId - ID of the node
453
- * @returns Code string or null if not found
454
- */
455
- getCode(nodeId: string): Promise<string | null>
456
- /**
457
- * Find relevant subgraph for a query
458
- *
459
- * Combines semantic search with graph traversal to find the most
460
- * relevant nodes and their relationships for a given query.
461
- *
462
- * @param query - Natural language query describing the task
463
- * @param options - Search and traversal options
464
- * @returns Subgraph of relevant nodes and edges
465
- */
466
- findRelevantContext(
467
- query: string,
468
- options?: FindRelevantContextOptions,
469
- ): Promise<Subgraph>
470
- /**
471
- * Build context for a task
472
- *
473
- * Creates comprehensive context by:
474
- * 1. Running FTS search to find entry points
475
- * 2. Expanding the graph around entry points
476
- * 3. Extracting code blocks for key nodes
477
- * 4. Formatting output for Claude
478
- *
479
- * @param input - Task description (string or {title, description})
480
- * @param options - Build options (maxNodes, includeCode, format, etc.)
481
- * @returns TaskContext object or formatted string (markdown/JSON)
482
- */
483
- buildContext(
484
- input: TaskInput,
485
- options?: BuildContextOptions,
486
- ): Promise<TaskContext | string>
487
- /**
488
- * Optimize the database (vacuum and analyze)
489
- */
490
- optimize(): void
491
- /**
492
- * Clear all data from the graph
493
- */
494
- clear(): void
495
- /**
496
- * Alias for close() for backwards compatibility.
497
- * @deprecated Use close() instead
498
- */
499
- destroy(): void
500
- /**
501
- * Completely remove CodeGraph from the project.
502
- * This closes the database and deletes the .CodeGraph directory.
503
- *
504
- * WARNING: This permanently deletes all CodeGraph data for the project.
505
- */
506
- uninitialize(): void
507
- }
508
- export default CodeGraph
509
- //# sourceMappingURL=index.d.ts.map