@colbymchenry/codegraph-win32-arm64 1.6.2 → 1.6.4

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 (1110) hide show
  1. package/bin/codegraph +1 -1
  2. package/bin/codegraph.cmd +1 -1
  3. package/lib/dist/.test-build-engine.json +1 -1
  4. package/lib/dist/.test-build-viewer.json +1 -1
  5. package/lib/dist/bin/codegraph.d.ts +3 -0
  6. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  7. package/lib/dist/bin/codegraph.js +507 -702
  8. package/lib/dist/bin/codegraph.js.map +1 -1
  9. package/lib/dist/bin/command-supervision.js +1 -57
  10. package/lib/dist/bin/command-supervision.js.map +1 -1
  11. package/lib/dist/bin/fatal-handler.js +0 -46
  12. package/lib/dist/bin/fatal-handler.js.map +1 -1
  13. package/lib/dist/bin/node-version-check.js +0 -33
  14. package/lib/dist/bin/node-version-check.js.map +1 -1
  15. package/lib/dist/bin/uninstall.js +0 -19
  16. package/lib/dist/bin/uninstall.js.map +1 -1
  17. package/lib/dist/bin/viewer-gate.js +0 -14
  18. package/lib/dist/bin/viewer-gate.js.map +1 -1
  19. package/lib/dist/compile-cache.d.ts +2 -0
  20. package/lib/dist/compile-cache.d.ts.map +1 -0
  21. package/lib/dist/compile-cache.js +45 -0
  22. package/lib/dist/compile-cache.js.map +1 -0
  23. package/lib/dist/context/formatter.js +3 -66
  24. package/lib/dist/context/formatter.js.map +1 -1
  25. package/lib/dist/context/index.d.ts +44 -1
  26. package/lib/dist/context/index.d.ts.map +1 -1
  27. package/lib/dist/context/index.js +123 -430
  28. package/lib/dist/context/index.js.map +1 -1
  29. package/lib/dist/context/markers.js +0 -17
  30. package/lib/dist/context/markers.js.map +1 -1
  31. package/lib/dist/db/index.d.ts +44 -1
  32. package/lib/dist/db/index.d.ts.map +1 -1
  33. package/lib/dist/db/index.js +123 -395
  34. package/lib/dist/db/index.js.map +1 -1
  35. package/lib/dist/db/migrations.d.ts +11 -1
  36. package/lib/dist/db/migrations.d.ts.map +1 -1
  37. package/lib/dist/db/migrations.js +71 -79
  38. package/lib/dist/db/migrations.js.map +1 -1
  39. package/lib/dist/db/name-substring-index.d.ts +63 -0
  40. package/lib/dist/db/name-substring-index.d.ts.map +1 -0
  41. package/lib/dist/db/name-substring-index.js +151 -0
  42. package/lib/dist/db/name-substring-index.js.map +1 -0
  43. package/lib/dist/db/node-sqlite.d.ts +19 -0
  44. package/lib/dist/db/node-sqlite.d.ts.map +1 -0
  45. package/lib/dist/db/node-sqlite.js +23 -0
  46. package/lib/dist/db/node-sqlite.js.map +1 -0
  47. package/lib/dist/db/open-error.d.ts +36 -0
  48. package/lib/dist/db/open-error.d.ts.map +1 -0
  49. package/lib/dist/db/open-error.js +63 -0
  50. package/lib/dist/db/open-error.js.map +1 -0
  51. package/lib/dist/db/parameter-flow-queries.d.ts +120 -0
  52. package/lib/dist/db/parameter-flow-queries.d.ts.map +1 -0
  53. package/lib/dist/db/parameter-flow-queries.js +168 -0
  54. package/lib/dist/db/parameter-flow-queries.js.map +1 -0
  55. package/lib/dist/db/queries.d.ts +654 -34
  56. package/lib/dist/db/queries.d.ts.map +1 -1
  57. package/lib/dist/db/queries.js +1466 -1470
  58. package/lib/dist/db/queries.js.map +1 -1
  59. package/lib/dist/db/reference-tail.d.ts +83 -0
  60. package/lib/dist/db/reference-tail.d.ts.map +1 -0
  61. package/lib/dist/db/reference-tail.js +68 -0
  62. package/lib/dist/db/reference-tail.js.map +1 -0
  63. package/lib/dist/db/schema.sql +18 -2
  64. package/lib/dist/db/sqlite-adapter.d.ts +18 -1
  65. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  66. package/lib/dist/db/sqlite-adapter.js +12 -62
  67. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  68. package/lib/dist/db/synthesis-stage.d.ts.map +1 -1
  69. package/lib/dist/db/synthesis-stage.js +2 -6
  70. package/lib/dist/db/synthesis-stage.js.map +1 -1
  71. package/lib/dist/db/wal-valve.js +1 -153
  72. package/lib/dist/db/wal-valve.js.map +1 -1
  73. package/lib/dist/db/wsl-shared-index.js +0 -37
  74. package/lib/dist/db/wsl-shared-index.js.map +1 -1
  75. package/lib/dist/directory.d.ts +51 -0
  76. package/lib/dist/directory.d.ts.map +1 -1
  77. package/lib/dist/directory.js +76 -530
  78. package/lib/dist/directory.js.map +1 -1
  79. package/lib/dist/engine.d.ts +15 -0
  80. package/lib/dist/engine.d.ts.map +1 -0
  81. package/lib/dist/engine.js +35 -0
  82. package/lib/dist/engine.js.map +1 -0
  83. package/lib/dist/errors.d.ts +10 -0
  84. package/lib/dist/errors.d.ts.map +1 -1
  85. package/lib/dist/errors.js +8 -101
  86. package/lib/dist/errors.js.map +1 -1
  87. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -1
  88. package/lib/dist/extraction/astro-extractor.js +11 -101
  89. package/lib/dist/extraction/astro-extractor.js.map +1 -1
  90. package/lib/dist/extraction/cfml-extractor.d.ts +27 -1
  91. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
  92. package/lib/dist/extraction/cfml-extractor.js +70 -206
  93. package/lib/dist/extraction/cfml-extractor.js.map +1 -1
  94. package/lib/dist/extraction/commonjs-requires.js +0 -31
  95. package/lib/dist/extraction/commonjs-requires.js.map +1 -1
  96. package/lib/dist/extraction/dfm-extractor.js +0 -21
  97. package/lib/dist/extraction/dfm-extractor.js.map +1 -1
  98. package/lib/dist/extraction/extraction-version.d.ts +1 -1
  99. package/lib/dist/extraction/extraction-version.js +1 -24
  100. package/lib/dist/extraction/extraction-version.js.map +1 -1
  101. package/lib/dist/extraction/function-ref.d.ts +40 -0
  102. package/lib/dist/extraction/function-ref.d.ts.map +1 -1
  103. package/lib/dist/extraction/function-ref.js +157 -207
  104. package/lib/dist/extraction/function-ref.js.map +1 -1
  105. package/lib/dist/extraction/generated-detection.js +0 -165
  106. package/lib/dist/extraction/generated-detection.js.map +1 -1
  107. package/lib/dist/extraction/grammars.d.ts +73 -4
  108. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  109. package/lib/dist/extraction/grammars.js +160 -431
  110. package/lib/dist/extraction/grammars.js.map +1 -1
  111. package/lib/dist/extraction/index.d.ts +208 -7
  112. package/lib/dist/extraction/index.d.ts.map +1 -1
  113. package/lib/dist/extraction/index.js +594 -1383
  114. package/lib/dist/extraction/index.js.map +1 -1
  115. package/lib/dist/extraction/kernel/decode.js +0 -16
  116. package/lib/dist/extraction/kernel/decode.js.map +1 -1
  117. package/lib/dist/extraction/kernel/index.d.ts +3 -1
  118. package/lib/dist/extraction/kernel/index.d.ts.map +1 -1
  119. package/lib/dist/extraction/kernel/index.js +48 -135
  120. package/lib/dist/extraction/kernel/index.js.map +1 -1
  121. package/lib/dist/extraction/kernel/layout.js +42 -76
  122. package/lib/dist/extraction/kernel/layout.js.map +1 -1
  123. package/lib/dist/extraction/kernel/loader.d.ts +5 -1
  124. package/lib/dist/extraction/kernel/loader.d.ts.map +1 -1
  125. package/lib/dist/extraction/kernel/loader.js +0 -37
  126. package/lib/dist/extraction/kernel/loader.js.map +1 -1
  127. package/lib/dist/extraction/languages/arkts.js +0 -59
  128. package/lib/dist/extraction/languages/arkts.js.map +1 -1
  129. package/lib/dist/extraction/languages/c-cpp.d.ts +125 -28
  130. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  131. package/lib/dist/extraction/languages/c-cpp.js +789 -856
  132. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  133. package/lib/dist/extraction/languages/cfquery.js +0 -9
  134. package/lib/dist/extraction/languages/cfquery.js.map +1 -1
  135. package/lib/dist/extraction/languages/cfscript.d.ts +20 -0
  136. package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -1
  137. package/lib/dist/extraction/languages/cfscript.js +80 -9
  138. package/lib/dist/extraction/languages/cfscript.js.map +1 -1
  139. package/lib/dist/extraction/languages/cobol.js +0 -114
  140. package/lib/dist/extraction/languages/cobol.js.map +1 -1
  141. package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts +66 -0
  142. package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts.map +1 -0
  143. package/lib/dist/extraction/languages/cpp-brace-scopes.js +343 -0
  144. package/lib/dist/extraction/languages/cpp-brace-scopes.js.map +1 -0
  145. package/lib/dist/extraction/languages/cpp-macro-methods.d.ts +41 -0
  146. package/lib/dist/extraction/languages/cpp-macro-methods.d.ts.map +1 -0
  147. package/lib/dist/extraction/languages/cpp-macro-methods.js +487 -0
  148. package/lib/dist/extraction/languages/cpp-macro-methods.js.map +1 -0
  149. package/lib/dist/extraction/languages/csharp.js +3 -55
  150. package/lib/dist/extraction/languages/csharp.js.map +1 -1
  151. package/lib/dist/extraction/languages/dart.d.ts +129 -0
  152. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  153. package/lib/dist/extraction/languages/dart.js +517 -162
  154. package/lib/dist/extraction/languages/dart.js.map +1 -1
  155. package/lib/dist/extraction/languages/erlang.d.ts.map +1 -1
  156. package/lib/dist/extraction/languages/erlang.js +15 -102
  157. package/lib/dist/extraction/languages/erlang.js.map +1 -1
  158. package/lib/dist/extraction/languages/go.d.ts +48 -0
  159. package/lib/dist/extraction/languages/go.d.ts.map +1 -1
  160. package/lib/dist/extraction/languages/go.js +102 -31
  161. package/lib/dist/extraction/languages/go.js.map +1 -1
  162. package/lib/dist/extraction/languages/index.js +0 -6
  163. package/lib/dist/extraction/languages/index.js.map +1 -1
  164. package/lib/dist/extraction/languages/java.d.ts.map +1 -1
  165. package/lib/dist/extraction/languages/java.js +67 -78
  166. package/lib/dist/extraction/languages/java.js.map +1 -1
  167. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
  168. package/lib/dist/extraction/languages/javascript.js +2 -12
  169. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  170. package/lib/dist/extraction/languages/kotlin.d.ts +11 -0
  171. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  172. package/lib/dist/extraction/languages/kotlin.js +43 -197
  173. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  174. package/lib/dist/extraction/languages/lua.js +2 -39
  175. package/lib/dist/extraction/languages/lua.js.map +1 -1
  176. package/lib/dist/extraction/languages/luau.js +0 -14
  177. package/lib/dist/extraction/languages/luau.js.map +1 -1
  178. package/lib/dist/extraction/languages/nix.js +0 -16
  179. package/lib/dist/extraction/languages/nix.js.map +1 -1
  180. package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
  181. package/lib/dist/extraction/languages/objc.js +5 -16
  182. package/lib/dist/extraction/languages/objc.js.map +1 -1
  183. package/lib/dist/extraction/languages/pascal-preparse.d.ts +66 -0
  184. package/lib/dist/extraction/languages/pascal-preparse.d.ts.map +1 -0
  185. package/lib/dist/extraction/languages/pascal-preparse.js +958 -0
  186. package/lib/dist/extraction/languages/pascal-preparse.js.map +1 -0
  187. package/lib/dist/extraction/languages/pascal-system.d.ts +11 -0
  188. package/lib/dist/extraction/languages/pascal-system.d.ts.map +1 -0
  189. package/lib/dist/extraction/languages/pascal-system.js +23 -0
  190. package/lib/dist/extraction/languages/pascal-system.js.map +1 -0
  191. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
  192. package/lib/dist/extraction/languages/pascal.js +3 -4
  193. package/lib/dist/extraction/languages/pascal.js.map +1 -1
  194. package/lib/dist/extraction/languages/php.d.ts +9 -0
  195. package/lib/dist/extraction/languages/php.d.ts.map +1 -1
  196. package/lib/dist/extraction/languages/php.js +207 -44
  197. package/lib/dist/extraction/languages/php.js.map +1 -1
  198. package/lib/dist/extraction/languages/python.js +2 -20
  199. package/lib/dist/extraction/languages/python.js.map +1 -1
  200. package/lib/dist/extraction/languages/r.js +8 -78
  201. package/lib/dist/extraction/languages/r.js.map +1 -1
  202. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
  203. package/lib/dist/extraction/languages/ruby.js +17 -25
  204. package/lib/dist/extraction/languages/ruby.js.map +1 -1
  205. package/lib/dist/extraction/languages/rust-macro-calls.d.ts +32 -0
  206. package/lib/dist/extraction/languages/rust-macro-calls.d.ts.map +1 -0
  207. package/lib/dist/extraction/languages/rust-macro-calls.js +306 -0
  208. package/lib/dist/extraction/languages/rust-macro-calls.js.map +1 -0
  209. package/lib/dist/extraction/languages/rust.d.ts +10 -0
  210. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  211. package/lib/dist/extraction/languages/rust.js +15 -47
  212. package/lib/dist/extraction/languages/rust.js.map +1 -1
  213. package/lib/dist/extraction/languages/scala.js +5 -41
  214. package/lib/dist/extraction/languages/scala.js.map +1 -1
  215. package/lib/dist/extraction/languages/solidity.js +1 -82
  216. package/lib/dist/extraction/languages/solidity.js.map +1 -1
  217. package/lib/dist/extraction/languages/swift.js +3 -47
  218. package/lib/dist/extraction/languages/swift.js.map +1 -1
  219. package/lib/dist/extraction/languages/terraform.js +6 -152
  220. package/lib/dist/extraction/languages/terraform.js.map +1 -1
  221. package/lib/dist/extraction/languages/typescript.d.ts +64 -0
  222. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  223. package/lib/dist/extraction/languages/typescript.js +73 -49
  224. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  225. package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -1
  226. package/lib/dist/extraction/languages/vbnet.js +9 -42
  227. package/lib/dist/extraction/languages/vbnet.js.map +1 -1
  228. package/lib/dist/extraction/lazy-frameworks.d.ts +15 -0
  229. package/lib/dist/extraction/lazy-frameworks.d.ts.map +1 -0
  230. package/lib/dist/extraction/lazy-frameworks.js +8 -0
  231. package/lib/dist/extraction/lazy-frameworks.js.map +1 -0
  232. package/lib/dist/extraction/liquid-extractor.d.ts +29 -3
  233. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  234. package/lib/dist/extraction/liquid-extractor.js +89 -148
  235. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  236. package/lib/dist/extraction/mybatis-extractor.js +0 -78
  237. package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
  238. package/lib/dist/extraction/parse-budget.d.ts +42 -7
  239. package/lib/dist/extraction/parse-budget.d.ts.map +1 -1
  240. package/lib/dist/extraction/parse-budget.js +39 -15
  241. package/lib/dist/extraction/parse-budget.js.map +1 -1
  242. package/lib/dist/extraction/parse-pool.d.ts +29 -17
  243. package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
  244. package/lib/dist/extraction/parse-pool.js +49 -193
  245. package/lib/dist/extraction/parse-pool.js.map +1 -1
  246. package/lib/dist/extraction/parse-worker.d.ts +1 -1
  247. package/lib/dist/extraction/parse-worker.d.ts.map +1 -1
  248. package/lib/dist/extraction/parse-worker.js +5 -58
  249. package/lib/dist/extraction/parse-worker.js.map +1 -1
  250. package/lib/dist/extraction/razor-extractor.d.ts +9 -0
  251. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -1
  252. package/lib/dist/extraction/razor-extractor.js +45 -69
  253. package/lib/dist/extraction/razor-extractor.js.map +1 -1
  254. package/lib/dist/extraction/razor-script.d.ts +23 -0
  255. package/lib/dist/extraction/razor-script.d.ts.map +1 -0
  256. package/lib/dist/extraction/razor-script.js +244 -0
  257. package/lib/dist/extraction/razor-script.js.map +1 -0
  258. package/lib/dist/extraction/sfc-script.d.ts +42 -0
  259. package/lib/dist/extraction/sfc-script.d.ts.map +1 -1
  260. package/lib/dist/extraction/sfc-script.js +32 -31
  261. package/lib/dist/extraction/sfc-script.js.map +1 -1
  262. package/lib/dist/extraction/store-worker.d.ts +1 -1
  263. package/lib/dist/extraction/store-worker.d.ts.map +1 -1
  264. package/lib/dist/extraction/store-worker.js +1 -38
  265. package/lib/dist/extraction/store-worker.js.map +1 -1
  266. package/lib/dist/extraction/store-writer.js +2 -34
  267. package/lib/dist/extraction/store-writer.js.map +1 -1
  268. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
  269. package/lib/dist/extraction/svelte-extractor.js +11 -87
  270. package/lib/dist/extraction/svelte-extractor.js.map +1 -1
  271. package/lib/dist/extraction/syntax-tokens.d.ts +6 -5
  272. package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -1
  273. package/lib/dist/extraction/syntax-tokens.js +4 -152
  274. package/lib/dist/extraction/syntax-tokens.js.map +1 -1
  275. package/lib/dist/extraction/tree-sitter-helpers.d.ts +37 -1
  276. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  277. package/lib/dist/extraction/tree-sitter-helpers.js +76 -68
  278. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  279. package/lib/dist/extraction/tree-sitter-types.d.ts +102 -22
  280. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  281. package/lib/dist/extraction/tree-sitter-types.js +0 -7
  282. package/lib/dist/extraction/tree-sitter-types.js.map +1 -1
  283. package/lib/dist/extraction/tree-sitter.d.ts +518 -10
  284. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  285. package/lib/dist/extraction/tree-sitter.js +2118 -2554
  286. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  287. package/lib/dist/extraction/vue-extractor.d.ts +13 -0
  288. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
  289. package/lib/dist/extraction/vue-extractor.js +52 -92
  290. package/lib/dist/extraction/vue-extractor.js.map +1 -1
  291. package/lib/dist/extraction/vue-options-api.js +0 -32
  292. package/lib/dist/extraction/vue-options-api.js.map +1 -1
  293. package/lib/dist/extraction/vue-template-calls.d.ts +37 -0
  294. package/lib/dist/extraction/vue-template-calls.d.ts.map +1 -0
  295. package/lib/dist/extraction/vue-template-calls.js +497 -0
  296. package/lib/dist/extraction/vue-template-calls.js.map +1 -0
  297. package/lib/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  298. package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  299. package/lib/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  300. package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  301. package/lib/dist/extraction/wasm-runtime-flags.d.ts +15 -0
  302. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
  303. package/lib/dist/extraction/wasm-runtime-flags.js +18 -89
  304. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -1
  305. package/lib/dist/file-limits.d.ts +8 -0
  306. package/lib/dist/file-limits.d.ts.map +1 -1
  307. package/lib/dist/file-limits.js +13 -28
  308. package/lib/dist/file-limits.js.map +1 -1
  309. package/lib/dist/graph/branch-guards.d.ts.map +1 -1
  310. package/lib/dist/graph/branch-guards.js +4 -251
  311. package/lib/dist/graph/branch-guards.js.map +1 -1
  312. package/lib/dist/graph/call-sites.d.ts +12 -0
  313. package/lib/dist/graph/call-sites.d.ts.map +1 -0
  314. package/lib/dist/graph/call-sites.js +17 -0
  315. package/lib/dist/graph/call-sites.js.map +1 -0
  316. package/lib/dist/graph/cobol-copybooks.d.ts +75 -0
  317. package/lib/dist/graph/cobol-copybooks.d.ts.map +1 -0
  318. package/lib/dist/graph/cobol-copybooks.js +45 -0
  319. package/lib/dist/graph/cobol-copybooks.js.map +1 -0
  320. package/lib/dist/graph/dead-code.d.ts +26 -4
  321. package/lib/dist/graph/dead-code.d.ts.map +1 -1
  322. package/lib/dist/graph/dead-code.js +157 -311
  323. package/lib/dist/graph/dead-code.js.map +1 -1
  324. package/lib/dist/graph/dynamic-boundary-report.js +1 -88
  325. package/lib/dist/graph/dynamic-boundary-report.js.map +1 -1
  326. package/lib/dist/graph/file-cycles.d.ts +20 -0
  327. package/lib/dist/graph/file-cycles.d.ts.map +1 -0
  328. package/lib/dist/graph/file-cycles.js +79 -0
  329. package/lib/dist/graph/file-cycles.js.map +1 -0
  330. package/lib/dist/graph/file-drift.d.ts +35 -0
  331. package/lib/dist/graph/file-drift.d.ts.map +1 -0
  332. package/lib/dist/graph/file-drift.js +46 -0
  333. package/lib/dist/graph/file-drift.js.map +1 -0
  334. package/lib/dist/graph/go-package.d.ts +27 -0
  335. package/lib/dist/graph/go-package.d.ts.map +1 -0
  336. package/lib/dist/graph/go-package.js +49 -0
  337. package/lib/dist/graph/go-package.js.map +1 -0
  338. package/lib/dist/graph/index.d.ts +2 -0
  339. package/lib/dist/graph/index.d.ts.map +1 -1
  340. package/lib/dist/graph/index.js +4 -6
  341. package/lib/dist/graph/index.js.map +1 -1
  342. package/lib/dist/graph/named-symbol-flow.d.ts +5 -1
  343. package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -1
  344. package/lib/dist/graph/named-symbol-flow.js +82 -223
  345. package/lib/dist/graph/named-symbol-flow.js.map +1 -1
  346. package/lib/dist/graph/owning-package.d.ts +59 -0
  347. package/lib/dist/graph/owning-package.d.ts.map +1 -0
  348. package/lib/dist/graph/owning-package.js +120 -0
  349. package/lib/dist/graph/owning-package.js.map +1 -0
  350. package/lib/dist/graph/queries.d.ts +6 -3
  351. package/lib/dist/graph/queries.d.ts.map +1 -1
  352. package/lib/dist/graph/queries.js +4 -137
  353. package/lib/dist/graph/queries.js.map +1 -1
  354. package/lib/dist/graph/symbol-lookup.d.ts +15 -3
  355. package/lib/dist/graph/symbol-lookup.d.ts.map +1 -1
  356. package/lib/dist/graph/symbol-lookup.js +47 -89
  357. package/lib/dist/graph/symbol-lookup.js.map +1 -1
  358. package/lib/dist/graph/symbol-references.d.ts +86 -0
  359. package/lib/dist/graph/symbol-references.d.ts.map +1 -0
  360. package/lib/dist/graph/symbol-references.js +304 -0
  361. package/lib/dist/graph/symbol-references.js.map +1 -0
  362. package/lib/dist/graph/synthesized-hop.d.ts +37 -0
  363. package/lib/dist/graph/synthesized-hop.d.ts.map +1 -0
  364. package/lib/dist/graph/synthesized-hop.js +62 -0
  365. package/lib/dist/graph/synthesized-hop.js.map +1 -0
  366. package/lib/dist/graph/test-code.d.ts +33 -0
  367. package/lib/dist/graph/test-code.d.ts.map +1 -0
  368. package/lib/dist/graph/test-code.js +104 -0
  369. package/lib/dist/graph/test-code.js.map +1 -0
  370. package/lib/dist/graph/traversal.d.ts +31 -2
  371. package/lib/dist/graph/traversal.d.ts.map +1 -1
  372. package/lib/dist/graph/traversal.js +96 -226
  373. package/lib/dist/graph/traversal.js.map +1 -1
  374. package/lib/dist/graph/type-hierarchy.js +0 -138
  375. package/lib/dist/graph/type-hierarchy.js.map +1 -1
  376. package/lib/dist/index.d.ts +214 -26
  377. package/lib/dist/index.d.ts.map +1 -1
  378. package/lib/dist/index.js +736 -1112
  379. package/lib/dist/index.js.map +1 -1
  380. package/lib/dist/installer/beta-signup.js +0 -39
  381. package/lib/dist/installer/beta-signup.js.map +1 -1
  382. package/lib/dist/installer/config-writer.js +0 -24
  383. package/lib/dist/installer/config-writer.js.map +1 -1
  384. package/lib/dist/installer/index.d.ts +13 -6
  385. package/lib/dist/installer/index.d.ts.map +1 -1
  386. package/lib/dist/installer/index.js +27 -160
  387. package/lib/dist/installer/index.js.map +1 -1
  388. package/lib/dist/installer/instructions-template.d.ts +16 -1
  389. package/lib/dist/installer/instructions-template.d.ts.map +1 -1
  390. package/lib/dist/installer/instructions-template.js +10 -38
  391. package/lib/dist/installer/instructions-template.js.map +1 -1
  392. package/lib/dist/installer/targets/antigravity.js +0 -113
  393. package/lib/dist/installer/targets/antigravity.js.map +1 -1
  394. package/lib/dist/installer/targets/bob.d.ts +20 -0
  395. package/lib/dist/installer/targets/bob.d.ts.map +1 -0
  396. package/lib/dist/installer/targets/bob.js +83 -0
  397. package/lib/dist/installer/targets/bob.js.map +1 -0
  398. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  399. package/lib/dist/installer/targets/claude.js +1 -185
  400. package/lib/dist/installer/targets/claude.js.map +1 -1
  401. package/lib/dist/installer/targets/codex.d.ts.map +1 -1
  402. package/lib/dist/installer/targets/codex.js +17 -109
  403. package/lib/dist/installer/targets/codex.js.map +1 -1
  404. package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
  405. package/lib/dist/installer/targets/copilot-cli.js +2 -54
  406. package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
  407. package/lib/dist/installer/targets/copilot-jetbrains.js +0 -57
  408. package/lib/dist/installer/targets/copilot-jetbrains.js.map +1 -1
  409. package/lib/dist/installer/targets/copilot-vscode.js +0 -58
  410. package/lib/dist/installer/targets/copilot-vscode.js.map +1 -1
  411. package/lib/dist/installer/targets/cursor.js +7 -88
  412. package/lib/dist/installer/targets/cursor.js.map +1 -1
  413. package/lib/dist/installer/targets/droid.d.ts +18 -0
  414. package/lib/dist/installer/targets/droid.d.ts.map +1 -0
  415. package/lib/dist/installer/targets/droid.js +92 -0
  416. package/lib/dist/installer/targets/droid.js.map +1 -0
  417. package/lib/dist/installer/targets/dsh.d.ts +35 -0
  418. package/lib/dist/installer/targets/dsh.d.ts.map +1 -0
  419. package/lib/dist/installer/targets/dsh.js +267 -0
  420. package/lib/dist/installer/targets/dsh.js.map +1 -0
  421. package/lib/dist/installer/targets/gemini.js +0 -37
  422. package/lib/dist/installer/targets/gemini.js.map +1 -1
  423. package/lib/dist/installer/targets/grok.d.ts +25 -0
  424. package/lib/dist/installer/targets/grok.d.ts.map +1 -0
  425. package/lib/dist/installer/targets/grok.js +96 -0
  426. package/lib/dist/installer/targets/grok.js.map +1 -0
  427. package/lib/dist/installer/targets/hermes.d.ts +19 -7
  428. package/lib/dist/installer/targets/hermes.d.ts.map +1 -1
  429. package/lib/dist/installer/targets/hermes.js +218 -214
  430. package/lib/dist/installer/targets/hermes.js.map +1 -1
  431. package/lib/dist/installer/targets/json-config.d.ts +45 -0
  432. package/lib/dist/installer/targets/json-config.d.ts.map +1 -0
  433. package/lib/dist/installer/targets/json-config.js +128 -0
  434. package/lib/dist/installer/targets/json-config.js.map +1 -0
  435. package/lib/dist/installer/targets/kimi.d.ts +21 -0
  436. package/lib/dist/installer/targets/kimi.d.ts.map +1 -0
  437. package/lib/dist/installer/targets/kimi.js +97 -0
  438. package/lib/dist/installer/targets/kimi.js.map +1 -0
  439. package/lib/dist/installer/targets/kiro.js +1 -41
  440. package/lib/dist/installer/targets/kiro.js.map +1 -1
  441. package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
  442. package/lib/dist/installer/targets/opencode.js +1 -103
  443. package/lib/dist/installer/targets/opencode.js.map +1 -1
  444. package/lib/dist/installer/targets/pi.d.ts +24 -0
  445. package/lib/dist/installer/targets/pi.d.ts.map +1 -0
  446. package/lib/dist/installer/targets/pi.js +100 -0
  447. package/lib/dist/installer/targets/pi.js.map +1 -0
  448. package/lib/dist/installer/targets/qoder.d.ts +23 -0
  449. package/lib/dist/installer/targets/qoder.d.ts.map +1 -0
  450. package/lib/dist/installer/targets/qoder.js +83 -0
  451. package/lib/dist/installer/targets/qoder.js.map +1 -0
  452. package/lib/dist/installer/targets/qwen.d.ts +21 -0
  453. package/lib/dist/installer/targets/qwen.d.ts.map +1 -0
  454. package/lib/dist/installer/targets/qwen.js +115 -0
  455. package/lib/dist/installer/targets/qwen.js.map +1 -0
  456. package/lib/dist/installer/targets/registry.d.ts.map +1 -1
  457. package/lib/dist/installer/targets/registry.js +18 -25
  458. package/lib/dist/installer/targets/registry.js.map +1 -1
  459. package/lib/dist/installer/targets/shared.d.ts +83 -13
  460. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  461. package/lib/dist/installer/targets/shared.js +201 -131
  462. package/lib/dist/installer/targets/shared.js.map +1 -1
  463. package/lib/dist/installer/targets/toml.d.ts +82 -6
  464. package/lib/dist/installer/targets/toml.d.ts.map +1 -1
  465. package/lib/dist/installer/targets/toml.js +318 -112
  466. package/lib/dist/installer/targets/toml.js.map +1 -1
  467. package/lib/dist/installer/targets/types.d.ts +1 -1
  468. package/lib/dist/installer/targets/types.d.ts.map +1 -1
  469. package/lib/dist/installer/targets/types.js +0 -13
  470. package/lib/dist/installer/targets/types.js.map +1 -1
  471. package/lib/dist/installer/targets/windsurf.d.ts +22 -0
  472. package/lib/dist/installer/targets/windsurf.d.ts.map +1 -0
  473. package/lib/dist/installer/targets/windsurf.js +90 -0
  474. package/lib/dist/installer/targets/windsurf.js.map +1 -0
  475. package/lib/dist/lazy-engine.d.ts +22 -0
  476. package/lib/dist/lazy-engine.d.ts.map +1 -0
  477. package/lib/dist/lazy-engine.js +16 -0
  478. package/lib/dist/lazy-engine.js.map +1 -0
  479. package/lib/dist/mcp/answer-freshness.js +0 -6
  480. package/lib/dist/mcp/answer-freshness.js.map +1 -1
  481. package/lib/dist/mcp/daemon-manager.js +2 -23
  482. package/lib/dist/mcp/daemon-manager.js.map +1 -1
  483. package/lib/dist/mcp/daemon-paths.d.ts +2 -0
  484. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
  485. package/lib/dist/mcp/daemon-paths.js +9 -85
  486. package/lib/dist/mcp/daemon-paths.js.map +1 -1
  487. package/lib/dist/mcp/daemon-proof.d.ts +19 -0
  488. package/lib/dist/mcp/daemon-proof.d.ts.map +1 -0
  489. package/lib/dist/mcp/daemon-proof.js +126 -0
  490. package/lib/dist/mcp/daemon-proof.js.map +1 -0
  491. package/lib/dist/mcp/daemon-registry.d.ts +47 -2
  492. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
  493. package/lib/dist/mcp/daemon-registry.js +188 -139
  494. package/lib/dist/mcp/daemon-registry.js.map +1 -1
  495. package/lib/dist/mcp/daemon.d.ts +69 -0
  496. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  497. package/lib/dist/mcp/daemon.js +186 -376
  498. package/lib/dist/mcp/daemon.js.map +1 -1
  499. package/lib/dist/mcp/dynamic-boundaries.js +4 -78
  500. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
  501. package/lib/dist/mcp/early-ppid.js +0 -24
  502. package/lib/dist/mcp/early-ppid.js.map +1 -1
  503. package/lib/dist/mcp/engine.d.ts +24 -0
  504. package/lib/dist/mcp/engine.d.ts.map +1 -1
  505. package/lib/dist/mcp/engine.js +47 -152
  506. package/lib/dist/mcp/engine.js.map +1 -1
  507. package/lib/dist/mcp/explore-dedup.js +0 -108
  508. package/lib/dist/mcp/explore-dedup.js.map +1 -1
  509. package/lib/dist/mcp/explore-diagnostics.d.ts +6 -0
  510. package/lib/dist/mcp/explore-diagnostics.d.ts.map +1 -1
  511. package/lib/dist/mcp/explore-diagnostics.js +8 -116
  512. package/lib/dist/mcp/explore-diagnostics.js.map +1 -1
  513. package/lib/dist/mcp/explore-one-symbol.d.ts +77 -0
  514. package/lib/dist/mcp/explore-one-symbol.d.ts.map +1 -0
  515. package/lib/dist/mcp/explore-one-symbol.js +431 -0
  516. package/lib/dist/mcp/explore-one-symbol.js.map +1 -0
  517. package/lib/dist/mcp/explore-session-state.js +0 -129
  518. package/lib/dist/mcp/explore-session-state.js.map +1 -1
  519. package/lib/dist/mcp/hook-client.d.ts +44 -0
  520. package/lib/dist/mcp/hook-client.d.ts.map +1 -0
  521. package/lib/dist/mcp/hook-client.js +202 -0
  522. package/lib/dist/mcp/hook-client.js.map +1 -0
  523. package/lib/dist/mcp/index-freshness-worker.js +1 -6
  524. package/lib/dist/mcp/index-freshness-worker.js.map +1 -1
  525. package/lib/dist/mcp/index-freshness.js +0 -15
  526. package/lib/dist/mcp/index-freshness.js.map +1 -1
  527. package/lib/dist/mcp/index-version-warning.d.ts +21 -0
  528. package/lib/dist/mcp/index-version-warning.d.ts.map +1 -0
  529. package/lib/dist/mcp/index-version-warning.js +38 -0
  530. package/lib/dist/mcp/index-version-warning.js.map +1 -0
  531. package/lib/dist/mcp/index.d.ts +29 -1
  532. package/lib/dist/mcp/index.d.ts.map +1 -1
  533. package/lib/dist/mcp/index.js +131 -300
  534. package/lib/dist/mcp/index.js.map +1 -1
  535. package/lib/dist/mcp/liveness-watchdog.d.ts +13 -3
  536. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  537. package/lib/dist/mcp/liveness-watchdog.js +106 -121
  538. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  539. package/lib/dist/mcp/opencode-tool-names.d.ts +32 -0
  540. package/lib/dist/mcp/opencode-tool-names.d.ts.map +1 -0
  541. package/lib/dist/mcp/opencode-tool-names.js +24 -0
  542. package/lib/dist/mcp/opencode-tool-names.js.map +1 -0
  543. package/lib/dist/mcp/ppid-watchdog.js +0 -24
  544. package/lib/dist/mcp/ppid-watchdog.js.map +1 -1
  545. package/lib/dist/mcp/process-identity.d.ts +42 -0
  546. package/lib/dist/mcp/process-identity.d.ts.map +1 -0
  547. package/lib/dist/mcp/process-identity.js +130 -0
  548. package/lib/dist/mcp/process-identity.js.map +1 -0
  549. package/lib/dist/mcp/project-lifecycle.d.ts +6 -0
  550. package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -1
  551. package/lib/dist/mcp/project-lifecycle.js +70 -19
  552. package/lib/dist/mcp/project-lifecycle.js.map +1 -1
  553. package/lib/dist/mcp/prompt-explore.d.ts +19 -0
  554. package/lib/dist/mcp/prompt-explore.d.ts.map +1 -0
  555. package/lib/dist/mcp/prompt-explore.js +6 -0
  556. package/lib/dist/mcp/prompt-explore.js.map +1 -0
  557. package/lib/dist/mcp/proxy.d.ts +25 -7
  558. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  559. package/lib/dist/mcp/proxy.js +145 -274
  560. package/lib/dist/mcp/proxy.js.map +1 -1
  561. package/lib/dist/mcp/query-pool.d.ts +52 -3
  562. package/lib/dist/mcp/query-pool.d.ts.map +1 -1
  563. package/lib/dist/mcp/query-pool.js +114 -123
  564. package/lib/dist/mcp/query-pool.js.map +1 -1
  565. package/lib/dist/mcp/query-worker.js +24 -36
  566. package/lib/dist/mcp/query-worker.js.map +1 -1
  567. package/lib/dist/mcp/server-instructions.d.ts +18 -0
  568. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  569. package/lib/dist/mcp/server-instructions.js +12 -32
  570. package/lib/dist/mcp/server-instructions.js.map +1 -1
  571. package/lib/dist/mcp/session.d.ts +46 -0
  572. package/lib/dist/mcp/session.d.ts.map +1 -1
  573. package/lib/dist/mcp/session.js +70 -132
  574. package/lib/dist/mcp/session.js.map +1 -1
  575. package/lib/dist/mcp/startup-handshake.js +1 -48
  576. package/lib/dist/mcp/startup-handshake.js.map +1 -1
  577. package/lib/dist/mcp/stdin-teardown.js +0 -28
  578. package/lib/dist/mcp/stdin-teardown.js.map +1 -1
  579. package/lib/dist/mcp/stdout-teardown.d.ts +26 -0
  580. package/lib/dist/mcp/stdout-teardown.d.ts.map +1 -0
  581. package/lib/dist/mcp/stdout-teardown.js +20 -0
  582. package/lib/dist/mcp/stdout-teardown.js.map +1 -0
  583. package/lib/dist/mcp/tools.d.ts +157 -18
  584. package/lib/dist/mcp/tools.d.ts.map +1 -1
  585. package/lib/dist/mcp/tools.js +797 -3621
  586. package/lib/dist/mcp/tools.js.map +1 -1
  587. package/lib/dist/mcp/transport.d.ts.map +1 -1
  588. package/lib/dist/mcp/transport.js +4 -96
  589. package/lib/dist/mcp/transport.js.map +1 -1
  590. package/lib/dist/mcp/version.d.ts +13 -1
  591. package/lib/dist/mcp/version.d.ts.map +1 -1
  592. package/lib/dist/mcp/version.js +19 -21
  593. package/lib/dist/mcp/version.js.map +1 -1
  594. package/lib/dist/mcp/writer-lock.d.ts +11 -0
  595. package/lib/dist/mcp/writer-lock.d.ts.map +1 -1
  596. package/lib/dist/mcp/writer-lock.js +49 -46
  597. package/lib/dist/mcp/writer-lock.js.map +1 -1
  598. package/lib/dist/project-config.d.ts +20 -0
  599. package/lib/dist/project-config.d.ts.map +1 -1
  600. package/lib/dist/project-config.js +31 -140
  601. package/lib/dist/project-config.js.map +1 -1
  602. package/lib/dist/resolution/alias-binding.d.ts +7 -0
  603. package/lib/dist/resolution/alias-binding.d.ts.map +1 -1
  604. package/lib/dist/resolution/alias-binding.js +7 -56
  605. package/lib/dist/resolution/alias-binding.js.map +1 -1
  606. package/lib/dist/resolution/ambient-modules.d.ts +185 -0
  607. package/lib/dist/resolution/ambient-modules.d.ts.map +1 -0
  608. package/lib/dist/resolution/ambient-modules.js +732 -0
  609. package/lib/dist/resolution/ambient-modules.js.map +1 -0
  610. package/lib/dist/resolution/angular-template-synthesizer.d.ts +48 -1
  611. package/lib/dist/resolution/angular-template-synthesizer.d.ts.map +1 -1
  612. package/lib/dist/resolution/angular-template-synthesizer.js +401 -65
  613. package/lib/dist/resolution/angular-template-synthesizer.js.map +1 -1
  614. package/lib/dist/resolution/c-feature-variants.d.ts +40 -0
  615. package/lib/dist/resolution/c-feature-variants.d.ts.map +1 -0
  616. package/lib/dist/resolution/c-feature-variants.js +249 -0
  617. package/lib/dist/resolution/c-feature-variants.js.map +1 -0
  618. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  619. package/lib/dist/resolution/c-fnptr-synthesizer.js +23 -391
  620. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  621. package/lib/dist/resolution/c-macro-renames.d.ts +25 -0
  622. package/lib/dist/resolution/c-macro-renames.d.ts.map +1 -0
  623. package/lib/dist/resolution/c-macro-renames.js +95 -0
  624. package/lib/dist/resolution/c-macro-renames.js.map +1 -0
  625. package/lib/dist/resolution/callback-synthesizer.d.ts +19 -5
  626. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  627. package/lib/dist/resolution/callback-synthesizer.js +1395 -1343
  628. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  629. package/lib/dist/resolution/const-alias-synthesizer.d.ts +48 -0
  630. package/lib/dist/resolution/const-alias-synthesizer.d.ts.map +1 -0
  631. package/lib/dist/resolution/const-alias-synthesizer.js +234 -0
  632. package/lib/dist/resolution/const-alias-synthesizer.js.map +1 -0
  633. package/lib/dist/resolution/cooperative-yield.js +0 -27
  634. package/lib/dist/resolution/cooperative-yield.js.map +1 -1
  635. package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -1
  636. package/lib/dist/resolution/cpp-constructor.js +15 -17
  637. package/lib/dist/resolution/cpp-constructor.js.map +1 -1
  638. package/lib/dist/resolution/cpp-includers.d.ts +46 -0
  639. package/lib/dist/resolution/cpp-includers.d.ts.map +1 -0
  640. package/lib/dist/resolution/cpp-includers.js +153 -0
  641. package/lib/dist/resolution/cpp-includers.js.map +1 -0
  642. package/lib/dist/resolution/cpp-macro-visibility.d.ts +16 -0
  643. package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -1
  644. package/lib/dist/resolution/cpp-macro-visibility.js +17 -68
  645. package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -1
  646. package/lib/dist/resolution/cpp-namespaces.d.ts +54 -0
  647. package/lib/dist/resolution/cpp-namespaces.d.ts.map +1 -0
  648. package/lib/dist/resolution/cpp-namespaces.js +151 -0
  649. package/lib/dist/resolution/cpp-namespaces.js.map +1 -0
  650. package/lib/dist/resolution/cpp-raw-strings.d.ts +33 -0
  651. package/lib/dist/resolution/cpp-raw-strings.d.ts.map +1 -0
  652. package/lib/dist/resolution/cpp-raw-strings.js +167 -0
  653. package/lib/dist/resolution/cpp-raw-strings.js.map +1 -0
  654. package/lib/dist/resolution/cpp-supertypes.d.ts +118 -0
  655. package/lib/dist/resolution/cpp-supertypes.d.ts.map +1 -0
  656. package/lib/dist/resolution/cpp-supertypes.js +322 -0
  657. package/lib/dist/resolution/cpp-supertypes.js.map +1 -0
  658. package/lib/dist/resolution/cpp-template-instantiations.d.ts +83 -0
  659. package/lib/dist/resolution/cpp-template-instantiations.d.ts.map +1 -0
  660. package/lib/dist/resolution/cpp-template-instantiations.js +983 -0
  661. package/lib/dist/resolution/cpp-template-instantiations.js.map +1 -0
  662. package/lib/dist/resolution/cpp-type-aliases.d.ts +194 -0
  663. package/lib/dist/resolution/cpp-type-aliases.d.ts.map +1 -0
  664. package/lib/dist/resolution/cpp-type-aliases.js +648 -0
  665. package/lib/dist/resolution/cpp-type-aliases.js.map +1 -0
  666. package/lib/dist/resolution/dart-libraries.d.ts +75 -0
  667. package/lib/dist/resolution/dart-libraries.d.ts.map +1 -0
  668. package/lib/dist/resolution/dart-libraries.js +721 -0
  669. package/lib/dist/resolution/dart-libraries.js.map +1 -0
  670. package/lib/dist/resolution/dart-local-scope.d.ts +41 -0
  671. package/lib/dist/resolution/dart-local-scope.d.ts.map +1 -0
  672. package/lib/dist/resolution/dart-local-scope.js +565 -0
  673. package/lib/dist/resolution/dart-local-scope.js.map +1 -0
  674. package/lib/dist/resolution/event-emitter-synthesizer.d.ts +39 -0
  675. package/lib/dist/resolution/event-emitter-synthesizer.d.ts.map +1 -0
  676. package/lib/dist/resolution/event-emitter-synthesizer.js +656 -0
  677. package/lib/dist/resolution/event-emitter-synthesizer.js.map +1 -0
  678. package/lib/dist/resolution/expo-router-synthesizer.js +0 -52
  679. package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -1
  680. package/lib/dist/resolution/frameworks/angular-router.d.ts.map +1 -1
  681. package/lib/dist/resolution/frameworks/angular-router.js +41 -208
  682. package/lib/dist/resolution/frameworks/angular-router.js.map +1 -1
  683. package/lib/dist/resolution/frameworks/aspnet-routes.d.ts +62 -0
  684. package/lib/dist/resolution/frameworks/aspnet-routes.d.ts.map +1 -0
  685. package/lib/dist/resolution/frameworks/aspnet-routes.js +382 -0
  686. package/lib/dist/resolution/frameworks/aspnet-routes.js.map +1 -0
  687. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -1
  688. package/lib/dist/resolution/frameworks/astro.js +4 -60
  689. package/lib/dist/resolution/frameworks/astro.js.map +1 -1
  690. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -1
  691. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -1
  692. package/lib/dist/resolution/frameworks/cargo-workspace.js +65 -15
  693. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -1
  694. package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -1
  695. package/lib/dist/resolution/frameworks/cics.js +7 -33
  696. package/lib/dist/resolution/frameworks/cics.js.map +1 -1
  697. package/lib/dist/resolution/frameworks/codeigniter.d.ts +23 -0
  698. package/lib/dist/resolution/frameworks/codeigniter.d.ts.map +1 -0
  699. package/lib/dist/resolution/frameworks/codeigniter.js +271 -0
  700. package/lib/dist/resolution/frameworks/codeigniter.js.map +1 -0
  701. package/lib/dist/resolution/frameworks/component-folder.d.ts +17 -0
  702. package/lib/dist/resolution/frameworks/component-folder.d.ts.map +1 -0
  703. package/lib/dist/resolution/frameworks/component-folder.js +11 -0
  704. package/lib/dist/resolution/frameworks/component-folder.js.map +1 -0
  705. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  706. package/lib/dist/resolution/frameworks/csharp.js +85 -102
  707. package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
  708. package/lib/dist/resolution/frameworks/drupal.d.ts +17 -8
  709. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -1
  710. package/lib/dist/resolution/frameworks/drupal.js +377 -142
  711. package/lib/dist/resolution/frameworks/drupal.js.map +1 -1
  712. package/lib/dist/resolution/frameworks/elysia.d.ts +38 -0
  713. package/lib/dist/resolution/frameworks/elysia.d.ts.map +1 -0
  714. package/lib/dist/resolution/frameworks/elysia.js +683 -0
  715. package/lib/dist/resolution/frameworks/elysia.js.map +1 -0
  716. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
  717. package/lib/dist/resolution/frameworks/expo-modules.js +8 -88
  718. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
  719. package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -1
  720. package/lib/dist/resolution/frameworks/expo-router.js +9 -190
  721. package/lib/dist/resolution/frameworks/expo-router.js.map +1 -1
  722. package/lib/dist/resolution/frameworks/express.d.ts +48 -1
  723. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
  724. package/lib/dist/resolution/frameworks/express.js +193 -199
  725. package/lib/dist/resolution/frameworks/express.js.map +1 -1
  726. package/lib/dist/resolution/frameworks/fabric.js +1 -104
  727. package/lib/dist/resolution/frameworks/fabric.js.map +1 -1
  728. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
  729. package/lib/dist/resolution/frameworks/go.js +14 -43
  730. package/lib/dist/resolution/frameworks/go.js.map +1 -1
  731. package/lib/dist/resolution/frameworks/goframe.js +1 -55
  732. package/lib/dist/resolution/frameworks/goframe.js.map +1 -1
  733. package/lib/dist/resolution/frameworks/index.d.ts +14 -0
  734. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  735. package/lib/dist/resolution/frameworks/index.js +16 -50
  736. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  737. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
  738. package/lib/dist/resolution/frameworks/java.js +203 -129
  739. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  740. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
  741. package/lib/dist/resolution/frameworks/laravel.js +71 -136
  742. package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
  743. package/lib/dist/resolution/frameworks/name-heuristic.js +0 -12
  744. package/lib/dist/resolution/frameworks/name-heuristic.js.map +1 -1
  745. package/lib/dist/resolution/frameworks/nestjs.js +2 -199
  746. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
  747. package/lib/dist/resolution/frameworks/next-proxy.d.ts +67 -0
  748. package/lib/dist/resolution/frameworks/next-proxy.d.ts.map +1 -0
  749. package/lib/dist/resolution/frameworks/next-proxy.js +239 -0
  750. package/lib/dist/resolution/frameworks/next-proxy.js.map +1 -0
  751. package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -1
  752. package/lib/dist/resolution/frameworks/nextjs.js +10 -66
  753. package/lib/dist/resolution/frameworks/nextjs.js.map +1 -1
  754. package/lib/dist/resolution/frameworks/object-literal.js +0 -21
  755. package/lib/dist/resolution/frameworks/object-literal.js.map +1 -1
  756. package/lib/dist/resolution/frameworks/package-deps.d.ts +11 -7
  757. package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -1
  758. package/lib/dist/resolution/frameworks/package-deps.js +35 -26
  759. package/lib/dist/resolution/frameworks/package-deps.js.map +1 -1
  760. package/lib/dist/resolution/frameworks/page-component.js +0 -14
  761. package/lib/dist/resolution/frameworks/page-component.js.map +1 -1
  762. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -1
  763. package/lib/dist/resolution/frameworks/play.js +26 -34
  764. package/lib/dist/resolution/frameworks/play.js.map +1 -1
  765. package/lib/dist/resolution/frameworks/python.js +5 -102
  766. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  767. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  768. package/lib/dist/resolution/frameworks/react-native.js +1 -166
  769. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  770. package/lib/dist/resolution/frameworks/react-router.d.ts +13 -4
  771. package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -1
  772. package/lib/dist/resolution/frameworks/react-router.js +10 -82
  773. package/lib/dist/resolution/frameworks/react-router.js.map +1 -1
  774. package/lib/dist/resolution/frameworks/react.d.ts +57 -0
  775. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  776. package/lib/dist/resolution/frameworks/react.js +1449 -191
  777. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  778. package/lib/dist/resolution/frameworks/ruby.js +1 -61
  779. package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
  780. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
  781. package/lib/dist/resolution/frameworks/rust.js +35 -56
  782. package/lib/dist/resolution/frameworks/rust.js.map +1 -1
  783. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
  784. package/lib/dist/resolution/frameworks/svelte.js +7 -75
  785. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  786. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -1
  787. package/lib/dist/resolution/frameworks/sveltekit-router.js +8 -46
  788. package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -1
  789. package/lib/dist/resolution/frameworks/swift-objc.js +0 -97
  790. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -1
  791. package/lib/dist/resolution/frameworks/swift.js +0 -97
  792. package/lib/dist/resolution/frameworks/swift.js.map +1 -1
  793. package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -1
  794. package/lib/dist/resolution/frameworks/tanstack-router.js +9 -130
  795. package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -1
  796. package/lib/dist/resolution/frameworks/terraform.js +1 -85
  797. package/lib/dist/resolution/frameworks/terraform.js.map +1 -1
  798. package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -1
  799. package/lib/dist/resolution/frameworks/vue-router.js +11 -134
  800. package/lib/dist/resolution/frameworks/vue-router.js.map +1 -1
  801. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -1
  802. package/lib/dist/resolution/frameworks/vue.js +42 -114
  803. package/lib/dist/resolution/frameworks/vue.js.map +1 -1
  804. package/lib/dist/resolution/go-func-field-synthesizer.d.ts +58 -0
  805. package/lib/dist/resolution/go-func-field-synthesizer.d.ts.map +1 -0
  806. package/lib/dist/resolution/go-func-field-synthesizer.js +696 -0
  807. package/lib/dist/resolution/go-func-field-synthesizer.js.map +1 -0
  808. package/lib/dist/resolution/go-module.d.ts +23 -7
  809. package/lib/dist/resolution/go-module.d.ts.map +1 -1
  810. package/lib/dist/resolution/go-module.js +21 -24
  811. package/lib/dist/resolution/go-module.js.map +1 -1
  812. package/lib/dist/resolution/go-stdlib-methods.d.ts +9 -0
  813. package/lib/dist/resolution/go-stdlib-methods.d.ts.map +1 -0
  814. package/lib/dist/resolution/go-stdlib-methods.js +224 -0
  815. package/lib/dist/resolution/go-stdlib-methods.js.map +1 -0
  816. package/lib/dist/resolution/goframe-synthesizer.js +2 -53
  817. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -1
  818. package/lib/dist/resolution/import-resolver.d.ts +278 -29
  819. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  820. package/lib/dist/resolution/import-resolver.js +1825 -1396
  821. package/lib/dist/resolution/import-resolver.js.map +1 -1
  822. package/lib/dist/resolution/index.d.ts +517 -6
  823. package/lib/dist/resolution/index.d.ts.map +1 -1
  824. package/lib/dist/resolution/index.js +1604 -1042
  825. package/lib/dist/resolution/index.js.map +1 -1
  826. package/lib/dist/resolution/js-builtins.d.ts +23 -0
  827. package/lib/dist/resolution/js-builtins.d.ts.map +1 -1
  828. package/lib/dist/resolution/js-builtins.js +34 -14
  829. package/lib/dist/resolution/js-builtins.js.map +1 -1
  830. package/lib/dist/resolution/js-class-expressions.d.ts +48 -0
  831. package/lib/dist/resolution/js-class-expressions.d.ts.map +1 -0
  832. package/lib/dist/resolution/js-class-expressions.js +25 -0
  833. package/lib/dist/resolution/js-class-expressions.js.map +1 -0
  834. package/lib/dist/resolution/js-super-calls.d.ts +18 -0
  835. package/lib/dist/resolution/js-super-calls.d.ts.map +1 -0
  836. package/lib/dist/resolution/js-super-calls.js +94 -0
  837. package/lib/dist/resolution/js-super-calls.js.map +1 -0
  838. package/lib/dist/resolution/jsx-code.d.ts +28 -0
  839. package/lib/dist/resolution/jsx-code.d.ts.map +1 -0
  840. package/lib/dist/resolution/jsx-code.js +459 -0
  841. package/lib/dist/resolution/jsx-code.js.map +1 -0
  842. package/lib/dist/resolution/lru-cache.d.ts +5 -13
  843. package/lib/dist/resolution/lru-cache.d.ts.map +1 -1
  844. package/lib/dist/resolution/lru-cache.js +43 -32
  845. package/lib/dist/resolution/lru-cache.js.map +1 -1
  846. package/lib/dist/resolution/memory-budget.js +0 -52
  847. package/lib/dist/resolution/memory-budget.js.map +1 -1
  848. package/lib/dist/resolution/module-importers.d.ts +210 -0
  849. package/lib/dist/resolution/module-importers.d.ts.map +1 -0
  850. package/lib/dist/resolution/module-importers.js +673 -0
  851. package/lib/dist/resolution/module-importers.js.map +1 -0
  852. package/lib/dist/resolution/name-matcher.d.ts +986 -7
  853. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  854. package/lib/dist/resolution/name-matcher.js +24176 -6745
  855. package/lib/dist/resolution/name-matcher.js.map +1 -1
  856. package/lib/dist/resolution/next-router-synthesizer.d.ts +19 -0
  857. package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -1
  858. package/lib/dist/resolution/next-router-synthesizer.js +46 -28
  859. package/lib/dist/resolution/next-router-synthesizer.js.map +1 -1
  860. package/lib/dist/resolution/override-parameters.d.ts +40 -0
  861. package/lib/dist/resolution/override-parameters.d.ts.map +1 -0
  862. package/lib/dist/resolution/override-parameters.js +339 -0
  863. package/lib/dist/resolution/override-parameters.js.map +1 -0
  864. package/lib/dist/resolution/parameter-flow.d.ts +218 -0
  865. package/lib/dist/resolution/parameter-flow.d.ts.map +1 -0
  866. package/lib/dist/resolution/parameter-flow.js +474 -0
  867. package/lib/dist/resolution/parameter-flow.js.map +1 -0
  868. package/lib/dist/resolution/pascal-scope.d.ts +91 -0
  869. package/lib/dist/resolution/pascal-scope.d.ts.map +1 -0
  870. package/lib/dist/resolution/pascal-scope.js +961 -0
  871. package/lib/dist/resolution/pascal-scope.js.map +1 -0
  872. package/lib/dist/resolution/path-aliases.d.ts +32 -4
  873. package/lib/dist/resolution/path-aliases.d.ts.map +1 -1
  874. package/lib/dist/resolution/path-aliases.js +43 -110
  875. package/lib/dist/resolution/path-aliases.js.map +1 -1
  876. package/lib/dist/resolution/php-web-root.d.ts +39 -0
  877. package/lib/dist/resolution/php-web-root.d.ts.map +1 -0
  878. package/lib/dist/resolution/php-web-root.js +141 -0
  879. package/lib/dist/resolution/php-web-root.js.map +1 -0
  880. package/lib/dist/resolution/project-scans.d.ts +38 -0
  881. package/lib/dist/resolution/project-scans.d.ts.map +1 -0
  882. package/lib/dist/resolution/project-scans.js +30 -0
  883. package/lib/dist/resolution/project-scans.js.map +1 -0
  884. package/lib/dist/resolution/python-overloads.d.ts +10 -0
  885. package/lib/dist/resolution/python-overloads.d.ts.map +1 -0
  886. package/lib/dist/resolution/python-overloads.js +75 -0
  887. package/lib/dist/resolution/python-overloads.js.map +1 -0
  888. package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -1
  889. package/lib/dist/resolution/react-router-synthesizer.js +3 -55
  890. package/lib/dist/resolution/react-router-synthesizer.js.map +1 -1
  891. package/lib/dist/resolution/resolver-pool.d.ts +23 -2
  892. package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
  893. package/lib/dist/resolution/resolver-pool.js +43 -111
  894. package/lib/dist/resolution/resolver-pool.js.map +1 -1
  895. package/lib/dist/resolution/resolver-worker.d.ts +1 -1
  896. package/lib/dist/resolution/resolver-worker.d.ts.map +1 -1
  897. package/lib/dist/resolution/resolver-worker.js +8 -37
  898. package/lib/dist/resolution/resolver-worker.js.map +1 -1
  899. package/lib/dist/resolution/resurrect-ref.d.ts +25 -0
  900. package/lib/dist/resolution/resurrect-ref.d.ts.map +1 -0
  901. package/lib/dist/resolution/resurrect-ref.js +19 -0
  902. package/lib/dist/resolution/resurrect-ref.js.map +1 -0
  903. package/lib/dist/resolution/ruby-constant-paths.d.ts +56 -0
  904. package/lib/dist/resolution/ruby-constant-paths.d.ts.map +1 -0
  905. package/lib/dist/resolution/ruby-constant-paths.js +255 -0
  906. package/lib/dist/resolution/ruby-constant-paths.js.map +1 -0
  907. package/lib/dist/resolution/ruby-parameter-flow.d.ts +10 -0
  908. package/lib/dist/resolution/ruby-parameter-flow.d.ts.map +1 -0
  909. package/lib/dist/resolution/ruby-parameter-flow.js +801 -0
  910. package/lib/dist/resolution/ruby-parameter-flow.js.map +1 -0
  911. package/lib/dist/resolution/rust-scopes.d.ts +120 -0
  912. package/lib/dist/resolution/rust-scopes.d.ts.map +1 -0
  913. package/lib/dist/resolution/rust-scopes.js +730 -0
  914. package/lib/dist/resolution/rust-scopes.js.map +1 -0
  915. package/lib/dist/resolution/shopify-themes.d.ts +10 -0
  916. package/lib/dist/resolution/shopify-themes.d.ts.map +1 -0
  917. package/lib/dist/resolution/shopify-themes.js +19 -0
  918. package/lib/dist/resolution/shopify-themes.js.map +1 -0
  919. package/lib/dist/resolution/strip-comments.d.ts +20 -1
  920. package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
  921. package/lib/dist/resolution/strip-comments.js +164 -119
  922. package/lib/dist/resolution/strip-comments.js.map +1 -1
  923. package/lib/dist/resolution/sveltekit-synthesizer.js +0 -64
  924. package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -1
  925. package/lib/dist/resolution/swift-objc-bridge.js +0 -160
  926. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -1
  927. package/lib/dist/resolution/swift-type-visibility.d.ts.map +1 -1
  928. package/lib/dist/resolution/swift-type-visibility.js +62 -104
  929. package/lib/dist/resolution/swift-type-visibility.js.map +1 -1
  930. package/lib/dist/resolution/synth-utils.js +1 -22
  931. package/lib/dist/resolution/synth-utils.js.map +1 -1
  932. package/lib/dist/resolution/tanstack-router-synthesizer.js +0 -32
  933. package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -1
  934. package/lib/dist/resolution/tauri-synthesizer.d.ts +37 -0
  935. package/lib/dist/resolution/tauri-synthesizer.d.ts.map +1 -0
  936. package/lib/dist/resolution/tauri-synthesizer.js +1038 -0
  937. package/lib/dist/resolution/tauri-synthesizer.js.map +1 -0
  938. package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -1
  939. package/lib/dist/resolution/tier-synthesizer.js +35 -177
  940. package/lib/dist/resolution/tier-synthesizer.js.map +1 -1
  941. package/lib/dist/resolution/type-parameters.d.ts +23 -0
  942. package/lib/dist/resolution/type-parameters.d.ts.map +1 -1
  943. package/lib/dist/resolution/type-parameters.js +52 -54
  944. package/lib/dist/resolution/type-parameters.js.map +1 -1
  945. package/lib/dist/resolution/types.d.ts +192 -11
  946. package/lib/dist/resolution/types.d.ts.map +1 -1
  947. package/lib/dist/resolution/types.js +0 -47
  948. package/lib/dist/resolution/types.js.map +1 -1
  949. package/lib/dist/resolution/vbnet-receivers.d.ts +92 -0
  950. package/lib/dist/resolution/vbnet-receivers.d.ts.map +1 -0
  951. package/lib/dist/resolution/vbnet-receivers.js +1482 -0
  952. package/lib/dist/resolution/vbnet-receivers.js.map +1 -0
  953. package/lib/dist/resolution/vue-router-synthesizer.js +0 -31
  954. package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -1
  955. package/lib/dist/resolution/workspace-packages.d.ts +206 -15
  956. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -1
  957. package/lib/dist/resolution/workspace-packages.js +573 -152
  958. package/lib/dist/resolution/workspace-packages.js.map +1 -1
  959. package/lib/dist/search/identifier-segments.js +2 -93
  960. package/lib/dist/search/identifier-segments.js.map +1 -1
  961. package/lib/dist/search/query-parser.js +0 -54
  962. package/lib/dist/search/query-parser.js.map +1 -1
  963. package/lib/dist/search/query-paths.js +0 -167
  964. package/lib/dist/search/query-paths.js.map +1 -1
  965. package/lib/dist/search/query-utils.d.ts +44 -0
  966. package/lib/dist/search/query-utils.d.ts.map +1 -1
  967. package/lib/dist/search/query-utils.js +120 -198
  968. package/lib/dist/search/query-utils.js.map +1 -1
  969. package/lib/dist/sync/git-hooks.d.ts +14 -5
  970. package/lib/dist/sync/git-hooks.d.ts.map +1 -1
  971. package/lib/dist/sync/git-hooks.js +118 -65
  972. package/lib/dist/sync/git-hooks.js.map +1 -1
  973. package/lib/dist/sync/index.js +0 -14
  974. package/lib/dist/sync/index.js.map +1 -1
  975. package/lib/dist/sync/watch-policy.js +0 -45
  976. package/lib/dist/sync/watch-policy.js.map +1 -1
  977. package/lib/dist/sync/watcher.d.ts +29 -11
  978. package/lib/dist/sync/watcher.d.ts.map +1 -1
  979. package/lib/dist/sync/watcher.js +83 -487
  980. package/lib/dist/sync/watcher.js.map +1 -1
  981. package/lib/dist/sync/worktree.d.ts +7 -2
  982. package/lib/dist/sync/worktree.d.ts.map +1 -1
  983. package/lib/dist/sync/worktree.js +24 -97
  984. package/lib/dist/sync/worktree.js.map +1 -1
  985. package/lib/dist/telemetry/index.d.ts.map +1 -1
  986. package/lib/dist/telemetry/index.js +15 -135
  987. package/lib/dist/telemetry/index.js.map +1 -1
  988. package/lib/dist/types.d.ts +46 -0
  989. package/lib/dist/types.d.ts.map +1 -1
  990. package/lib/dist/types.js +15 -44
  991. package/lib/dist/types.js.map +1 -1
  992. package/lib/dist/ui/color.js +0 -19
  993. package/lib/dist/ui/color.js.map +1 -1
  994. package/lib/dist/ui/glyphs.js +2 -45
  995. package/lib/dist/ui/glyphs.js.map +1 -1
  996. package/lib/dist/ui/shimmer-progress.js +0 -21
  997. package/lib/dist/ui/shimmer-progress.js.map +1 -1
  998. package/lib/dist/ui/shimmer-worker.js +0 -22
  999. package/lib/dist/ui/shimmer-worker.js.map +1 -1
  1000. package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -1
  1001. package/lib/dist/ui-server/api/deadcode.js +2 -31
  1002. package/lib/dist/ui-server/api/deadcode.js.map +1 -1
  1003. package/lib/dist/ui-server/api/effects.js +0 -111
  1004. package/lib/dist/ui-server/api/effects.js.map +1 -1
  1005. package/lib/dist/ui-server/api/entrypoints.js +0 -142
  1006. package/lib/dist/ui-server/api/entrypoints.js.map +1 -1
  1007. package/lib/dist/ui-server/api/events.js +0 -145
  1008. package/lib/dist/ui-server/api/events.js.map +1 -1
  1009. package/lib/dist/ui-server/api/file.js +0 -80
  1010. package/lib/dist/ui-server/api/file.js.map +1 -1
  1011. package/lib/dist/ui-server/api/filecode.js +0 -95
  1012. package/lib/dist/ui-server/api/filecode.js.map +1 -1
  1013. package/lib/dist/ui-server/api/flow.js +0 -149
  1014. package/lib/dist/ui-server/api/flow.js.map +1 -1
  1015. package/lib/dist/ui-server/api/hierarchy.js +0 -28
  1016. package/lib/dist/ui-server/api/hierarchy.js.map +1 -1
  1017. package/lib/dist/ui-server/api/index.js +0 -88
  1018. package/lib/dist/ui-server/api/index.js.map +1 -1
  1019. package/lib/dist/ui-server/api/map.d.ts.map +1 -1
  1020. package/lib/dist/ui-server/api/map.js +4 -317
  1021. package/lib/dist/ui-server/api/map.js.map +1 -1
  1022. package/lib/dist/ui-server/api/node.js +0 -111
  1023. package/lib/dist/ui-server/api/node.js.map +1 -1
  1024. package/lib/dist/ui-server/api/nodes.js +0 -16
  1025. package/lib/dist/ui-server/api/nodes.js.map +1 -1
  1026. package/lib/dist/ui-server/api/program.js +0 -90
  1027. package/lib/dist/ui-server/api/program.js.map +1 -1
  1028. package/lib/dist/ui-server/api/respond.js +0 -60
  1029. package/lib/dist/ui-server/api/respond.js.map +1 -1
  1030. package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -1
  1031. package/lib/dist/ui-server/api/route-roots.js +2 -44
  1032. package/lib/dist/ui-server/api/route-roots.js.map +1 -1
  1033. package/lib/dist/ui-server/api/routes.d.ts.map +1 -1
  1034. package/lib/dist/ui-server/api/routes.js +4 -60
  1035. package/lib/dist/ui-server/api/routes.js.map +1 -1
  1036. package/lib/dist/ui-server/api/screens.d.ts.map +1 -1
  1037. package/lib/dist/ui-server/api/screens.js +4 -174
  1038. package/lib/dist/ui-server/api/screens.js.map +1 -1
  1039. package/lib/dist/ui-server/api/search.js +0 -62
  1040. package/lib/dist/ui-server/api/search.js.map +1 -1
  1041. package/lib/dist/ui-server/api/session.js +0 -58
  1042. package/lib/dist/ui-server/api/session.js.map +1 -1
  1043. package/lib/dist/ui-server/api/source.d.ts.map +1 -1
  1044. package/lib/dist/ui-server/api/source.js +0 -161
  1045. package/lib/dist/ui-server/api/source.js.map +1 -1
  1046. package/lib/dist/ui-server/api/stats.js +0 -58
  1047. package/lib/dist/ui-server/api/stats.js.map +1 -1
  1048. package/lib/dist/ui-server/api/steps.d.ts.map +1 -1
  1049. package/lib/dist/ui-server/api/steps.js +5 -381
  1050. package/lib/dist/ui-server/api/steps.js.map +1 -1
  1051. package/lib/dist/ui-server/api/trail-store.d.ts +3 -3
  1052. package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -1
  1053. package/lib/dist/ui-server/api/trail-store.js +24 -106
  1054. package/lib/dist/ui-server/api/trail-store.js.map +1 -1
  1055. package/lib/dist/ui-server/api/trails.d.ts.map +1 -1
  1056. package/lib/dist/ui-server/api/trails.js +19 -94
  1057. package/lib/dist/ui-server/api/trails.js.map +1 -1
  1058. package/lib/dist/ui-server/api/when.js +0 -36
  1059. package/lib/dist/ui-server/api/when.js.map +1 -1
  1060. package/lib/dist/ui-server/api/wire.js +0 -58
  1061. package/lib/dist/ui-server/api/wire.js.map +1 -1
  1062. package/lib/dist/ui-server/assets.js +0 -35
  1063. package/lib/dist/ui-server/assets.js.map +1 -1
  1064. package/lib/dist/ui-server/constants.js +0 -26
  1065. package/lib/dist/ui-server/constants.js.map +1 -1
  1066. package/lib/dist/ui-server/highlight/bounded-tokenize.js +0 -25
  1067. package/lib/dist/ui-server/highlight/bounded-tokenize.js.map +1 -1
  1068. package/lib/dist/ui-server/highlight/index.js +1 -132
  1069. package/lib/dist/ui-server/highlight/index.js.map +1 -1
  1070. package/lib/dist/ui-server/highlight/languages.d.ts +3 -3
  1071. package/lib/dist/ui-server/highlight/languages.js +0 -31
  1072. package/lib/dist/ui-server/highlight/languages.js.map +1 -1
  1073. package/lib/dist/ui-server/highlight/tokenize-worker.js +0 -5
  1074. package/lib/dist/ui-server/highlight/tokenize-worker.js.map +1 -1
  1075. package/lib/dist/ui-server/index.d.ts +25 -0
  1076. package/lib/dist/ui-server/index.d.ts.map +1 -1
  1077. package/lib/dist/ui-server/index.js +35 -103
  1078. package/lib/dist/ui-server/index.js.map +1 -1
  1079. package/lib/dist/ui-server/open-browser.js +0 -34
  1080. package/lib/dist/ui-server/open-browser.js.map +1 -1
  1081. package/lib/dist/ui-server/security.d.ts +5 -0
  1082. package/lib/dist/ui-server/security.d.ts.map +1 -1
  1083. package/lib/dist/ui-server/security.js +11 -147
  1084. package/lib/dist/ui-server/security.js.map +1 -1
  1085. package/lib/dist/ui-server/static.js +0 -41
  1086. package/lib/dist/ui-server/static.js.map +1 -1
  1087. package/lib/dist/upgrade/index.d.ts +18 -5
  1088. package/lib/dist/upgrade/index.d.ts.map +1 -1
  1089. package/lib/dist/upgrade/index.js +73 -229
  1090. package/lib/dist/upgrade/index.js.map +1 -1
  1091. package/lib/dist/upgrade/remove-binary.js +2 -67
  1092. package/lib/dist/upgrade/remove-binary.js.map +1 -1
  1093. package/lib/dist/upgrade/update-check.js +1 -81
  1094. package/lib/dist/upgrade/update-check.js.map +1 -1
  1095. package/lib/dist/utils.d.ts +69 -1
  1096. package/lib/dist/utils.d.ts.map +1 -1
  1097. package/lib/dist/utils.js +224 -266
  1098. package/lib/dist/utils.js.map +1 -1
  1099. package/lib/dist/worker-teardown.js +0 -47
  1100. package/lib/dist/worker-teardown.js.map +1 -1
  1101. package/lib/kernel/codegraph-kernel.node +2 -2
  1102. package/lib/node_modules/.package-lock.json +4 -4
  1103. package/lib/node_modules/ignore/README.md +138 -8
  1104. package/lib/node_modules/ignore/index.d.ts +56 -20
  1105. package/lib/node_modules/ignore/index.js +1033 -221
  1106. package/lib/node_modules/ignore/legacy.js +871 -178
  1107. package/lib/node_modules/ignore/package.json +10 -4
  1108. package/lib/package.json +14 -8
  1109. package/node.exe +2 -2
  1110. package/package.json +1 -1
package/lib/dist/index.js CHANGED
@@ -1,10 +1,4 @@
1
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
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
3
  if (k2 === undefined) k2 = k;
10
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -45,20 +39,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
45
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
46
40
  };
47
41
  Object.defineProperty(exports, "__esModule", { value: true });
48
- 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.QueryBuilder = exports.DatabaseConnection = exports.getDatabasePath = void 0;
42
+ exports.CodeGraph = exports.MCPServer = exports.FileWatcher = exports.MemoryMonitor = exports.throttle = exports.debounce = exports.processInBatches = exports.FileLock = exports.Mutex = exports.LockUnavailableError = 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.QueryBuilder = exports.DatabaseConnection = exports.getDatabasePath = void 0;
43
+ exports.parseSynthMinIntervalEnv = parseSynthMinIntervalEnv;
49
44
  const fs = __importStar(require("fs"));
50
45
  const path = __importStar(require("path"));
51
46
  const db_1 = require("./db");
52
47
  const wal_valve_1 = require("./db/wal-valve");
48
+ const errors_1 = require("./errors");
53
49
  const queries_1 = require("./db/queries");
50
+ const reference_tail_1 = require("./db/reference-tail");
54
51
  const directory_1 = require("./directory");
55
- const extraction_1 = require("./extraction");
56
- const resolution_1 = require("./resolution");
57
- const callback_synthesizer_1 = require("./resolution/callback-synthesizer");
52
+ const grammars_1 = require("./extraction/grammars");
53
+ const lazy_engine_1 = require("./lazy-engine");
58
54
  const graph_1 = require("./graph");
55
+ const cobol_copybooks_1 = require("./graph/cobol-copybooks");
59
56
  const context_1 = require("./context");
60
57
  const utils_1 = require("./utils");
61
- const sync_1 = require("./sync");
58
+ const errors_2 = require("./errors");
62
59
  const extraction_version_1 = require("./extraction/extraction-version");
63
60
  const directory_2 = require("./directory");
64
61
  const query_utils_1 = require("./search/query-utils");
@@ -68,12 +65,7 @@ const version_1 = require("./mcp/version");
68
65
  const identifier_segments_1 = require("./search/identifier-segments");
69
66
  const cooperative_yield_1 = require("./resolution/cooperative-yield");
70
67
  const resolver_pool_1 = require("./resolution/resolver-pool");
71
- // Re-export types for consumers
72
68
  __exportStar(require("./types"), exports);
73
- // Storage building blocks for embedded/SDK consumers that drive the graph
74
- // directly (open a DB, run prepared queries) rather than through the CodeGraph
75
- // facade. Exposed from the package entry so they no longer require deep imports
76
- // into dist/ (issue #354).
77
69
  var db_2 = require("./db");
78
70
  Object.defineProperty(exports, "getDatabasePath", { enumerable: true, get: function () { return db_2.getDatabasePath; } });
79
71
  Object.defineProperty(exports, "DatabaseConnection", { enumerable: true, get: function () { return db_2.DatabaseConnection; } });
@@ -84,26 +76,27 @@ Object.defineProperty(exports, "getCodeGraphDir", { enumerable: true, get: funct
84
76
  Object.defineProperty(exports, "isInitialized", { enumerable: true, get: function () { return directory_3.isInitialized; } });
85
77
  Object.defineProperty(exports, "findNearestCodeGraphRoot", { enumerable: true, get: function () { return directory_3.findNearestCodeGraphRoot; } });
86
78
  Object.defineProperty(exports, "CODEGRAPH_DIR", { enumerable: true, get: function () { return directory_3.CODEGRAPH_DIR; } });
87
- var extraction_2 = require("./extraction");
88
- Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return extraction_2.detectLanguage; } });
89
- Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return extraction_2.isLanguageSupported; } });
90
- Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return extraction_2.isGrammarLoaded; } });
91
- Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return extraction_2.getSupportedLanguages; } });
92
- Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return extraction_2.initGrammars; } });
93
- Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return extraction_2.loadGrammarsForLanguages; } });
94
- Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return extraction_2.loadAllGrammars; } });
95
- var errors_1 = require("./errors");
96
- Object.defineProperty(exports, "CodeGraphError", { enumerable: true, get: function () { return errors_1.CodeGraphError; } });
97
- Object.defineProperty(exports, "FileError", { enumerable: true, get: function () { return errors_1.FileError; } });
98
- Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_1.ParseError; } });
99
- Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_1.DatabaseError; } });
100
- Object.defineProperty(exports, "SearchError", { enumerable: true, get: function () { return errors_1.SearchError; } });
101
- Object.defineProperty(exports, "VectorError", { enumerable: true, get: function () { return errors_1.VectorError; } });
102
- Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_1.ConfigError; } });
103
- Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return errors_1.setLogger; } });
104
- Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return errors_1.getLogger; } });
105
- Object.defineProperty(exports, "silentLogger", { enumerable: true, get: function () { return errors_1.silentLogger; } });
106
- Object.defineProperty(exports, "defaultLogger", { enumerable: true, get: function () { return errors_1.defaultLogger; } });
79
+ var grammars_2 = require("./extraction/grammars");
80
+ Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return grammars_2.detectLanguage; } });
81
+ Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return grammars_2.isLanguageSupported; } });
82
+ Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return grammars_2.isGrammarLoaded; } });
83
+ Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return grammars_2.getSupportedLanguages; } });
84
+ Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return grammars_2.initGrammars; } });
85
+ Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return grammars_2.loadGrammarsForLanguages; } });
86
+ Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return grammars_2.loadAllGrammars; } });
87
+ var errors_3 = require("./errors");
88
+ Object.defineProperty(exports, "CodeGraphError", { enumerable: true, get: function () { return errors_3.CodeGraphError; } });
89
+ Object.defineProperty(exports, "FileError", { enumerable: true, get: function () { return errors_3.FileError; } });
90
+ Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_3.ParseError; } });
91
+ Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_3.DatabaseError; } });
92
+ Object.defineProperty(exports, "SearchError", { enumerable: true, get: function () { return errors_3.SearchError; } });
93
+ Object.defineProperty(exports, "VectorError", { enumerable: true, get: function () { return errors_3.VectorError; } });
94
+ Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_3.ConfigError; } });
95
+ Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return errors_3.setLogger; } });
96
+ Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return errors_3.getLogger; } });
97
+ Object.defineProperty(exports, "silentLogger", { enumerable: true, get: function () { return errors_3.silentLogger; } });
98
+ Object.defineProperty(exports, "defaultLogger", { enumerable: true, get: function () { return errors_3.defaultLogger; } });
99
+ Object.defineProperty(exports, "LockUnavailableError", { enumerable: true, get: function () { return errors_3.LockUnavailableError; } });
107
100
  var utils_2 = require("./utils");
108
101
  Object.defineProperty(exports, "Mutex", { enumerable: true, get: function () { return utils_2.Mutex; } });
109
102
  Object.defineProperty(exports, "FileLock", { enumerable: true, get: function () { return utils_2.FileLock; } });
@@ -111,34 +104,48 @@ Object.defineProperty(exports, "processInBatches", { enumerable: true, get: func
111
104
  Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return utils_2.debounce; } });
112
105
  Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return utils_2.throttle; } });
113
106
  Object.defineProperty(exports, "MemoryMonitor", { enumerable: true, get: function () { return utils_2.MemoryMonitor; } });
114
- var sync_2 = require("./sync");
115
- Object.defineProperty(exports, "FileWatcher", { enumerable: true, get: function () { return sync_2.FileWatcher; } });
116
- Object.defineProperty(exports, "LockUnavailableError", { enumerable: true, get: function () { return sync_2.LockUnavailableError; } });
117
- var mcp_1 = require("./mcp");
118
- Object.defineProperty(exports, "MCPServer", { enumerable: true, get: function () { return mcp_1.MCPServer; } });
119
- /**
120
- * Main CodeGraph class
121
- *
122
- * Provides the primary interface for interacting with the code knowledge graph.
123
- */
107
+ var lazy_engine_2 = require("./lazy-engine");
108
+ Object.defineProperty(exports, "FileWatcher", { enumerable: true, get: function () { return lazy_engine_2.FileWatcher; } });
109
+ Object.defineProperty(exports, "MCPServer", { enumerable: true, get: function () { return lazy_engine_2.MCPServer; } });
110
+ const PYTHON_ROOTS_METADATA_KEY = 'python_root_fingerprint';
111
+ const PHP_WEB_ROOTS_METADATA_KEY = 'php_web_roots';
112
+ const WORKSPACE_METADATA_KEY = 'js_workspace_fingerprint';
113
+ const WORKSPACE_MANIFESTS_METADATA_KEY = 'js_workspace_manifests';
114
+ const MODULE_CONFIG_METADATA_KEY = 'module_config_snapshot';
115
+ const FRAMEWORKS_AT_INDEX_KEY = 'frameworks_at_index';
116
+ const FRAMEWORKS_SINCE_INDEX_KEY = 'frameworks_since_index';
117
+ const RESOLVER_FRAMEWORKS_AT_INDEX_KEY = 'resolver_frameworks_at_index';
118
+ function parseNameList(value) {
119
+ if (!value)
120
+ return null;
121
+ try {
122
+ const parsed = JSON.parse(value);
123
+ return Array.isArray(parsed) && parsed.every((n) => typeof n === 'string') ? parsed : null;
124
+ }
125
+ catch {
126
+ return null;
127
+ }
128
+ }
129
+ function parseSynthMinIntervalEnv(raw) {
130
+ if (!raw || !raw.trim())
131
+ return undefined;
132
+ const n = Number(raw);
133
+ if (!Number.isInteger(n) || n < 1000 || n > 86_400_000)
134
+ return undefined;
135
+ return n;
136
+ }
124
137
  class CodeGraph {
125
138
  db;
126
139
  queries;
127
140
  projectRoot;
128
- // Assigned via wireLayers() from the constructor (and again on reopen) — the
129
- // `!` tells TS these are definitely set even though the assignment is one
130
- // method call away from the constructor body.
131
- orchestrator;
132
- resolver;
133
141
  graphManager;
134
142
  traverser;
135
143
  contextBuilder;
136
- // Mutex for preventing concurrent indexing operations (in-process)
137
144
  indexMutex = new utils_1.Mutex();
138
- // File lock for preventing concurrent writes across processes (CLI, MCP, git hooks)
139
145
  fileLock;
140
- // File watcher for auto-sync on file changes
141
146
  watcher = null;
147
+ lastSynthesisAt = 0;
148
+ deferredSynthesisTimer = null;
142
149
  constructor(db, queries, projectRoot) {
143
150
  this.db = db;
144
151
  this.queries = queries;
@@ -146,71 +153,85 @@ class CodeGraph {
146
153
  this.fileLock = new utils_1.FileLock(path.join((0, directory_2.getCodeGraphDir)(projectRoot), 'codegraph.lock'));
147
154
  this.wireLayers();
148
155
  }
149
- /**
150
- * (Re)build the query/extraction/graph layers over the current `this.queries`
151
- * (which wraps `this.db`). Factored out of the constructor so `reopenIfReplaced`
152
- * can rebuild them against a fresh connection without duplicating the wiring.
153
- * The path-based `fileLock` is independent of the DB handle, so it stays put.
154
- */
155
156
  wireLayers() {
156
- // Down-weight the project name as a query term in search ranking — it names
157
- // the whole repo, not a symbol, so it has no discriminative value (#720).
158
157
  try {
159
158
  this.queries.setProjectNameTokens((0, query_utils_1.deriveProjectNameTokens)(this.projectRoot));
160
159
  }
161
160
  catch {
162
- // Best-effort: ranking still works without it.
163
161
  }
164
- // Down-weight the peripheral trees the project named in `codegraph.json`
165
- // `deprioritize` — indexed and findable, but never outranking real code
166
- // (#982). Ranking-only, so a bad pattern costs relevance, never recall.
167
- //
168
- // Read LAZILY, not once here: `wireLayers` runs from the constructor and
169
- // from `reopenIfReplaced`, so a matcher built here would freeze at whatever
170
- // the config said when the project opened. The MCP server caches one
171
- // CodeGraph per root for its whole lifetime, so editing `codegraph.json`
172
- // would appear to do nothing until the process restarted — `exclude` and
173
- // `include` do not behave that way. `loadDeprioritizePatterns` is
174
- // mtime-cached, so this costs one `stat`; the compiled matcher is memoized
175
- // on the pattern array's identity, which the cache keeps stable.
176
162
  let cachedPatterns;
177
163
  let cachedMatcher;
178
- this.queries.setDeprioritizedPathMatcher((filePath) => {
164
+ const currentMatcher = () => {
165
+ const patterns = (0, project_config_1.loadDeprioritizePatterns)(this.projectRoot);
166
+ if (patterns.length === 0)
167
+ return null;
168
+ if (patterns !== cachedPatterns) {
169
+ cachedPatterns = patterns;
170
+ cachedMatcher = (0, ignore_1.default)().add(patterns);
171
+ }
172
+ return cachedMatcher;
173
+ };
174
+ const matches = (matcher, filePath) => {
175
+ if (!matcher)
176
+ return false;
177
+ const rel = path.isAbsolute(filePath)
178
+ ? path.relative(this.projectRoot, filePath)
179
+ : filePath;
180
+ if (!rel || (0, utils_1.escapesRoot)(rel))
181
+ return false;
182
+ return matcher.ignores(rel.split(path.sep).join('/'));
183
+ };
184
+ const deprioritized = (filePath) => {
179
185
  try {
180
- const patterns = (0, project_config_1.loadDeprioritizePatterns)(this.projectRoot);
181
- if (patterns.length === 0)
182
- return false;
183
- if (patterns !== cachedPatterns) {
184
- cachedPatterns = patterns;
185
- cachedMatcher = (0, ignore_1.default)().add(patterns);
186
- }
187
- const rel = path.isAbsolute(filePath)
188
- ? path.relative(this.projectRoot, filePath)
189
- : filePath;
190
- if (!rel || rel.startsWith('..'))
191
- return false;
192
- return cachedMatcher.ignores(rel.split(path.sep).join('/'));
186
+ return matches(currentMatcher(), filePath);
193
187
  }
194
188
  catch {
195
- // Ranking must never take the search down with it.
196
189
  return false;
197
190
  }
198
- });
199
- this.orchestrator = new extraction_1.ExtractionOrchestrator(this.projectRoot, this.queries);
200
- this.resolver = (0, resolution_1.createResolver)(this.projectRoot, this.queries);
191
+ };
192
+ deprioritized.snapshot = () => {
193
+ let matcher = null;
194
+ try {
195
+ matcher = currentMatcher();
196
+ }
197
+ catch {
198
+ matcher = null;
199
+ }
200
+ return (filePath) => {
201
+ try {
202
+ return matches(matcher, filePath);
203
+ }
204
+ catch {
205
+ return false;
206
+ }
207
+ };
208
+ };
209
+ this.queries.setDeprioritizedPathMatcher(deprioritized);
210
+ this.builtOrchestrator = null;
211
+ this.builtResolver = null;
212
+ if (!this.db.readOnly) {
213
+ void this.orchestrator;
214
+ void this.resolver;
215
+ }
201
216
  this.graphManager = new graph_1.GraphQueryManager(this.queries);
202
217
  this.traverser = new graph_1.GraphTraverser(this.queries);
203
218
  this.contextBuilder = (0, context_1.createContextBuilder)(this.projectRoot, this.queries, this.traverser);
204
219
  }
205
- /**
206
- * Set when this instance followed a database replaced on disk (#1902): the
207
- * next sync that can run reconciles the whole tree, because whatever the old
208
- * handle absorbed since the rebuild never reached the new file.
209
- */
220
+ builtOrchestrator = null;
221
+ builtResolver = null;
222
+ get orchestrator() {
223
+ if (!this.builtOrchestrator) {
224
+ this.builtOrchestrator = new ((0, lazy_engine_1.engine)().ExtractionOrchestrator)(this.projectRoot, this.queries);
225
+ if (this.watcher)
226
+ this.builtOrchestrator.setKeepDetectionContents(true);
227
+ }
228
+ return this.builtOrchestrator;
229
+ }
230
+ get resolver() {
231
+ return (this.builtResolver ??= (0, lazy_engine_1.engine)().createResolver(this.projectRoot, this.queries));
232
+ }
210
233
  pendingFullReconcile = false;
211
- /** How long a recreated, not-yet-indexed database is treated as a rebuild in progress. */
212
234
  static RECREATE_GRACE_MS = 120_000;
213
- /** The database file at the path was written within the recreate grace window. */
214
235
  isFreshlyRecreated() {
215
236
  try {
216
237
  return Date.now() - fs.statSync((0, db_1.getDatabasePath)(this.projectRoot)).mtimeMs < CodeGraph.RECREATE_GRACE_MS;
@@ -219,128 +240,75 @@ class CodeGraph {
219
240
  return false;
220
241
  }
221
242
  }
222
- /**
223
- * Heal a stale database handle in place. If `.codegraph/` was removed and
224
- * recreated at the SAME path while this instance held the DB open — a git
225
- * worktree removed and re-added, or `rm -rf .codegraph` + `codegraph init` —
226
- * our open fd points at the now-unlinked inode and can never see the new
227
- * index, so every query returns the pre-removal snapshot until the process
228
- * restarts (#925). When that's detected, open the live file at the same path,
229
- * rebuild the query layers, and swap them IN PLACE, so every holder of this
230
- * instance (the MCP daemon's default project, cached projectPath connections)
231
- * heals without a restart. Returns true iff it reopened.
232
- *
233
- * POSIX-only in practice: `isReplacedOnDisk` never fires on Windows (an open
234
- * file can't be unlinked there, and st_ino is unreliable).
235
- *
236
- * Refuses (returns false) while an index/sync holds the index mutex: closing
237
- * the handle that run is writing through would break it mid-flight. `sync()`
238
- * performs the same check itself once it holds the mutex (#1902), so the
239
- * replaced file is still picked up — by that sync, or by the caller's retry.
240
- */
241
243
  reopenIfReplaced() {
242
244
  if (this.indexMutex.isLocked())
243
245
  return false;
244
246
  return this.reopenReplacedDatabase();
245
247
  }
246
- /** The body of {@link reopenIfReplaced}, without the in-flight-sync guard. */
247
248
  reopenReplacedDatabase() {
248
249
  if (!this.db.isReplacedOnDisk())
249
250
  return false;
250
251
  const dbPath = this.db.getPath();
251
- // Open the live file FIRST — if that throws (e.g. mid-recreate), the old
252
- // handle stays in place and the caller retries on the next query, rather
253
- // than leaving this instance with no connection at all.
254
252
  const fresh = db_1.DatabaseConnection.open(dbPath, { readOnly: this.db.readOnly });
255
253
  const stale = this.db;
256
254
  this.db = fresh;
257
255
  this.queries = new queries_1.QueryBuilder(fresh.getDb());
258
256
  this.wireLayers();
259
- // Whoever reopened — a sync, or a tool call's self-heal — the next sync
260
- // must reconcile the whole tree (#1902).
261
257
  this.pendingFullReconcile = true;
262
- // Releasing the dead handle also frees the leaked db/-wal/-shm fds that were
263
- // pinning the unlinked inode (#925).
264
258
  try {
265
259
  stale.close();
266
260
  }
267
- catch { /* the old inode is gone; closing just frees fds */ }
261
+ catch { }
268
262
  return true;
269
263
  }
270
- // ===========================================================================
271
- // Lifecycle Methods
272
- // ===========================================================================
273
- /**
274
- * Initialize a new CodeGraph project
275
- *
276
- * Creates the .CodeGraph directory, database, and configuration.
277
- *
278
- * @param projectRoot - Path to the project root directory
279
- * @param options - Initialization options
280
- * @returns A new CodeGraph instance
281
- */
282
264
  static async init(projectRoot, options = {}) {
283
- await (0, extraction_1.initGrammars)();
265
+ await (0, grammars_1.initGrammars)();
284
266
  const resolvedRoot = path.resolve(projectRoot);
285
- // Check if already initialized
286
267
  if ((0, directory_1.isInitialized)(resolvedRoot)) {
287
268
  throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
288
269
  }
289
- // Create directory structure
290
270
  (0, directory_1.createDirectory)(resolvedRoot);
291
- // Initialize database
292
271
  const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
293
272
  const db = db_1.DatabaseConnection.initialize(dbPath);
294
273
  const queries = new queries_1.QueryBuilder(db.getDb());
295
274
  const instance = new CodeGraph(db, queries, resolvedRoot);
296
- // Run initial indexing if requested
297
275
  if (options.index) {
298
276
  await instance.indexAll({ onProgress: options.onProgress });
299
277
  }
300
278
  return instance;
301
279
  }
302
- /**
303
- * Initialize synchronously (without indexing)
304
- */
305
280
  static initSync(projectRoot) {
306
281
  const resolvedRoot = path.resolve(projectRoot);
307
- // Check if already initialized
308
282
  if ((0, directory_1.isInitialized)(resolvedRoot)) {
309
283
  throw new Error(`CodeGraph already initialized in ${resolvedRoot}`);
310
284
  }
311
- // Create directory structure
312
285
  (0, directory_1.createDirectory)(resolvedRoot);
313
- // Initialize database
314
286
  const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
315
287
  const db = db_1.DatabaseConnection.initialize(dbPath);
316
288
  const queries = new queries_1.QueryBuilder(db.getDb());
317
289
  return new CodeGraph(db, queries, resolvedRoot);
318
290
  }
319
- /**
320
- * Open an existing CodeGraph project
321
- *
322
- * @param projectRoot - Path to the project root directory
323
- * @param options - Open options
324
- * @returns A CodeGraph instance
325
- */
326
291
  static async open(projectRoot, options = {}) {
327
- await (0, extraction_1.initGrammars)();
292
+ await (0, grammars_1.initGrammars)();
328
293
  const resolvedRoot = path.resolve(projectRoot);
329
- // Check if initialized
330
294
  if (!(0, directory_1.isInitialized)(resolvedRoot)) {
331
295
  throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
332
296
  }
333
- // Validate directory structure
334
297
  const validation = (0, directory_1.validateDirectory)(resolvedRoot);
335
298
  if (!validation.valid) {
336
299
  throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
337
300
  }
338
- // Open database
339
301
  const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
340
- const db = db_1.DatabaseConnection.open(dbPath, { readOnly: options.readOnly });
302
+ const db = db_1.DatabaseConnection.open(dbPath, { readOnly: options.readOnly, deferIndexRecovery: true });
303
+ try {
304
+ await db.recoverIndexesOffThread();
305
+ }
306
+ catch (err) {
307
+ db.close();
308
+ throw err;
309
+ }
341
310
  const queries = new queries_1.QueryBuilder(db.getDb());
342
311
  const instance = new CodeGraph(db, queries, resolvedRoot);
343
- // Sync if requested
344
312
  if (options.sync && !options.readOnly) {
345
313
  try {
346
314
  await instance.sync();
@@ -352,27 +320,9 @@ class CodeGraph {
352
320
  }
353
321
  return instance;
354
322
  }
355
- /**
356
- * Rebuild the project's database from scratch and return a fresh, empty
357
- * instance — the "same result as a fresh init" semantics that `codegraph
358
- * index` documents.
359
- *
360
- * Unlike `open()` followed by `clear()`, this DISCARDS the existing
361
- * `.codegraph/codegraph.db` (and its `-wal`/`-shm` sidecars) before
362
- * re-initializing, instead of opening the old database and DELETE-ing every
363
- * row. On a large or pre-fix poisoned index — e.g. an old graph that scanned
364
- * an ignored gitlink corpus (#1065) into ~1.6M nodes with a multi-GB WAL —
365
- * the per-row `nodes_fts` delete-trigger churn blocks the main thread long
366
- * enough to trip the #850 liveness watchdog before indexing even starts, so a
367
- * full re-index could never recover the bad state (#1067). Discarding the
368
- * files is O(1) regardless of size, reclaims the disk, and sidesteps opening
369
- * (and running migrations against) the poisoned database entirely.
370
- */
371
323
  static async recreate(projectRoot) {
372
- await (0, extraction_1.initGrammars)();
324
+ await (0, grammars_1.initGrammars)();
373
325
  const resolvedRoot = path.resolve(projectRoot);
374
- // Check if initialized — recreate REBUILDS an existing project; it is not a
375
- // first-time `init`.
376
326
  if (!(0, directory_1.isInitialized)(resolvedRoot)) {
377
327
  throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
378
328
  }
@@ -381,91 +331,62 @@ class CodeGraph {
381
331
  (0, db_1.removeDatabaseFiles)(dbPath);
382
332
  }
383
333
  catch (err) {
384
- // POSIX unlinks an open file fine; this fires mainly on Windows when a
385
- // live daemon/MCP server still holds the database. Turn the raw EBUSY into
386
- // an actionable instruction instead of a generic failure.
387
334
  const reason = err instanceof Error ? err.message : String(err);
388
335
  throw new Error(`Could not rebuild the index — the database file is in use (${reason}). ` +
389
336
  `Stop any running CodeGraph MCP server/daemon for this project and retry, ` +
390
337
  `or remove the ${(0, directory_2.getCodeGraphDir)(resolvedRoot)} directory and run "codegraph init".`);
391
338
  }
392
- // Re-create an empty, freshly-schema'd database at the same path.
393
339
  const db = db_1.DatabaseConnection.initialize(dbPath);
394
340
  const queries = new queries_1.QueryBuilder(db.getDb());
395
341
  return new CodeGraph(db, queries, resolvedRoot);
396
342
  }
397
- /**
398
- * Open synchronously (without sync)
399
- */
400
343
  static openSync(projectRoot, options = {}) {
401
344
  const resolvedRoot = path.resolve(projectRoot);
402
- // Check if initialized
403
345
  if (!(0, directory_1.isInitialized)(resolvedRoot)) {
404
346
  throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
405
347
  }
406
- // Validate directory structure
407
348
  const validation = (0, directory_1.validateDirectory)(resolvedRoot);
408
349
  if (!validation.valid) {
409
350
  throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
410
351
  }
411
- // Open database
412
352
  const dbPath = (0, db_1.getDatabasePath)(resolvedRoot);
413
- const db = db_1.DatabaseConnection.open(dbPath, { readOnly: options.readOnly });
353
+ const db = db_1.DatabaseConnection.open(dbPath, { readOnly: options.readOnly, deferIndexRecovery: options.deferIndexRecovery });
414
354
  const queries = new queries_1.QueryBuilder(db.getDb());
415
355
  return new CodeGraph(db, queries, resolvedRoot);
416
356
  }
417
- /**
418
- * Check if a directory has been initialized as a CodeGraph project
419
- */
357
+ recoverIndexes() {
358
+ return this.db.recoverIndexesOffThread();
359
+ }
360
+ hasPendingIndexRecovery() {
361
+ return this.db.hasDeferredIndexRecovery();
362
+ }
420
363
  static isInitialized(projectRoot) {
421
364
  return (0, directory_1.isInitialized)(path.resolve(projectRoot));
422
365
  }
423
- /**
424
- * Close the CodeGraph instance and release resources
425
- */
366
+ releaseMemory() {
367
+ this.db.releaseMemory();
368
+ }
426
369
  close() {
427
370
  this.unwatch();
428
- // Release file lock if held
371
+ if (this.deferredSynthesisTimer) {
372
+ clearTimeout(this.deferredSynthesisTimer);
373
+ this.deferredSynthesisTimer = null;
374
+ }
429
375
  this.fileLock.release();
430
376
  this.db.close();
431
377
  }
432
- /**
433
- * Get the project root directory
434
- */
435
378
  getProjectRoot() {
436
379
  return this.projectRoot;
437
380
  }
438
- // ===========================================================================
439
- // Indexing
440
- // ===========================================================================
441
- /**
442
- * Index all files in the project
443
- *
444
- * Uses a mutex to prevent concurrent indexing operations.
445
- */
446
381
  async indexAll(options = {}) {
447
382
  return this.indexMutex.withLock(async () => {
383
+ const startedAt = Date.now();
448
384
  try {
449
385
  this.fileLock.acquire();
450
386
  }
451
387
  catch {
452
388
  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 };
453
389
  }
454
- // Defer WAL auto-checkpointing for the whole bulk run (#1231): the
455
- // default 1000-page interval re-writes hot pages into the main DB file
456
- // over and over — ~95% of all disk I/O during a bulk index, and a
457
- // 19+min → 45s difference on HDD-class storage. The valve bounds WAL
458
- // growth by backfilling PASSIVEly on a worker thread (never blocking
459
- // the writer or the #850 watchdog heartbeat); runMaintenance below does
460
- // the final fold-up before the interval is restored in the finally.
461
- // Kill switch: CODEGRAPH_NO_WAL_DEFER=1. Non-WAL journal modes (some
462
- // network filesystems) have no WAL to defer — skip.
463
- // Fast-init: on a COMPLETELY fresh DB, trade crash-durability for speed
464
- // during the bulk build (journal in memory, no fsync). Safe because the
465
- // DB is disposable until the index completes — index_state stays
466
- // 'indexing' and a crashed init is re-run from scratch; existing DBs
467
- // (re-index/sync) never take this path. Kill switch:
468
- // CODEGRAPH_NO_FAST_INIT=1 (same pattern as CODEGRAPH_NO_WAL_DEFER).
469
390
  const freshDb = this.queries.getNodeAndEdgeCount().nodes === 0;
470
391
  const fastInit = process.env.CODEGRAPH_NO_FAST_INIT !== '1' && freshDb;
471
392
  if (fastInit) {
@@ -473,13 +394,11 @@ class CodeGraph {
473
394
  this.db.getDb().pragma('journal_mode = MEMORY');
474
395
  this.db.getDb().pragma('synchronous = OFF');
475
396
  }
476
- catch { /* keep WAL */ }
397
+ catch { }
477
398
  }
478
399
  const deferWal = !fastInit && process.env.CODEGRAPH_NO_WAL_DEFER !== '1' && this.db.getJournalMode() === 'wal';
479
400
  let walValve = null;
480
401
  let priorAutocheckpoint = 1000;
481
- // Set when the fastInit+pool path below defers autocheckpointing, so the
482
- // finally knows to restore the interval on that path too.
483
402
  let restoreAutocheckpoint = false;
484
403
  if (deferWal) {
485
404
  priorAutocheckpoint = this.db.getWalAutocheckpoint();
@@ -490,38 +409,22 @@ class CodeGraph {
490
409
  try {
491
410
  const gitState = this.orchestrator.beginGitIndexState(true);
492
411
  const before = this.queries.getNodeAndEdgeCount();
493
- // Mark the index as in-flight BEFORE any writes: a run killed
494
- // mid-index (OOM, SIGKILL, the #850 liveness watchdog) leaves this
495
- // marker behind, so `codegraph status` can tell a truncated index
496
- // from a completed one instead of silently serving partial results.
497
412
  try {
498
413
  this.queries.setMetadata('index_state', 'indexing');
499
414
  }
500
- catch { /* metadata is advisory */ }
501
- // Segment vocabulary starts empty and is repopulated by the node write
502
- // path as every file (re-)indexes below — so a full index is also the
503
- // orphan-cleanup pass for names deleted since the last one.
504
- try {
505
- this.queries.clearNameSegmentVocab();
415
+ catch { }
416
+ if (freshDb) {
417
+ try {
418
+ this.queries.clearNameSegmentVocab();
419
+ }
420
+ catch { }
506
421
  }
507
- catch { /* vocab is advisory — never fail an index over it */ }
508
- // Bulk FTS mode for the mass-insert phase: drop the per-row FTS sync
509
- // triggers, rebuild nodes_fts once from the nodes table afterwards.
510
- // Crash inside the window is healed on the next DatabaseConnection.open.
511
422
  this.db.beginBulkNodeLoad();
512
- // Fresh-init only: also drop the parse-lane secondary indexes for the
513
- // mass insert (the store-writer's B-tree-maintenance floor, plan §4d)
514
- // and rebuild each in one scan afterwards. Incremental runs keep them
515
- // — they delete per-file rows mid-phase through the file_path indexes.
516
423
  if (freshDb)
517
424
  this.db.beginBulkParseLoad();
518
425
  let result;
519
426
  try {
520
- result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose, walValve ? () => walValve.backpressure() : undefined,
521
- // Store-writer offload is fresh-DB-only: with any pre-existing
522
- // data the store path must read (existing-file checks, cross-file
523
- // edge snapshots) and delete, which belongs on one thread.
524
- freshDb ? { dbPath: this.db.getPath(), fastInit } : null);
427
+ result = await this.orchestrator.indexAll(options.onProgress, options.signal, options.verbose, walValve ? () => walValve.backpressure() : undefined, freshDb ? { dbPath: this.db.getPath(), fastInit } : null);
525
428
  }
526
429
  finally {
527
430
  if (freshDb) {
@@ -535,58 +438,28 @@ class CodeGraph {
535
438
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
536
439
  console.error(`[phase-timing] fts-rebuild: ${Date.now() - tFts}ms`);
537
440
  }
538
- // Fold the parse phase's WAL BEFORE the first post-parse reads
539
- // (resolver re-init and resolution both read on the main thread):
540
- // paging a bulk-write-sized WAL there is what blew the #850
541
- // watchdog's 60s window in the #1231 repro. Off-thread + awaited,
542
- // so the event loop keeps turning.
543
441
  if (walValve)
544
442
  await walValve.foldNow();
545
- // Re-detect frameworks now that the index is populated. The resolver
546
- // is constructed with createResolver() before any files exist, so
547
- // framework resolvers whose detect() consults the indexed file list
548
- // (e.g. UIKit/SwiftUI scanning for imports, swift-objc-bridge looking
549
- // for both Swift and ObjC files) all return false on that initial pass
550
- // and silently drop themselves. Re-initializing here gives them a
551
- // chance to see the actual project before resolution runs.
552
443
  if (result.success && result.filesIndexed > 0) {
553
444
  const tReinit = Date.now();
554
445
  this.resolver.initialize();
555
- // Cross-file finalization (e.g. NestJS RouterModule prefixes). Runs
556
- // before resolution so updated names show up in subsequent reads.
557
446
  this.resolver.runPostExtract();
558
447
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
559
448
  console.error(`[phase-timing] resolver-reinit: ${Date.now() - tReinit}ms`);
560
449
  }
561
- // Resolve references to create call/import/extends edges
562
450
  if (result.success && result.filesIndexed > 0) {
563
- // Get count without loading all refs into memory
564
451
  const unresolvedCount = this.queries.getUnresolvedReferencesCount();
565
- // Fast-init leaves the DB in memory-journal (rollback) mode, where
566
- // the parallel resolver pool's read connections would contend with
567
- // the main writer's exclusive commits. When the pool will actually
568
- // run (enough pending refs), restore WAL BEFORE resolution so
569
- // readers never block the writer; otherwise stay in the fast mode
570
- // until the finally — sequential resolution has no readers.
571
452
  if (fastInit && unresolvedCount >= (0, resolver_pool_1.minRefsForPool)()) {
572
453
  try {
573
454
  this.db.getDb().pragma('synchronous = NORMAL');
574
455
  this.db.getDb().pragma('journal_mode = WAL');
575
- // Defer auto-checkpointing for the resolution phase, same
576
- // rationale as the deferWal path above: at the default 1000-page
577
- // interval, the persist loop's edge inserts + ref deletes make
578
- // SQLite re-write hot B-tree pages into the main DB file inline
579
- // on the writer over and over (#1231's pathology — measured as
580
- // ~58% of the resolution phase on a 255k-ref repo). The valve
581
- // bounds WAL growth off-thread; runMaintenance does the final
582
- // fold and the finally restores the interval.
583
456
  priorAutocheckpoint = this.db.getWalAutocheckpoint();
584
457
  this.db.setWalAutocheckpoint(0);
585
458
  restoreAutocheckpoint = true;
586
459
  walValve = new wal_valve_1.WalCheckpointValve(this.db, undefined, undefined, options.verbose ? (m) => console.log(`[wal-valve] ${m}`) : undefined);
587
460
  walValve.start();
588
461
  }
589
- catch { /* keep current mode; resolution still works sequentially */ }
462
+ catch { }
590
463
  }
591
464
  options.onProgress?.({
592
465
  phase: 'resolving',
@@ -606,33 +479,31 @@ class CodeGraph {
606
479
  current: done,
607
480
  total: totalPasses,
608
481
  });
609
- }, walValve ? () => walValve.backpressure() : undefined);
482
+ }, walValve ? () => walValve.backpressure() : undefined, true, true);
610
483
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
611
484
  console.error(`[phase-timing] resolution: ${Date.now() - tResolve}ms`);
612
- // Second pass: chained calls whose method lives on a supertype the
613
- // receiver conforms to (protocol-extension / inherited / default-
614
- // interface). Needs the implements/extends edges the main pass just
615
- // built, so it runs after resolution (#750).
485
+ this.lastSynthesisAt = Date.now();
616
486
  const tChained = Date.now();
617
487
  await this.resolver.resolveChainedCallsViaConformance();
618
488
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
619
489
  console.error(`[synth-timing] chainedConformance: ${Date.now() - tChained}ms`);
620
- // Same lifecycle for `this.<member>` callback registrations whose
621
- // member is inherited from a supertype (#808).
622
490
  const tDeferred = Date.now();
623
491
  await this.resolver.resolveDeferredThisMemberRefs();
624
492
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
625
493
  console.error(`[synth-timing] deferredThisMember: ${Date.now() - tDeferred}ms`);
494
+ await this.resolver.resolveParameterFlows();
495
+ }
496
+ if (!freshDb && result.success && !options.signal?.aborted) {
497
+ const tPrune = Date.now();
498
+ try {
499
+ this.queries.pruneNameSegmentVocab();
500
+ }
501
+ catch { }
502
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
503
+ console.error(`[phase-timing] vocab-prune: ${Date.now() - tPrune}ms`);
626
504
  }
627
- // Refresh planner stats + checkpoint the WAL after bulk writes.
628
- // Off-thread (worker connection): on a multi-GB index this is minutes
629
- // of IO, and inline it starved the #850 watchdog AFTER a fully
630
- // successful index. Never load-bearing for correctness.
631
505
  if (result.success && result.filesIndexed > 0) {
632
506
  const tMaint = Date.now();
633
- // Quiesce the valve first so its in-flight checkpoint and the
634
- // maintenance checkpoint don't contend for the checkpointer lock
635
- // (the loser would silently no-op and leave the WAL unfolded).
636
507
  if (walValve) {
637
508
  walValve.stop();
638
509
  await walValve.drain();
@@ -641,9 +512,6 @@ class CodeGraph {
641
512
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
642
513
  console.error(`[phase-timing] maintenance: ${Date.now() - tMaint}ms`);
643
514
  }
644
- // The orchestrator only sees extraction-phase counts; resolution and
645
- // synthesizer edges (often >50% of the graph on JVM repos) come later.
646
- // Recompute against the DB so the CLI summary reports the true totals.
647
515
  if (result.success && result.filesIndexed > 0) {
648
516
  const tCount = Date.now();
649
517
  const after = this.queries.getNodeAndEdgeCount();
@@ -652,27 +520,29 @@ class CodeGraph {
652
520
  result.nodesCreated = after.nodes - before.nodes;
653
521
  result.edgesCreated = after.edges - before.edges;
654
522
  }
655
- // Stamp the index with the engine that built it, so `codegraph status`
656
- // and `codegraph upgrade` can recommend a re-index when the running
657
- // engine produces richer extraction than the one on disk. Only on a
658
- // real full index — a sync touches a subset, so it must NOT advance the
659
- // extraction stamp (the bulk would still be stale). See extraction-version.ts.
523
+ if (result.success)
524
+ this.stampPythonRootFingerprint();
525
+ if (result.success)
526
+ this.stampPhpWebRoots();
527
+ if (result.success)
528
+ this.stampWorkspaceFingerprint();
529
+ if (result.success)
530
+ this.stampWorkspaceManifests(this.orchestrator.takeManifestEvidence());
531
+ if (result.success)
532
+ this.stampModuleConfigSnapshot();
533
+ if (result.success)
534
+ this.stampIndexedFrameworks();
660
535
  if (result.success && result.filesIndexed > 0) {
661
536
  try {
662
537
  this.queries.setMetadata('indexed_with_version', version_1.CodeGraphPackageVersion);
663
538
  this.queries.setMetadata('indexed_with_extraction_version', String(extraction_version_1.EXTRACTION_VERSION));
664
539
  }
665
- catch { /* metadata is advisory — never fail an index over it */ }
540
+ catch { }
666
541
  }
667
542
  if (result.success && result.filesErrored === 0 &&
668
543
  (result.filesDiscovered === undefined || result.filesIndexed + result.filesSkipped >= result.filesDiscovered)) {
669
544
  this.orchestrator.finishGitIndexState(gitState, true);
670
545
  }
671
- // Reconcile the scan's ground truth against what the pipeline
672
- // accounted for. A shortfall means files were silently dropped
673
- // (observed in the wild: a run under heavy load came up 37 files
674
- // short with no error) — record it and tell the user, don't let the
675
- // index pass as complete.
676
546
  try {
677
547
  if (!result.success) {
678
548
  this.queries.setMetadata('index_state', 'failed');
@@ -700,15 +570,11 @@ class CodeGraph {
700
570
  }
701
571
  }
702
572
  }
703
- catch { /* metadata is advisory — never fail an index over it */ }
573
+ catch { }
574
+ result.durationMs = Date.now() - startedAt;
704
575
  return result;
705
576
  }
706
577
  finally {
707
- // Restore the auto-checkpoint interval AFTER the fold-up above so the
708
- // next ordinary write doesn't inherit a giant inline checkpoint. On
709
- // the error path the WAL may still be large; correctness is unchanged
710
- // (SQLite replays the WAL on the next open) and the follow-up write
711
- // that folds it is the known cost of a failed run.
712
578
  if (walValve) {
713
579
  walValve.stop();
714
580
  await walValve.drain();
@@ -717,26 +583,19 @@ class CodeGraph {
717
583
  try {
718
584
  this.db.setWalAutocheckpoint(priorAutocheckpoint);
719
585
  }
720
- catch { /* connection may be closing */ }
586
+ catch { }
721
587
  }
722
588
  if (fastInit) {
723
- // Back to the durable defaults; journal_mode=WAL folds the MEMORY
724
- // journal state into a normal WAL-mode database file.
725
589
  try {
726
590
  this.db.getDb().pragma('synchronous = NORMAL');
727
591
  this.db.getDb().pragma('journal_mode = WAL');
728
592
  }
729
- catch { /* connection may be closing */ }
593
+ catch { }
730
594
  }
731
595
  this.fileLock.release();
732
596
  }
733
597
  });
734
598
  }
735
- /**
736
- * Index specific files
737
- *
738
- * Uses a mutex to prevent concurrent indexing operations.
739
- */
740
599
  async indexFiles(filePaths) {
741
600
  return this.indexMutex.withLock(async () => {
742
601
  try {
@@ -746,70 +605,143 @@ class CodeGraph {
746
605
  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 };
747
606
  }
748
607
  try {
749
- return this.orchestrator.indexFiles(filePaths);
608
+ return await this.orchestrator.indexFiles(filePaths).finally(() => this.resolver.clearCaches());
750
609
  }
751
610
  finally {
752
611
  this.fileLock.release();
753
612
  }
754
613
  });
755
614
  }
756
- /**
757
- * Sync with current file state (incremental update).
758
- * Throws LockUnavailableError if the cross-process write lock is unavailable.
759
- *
760
- * Uses a mutex to prevent concurrent indexing operations.
761
- */
615
+ pythonFilePaths() {
616
+ return new Set(this.queries.getAllFilePaths().filter((f) => f.endsWith('.py')));
617
+ }
618
+ stampPythonRootFingerprint(fingerprint = this.resolver.getPythonRootFingerprint()) {
619
+ try {
620
+ this.queries.setMetadata(PYTHON_ROOTS_METADATA_KEY, fingerprint);
621
+ }
622
+ catch { }
623
+ }
624
+ stampPhpWebRoots(snapshot = this.resolver.getPhpWebRootSnapshot()) {
625
+ try {
626
+ this.queries.setMetadata(PHP_WEB_ROOTS_METADATA_KEY, snapshot);
627
+ }
628
+ catch { }
629
+ }
630
+ stampModuleConfigSnapshot() {
631
+ try {
632
+ const stored = this.queries.getMetadata(MODULE_CONFIG_METADATA_KEY);
633
+ this.queries.setMetadata(MODULE_CONFIG_METADATA_KEY, JSON.stringify(this.resolver.getModuleConfigSnapshot(stored, true)));
634
+ }
635
+ catch { }
636
+ }
637
+ stampModuleConfigSnapshotIfMoved() {
638
+ try {
639
+ const stored = this.queries.getMetadata(MODULE_CONFIG_METADATA_KEY);
640
+ const now = JSON.stringify(this.resolver.getModuleConfigSnapshot(stored));
641
+ if (now !== stored)
642
+ this.queries.setMetadata(MODULE_CONFIG_METADATA_KEY, now);
643
+ }
644
+ catch { }
645
+ }
646
+ stampWorkspaceFingerprint(fingerprint = this.resolver.getWorkspaceFingerprint()) {
647
+ try {
648
+ this.queries.setMetadata(WORKSPACE_METADATA_KEY, fingerprint);
649
+ }
650
+ catch { }
651
+ }
652
+ stampWorkspaceManifests(evidence) {
653
+ try {
654
+ const discovery = this.resolver.getWorkspaceDiscovery();
655
+ const stamp = discovery ? (0, lazy_engine_1.engine)().manifestStamp(evidence, discovery) : null;
656
+ const value = stamp ? JSON.stringify(stamp) : '';
657
+ if (this.queries.getMetadata(WORKSPACE_MANIFESTS_METADATA_KEY) !== value)
658
+ this.queries.setMetadata(WORKSPACE_MANIFESTS_METADATA_KEY, value);
659
+ }
660
+ catch { }
661
+ }
662
+ stampIndexedFrameworks() {
663
+ const names = this.orchestrator.getDetectedFrameworkNames();
664
+ if (names === null)
665
+ return;
666
+ try {
667
+ this.queries.setMetadata(FRAMEWORKS_AT_INDEX_KEY, JSON.stringify([...names].sort()));
668
+ this.queries.setMetadata(FRAMEWORKS_SINCE_INDEX_KEY, '');
669
+ this.queries.setMetadata(RESOLVER_FRAMEWORKS_AT_INDEX_KEY, JSON.stringify([...this.resolver.getDetectedFrameworks()].sort()));
670
+ }
671
+ catch { }
672
+ }
673
+ followDetectedFrameworks(detected) {
674
+ const now = [...detected].sort();
675
+ const resolverNow = [...this.resolver.getDetectedFrameworks()].sort();
676
+ if (now.join('\0') !== resolverNow.join('\0'))
677
+ this.resolver.initialize();
678
+ try {
679
+ const atIndex = parseNameList(this.queries.getMetadata(FRAMEWORKS_AT_INDEX_KEY));
680
+ if (!atIndex)
681
+ return;
682
+ const added = now.filter((name) => !atIndex.includes(name));
683
+ const removed = atIndex.filter((name) => !now.includes(name));
684
+ const value = added.length > 0 || removed.length > 0 ? JSON.stringify({ added, removed }) : '';
685
+ if ((this.queries.getMetadata(FRAMEWORKS_SINCE_INDEX_KEY) ?? '') !== value) {
686
+ this.queries.setMetadata(FRAMEWORKS_SINCE_INDEX_KEY, value);
687
+ }
688
+ }
689
+ catch { }
690
+ }
691
+ getFrameworkChangesSinceIndex() {
692
+ const names = (list) => (Array.isArray(list) ? list.filter((n) => typeof n === 'string') : []);
693
+ const added = new Set();
694
+ const removed = new Set();
695
+ try {
696
+ const value = this.queries.getMetadata(FRAMEWORKS_SINCE_INDEX_KEY);
697
+ if (value) {
698
+ const parsed = JSON.parse(value);
699
+ for (const name of names(parsed.added))
700
+ added.add(name);
701
+ for (const name of names(parsed.removed))
702
+ removed.add(name);
703
+ }
704
+ }
705
+ catch { }
706
+ try {
707
+ const atIndex = parseNameList(this.queries.getMetadata(RESOLVER_FRAMEWORKS_AT_INDEX_KEY));
708
+ if (atIndex) {
709
+ const now = this.resolver.getDetectedFrameworks();
710
+ for (const name of now)
711
+ if (!atIndex.includes(name))
712
+ added.add(name);
713
+ for (const name of atIndex)
714
+ if (!now.includes(name))
715
+ removed.add(name);
716
+ }
717
+ }
718
+ catch { }
719
+ return added.size > 0 || removed.size > 0 ? { added: [...added].sort(), removed: [...removed].sort() } : null;
720
+ }
762
721
  async sync(options = {}) {
722
+ const { ESM_IMPORT_LANGUAGES, aliasMayName, changedModuleConfigs, changedRoutes, createImportReader, hasSynthesisPattern, isJsxChildCandidate, moduleConfigLanguages, parseManifestStamp, parseModuleConfigSnapshot, reopenNameMatchedImports, reopenReferencesThroughAddedFiles, reopenReferencesThroughBarrels, reopenReferencesThroughChangedDefaults, reopenReferencesThroughDeclaredPackages, reopenReferencesThroughObjectMembers, reopenReferencesThroughRetargetedModules, trustedManifestList, } = (0, lazy_engine_1.engine)();
763
723
  return this.indexMutex.withLock(async () => {
724
+ const startedAt = Date.now();
764
725
  try {
765
726
  this.fileLock.acquire();
766
727
  }
767
728
  catch (err) {
768
- throw new sync_1.LockUnavailableError(`Sync could not acquire the file lock; retry when the index is available. ${err instanceof Error ? err.message : String(err)}`);
729
+ throw new errors_2.LockUnavailableError(`Sync could not acquire the file lock; retry when the index is available. ${err instanceof Error ? err.message : String(err)}`);
769
730
  }
770
- // A full rebuild in another process (`codegraph index` → recreate)
771
- // unlinks the database and creates a new file at the same path. A
772
- // long-lived instance — the MCP daemon's watcher — would otherwise keep
773
- // "syncing" into the dead inode, and nothing it wrote there is visible
774
- // to anyone (#1902). Follow the path before writing (one stat), and
775
- // widen a scoped sync to a full one: whatever the old handle absorbed
776
- // since the rebuild is gone, so the new file has to be reconciled whole.
777
- // If the reopen fails (the rebuild is mid-way), report lock contention
778
- // so the watcher keeps its pending files and retries.
779
731
  try {
780
732
  this.reopenReplacedDatabase();
781
733
  }
782
734
  catch (err) {
783
735
  this.fileLock.release();
784
- throw new sync_1.LockUnavailableError(`Sync could not open the rebuilt index yet; retry when the rebuild finishes. ${err instanceof Error ? err.message : String(err)}`);
736
+ throw new errors_2.LockUnavailableError(`Sync could not open the rebuilt index yet; retry when the rebuild finishes. ${err instanceof Error ? err.message : String(err)}`);
785
737
  }
786
738
  if (this.pendingFullReconcile) {
787
- // `codegraph index` recreates the file, THEN takes the write lock in
788
- // indexAll. A sync landing in that gap would otherwise run a full
789
- // reconcile of the empty file and hold the lock the rebuild is about
790
- // to ask for. A fresh file with no index_state yet is that rebuild:
791
- // step aside (lock contention, the watcher retries) and reconcile in
792
- // full once it is done. Bounded, so a rebuild that died before
793
- // indexing does not park the watcher forever.
794
739
  if (this.getIndexState() === null && this.isFreshlyRecreated()) {
795
740
  this.fileLock.release();
796
- throw new sync_1.LockUnavailableError('A rebuild of this index is in progress; retry when it finishes.');
741
+ throw new errors_2.LockUnavailableError('A rebuild of this index is in progress; retry when it finishes.');
797
742
  }
798
- // Cleared only once this run completes (below): a sync that throws
799
- // must leave the full catch-up for the next one.
800
743
  options = { ...options, paths: undefined };
801
744
  }
802
- // Defer WAL auto-checkpointing for the whole incremental run, exactly
803
- // as indexAll does for the bulk path (#1231): sync's store loop and its
804
- // resolution passes churn the same FTS + secondary-index hot pages, and
805
- // at the default 1000-page cadence the inline checkpoints re-write them
806
- // over and over — on HDD-class storage a 7-file sync took 2 minutes at
807
- // 0-2% CPU (#1248). The cost scales with the EXISTING database size,
808
- // not the change size, so small syncs on big indexes hurt most. The
809
- // valve bounds WAL growth off-thread; runMaintenance at the end does
810
- // the final fold-up before the interval is restored in the finally.
811
- // Same kill switch as indexAll: CODEGRAPH_NO_WAL_DEFER=1. Idle valve
812
- // cost is one timer, so watcher-frequency syncs stay cheap.
813
745
  const deferWal = process.env.CODEGRAPH_NO_WAL_DEFER !== '1' && this.db.getJournalMode() === 'wal';
814
746
  let walValve = null;
815
747
  let priorAutocheckpoint = 1000;
@@ -820,10 +752,6 @@ class CodeGraph {
820
752
  walValve.start();
821
753
  }
822
754
  try {
823
- // Captured BEFORE the sync runs: the sync's own incremental writes
824
- // populate vocab rows for the files it touches, so an end-of-sync
825
- // emptiness check would see "non-empty" and skip the backfill forever,
826
- // leaving every unchanged file's names unsegmented.
827
755
  const vocabWasEmpty = (() => {
828
756
  try {
829
757
  return this.queries.isNameSegmentVocabEmpty();
@@ -832,55 +760,101 @@ class CodeGraph {
832
760
  return false;
833
761
  }
834
762
  })();
835
- // Writer-side backstop for deferred WAL checkpointing (#1539): sync
836
- // previously armed the valve but never called backpressure(), so the
837
- // hard/file caps were never enforced during daemon catch-up — only
838
- // timer-driven PASSIVE checkpoints ran, and a query-pool reader could
839
- // pin frames while the WAL grew without a bound.
840
763
  const backpressure = walValve ? () => walValve.backpressure() : undefined;
841
764
  const fullReconcile = !options.paths || options.paths.length === 0;
842
765
  const gitState = this.orchestrator.beginGitIndexState(fullReconcile);
843
- // An interrupted index may have absorbed its changed files before
844
- // resolution/synthesis. Detect those orphans BEFORE this sync adds refs.
766
+ const pythonFilesBefore = this.pythonFilePaths();
845
767
  let refreshSynthesis = this.queries.getMetadata('synthesis_pending') === '1' ||
846
768
  this.queries.getUnresolvedReferencesCount() > 0;
847
769
  if (refreshSynthesis)
848
770
  this.queries.setMetadata('synthesis_pending', '1');
771
+ const watchRoutes = this.resolver.hasNavigationRouters();
772
+ let routesBefore = null;
773
+ const flowChange = this.resolver.trackParameterFlows();
849
774
  const result = await this.orchestrator.sync(options.onProgress, options.paths, backpressure, (filePath, content) => {
775
+ flowChange.before(filePath);
776
+ if (watchRoutes && routesBefore === null)
777
+ routesBefore = this.queries.getNodesByKind('route');
850
778
  if (!refreshSynthesis && (this.queries.hasSynthesizedEdgesTouchingFile(filePath) ||
851
779
  this.queries.wasSynthesisInput(filePath) ||
852
- (content !== undefined && (0, callback_synthesizer_1.hasSynthesisPattern)(filePath, content)))) {
780
+ (content !== undefined && hasSynthesisPattern(filePath, content)))) {
853
781
  refreshSynthesis = true;
854
782
  this.queries.setMetadata('synthesis_pending', '1');
855
783
  }
856
784
  });
857
- // Fold the store phase's WAL BEFORE the post-store reads below
858
- // (resolution reads on the main thread) — same rationale as
859
- // indexAll's fold between store and resolution.
785
+ if (result.detectedFrameworks)
786
+ this.followDetectedFrameworks(result.detectedFrameworks);
787
+ if (!refreshSynthesis && result.definitionDelta && result.changedFilePaths) {
788
+ const delta = new Set(result.definitionDelta);
789
+ const defined = this.queries.getNodesByFiles(result.changedFilePaths).filter((n) => delta.has(n.name));
790
+ if (defined.some(isJsxChildCandidate) || aliasMayName(this.queries, defined)) {
791
+ refreshSynthesis = true;
792
+ this.queries.setMetadata('synthesis_pending', '1');
793
+ }
794
+ }
860
795
  if (walValve)
861
796
  await walValve.foldNow();
862
- // Cross-file finalization (e.g. NestJS RouterModule prefixes). Run on
863
- // every sync that touched files so edits to `app.module.ts` propagate
864
- // to controllers in unchanged files. The pass is idempotent and cheap
865
- // (regex over *.module.ts only).
866
- if (result.filesAdded > 0 || result.filesModified > 0) {
797
+ if (result.filesAdded > 0 || result.filesModified > 0 || result.filesRemoved > 0) {
867
798
  this.resolver.runPostExtract();
868
799
  }
869
- else if (result.filesRemoved > 0) {
870
- // A pure-removal sync still resolves refs below — the deletion path
871
- // resurrects the removed file's incoming edges as pending refs
872
- // (#1240 removal case) and the orphan sweep consumes them. In a
873
- // long-lived process (daemon) the resolver's name caches were
874
- // warmed against the pre-removal graph; drop them so resolution
875
- // sees the post-removal state. (runPostExtract above clears caches
876
- // itself, so the changed-files branch is already covered.)
877
- this.resolver.clearCaches();
800
+ if (routesBefore) {
801
+ const tNav = Date.now();
802
+ const routes = changedRoutes(routesBefore, this.queries.getNodesByKind('route'));
803
+ const reopened = this.resolver.reopenNavigationsFor(routes, result.changedFilePaths ?? []);
804
+ if (routes.length > 0 && !refreshSynthesis) {
805
+ refreshSynthesis = true;
806
+ this.queries.setMetadata('synthesis_pending', '1');
807
+ }
808
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
809
+ console.error(`[phase-timing] sync-navigation-retry: ${Date.now() - tNav}ms (${routes.length} routes changed, ${reopened} refs re-opened)`);
810
+ }
811
+ }
812
+ {
813
+ const tConfig = Date.now();
814
+ const stored = this.queries.getMetadata(MODULE_CONFIG_METADATA_KEY);
815
+ const snapshot = this.resolver.getModuleConfigSnapshot(stored, result.filesAdded > 0 || result.filesRemoved > 0);
816
+ const changed = stored === null ? [] : changedModuleConfigs(parseModuleConfigSnapshot(stored), snapshot);
817
+ if (changed.length > 0) {
818
+ this.resolver.resetModuleConfig();
819
+ let reopened = 0;
820
+ for (const language of moduleConfigLanguages(changed))
821
+ reopened += this.orchestrator.resurrectResolutionEdgesForLanguage(language);
822
+ refreshSynthesis = true;
823
+ this.queries.setMetadata('synthesis_pending', '1');
824
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
825
+ console.error(`[phase-timing] sync-module-config: ${Date.now() - tConfig}ms (${changed.join(', ')} changed, ${reopened} refs re-opened)`);
826
+ }
827
+ }
828
+ }
829
+ if (fullReconcile) {
830
+ const tWorkspace = Date.now();
831
+ const before = this.queries.getMetadata(WORKSPACE_METADATA_KEY);
832
+ const evidence = this.orchestrator.takeManifestEvidence();
833
+ const known = before === null ? null : trustedManifestList(this.projectRoot, parseManifestStamp(this.queries.getMetadata(WORKSPACE_MANIFESTS_METADATA_KEY)), evidence);
834
+ const now = this.resolver.refreshWorkspacePackages(known ?? undefined);
835
+ if (!known)
836
+ this.stampWorkspaceManifests(evidence);
837
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
838
+ console.error(`[phase-timing] sync-workspace-manifests: ${Date.now() - tWorkspace}ms (${known ? `${known.length} read where the last walk found them` : 'walked'})`);
839
+ }
840
+ if (before !== null && before !== now) {
841
+ let reopened = 0;
842
+ for (const language of ESM_IMPORT_LANGUAGES)
843
+ reopened += this.orchestrator.resurrectResolutionEdgesForLanguage(language);
844
+ refreshSynthesis = true;
845
+ this.queries.setMetadata('synthesis_pending', '1');
846
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
847
+ console.error(`[phase-timing] sync-workspace-packages: ${Date.now() - tWorkspace}ms (${reopened} refs re-opened)`);
848
+ }
849
+ }
850
+ if (before !== now)
851
+ this.stampWorkspaceFingerprint(now);
878
852
  }
879
- // Resolve references if files were updated
880
853
  const filesChanged = result.filesAdded > 0 || result.filesModified > 0;
854
+ let edgesBeforeRetry;
855
+ const edgesBeforeResolution = this.queries.getMaxEdgeId();
881
856
  if (filesChanged) {
882
857
  if (result.changedFilePaths) {
883
- // Scope resolution to changed files (git fast path — bounded set)
884
858
  const tRefLoad = Date.now();
885
859
  const unresolvedRefs = this.queries.getUnresolvedReferencesByFiles(result.changedFilePaths);
886
860
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
@@ -897,17 +871,32 @@ class CodeGraph {
897
871
  total,
898
872
  });
899
873
  });
900
- // Retry previously-failed refs the changed files may now satisfy
901
- // (#1240). Scoped resolution above only re-resolves refs FROM the
902
- // changed files — but when a changed file gains an export/symbol,
903
- // refs in UNCHANGED files that failed against the old graph can
904
- // now resolve, and nothing else ever revisits them (their rows
905
- // were parked as status='failed' by an earlier completed pass).
906
- // Look them up by the symbol names the changed files now carry
907
- // and re-resolve just that set. On a sync where no failed ref
908
- // matches, this is one indexed lookup.
909
874
  const tRetry = Date.now();
910
- const retryable = this.queries.getRetryableFailedReferences(this.queries.getNodeNamesByFiles(result.changedFilePaths));
875
+ edgesBeforeRetry = this.queries.getMaxEdgeId();
876
+ const retryable = this.queries.getRetryableFailedReferences([...new Set([
877
+ ...this.queries.getNodeNamesByFiles(result.changedFilePaths),
878
+ ...result.changedFilePaths.flatMap(reference_tail_1.moduleReferenceKeys),
879
+ ])]);
880
+ const addedFiles = new Set(result.addedFilePaths ?? []);
881
+ const resolvesToAdded = (specifier, fromFile, language) => {
882
+ const file = this.resolver.resolveModuleFile(specifier, fromFile, language);
883
+ return file !== null && addedFiles.has(file);
884
+ };
885
+ const resolvedModules = addedFiles.size === 0 ? [] : this.queries.getFailedScopedImports()
886
+ .filter((s) => resolvesToAdded(s.name, s.filePath, s.language))
887
+ .map((s) => s.name);
888
+ const folderImports = addedFiles.size === 0 ? [] : this.queries.getFailedFolderImports()
889
+ .filter((ref) => ref.filePath !== undefined && ref.language !== undefined &&
890
+ resolvesToAdded(ref.referenceName, ref.filePath, ref.language));
891
+ const retryRows = new Set(retryable.map((ref) => ref.rowId));
892
+ const importRetry = this.queries.getRetryableFailedImports((result.addedFilePaths ?? []).flatMap(reference_tail_1.importPathKeys), this.queries.getNodeNamesByFiles(result.changedFilePaths, ['namespace', 'module']), undefined, resolvedModules, undefined, this.resolver.couldNameAnyOf([...addedFiles]));
893
+ for (const ref of [...importRetry, ...folderImports]) {
894
+ if (!retryRows.has(ref.rowId)) {
895
+ retryable.push(ref);
896
+ retryRows.add(ref.rowId);
897
+ }
898
+ }
899
+ retryable.sort((a, b) => (a.rowId ?? 0) - (b.rowId ?? 0));
911
900
  if (retryable.length > 0) {
912
901
  options.onProgress?.({
913
902
  phase: 'resolving',
@@ -923,9 +912,70 @@ class CodeGraph {
923
912
  }
924
913
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
925
914
  console.error(`[phase-timing] sync-failed-ref-retry: ${Date.now() - tRetry}ms (${retryable.length} refs)`);
915
+ const importReader = createImportReader(this.projectRoot);
916
+ const added = (result.addedFilePaths ?? []).flatMap((filePath) => {
917
+ const file = this.queries.getFileByPath(filePath);
918
+ return file ? [{ path: filePath, language: file.language }] : [];
919
+ });
920
+ if (added.length > 0) {
921
+ const tAdded = Date.now();
922
+ const reopened = reopenReferencesThroughAddedFiles(this.queries, importReader, added, edgesBeforeResolution, (specifier, fromFile, language) => this.resolver.resolveModuleFile(specifier, fromFile, language), (file) => this.resolver.workspacePackageDirOf(file));
923
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
924
+ console.error(`[phase-timing] sync-added-module-importers: ${Date.now() - tAdded}ms (${reopened} refs re-opened)`);
925
+ }
926
+ const tBarrels = Date.now();
927
+ const delta = new Set(result.definitionDelta ?? []);
928
+ const seeds = new Map(added.map((file) => [file.path, file.language]));
929
+ const modified = result.changedFilePaths.filter((filePath) => !seeds.has(filePath));
930
+ if (delta.size > 0 && modified.length > 0) {
931
+ for (const node of this.queries.getNodesByFiles(modified)) {
932
+ if (delta.has(node.name))
933
+ seeds.set(node.filePath, node.language);
934
+ }
935
+ }
936
+ const throughBarrels = reopenReferencesThroughBarrels(this.queries, importReader, [...seeds].map(([path, language]) => ({ path, language })), edgesBeforeResolution);
937
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
938
+ console.error(`[phase-timing] sync-barrel-modules: ${Date.now() - tBarrels}ms (${throughBarrels} refs re-opened)`);
939
+ const declared = reopenReferencesThroughDeclaredPackages(this.queries, importReader, this.projectRoot, result.changedFilePaths, edgesBeforeResolution);
940
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS && declared > 0)
941
+ console.error(`[phase-timing] sync-declared-packages: ${declared} refs re-opened`);
942
+ const tDefaults = Date.now();
943
+ const movedDefaults = this.resolver.changedDefaultExports(modified, result.changedFilePaths, edgesBeforeResolution);
944
+ const throughDefaults = movedDefaults.length === 0 ? 0
945
+ : reopenReferencesThroughChangedDefaults(this.queries, importReader, movedDefaults, edgesBeforeResolution);
946
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
947
+ console.error(`[phase-timing] sync-default-exports: ${Date.now() - tDefaults}ms (${movedDefaults.length} defaults moved, ${throughDefaults} refs re-opened)`);
948
+ const tNamed = Date.now();
949
+ const editedModules = modified.flatMap((filePath) => {
950
+ const file = this.queries.getFileByPath(filePath);
951
+ return file ? [{ path: filePath, language: file.language }] : [];
952
+ });
953
+ const nameMatched = reopenNameMatchedImports(this.queries, importReader, editedModules, edgesBeforeResolution, (specifier, fromFile, language) => this.resolver.resolveModuleFile(specifier, fromFile, language), (ref) => this.resolver.resolveNow(ref));
954
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
955
+ console.error(`[phase-timing] sync-name-matched-imports: ${Date.now() - tNamed}ms (${nameMatched} refs re-opened)`);
956
+ const tRetargeted = Date.now();
957
+ const retargeted = (result.reExportsChangedFilePaths ?? []).flatMap((filePath) => {
958
+ const file = this.queries.getFileByPath(filePath);
959
+ return file ? [{ path: filePath, language: file.language }] : [];
960
+ });
961
+ const throughRetargeted = retargeted.length === 0 ? 0
962
+ : reopenReferencesThroughRetargetedModules(this.queries, importReader, retargeted);
963
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
964
+ console.error(`[phase-timing] sync-retargeted-modules: ${Date.now() - tRetargeted}ms (${throughRetargeted} refs re-opened)`);
965
+ const tMembers = Date.now();
966
+ const throughMembers = editedModules.length === 0 || process.env.CODEGRAPH_NO_REBIND === '1' ? 0
967
+ : reopenReferencesThroughObjectMembers(this.queries, importReader, editedModules, (filePath) => {
968
+ try {
969
+ return fs.readFileSync(path.join(this.projectRoot, filePath), 'utf-8').split('\n');
970
+ }
971
+ catch {
972
+ return null;
973
+ }
974
+ });
975
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
976
+ console.error(`[phase-timing] sync-object-members: ${Date.now() - tMembers}ms (${throughMembers} refs re-opened)`);
926
977
  }
927
978
  else {
928
- // No git info — use batched resolution to avoid OOM
929
979
  const unresolvedCount = this.queries.getUnresolvedReferencesCount();
930
980
  options.onProgress?.({
931
981
  phase: 'resolving',
@@ -947,39 +997,77 @@ class CodeGraph {
947
997
  }, backpressure, false);
948
998
  }
949
999
  }
950
- // Re-open resolution edges this sync may have invalidated ELSEWHERE in
951
- // the repo (CG-33). Everything above re-resolves references in the
952
- // changed files; this covers the opposite direction — references in
953
- // files the sync never touched whose answer depended on a definition
954
- // that just appeared or disappeared. Without it a synced index never
955
- // converges to a full rebuild: measured at 4.3% of distinct edges wrong
956
- // on codegraph's own index, in both directions, mostly `calls`. The
957
- // resurrected refs are pending rows, so the orphan sweep immediately
958
- // below is what resolves them — batched, yielding, multi-pass, exactly
959
- // as a full index resolves.
960
- //
961
- // `definitionDelta` is empty for a body-only edit, so the overwhelmingly
962
- // common sync pays one branch. CODEGRAPH_NO_REBIND=1 disables it.
963
1000
  if (result.definitionDelta && process.env.CODEGRAPH_NO_REBIND !== '1') {
964
1001
  const tRebind = Date.now();
965
- const rebound = this.orchestrator.resurrectStaleResolutionEdges(result.definitionDelta, result.changedFilePaths ?? []);
1002
+ const rebound = this.orchestrator.resurrectStaleResolutionEdges(result.definitionDelta, result.changedFilePaths ?? [], edgesBeforeRetry);
1003
+ const reopenedFailed = this.queries.reopenFailedReferences(this.queries.getRetryableFailedReferences(result.definitionDelta).flatMap((ref) => (ref.rowId === undefined ? [] : [ref.rowId])));
1004
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
1005
+ console.error(`[phase-timing] sync-rebind: ${Date.now() - tRebind}ms (${result.definitionDelta.length} changed names, ${rebound} edges and ${reopenedFailed} failed refs re-opened)`);
1006
+ }
1007
+ }
1008
+ if (filesChanged && result.changedFilePaths) {
1009
+ const tModules = Date.now();
1010
+ const reopened = this.resolver.reopenRouteModuleReaders(result.changedFilePaths);
966
1011
  if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
967
- console.error(`[phase-timing] sync-rebind: ${Date.now() - tRebind}ms (${result.definitionDelta.length} changed names, ${rebound} edges re-opened)`);
1012
+ console.error(`[phase-timing] sync-route-modules: ${Date.now() - tModules}ms (${reopened} refs re-opened)`);
968
1013
  }
969
1014
  }
970
- // Orphan sweep (#1187). A resolution pass that dies mid-run — the #850
971
- // daemon liveness watchdog's SIGKILL (#1122), Ctrl-C, a crash — leaves
972
- // the refs it never reached in unresolved_refs, and the git-scoped fast
973
- // path above never revisits them (it reads only the changed files'
974
- // rows). Those files' call edges were then missing PERMANENTLY, with
975
- // nothing to see except a too-small blast radius, until a full
976
- // re-index. A completed pass takes every row it processed out of the
977
- // PENDING set (resolved rows are deleted, unresolvable ones parked as
978
- // status='failed' for the #1240 retry above), so any pending row now
979
- // is such an orphan — or a row from an older engine's scoped pass.
980
- // Grind them down with the batched resolver; this also makes a bare
981
- // `codegraph sync` the recovery command for a wedged index. On a
982
- // healthy index this is one COUNT query.
1015
+ {
1016
+ const before = this.queries.getMetadata(PYTHON_ROOTS_METADATA_KEY);
1017
+ const now = this.resolver.getPythonRootFingerprint();
1018
+ if (before !== null && before !== now) {
1019
+ this.resolver.clearCaches();
1020
+ this.orchestrator.resurrectResolutionEdgesForLanguage('python');
1021
+ refreshSynthesis = true;
1022
+ this.queries.setMetadata('synthesis_pending', '1');
1023
+ }
1024
+ else if (before !== null) {
1025
+ const after = this.pythonFilePaths();
1026
+ const moved = [...after].filter((f) => !pythonFilesBefore.has(f));
1027
+ for (const f of pythonFilesBefore)
1028
+ if (!after.has(f))
1029
+ moved.push(f);
1030
+ const reopened = new Set();
1031
+ if (moved.length > 0) {
1032
+ this.resolver.clearCaches();
1033
+ for (const f of this.orchestrator.resurrectResolutionEdgesTouching('python', this.resolver.getPythonReopenScope(moved)))
1034
+ reopened.add(f);
1035
+ }
1036
+ const editedInits = (result.changedFilePaths ?? []).filter((f) => pythonFilesBefore.has(f) && after.has(f) && /(?:^|[\\/])__init__\.py$/.test(f));
1037
+ if (editedInits.length > 0) {
1038
+ this.resolver.clearCaches();
1039
+ for (const f of this.orchestrator.resurrectPythonPackageImporters(this.resolver.getPythonPackageImporters(editedInits)))
1040
+ reopened.add(f);
1041
+ }
1042
+ const scriptModules = this.resolver.getPythonScriptModuleScope((result.changedFilePaths ?? []).filter((f) => pythonFilesBefore.has(f) && after.has(f)));
1043
+ if (scriptModules.targetFiles.length > 0) {
1044
+ this.resolver.clearCaches();
1045
+ for (const f of this.orchestrator.resurrectResolutionEdgesTouching('python', scriptModules))
1046
+ reopened.add(f);
1047
+ }
1048
+ if (reopened.size > 0) {
1049
+ this.resolver.resolveAndPersist(this.queries.getUnresolvedReferencesByFiles([...reopened]));
1050
+ if (!refreshSynthesis && [...reopened].some((f) => this.queries.hasSynthesizedEdgesTouchingFile(f) || this.queries.wasSynthesisInput(f))) {
1051
+ refreshSynthesis = true;
1052
+ this.queries.setMetadata('synthesis_pending', '1');
1053
+ }
1054
+ }
1055
+ }
1056
+ if (before !== now)
1057
+ this.stampPythonRootFingerprint(now);
1058
+ }
1059
+ {
1060
+ const before = this.queries.getMetadata(PHP_WEB_ROOTS_METADATA_KEY);
1061
+ const now = this.resolver.getPhpWebRootSnapshot();
1062
+ if (before !== null && this.resolver.phpWebRootsMoved(before, now)) {
1063
+ this.resolver.clearCaches();
1064
+ this.orchestrator.resurrectResolutionEdgesForLanguage('php');
1065
+ refreshSynthesis = true;
1066
+ this.queries.setMetadata('synthesis_pending', '1');
1067
+ }
1068
+ if (before !== now)
1069
+ this.stampPhpWebRoots(now);
1070
+ }
983
1071
  result.pendingRefsProcessed = 0;
984
1072
  result.pendingRefsResolved = 0;
985
1073
  result.pendingRefsUnresolved = 0;
@@ -1007,57 +1095,67 @@ class CodeGraph {
1007
1095
  result.pendingRefsResolved = recovery.stats.resolved;
1008
1096
  result.pendingRefsUnresolved = recovery.stats.unresolved;
1009
1097
  }
1098
+ if (process.env.CODEGRAPH_NO_REBIND !== '1') {
1099
+ const touched = [...(result.changedFilePaths ?? []), ...(result.removedFilePaths ?? [])];
1100
+ const touchedPy = touched.filter((p) => /\.pyi?$/.test(p));
1101
+ if (touched.length > 0) {
1102
+ const tTypes = Date.now();
1103
+ const reopenedFiles = this.orchestrator.resurrectTypeDependentEdges(touched, result.changedFilePaths ?? []);
1104
+ const ceiling = Number(process.env.CODEGRAPH_PY_ATTR_RETRY_CEILING ?? '') || 2000;
1105
+ const failed = touchedPy.length > 0 ? this.resolver.pythonAttrRetryCandidates(touchedPy, ceiling) : [];
1106
+ const retry = [...this.queries.getUnresolvedReferencesByFiles(reopenedFiles), ...(failed ?? [])];
1107
+ if (retry.length > 0)
1108
+ await this.resolver.resolveAndPersistListYielding(retry);
1109
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS) {
1110
+ console.error(`[phase-timing] sync-type-rebind: ${Date.now() - tTypes}ms (${retry.length} refs${failed ? '' : ', failed-ref fan-in over ceiling'})`);
1111
+ }
1112
+ }
1113
+ }
1010
1114
  if (filesChanged || orphanCount > 0) {
1011
- // Second pass: chained calls whose method lives on a supertype the
1012
- // receiver conforms to (protocol-extension / inherited). Needs the
1013
- // implements/extends edges built above (#750).
1014
1115
  await this.resolver.resolveChainedCallsViaConformance();
1015
- // Same lifecycle for `this.<member>` callback registrations whose
1016
- // member is inherited from a supertype (#808).
1017
1116
  await this.resolver.resolveDeferredThisMemberRefs();
1018
1117
  }
1118
+ let synthesized = false;
1019
1119
  if (refreshSynthesis) {
1020
- await this.resolver.refreshSynthesis(this.db.getPath(), (done, total) => {
1021
- options.onProgress?.({ phase: 'linking', current: done, total });
1022
- }, backpressure);
1023
- this.queries.setMetadata('synthesis_pending', '0');
1120
+ const hold = this.synthesisHoldMs();
1121
+ if (hold > 0) {
1122
+ this.armDeferredSynthesis(hold);
1123
+ }
1124
+ else {
1125
+ await this.resolver.refreshSynthesis(this.db.getPath(), (done, total) => {
1126
+ options.onProgress?.({ phase: 'linking', current: done, total });
1127
+ }, backpressure);
1128
+ this.queries.setMetadata('synthesis_pending', '0');
1129
+ this.lastSynthesisAt = Date.now();
1130
+ synthesized = true;
1131
+ }
1024
1132
  }
1025
- // Refresh planner stats + checkpoint the WAL after bulk writes.
1026
- // Off-thread — see indexAll's call site.
1027
- if (filesChanged || result.filesRemoved > 0 || orphanCount > 0 || refreshSynthesis) {
1133
+ if (filesChanged || result.filesRemoved > 0 || orphanCount > 0) {
1134
+ await this.resolver.resolveParameterFlows(flowChange);
1135
+ }
1136
+ if (filesChanged || result.filesRemoved > 0 || orphanCount > 0 || synthesized) {
1028
1137
  await this.db.runMaintenance();
1029
1138
  }
1030
- // Heal the segment vocabulary on indexes built before the table
1031
- // existed (upgrade path): incremental writes above only cover changed
1032
- // files, so a vocab that was empty when this sync STARTED means the
1033
- // bulk was never segmented — backfill it (INSERT OR IGNORE, so the
1034
- // rows the sync just wrote are fine). Batched + yielding — sync can
1035
- // run on the daemon's liveness-watchdog thread (#850/#1091).
1036
1139
  try {
1037
1140
  if (vocabWasEmpty && this.queries.getNodeAndEdgeCount().nodes > 0) {
1038
1141
  await this.rebuildNameSegmentVocab();
1039
1142
  }
1040
1143
  }
1041
- catch { /* vocab is advisory — never fail a sync over it */ }
1042
- // A killed full index leaves this marker at `indexing`. Sync repairs
1043
- // missing files, pending refs, and (on open) dropped indexes, so a
1044
- // successful recovery must also close the metadata state (#1556).
1144
+ catch { }
1045
1145
  if (fullReconcile && this.getIndexState() === 'indexing') {
1046
1146
  try {
1047
1147
  this.queries.setMetadata('index_state', 'complete');
1048
1148
  }
1049
- catch { /* advisory */ }
1149
+ catch { }
1050
1150
  }
1051
1151
  this.orchestrator.finishGitIndexState(gitState, fullReconcile, result.failedFilePaths);
1052
1152
  if (fullReconcile && result.filesChecked > 0)
1053
1153
  this.pendingFullReconcile = false;
1154
+ this.stampModuleConfigSnapshotIfMoved();
1155
+ result.durationMs = Date.now() - startedAt;
1054
1156
  return result;
1055
1157
  }
1056
1158
  finally {
1057
- // Mirror indexAll's teardown: stop the valve, then restore the
1058
- // auto-checkpoint interval (runMaintenance above already folded the
1059
- // WAL on the success path; on the error path SQLite replays it on
1060
- // the next open).
1061
1159
  if (walValve) {
1062
1160
  walValve.stop();
1063
1161
  await walValve.drain();
@@ -1066,26 +1164,92 @@ class CodeGraph {
1066
1164
  try {
1067
1165
  this.db.setWalAutocheckpoint(priorAutocheckpoint);
1068
1166
  }
1069
- catch { /* connection may be closing */ }
1167
+ catch { }
1070
1168
  }
1071
1169
  this.fileLock.release();
1072
1170
  }
1073
1171
  });
1074
1172
  }
1075
- /**
1076
- * Check if an indexing operation is currently in progress
1077
- */
1078
1173
  isIndexing() {
1079
1174
  return this.indexMutex.isLocked();
1080
1175
  }
1081
- // ===========================================================================
1082
- // File Watching
1083
- // ===========================================================================
1084
- /**
1085
- * Whether an OS watcher event points at a file whose index metadata is still
1086
- * current. Used on Windows to discard NTFS last-access notifications, which
1087
- * libuv reports through fs.watch as ordinary change events (#1451).
1088
- */
1176
+ synthesisHoldMs() {
1177
+ const interval = parseSynthMinIntervalEnv(process.env.CODEGRAPH_SYNTH_MIN_INTERVAL_MS);
1178
+ if (!interval || this.lastSynthesisAt === 0)
1179
+ return 0;
1180
+ return Math.max(0, this.lastSynthesisAt + interval - Date.now());
1181
+ }
1182
+ armDeferredSynthesis(delayMs) {
1183
+ if (this.deferredSynthesisTimer)
1184
+ return;
1185
+ this.deferredSynthesisTimer = setTimeout(() => {
1186
+ this.deferredSynthesisTimer = null;
1187
+ void this.runDeferredSynthesis();
1188
+ }, delayMs);
1189
+ this.deferredSynthesisTimer.unref?.();
1190
+ }
1191
+ async runDeferredSynthesis() {
1192
+ const retryLater = () => {
1193
+ if (!this.db.isOpen())
1194
+ return;
1195
+ this.armDeferredSynthesis(parseSynthMinIntervalEnv(process.env.CODEGRAPH_SYNTH_MIN_INTERVAL_MS) ?? 1000);
1196
+ };
1197
+ try {
1198
+ await this.indexMutex.withLock(async () => {
1199
+ if (this.queries.getMetadata('synthesis_pending') !== '1')
1200
+ return;
1201
+ try {
1202
+ this.fileLock.acquire();
1203
+ }
1204
+ catch {
1205
+ retryLater();
1206
+ return;
1207
+ }
1208
+ try {
1209
+ this.reopenReplacedDatabase();
1210
+ if (this.queries.getMetadata('synthesis_pending') !== '1')
1211
+ return;
1212
+ await this.synthesizeWithWalDeferred();
1213
+ }
1214
+ finally {
1215
+ this.fileLock.release();
1216
+ }
1217
+ });
1218
+ }
1219
+ catch (err) {
1220
+ (0, errors_1.logWarn)(`Put-off synthesis failed, trying again after the interval: ${err instanceof Error ? err.message : String(err)}`);
1221
+ retryLater();
1222
+ }
1223
+ }
1224
+ async synthesizeWithWalDeferred() {
1225
+ const deferWal = process.env.CODEGRAPH_NO_WAL_DEFER !== '1' && this.db.getJournalMode() === 'wal';
1226
+ let walValve = null;
1227
+ let priorAutocheckpoint = 1000;
1228
+ if (deferWal) {
1229
+ priorAutocheckpoint = this.db.getWalAutocheckpoint();
1230
+ this.db.setWalAutocheckpoint(0);
1231
+ walValve = new wal_valve_1.WalCheckpointValve(this.db, (0, wal_valve_1.resolveWalValveMb)(process.env.CODEGRAPH_WAL_VALVE_MB, this.db.getDbFileSizeBytes()));
1232
+ walValve.start();
1233
+ }
1234
+ try {
1235
+ await this.resolver.refreshSynthesis(this.db.getPath(), undefined, walValve ? () => walValve.backpressure() : undefined);
1236
+ this.queries.setMetadata('synthesis_pending', '0');
1237
+ this.lastSynthesisAt = Date.now();
1238
+ await this.db.runMaintenance();
1239
+ }
1240
+ finally {
1241
+ if (walValve) {
1242
+ walValve.stop();
1243
+ await walValve.drain();
1244
+ }
1245
+ if (deferWal) {
1246
+ try {
1247
+ this.db.setWalAutocheckpoint(priorAutocheckpoint);
1248
+ }
1249
+ catch { }
1250
+ }
1251
+ }
1252
+ }
1089
1253
  isIndexedFileStateCurrent(filePath) {
1090
1254
  const tracked = this.queries.getFileByPath(filePath);
1091
1255
  if (!tracked)
@@ -1099,221 +1263,98 @@ class CodeGraph {
1099
1263
  Math.floor(stat.mtimeMs) === Math.floor(tracked.modifiedAt));
1100
1264
  }
1101
1265
  catch {
1102
- // Missing/inaccessible files must still reach sync so removals and
1103
- // transient filesystem failures are reconciled rather than hidden.
1104
1266
  return false;
1105
1267
  }
1106
1268
  }
1107
- /**
1108
- * Start watching for file changes and auto-syncing.
1109
- *
1110
- * Uses native OS file events (FSEvents on macOS, inotify on Linux 19+,
1111
- * ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing.
1112
- *
1113
- * @param options - Watch options (debounce delay, callbacks)
1114
- * @returns true if watching started successfully
1115
- */
1116
1269
  watch(options = {}) {
1117
1270
  if (this.watcher?.isActive())
1118
1271
  return true;
1119
- this.watcher = new sync_1.FileWatcher(this.projectRoot, async (paths) => {
1272
+ this.watcher = new ((0, lazy_engine_1.engine)().FileWatcher)(this.projectRoot, async (paths) => {
1120
1273
  const result = await this.sync({ paths });
1121
1274
  const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
1122
1275
  return { filesChanged, durationMs: result.durationMs };
1123
1276
  }, options, process.platform === 'win32'
1124
1277
  ? (filePath) => this.isIndexedFileStateCurrent(filePath)
1125
1278
  : undefined);
1126
- return this.watcher.start();
1279
+ this.orchestrator.setKeepDetectionContents(true);
1280
+ const started = this.watcher.start();
1281
+ if (!started)
1282
+ this.orchestrator.setKeepDetectionContents(false);
1283
+ return started;
1127
1284
  }
1128
- /**
1129
- * Stop watching for file changes.
1130
- */
1131
1285
  unwatch() {
1132
1286
  if (this.watcher) {
1133
1287
  this.watcher.stop();
1134
1288
  this.watcher = null;
1135
1289
  }
1290
+ if (this.builtOrchestrator)
1291
+ this.builtOrchestrator.setKeepDetectionContents(false);
1136
1292
  }
1137
- /**
1138
- * Check if the file watcher is active.
1139
- */
1140
1293
  isWatching() {
1141
1294
  return this.watcher?.isActive() ?? false;
1142
1295
  }
1143
- /**
1144
- * True once live watching has degraded, or while a re-armed watcher has not
1145
- * completed its full catch-up. Distinct from `!isWatching()`: a stopped or
1146
- * never-started watcher is inactive but NOT degraded. MCP tools use this for
1147
- * a whole-index stale notice, since pending files are lost when watching
1148
- * stops (#876, #1959).
1149
- */
1150
1296
  isWatcherDegraded() {
1151
1297
  return this.watcher?.isDegraded() ?? false;
1152
1298
  }
1153
- /** The reason live watching degraded, or null if it is healthy (#876). */
1154
1299
  getWatcherDegradedReason() {
1155
1300
  return this.watcher?.getDegradedReason() ?? null;
1156
1301
  }
1157
- /** Re-arm a lock-degraded watcher; its stale state persists until a full sync. */
1158
1302
  rearmWatcherAfterLockContention() {
1159
1303
  return this.watcher?.rearmAfterLockContention() ?? false;
1160
1304
  }
1161
- /** True while a re-armed watcher owes a full reconcile of missed changes. */
1162
1305
  isWatcherRecovering() {
1163
1306
  return this.watcher?.isRecoveringFromLock() ?? false;
1164
1307
  }
1165
- /**
1166
- * Files seen by the file watcher since the last successful sync —
1167
- * the per-file "stale" signal MCP tools attach to responses so an agent
1168
- * can fall back to {@link Read} for just the affected file without
1169
- * waiting for a debounced sync to complete (issue #403).
1170
- *
1171
- * Returns an empty list when the watcher isn't active, or no events have
1172
- * arrived. Each entry includes `firstSeenMs` and `lastSeenMs` (wall-clock
1173
- * `Date.now()` values) so callers can render "edited Nms ago", plus an
1174
- * `indexing` flag indicating whether the in-flight sync (if any) will
1175
- * absorb that file.
1176
- */
1177
1308
  getPendingFiles() {
1178
1309
  return this.watcher?.getPendingFiles() ?? [];
1179
1310
  }
1180
- /**
1181
- * Resolves once the file watcher has installed its watch set. Useful for
1182
- * tests that need a deterministic boundary before asserting on
1183
- * `getPendingFiles()`. Resolves immediately when no watcher is active.
1184
- */
1185
1311
  waitUntilWatcherReady(timeoutMs) {
1186
1312
  return this.watcher ? this.watcher.waitUntilReady(timeoutMs) : Promise.resolve();
1187
1313
  }
1188
- /**
1189
- * Get files that have changed since last index
1190
- */
1191
1314
  getChangedFiles() {
1192
1315
  return this.orchestrator.getChangedFiles();
1193
1316
  }
1194
- /**
1195
- * Most recent index timestamp (ms since epoch) across all tracked files, or
1196
- * null when nothing is indexed yet. Lets library consumers check index
1197
- * freshness without shelling out to `codegraph status --json`. (#329)
1198
- */
1199
1317
  getLastIndexedAt() {
1200
1318
  return this.queries.getLastIndexedAt();
1201
1319
  }
1202
- /**
1203
- * How far the last sync got and how many files it left behind — the cheapest
1204
- * marker of "has this index moved". One query; safe to call on every
1205
- * filesystem event a live viewer sees.
1206
- */
1207
1320
  getIndexRevision() {
1208
1321
  return this.queries.getIndexRevision();
1209
1322
  }
1210
- /**
1211
- * Files re-indexed strictly after `since`, newest first — what a sync just
1212
- * picked up. `total` is the real count, `paths` is capped at `limit`.
1213
- */
1214
1323
  getFilesIndexedSince(since, limit) {
1215
1324
  return this.queries.getFilesIndexedSince(since, limit);
1216
1325
  }
1217
- /**
1218
- * Forget everything held in memory about rows another process may have
1219
- * changed.
1220
- *
1221
- * The query layer keeps an LRU of nodes by id, invalidated by writes made
1222
- * through THIS instance — which is exactly right for a process that owns the
1223
- * index, and wrong for one that is only reading a database somebody else is
1224
- * writing. A long-lived reader (the `codegraph ui` server, a daemon holding a
1225
- * graph open across an agent's edits) will otherwise answer `getNode(id)`
1226
- * with a row a sync deleted minutes ago, while every SQL-backed query beside
1227
- * it reports the truth — a disagreement that reads as a bug in whichever
1228
- * screen shows both.
1229
- *
1230
- * Cheap (clearing a bounded Map) and safe to call whenever the database file
1231
- * looks like it moved.
1232
- */
1233
1326
  dropReadCaches() {
1234
1327
  this.queries.clearCache();
1235
1328
  }
1236
- /**
1237
- * Completeness of the last full index run. `'complete'` is the only good
1238
- * state. `'indexing'` after the fact means a run was killed mid-index (OOM,
1239
- * SIGKILL, liveness watchdog) and the on-disk index is truncated;
1240
- * `'partial'` means the run finished but silently dropped files
1241
- * (discovered > indexed+skipped+errored); `'failed'` means it reported
1242
- * failure. `null` = index predates this marker. Surfaced by
1243
- * `codegraph status`.
1244
- */
1245
1329
  getIndexState() {
1246
1330
  const raw = this.queries.getMetadata('index_state');
1247
1331
  return raw === 'indexing' || raw === 'complete' || raw === 'partial' || raw === 'failed'
1248
1332
  ? raw
1249
1333
  : null;
1250
1334
  }
1251
- /**
1252
- * Which engine built the current index: the package version + extraction
1253
- * version stamped at the last full `indexAll`. Either field is null for an
1254
- * index built before stamping existed (treated as stale). See
1255
- * `extraction-version.ts` and `isIndexStale()`.
1256
- */
1257
1335
  getIndexBuildInfo() {
1258
1336
  const version = this.queries.getMetadata('indexed_with_version');
1259
1337
  const ev = this.queries.getMetadata('indexed_with_extraction_version');
1260
1338
  const parsed = ev != null ? parseInt(ev, 10) : NaN;
1261
1339
  return { version, extractionVersion: Number.isFinite(parsed) ? parsed : null };
1262
1340
  }
1263
- /**
1264
- * True when the on-disk index was built by an engine whose extraction is
1265
- * older than the one now running — i.e. a re-index would add data a migration
1266
- * can't backfill. False when there's no index yet (nothing to refresh) or the
1267
- * stamp is current. This is the signal behind `codegraph status`'s re-index
1268
- * hint and `codegraph upgrade`'s reminder.
1269
- */
1270
1341
  isIndexStale() {
1271
1342
  if (this.queries.getLastIndexedAt() == null)
1272
1343
  return false;
1273
1344
  const { extractionVersion } = this.getIndexBuildInfo();
1274
1345
  return extractionVersion == null || extractionVersion < extraction_version_1.EXTRACTION_VERSION;
1275
1346
  }
1276
- /**
1277
- * Extract nodes and edges from source code (without storing)
1278
- */
1279
1347
  extractFromSource(filePath, source) {
1280
- return (0, extraction_1.extractFromSource)(filePath, source);
1281
- }
1282
- // ===========================================================================
1283
- // Reference Resolution
1284
- // ===========================================================================
1285
- /**
1286
- * Resolve unresolved references and create edges
1287
- *
1288
- * This method takes unresolved references from extraction and attempts
1289
- * to resolve them using multiple strategies:
1290
- * - Framework-specific patterns (React, Express, Laravel)
1291
- * - Import-based resolution
1292
- * - Name-based symbol matching
1293
- */
1348
+ return (0, lazy_engine_1.engine)().extractFromSource(filePath, source, (0, grammars_1.detectLanguage)(filePath, source, undefined, this.projectRoot));
1349
+ }
1294
1350
  resolveReferences(onProgress) {
1295
- // Get all unresolved references from the database
1296
1351
  const unresolvedRefs = this.queries.getUnresolvedReferences();
1297
1352
  return this.resolver.resolveAndPersist(unresolvedRefs, onProgress);
1298
1353
  }
1299
- /**
1300
- * Resolve references in batches to keep memory bounded on large codebases.
1301
- * Processes chunks of unresolved refs, persisting results after each batch.
1302
- */
1303
- async resolveReferencesBatched(onProgress, onSynthesisProgress,
1304
- // The WAL valve's writer-side backstop, threaded into the batch loop's
1305
- // pool-idle boundaries. Without it the valve's only lever during
1306
- // resolution is timer-driven passive checkpoints, which the pool's
1307
- // continuous reads keep perpetually partial — the WAL then accretes the
1308
- // whole phase's write volume (22GB on a 4.6GB DB at kernel scale).
1309
- backpressure, synthesize = true) {
1354
+ async resolveReferencesBatched(onProgress, onSynthesisProgress, backpressure, synthesize = true, frameworksCurrent = false) {
1310
1355
  return this.resolver.resolveAndPersistBatched(onProgress, undefined, onSynthesisProgress, {
1311
1356
  dbPath: this.db.getPath(),
1312
- // Bulk-edge-load hooks: on big runs the resolver drops the non-unique
1313
- // edge indexes for the batch loop and recreates them before synthesis
1314
- // (which reads kind-keyed). Concurrent readers (a daemon serving this
1315
- // project mid-index) stay CORRECT during the window — target/kind reads
1316
- // just degrade to scans until the recreate.
1357
+ shareFrameworks: frameworksCurrent,
1317
1358
  bulkEdgeLoad: {
1318
1359
  begin: () => this.db.beginBulkEdgeLoad(),
1319
1360
  end: () => this.db.endBulkEdgeLoad({ deferSynthesisSite: true }),
@@ -1326,306 +1367,142 @@ class CodeGraph {
1326
1367
  backpressure,
1327
1368
  }, synthesize);
1328
1369
  }
1329
- /**
1330
- * References extracted but never attempted by a resolution pass. Zero on a
1331
- * healthy index — a completed pass consumes every pending row (resolving it
1332
- * or parking it as failed, #1240). Non-zero at rest means a pass was
1333
- * interrupted mid-run (killed indexer, crash — #1187), so some files' call
1334
- * edges are missing; the next `sync` sweeps them.
1335
- */
1336
1370
  getPendingReferenceCount() {
1337
1371
  return this.queries.getUnresolvedReferencesCount();
1338
1372
  }
1339
- /**
1340
- * Get detected frameworks in the project
1341
- */
1342
1373
  getDetectedFrameworks() {
1343
1374
  return this.resolver.getDetectedFrameworks();
1344
1375
  }
1345
- /**
1346
- * Re-initialize the resolver (useful after adding new files)
1347
- */
1348
1376
  reinitializeResolver() {
1349
1377
  this.resolver.initialize();
1350
1378
  }
1351
- // ===========================================================================
1352
- // Graph Statistics
1353
- // ===========================================================================
1354
- /**
1355
- * Get statistics about the knowledge graph
1356
- */
1357
1379
  getStats() {
1358
1380
  const stats = this.queries.getStats();
1359
1381
  stats.dbSizeBytes = this.db.getSize();
1360
1382
  stats.walSizeBytes = this.db.getWalSizeBytes();
1361
1383
  return stats;
1362
1384
  }
1363
- /**
1364
- * Active SQLite backend for this project's connection (`node-sqlite` — Node's
1365
- * built-in real-SQLite module). Surfaced via `codegraph status` and the
1366
- * `codegraph_status` MCP tool alongside the effective journal mode.
1367
- */
1368
1385
  getBackend() {
1369
1386
  return this.db.getBackend();
1370
1387
  }
1371
- /**
1372
- * The journal mode actually in effect ('wal', 'delete', …). 'wal' means
1373
- * readers never block on a concurrent writer; anything else means they can,
1374
- * which is the precondition for the "database is locked" failures in issue
1375
- * #238. Surfaced via `codegraph status` and the `codegraph_status` MCP tool.
1376
- */
1377
1388
  getJournalMode() {
1378
1389
  return this.db.getJournalMode();
1379
1390
  }
1380
- // ===========================================================================
1381
- // Node Operations
1382
- // ===========================================================================
1383
- /**
1384
- * Get a node by ID
1385
- */
1386
1391
  getNode(id) {
1387
1392
  return this.queries.getNodeById(id);
1388
1393
  }
1389
- /**
1390
- * Get many nodes by id in ONE round-trip (LRU-cache aware).
1391
- *
1392
- * The batch form of {@link getNode}. Anything resolving a list of edges to
1393
- * their endpoints — a caller list, a callee rail, an impact set — must use
1394
- * this rather than a `getNode` per edge: a symbol with 500 callers is 500
1395
- * queries otherwise. Ids that name nothing are simply absent from the map.
1396
- */
1397
1394
  getNodesByIds(ids) {
1398
1395
  return this.queries.getNodesByIds(ids);
1399
1396
  }
1400
- /**
1401
- * Every symbol carrying an exact qualified name.
1402
- *
1403
- * The identity that survives a re-index. A node's id contains its start line,
1404
- * so any edit ABOVE a symbol gives it a different id — anything that has to
1405
- * name the same symbol across two indexes (a saved trail, a bookmark, a
1406
- * review comment) has to key on this instead, and then disambiguate the
1407
- * result by kind and file. Index-backed; unlike
1408
- * {@link GraphQueryManager.findByQualifiedName} it takes no pattern and scans
1409
- * nothing.
1410
- */
1411
1397
  getNodesByQualifiedName(qualifiedName) {
1412
1398
  return this.queries.getNodesByQualifiedNameExact(qualifiedName);
1413
1399
  }
1414
- /**
1415
- * Outgoing edges for many source nodes at once — the batch form of
1416
- * {@link getOutgoingEdges}. See {@link QueryBuilder.getOutgoingEdgesFrom}.
1417
- */
1418
1400
  getOutgoingEdgesFrom(nodeIds, kinds) {
1419
1401
  return this.queries.getOutgoingEdgesFrom(nodeIds, kinds);
1420
1402
  }
1421
- /**
1422
- * Fan-in (incoming edge count) for many nodes at once — the "hub" signal,
1423
- * without a query per node. See {@link QueryBuilder.countIncomingEdges}.
1424
- */
1425
1403
  getFanIn(ids) {
1426
1404
  return this.queries.countIncomingEdges(ids);
1427
1405
  }
1428
- /**
1429
- * Incoming edges for many target nodes at once — the mirror of
1430
- * {@link getOutgoingEdgesFrom}. See {@link QueryBuilder.getIncomingEdgesTo}.
1431
- */
1432
1406
  getIncomingEdgesTo(nodeIds, kinds) {
1433
1407
  return this.queries.getIncomingEdgesTo(nodeIds, kinds);
1434
1408
  }
1435
- /**
1436
- * Fan-out (outgoing edge count) for many nodes at once — the mirror of
1437
- * {@link getFanIn}. See {@link QueryBuilder.countOutgoingEdges}.
1438
- */
1439
1409
  getFanOut(ids) {
1440
1410
  return this.queries.countOutgoingEdges(ids);
1441
1411
  }
1442
- /**
1443
- * Symbols nothing in the index points at, by kind — the candidate set the
1444
- * dead code report (`src/graph/dead-code.ts`) applies its exclusions to.
1445
- *
1446
- * Every edge kind except `contains` counts as a reference, so a method is
1447
- * not "reached" by the class that holds it. An unreferenced symbol is not
1448
- * yet a dead one: see {@link buildDeadCodeReport}.
1449
- */
1450
1412
  getUnreferencedNodes(kinds, limit) {
1451
1413
  return this.queries.getUnreferencedNodes(kinds, limit);
1452
1414
  }
1453
- /**
1454
- * Which of the given names are carried by more than one symbol, at least one
1455
- * of which something references — the names a "nothing reaches this" claim
1456
- * must not be made about, because the resolver may have picked the twin.
1457
- */
1458
1415
  getAmbiguousReferencedNames(names) {
1459
1416
  return this.queries.getAmbiguousReferencedNames(names);
1460
1417
  }
1461
- /**
1462
- * Which of the given languages this index records an export marker for. A
1463
- * language with none has no "reachable from outside" signal at all.
1464
- */
1465
1418
  getLanguagesWithExports(languages) {
1466
1419
  return this.queries.getLanguagesWithExports(languages);
1467
1420
  }
1468
- /**
1469
- * Which of the given names the index holds an unresolved reference to — the
1470
- * resolver saw the name and could not decide what it meant. A symbol with
1471
- * such a name can never be called unreferenced.
1472
- */
1473
1421
  getUnresolvedNamesAmong(names) {
1474
1422
  return this.queries.getUnresolvedNamesAmong(names);
1475
1423
  }
1476
- /**
1477
- * Which of the given symbols extend or implement a type outside the index —
1478
- * an ancestor the resolver could not follow, so it has no edge (#1973).
1479
- */
1480
1424
  getUnresolvedSupertypeSourcesAmong(nodeIds) {
1481
1425
  return this.queries.getUnresolvedSupertypeSourcesAmong(nodeIds);
1482
1426
  }
1483
- /**
1484
- * The symbols with the most distinct dependents, most first — the index's
1485
- * hubs. Distinct dependents, not edges: a helper called forty times from one
1486
- * function has one dependent, and it is dependents a blast radius grows from.
1487
- */
1427
+ getUnresolvedReferenceNamesFrom(nodeIds, kinds) {
1428
+ return this.queries.getUnresolvedReferenceNamesFrom(nodeIds, kinds);
1429
+ }
1430
+ getUnresolvedReferenceSourcesNamed(names, kinds) {
1431
+ return this.queries.getUnresolvedReferenceSourcesNamed(names, kinds);
1432
+ }
1433
+ getUnlinkedReferencesNamed(name, limit) {
1434
+ return this.queries.getFailedReferencesByTail(name, ['imports'], limit);
1435
+ }
1436
+ getUnlinkedReferencesWritten(names, limit) {
1437
+ return this.queries.getFailedReferencesByNames(names, limit);
1438
+ }
1488
1439
  getTopDependedOn(limit) {
1489
1440
  return this.queries.getTopDependedOn(limit);
1490
1441
  }
1491
- /**
1492
- * The graph's executable roots — files that run something at module level (a
1493
- * CLI, a worker entry, a script), ranked by calls x the number of other files
1494
- * they reach. A statement at the top level of a file is recorded as an edge
1495
- * out of the *file* node, which is what makes these visible at all.
1496
- */
1497
1442
  getTopCallingFiles(limit) {
1498
1443
  return this.queries.getTopCallingFiles(limit);
1499
1444
  }
1500
- /**
1501
- * How many other files depend on each of the given files, counted through
1502
- * their symbols (an `imports` edge points at the symbol, not the file).
1503
- * A zero means nothing else in the index reaches into that file.
1504
- */
1505
1445
  getFileDependentCounts(filePaths) {
1506
1446
  return new Map(this.queries.getFileDependentCounts(filePaths).map((row) => [row.filePath, row.dependents]));
1507
1447
  }
1508
- /**
1509
- * How far each of the given files reaches out: distinct other files their
1510
- * symbols touch, and how many references that is. The mirror of
1511
- * {@link getFileDependentCounts}; a test file's reach is what it exercises.
1512
- */
1513
1448
  getFileReachCounts(filePaths) {
1514
1449
  return new Map(this.queries
1515
1450
  .getFileReachCounts(filePaths)
1516
1451
  .map((row) => [row.filePath, { reaches: row.reaches, refs: row.refs }]));
1517
1452
  }
1518
- /** The `file` nodes for the given paths, in one query. */
1519
1453
  getFileNodes(filePaths) {
1520
1454
  return this.queries.getFileNodes(filePaths);
1521
1455
  }
1522
- /**
1523
- * Roll the edge table up to module granularity, for a file → module
1524
- * assignment the caller decides.
1525
- *
1526
- * The architecture map's single query: cross-module edge counts by kind,
1527
- * the `declared` subset of each (see {@link QueryBuilder.aggregateModuleGraph}),
1528
- * and the busiest symbol pairs behind each link. Read-only, and bounded by
1529
- * the number of modules rather than the number of edges.
1530
- */
1531
1456
  getModuleAggregation(assignments, options) {
1532
1457
  return this.queries.aggregateModuleGraph(assignments, options);
1533
1458
  }
1534
- /**
1535
- * Every ordered pair of files where one reaches into the other — the edge
1536
- * list a cycle finder runs on. See {@link QueryBuilder.getCrossFileDependencyPairs}.
1537
- */
1538
1459
  getFileDependencyPairs(minConfidence = 0) {
1539
1460
  return this.queries.getCrossFileDependencyPairs(minConfidence);
1540
1461
  }
1541
- /**
1542
- * References from a symbol that never resolved to an indexed node — the
1543
- * calls and type mentions that leave the index. Lets a reader account for
1544
- * the call sites that have no callee row instead of implying there are none.
1545
- */
1462
+ getFileImportPairs() {
1463
+ return this.queries.getFileImportPairs();
1464
+ }
1546
1465
  getUnresolvedReferencesFrom(nodeId) {
1547
1466
  return this.queries.getUnresolvedReferencesFrom(nodeId);
1548
1467
  }
1549
- /**
1550
- * The same, for every symbol in a FILE at once, in line order.
1551
- *
1552
- * One indexed lookup instead of one per symbol — the whole-file reader needs
1553
- * it for every line it draws. See
1554
- * {@link QueryBuilder.getUnresolvedReferencesInFile}.
1555
- */
1556
1468
  getUnresolvedReferencesInFile(filePath, limit) {
1557
1469
  return this.queries.getUnresolvedReferencesInFile(filePath, limit);
1558
1470
  }
1559
- /**
1560
- * Get all nodes in a file
1561
- */
1562
1471
  getNodesInFile(filePath) {
1563
1472
  return this.queries.getNodesByFile(filePath);
1564
1473
  }
1565
- /**
1566
- * Get all nodes in several files, in one batched query.
1567
- */
1568
1474
  getNodesInFiles(filePaths) {
1569
1475
  return this.queries.getNodesByFiles(filePaths);
1570
1476
  }
1571
- /**
1572
- * Get all nodes of a specific kind
1573
- */
1574
1477
  getNodesByKind(kind) {
1575
1478
  return this.queries.getNodesByKind(kind);
1576
1479
  }
1577
- /**
1578
- * Get ALL nodes with an exact name (direct index lookup, not FTS-ranked/capped).
1579
- * Used to enumerate every overload of a heavily-overloaded name so the specific
1580
- * definition the caller wants is never dropped below a search cut.
1581
- */
1582
1480
  getNodesByName(name) {
1583
1481
  return this.queries.getNodesByName(name);
1584
1482
  }
1585
- /** Nodes whose name starts with `prefix` (index range scan, capped). */
1586
1483
  getNodesByNamePrefix(prefix, limit = 20) {
1587
1484
  return this.queries.getNodesByNamePrefix(prefix, limit);
1588
1485
  }
1589
- /**
1590
- * Nodes whose name CONTAINS `substring` (LIKE scan, ASCII-case-insensitive,
1591
- * shortest-first). The camel-infix lookup FTS can't do — `profileInfo`
1592
- * inside `getProfileInfoV2` is one FTS token (#1196).
1593
- */
1594
1486
  getNodesByNameSubstring(substring, options = {}) {
1595
1487
  return this.queries
1596
1488
  .findNodesByNameSubstring(substring, options)
1597
1489
  .map((r) => r.node);
1598
1490
  }
1599
- /**
1600
- * Search nodes by text
1601
- */
1602
1491
  searchNodes(query, options) {
1603
1492
  return this.queries.searchNodes(query, options);
1604
1493
  }
1605
- /** Lexical evidence for an empty explore result; does not alter retrieval. */
1606
1494
  getExploreMissDiagnostics(query) {
1607
1495
  return this.queries.getExploreMissDiagnostics(query);
1608
1496
  }
1609
- /**
1610
- * Graph-derived prompt matching for the front-load hook's MEDIUM tier:
1611
- * which indexed symbols do these prose words name? "state machine des
1612
- * commandes" → `OrderStateMachine`, in any human language whose technical
1613
- * nouns are Latin script — no keyword list involved.
1614
- *
1615
- * Precision comes from the repo's own naming statistics, not vocabulary:
1616
- * - CO-OCCURRENCE: ≥2 words that are segments of the SAME name ("state" +
1617
- * "machine" → OrderStateMachine) is strong evidence and always qualifies.
1618
- * - RARITY: a single matched word qualifies only when its segment is
1619
- * discriminative here (≤ {@link SEGMENT_RARITY_CEILING} distinct names) —
1620
- * "checkout" in a shop backend yes, "state" in a react app no.
1621
- * Every candidate is re-verified against `nodes` before being returned
1622
- * (vocab rows are proposals; deletions leave orphans by design), so a
1623
- * returned symbol is guaranteed to exist right now.
1624
- */
1497
+ getUnseenNames(names) {
1498
+ return this.queries.getUnseenNames(names);
1499
+ }
1500
+ findNamedCopybooks(query) {
1501
+ return (0, cobol_copybooks_1.findNamedCopybooks)(this.queries, query);
1502
+ }
1625
1503
  getSegmentMatches(words, limit = 6) {
1626
1504
  if (words.length === 0)
1627
1505
  return [];
1628
- // Variant → original word (plural folding), for coverage accounting.
1629
1506
  const variantToWord = new Map();
1630
1507
  for (const word of words) {
1631
1508
  for (const variant of (0, identifier_segments_1.segmentLookupVariants)(word)) {
@@ -1634,11 +1511,6 @@ class CodeGraph {
1634
1511
  }
1635
1512
  }
1636
1513
  const variants = [...variantToWord.keys()];
1637
- // Tier A: co-occurrence. The SQL folds variants back to their original
1638
- // word (#1146), so minWords=2 means two distinct PROMPT WORDS — a name
1639
- // matching both `service` and `services` can't tie with (or crowd past
1640
- // the LIMIT) a genuine two-word match. The JS re-check below recomputes
1641
- // the fold from live segments as the honesty layer.
1642
1514
  const variantPairs = [...variantToWord.entries()].map(([segment, word]) => ({ segment, word }));
1643
1515
  const candidates = [];
1644
1516
  for (const hit of this.queries.getSegmentCoOccurrence(variantPairs, 2, 24)) {
@@ -1646,16 +1518,6 @@ class CodeGraph {
1646
1518
  if (matched.size >= 2)
1647
1519
  candidates.push({ name: hit.name, matchedWords: matched });
1648
1520
  }
1649
- // Tier B: single rare word. Only when co-occurrence found nothing — a
1650
- // co-occurring name is categorically stronger evidence — and under
1651
- // stricter rules, because one word is thin: the word must be ≥5 chars
1652
- // (measured FPs: "this", "typo"); the segment must appear in AT LEAST TWO
1653
- // names (a concept the codebase is about clusters across names —
1654
- // CheckoutService/CheckoutController — while a prose coincidence is a
1655
- // singleton: measured FP "deploy to PRODUCTION" → the one name
1656
- // matchesNonProductionDir); and the candidate name must have ≥2 segments
1657
- // (a bare common verb matching a bare function name — "write" → `write` —
1658
- // is prose coincidence, not the user naming a symbol).
1659
1521
  if (candidates.length === 0) {
1660
1522
  const singleWordVariants = variants.filter((v) => variantToWord.get(v).length >= 5);
1661
1523
  const counts = this.queries.getSegmentNameCounts(singleWordVariants);
@@ -1672,13 +1534,6 @@ class CodeGraph {
1672
1534
  }
1673
1535
  }
1674
1536
  }
1675
- // Verify against nodes (the honesty gate) and pick a representative
1676
- // definition per name. A name whose only nodes are file/import kind has
1677
- // no real definition to point at — surfacing the import statement instead
1678
- // reads as a matched symbol but isn't one (#1144) — so it's skipped, the
1679
- // same way an orphaned vocab row is. (Import names no longer enter the
1680
- // vocab at write time, but rows written before that exclusion persist
1681
- // until the next full index.)
1682
1537
  const out = [];
1683
1538
  const seen = new Set();
1684
1539
  candidates.sort((a, b) => b.matchedWords.size - a.matchedWords.size || a.name.length - b.name.length);
@@ -1690,10 +1545,10 @@ class CodeGraph {
1690
1545
  seen.add(candidate.name);
1691
1546
  const nodes = this.queries.getNodesByName(candidate.name);
1692
1547
  if (nodes.length === 0)
1693
- continue; // orphaned vocab row — name no longer exists
1548
+ continue;
1694
1549
  const rep = nodes.find((n) => n.kind !== 'file' && n.kind !== 'import');
1695
1550
  if (!rep)
1696
- continue; // no real definition — don't surface an import/file as one
1551
+ continue;
1697
1552
  out.push({
1698
1553
  name: candidate.name,
1699
1554
  kind: rep.kind,
@@ -1704,13 +1559,7 @@ class CodeGraph {
1704
1559
  }
1705
1560
  return out;
1706
1561
  }
1707
- /** A single word ("state") can match hundreds of names in a big repo — that
1708
- * is noise, not signal. Ceiling for the single-word tier; co-occurrence is
1709
- * exempt because two words on one name is already discriminative. */
1710
1562
  static SEGMENT_RARITY_CEILING = 25;
1711
- /** Which of the prompt's original words match `name`'s segments (via
1712
- * variants). Segments are recomputed in JS — a name-keyed vocab lookup
1713
- * would scan the (segment, name) primary key. */
1714
1563
  wordsMatchingName(name, variantToWord) {
1715
1564
  const segments = new Set((0, identifier_segments_1.splitIdentifierSegments)(name));
1716
1565
  const matched = new Set();
@@ -1720,16 +1569,6 @@ class CodeGraph {
1720
1569
  }
1721
1570
  return matched;
1722
1571
  }
1723
- /**
1724
- * One-shot upgrade heal for callers that open the graph WITHOUT syncing —
1725
- * concretely the prompt hook, whose MEDIUM tier reads the segment
1726
- * vocabulary: a database migrated from before the vocab table existed
1727
- * starts with it empty, and the only other backfill lives inside `sync()`,
1728
- * which such callers never run (#1142). Returns true when the vocab is
1729
- * usable (already populated — the overwhelmingly common one-SELECT case —
1730
- * or healed here); false when it isn't (empty graph, or another process
1731
- * holds the index lock — that process's own sync heals it).
1732
- */
1733
1572
  async healSegmentVocabIfEmpty() {
1734
1573
  const empty = (() => {
1735
1574
  try {
@@ -1748,12 +1587,22 @@ class CodeGraph {
1748
1587
  this.fileLock.acquire();
1749
1588
  }
1750
1589
  catch {
1751
- return false; // an index/sync is running — it backfills the vocab itself
1590
+ return false;
1752
1591
  }
1753
1592
  try {
1754
1593
  if (!this.queries.isNameSegmentVocabEmpty())
1755
- return true; // raced: healed meanwhile
1756
- await this.rebuildNameSegmentVocab();
1594
+ return true;
1595
+ if (!this.db.readOnly) {
1596
+ await this.rebuildNameSegmentVocab();
1597
+ return true;
1598
+ }
1599
+ const writer = db_1.DatabaseConnection.open(this.db.getPath());
1600
+ try {
1601
+ await this.rebuildNameSegmentVocab(new queries_1.QueryBuilder(writer.getDb()));
1602
+ }
1603
+ finally {
1604
+ writer.close();
1605
+ }
1757
1606
  return true;
1758
1607
  }
1759
1608
  finally {
@@ -1761,331 +1610,139 @@ class CodeGraph {
1761
1610
  }
1762
1611
  });
1763
1612
  }
1764
- /**
1765
- * Rebuild the segment vocabulary from the current graph, batched and
1766
- * yielding — the upgrade-heal path for indexes built before the vocab table
1767
- * existed. Runs inside the index mutex/lock (sync and
1768
- * healSegmentVocabIfEmpty hold them).
1769
- */
1770
- async rebuildNameSegmentVocab() {
1613
+ async rebuildNameSegmentVocab(queries = this.queries) {
1771
1614
  const maybeYield = (0, cooperative_yield_1.createYielder)();
1772
1615
  const BATCH = 2000;
1773
1616
  for (let offset = 0;; offset += BATCH) {
1774
- const names = this.queries.getDistinctNodeNames(BATCH, offset);
1617
+ const names = queries.getDistinctNodeNames(BATCH, offset);
1775
1618
  if (names.length === 0)
1776
1619
  break;
1777
- this.queries.insertNameSegmentsBatch(names);
1620
+ queries.insertNameSegmentsBatch(names);
1778
1621
  await maybeYield();
1779
1622
  }
1780
1623
  }
1781
- /**
1782
- * Normalized project-name tokens (go.mod / package.json / repo dir) used to
1783
- * down-weight the non-discriminative project name in search ranking (#720).
1784
- * Exposed so explore can exclude it from the PascalCase type-disambiguation
1785
- * bias, which would otherwise pull overloaded tokens toward whichever stack
1786
- * embeds the project name.
1787
- */
1788
1624
  getProjectNameTokens() {
1789
1625
  return this.queries.getProjectNameTokens();
1790
1626
  }
1791
- /**
1792
- * Find the project's "primary route file" — the file with the densest
1793
- * concentration of framework-emitted `route` nodes (≥3 routes, ≥30%
1794
- * of all non-test routes). Used to inline the routing config in
1795
- * `codegraph_explore` responses on small realworld template repos
1796
- * (rails-realworld, laravel-realworld, drupal-admintoolbar, …) where
1797
- * Glob+Read of `routes.rb`/`urls.py`/etc. otherwise beats codegraph.
1798
- */
1799
1627
  getTopRouteFile() {
1800
1628
  return this.queries.getTopRouteFile();
1801
1629
  }
1802
- /**
1803
- * Build a URL → handler routing manifest from the index. Each entry
1804
- * pairs a route node (URL + method) with its handler function/method
1805
- * via the `references` edge that framework resolvers emit. Returns
1806
- * null when fewer than 3 valid (non-test) routes exist.
1807
- */
1808
- getRoutingManifest(limit) {
1809
- return this.queries.getRoutingManifest(limit);
1810
- }
1811
- // ===========================================================================
1812
- // Edge Operations
1813
- // ===========================================================================
1814
- /**
1815
- * Get outgoing edges from a node
1816
- */
1630
+ getRoutingManifest(limit, perRoute) {
1631
+ return this.queries.getRoutingManifest(limit, perRoute);
1632
+ }
1817
1633
  getOutgoingEdges(nodeId) {
1818
1634
  return this.queries.getOutgoingEdges(nodeId);
1819
1635
  }
1820
- /**
1821
- * Get incoming edges to a node
1822
- */
1823
1636
  getIncomingEdges(nodeId) {
1824
1637
  return this.queries.getIncomingEdges(nodeId);
1825
1638
  }
1826
- // ===========================================================================
1827
- // File Operations
1828
- // ===========================================================================
1829
- /**
1830
- * Get a file record by path
1831
- */
1832
1639
  getFile(filePath) {
1833
1640
  return this.queries.getFileByPath(filePath);
1834
1641
  }
1835
- /**
1836
- * Whether the index holds any file under `dir`, a project-relative POSIX
1837
- * directory (e.g. `packages/api`).
1838
- */
1839
1642
  hasFilesUnder(dir) {
1840
1643
  return this.queries.hasFilesUnder(dir);
1841
1644
  }
1842
- /**
1843
- * Get all tracked files
1844
- */
1845
1645
  getFiles() {
1846
1646
  return this.queries.getAllFiles();
1847
1647
  }
1848
- /**
1849
- * A `(path) => boolean` generated-file test over a BOUNDED candidate list,
1850
- * unioning the index-time content-banner flag with the filename convention
1851
- * (#1500). One query up front, O(1) per call after — built for use inside a
1852
- * ranking comparator, where re-querying per comparison would be quadratic.
1853
- *
1854
- * Pass every path you might ask about; a path outside the list falls back to
1855
- * the filename check alone.
1856
- */
1857
1648
  generatedFilePredicate(filePaths) {
1858
1649
  return this.queries.generatedPredicateFor(filePaths);
1859
1650
  }
1860
- /**
1861
- * A `(path) => boolean` ambient-declaration test over a BOUNDED candidate
1862
- * list: true for a file that declares nothing but types, originates no call
1863
- * edge, and that nothing in the index depends on — an ambient `.d.ts` of
1864
- * global shims, vendored typings, module augmentation (CG-28). Structural
1865
- * rather than extension-based, and deliberately narrow: see
1866
- * `QueryBuilder.getAmbientDeclarationPathsAmong` for why each condition is
1867
- * there, in particular why a `types.ts` the codebase imports is NOT flagged.
1868
- */
1869
1651
  ambientDeclarationFilePredicate(filePaths) {
1870
1652
  return this.queries.ambientDeclarationPredicateFor(filePaths);
1871
1653
  }
1872
- /** How many indexed files are flagged tool-generated. Reported by `status`. */
1873
1654
  getGeneratedFileCount() {
1874
1655
  return this.queries.countGeneratedFiles();
1875
1656
  }
1876
- // ===========================================================================
1877
- // Graph Query Methods
1878
- // ===========================================================================
1879
- /**
1880
- * Get the context for a node (ancestors, children, references)
1881
- *
1882
- * Returns comprehensive context about a node including its containment
1883
- * hierarchy, children, incoming/outgoing references, type information,
1884
- * and relevant imports.
1885
- *
1886
- * @param nodeId - ID of the focal node
1887
- * @returns Context object with all related information
1888
- */
1657
+ getIndexHealth() {
1658
+ const needsReindex = [];
1659
+ const parseErrors = [];
1660
+ for (const file of this.queries.getFilesWithoutNodesOrWithErrors()) {
1661
+ const errors = file.errors ?? [];
1662
+ if ((0, grammars_1.hasGrammarLoadFailure)(errors)) {
1663
+ needsReindex.push(file.path);
1664
+ }
1665
+ else if (file.nodeCount === 0) {
1666
+ if ((0, grammars_1.isFileLevelOnlyLanguage)(file.language))
1667
+ continue;
1668
+ if (errors.length === 0)
1669
+ needsReindex.push(file.path);
1670
+ else if (errors.some((e) => e.severity === 'error' || e.code === 'parse_error'))
1671
+ parseErrors.push(file.path);
1672
+ }
1673
+ else if (errors.some((e) => e.code === 'parse_error')) {
1674
+ parseErrors.push(file.path);
1675
+ }
1676
+ }
1677
+ return { needsReindex, parseErrors };
1678
+ }
1679
+ getLanguageCoverage() {
1680
+ const parsedFilesByLanguage = {};
1681
+ const unparsedLanguages = [];
1682
+ for (const { language, parsed } of this.queries.getParsedFileCounts()) {
1683
+ if (!(0, grammars_1.yieldsSymbols)(language))
1684
+ continue;
1685
+ parsedFilesByLanguage[language] = parsed;
1686
+ if (parsed === 0)
1687
+ unparsedLanguages.push(language);
1688
+ }
1689
+ return { parsedFilesByLanguage, unparsedLanguages };
1690
+ }
1889
1691
  getContext(nodeId) {
1890
1692
  return this.graphManager.getContext(nodeId);
1891
1693
  }
1892
- /**
1893
- * Traverse the graph from a starting node
1894
- *
1895
- * Uses breadth-first search by default. Supports filtering by edge types,
1896
- * node types, and traversal direction.
1897
- *
1898
- * @param startId - Starting node ID
1899
- * @param options - Traversal options
1900
- * @returns Subgraph containing traversed nodes and edges
1901
- */
1902
1694
  traverse(startId, options) {
1903
1695
  return this.traverser.traverseBFS(startId, options);
1904
1696
  }
1905
- /**
1906
- * Get the call graph for a function
1907
- *
1908
- * Returns both callers (functions that call this function) and
1909
- * callees (functions called by this function) up to the specified depth.
1910
- *
1911
- * @param nodeId - ID of the function/method node
1912
- * @param depth - Maximum depth in each direction (default: 2)
1913
- * @returns Subgraph containing the call graph
1914
- */
1915
1697
  getCallGraph(nodeId, depth = 2) {
1916
1698
  return this.traverser.getCallGraph(nodeId, depth);
1917
1699
  }
1918
- /**
1919
- * Get the type hierarchy for a class/interface
1920
- *
1921
- * Returns both ancestors (types this extends/implements) and
1922
- * descendants (types that extend/implement this).
1923
- *
1924
- * @param nodeId - ID of the class/interface node
1925
- * @returns Subgraph containing the type hierarchy
1926
- */
1927
1700
  getTypeHierarchy(nodeId) {
1928
1701
  return this.traverser.getTypeHierarchy(nodeId);
1929
1702
  }
1930
- /**
1931
- * Find all usages of a symbol
1932
- *
1933
- * Returns all nodes that reference the specified symbol through
1934
- * any edge type (calls, references, type_of, etc.).
1935
- *
1936
- * @param nodeId - ID of the symbol node
1937
- * @returns Array of nodes and edges that reference this symbol
1938
- */
1939
1703
  findUsages(nodeId) {
1940
1704
  return this.traverser.findUsages(nodeId);
1941
1705
  }
1942
- /**
1943
- * Get callers of a function/method
1944
- *
1945
- * @param nodeId - ID of the function/method node
1946
- * @param maxDepth - Maximum depth to traverse (default: 1)
1947
- * @returns Array of nodes that call this function
1948
- */
1949
1706
  getCallers(nodeId, maxDepth = 1) {
1950
1707
  return this.traverser.getCallers(nodeId, maxDepth);
1951
1708
  }
1952
- /**
1953
- * Get callees of a function/method
1954
- *
1955
- * @param nodeId - ID of the function/method node
1956
- * @param maxDepth - Maximum depth to traverse (default: 1)
1957
- * @returns Array of nodes called by this function
1958
- */
1959
1709
  getCallees(nodeId, maxDepth = 1) {
1960
1710
  return this.traverser.getCallees(nodeId, maxDepth);
1961
1711
  }
1962
- /**
1963
- * Calculate the impact radius of a node
1964
- *
1965
- * Returns all nodes that could be affected by changes to this node.
1966
- *
1967
- * @param nodeId - ID of the node
1968
- * @param maxDepth - Maximum depth to traverse (default: 3)
1969
- * @returns Subgraph containing potentially impacted nodes
1970
- */
1971
- getImpactRadius(nodeId, maxDepth = 3) {
1972
- return this.traverser.getImpactRadius(nodeId, maxDepth);
1973
- }
1974
- /**
1975
- * Find the shortest path between two nodes
1976
- *
1977
- * @param fromId - Starting node ID
1978
- * @param toId - Target node ID
1979
- * @param edgeKinds - Edge types to consider (all if empty)
1980
- * @returns Array of nodes and edges forming the path, or null if no path exists
1981
- */
1712
+ getCallSites(nodeId, direction) {
1713
+ return this.traverser.getCallSites(nodeId, direction);
1714
+ }
1715
+ getImpactRadius(nodeId, maxDepth = 3, options = {}) {
1716
+ return this.traverser.getImpactRadius(nodeId, maxDepth, options);
1717
+ }
1982
1718
  findPath(fromId, toId, edgeKinds) {
1983
1719
  return this.traverser.findPath(fromId, toId, edgeKinds);
1984
1720
  }
1985
- /**
1986
- * Get ancestors of a node in the containment hierarchy
1987
- *
1988
- * @param nodeId - ID of the node
1989
- * @returns Array of ancestor nodes from immediate parent to root
1990
- */
1991
1721
  getAncestors(nodeId) {
1992
1722
  return this.traverser.getAncestors(nodeId);
1993
1723
  }
1994
- /**
1995
- * Get immediate children of a node
1996
- *
1997
- * @param nodeId - ID of the node
1998
- * @returns Array of child nodes
1999
- */
2000
1724
  getChildren(nodeId) {
2001
1725
  return this.traverser.getChildren(nodeId);
2002
1726
  }
2003
- /**
2004
- * Get dependencies of a file
2005
- *
2006
- * @param filePath - Path to the file
2007
- * @returns Array of file paths this file depends on
2008
- */
2009
1727
  getFileDependencies(filePath) {
2010
1728
  return this.graphManager.getFileDependencies(filePath);
2011
1729
  }
2012
- /**
2013
- * Get dependents of a file
2014
- *
2015
- * @param filePath - Path to the file
2016
- * @returns Array of file paths that depend on this file
2017
- */
2018
- getFileDependents(filePath) {
2019
- return this.graphManager.getFileDependents(filePath);
2020
- }
2021
- /**
2022
- * Find circular dependencies in the codebase
2023
- *
2024
- * @returns Array of cycles, each cycle is an array of file paths
2025
- */
1730
+ getFileDependents(filePath, opts = {}) {
1731
+ return this.graphManager.getFileDependents(filePath, opts);
1732
+ }
2026
1733
  findCircularDependencies() {
2027
1734
  return this.graphManager.findCircularDependencies();
2028
1735
  }
2029
- /**
2030
- * Find unreferenced symbols — the RAW candidate set.
2031
- *
2032
- * Non-exported symbols of the given kinds with no incoming edge but
2033
- * `contains`. That is a fact, not a claim: on this engine's own index it
2034
- * returns ~2 500 symbols, of which about 20 are actually unreachable. The
2035
- * rest are overrides, framework registrations, mis-resolved twins and
2036
- * references the extractor never recorded.
2037
- *
2038
- * For a list anybody should act on, use `buildDeadCodeReport` from
2039
- * `src/graph/dead-code.ts`, which applies the exclusions and counts every one
2040
- * of them. This method is kept as-is because it is a published API.
2041
- *
2042
- * @param kinds - Node kinds to check (default: functions, methods, classes)
2043
- * @returns Array of unreferenced nodes
2044
- */
2045
1736
  findDeadCode(kinds) {
2046
1737
  return this.graphManager.findDeadCode(kinds);
2047
1738
  }
2048
- /**
2049
- * Get complexity metrics for a node
2050
- *
2051
- * @param nodeId - ID of the node
2052
- * @returns Object containing various complexity metrics
2053
- */
2054
1739
  getNodeMetrics(nodeId) {
2055
1740
  return this.graphManager.getNodeMetrics(nodeId);
2056
1741
  }
2057
- // ===========================================================================
2058
- // Context Building
2059
- // ===========================================================================
2060
- /**
2061
- * Get the source code for a node
2062
- *
2063
- * Reads the file and extracts the code between startLine and endLine.
2064
- *
2065
- * @param nodeId - ID of the node
2066
- * @returns Code string or null if not found
2067
- */
2068
1742
  async getCode(nodeId) {
2069
1743
  return this.contextBuilder.getCode(nodeId);
2070
1744
  }
2071
- /**
2072
- * Find relevant subgraph for a query
2073
- *
2074
- * Combines semantic search with graph traversal to find the most
2075
- * relevant nodes and their relationships for a given query.
2076
- *
2077
- * @param query - Natural language query describing the task
2078
- * @param options - Search and traversal options
2079
- * @returns Subgraph of relevant nodes and edges
2080
- */
2081
1745
  async findRelevantContext(query, options) {
2082
- // Segment-vocab supplement: FTS keeps camelCase names as single tokens,
2083
- // so a word-level query ("auto-scroll to bottom") can never reach
2084
- // `pinFeedIfNearBottom` through search alone. Resolve the query's words
2085
- // against name_segment_vocab (same precision rules as the prompt hook:
2086
- // co-occurrence, else rare singles, verified against live nodes) and hand
2087
- // the names down as dampened exact-name seeds. Callers that pass their
2088
- // own seedNames keep them; failures degrade to no supplement.
2089
1746
  let seedNames = options?.seedNames;
2090
1747
  if (seedNames === undefined) {
2091
1748
  try {
@@ -2098,56 +1755,23 @@ class CodeGraph {
2098
1755
  }
2099
1756
  return this.contextBuilder.findRelevantContext(query, { ...options, seedNames });
2100
1757
  }
2101
- /**
2102
- * Build context for a task
2103
- *
2104
- * Creates comprehensive context by:
2105
- * 1. Running FTS search to find entry points
2106
- * 2. Expanding the graph around entry points
2107
- * 3. Extracting code blocks for key nodes
2108
- * 4. Formatting output for Claude
2109
- *
2110
- * @param input - Task description (string or {title, description})
2111
- * @param options - Build options (maxNodes, includeCode, format, etc.)
2112
- * @returns TaskContext object or formatted string (markdown/JSON)
2113
- */
2114
1758
  async buildContext(input, options) {
2115
1759
  return this.contextBuilder.buildContext(input, options);
2116
1760
  }
2117
- // ===========================================================================
2118
- // Database Management
2119
- // ===========================================================================
2120
- /**
2121
- * Optimize the database (vacuum and analyze)
2122
- */
2123
1761
  optimize() {
2124
1762
  this.db.optimize();
2125
1763
  }
2126
- /**
2127
- * Clear all data from the graph
2128
- */
2129
1764
  clear() {
2130
1765
  this.queries.clear();
2131
1766
  }
2132
- /**
2133
- * Alias for close() for backwards compatibility.
2134
- * @deprecated Use close() instead
2135
- */
2136
1767
  destroy() {
2137
1768
  this.close();
2138
1769
  }
2139
- /**
2140
- * Completely remove CodeGraph from the project.
2141
- * This closes the database and deletes the .CodeGraph directory.
2142
- *
2143
- * WARNING: This permanently deletes all CodeGraph data for the project.
2144
- */
2145
1770
  uninitialize() {
2146
1771
  this.close();
2147
1772
  (0, directory_1.removeDirectory)(this.projectRoot);
2148
1773
  }
2149
1774
  }
2150
1775
  exports.CodeGraph = CodeGraph;
2151
- // Default export
2152
1776
  exports.default = CodeGraph;
2153
1777
  //# sourceMappingURL=index.js.map