homegraph 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 (549) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +709 -0
  3. package/dist/bin/codegraph.d.ts +26 -0
  4. package/dist/bin/codegraph.d.ts.map +1 -0
  5. package/dist/bin/codegraph.js +1572 -0
  6. package/dist/bin/codegraph.js.map +1 -0
  7. package/dist/bin/homegraph.d.ts +26 -0
  8. package/dist/bin/homegraph.d.ts.map +1 -0
  9. package/dist/bin/homegraph.js +1572 -0
  10. package/dist/bin/homegraph.js.map +1 -0
  11. package/dist/bin/node-version-check.d.ts +37 -0
  12. package/dist/bin/node-version-check.d.ts.map +1 -0
  13. package/dist/bin/node-version-check.js +79 -0
  14. package/dist/bin/node-version-check.js.map +1 -0
  15. package/dist/bin/uninstall.d.ts +14 -0
  16. package/dist/bin/uninstall.d.ts.map +1 -0
  17. package/dist/bin/uninstall.js +36 -0
  18. package/dist/bin/uninstall.js.map +1 -0
  19. package/dist/context/formatter.d.ts +30 -0
  20. package/dist/context/formatter.d.ts.map +1 -0
  21. package/dist/context/formatter.js +263 -0
  22. package/dist/context/formatter.js.map +1 -0
  23. package/dist/context/index.d.ts +119 -0
  24. package/dist/context/index.d.ts.map +1 -0
  25. package/dist/context/index.js +1289 -0
  26. package/dist/context/index.js.map +1 -0
  27. package/dist/context/markers.d.ts +19 -0
  28. package/dist/context/markers.d.ts.map +1 -0
  29. package/dist/context/markers.js +22 -0
  30. package/dist/context/markers.js.map +1 -0
  31. package/dist/db/index.d.ts +101 -0
  32. package/dist/db/index.d.ts.map +1 -0
  33. package/dist/db/index.js +250 -0
  34. package/dist/db/index.js.map +1 -0
  35. package/dist/db/migrations.d.ts +44 -0
  36. package/dist/db/migrations.d.ts.map +1 -0
  37. package/dist/db/migrations.js +131 -0
  38. package/dist/db/migrations.js.map +1 -0
  39. package/dist/db/queries.d.ts +386 -0
  40. package/dist/db/queries.d.ts.map +1 -0
  41. package/dist/db/queries.js +1562 -0
  42. package/dist/db/queries.js.map +1 -0
  43. package/dist/db/schema.sql +151 -0
  44. package/dist/db/sqlite-adapter.d.ts +53 -0
  45. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  46. package/dist/db/sqlite-adapter.js +117 -0
  47. package/dist/db/sqlite-adapter.js.map +1 -0
  48. package/dist/directory.d.ts +57 -0
  49. package/dist/directory.d.ts.map +1 -0
  50. package/dist/directory.js +253 -0
  51. package/dist/directory.js.map +1 -0
  52. package/dist/errors.d.ts +136 -0
  53. package/dist/errors.d.ts.map +1 -0
  54. package/dist/errors.js +219 -0
  55. package/dist/errors.js.map +1 -0
  56. package/dist/extraction/arkanalyzer-extractor.d.ts +6 -0
  57. package/dist/extraction/arkanalyzer-extractor.d.ts.map +1 -0
  58. package/dist/extraction/arkanalyzer-extractor.js +11 -0
  59. package/dist/extraction/arkanalyzer-extractor.js.map +1 -0
  60. package/dist/extraction/arkanalyzer-project.d.ts +20 -0
  61. package/dist/extraction/arkanalyzer-project.d.ts.map +1 -0
  62. package/dist/extraction/arkanalyzer-project.js +596 -0
  63. package/dist/extraction/arkanalyzer-project.js.map +1 -0
  64. package/dist/extraction/context.d.ts +12 -0
  65. package/dist/extraction/context.d.ts.map +1 -0
  66. package/dist/extraction/context.js +29 -0
  67. package/dist/extraction/context.js.map +1 -0
  68. package/dist/extraction/dfm-extractor.d.ts +31 -0
  69. package/dist/extraction/dfm-extractor.d.ts.map +1 -0
  70. package/dist/extraction/dfm-extractor.js +151 -0
  71. package/dist/extraction/dfm-extractor.js.map +1 -0
  72. package/dist/extraction/extraction-version.d.ts +25 -0
  73. package/dist/extraction/extraction-version.d.ts.map +1 -0
  74. package/dist/extraction/extraction-version.js +28 -0
  75. package/dist/extraction/extraction-version.js.map +1 -0
  76. package/dist/extraction/generated-detection.d.ts +30 -0
  77. package/dist/extraction/generated-detection.d.ts.map +1 -0
  78. package/dist/extraction/generated-detection.js +80 -0
  79. package/dist/extraction/generated-detection.js.map +1 -0
  80. package/dist/extraction/grammars.d.ts +108 -0
  81. package/dist/extraction/grammars.d.ts.map +1 -0
  82. package/dist/extraction/grammars.js +465 -0
  83. package/dist/extraction/grammars.js.map +1 -0
  84. package/dist/extraction/index.d.ts +138 -0
  85. package/dist/extraction/index.d.ts.map +1 -0
  86. package/dist/extraction/index.js +1396 -0
  87. package/dist/extraction/index.js.map +1 -0
  88. package/dist/extraction/languages/arkts.d.ts +18 -0
  89. package/dist/extraction/languages/arkts.d.ts.map +1 -0
  90. package/dist/extraction/languages/arkts.js +878 -0
  91. package/dist/extraction/languages/arkts.js.map +1 -0
  92. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  93. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  94. package/dist/extraction/languages/c-cpp.js +173 -0
  95. package/dist/extraction/languages/c-cpp.js.map +1 -0
  96. package/dist/extraction/languages/csharp.d.ts +25 -0
  97. package/dist/extraction/languages/csharp.d.ts.map +1 -0
  98. package/dist/extraction/languages/csharp.js +120 -0
  99. package/dist/extraction/languages/csharp.js.map +1 -0
  100. package/dist/extraction/languages/dart.d.ts +3 -0
  101. package/dist/extraction/languages/dart.d.ts.map +1 -0
  102. package/dist/extraction/languages/dart.js +192 -0
  103. package/dist/extraction/languages/dart.js.map +1 -0
  104. package/dist/extraction/languages/go.d.ts +3 -0
  105. package/dist/extraction/languages/go.d.ts.map +1 -0
  106. package/dist/extraction/languages/go.js +74 -0
  107. package/dist/extraction/languages/go.js.map +1 -0
  108. package/dist/extraction/languages/index.d.ts +10 -0
  109. package/dist/extraction/languages/index.d.ts.map +1 -0
  110. package/dist/extraction/languages/index.js +51 -0
  111. package/dist/extraction/languages/index.js.map +1 -0
  112. package/dist/extraction/languages/java.d.ts +3 -0
  113. package/dist/extraction/languages/java.d.ts.map +1 -0
  114. package/dist/extraction/languages/java.js +74 -0
  115. package/dist/extraction/languages/java.js.map +1 -0
  116. package/dist/extraction/languages/javascript.d.ts +3 -0
  117. package/dist/extraction/languages/javascript.d.ts.map +1 -0
  118. package/dist/extraction/languages/javascript.js +90 -0
  119. package/dist/extraction/languages/javascript.js.map +1 -0
  120. package/dist/extraction/languages/kotlin.d.ts +3 -0
  121. package/dist/extraction/languages/kotlin.d.ts.map +1 -0
  122. package/dist/extraction/languages/kotlin.js +285 -0
  123. package/dist/extraction/languages/kotlin.js.map +1 -0
  124. package/dist/extraction/languages/lua.d.ts +3 -0
  125. package/dist/extraction/languages/lua.d.ts.map +1 -0
  126. package/dist/extraction/languages/lua.js +150 -0
  127. package/dist/extraction/languages/lua.js.map +1 -0
  128. package/dist/extraction/languages/luau.d.ts +3 -0
  129. package/dist/extraction/languages/luau.d.ts.map +1 -0
  130. package/dist/extraction/languages/luau.js +37 -0
  131. package/dist/extraction/languages/luau.js.map +1 -0
  132. package/dist/extraction/languages/objc.d.ts +3 -0
  133. package/dist/extraction/languages/objc.d.ts.map +1 -0
  134. package/dist/extraction/languages/objc.js +133 -0
  135. package/dist/extraction/languages/objc.js.map +1 -0
  136. package/dist/extraction/languages/pascal.d.ts +3 -0
  137. package/dist/extraction/languages/pascal.d.ts.map +1 -0
  138. package/dist/extraction/languages/pascal.js +66 -0
  139. package/dist/extraction/languages/pascal.js.map +1 -0
  140. package/dist/extraction/languages/php.d.ts +3 -0
  141. package/dist/extraction/languages/php.d.ts.map +1 -0
  142. package/dist/extraction/languages/php.js +120 -0
  143. package/dist/extraction/languages/php.js.map +1 -0
  144. package/dist/extraction/languages/python.d.ts +3 -0
  145. package/dist/extraction/languages/python.d.ts.map +1 -0
  146. package/dist/extraction/languages/python.js +56 -0
  147. package/dist/extraction/languages/python.js.map +1 -0
  148. package/dist/extraction/languages/ruby.d.ts +3 -0
  149. package/dist/extraction/languages/ruby.d.ts.map +1 -0
  150. package/dist/extraction/languages/ruby.js +149 -0
  151. package/dist/extraction/languages/ruby.js.map +1 -0
  152. package/dist/extraction/languages/rust.d.ts +3 -0
  153. package/dist/extraction/languages/rust.d.ts.map +1 -0
  154. package/dist/extraction/languages/rust.js +113 -0
  155. package/dist/extraction/languages/rust.js.map +1 -0
  156. package/dist/extraction/languages/scala.d.ts +3 -0
  157. package/dist/extraction/languages/scala.d.ts.map +1 -0
  158. package/dist/extraction/languages/scala.js +174 -0
  159. package/dist/extraction/languages/scala.js.map +1 -0
  160. package/dist/extraction/languages/swift.d.ts +3 -0
  161. package/dist/extraction/languages/swift.d.ts.map +1 -0
  162. package/dist/extraction/languages/swift.js +91 -0
  163. package/dist/extraction/languages/swift.js.map +1 -0
  164. package/dist/extraction/languages/typescript.d.ts +3 -0
  165. package/dist/extraction/languages/typescript.d.ts.map +1 -0
  166. package/dist/extraction/languages/typescript.js +129 -0
  167. package/dist/extraction/languages/typescript.js.map +1 -0
  168. package/dist/extraction/liquid-extractor.d.ts +59 -0
  169. package/dist/extraction/liquid-extractor.d.ts.map +1 -0
  170. package/dist/extraction/liquid-extractor.js +354 -0
  171. package/dist/extraction/liquid-extractor.js.map +1 -0
  172. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  173. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  174. package/dist/extraction/mybatis-extractor.js +198 -0
  175. package/dist/extraction/mybatis-extractor.js.map +1 -0
  176. package/dist/extraction/parse-worker.d.ts +8 -0
  177. package/dist/extraction/parse-worker.d.ts.map +1 -0
  178. package/dist/extraction/parse-worker.js +94 -0
  179. package/dist/extraction/parse-worker.js.map +1 -0
  180. package/dist/extraction/razor-extractor.d.ts +42 -0
  181. package/dist/extraction/razor-extractor.d.ts.map +1 -0
  182. package/dist/extraction/razor-extractor.js +285 -0
  183. package/dist/extraction/razor-extractor.js.map +1 -0
  184. package/dist/extraction/svelte-extractor.d.ts +56 -0
  185. package/dist/extraction/svelte-extractor.d.ts.map +1 -0
  186. package/dist/extraction/svelte-extractor.js +272 -0
  187. package/dist/extraction/svelte-extractor.js.map +1 -0
  188. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  189. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  190. package/dist/extraction/tree-sitter-helpers.js +103 -0
  191. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  192. package/dist/extraction/tree-sitter-types.d.ts +210 -0
  193. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  194. package/dist/extraction/tree-sitter-types.js +10 -0
  195. package/dist/extraction/tree-sitter-types.js.map +1 -0
  196. package/dist/extraction/tree-sitter.d.ts +455 -0
  197. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  198. package/dist/extraction/tree-sitter.js +4089 -0
  199. package/dist/extraction/tree-sitter.js.map +1 -0
  200. package/dist/extraction/vue-extractor.d.ts +51 -0
  201. package/dist/extraction/vue-extractor.d.ts.map +1 -0
  202. package/dist/extraction/vue-extractor.js +251 -0
  203. package/dist/extraction/vue-extractor.js.map +1 -0
  204. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  205. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  206. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  207. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  208. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  209. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  210. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  211. package/dist/extraction/wasm-runtime-flags.js +106 -0
  212. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  213. package/dist/graph/index.d.ts +8 -0
  214. package/dist/graph/index.d.ts.map +1 -0
  215. package/dist/graph/index.js +13 -0
  216. package/dist/graph/index.js.map +1 -0
  217. package/dist/graph/queries.d.ts +106 -0
  218. package/dist/graph/queries.d.ts.map +1 -0
  219. package/dist/graph/queries.js +339 -0
  220. package/dist/graph/queries.js.map +1 -0
  221. package/dist/graph/traversal.d.ts +127 -0
  222. package/dist/graph/traversal.d.ts.map +1 -0
  223. package/dist/graph/traversal.js +531 -0
  224. package/dist/graph/traversal.js.map +1 -0
  225. package/dist/index.d.ts +522 -0
  226. package/dist/index.d.ts.map +1 -0
  227. package/dist/index.js +947 -0
  228. package/dist/index.js.map +1 -0
  229. package/dist/installer/config-writer.d.ts +28 -0
  230. package/dist/installer/config-writer.d.ts.map +1 -0
  231. package/dist/installer/config-writer.js +91 -0
  232. package/dist/installer/config-writer.js.map +1 -0
  233. package/dist/installer/index.d.ts +100 -0
  234. package/dist/installer/index.d.ts.map +1 -0
  235. package/dist/installer/index.js +497 -0
  236. package/dist/installer/index.js.map +1 -0
  237. package/dist/installer/instructions-template.d.ts +18 -0
  238. package/dist/installer/instructions-template.d.ts.map +1 -0
  239. package/dist/installer/instructions-template.js +21 -0
  240. package/dist/installer/instructions-template.js.map +1 -0
  241. package/dist/installer/targets/antigravity.d.ts +57 -0
  242. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  243. package/dist/installer/targets/antigravity.js +308 -0
  244. package/dist/installer/targets/antigravity.js.map +1 -0
  245. package/dist/installer/targets/claude.d.ts +56 -0
  246. package/dist/installer/targets/claude.d.ts.map +1 -0
  247. package/dist/installer/targets/claude.js +388 -0
  248. package/dist/installer/targets/claude.js.map +1 -0
  249. package/dist/installer/targets/codex.d.ts +18 -0
  250. package/dist/installer/targets/codex.d.ts.map +1 -0
  251. package/dist/installer/targets/codex.js +187 -0
  252. package/dist/installer/targets/codex.js.map +1 -0
  253. package/dist/installer/targets/cursor.d.ts +35 -0
  254. package/dist/installer/targets/cursor.d.ts.map +1 -0
  255. package/dist/installer/targets/cursor.js +254 -0
  256. package/dist/installer/targets/cursor.js.map +1 -0
  257. package/dist/installer/targets/gemini.d.ts +26 -0
  258. package/dist/installer/targets/gemini.d.ts.map +1 -0
  259. package/dist/installer/targets/gemini.js +167 -0
  260. package/dist/installer/targets/gemini.js.map +1 -0
  261. package/dist/installer/targets/hermes.d.ts +18 -0
  262. package/dist/installer/targets/hermes.d.ts.map +1 -0
  263. package/dist/installer/targets/hermes.js +359 -0
  264. package/dist/installer/targets/hermes.js.map +1 -0
  265. package/dist/installer/targets/kiro.d.ts +27 -0
  266. package/dist/installer/targets/kiro.d.ts.map +1 -0
  267. package/dist/installer/targets/kiro.js +178 -0
  268. package/dist/installer/targets/kiro.js.map +1 -0
  269. package/dist/installer/targets/opencode.d.ts +30 -0
  270. package/dist/installer/targets/opencode.d.ts.map +1 -0
  271. package/dist/installer/targets/opencode.js +237 -0
  272. package/dist/installer/targets/opencode.js.map +1 -0
  273. package/dist/installer/targets/registry.d.ts +35 -0
  274. package/dist/installer/targets/registry.d.ts.map +1 -0
  275. package/dist/installer/targets/registry.js +91 -0
  276. package/dist/installer/targets/registry.js.map +1 -0
  277. package/dist/installer/targets/shared.d.ts +77 -0
  278. package/dist/installer/targets/shared.d.ts.map +1 -0
  279. package/dist/installer/targets/shared.js +247 -0
  280. package/dist/installer/targets/shared.js.map +1 -0
  281. package/dist/installer/targets/toml.d.ts +52 -0
  282. package/dist/installer/targets/toml.d.ts.map +1 -0
  283. package/dist/installer/targets/toml.js +147 -0
  284. package/dist/installer/targets/toml.js.map +1 -0
  285. package/dist/installer/targets/types.d.ts +101 -0
  286. package/dist/installer/targets/types.d.ts.map +1 -0
  287. package/dist/installer/targets/types.js +16 -0
  288. package/dist/installer/targets/types.js.map +1 -0
  289. package/dist/mcp/daemon-paths.d.ts +46 -0
  290. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  291. package/dist/mcp/daemon-paths.js +125 -0
  292. package/dist/mcp/daemon-paths.js.map +1 -0
  293. package/dist/mcp/daemon.d.ts +220 -0
  294. package/dist/mcp/daemon.d.ts.map +1 -0
  295. package/dist/mcp/daemon.js +616 -0
  296. package/dist/mcp/daemon.js.map +1 -0
  297. package/dist/mcp/engine.d.ts +105 -0
  298. package/dist/mcp/engine.d.ts.map +1 -0
  299. package/dist/mcp/engine.js +270 -0
  300. package/dist/mcp/engine.js.map +1 -0
  301. package/dist/mcp/index.d.ts +112 -0
  302. package/dist/mcp/index.d.ts.map +1 -0
  303. package/dist/mcp/index.js +478 -0
  304. package/dist/mcp/index.js.map +1 -0
  305. package/dist/mcp/ppid-watchdog.d.ts +44 -0
  306. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  307. package/dist/mcp/ppid-watchdog.js +27 -0
  308. package/dist/mcp/ppid-watchdog.js.map +1 -0
  309. package/dist/mcp/proxy.d.ts +81 -0
  310. package/dist/mcp/proxy.d.ts.map +1 -0
  311. package/dist/mcp/proxy.js +584 -0
  312. package/dist/mcp/proxy.js.map +1 -0
  313. package/dist/mcp/server-instructions.d.ts +19 -0
  314. package/dist/mcp/server-instructions.d.ts.map +1 -0
  315. package/dist/mcp/server-instructions.js +74 -0
  316. package/dist/mcp/server-instructions.js.map +1 -0
  317. package/dist/mcp/session.d.ts +77 -0
  318. package/dist/mcp/session.d.ts.map +1 -0
  319. package/dist/mcp/session.js +294 -0
  320. package/dist/mcp/session.js.map +1 -0
  321. package/dist/mcp/tools.d.ts +413 -0
  322. package/dist/mcp/tools.d.ts.map +1 -0
  323. package/dist/mcp/tools.js +3049 -0
  324. package/dist/mcp/tools.js.map +1 -0
  325. package/dist/mcp/transport.d.ts +188 -0
  326. package/dist/mcp/transport.d.ts.map +1 -0
  327. package/dist/mcp/transport.js +343 -0
  328. package/dist/mcp/transport.js.map +1 -0
  329. package/dist/mcp/version.d.ts +19 -0
  330. package/dist/mcp/version.d.ts.map +1 -0
  331. package/dist/mcp/version.js +71 -0
  332. package/dist/mcp/version.js.map +1 -0
  333. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  334. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  335. package/dist/resolution/callback-synthesizer.js +1818 -0
  336. package/dist/resolution/callback-synthesizer.js.map +1 -0
  337. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  338. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  339. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  340. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  341. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  342. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  343. package/dist/resolution/frameworks/csharp.js +241 -0
  344. package/dist/resolution/frameworks/csharp.js.map +1 -0
  345. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  346. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  347. package/dist/resolution/frameworks/drupal.js +367 -0
  348. package/dist/resolution/frameworks/drupal.js.map +1 -0
  349. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  350. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  351. package/dist/resolution/frameworks/expo-modules.js +148 -0
  352. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  353. package/dist/resolution/frameworks/express.d.ts +8 -0
  354. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  355. package/dist/resolution/frameworks/express.js +308 -0
  356. package/dist/resolution/frameworks/express.js.map +1 -0
  357. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  358. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  359. package/dist/resolution/frameworks/fabric.js +354 -0
  360. package/dist/resolution/frameworks/fabric.js.map +1 -0
  361. package/dist/resolution/frameworks/go.d.ts +8 -0
  362. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  363. package/dist/resolution/frameworks/go.js +161 -0
  364. package/dist/resolution/frameworks/go.js.map +1 -0
  365. package/dist/resolution/frameworks/index.d.ts +48 -0
  366. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  367. package/dist/resolution/frameworks/index.js +161 -0
  368. package/dist/resolution/frameworks/index.js.map +1 -0
  369. package/dist/resolution/frameworks/java.d.ts +8 -0
  370. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  371. package/dist/resolution/frameworks/java.js +504 -0
  372. package/dist/resolution/frameworks/java.js.map +1 -0
  373. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  374. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  375. package/dist/resolution/frameworks/laravel.js +257 -0
  376. package/dist/resolution/frameworks/laravel.js.map +1 -0
  377. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  378. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  379. package/dist/resolution/frameworks/nestjs.js +698 -0
  380. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  381. package/dist/resolution/frameworks/play.d.ts +19 -0
  382. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  383. package/dist/resolution/frameworks/play.js +111 -0
  384. package/dist/resolution/frameworks/play.js.map +1 -0
  385. package/dist/resolution/frameworks/python.d.ts +10 -0
  386. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  387. package/dist/resolution/frameworks/python.js +400 -0
  388. package/dist/resolution/frameworks/python.js.map +1 -0
  389. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  390. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  391. package/dist/resolution/frameworks/react-native.js +410 -0
  392. package/dist/resolution/frameworks/react-native.js.map +1 -0
  393. package/dist/resolution/frameworks/react.d.ts +8 -0
  394. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  395. package/dist/resolution/frameworks/react.js +365 -0
  396. package/dist/resolution/frameworks/react.js.map +1 -0
  397. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  398. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  399. package/dist/resolution/frameworks/ruby.js +302 -0
  400. package/dist/resolution/frameworks/ruby.js.map +1 -0
  401. package/dist/resolution/frameworks/rust.d.ts +8 -0
  402. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  403. package/dist/resolution/frameworks/rust.js +304 -0
  404. package/dist/resolution/frameworks/rust.js.map +1 -0
  405. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  406. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  407. package/dist/resolution/frameworks/svelte.js +249 -0
  408. package/dist/resolution/frameworks/svelte.js.map +1 -0
  409. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  410. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  411. package/dist/resolution/frameworks/swift-objc.js +252 -0
  412. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  413. package/dist/resolution/frameworks/swift.d.ts +10 -0
  414. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  415. package/dist/resolution/frameworks/swift.js +400 -0
  416. package/dist/resolution/frameworks/swift.js.map +1 -0
  417. package/dist/resolution/frameworks/vue.d.ts +9 -0
  418. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  419. package/dist/resolution/frameworks/vue.js +306 -0
  420. package/dist/resolution/frameworks/vue.js.map +1 -0
  421. package/dist/resolution/go-module.d.ts +26 -0
  422. package/dist/resolution/go-module.d.ts.map +1 -0
  423. package/dist/resolution/go-module.js +78 -0
  424. package/dist/resolution/go-module.js.map +1 -0
  425. package/dist/resolution/import-resolver.d.ts +68 -0
  426. package/dist/resolution/import-resolver.d.ts.map +1 -0
  427. package/dist/resolution/import-resolver.js +1726 -0
  428. package/dist/resolution/import-resolver.js.map +1 -0
  429. package/dist/resolution/index.d.ts +159 -0
  430. package/dist/resolution/index.d.ts.map +1 -0
  431. package/dist/resolution/index.js +1025 -0
  432. package/dist/resolution/index.js.map +1 -0
  433. package/dist/resolution/lru-cache.d.ts +24 -0
  434. package/dist/resolution/lru-cache.d.ts.map +1 -0
  435. package/dist/resolution/lru-cache.js +62 -0
  436. package/dist/resolution/lru-cache.js.map +1 -0
  437. package/dist/resolution/name-matcher.d.ts +52 -0
  438. package/dist/resolution/name-matcher.d.ts.map +1 -0
  439. package/dist/resolution/name-matcher.js +707 -0
  440. package/dist/resolution/name-matcher.js.map +1 -0
  441. package/dist/resolution/path-aliases.d.ts +68 -0
  442. package/dist/resolution/path-aliases.d.ts.map +1 -0
  443. package/dist/resolution/path-aliases.js +238 -0
  444. package/dist/resolution/path-aliases.js.map +1 -0
  445. package/dist/resolution/strip-comments.d.ts +27 -0
  446. package/dist/resolution/strip-comments.d.ts.map +1 -0
  447. package/dist/resolution/strip-comments.js +441 -0
  448. package/dist/resolution/strip-comments.js.map +1 -0
  449. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  450. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  451. package/dist/resolution/swift-objc-bridge.js +256 -0
  452. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  453. package/dist/resolution/types.d.ts +216 -0
  454. package/dist/resolution/types.d.ts.map +1 -0
  455. package/dist/resolution/types.js +8 -0
  456. package/dist/resolution/types.js.map +1 -0
  457. package/dist/resolution/workspace-packages.d.ts +48 -0
  458. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  459. package/dist/resolution/workspace-packages.js +208 -0
  460. package/dist/resolution/workspace-packages.js.map +1 -0
  461. package/dist/search/query-parser.d.ts +57 -0
  462. package/dist/search/query-parser.d.ts.map +1 -0
  463. package/dist/search/query-parser.js +177 -0
  464. package/dist/search/query-parser.js.map +1 -0
  465. package/dist/search/query-utils.d.ts +71 -0
  466. package/dist/search/query-utils.d.ts.map +1 -0
  467. package/dist/search/query-utils.js +380 -0
  468. package/dist/search/query-utils.js.map +1 -0
  469. package/dist/sync/git-hooks.d.ts +45 -0
  470. package/dist/sync/git-hooks.d.ts.map +1 -0
  471. package/dist/sync/git-hooks.js +225 -0
  472. package/dist/sync/git-hooks.js.map +1 -0
  473. package/dist/sync/index.d.ts +19 -0
  474. package/dist/sync/index.d.ts.map +1 -0
  475. package/dist/sync/index.js +35 -0
  476. package/dist/sync/index.js.map +1 -0
  477. package/dist/sync/watch-policy.d.ts +48 -0
  478. package/dist/sync/watch-policy.d.ts.map +1 -0
  479. package/dist/sync/watch-policy.js +124 -0
  480. package/dist/sync/watch-policy.js.map +1 -0
  481. package/dist/sync/watcher.d.ts +283 -0
  482. package/dist/sync/watcher.d.ts.map +1 -0
  483. package/dist/sync/watcher.js +606 -0
  484. package/dist/sync/watcher.js.map +1 -0
  485. package/dist/sync/worktree.d.ts +54 -0
  486. package/dist/sync/worktree.d.ts.map +1 -0
  487. package/dist/sync/worktree.js +137 -0
  488. package/dist/sync/worktree.js.map +1 -0
  489. package/dist/types.d.ts +377 -0
  490. package/dist/types.d.ts.map +1 -0
  491. package/dist/types.js +80 -0
  492. package/dist/types.js.map +1 -0
  493. package/dist/ui/glyphs.d.ts +42 -0
  494. package/dist/ui/glyphs.d.ts.map +1 -0
  495. package/dist/ui/glyphs.js +78 -0
  496. package/dist/ui/glyphs.js.map +1 -0
  497. package/dist/ui/shimmer-progress.d.ts +11 -0
  498. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  499. package/dist/ui/shimmer-progress.js +90 -0
  500. package/dist/ui/shimmer-progress.js.map +1 -0
  501. package/dist/ui/shimmer-worker.d.ts +2 -0
  502. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  503. package/dist/ui/shimmer-worker.js +118 -0
  504. package/dist/ui/shimmer-worker.js.map +1 -0
  505. package/dist/ui/types.d.ts +17 -0
  506. package/dist/ui/types.d.ts.map +1 -0
  507. package/dist/ui/types.js +3 -0
  508. package/dist/ui/types.js.map +1 -0
  509. package/dist/upgrade/index.d.ts +132 -0
  510. package/dist/upgrade/index.d.ts.map +1 -0
  511. package/dist/upgrade/index.js +462 -0
  512. package/dist/upgrade/index.js.map +1 -0
  513. package/dist/utils.d.ts +205 -0
  514. package/dist/utils.d.ts.map +1 -0
  515. package/dist/utils.js +549 -0
  516. package/dist/utils.js.map +1 -0
  517. package/package.json +57 -0
  518. package/scripts/add-lang/bench.sh +60 -0
  519. package/scripts/add-lang/check-grammar.mjs +75 -0
  520. package/scripts/add-lang/dump-ast.mjs +103 -0
  521. package/scripts/add-lang/verify-extraction.mjs +70 -0
  522. package/scripts/agent-eval/arms-F.sh +21 -0
  523. package/scripts/agent-eval/arms-matrix.sh +37 -0
  524. package/scripts/agent-eval/audit.sh +68 -0
  525. package/scripts/agent-eval/bench-readme.sh +28 -0
  526. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  527. package/scripts/agent-eval/block-read-hook.sh +19 -0
  528. package/scripts/agent-eval/hook-settings.json +15 -0
  529. package/scripts/agent-eval/itrun.sh +120 -0
  530. package/scripts/agent-eval/parse-arms.mjs +116 -0
  531. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  532. package/scripts/agent-eval/parse-run.mjs +45 -0
  533. package/scripts/agent-eval/parse-session.mjs +93 -0
  534. package/scripts/agent-eval/probe-context.mjs +21 -0
  535. package/scripts/agent-eval/probe-explore.mjs +40 -0
  536. package/scripts/agent-eval/probe-node.mjs +20 -0
  537. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  538. package/scripts/agent-eval/probe-trace.mjs +20 -0
  539. package/scripts/agent-eval/run-agent.sh +34 -0
  540. package/scripts/agent-eval/run-all.sh +67 -0
  541. package/scripts/agent-eval/run-arms.sh +56 -0
  542. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  543. package/scripts/build-bundle.sh +118 -0
  544. package/scripts/extract-release-notes.mjs +130 -0
  545. package/scripts/local-install.sh +41 -0
  546. package/scripts/npm-sdk.js +75 -0
  547. package/scripts/npm-shim.js +246 -0
  548. package/scripts/pack-npm.sh +119 -0
  549. package/scripts/prepare-release.mjs +270 -0
package/dist/index.js ADDED
@@ -0,0 +1,947 @@
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.LockUnavailableError = 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.HOMEGRAPH_DIR = exports.findNearestCodeGraphRoot = exports.isInitialized = exports.getCodeGraphDir = exports.QueryBuilder = exports.DatabaseConnection = 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 directory_1 = require("./directory");
50
+ const extraction_1 = require("./extraction");
51
+ const context_1 = require("./extraction/context");
52
+ const resolution_1 = require("./resolution");
53
+ const graph_1 = require("./graph");
54
+ const context_2 = require("./context");
55
+ const utils_1 = require("./utils");
56
+ const sync_1 = require("./sync");
57
+ const extraction_version_1 = require("./extraction/extraction-version");
58
+ const version_1 = require("./mcp/version");
59
+ // Re-export types for consumers
60
+ __exportStar(require("./types"), exports);
61
+ // Storage building blocks for embedded/SDK consumers that drive the graph
62
+ // directly (open a DB, run prepared queries) rather than through the CodeGraph
63
+ // facade. Exposed from the package entry so they no longer require deep imports
64
+ // into dist/ (issue #354).
65
+ var db_2 = require("./db");
66
+ Object.defineProperty(exports, "getDatabasePath", { enumerable: true, get: function () { return db_2.getDatabasePath; } });
67
+ Object.defineProperty(exports, "DatabaseConnection", { enumerable: true, get: function () { return db_2.DatabaseConnection; } });
68
+ var queries_2 = require("./db/queries");
69
+ Object.defineProperty(exports, "QueryBuilder", { enumerable: true, get: function () { return queries_2.QueryBuilder; } });
70
+ var directory_2 = require("./directory");
71
+ Object.defineProperty(exports, "getCodeGraphDir", { enumerable: true, get: function () { return directory_2.getCodeGraphDir; } });
72
+ Object.defineProperty(exports, "isInitialized", { enumerable: true, get: function () { return directory_2.isInitialized; } });
73
+ Object.defineProperty(exports, "findNearestCodeGraphRoot", { enumerable: true, get: function () { return directory_2.findNearestCodeGraphRoot; } });
74
+ Object.defineProperty(exports, "HOMEGRAPH_DIR", { enumerable: true, get: function () { return directory_2.HOMEGRAPH_DIR; } });
75
+ var extraction_2 = require("./extraction");
76
+ Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return extraction_2.detectLanguage; } });
77
+ Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return extraction_2.isLanguageSupported; } });
78
+ Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return extraction_2.isGrammarLoaded; } });
79
+ Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return extraction_2.getSupportedLanguages; } });
80
+ Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return extraction_2.initGrammars; } });
81
+ Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return extraction_2.loadGrammarsForLanguages; } });
82
+ Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return extraction_2.loadAllGrammars; } });
83
+ var errors_1 = require("./errors");
84
+ Object.defineProperty(exports, "CodeGraphError", { enumerable: true, get: function () { return errors_1.CodeGraphError; } });
85
+ Object.defineProperty(exports, "FileError", { enumerable: true, get: function () { return errors_1.FileError; } });
86
+ Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_1.ParseError; } });
87
+ Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_1.DatabaseError; } });
88
+ Object.defineProperty(exports, "SearchError", { enumerable: true, get: function () { return errors_1.SearchError; } });
89
+ Object.defineProperty(exports, "VectorError", { enumerable: true, get: function () { return errors_1.VectorError; } });
90
+ Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_1.ConfigError; } });
91
+ Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return errors_1.setLogger; } });
92
+ Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return errors_1.getLogger; } });
93
+ Object.defineProperty(exports, "silentLogger", { enumerable: true, get: function () { return errors_1.silentLogger; } });
94
+ Object.defineProperty(exports, "defaultLogger", { enumerable: true, get: function () { return errors_1.defaultLogger; } });
95
+ var utils_2 = require("./utils");
96
+ Object.defineProperty(exports, "Mutex", { enumerable: true, get: function () { return utils_2.Mutex; } });
97
+ Object.defineProperty(exports, "FileLock", { enumerable: true, get: function () { return utils_2.FileLock; } });
98
+ Object.defineProperty(exports, "processInBatches", { enumerable: true, get: function () { return utils_2.processInBatches; } });
99
+ Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return utils_2.debounce; } });
100
+ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return utils_2.throttle; } });
101
+ Object.defineProperty(exports, "MemoryMonitor", { enumerable: true, get: function () { return utils_2.MemoryMonitor; } });
102
+ var sync_2 = require("./sync");
103
+ Object.defineProperty(exports, "FileWatcher", { enumerable: true, get: function () { return sync_2.FileWatcher; } });
104
+ Object.defineProperty(exports, "LockUnavailableError", { enumerable: true, get: function () { return sync_2.LockUnavailableError; } });
105
+ var mcp_1 = require("./mcp");
106
+ Object.defineProperty(exports, "MCPServer", { enumerable: true, get: function () { return mcp_1.MCPServer; } });
107
+ /**
108
+ * Main CodeGraph class
109
+ *
110
+ * Provides the primary interface for interacting with the code knowledge graph.
111
+ */
112
+ class CodeGraph {
113
+ db;
114
+ queries;
115
+ projectRoot;
116
+ orchestrator;
117
+ resolver;
118
+ graphManager;
119
+ traverser;
120
+ contextBuilder;
121
+ // Mutex for preventing concurrent indexing operations (in-process)
122
+ indexMutex = new utils_1.Mutex();
123
+ // File lock for preventing concurrent writes across processes (CLI, MCP, git hooks)
124
+ fileLock;
125
+ // File watcher for auto-sync on file changes
126
+ watcher = null;
127
+ constructor(db, queries, projectRoot) {
128
+ this.db = db;
129
+ this.queries = queries;
130
+ this.projectRoot = projectRoot;
131
+ (0, context_1.bindExtractionContext)(projectRoot, queries);
132
+ this.fileLock = new utils_1.FileLock(path.join(projectRoot, '.homegraph', 'homegraph.lock'));
133
+ this.orchestrator = new extraction_1.ExtractionOrchestrator(projectRoot, queries);
134
+ this.resolver = (0, resolution_1.createResolver)(projectRoot, queries);
135
+ this.graphManager = new graph_1.GraphQueryManager(queries);
136
+ this.traverser = new graph_1.GraphTraverser(queries);
137
+ this.contextBuilder = (0, context_2.createContextBuilder)(projectRoot, queries, this.traverser);
138
+ }
139
+ // ===========================================================================
140
+ // Lifecycle Methods
141
+ // ===========================================================================
142
+ /**
143
+ * Initialize a new CodeGraph project
144
+ *
145
+ * Creates the .CodeGraph directory, database, and configuration.
146
+ *
147
+ * @param projectRoot - Path to the project root directory
148
+ * @param options - Initialization options
149
+ * @returns A new CodeGraph instance
150
+ */
151
+ static async init(projectRoot, options = {}) {
152
+ await (0, extraction_1.initGrammars)();
153
+ const resolvedRoot = path.resolve(projectRoot);
154
+ // Check if already initialized
155
+ if ((0, directory_1.isInitialized)(resolvedRoot)) {
156
+ throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
157
+ }
158
+ // Create directory structure
159
+ (0, directory_1.createDirectory)(resolvedRoot);
160
+ // Initialize database
161
+ const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
162
+ const db = db_1.DatabaseConnection.initialize(dbPath);
163
+ const queries = new queries_1.QueryBuilder(db.getDb());
164
+ const instance = new CodeGraph(db, queries, resolvedRoot);
165
+ // Run initial indexing if requested
166
+ if (options.index) {
167
+ await instance.indexAll({ onProgress: options.onProgress });
168
+ }
169
+ return instance;
170
+ }
171
+ /**
172
+ * Initialize synchronously (without indexing)
173
+ */
174
+ static initSync(projectRoot) {
175
+ const resolvedRoot = path.resolve(projectRoot);
176
+ // Check if already initialized
177
+ if ((0, directory_1.isInitialized)(resolvedRoot)) {
178
+ throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
179
+ }
180
+ // Create directory structure
181
+ (0, directory_1.createDirectory)(resolvedRoot);
182
+ // Initialize database
183
+ const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
184
+ const db = db_1.DatabaseConnection.initialize(dbPath);
185
+ const queries = new queries_1.QueryBuilder(db.getDb());
186
+ return new CodeGraph(db, queries, resolvedRoot);
187
+ }
188
+ /**
189
+ * Open an existing CodeGraph project
190
+ *
191
+ * @param projectRoot - Path to the project root directory
192
+ * @param options - Open options
193
+ * @returns A CodeGraph instance
194
+ */
195
+ static async open(projectRoot, options = {}) {
196
+ await (0, extraction_1.initGrammars)();
197
+ const resolvedRoot = path.resolve(projectRoot);
198
+ // Check if initialized
199
+ if (!(0, directory_1.isInitialized)(resolvedRoot)) {
200
+ throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
201
+ }
202
+ // Validate directory structure
203
+ const validation = (0, directory_1.validateDirectory)(resolvedRoot);
204
+ if (!validation.valid) {
205
+ throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
206
+ }
207
+ // Open database
208
+ const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
209
+ const db = db_1.DatabaseConnection.open(dbPath);
210
+ const queries = new queries_1.QueryBuilder(db.getDb());
211
+ const instance = new CodeGraph(db, queries, resolvedRoot);
212
+ // Sync if requested
213
+ if (options.sync) {
214
+ await instance.sync();
215
+ }
216
+ return instance;
217
+ }
218
+ /**
219
+ * Open synchronously (without sync)
220
+ */
221
+ static openSync(projectRoot) {
222
+ const resolvedRoot = path.resolve(projectRoot);
223
+ // Check if initialized
224
+ if (!(0, directory_1.isInitialized)(resolvedRoot)) {
225
+ throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
226
+ }
227
+ // Validate directory structure
228
+ const validation = (0, directory_1.validateDirectory)(resolvedRoot);
229
+ if (!validation.valid) {
230
+ throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
231
+ }
232
+ // Open database
233
+ const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
234
+ const db = db_1.DatabaseConnection.open(dbPath);
235
+ const queries = new queries_1.QueryBuilder(db.getDb());
236
+ return new CodeGraph(db, queries, resolvedRoot);
237
+ }
238
+ /**
239
+ * Check if a directory has been initialized as a CodeGraph project
240
+ */
241
+ static isInitialized(projectRoot) {
242
+ return (0, directory_1.isInitialized)(path.resolve(projectRoot));
243
+ }
244
+ /**
245
+ * Close the CodeGraph instance and release resources
246
+ */
247
+ close() {
248
+ this.unwatch();
249
+ // Release file lock if held
250
+ this.fileLock.release();
251
+ this.db.close();
252
+ }
253
+ /**
254
+ * Get the project root directory
255
+ */
256
+ getProjectRoot() {
257
+ return this.projectRoot;
258
+ }
259
+ // ===========================================================================
260
+ // Indexing
261
+ // ===========================================================================
262
+ /**
263
+ * Index all files in the project
264
+ *
265
+ * Uses a mutex to prevent concurrent indexing operations.
266
+ */
267
+ async indexAll(options = {}) {
268
+ return this.indexMutex.withLock(async () => {
269
+ try {
270
+ this.fileLock.acquire();
271
+ }
272
+ catch {
273
+ 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 };
274
+ }
275
+ try {
276
+ const before = this.queries.getNodeAndEdgeCount();
277
+ const result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose);
278
+ // Re-detect frameworks now that the index is populated. The resolver
279
+ // is constructed with createResolver() before any files exist, so
280
+ // framework resolvers whose detect() consults the indexed file list
281
+ // (e.g. UIKit/SwiftUI scanning for imports, swift-objc-bridge looking
282
+ // for both Swift and ObjC files) all return false on that initial pass
283
+ // and silently drop themselves. Re-initializing here gives them a
284
+ // chance to see the actual project before resolution runs.
285
+ if (result.success && result.filesIndexed > 0) {
286
+ this.resolver.initialize();
287
+ // Cross-file finalization (e.g. NestJS RouterModule prefixes). Runs
288
+ // before resolution so updated names show up in subsequent reads.
289
+ this.resolver.runPostExtract();
290
+ }
291
+ // Resolve references to create call/import/extends edges
292
+ if (result.success && result.filesIndexed > 0) {
293
+ // Get count without loading all refs into memory
294
+ const unresolvedCount = this.queries.getUnresolvedReferencesCount();
295
+ options.onProgress?.({
296
+ phase: 'resolving',
297
+ current: 0,
298
+ total: unresolvedCount,
299
+ });
300
+ await this.resolveReferencesBatched((current, total) => {
301
+ options.onProgress?.({
302
+ phase: 'resolving',
303
+ current,
304
+ total,
305
+ });
306
+ });
307
+ }
308
+ // Refresh planner stats + checkpoint the WAL after bulk writes.
309
+ // Cheap and non-blocking; never load-bearing for correctness.
310
+ if (result.success && result.filesIndexed > 0) {
311
+ this.db.runMaintenance();
312
+ }
313
+ // The orchestrator only sees extraction-phase counts; resolution and
314
+ // synthesizer edges (often >50% of the graph on JVM repos) come later.
315
+ // Recompute against the DB so the CLI summary reports the true totals.
316
+ if (result.success && result.filesIndexed > 0) {
317
+ const after = this.queries.getNodeAndEdgeCount();
318
+ result.nodesCreated = after.nodes - before.nodes;
319
+ result.edgesCreated = after.edges - before.edges;
320
+ }
321
+ // Stamp the index with the engine that built it, so `homegraph status`
322
+ // and `homegraph upgrade` can recommend a re-index when the running
323
+ // engine produces richer extraction than the one on disk. Only on a
324
+ // real full index — a sync touches a subset, so it must NOT advance the
325
+ // extraction stamp (the bulk would still be stale). See extraction-version.ts.
326
+ if (result.success && result.filesIndexed > 0) {
327
+ try {
328
+ this.queries.setMetadata('indexed_with_version', version_1.CodeGraphPackageVersion);
329
+ this.queries.setMetadata('indexed_with_extraction_version', String(extraction_version_1.EXTRACTION_VERSION));
330
+ }
331
+ catch { /* metadata is advisory — never fail an index over it */ }
332
+ }
333
+ return result;
334
+ }
335
+ finally {
336
+ this.fileLock.release();
337
+ }
338
+ });
339
+ }
340
+ /**
341
+ * Index specific files
342
+ *
343
+ * Uses a mutex to prevent concurrent indexing operations.
344
+ */
345
+ async indexFiles(filePaths) {
346
+ return this.indexMutex.withLock(async () => {
347
+ try {
348
+ this.fileLock.acquire();
349
+ }
350
+ catch {
351
+ 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 };
352
+ }
353
+ try {
354
+ return this.orchestrator.indexFiles(filePaths);
355
+ }
356
+ finally {
357
+ this.fileLock.release();
358
+ }
359
+ });
360
+ }
361
+ /**
362
+ * Sync with current file state (incremental update)
363
+ *
364
+ * Uses a mutex to prevent concurrent indexing operations.
365
+ */
366
+ async sync(options = {}) {
367
+ return this.indexMutex.withLock(async () => {
368
+ try {
369
+ this.fileLock.acquire();
370
+ }
371
+ catch {
372
+ return { filesChecked: 0, filesAdded: 0, filesModified: 0, filesRemoved: 0, nodesUpdated: 0, durationMs: 0 };
373
+ }
374
+ try {
375
+ const result = await this.orchestrator.sync(options.onProgress);
376
+ // Cross-file finalization (e.g. NestJS RouterModule prefixes). Run on
377
+ // every sync that touched files so edits to `app.module.ts` propagate
378
+ // to controllers in unchanged files. The pass is idempotent and cheap
379
+ // (regex over *.module.ts only).
380
+ if (result.filesAdded > 0 || result.filesModified > 0) {
381
+ this.resolver.runPostExtract();
382
+ }
383
+ // Resolve references if files were updated
384
+ if (result.filesAdded > 0 || result.filesModified > 0) {
385
+ if (result.changedFilePaths) {
386
+ // Scope resolution to changed files (git fast path — bounded set)
387
+ const unresolvedRefs = this.queries.getUnresolvedReferencesByFiles(result.changedFilePaths);
388
+ options.onProgress?.({
389
+ phase: 'resolving',
390
+ current: 0,
391
+ total: unresolvedRefs.length,
392
+ });
393
+ this.resolver.resolveAndPersist(unresolvedRefs, (current, total) => {
394
+ options.onProgress?.({
395
+ phase: 'resolving',
396
+ current,
397
+ total,
398
+ });
399
+ });
400
+ }
401
+ else {
402
+ // No git info — use batched resolution to avoid OOM
403
+ const unresolvedCount = this.queries.getUnresolvedReferencesCount();
404
+ options.onProgress?.({
405
+ phase: 'resolving',
406
+ current: 0,
407
+ total: unresolvedCount,
408
+ });
409
+ await this.resolveReferencesBatched((current, total) => {
410
+ options.onProgress?.({
411
+ phase: 'resolving',
412
+ current,
413
+ total,
414
+ });
415
+ });
416
+ }
417
+ }
418
+ // Refresh planner stats + checkpoint the WAL after bulk writes.
419
+ if (result.filesAdded > 0 || result.filesModified > 0 || result.filesRemoved > 0) {
420
+ this.db.runMaintenance();
421
+ }
422
+ return result;
423
+ }
424
+ finally {
425
+ this.fileLock.release();
426
+ }
427
+ });
428
+ }
429
+ /**
430
+ * Check if an indexing operation is currently in progress
431
+ */
432
+ isIndexing() {
433
+ return this.indexMutex.isLocked();
434
+ }
435
+ // ===========================================================================
436
+ // File Watching
437
+ // ===========================================================================
438
+ /**
439
+ * Start watching for file changes and auto-syncing.
440
+ *
441
+ * Uses native OS file events (FSEvents on macOS, inotify on Linux 19+,
442
+ * ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing.
443
+ *
444
+ * @param options - Watch options (debounce delay, callbacks)
445
+ * @returns true if watching started successfully
446
+ */
447
+ watch(options = {}) {
448
+ if (this.watcher?.isActive())
449
+ return true;
450
+ this.watcher = new sync_1.FileWatcher(this.projectRoot, async () => {
451
+ const result = await this.sync();
452
+ // sync() returns this exact zero-shape iff it failed to acquire the
453
+ // file lock (a real empty sync always has filesChecked > 0 because
454
+ // scanDirectory ran). Surface that to the watcher as a typed error
455
+ // so it keeps pendingFiles + reschedules instead of clearing them
456
+ // (#449).
457
+ if (result.filesChecked === 0 && result.durationMs === 0) {
458
+ throw new sync_1.LockUnavailableError();
459
+ }
460
+ const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
461
+ return { filesChanged, durationMs: result.durationMs };
462
+ }, options);
463
+ return this.watcher.start();
464
+ }
465
+ /**
466
+ * Stop watching for file changes.
467
+ */
468
+ unwatch() {
469
+ if (this.watcher) {
470
+ this.watcher.stop();
471
+ this.watcher = null;
472
+ }
473
+ }
474
+ /**
475
+ * Check if the file watcher is active.
476
+ */
477
+ isWatching() {
478
+ return this.watcher?.isActive() ?? false;
479
+ }
480
+ /**
481
+ * Files seen by the file watcher since the last successful sync —
482
+ * the per-file "stale" signal MCP tools attach to responses so an agent
483
+ * can fall back to {@link Read} for just the affected file without
484
+ * waiting for a debounced sync to complete (issue #403).
485
+ *
486
+ * Returns an empty list when the watcher isn't active, or no events have
487
+ * arrived. Each entry includes `firstSeenMs` and `lastSeenMs` (wall-clock
488
+ * `Date.now()` values) so callers can render "edited Nms ago", plus an
489
+ * `indexing` flag indicating whether the in-flight sync (if any) will
490
+ * absorb that file.
491
+ */
492
+ getPendingFiles() {
493
+ return this.watcher?.getPendingFiles() ?? [];
494
+ }
495
+ /**
496
+ * Resolves once the file watcher has installed its watch set. Useful for
497
+ * tests that need a deterministic boundary before asserting on
498
+ * `getPendingFiles()`. Resolves immediately when no watcher is active.
499
+ */
500
+ waitUntilWatcherReady(timeoutMs) {
501
+ return this.watcher ? this.watcher.waitUntilReady(timeoutMs) : Promise.resolve();
502
+ }
503
+ /**
504
+ * Get files that have changed since last index
505
+ */
506
+ getChangedFiles() {
507
+ return this.orchestrator.getChangedFiles();
508
+ }
509
+ /**
510
+ * Most recent index timestamp (ms since epoch) across all tracked files, or
511
+ * null when nothing is indexed yet. Lets library consumers check index
512
+ * freshness without shelling out to `homegraph status --json`. (#329)
513
+ */
514
+ getLastIndexedAt() {
515
+ return this.queries.getLastIndexedAt();
516
+ }
517
+ /**
518
+ * Which engine built the current index: the package version + extraction
519
+ * version stamped at the last full `indexAll`. Either field is null for an
520
+ * index built before stamping existed (treated as stale). See
521
+ * `extraction-version.ts` and `isIndexStale()`.
522
+ */
523
+ getIndexBuildInfo() {
524
+ const version = this.queries.getMetadata('indexed_with_version');
525
+ const ev = this.queries.getMetadata('indexed_with_extraction_version');
526
+ const parsed = ev != null ? parseInt(ev, 10) : NaN;
527
+ return { version, extractionVersion: Number.isFinite(parsed) ? parsed : null };
528
+ }
529
+ /**
530
+ * True when the on-disk index was built by an engine whose extraction is
531
+ * older than the one now running — i.e. a re-index would add data a migration
532
+ * can't backfill. False when there's no index yet (nothing to refresh) or the
533
+ * stamp is current. This is the signal behind `homegraph status`'s re-index
534
+ * hint and `homegraph upgrade`'s reminder.
535
+ */
536
+ isIndexStale() {
537
+ if (this.queries.getLastIndexedAt() == null)
538
+ return false;
539
+ const { extractionVersion } = this.getIndexBuildInfo();
540
+ return extractionVersion == null || extractionVersion < extraction_version_1.EXTRACTION_VERSION;
541
+ }
542
+ /**
543
+ * Extract nodes and edges from source code (without storing)
544
+ */
545
+ extractFromSource(filePath, source) {
546
+ return (0, extraction_1.extractFromSource)(filePath, source);
547
+ }
548
+ // ===========================================================================
549
+ // Reference Resolution
550
+ // ===========================================================================
551
+ /**
552
+ * Resolve unresolved references and create edges
553
+ *
554
+ * This method takes unresolved references from extraction and attempts
555
+ * to resolve them using multiple strategies:
556
+ * - Framework-specific patterns (React, Express, Laravel)
557
+ * - Import-based resolution
558
+ * - Name-based symbol matching
559
+ */
560
+ resolveReferences(onProgress) {
561
+ // Get all unresolved references from the database
562
+ const unresolvedRefs = this.queries.getUnresolvedReferences();
563
+ return this.resolver.resolveAndPersist(unresolvedRefs, onProgress);
564
+ }
565
+ /**
566
+ * Resolve references in batches to keep memory bounded on large codebases.
567
+ * Processes chunks of unresolved refs, persisting results after each batch.
568
+ */
569
+ async resolveReferencesBatched(onProgress) {
570
+ return this.resolver.resolveAndPersistBatched(onProgress);
571
+ }
572
+ /**
573
+ * Get detected frameworks in the project
574
+ */
575
+ getDetectedFrameworks() {
576
+ return this.resolver.getDetectedFrameworks();
577
+ }
578
+ /**
579
+ * Re-initialize the resolver (useful after adding new files)
580
+ */
581
+ reinitializeResolver() {
582
+ this.resolver.initialize();
583
+ }
584
+ // ===========================================================================
585
+ // Graph Statistics
586
+ // ===========================================================================
587
+ /**
588
+ * Get statistics about the knowledge graph
589
+ */
590
+ getStats() {
591
+ const stats = this.queries.getStats();
592
+ stats.dbSizeBytes = this.db.getSize();
593
+ return stats;
594
+ }
595
+ /**
596
+ * Active SQLite backend for this project's connection (`node-sqlite` — Node's
597
+ * built-in real-SQLite module). Surfaced via `homegraph status` and the
598
+ * `homegraph_status` MCP tool alongside the effective journal mode.
599
+ */
600
+ getBackend() {
601
+ return this.db.getBackend();
602
+ }
603
+ /**
604
+ * The journal mode actually in effect ('wal', 'delete', …). 'wal' means
605
+ * readers never block on a concurrent writer; anything else means they can,
606
+ * which is the precondition for the "database is locked" failures in issue
607
+ * #238. Surfaced via `homegraph status` and the `homegraph_status` MCP tool.
608
+ */
609
+ getJournalMode() {
610
+ return this.db.getJournalMode();
611
+ }
612
+ // ===========================================================================
613
+ // Node Operations
614
+ // ===========================================================================
615
+ /**
616
+ * Get a node by ID
617
+ */
618
+ getNode(id) {
619
+ return this.queries.getNodeById(id);
620
+ }
621
+ /**
622
+ * Get all nodes in a file
623
+ */
624
+ getNodesInFile(filePath) {
625
+ return this.queries.getNodesByFile(filePath);
626
+ }
627
+ /**
628
+ * Get all nodes of a specific kind
629
+ */
630
+ getNodesByKind(kind) {
631
+ return this.queries.getNodesByKind(kind);
632
+ }
633
+ /**
634
+ * Get ALL nodes with an exact name (direct index lookup, not FTS-ranked/capped).
635
+ * Used to enumerate every overload of a heavily-overloaded name so the specific
636
+ * definition the caller wants is never dropped below a search cut.
637
+ */
638
+ getNodesByName(name) {
639
+ return this.queries.getNodesByName(name);
640
+ }
641
+ /**
642
+ * Search nodes by text
643
+ */
644
+ searchNodes(query, options) {
645
+ return this.queries.searchNodes(query, options);
646
+ }
647
+ /**
648
+ * Find the project's "primary route file" — the file with the densest
649
+ * concentration of framework-emitted `route` nodes (≥3 routes, ≥30%
650
+ * of all non-test routes). Used to inline the routing config in
651
+ * `homegraph_explore` responses on small realworld template repos
652
+ * (rails-realworld, laravel-realworld, drupal-admintoolbar, …) where
653
+ * Glob+Read of `routes.rb`/`urls.py`/etc. otherwise beats codegraph.
654
+ */
655
+ getTopRouteFile() {
656
+ return this.queries.getTopRouteFile();
657
+ }
658
+ /**
659
+ * Build a URL → handler routing manifest from the index. Each entry
660
+ * pairs a route node (URL + method) with its handler function/method
661
+ * via the `references` edge that framework resolvers emit. Returns
662
+ * null when fewer than 3 valid (non-test) routes exist.
663
+ */
664
+ getRoutingManifest(limit) {
665
+ return this.queries.getRoutingManifest(limit);
666
+ }
667
+ // ===========================================================================
668
+ // Edge Operations
669
+ // ===========================================================================
670
+ /**
671
+ * Get outgoing edges from a node
672
+ */
673
+ getOutgoingEdges(nodeId) {
674
+ return this.queries.getOutgoingEdges(nodeId);
675
+ }
676
+ /**
677
+ * Get incoming edges to a node
678
+ */
679
+ getIncomingEdges(nodeId) {
680
+ return this.queries.getIncomingEdges(nodeId);
681
+ }
682
+ // ===========================================================================
683
+ // File Operations
684
+ // ===========================================================================
685
+ /**
686
+ * Get a file record by path
687
+ */
688
+ getFile(filePath) {
689
+ return this.queries.getFileByPath(filePath);
690
+ }
691
+ /**
692
+ * Get all tracked files
693
+ */
694
+ getFiles() {
695
+ return this.queries.getAllFiles();
696
+ }
697
+ // ===========================================================================
698
+ // Graph Query Methods
699
+ // ===========================================================================
700
+ /**
701
+ * Get the context for a node (ancestors, children, references)
702
+ *
703
+ * Returns comprehensive context about a node including its containment
704
+ * hierarchy, children, incoming/outgoing references, type information,
705
+ * and relevant imports.
706
+ *
707
+ * @param nodeId - ID of the focal node
708
+ * @returns Context object with all related information
709
+ */
710
+ getContext(nodeId) {
711
+ return this.graphManager.getContext(nodeId);
712
+ }
713
+ /**
714
+ * Traverse the graph from a starting node
715
+ *
716
+ * Uses breadth-first search by default. Supports filtering by edge types,
717
+ * node types, and traversal direction.
718
+ *
719
+ * @param startId - Starting node ID
720
+ * @param options - Traversal options
721
+ * @returns Subgraph containing traversed nodes and edges
722
+ */
723
+ traverse(startId, options) {
724
+ return this.traverser.traverseBFS(startId, options);
725
+ }
726
+ /**
727
+ * Get the call graph for a function
728
+ *
729
+ * Returns both callers (functions that call this function) and
730
+ * callees (functions called by this function) up to the specified depth.
731
+ *
732
+ * @param nodeId - ID of the function/method node
733
+ * @param depth - Maximum depth in each direction (default: 2)
734
+ * @returns Subgraph containing the call graph
735
+ */
736
+ getCallGraph(nodeId, depth = 2) {
737
+ return this.traverser.getCallGraph(nodeId, depth);
738
+ }
739
+ /**
740
+ * Get the type hierarchy for a class/interface
741
+ *
742
+ * Returns both ancestors (types this extends/implements) and
743
+ * descendants (types that extend/implement this).
744
+ *
745
+ * @param nodeId - ID of the class/interface node
746
+ * @returns Subgraph containing the type hierarchy
747
+ */
748
+ getTypeHierarchy(nodeId) {
749
+ return this.traverser.getTypeHierarchy(nodeId);
750
+ }
751
+ /**
752
+ * Find all usages of a symbol
753
+ *
754
+ * Returns all nodes that reference the specified symbol through
755
+ * any edge type (calls, references, type_of, etc.).
756
+ *
757
+ * @param nodeId - ID of the symbol node
758
+ * @returns Array of nodes and edges that reference this symbol
759
+ */
760
+ findUsages(nodeId) {
761
+ return this.traverser.findUsages(nodeId);
762
+ }
763
+ /**
764
+ * Get callers of a function/method
765
+ *
766
+ * @param nodeId - ID of the function/method node
767
+ * @param maxDepth - Maximum depth to traverse (default: 1)
768
+ * @returns Array of nodes that call this function
769
+ */
770
+ getCallers(nodeId, maxDepth = 1) {
771
+ return this.traverser.getCallers(nodeId, maxDepth);
772
+ }
773
+ /**
774
+ * Get callees of a function/method
775
+ *
776
+ * @param nodeId - ID of the function/method node
777
+ * @param maxDepth - Maximum depth to traverse (default: 1)
778
+ * @returns Array of nodes called by this function
779
+ */
780
+ getCallees(nodeId, maxDepth = 1) {
781
+ return this.traverser.getCallees(nodeId, maxDepth);
782
+ }
783
+ /**
784
+ * Calculate the impact radius of a node
785
+ *
786
+ * Returns all nodes that could be affected by changes to this node.
787
+ *
788
+ * @param nodeId - ID of the node
789
+ * @param maxDepth - Maximum depth to traverse (default: 3)
790
+ * @returns Subgraph containing potentially impacted nodes
791
+ */
792
+ getImpactRadius(nodeId, maxDepth = 3) {
793
+ return this.traverser.getImpactRadius(nodeId, maxDepth);
794
+ }
795
+ /**
796
+ * Find the shortest path between two nodes
797
+ *
798
+ * @param fromId - Starting node ID
799
+ * @param toId - Target node ID
800
+ * @param edgeKinds - Edge types to consider (all if empty)
801
+ * @returns Array of nodes and edges forming the path, or null if no path exists
802
+ */
803
+ findPath(fromId, toId, edgeKinds) {
804
+ return this.traverser.findPath(fromId, toId, edgeKinds);
805
+ }
806
+ /**
807
+ * Get ancestors of a node in the containment hierarchy
808
+ *
809
+ * @param nodeId - ID of the node
810
+ * @returns Array of ancestor nodes from immediate parent to root
811
+ */
812
+ getAncestors(nodeId) {
813
+ return this.traverser.getAncestors(nodeId);
814
+ }
815
+ /**
816
+ * Get immediate children of a node
817
+ *
818
+ * @param nodeId - ID of the node
819
+ * @returns Array of child nodes
820
+ */
821
+ getChildren(nodeId) {
822
+ return this.traverser.getChildren(nodeId);
823
+ }
824
+ /**
825
+ * Get dependencies of a file
826
+ *
827
+ * @param filePath - Path to the file
828
+ * @returns Array of file paths this file depends on
829
+ */
830
+ getFileDependencies(filePath) {
831
+ return this.graphManager.getFileDependencies(filePath);
832
+ }
833
+ /**
834
+ * Get dependents of a file
835
+ *
836
+ * @param filePath - Path to the file
837
+ * @returns Array of file paths that depend on this file
838
+ */
839
+ getFileDependents(filePath) {
840
+ return this.graphManager.getFileDependents(filePath);
841
+ }
842
+ /**
843
+ * Find circular dependencies in the codebase
844
+ *
845
+ * @returns Array of cycles, each cycle is an array of file paths
846
+ */
847
+ findCircularDependencies() {
848
+ return this.graphManager.findCircularDependencies();
849
+ }
850
+ /**
851
+ * Find dead code (unreferenced symbols)
852
+ *
853
+ * @param kinds - Node kinds to check (default: functions, methods, classes)
854
+ * @returns Array of unreferenced nodes
855
+ */
856
+ findDeadCode(kinds) {
857
+ return this.graphManager.findDeadCode(kinds);
858
+ }
859
+ /**
860
+ * Get complexity metrics for a node
861
+ *
862
+ * @param nodeId - ID of the node
863
+ * @returns Object containing various complexity metrics
864
+ */
865
+ getNodeMetrics(nodeId) {
866
+ return this.graphManager.getNodeMetrics(nodeId);
867
+ }
868
+ // ===========================================================================
869
+ // Context Building
870
+ // ===========================================================================
871
+ /**
872
+ * Get the source code for a node
873
+ *
874
+ * Reads the file and extracts the code between startLine and endLine.
875
+ *
876
+ * @param nodeId - ID of the node
877
+ * @returns Code string or null if not found
878
+ */
879
+ async getCode(nodeId) {
880
+ return this.contextBuilder.getCode(nodeId);
881
+ }
882
+ /**
883
+ * Find relevant subgraph for a query
884
+ *
885
+ * Combines semantic search with graph traversal to find the most
886
+ * relevant nodes and their relationships for a given query.
887
+ *
888
+ * @param query - Natural language query describing the task
889
+ * @param options - Search and traversal options
890
+ * @returns Subgraph of relevant nodes and edges
891
+ */
892
+ async findRelevantContext(query, options) {
893
+ return this.contextBuilder.findRelevantContext(query, options);
894
+ }
895
+ /**
896
+ * Build context for a task
897
+ *
898
+ * Creates comprehensive context by:
899
+ * 1. Running FTS search to find entry points
900
+ * 2. Expanding the graph around entry points
901
+ * 3. Extracting code blocks for key nodes
902
+ * 4. Formatting output for Claude
903
+ *
904
+ * @param input - Task description (string or {title, description})
905
+ * @param options - Build options (maxNodes, includeCode, format, etc.)
906
+ * @returns TaskContext object or formatted string (markdown/JSON)
907
+ */
908
+ async buildContext(input, options) {
909
+ return this.contextBuilder.buildContext(input, options);
910
+ }
911
+ // ===========================================================================
912
+ // Database Management
913
+ // ===========================================================================
914
+ /**
915
+ * Optimize the database (vacuum and analyze)
916
+ */
917
+ optimize() {
918
+ this.db.optimize();
919
+ }
920
+ /**
921
+ * Clear all data from the graph
922
+ */
923
+ clear() {
924
+ this.queries.clear();
925
+ }
926
+ /**
927
+ * Alias for close() for backwards compatibility.
928
+ * @deprecated Use close() instead
929
+ */
930
+ destroy() {
931
+ this.close();
932
+ }
933
+ /**
934
+ * Completely remove CodeGraph from the project.
935
+ * This closes the database and deletes the .CodeGraph directory.
936
+ *
937
+ * WARNING: This permanently deletes all CodeGraph data for the project.
938
+ */
939
+ uninitialize() {
940
+ this.close();
941
+ (0, directory_1.removeDirectory)(this.projectRoot);
942
+ }
943
+ }
944
+ exports.CodeGraph = CodeGraph;
945
+ // Default export
946
+ exports.default = CodeGraph;
947
+ //# sourceMappingURL=index.js.map