@colbymchenry/codegraph 0.7.10 → 0.9.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 (362) hide show
  1. package/README.md +70 -54
  2. package/npm-shim.js +43 -0
  3. package/package.json +13 -51
  4. package/LICENSE +0 -21
  5. package/dist/bin/codegraph.d.ts +0 -21
  6. package/dist/bin/codegraph.d.ts.map +0 -1
  7. package/dist/bin/codegraph.js +0 -1232
  8. package/dist/bin/codegraph.js.map +0 -1
  9. package/dist/bin/node-version-check.d.ts +0 -20
  10. package/dist/bin/node-version-check.d.ts.map +0 -1
  11. package/dist/bin/node-version-check.js +0 -42
  12. package/dist/bin/node-version-check.js.map +0 -1
  13. package/dist/bin/uninstall.d.ts +0 -14
  14. package/dist/bin/uninstall.d.ts.map +0 -1
  15. package/dist/bin/uninstall.js +0 -36
  16. package/dist/bin/uninstall.js.map +0 -1
  17. package/dist/config.d.ts +0 -51
  18. package/dist/config.d.ts.map +0 -1
  19. package/dist/config.js +0 -321
  20. package/dist/config.js.map +0 -1
  21. package/dist/context/formatter.d.ts +0 -30
  22. package/dist/context/formatter.d.ts.map +0 -1
  23. package/dist/context/formatter.js +0 -244
  24. package/dist/context/formatter.js.map +0 -1
  25. package/dist/context/index.d.ts +0 -97
  26. package/dist/context/index.d.ts.map +0 -1
  27. package/dist/context/index.js +0 -1048
  28. package/dist/context/index.js.map +0 -1
  29. package/dist/db/index.d.ts +0 -72
  30. package/dist/db/index.d.ts.map +0 -1
  31. package/dist/db/index.js +0 -200
  32. package/dist/db/index.js.map +0 -1
  33. package/dist/db/migrations.d.ts +0 -44
  34. package/dist/db/migrations.d.ts.map +0 -1
  35. package/dist/db/migrations.js +0 -131
  36. package/dist/db/migrations.js.map +0 -1
  37. package/dist/db/queries.d.ts +0 -253
  38. package/dist/db/queries.d.ts.map +0 -1
  39. package/dist/db/queries.js +0 -1207
  40. package/dist/db/queries.js.map +0 -1
  41. package/dist/db/schema.sql +0 -151
  42. package/dist/db/sqlite-adapter.d.ts +0 -52
  43. package/dist/db/sqlite-adapter.d.ts.map +0 -1
  44. package/dist/db/sqlite-adapter.js +0 -237
  45. package/dist/db/sqlite-adapter.js.map +0 -1
  46. package/dist/directory.d.ts +0 -57
  47. package/dist/directory.d.ts.map +0 -1
  48. package/dist/directory.js +0 -264
  49. package/dist/directory.js.map +0 -1
  50. package/dist/errors.d.ts +0 -136
  51. package/dist/errors.d.ts.map +0 -1
  52. package/dist/errors.js +0 -219
  53. package/dist/errors.js.map +0 -1
  54. package/dist/extraction/dfm-extractor.d.ts +0 -31
  55. package/dist/extraction/dfm-extractor.d.ts.map +0 -1
  56. package/dist/extraction/dfm-extractor.js +0 -151
  57. package/dist/extraction/dfm-extractor.js.map +0 -1
  58. package/dist/extraction/grammars.d.ts +0 -78
  59. package/dist/extraction/grammars.d.ts.map +0 -1
  60. package/dist/extraction/grammars.js +0 -322
  61. package/dist/extraction/grammars.js.map +0 -1
  62. package/dist/extraction/index.d.ts +0 -130
  63. package/dist/extraction/index.d.ts.map +0 -1
  64. package/dist/extraction/index.js +0 -1279
  65. package/dist/extraction/index.js.map +0 -1
  66. package/dist/extraction/languages/c-cpp.d.ts +0 -4
  67. package/dist/extraction/languages/c-cpp.d.ts.map +0 -1
  68. package/dist/extraction/languages/c-cpp.js +0 -126
  69. package/dist/extraction/languages/c-cpp.js.map +0 -1
  70. package/dist/extraction/languages/csharp.d.ts +0 -3
  71. package/dist/extraction/languages/csharp.d.ts.map +0 -1
  72. package/dist/extraction/languages/csharp.js +0 -72
  73. package/dist/extraction/languages/csharp.js.map +0 -1
  74. package/dist/extraction/languages/dart.d.ts +0 -3
  75. package/dist/extraction/languages/dart.d.ts.map +0 -1
  76. package/dist/extraction/languages/dart.js +0 -192
  77. package/dist/extraction/languages/dart.js.map +0 -1
  78. package/dist/extraction/languages/go.d.ts +0 -3
  79. package/dist/extraction/languages/go.d.ts.map +0 -1
  80. package/dist/extraction/languages/go.js +0 -58
  81. package/dist/extraction/languages/go.js.map +0 -1
  82. package/dist/extraction/languages/index.d.ts +0 -10
  83. package/dist/extraction/languages/index.d.ts.map +0 -1
  84. package/dist/extraction/languages/index.js +0 -45
  85. package/dist/extraction/languages/index.js.map +0 -1
  86. package/dist/extraction/languages/java.d.ts +0 -3
  87. package/dist/extraction/languages/java.d.ts.map +0 -1
  88. package/dist/extraction/languages/java.js +0 -64
  89. package/dist/extraction/languages/java.js.map +0 -1
  90. package/dist/extraction/languages/javascript.d.ts +0 -3
  91. package/dist/extraction/languages/javascript.d.ts.map +0 -1
  92. package/dist/extraction/languages/javascript.js +0 -90
  93. package/dist/extraction/languages/javascript.js.map +0 -1
  94. package/dist/extraction/languages/kotlin.d.ts +0 -3
  95. package/dist/extraction/languages/kotlin.d.ts.map +0 -1
  96. package/dist/extraction/languages/kotlin.js +0 -253
  97. package/dist/extraction/languages/kotlin.js.map +0 -1
  98. package/dist/extraction/languages/pascal.d.ts +0 -3
  99. package/dist/extraction/languages/pascal.d.ts.map +0 -1
  100. package/dist/extraction/languages/pascal.js +0 -66
  101. package/dist/extraction/languages/pascal.js.map +0 -1
  102. package/dist/extraction/languages/php.d.ts +0 -3
  103. package/dist/extraction/languages/php.d.ts.map +0 -1
  104. package/dist/extraction/languages/php.js +0 -107
  105. package/dist/extraction/languages/php.js.map +0 -1
  106. package/dist/extraction/languages/python.d.ts +0 -3
  107. package/dist/extraction/languages/python.d.ts.map +0 -1
  108. package/dist/extraction/languages/python.js +0 -56
  109. package/dist/extraction/languages/python.js.map +0 -1
  110. package/dist/extraction/languages/ruby.d.ts +0 -3
  111. package/dist/extraction/languages/ruby.d.ts.map +0 -1
  112. package/dist/extraction/languages/ruby.js +0 -114
  113. package/dist/extraction/languages/ruby.js.map +0 -1
  114. package/dist/extraction/languages/rust.d.ts +0 -3
  115. package/dist/extraction/languages/rust.d.ts.map +0 -1
  116. package/dist/extraction/languages/rust.js +0 -109
  117. package/dist/extraction/languages/rust.js.map +0 -1
  118. package/dist/extraction/languages/scala.d.ts +0 -3
  119. package/dist/extraction/languages/scala.d.ts.map +0 -1
  120. package/dist/extraction/languages/scala.js +0 -139
  121. package/dist/extraction/languages/scala.js.map +0 -1
  122. package/dist/extraction/languages/swift.d.ts +0 -3
  123. package/dist/extraction/languages/swift.d.ts.map +0 -1
  124. package/dist/extraction/languages/swift.js +0 -91
  125. package/dist/extraction/languages/swift.js.map +0 -1
  126. package/dist/extraction/languages/typescript.d.ts +0 -3
  127. package/dist/extraction/languages/typescript.d.ts.map +0 -1
  128. package/dist/extraction/languages/typescript.js +0 -129
  129. package/dist/extraction/languages/typescript.js.map +0 -1
  130. package/dist/extraction/liquid-extractor.d.ts +0 -52
  131. package/dist/extraction/liquid-extractor.d.ts.map +0 -1
  132. package/dist/extraction/liquid-extractor.js +0 -313
  133. package/dist/extraction/liquid-extractor.js.map +0 -1
  134. package/dist/extraction/parse-worker.d.ts +0 -8
  135. package/dist/extraction/parse-worker.d.ts.map +0 -1
  136. package/dist/extraction/parse-worker.js +0 -94
  137. package/dist/extraction/parse-worker.js.map +0 -1
  138. package/dist/extraction/svelte-extractor.d.ts +0 -56
  139. package/dist/extraction/svelte-extractor.d.ts.map +0 -1
  140. package/dist/extraction/svelte-extractor.js +0 -272
  141. package/dist/extraction/svelte-extractor.js.map +0 -1
  142. package/dist/extraction/tree-sitter-helpers.d.ts +0 -28
  143. package/dist/extraction/tree-sitter-helpers.d.ts.map +0 -1
  144. package/dist/extraction/tree-sitter-helpers.js +0 -103
  145. package/dist/extraction/tree-sitter-helpers.js.map +0 -1
  146. package/dist/extraction/tree-sitter-types.d.ts +0 -179
  147. package/dist/extraction/tree-sitter-types.d.ts.map +0 -1
  148. package/dist/extraction/tree-sitter-types.js +0 -10
  149. package/dist/extraction/tree-sitter-types.js.map +0 -1
  150. package/dist/extraction/tree-sitter.d.ts +0 -233
  151. package/dist/extraction/tree-sitter.d.ts.map +0 -1
  152. package/dist/extraction/tree-sitter.js +0 -2393
  153. package/dist/extraction/tree-sitter.js.map +0 -1
  154. package/dist/extraction/vue-extractor.d.ts +0 -36
  155. package/dist/extraction/vue-extractor.d.ts.map +0 -1
  156. package/dist/extraction/vue-extractor.js +0 -163
  157. package/dist/extraction/vue-extractor.js.map +0 -1
  158. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  159. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  160. package/dist/graph/index.d.ts +0 -8
  161. package/dist/graph/index.d.ts.map +0 -1
  162. package/dist/graph/index.js +0 -13
  163. package/dist/graph/index.js.map +0 -1
  164. package/dist/graph/queries.d.ts +0 -106
  165. package/dist/graph/queries.d.ts.map +0 -1
  166. package/dist/graph/queries.js +0 -366
  167. package/dist/graph/queries.js.map +0 -1
  168. package/dist/graph/traversal.d.ts +0 -127
  169. package/dist/graph/traversal.d.ts.map +0 -1
  170. package/dist/graph/traversal.js +0 -493
  171. package/dist/graph/traversal.js.map +0 -1
  172. package/dist/index.d.ts +0 -447
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/index.js +0 -825
  175. package/dist/index.js.map +0 -1
  176. package/dist/installer/claude-md-template.d.ts +0 -14
  177. package/dist/installer/claude-md-template.d.ts.map +0 -1
  178. package/dist/installer/claude-md-template.js +0 -21
  179. package/dist/installer/claude-md-template.js.map +0 -1
  180. package/dist/installer/config-writer.d.ts +0 -29
  181. package/dist/installer/config-writer.d.ts.map +0 -1
  182. package/dist/installer/config-writer.js +0 -109
  183. package/dist/installer/config-writer.js.map +0 -1
  184. package/dist/installer/index.d.ts +0 -53
  185. package/dist/installer/index.d.ts.map +0 -1
  186. package/dist/installer/index.js +0 -338
  187. package/dist/installer/index.js.map +0 -1
  188. package/dist/installer/instructions-template.d.ts +0 -28
  189. package/dist/installer/instructions-template.d.ts.map +0 -1
  190. package/dist/installer/instructions-template.js +0 -63
  191. package/dist/installer/instructions-template.js.map +0 -1
  192. package/dist/installer/targets/claude.d.ts +0 -27
  193. package/dist/installer/targets/claude.d.ts.map +0 -1
  194. package/dist/installer/targets/claude.js +0 -246
  195. package/dist/installer/targets/claude.js.map +0 -1
  196. package/dist/installer/targets/codex.d.ts +0 -18
  197. package/dist/installer/targets/codex.d.ts.map +0 -1
  198. package/dist/installer/targets/codex.js +0 -185
  199. package/dist/installer/targets/codex.js.map +0 -1
  200. package/dist/installer/targets/cursor.d.ts +0 -35
  201. package/dist/installer/targets/cursor.d.ts.map +0 -1
  202. package/dist/installer/targets/cursor.js +0 -229
  203. package/dist/installer/targets/cursor.js.map +0 -1
  204. package/dist/installer/targets/opencode.d.ts +0 -30
  205. package/dist/installer/targets/opencode.d.ts.map +0 -1
  206. package/dist/installer/targets/opencode.js +0 -235
  207. package/dist/installer/targets/opencode.js.map +0 -1
  208. package/dist/installer/targets/registry.d.ts +0 -35
  209. package/dist/installer/targets/registry.d.ts.map +0 -1
  210. package/dist/installer/targets/registry.js +0 -83
  211. package/dist/installer/targets/registry.js.map +0 -1
  212. package/dist/installer/targets/shared.d.ts +0 -77
  213. package/dist/installer/targets/shared.d.ts.map +0 -1
  214. package/dist/installer/targets/shared.js +0 -246
  215. package/dist/installer/targets/shared.js.map +0 -1
  216. package/dist/installer/targets/toml.d.ts +0 -52
  217. package/dist/installer/targets/toml.d.ts.map +0 -1
  218. package/dist/installer/targets/toml.js +0 -147
  219. package/dist/installer/targets/toml.js.map +0 -1
  220. package/dist/installer/targets/types.d.ts +0 -116
  221. package/dist/installer/targets/types.d.ts.map +0 -1
  222. package/dist/installer/targets/types.js +0 -16
  223. package/dist/installer/targets/types.js.map +0 -1
  224. package/dist/mcp/index.d.ts +0 -86
  225. package/dist/mcp/index.d.ts.map +0 -1
  226. package/dist/mcp/index.js +0 -355
  227. package/dist/mcp/index.js.map +0 -1
  228. package/dist/mcp/server-instructions.d.ts +0 -19
  229. package/dist/mcp/server-instructions.d.ts.map +0 -1
  230. package/dist/mcp/server-instructions.js +0 -59
  231. package/dist/mcp/server-instructions.js.map +0 -1
  232. package/dist/mcp/tools.d.ts +0 -200
  233. package/dist/mcp/tools.d.ts.map +0 -1
  234. package/dist/mcp/tools.js +0 -1319
  235. package/dist/mcp/tools.js.map +0 -1
  236. package/dist/mcp/transport.d.ts +0 -89
  237. package/dist/mcp/transport.d.ts.map +0 -1
  238. package/dist/mcp/transport.js +0 -170
  239. package/dist/mcp/transport.js.map +0 -1
  240. package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -18
  241. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +0 -1
  242. package/dist/resolution/frameworks/cargo-workspace.js +0 -225
  243. package/dist/resolution/frameworks/cargo-workspace.js.map +0 -1
  244. package/dist/resolution/frameworks/csharp.d.ts +0 -8
  245. package/dist/resolution/frameworks/csharp.d.ts.map +0 -1
  246. package/dist/resolution/frameworks/csharp.js +0 -213
  247. package/dist/resolution/frameworks/csharp.js.map +0 -1
  248. package/dist/resolution/frameworks/express.d.ts +0 -8
  249. package/dist/resolution/frameworks/express.d.ts.map +0 -1
  250. package/dist/resolution/frameworks/express.js +0 -225
  251. package/dist/resolution/frameworks/express.js.map +0 -1
  252. package/dist/resolution/frameworks/go.d.ts +0 -8
  253. package/dist/resolution/frameworks/go.d.ts.map +0 -1
  254. package/dist/resolution/frameworks/go.js +0 -158
  255. package/dist/resolution/frameworks/go.js.map +0 -1
  256. package/dist/resolution/frameworks/index.d.ts +0 -41
  257. package/dist/resolution/frameworks/index.d.ts.map +0 -1
  258. package/dist/resolution/frameworks/index.js +0 -129
  259. package/dist/resolution/frameworks/index.js.map +0 -1
  260. package/dist/resolution/frameworks/java.d.ts +0 -8
  261. package/dist/resolution/frameworks/java.d.ts.map +0 -1
  262. package/dist/resolution/frameworks/java.js +0 -177
  263. package/dist/resolution/frameworks/java.js.map +0 -1
  264. package/dist/resolution/frameworks/laravel.d.ts +0 -13
  265. package/dist/resolution/frameworks/laravel.d.ts.map +0 -1
  266. package/dist/resolution/frameworks/laravel.js +0 -248
  267. package/dist/resolution/frameworks/laravel.js.map +0 -1
  268. package/dist/resolution/frameworks/python.d.ts +0 -10
  269. package/dist/resolution/frameworks/python.d.ts.map +0 -1
  270. package/dist/resolution/frameworks/python.js +0 -278
  271. package/dist/resolution/frameworks/python.js.map +0 -1
  272. package/dist/resolution/frameworks/react.d.ts +0 -8
  273. package/dist/resolution/frameworks/react.d.ts.map +0 -1
  274. package/dist/resolution/frameworks/react.js +0 -272
  275. package/dist/resolution/frameworks/react.js.map +0 -1
  276. package/dist/resolution/frameworks/ruby.d.ts +0 -8
  277. package/dist/resolution/frameworks/ruby.d.ts.map +0 -1
  278. package/dist/resolution/frameworks/ruby.js +0 -198
  279. package/dist/resolution/frameworks/ruby.js.map +0 -1
  280. package/dist/resolution/frameworks/rust.d.ts +0 -8
  281. package/dist/resolution/frameworks/rust.d.ts.map +0 -1
  282. package/dist/resolution/frameworks/rust.js +0 -207
  283. package/dist/resolution/frameworks/rust.js.map +0 -1
  284. package/dist/resolution/frameworks/svelte.d.ts +0 -9
  285. package/dist/resolution/frameworks/svelte.d.ts.map +0 -1
  286. package/dist/resolution/frameworks/svelte.js +0 -249
  287. package/dist/resolution/frameworks/svelte.js.map +0 -1
  288. package/dist/resolution/frameworks/swift.d.ts +0 -10
  289. package/dist/resolution/frameworks/swift.d.ts.map +0 -1
  290. package/dist/resolution/frameworks/swift.js +0 -376
  291. package/dist/resolution/frameworks/swift.js.map +0 -1
  292. package/dist/resolution/frameworks/vue.d.ts +0 -9
  293. package/dist/resolution/frameworks/vue.d.ts.map +0 -1
  294. package/dist/resolution/frameworks/vue.js +0 -306
  295. package/dist/resolution/frameworks/vue.js.map +0 -1
  296. package/dist/resolution/import-resolver.d.ts +0 -40
  297. package/dist/resolution/import-resolver.d.ts.map +0 -1
  298. package/dist/resolution/import-resolver.js +0 -663
  299. package/dist/resolution/import-resolver.js.map +0 -1
  300. package/dist/resolution/index.d.ts +0 -106
  301. package/dist/resolution/index.d.ts.map +0 -1
  302. package/dist/resolution/index.js +0 -709
  303. package/dist/resolution/index.js.map +0 -1
  304. package/dist/resolution/name-matcher.d.ts +0 -32
  305. package/dist/resolution/name-matcher.d.ts.map +0 -1
  306. package/dist/resolution/name-matcher.js +0 -384
  307. package/dist/resolution/name-matcher.js.map +0 -1
  308. package/dist/resolution/path-aliases.d.ts +0 -68
  309. package/dist/resolution/path-aliases.d.ts.map +0 -1
  310. package/dist/resolution/path-aliases.js +0 -238
  311. package/dist/resolution/path-aliases.js.map +0 -1
  312. package/dist/resolution/strip-comments.d.ts +0 -27
  313. package/dist/resolution/strip-comments.d.ts.map +0 -1
  314. package/dist/resolution/strip-comments.js +0 -441
  315. package/dist/resolution/strip-comments.js.map +0 -1
  316. package/dist/resolution/types.d.ts +0 -172
  317. package/dist/resolution/types.d.ts.map +0 -1
  318. package/dist/resolution/types.js +0 -8
  319. package/dist/resolution/types.js.map +0 -1
  320. package/dist/search/query-parser.d.ts +0 -57
  321. package/dist/search/query-parser.d.ts.map +0 -1
  322. package/dist/search/query-parser.js +0 -177
  323. package/dist/search/query-parser.js.map +0 -1
  324. package/dist/search/query-utils.d.ts +0 -53
  325. package/dist/search/query-utils.d.ts.map +0 -1
  326. package/dist/search/query-utils.js +0 -347
  327. package/dist/search/query-utils.js.map +0 -1
  328. package/dist/sync/index.d.ts +0 -13
  329. package/dist/sync/index.d.ts.map +0 -1
  330. package/dist/sync/index.js +0 -17
  331. package/dist/sync/index.js.map +0 -1
  332. package/dist/sync/watcher.d.ts +0 -81
  333. package/dist/sync/watcher.d.ts.map +0 -1
  334. package/dist/sync/watcher.js +0 -184
  335. package/dist/sync/watcher.js.map +0 -1
  336. package/dist/types.d.ts +0 -423
  337. package/dist/types.d.ts.map +0 -1
  338. package/dist/types.js +0 -256
  339. package/dist/types.js.map +0 -1
  340. package/dist/ui/glyphs.d.ts +0 -42
  341. package/dist/ui/glyphs.d.ts.map +0 -1
  342. package/dist/ui/glyphs.js +0 -78
  343. package/dist/ui/glyphs.js.map +0 -1
  344. package/dist/ui/shimmer-progress.d.ts +0 -11
  345. package/dist/ui/shimmer-progress.d.ts.map +0 -1
  346. package/dist/ui/shimmer-progress.js +0 -90
  347. package/dist/ui/shimmer-progress.js.map +0 -1
  348. package/dist/ui/shimmer-worker.d.ts +0 -2
  349. package/dist/ui/shimmer-worker.d.ts.map +0 -1
  350. package/dist/ui/shimmer-worker.js +0 -118
  351. package/dist/ui/shimmer-worker.js.map +0 -1
  352. package/dist/ui/types.d.ts +0 -17
  353. package/dist/ui/types.d.ts.map +0 -1
  354. package/dist/ui/types.js +0 -3
  355. package/dist/ui/types.js.map +0 -1
  356. package/dist/utils.d.ts +0 -205
  357. package/dist/utils.d.ts.map +0 -1
  358. package/dist/utils.js +0 -549
  359. package/dist/utils.js.map +0 -1
  360. package/scripts/local-install.sh +0 -41
  361. package/scripts/patch-tree-sitter-dart.js +0 -112
  362. package/scripts/release.sh +0 -70
package/dist/index.js DELETED
@@ -1,825 +0,0 @@
1
- "use strict";
2
- /**
3
- * CodeGraph
4
- *
5
- * A local-first code intelligence system that builds a semantic
6
- * knowledge graph from any codebase.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
42
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.CodeGraph = exports.MCPServer = exports.FileWatcher = exports.MemoryMonitor = exports.throttle = exports.debounce = exports.processInBatches = exports.FileLock = exports.Mutex = exports.defaultLogger = exports.silentLogger = exports.getLogger = exports.setLogger = exports.ConfigError = exports.VectorError = exports.SearchError = exports.DatabaseError = exports.ParseError = exports.FileError = exports.CodeGraphError = exports.loadAllGrammars = exports.loadGrammarsForLanguages = exports.initGrammars = exports.getSupportedLanguages = exports.isGrammarLoaded = exports.isLanguageSupported = exports.detectLanguage = exports.CODEGRAPH_DIR = exports.findNearestCodeGraphRoot = exports.isInitialized = exports.getCodeGraphDir = exports.getConfigPath = exports.getDatabasePath = void 0;
46
- const path = __importStar(require("path"));
47
- const db_1 = require("./db");
48
- const queries_1 = require("./db/queries");
49
- const config_1 = require("./config");
50
- const directory_1 = require("./directory");
51
- const extraction_1 = require("./extraction");
52
- const resolution_1 = require("./resolution");
53
- const graph_1 = require("./graph");
54
- const context_1 = require("./context");
55
- const utils_1 = require("./utils");
56
- const sync_1 = require("./sync");
57
- // Re-export types for consumers
58
- __exportStar(require("./types"), exports);
59
- var db_2 = require("./db");
60
- Object.defineProperty(exports, "getDatabasePath", { enumerable: true, get: function () { return db_2.getDatabasePath; } });
61
- var config_2 = require("./config");
62
- Object.defineProperty(exports, "getConfigPath", { enumerable: true, get: function () { return config_2.getConfigPath; } });
63
- var directory_2 = require("./directory");
64
- Object.defineProperty(exports, "getCodeGraphDir", { enumerable: true, get: function () { return directory_2.getCodeGraphDir; } });
65
- Object.defineProperty(exports, "isInitialized", { enumerable: true, get: function () { return directory_2.isInitialized; } });
66
- Object.defineProperty(exports, "findNearestCodeGraphRoot", { enumerable: true, get: function () { return directory_2.findNearestCodeGraphRoot; } });
67
- Object.defineProperty(exports, "CODEGRAPH_DIR", { enumerable: true, get: function () { return directory_2.CODEGRAPH_DIR; } });
68
- var extraction_2 = require("./extraction");
69
- Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return extraction_2.detectLanguage; } });
70
- Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return extraction_2.isLanguageSupported; } });
71
- Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return extraction_2.isGrammarLoaded; } });
72
- Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return extraction_2.getSupportedLanguages; } });
73
- Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return extraction_2.initGrammars; } });
74
- Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return extraction_2.loadGrammarsForLanguages; } });
75
- Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return extraction_2.loadAllGrammars; } });
76
- var errors_1 = require("./errors");
77
- Object.defineProperty(exports, "CodeGraphError", { enumerable: true, get: function () { return errors_1.CodeGraphError; } });
78
- Object.defineProperty(exports, "FileError", { enumerable: true, get: function () { return errors_1.FileError; } });
79
- Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_1.ParseError; } });
80
- Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_1.DatabaseError; } });
81
- Object.defineProperty(exports, "SearchError", { enumerable: true, get: function () { return errors_1.SearchError; } });
82
- Object.defineProperty(exports, "VectorError", { enumerable: true, get: function () { return errors_1.VectorError; } });
83
- Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_1.ConfigError; } });
84
- Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return errors_1.setLogger; } });
85
- Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return errors_1.getLogger; } });
86
- Object.defineProperty(exports, "silentLogger", { enumerable: true, get: function () { return errors_1.silentLogger; } });
87
- Object.defineProperty(exports, "defaultLogger", { enumerable: true, get: function () { return errors_1.defaultLogger; } });
88
- var utils_2 = require("./utils");
89
- Object.defineProperty(exports, "Mutex", { enumerable: true, get: function () { return utils_2.Mutex; } });
90
- Object.defineProperty(exports, "FileLock", { enumerable: true, get: function () { return utils_2.FileLock; } });
91
- Object.defineProperty(exports, "processInBatches", { enumerable: true, get: function () { return utils_2.processInBatches; } });
92
- Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return utils_2.debounce; } });
93
- Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return utils_2.throttle; } });
94
- Object.defineProperty(exports, "MemoryMonitor", { enumerable: true, get: function () { return utils_2.MemoryMonitor; } });
95
- var sync_2 = require("./sync");
96
- Object.defineProperty(exports, "FileWatcher", { enumerable: true, get: function () { return sync_2.FileWatcher; } });
97
- var mcp_1 = require("./mcp");
98
- Object.defineProperty(exports, "MCPServer", { enumerable: true, get: function () { return mcp_1.MCPServer; } });
99
- /**
100
- * Main CodeGraph class
101
- *
102
- * Provides the primary interface for interacting with the code knowledge graph.
103
- */
104
- class CodeGraph {
105
- db;
106
- queries;
107
- config;
108
- projectRoot;
109
- orchestrator;
110
- resolver;
111
- graphManager;
112
- traverser;
113
- contextBuilder;
114
- // Mutex for preventing concurrent indexing operations (in-process)
115
- indexMutex = new utils_1.Mutex();
116
- // File lock for preventing concurrent writes across processes (CLI, MCP, git hooks)
117
- fileLock;
118
- // File watcher for auto-sync on file changes
119
- watcher = null;
120
- constructor(db, queries, config, projectRoot) {
121
- this.db = db;
122
- this.queries = queries;
123
- this.config = config;
124
- this.projectRoot = projectRoot;
125
- this.fileLock = new utils_1.FileLock(path.join(projectRoot, '.codegraph', 'codegraph.lock'));
126
- this.orchestrator = new extraction_1.ExtractionOrchestrator(projectRoot, config, queries);
127
- this.resolver = (0, resolution_1.createResolver)(projectRoot, queries);
128
- this.graphManager = new graph_1.GraphQueryManager(queries);
129
- this.traverser = new graph_1.GraphTraverser(queries);
130
- this.contextBuilder = (0, context_1.createContextBuilder)(projectRoot, queries, this.traverser);
131
- }
132
- // ===========================================================================
133
- // Lifecycle Methods
134
- // ===========================================================================
135
- /**
136
- * Initialize a new CodeGraph project
137
- *
138
- * Creates the .CodeGraph directory, database, and configuration.
139
- *
140
- * @param projectRoot - Path to the project root directory
141
- * @param options - Initialization options
142
- * @returns A new CodeGraph instance
143
- */
144
- static async init(projectRoot, options = {}) {
145
- await (0, extraction_1.initGrammars)();
146
- const resolvedRoot = path.resolve(projectRoot);
147
- // Check if already initialized
148
- if ((0, directory_1.isInitialized)(resolvedRoot)) {
149
- throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
150
- }
151
- // Create directory structure
152
- (0, directory_1.createDirectory)(resolvedRoot);
153
- // Create and save configuration
154
- const config = (0, config_1.createDefaultConfig)(resolvedRoot);
155
- if (options.config) {
156
- Object.assign(config, options.config);
157
- }
158
- (0, config_1.saveConfig)(resolvedRoot, config);
159
- // Initialize database
160
- const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
161
- const db = db_1.DatabaseConnection.initialize(dbPath);
162
- const queries = new queries_1.QueryBuilder(db.getDb());
163
- const instance = new CodeGraph(db, queries, config, resolvedRoot);
164
- // Run initial indexing if requested
165
- if (options.index) {
166
- await instance.indexAll({ onProgress: options.onProgress });
167
- }
168
- return instance;
169
- }
170
- /**
171
- * Initialize synchronously (without indexing)
172
- */
173
- static initSync(projectRoot, options = {}) {
174
- const resolvedRoot = path.resolve(projectRoot);
175
- // Check if already initialized
176
- if ((0, directory_1.isInitialized)(resolvedRoot)) {
177
- throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
178
- }
179
- // Create directory structure
180
- (0, directory_1.createDirectory)(resolvedRoot);
181
- // Create and save configuration
182
- const config = (0, config_1.createDefaultConfig)(resolvedRoot);
183
- if (options.config) {
184
- Object.assign(config, options.config);
185
- }
186
- (0, config_1.saveConfig)(resolvedRoot, config);
187
- // Initialize database
188
- const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
189
- const db = db_1.DatabaseConnection.initialize(dbPath);
190
- const queries = new queries_1.QueryBuilder(db.getDb());
191
- return new CodeGraph(db, queries, config, resolvedRoot);
192
- }
193
- /**
194
- * Open an existing CodeGraph project
195
- *
196
- * @param projectRoot - Path to the project root directory
197
- * @param options - Open options
198
- * @returns A CodeGraph instance
199
- */
200
- static async open(projectRoot, options = {}) {
201
- await (0, extraction_1.initGrammars)();
202
- const resolvedRoot = path.resolve(projectRoot);
203
- // Check if initialized
204
- if (!(0, directory_1.isInitialized)(resolvedRoot)) {
205
- throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
206
- }
207
- // Validate directory structure
208
- const validation = (0, directory_1.validateDirectory)(resolvedRoot);
209
- if (!validation.valid) {
210
- throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
211
- }
212
- // Load configuration
213
- const config = (0, config_1.loadConfig)(resolvedRoot);
214
- // Open database
215
- const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
216
- const db = db_1.DatabaseConnection.open(dbPath);
217
- const queries = new queries_1.QueryBuilder(db.getDb());
218
- const instance = new CodeGraph(db, queries, config, resolvedRoot);
219
- // Sync if requested
220
- if (options.sync) {
221
- await instance.sync();
222
- }
223
- return instance;
224
- }
225
- /**
226
- * Open synchronously (without sync)
227
- */
228
- static openSync(projectRoot) {
229
- const resolvedRoot = path.resolve(projectRoot);
230
- // Check if initialized
231
- if (!(0, directory_1.isInitialized)(resolvedRoot)) {
232
- throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
233
- }
234
- // Validate directory structure
235
- const validation = (0, directory_1.validateDirectory)(resolvedRoot);
236
- if (!validation.valid) {
237
- throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
238
- }
239
- // Load configuration
240
- const config = (0, config_1.loadConfig)(resolvedRoot);
241
- // Open database
242
- const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
243
- const db = db_1.DatabaseConnection.open(dbPath);
244
- const queries = new queries_1.QueryBuilder(db.getDb());
245
- return new CodeGraph(db, queries, config, resolvedRoot);
246
- }
247
- /**
248
- * Check if a directory has been initialized as a CodeGraph project
249
- */
250
- static isInitialized(projectRoot) {
251
- return (0, directory_1.isInitialized)(path.resolve(projectRoot));
252
- }
253
- /**
254
- * Close the CodeGraph instance and release resources
255
- */
256
- close() {
257
- this.unwatch();
258
- // Release file lock if held
259
- this.fileLock.release();
260
- this.db.close();
261
- }
262
- // ===========================================================================
263
- // Configuration
264
- // ===========================================================================
265
- /**
266
- * Get the current configuration
267
- */
268
- getConfig() {
269
- return { ...this.config };
270
- }
271
- /**
272
- * Update configuration
273
- */
274
- updateConfig(updates) {
275
- Object.assign(this.config, updates);
276
- (0, config_1.saveConfig)(this.projectRoot, this.config);
277
- // Recreate orchestrator and resolver with new config
278
- this.orchestrator = new extraction_1.ExtractionOrchestrator(this.projectRoot, this.config, this.queries);
279
- this.resolver = (0, resolution_1.createResolver)(this.projectRoot, this.queries);
280
- }
281
- /**
282
- * Get the project root directory
283
- */
284
- getProjectRoot() {
285
- return this.projectRoot;
286
- }
287
- // ===========================================================================
288
- // Indexing
289
- // ===========================================================================
290
- /**
291
- * Index all files in the project
292
- *
293
- * Uses a mutex to prevent concurrent indexing operations.
294
- */
295
- async indexAll(options = {}) {
296
- return this.indexMutex.withLock(async () => {
297
- try {
298
- this.fileLock.acquire();
299
- }
300
- catch {
301
- return { success: false, filesIndexed: 0, filesSkipped: 0, filesErrored: 0, nodesCreated: 0, edgesCreated: 0, errors: [{ message: 'Could not acquire file lock - another process may be indexing', severity: 'error' }], durationMs: 0 };
302
- }
303
- try {
304
- const result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose);
305
- // Resolve references to create call/import/extends edges
306
- if (result.success && result.filesIndexed > 0) {
307
- // Get count without loading all refs into memory
308
- const unresolvedCount = this.queries.getUnresolvedReferencesCount();
309
- options.onProgress?.({
310
- phase: 'resolving',
311
- current: 0,
312
- total: unresolvedCount,
313
- });
314
- await this.resolveReferencesBatched((current, total) => {
315
- options.onProgress?.({
316
- phase: 'resolving',
317
- current,
318
- total,
319
- });
320
- });
321
- }
322
- return result;
323
- }
324
- finally {
325
- this.fileLock.release();
326
- }
327
- });
328
- }
329
- /**
330
- * Index specific files
331
- *
332
- * Uses a mutex to prevent concurrent indexing operations.
333
- */
334
- async indexFiles(filePaths) {
335
- return this.indexMutex.withLock(async () => {
336
- try {
337
- this.fileLock.acquire();
338
- }
339
- catch {
340
- return { success: false, filesIndexed: 0, filesSkipped: 0, filesErrored: 0, nodesCreated: 0, edgesCreated: 0, errors: [{ message: 'Could not acquire file lock - another process may be indexing', severity: 'error' }], durationMs: 0 };
341
- }
342
- try {
343
- return this.orchestrator.indexFiles(filePaths);
344
- }
345
- finally {
346
- this.fileLock.release();
347
- }
348
- });
349
- }
350
- /**
351
- * Sync with current file state (incremental update)
352
- *
353
- * Uses a mutex to prevent concurrent indexing operations.
354
- */
355
- async sync(options = {}) {
356
- return this.indexMutex.withLock(async () => {
357
- try {
358
- this.fileLock.acquire();
359
- }
360
- catch {
361
- return { filesChecked: 0, filesAdded: 0, filesModified: 0, filesRemoved: 0, nodesUpdated: 0, durationMs: 0 };
362
- }
363
- try {
364
- const result = await this.orchestrator.sync(options.onProgress);
365
- // Resolve references if files were updated
366
- if (result.filesAdded > 0 || result.filesModified > 0) {
367
- if (result.changedFilePaths) {
368
- // Scope resolution to changed files (git fast path — bounded set)
369
- const unresolvedRefs = this.queries.getUnresolvedReferencesByFiles(result.changedFilePaths);
370
- options.onProgress?.({
371
- phase: 'resolving',
372
- current: 0,
373
- total: unresolvedRefs.length,
374
- });
375
- this.resolver.resolveAndPersist(unresolvedRefs, (current, total) => {
376
- options.onProgress?.({
377
- phase: 'resolving',
378
- current,
379
- total,
380
- });
381
- });
382
- }
383
- else {
384
- // No git info — use batched resolution to avoid OOM
385
- const unresolvedCount = this.queries.getUnresolvedReferencesCount();
386
- options.onProgress?.({
387
- phase: 'resolving',
388
- current: 0,
389
- total: unresolvedCount,
390
- });
391
- await this.resolveReferencesBatched((current, total) => {
392
- options.onProgress?.({
393
- phase: 'resolving',
394
- current,
395
- total,
396
- });
397
- });
398
- }
399
- }
400
- return result;
401
- }
402
- finally {
403
- this.fileLock.release();
404
- }
405
- });
406
- }
407
- /**
408
- * Check if an indexing operation is currently in progress
409
- */
410
- isIndexing() {
411
- return this.indexMutex.isLocked();
412
- }
413
- // ===========================================================================
414
- // File Watching
415
- // ===========================================================================
416
- /**
417
- * Start watching for file changes and auto-syncing.
418
- *
419
- * Uses native OS file events (FSEvents on macOS, inotify on Linux 19+,
420
- * ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing.
421
- *
422
- * @param options - Watch options (debounce delay, callbacks)
423
- * @returns true if watching started successfully
424
- */
425
- watch(options = {}) {
426
- if (this.watcher?.isActive())
427
- return true;
428
- this.watcher = new sync_1.FileWatcher(this.projectRoot, this.config, async () => {
429
- const result = await this.sync();
430
- const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
431
- return { filesChanged, durationMs: result.durationMs };
432
- }, options);
433
- return this.watcher.start();
434
- }
435
- /**
436
- * Stop watching for file changes.
437
- */
438
- unwatch() {
439
- if (this.watcher) {
440
- this.watcher.stop();
441
- this.watcher = null;
442
- }
443
- }
444
- /**
445
- * Check if the file watcher is active.
446
- */
447
- isWatching() {
448
- return this.watcher?.isActive() ?? false;
449
- }
450
- /**
451
- * Get files that have changed since last index
452
- */
453
- getChangedFiles() {
454
- return this.orchestrator.getChangedFiles();
455
- }
456
- /**
457
- * Extract nodes and edges from source code (without storing)
458
- */
459
- extractFromSource(filePath, source) {
460
- return (0, extraction_1.extractFromSource)(filePath, source);
461
- }
462
- // ===========================================================================
463
- // Reference Resolution
464
- // ===========================================================================
465
- /**
466
- * Resolve unresolved references and create edges
467
- *
468
- * This method takes unresolved references from extraction and attempts
469
- * to resolve them using multiple strategies:
470
- * - Framework-specific patterns (React, Express, Laravel)
471
- * - Import-based resolution
472
- * - Name-based symbol matching
473
- */
474
- resolveReferences(onProgress) {
475
- // Get all unresolved references from the database
476
- const unresolvedRefs = this.queries.getUnresolvedReferences();
477
- return this.resolver.resolveAndPersist(unresolvedRefs, onProgress);
478
- }
479
- /**
480
- * Resolve references in batches to keep memory bounded on large codebases.
481
- * Processes chunks of unresolved refs, persisting results after each batch.
482
- */
483
- async resolveReferencesBatched(onProgress) {
484
- return this.resolver.resolveAndPersistBatched(onProgress);
485
- }
486
- /**
487
- * Get detected frameworks in the project
488
- */
489
- getDetectedFrameworks() {
490
- return this.resolver.getDetectedFrameworks();
491
- }
492
- /**
493
- * Re-initialize the resolver (useful after adding new files)
494
- */
495
- reinitializeResolver() {
496
- this.resolver.initialize();
497
- }
498
- // ===========================================================================
499
- // Graph Statistics
500
- // ===========================================================================
501
- /**
502
- * Get statistics about the knowledge graph
503
- */
504
- getStats() {
505
- const stats = this.queries.getStats();
506
- stats.dbSizeBytes = this.db.getSize();
507
- return stats;
508
- }
509
- /**
510
- * Active SQLite backend for this project's connection. `wasm` means
511
- * the native better-sqlite3 install failed and the WASM fallback is
512
- * serving requests at 5-10x the latency. Surfaced via `codegraph
513
- * status` and the `codegraph_status` MCP tool.
514
- */
515
- getBackend() {
516
- return this.db.getBackend();
517
- }
518
- // ===========================================================================
519
- // Node Operations
520
- // ===========================================================================
521
- /**
522
- * Get a node by ID
523
- */
524
- getNode(id) {
525
- return this.queries.getNodeById(id);
526
- }
527
- /**
528
- * Get all nodes in a file
529
- */
530
- getNodesInFile(filePath) {
531
- return this.queries.getNodesByFile(filePath);
532
- }
533
- /**
534
- * Get all nodes of a specific kind
535
- */
536
- getNodesByKind(kind) {
537
- return this.queries.getNodesByKind(kind);
538
- }
539
- /**
540
- * Search nodes by text
541
- */
542
- searchNodes(query, options) {
543
- return this.queries.searchNodes(query, options);
544
- }
545
- // ===========================================================================
546
- // Edge Operations
547
- // ===========================================================================
548
- /**
549
- * Get outgoing edges from a node
550
- */
551
- getOutgoingEdges(nodeId) {
552
- return this.queries.getOutgoingEdges(nodeId);
553
- }
554
- /**
555
- * Get incoming edges to a node
556
- */
557
- getIncomingEdges(nodeId) {
558
- return this.queries.getIncomingEdges(nodeId);
559
- }
560
- // ===========================================================================
561
- // File Operations
562
- // ===========================================================================
563
- /**
564
- * Get a file record by path
565
- */
566
- getFile(filePath) {
567
- return this.queries.getFileByPath(filePath);
568
- }
569
- /**
570
- * Get all tracked files
571
- */
572
- getFiles() {
573
- return this.queries.getAllFiles();
574
- }
575
- // ===========================================================================
576
- // Graph Query Methods
577
- // ===========================================================================
578
- /**
579
- * Get the context for a node (ancestors, children, references)
580
- *
581
- * Returns comprehensive context about a node including its containment
582
- * hierarchy, children, incoming/outgoing references, type information,
583
- * and relevant imports.
584
- *
585
- * @param nodeId - ID of the focal node
586
- * @returns Context object with all related information
587
- */
588
- getContext(nodeId) {
589
- return this.graphManager.getContext(nodeId);
590
- }
591
- /**
592
- * Traverse the graph from a starting node
593
- *
594
- * Uses breadth-first search by default. Supports filtering by edge types,
595
- * node types, and traversal direction.
596
- *
597
- * @param startId - Starting node ID
598
- * @param options - Traversal options
599
- * @returns Subgraph containing traversed nodes and edges
600
- */
601
- traverse(startId, options) {
602
- return this.traverser.traverseBFS(startId, options);
603
- }
604
- /**
605
- * Get the call graph for a function
606
- *
607
- * Returns both callers (functions that call this function) and
608
- * callees (functions called by this function) up to the specified depth.
609
- *
610
- * @param nodeId - ID of the function/method node
611
- * @param depth - Maximum depth in each direction (default: 2)
612
- * @returns Subgraph containing the call graph
613
- */
614
- getCallGraph(nodeId, depth = 2) {
615
- return this.traverser.getCallGraph(nodeId, depth);
616
- }
617
- /**
618
- * Get the type hierarchy for a class/interface
619
- *
620
- * Returns both ancestors (types this extends/implements) and
621
- * descendants (types that extend/implement this).
622
- *
623
- * @param nodeId - ID of the class/interface node
624
- * @returns Subgraph containing the type hierarchy
625
- */
626
- getTypeHierarchy(nodeId) {
627
- return this.traverser.getTypeHierarchy(nodeId);
628
- }
629
- /**
630
- * Find all usages of a symbol
631
- *
632
- * Returns all nodes that reference the specified symbol through
633
- * any edge type (calls, references, type_of, etc.).
634
- *
635
- * @param nodeId - ID of the symbol node
636
- * @returns Array of nodes and edges that reference this symbol
637
- */
638
- findUsages(nodeId) {
639
- return this.traverser.findUsages(nodeId);
640
- }
641
- /**
642
- * Get callers of a function/method
643
- *
644
- * @param nodeId - ID of the function/method node
645
- * @param maxDepth - Maximum depth to traverse (default: 1)
646
- * @returns Array of nodes that call this function
647
- */
648
- getCallers(nodeId, maxDepth = 1) {
649
- return this.traverser.getCallers(nodeId, maxDepth);
650
- }
651
- /**
652
- * Get callees of a function/method
653
- *
654
- * @param nodeId - ID of the function/method node
655
- * @param maxDepth - Maximum depth to traverse (default: 1)
656
- * @returns Array of nodes called by this function
657
- */
658
- getCallees(nodeId, maxDepth = 1) {
659
- return this.traverser.getCallees(nodeId, maxDepth);
660
- }
661
- /**
662
- * Calculate the impact radius of a node
663
- *
664
- * Returns all nodes that could be affected by changes to this node.
665
- *
666
- * @param nodeId - ID of the node
667
- * @param maxDepth - Maximum depth to traverse (default: 3)
668
- * @returns Subgraph containing potentially impacted nodes
669
- */
670
- getImpactRadius(nodeId, maxDepth = 3) {
671
- return this.traverser.getImpactRadius(nodeId, maxDepth);
672
- }
673
- /**
674
- * Find the shortest path between two nodes
675
- *
676
- * @param fromId - Starting node ID
677
- * @param toId - Target node ID
678
- * @param edgeKinds - Edge types to consider (all if empty)
679
- * @returns Array of nodes and edges forming the path, or null if no path exists
680
- */
681
- findPath(fromId, toId, edgeKinds) {
682
- return this.traverser.findPath(fromId, toId, edgeKinds);
683
- }
684
- /**
685
- * Get ancestors of a node in the containment hierarchy
686
- *
687
- * @param nodeId - ID of the node
688
- * @returns Array of ancestor nodes from immediate parent to root
689
- */
690
- getAncestors(nodeId) {
691
- return this.traverser.getAncestors(nodeId);
692
- }
693
- /**
694
- * Get immediate children of a node
695
- *
696
- * @param nodeId - ID of the node
697
- * @returns Array of child nodes
698
- */
699
- getChildren(nodeId) {
700
- return this.traverser.getChildren(nodeId);
701
- }
702
- /**
703
- * Get dependencies of a file
704
- *
705
- * @param filePath - Path to the file
706
- * @returns Array of file paths this file depends on
707
- */
708
- getFileDependencies(filePath) {
709
- return this.graphManager.getFileDependencies(filePath);
710
- }
711
- /**
712
- * Get dependents of a file
713
- *
714
- * @param filePath - Path to the file
715
- * @returns Array of file paths that depend on this file
716
- */
717
- getFileDependents(filePath) {
718
- return this.graphManager.getFileDependents(filePath);
719
- }
720
- /**
721
- * Find circular dependencies in the codebase
722
- *
723
- * @returns Array of cycles, each cycle is an array of file paths
724
- */
725
- findCircularDependencies() {
726
- return this.graphManager.findCircularDependencies();
727
- }
728
- /**
729
- * Find dead code (unreferenced symbols)
730
- *
731
- * @param kinds - Node kinds to check (default: functions, methods, classes)
732
- * @returns Array of unreferenced nodes
733
- */
734
- findDeadCode(kinds) {
735
- return this.graphManager.findDeadCode(kinds);
736
- }
737
- /**
738
- * Get complexity metrics for a node
739
- *
740
- * @param nodeId - ID of the node
741
- * @returns Object containing various complexity metrics
742
- */
743
- getNodeMetrics(nodeId) {
744
- return this.graphManager.getNodeMetrics(nodeId);
745
- }
746
- // ===========================================================================
747
- // Context Building
748
- // ===========================================================================
749
- /**
750
- * Get the source code for a node
751
- *
752
- * Reads the file and extracts the code between startLine and endLine.
753
- *
754
- * @param nodeId - ID of the node
755
- * @returns Code string or null if not found
756
- */
757
- async getCode(nodeId) {
758
- return this.contextBuilder.getCode(nodeId);
759
- }
760
- /**
761
- * Find relevant subgraph for a query
762
- *
763
- * Combines semantic search with graph traversal to find the most
764
- * relevant nodes and their relationships for a given query.
765
- *
766
- * @param query - Natural language query describing the task
767
- * @param options - Search and traversal options
768
- * @returns Subgraph of relevant nodes and edges
769
- */
770
- async findRelevantContext(query, options) {
771
- return this.contextBuilder.findRelevantContext(query, options);
772
- }
773
- /**
774
- * Build context for a task
775
- *
776
- * Creates comprehensive context by:
777
- * 1. Running FTS search to find entry points
778
- * 2. Expanding the graph around entry points
779
- * 3. Extracting code blocks for key nodes
780
- * 4. Formatting output for Claude
781
- *
782
- * @param input - Task description (string or {title, description})
783
- * @param options - Build options (maxNodes, includeCode, format, etc.)
784
- * @returns TaskContext object or formatted string (markdown/JSON)
785
- */
786
- async buildContext(input, options) {
787
- return this.contextBuilder.buildContext(input, options);
788
- }
789
- // ===========================================================================
790
- // Database Management
791
- // ===========================================================================
792
- /**
793
- * Optimize the database (vacuum and analyze)
794
- */
795
- optimize() {
796
- this.db.optimize();
797
- }
798
- /**
799
- * Clear all data from the graph
800
- */
801
- clear() {
802
- this.queries.clear();
803
- }
804
- /**
805
- * Alias for close() for backwards compatibility.
806
- * @deprecated Use close() instead
807
- */
808
- destroy() {
809
- this.close();
810
- }
811
- /**
812
- * Completely remove CodeGraph from the project.
813
- * This closes the database and deletes the .CodeGraph directory.
814
- *
815
- * WARNING: This permanently deletes all CodeGraph data for the project.
816
- */
817
- uninitialize() {
818
- this.close();
819
- (0, directory_1.removeDirectory)(this.projectRoot);
820
- }
821
- }
822
- exports.CodeGraph = CodeGraph;
823
- // Default export
824
- exports.default = CodeGraph;
825
- //# sourceMappingURL=index.js.map