@kkvcrobatz107/codegraph 0.9.6-pkm.1

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