@colbymchenry/codegraph-win32-arm64 1.6.0 → 1.6.2

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 (761) hide show
  1. package/bin/codegraph +5 -0
  2. package/lib/dist/.test-build-engine.json +1 -0
  3. package/lib/dist/.test-build-viewer.json +1 -0
  4. package/lib/dist/bin/codegraph.d.ts +1 -0
  5. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  6. package/lib/dist/bin/codegraph.js +605 -291
  7. package/lib/dist/bin/codegraph.js.map +1 -1
  8. package/lib/dist/bin/command-supervision.d.ts +7 -0
  9. package/lib/dist/bin/command-supervision.d.ts.map +1 -1
  10. package/lib/dist/bin/command-supervision.js +39 -27
  11. package/lib/dist/bin/command-supervision.js.map +1 -1
  12. package/lib/dist/bin/viewer-gate.d.ts +17 -0
  13. package/lib/dist/bin/viewer-gate.d.ts.map +1 -0
  14. package/lib/dist/bin/viewer-gate.js +31 -0
  15. package/lib/dist/bin/viewer-gate.js.map +1 -0
  16. package/lib/dist/context/index.d.ts.map +1 -1
  17. package/lib/dist/context/index.js +43 -2
  18. package/lib/dist/context/index.js.map +1 -1
  19. package/lib/dist/db/index.d.ts +21 -2
  20. package/lib/dist/db/index.d.ts.map +1 -1
  21. package/lib/dist/db/index.js +86 -31
  22. package/lib/dist/db/index.js.map +1 -1
  23. package/lib/dist/db/migrations.d.ts +1 -1
  24. package/lib/dist/db/migrations.d.ts.map +1 -1
  25. package/lib/dist/db/migrations.js +40 -1
  26. package/lib/dist/db/migrations.js.map +1 -1
  27. package/lib/dist/db/queries.d.ts +454 -10
  28. package/lib/dist/db/queries.d.ts.map +1 -1
  29. package/lib/dist/db/queries.js +1080 -41
  30. package/lib/dist/db/queries.js.map +1 -1
  31. package/lib/dist/db/schema.sql +11 -1
  32. package/lib/dist/db/sqlite-adapter.d.ts +2 -0
  33. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  34. package/lib/dist/db/sqlite-adapter.js +56 -7
  35. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  36. package/lib/dist/db/synthesis-stage.d.ts +12 -0
  37. package/lib/dist/db/synthesis-stage.d.ts.map +1 -0
  38. package/lib/dist/db/synthesis-stage.js +89 -0
  39. package/lib/dist/db/synthesis-stage.js.map +1 -0
  40. package/lib/dist/db/wal-valve.d.ts +32 -12
  41. package/lib/dist/db/wal-valve.d.ts.map +1 -1
  42. package/lib/dist/db/wal-valve.js +65 -22
  43. package/lib/dist/db/wal-valve.js.map +1 -1
  44. package/lib/dist/db/wsl-shared-index.d.ts +53 -0
  45. package/lib/dist/db/wsl-shared-index.d.ts.map +1 -0
  46. package/lib/dist/db/wsl-shared-index.js +121 -0
  47. package/lib/dist/db/wsl-shared-index.js.map +1 -0
  48. package/lib/dist/directory.d.ts +131 -2
  49. package/lib/dist/directory.d.ts.map +1 -1
  50. package/lib/dist/directory.js +299 -23
  51. package/lib/dist/directory.js.map +1 -1
  52. package/lib/dist/errors.d.ts +14 -0
  53. package/lib/dist/errors.d.ts.map +1 -1
  54. package/lib/dist/errors.js +16 -1
  55. package/lib/dist/errors.js.map +1 -1
  56. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -1
  57. package/lib/dist/extraction/astro-extractor.js +7 -35
  58. package/lib/dist/extraction/astro-extractor.js.map +1 -1
  59. package/lib/dist/extraction/cfml-extractor.d.ts +77 -10
  60. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
  61. package/lib/dist/extraction/cfml-extractor.js +302 -71
  62. package/lib/dist/extraction/cfml-extractor.js.map +1 -1
  63. package/lib/dist/extraction/commonjs-requires.d.ts +23 -0
  64. package/lib/dist/extraction/commonjs-requires.d.ts.map +1 -0
  65. package/lib/dist/extraction/commonjs-requires.js +68 -0
  66. package/lib/dist/extraction/commonjs-requires.js.map +1 -0
  67. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -1
  68. package/lib/dist/extraction/dfm-extractor.js +14 -10
  69. package/lib/dist/extraction/dfm-extractor.js.map +1 -1
  70. package/lib/dist/extraction/extraction-version.d.ts +1 -1
  71. package/lib/dist/extraction/extraction-version.js +1 -1
  72. package/lib/dist/extraction/function-ref.d.ts +6 -4
  73. package/lib/dist/extraction/function-ref.d.ts.map +1 -1
  74. package/lib/dist/extraction/function-ref.js +35 -14
  75. package/lib/dist/extraction/function-ref.js.map +1 -1
  76. package/lib/dist/extraction/generated-detection.d.ts +9 -0
  77. package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
  78. package/lib/dist/extraction/generated-detection.js +42 -2
  79. package/lib/dist/extraction/generated-detection.js.map +1 -1
  80. package/lib/dist/extraction/grammars.d.ts +40 -0
  81. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  82. package/lib/dist/extraction/grammars.js +171 -1
  83. package/lib/dist/extraction/grammars.js.map +1 -1
  84. package/lib/dist/extraction/index.d.ts +132 -19
  85. package/lib/dist/extraction/index.d.ts.map +1 -1
  86. package/lib/dist/extraction/index.js +825 -195
  87. package/lib/dist/extraction/index.js.map +1 -1
  88. package/lib/dist/extraction/kernel/index.d.ts.map +1 -1
  89. package/lib/dist/extraction/kernel/index.js +6 -0
  90. package/lib/dist/extraction/kernel/index.js.map +1 -1
  91. package/lib/dist/extraction/languages/c-cpp.d.ts +73 -0
  92. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  93. package/lib/dist/extraction/languages/c-cpp.js +412 -16
  94. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  95. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
  96. package/lib/dist/extraction/languages/csharp.js +14 -5
  97. package/lib/dist/extraction/languages/csharp.js.map +1 -1
  98. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  99. package/lib/dist/extraction/languages/dart.js +16 -3
  100. package/lib/dist/extraction/languages/dart.js.map +1 -1
  101. package/lib/dist/extraction/languages/javascript.js +1 -1
  102. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  103. package/lib/dist/extraction/languages/kotlin.d.ts +4 -0
  104. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  105. package/lib/dist/extraction/languages/kotlin.js +237 -36
  106. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  107. package/lib/dist/extraction/languages/lua.d.ts.map +1 -1
  108. package/lib/dist/extraction/languages/lua.js +4 -1
  109. package/lib/dist/extraction/languages/lua.js.map +1 -1
  110. package/lib/dist/extraction/languages/python.d.ts.map +1 -1
  111. package/lib/dist/extraction/languages/python.js +71 -0
  112. package/lib/dist/extraction/languages/python.js.map +1 -1
  113. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  114. package/lib/dist/extraction/languages/rust.js +3 -0
  115. package/lib/dist/extraction/languages/rust.js.map +1 -1
  116. package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
  117. package/lib/dist/extraction/languages/scala.js +18 -3
  118. package/lib/dist/extraction/languages/scala.js.map +1 -1
  119. package/lib/dist/extraction/languages/swift.d.ts +15 -0
  120. package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
  121. package/lib/dist/extraction/languages/swift.js +50 -0
  122. package/lib/dist/extraction/languages/swift.js.map +1 -1
  123. package/lib/dist/extraction/languages/typescript.d.ts +7 -0
  124. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  125. package/lib/dist/extraction/languages/typescript.js +30 -2
  126. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  127. package/lib/dist/extraction/liquid-extractor.d.ts +18 -0
  128. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  129. package/lib/dist/extraction/liquid-extractor.js +98 -22
  130. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  131. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -1
  132. package/lib/dist/extraction/mybatis-extractor.js +6 -4
  133. package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
  134. package/lib/dist/extraction/parse-budget.d.ts +16 -0
  135. package/lib/dist/extraction/parse-budget.d.ts.map +1 -0
  136. package/lib/dist/extraction/parse-budget.js +24 -0
  137. package/lib/dist/extraction/parse-budget.js.map +1 -0
  138. package/lib/dist/extraction/parse-pool.d.ts +12 -0
  139. package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
  140. package/lib/dist/extraction/parse-pool.js +51 -3
  141. package/lib/dist/extraction/parse-pool.js.map +1 -1
  142. package/lib/dist/extraction/parse-worker.js +3 -1
  143. package/lib/dist/extraction/parse-worker.js.map +1 -1
  144. package/lib/dist/extraction/sfc-script.d.ts +43 -0
  145. package/lib/dist/extraction/sfc-script.d.ts.map +1 -0
  146. package/lib/dist/extraction/sfc-script.js +135 -0
  147. package/lib/dist/extraction/sfc-script.js.map +1 -0
  148. package/lib/dist/extraction/store-worker.js +5 -0
  149. package/lib/dist/extraction/store-worker.js.map +1 -1
  150. package/lib/dist/extraction/store-writer.d.ts +10 -2
  151. package/lib/dist/extraction/store-writer.d.ts.map +1 -1
  152. package/lib/dist/extraction/store-writer.js +12 -4
  153. package/lib/dist/extraction/store-writer.js.map +1 -1
  154. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
  155. package/lib/dist/extraction/svelte-extractor.js +7 -37
  156. package/lib/dist/extraction/svelte-extractor.js.map +1 -1
  157. package/lib/dist/extraction/syntax-tokens.d.ts +103 -0
  158. package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -0
  159. package/lib/dist/extraction/syntax-tokens.js +382 -0
  160. package/lib/dist/extraction/syntax-tokens.js.map +1 -0
  161. package/lib/dist/extraction/tree-sitter-helpers.d.ts +5 -0
  162. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  163. package/lib/dist/extraction/tree-sitter-helpers.js +17 -0
  164. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  165. package/lib/dist/extraction/tree-sitter-types.d.ts +29 -3
  166. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  167. package/lib/dist/extraction/tree-sitter.d.ts +104 -17
  168. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  169. package/lib/dist/extraction/tree-sitter.js +943 -88
  170. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  171. package/lib/dist/extraction/vue-extractor.d.ts +7 -0
  172. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
  173. package/lib/dist/extraction/vue-extractor.js +73 -35
  174. package/lib/dist/extraction/vue-extractor.js.map +1 -1
  175. package/lib/dist/extraction/vue-options-api.d.ts +28 -0
  176. package/lib/dist/extraction/vue-options-api.d.ts.map +1 -0
  177. package/lib/dist/extraction/vue-options-api.js +196 -0
  178. package/lib/dist/extraction/vue-options-api.js.map +1 -0
  179. package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  180. package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  181. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  182. package/lib/dist/file-limits.d.ts +40 -0
  183. package/lib/dist/file-limits.d.ts.map +1 -0
  184. package/lib/dist/file-limits.js +147 -0
  185. package/lib/dist/file-limits.js.map +1 -0
  186. package/lib/dist/graph/branch-guards.d.ts +265 -0
  187. package/lib/dist/graph/branch-guards.d.ts.map +1 -0
  188. package/lib/dist/graph/branch-guards.js +2326 -0
  189. package/lib/dist/graph/branch-guards.js.map +1 -0
  190. package/lib/dist/graph/dead-code.d.ts +251 -0
  191. package/lib/dist/graph/dead-code.d.ts.map +1 -0
  192. package/lib/dist/graph/dead-code.js +776 -0
  193. package/lib/dist/graph/dead-code.js.map +1 -0
  194. package/lib/dist/graph/dynamic-boundary-report.d.ts +121 -0
  195. package/lib/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  196. package/lib/dist/graph/dynamic-boundary-report.js +283 -0
  197. package/lib/dist/graph/dynamic-boundary-report.js.map +1 -0
  198. package/lib/dist/graph/index.d.ts +4 -0
  199. package/lib/dist/graph/index.d.ts.map +1 -1
  200. package/lib/dist/graph/index.js +16 -1
  201. package/lib/dist/graph/index.js.map +1 -1
  202. package/lib/dist/graph/named-symbol-flow.d.ts +125 -0
  203. package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -0
  204. package/lib/dist/graph/named-symbol-flow.js +559 -0
  205. package/lib/dist/graph/named-symbol-flow.js.map +1 -0
  206. package/lib/dist/graph/symbol-lookup.d.ts +83 -0
  207. package/lib/dist/graph/symbol-lookup.d.ts.map +1 -0
  208. package/lib/dist/graph/symbol-lookup.js +181 -0
  209. package/lib/dist/graph/symbol-lookup.js.map +1 -0
  210. package/lib/dist/graph/traversal.d.ts +9 -0
  211. package/lib/dist/graph/traversal.d.ts.map +1 -1
  212. package/lib/dist/graph/traversal.js +61 -35
  213. package/lib/dist/graph/traversal.js.map +1 -1
  214. package/lib/dist/graph/type-hierarchy.d.ts +155 -0
  215. package/lib/dist/graph/type-hierarchy.d.ts.map +1 -0
  216. package/lib/dist/graph/type-hierarchy.js +382 -0
  217. package/lib/dist/graph/type-hierarchy.js.map +1 -0
  218. package/lib/dist/index.d.ts +256 -11
  219. package/lib/dist/index.d.ts.map +1 -1
  220. package/lib/dist/index.js +402 -34
  221. package/lib/dist/index.js.map +1 -1
  222. package/lib/dist/installer/index.d.ts.map +1 -1
  223. package/lib/dist/installer/index.js +3 -2
  224. package/lib/dist/installer/index.js.map +1 -1
  225. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -1
  226. package/lib/dist/installer/targets/antigravity.js +14 -2
  227. package/lib/dist/installer/targets/antigravity.js.map +1 -1
  228. package/lib/dist/installer/targets/claude.d.ts +3 -0
  229. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  230. package/lib/dist/installer/targets/claude.js +35 -7
  231. package/lib/dist/installer/targets/claude.js.map +1 -1
  232. package/lib/dist/installer/targets/codex.d.ts +2 -1
  233. package/lib/dist/installer/targets/codex.d.ts.map +1 -1
  234. package/lib/dist/installer/targets/codex.js +14 -4
  235. package/lib/dist/installer/targets/codex.js.map +1 -1
  236. package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
  237. package/lib/dist/installer/targets/copilot-cli.js +7 -1
  238. package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
  239. package/lib/dist/installer/targets/opencode.d.ts +16 -5
  240. package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
  241. package/lib/dist/installer/targets/opencode.js +73 -22
  242. package/lib/dist/installer/targets/opencode.js.map +1 -1
  243. package/lib/dist/installer/targets/shared.d.ts +14 -3
  244. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  245. package/lib/dist/installer/targets/shared.js +39 -11
  246. package/lib/dist/installer/targets/shared.js.map +1 -1
  247. package/lib/dist/installer/targets/types.d.ts +7 -0
  248. package/lib/dist/installer/targets/types.d.ts.map +1 -1
  249. package/lib/dist/mcp/answer-freshness.d.ts +10 -0
  250. package/lib/dist/mcp/answer-freshness.d.ts.map +1 -0
  251. package/lib/dist/mcp/answer-freshness.js +68 -0
  252. package/lib/dist/mcp/answer-freshness.js.map +1 -0
  253. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -1
  254. package/lib/dist/mcp/daemon-manager.js +16 -0
  255. package/lib/dist/mcp/daemon-manager.js.map +1 -1
  256. package/lib/dist/mcp/daemon-paths.d.ts +2 -0
  257. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
  258. package/lib/dist/mcp/daemon-paths.js +20 -5
  259. package/lib/dist/mcp/daemon-paths.js.map +1 -1
  260. package/lib/dist/mcp/daemon-registry.d.ts +11 -4
  261. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
  262. package/lib/dist/mcp/daemon-registry.js +132 -36
  263. package/lib/dist/mcp/daemon-registry.js.map +1 -1
  264. package/lib/dist/mcp/daemon.d.ts +17 -7
  265. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  266. package/lib/dist/mcp/daemon.js +116 -24
  267. package/lib/dist/mcp/daemon.js.map +1 -1
  268. package/lib/dist/mcp/dynamic-boundaries.d.ts +1 -10
  269. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
  270. package/lib/dist/mcp/dynamic-boundaries.js +46 -42
  271. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
  272. package/lib/dist/mcp/engine.d.ts +30 -9
  273. package/lib/dist/mcp/engine.d.ts.map +1 -1
  274. package/lib/dist/mcp/engine.js +158 -66
  275. package/lib/dist/mcp/engine.js.map +1 -1
  276. package/lib/dist/mcp/explore-dedup.d.ts +5 -2
  277. package/lib/dist/mcp/explore-dedup.d.ts.map +1 -1
  278. package/lib/dist/mcp/explore-dedup.js +8 -5
  279. package/lib/dist/mcp/explore-dedup.js.map +1 -1
  280. package/lib/dist/mcp/index-freshness-worker.d.ts +2 -0
  281. package/lib/dist/mcp/index-freshness-worker.d.ts.map +1 -0
  282. package/lib/dist/mcp/index-freshness-worker.js +36 -0
  283. package/lib/dist/mcp/index-freshness-worker.js.map +1 -0
  284. package/lib/dist/mcp/index-freshness.d.ts +13 -0
  285. package/lib/dist/mcp/index-freshness.d.ts.map +1 -0
  286. package/lib/dist/mcp/index-freshness.js +117 -0
  287. package/lib/dist/mcp/index-freshness.js.map +1 -0
  288. package/lib/dist/mcp/index.d.ts +3 -1
  289. package/lib/dist/mcp/index.d.ts.map +1 -1
  290. package/lib/dist/mcp/index.js +95 -11
  291. package/lib/dist/mcp/index.js.map +1 -1
  292. package/lib/dist/mcp/liveness-watchdog.d.ts +4 -1
  293. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  294. package/lib/dist/mcp/liveness-watchdog.js +11 -2
  295. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  296. package/lib/dist/mcp/project-lifecycle.d.ts +9 -0
  297. package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -0
  298. package/lib/dist/mcp/project-lifecycle.js +182 -0
  299. package/lib/dist/mcp/project-lifecycle.js.map +1 -0
  300. package/lib/dist/mcp/proxy.d.ts +9 -2
  301. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  302. package/lib/dist/mcp/proxy.js +201 -32
  303. package/lib/dist/mcp/proxy.js.map +1 -1
  304. package/lib/dist/mcp/query-pool.d.ts +18 -3
  305. package/lib/dist/mcp/query-pool.d.ts.map +1 -1
  306. package/lib/dist/mcp/query-pool.js +67 -11
  307. package/lib/dist/mcp/query-pool.js.map +1 -1
  308. package/lib/dist/mcp/query-worker.js +2 -2
  309. package/lib/dist/mcp/query-worker.js.map +1 -1
  310. package/lib/dist/mcp/server-instructions.d.ts +1 -1
  311. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  312. package/lib/dist/mcp/server-instructions.js +6 -3
  313. package/lib/dist/mcp/server-instructions.js.map +1 -1
  314. package/lib/dist/mcp/startup-handshake.d.ts +3 -1
  315. package/lib/dist/mcp/startup-handshake.d.ts.map +1 -1
  316. package/lib/dist/mcp/startup-handshake.js +10 -2
  317. package/lib/dist/mcp/startup-handshake.js.map +1 -1
  318. package/lib/dist/mcp/tools.d.ts +306 -36
  319. package/lib/dist/mcp/tools.d.ts.map +1 -1
  320. package/lib/dist/mcp/tools.js +2395 -966
  321. package/lib/dist/mcp/tools.js.map +1 -1
  322. package/lib/dist/mcp/writer-lock.d.ts +61 -0
  323. package/lib/dist/mcp/writer-lock.d.ts.map +1 -0
  324. package/lib/dist/mcp/writer-lock.js +260 -0
  325. package/lib/dist/mcp/writer-lock.js.map +1 -0
  326. package/lib/dist/resolution/alias-binding.d.ts +56 -0
  327. package/lib/dist/resolution/alias-binding.d.ts.map +1 -0
  328. package/lib/dist/resolution/alias-binding.js +143 -0
  329. package/lib/dist/resolution/alias-binding.js.map +1 -0
  330. package/lib/dist/resolution/angular-template-synthesizer.d.ts +49 -0
  331. package/lib/dist/resolution/angular-template-synthesizer.d.ts.map +1 -0
  332. package/lib/dist/resolution/angular-template-synthesizer.js +359 -0
  333. package/lib/dist/resolution/angular-template-synthesizer.js.map +1 -0
  334. package/lib/dist/resolution/callback-synthesizer.d.ts +23 -1
  335. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  336. package/lib/dist/resolution/callback-synthesizer.js +460 -144
  337. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  338. package/lib/dist/resolution/cpp-constructor.d.ts +4 -0
  339. package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -0
  340. package/lib/dist/resolution/cpp-constructor.js +123 -0
  341. package/lib/dist/resolution/cpp-constructor.js.map +1 -0
  342. package/lib/dist/resolution/cpp-macro-visibility.d.ts +12 -0
  343. package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -0
  344. package/lib/dist/resolution/cpp-macro-visibility.js +392 -0
  345. package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -0
  346. package/lib/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  347. package/lib/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  348. package/lib/dist/resolution/expo-router-synthesizer.js +189 -0
  349. package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -0
  350. package/lib/dist/resolution/frameworks/angular-router.d.ts +142 -0
  351. package/lib/dist/resolution/frameworks/angular-router.d.ts.map +1 -0
  352. package/lib/dist/resolution/frameworks/angular-router.js +1126 -0
  353. package/lib/dist/resolution/frameworks/angular-router.js.map +1 -0
  354. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -1
  355. package/lib/dist/resolution/frameworks/astro.js +32 -6
  356. package/lib/dist/resolution/frameworks/astro.js.map +1 -1
  357. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  358. package/lib/dist/resolution/frameworks/csharp.js +186 -24
  359. package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
  360. package/lib/dist/resolution/frameworks/expo-modules.d.ts +10 -0
  361. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
  362. package/lib/dist/resolution/frameworks/expo-modules.js +95 -1
  363. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
  364. package/lib/dist/resolution/frameworks/expo-router.d.ts +195 -0
  365. package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  366. package/lib/dist/resolution/frameworks/expo-router.js +847 -0
  367. package/lib/dist/resolution/frameworks/expo-router.js.map +1 -0
  368. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
  369. package/lib/dist/resolution/frameworks/express.js +339 -45
  370. package/lib/dist/resolution/frameworks/express.js.map +1 -1
  371. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -1
  372. package/lib/dist/resolution/frameworks/fabric.js +13 -11
  373. package/lib/dist/resolution/frameworks/fabric.js.map +1 -1
  374. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
  375. package/lib/dist/resolution/frameworks/go.js +11 -28
  376. package/lib/dist/resolution/frameworks/go.js.map +1 -1
  377. package/lib/dist/resolution/frameworks/index.d.ts +8 -2
  378. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  379. package/lib/dist/resolution/frameworks/index.js +39 -1
  380. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  381. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
  382. package/lib/dist/resolution/frameworks/java.js +88 -68
  383. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  384. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
  385. package/lib/dist/resolution/frameworks/laravel.js +369 -26
  386. package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
  387. package/lib/dist/resolution/frameworks/name-heuristic.d.ts +35 -0
  388. package/lib/dist/resolution/frameworks/name-heuristic.d.ts.map +1 -0
  389. package/lib/dist/resolution/frameworks/name-heuristic.js +45 -0
  390. package/lib/dist/resolution/frameworks/name-heuristic.js.map +1 -0
  391. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  392. package/lib/dist/resolution/frameworks/nestjs.js +288 -55
  393. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
  394. package/lib/dist/resolution/frameworks/nextjs.d.ts +76 -0
  395. package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  396. package/lib/dist/resolution/frameworks/nextjs.js +329 -0
  397. package/lib/dist/resolution/frameworks/nextjs.js.map +1 -0
  398. package/lib/dist/resolution/frameworks/object-literal.d.ts +32 -0
  399. package/lib/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  400. package/lib/dist/resolution/frameworks/object-literal.js +139 -0
  401. package/lib/dist/resolution/frameworks/object-literal.js.map +1 -0
  402. package/lib/dist/resolution/frameworks/package-deps.d.ts +14 -0
  403. package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  404. package/lib/dist/resolution/frameworks/package-deps.js +78 -0
  405. package/lib/dist/resolution/frameworks/package-deps.js.map +1 -0
  406. package/lib/dist/resolution/frameworks/page-component.d.ts +20 -0
  407. package/lib/dist/resolution/frameworks/page-component.d.ts.map +1 -0
  408. package/lib/dist/resolution/frameworks/page-component.js +45 -0
  409. package/lib/dist/resolution/frameworks/page-component.js.map +1 -0
  410. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -1
  411. package/lib/dist/resolution/frameworks/play.js +3 -1
  412. package/lib/dist/resolution/frameworks/play.js.map +1 -1
  413. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  414. package/lib/dist/resolution/frameworks/python.js +279 -26
  415. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  416. package/lib/dist/resolution/frameworks/react-native.d.ts +26 -0
  417. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  418. package/lib/dist/resolution/frameworks/react-native.js +153 -14
  419. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  420. package/lib/dist/resolution/frameworks/react-router.d.ts +47 -0
  421. package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  422. package/lib/dist/resolution/frameworks/react-router.js +201 -0
  423. package/lib/dist/resolution/frameworks/react-router.js.map +1 -0
  424. package/lib/dist/resolution/frameworks/react.d.ts +13 -2
  425. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  426. package/lib/dist/resolution/frameworks/react.js +542 -144
  427. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  428. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -1
  429. package/lib/dist/resolution/frameworks/ruby.js +177 -17
  430. package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
  431. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
  432. package/lib/dist/resolution/frameworks/rust.js +24 -22
  433. package/lib/dist/resolution/frameworks/rust.js.map +1 -1
  434. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
  435. package/lib/dist/resolution/frameworks/svelte.js +14 -6
  436. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  437. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  438. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  439. package/lib/dist/resolution/frameworks/sveltekit-router.js +156 -0
  440. package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  441. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
  442. package/lib/dist/resolution/frameworks/swift.js +253 -124
  443. package/lib/dist/resolution/frameworks/swift.js.map +1 -1
  444. package/lib/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  445. package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  446. package/lib/dist/resolution/frameworks/tanstack-router.js +437 -0
  447. package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  448. package/lib/dist/resolution/frameworks/vue-router.d.ts +98 -0
  449. package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  450. package/lib/dist/resolution/frameworks/vue-router.js +500 -0
  451. package/lib/dist/resolution/frameworks/vue-router.js.map +1 -0
  452. package/lib/dist/resolution/frameworks/vue.d.ts +9 -2
  453. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -1
  454. package/lib/dist/resolution/frameworks/vue.js +45 -11
  455. package/lib/dist/resolution/frameworks/vue.js.map +1 -1
  456. package/lib/dist/resolution/import-resolver.d.ts +66 -0
  457. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  458. package/lib/dist/resolution/import-resolver.js +643 -61
  459. package/lib/dist/resolution/import-resolver.js.map +1 -1
  460. package/lib/dist/resolution/index.d.ts +124 -25
  461. package/lib/dist/resolution/index.d.ts.map +1 -1
  462. package/lib/dist/resolution/index.js +769 -152
  463. package/lib/dist/resolution/index.js.map +1 -1
  464. package/lib/dist/resolution/js-builtins.d.ts +13 -0
  465. package/lib/dist/resolution/js-builtins.d.ts.map +1 -0
  466. package/lib/dist/resolution/js-builtins.js +48 -0
  467. package/lib/dist/resolution/js-builtins.js.map +1 -0
  468. package/lib/dist/resolution/name-matcher.d.ts +101 -22
  469. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  470. package/lib/dist/resolution/name-matcher.js +8267 -287
  471. package/lib/dist/resolution/name-matcher.js.map +1 -1
  472. package/lib/dist/resolution/next-router-synthesizer.d.ts +27 -0
  473. package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  474. package/lib/dist/resolution/next-router-synthesizer.js +113 -0
  475. package/lib/dist/resolution/next-router-synthesizer.js.map +1 -0
  476. package/lib/dist/resolution/react-router-synthesizer.d.ts +35 -0
  477. package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  478. package/lib/dist/resolution/react-router-synthesizer.js +197 -0
  479. package/lib/dist/resolution/react-router-synthesizer.js.map +1 -0
  480. package/lib/dist/resolution/resolver-pool.d.ts +22 -1
  481. package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
  482. package/lib/dist/resolution/resolver-pool.js +35 -5
  483. package/lib/dist/resolution/resolver-pool.js.map +1 -1
  484. package/lib/dist/resolution/resolver-worker.js +3 -0
  485. package/lib/dist/resolution/resolver-worker.js.map +1 -1
  486. package/lib/dist/resolution/strip-comments.d.ts +6 -0
  487. package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
  488. package/lib/dist/resolution/strip-comments.js +58 -0
  489. package/lib/dist/resolution/strip-comments.js.map +1 -1
  490. package/lib/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  491. package/lib/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  492. package/lib/dist/resolution/sveltekit-synthesizer.js +173 -0
  493. package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  494. package/lib/dist/resolution/swift-type-visibility.d.ts +68 -0
  495. package/lib/dist/resolution/swift-type-visibility.d.ts.map +1 -0
  496. package/lib/dist/resolution/swift-type-visibility.js +454 -0
  497. package/lib/dist/resolution/swift-type-visibility.js.map +1 -0
  498. package/lib/dist/resolution/synth-utils.d.ts +26 -0
  499. package/lib/dist/resolution/synth-utils.d.ts.map +1 -0
  500. package/lib/dist/resolution/synth-utils.js +75 -0
  501. package/lib/dist/resolution/synth-utils.js.map +1 -0
  502. package/lib/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  503. package/lib/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  504. package/lib/dist/resolution/tanstack-router-synthesizer.js +114 -0
  505. package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  506. package/lib/dist/resolution/tier-synthesizer.d.ts +54 -0
  507. package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  508. package/lib/dist/resolution/tier-synthesizer.js +1294 -0
  509. package/lib/dist/resolution/tier-synthesizer.js.map +1 -0
  510. package/lib/dist/resolution/type-parameters.d.ts +11 -0
  511. package/lib/dist/resolution/type-parameters.d.ts.map +1 -0
  512. package/lib/dist/resolution/type-parameters.js +287 -0
  513. package/lib/dist/resolution/type-parameters.js.map +1 -0
  514. package/lib/dist/resolution/types.d.ts +105 -2
  515. package/lib/dist/resolution/types.d.ts.map +1 -1
  516. package/lib/dist/resolution/types.js +64 -0
  517. package/lib/dist/resolution/types.js.map +1 -1
  518. package/lib/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  519. package/lib/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  520. package/lib/dist/resolution/vue-router-synthesizer.js +115 -0
  521. package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -0
  522. package/lib/dist/search/query-paths.d.ts +50 -1
  523. package/lib/dist/search/query-paths.d.ts.map +1 -1
  524. package/lib/dist/search/query-paths.js +227 -12
  525. package/lib/dist/search/query-paths.js.map +1 -1
  526. package/lib/dist/search/query-utils.d.ts +15 -0
  527. package/lib/dist/search/query-utils.d.ts.map +1 -1
  528. package/lib/dist/search/query-utils.js +35 -7
  529. package/lib/dist/search/query-utils.js.map +1 -1
  530. package/lib/dist/sync/watch-policy.d.ts +14 -0
  531. package/lib/dist/sync/watch-policy.d.ts.map +1 -1
  532. package/lib/dist/sync/watch-policy.js +19 -0
  533. package/lib/dist/sync/watch-policy.js.map +1 -1
  534. package/lib/dist/sync/watcher.d.ts +52 -35
  535. package/lib/dist/sync/watcher.d.ts.map +1 -1
  536. package/lib/dist/sync/watcher.js +236 -100
  537. package/lib/dist/sync/watcher.js.map +1 -1
  538. package/lib/dist/sync/worktree.d.ts +22 -0
  539. package/lib/dist/sync/worktree.d.ts.map +1 -1
  540. package/lib/dist/sync/worktree.js +54 -0
  541. package/lib/dist/sync/worktree.js.map +1 -1
  542. package/lib/dist/telemetry/index.d.ts +4 -2
  543. package/lib/dist/telemetry/index.d.ts.map +1 -1
  544. package/lib/dist/telemetry/index.js +159 -66
  545. package/lib/dist/telemetry/index.js.map +1 -1
  546. package/lib/dist/types.d.ts +1 -1
  547. package/lib/dist/types.d.ts.map +1 -1
  548. package/lib/dist/types.js +1 -0
  549. package/lib/dist/types.js.map +1 -1
  550. package/lib/dist/ui-server/api/deadcode.d.ts +84 -0
  551. package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -0
  552. package/lib/dist/ui-server/api/deadcode.js +136 -0
  553. package/lib/dist/ui-server/api/deadcode.js.map +1 -0
  554. package/lib/dist/ui-server/api/effects.d.ts +94 -0
  555. package/lib/dist/ui-server/api/effects.d.ts.map +1 -0
  556. package/lib/dist/ui-server/api/effects.js +527 -0
  557. package/lib/dist/ui-server/api/effects.js.map +1 -0
  558. package/lib/dist/ui-server/api/entrypoints.d.ts +92 -0
  559. package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  560. package/lib/dist/ui-server/api/entrypoints.js +364 -0
  561. package/lib/dist/ui-server/api/entrypoints.js.map +1 -0
  562. package/lib/dist/ui-server/api/events.d.ts +183 -0
  563. package/lib/dist/ui-server/api/events.d.ts.map +1 -0
  564. package/lib/dist/ui-server/api/events.js +430 -0
  565. package/lib/dist/ui-server/api/events.js.map +1 -0
  566. package/lib/dist/ui-server/api/file.d.ts +66 -0
  567. package/lib/dist/ui-server/api/file.d.ts.map +1 -0
  568. package/lib/dist/ui-server/api/file.js +235 -0
  569. package/lib/dist/ui-server/api/file.js.map +1 -0
  570. package/lib/dist/ui-server/api/filecode.d.ts +126 -0
  571. package/lib/dist/ui-server/api/filecode.d.ts.map +1 -0
  572. package/lib/dist/ui-server/api/filecode.js +205 -0
  573. package/lib/dist/ui-server/api/filecode.js.map +1 -0
  574. package/lib/dist/ui-server/api/flow.d.ts +226 -0
  575. package/lib/dist/ui-server/api/flow.d.ts.map +1 -0
  576. package/lib/dist/ui-server/api/flow.js +612 -0
  577. package/lib/dist/ui-server/api/flow.js.map +1 -0
  578. package/lib/dist/ui-server/api/hierarchy.d.ts +81 -0
  579. package/lib/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  580. package/lib/dist/ui-server/api/hierarchy.js +92 -0
  581. package/lib/dist/ui-server/api/hierarchy.js.map +1 -0
  582. package/lib/dist/ui-server/api/index.d.ts +90 -0
  583. package/lib/dist/ui-server/api/index.d.ts.map +1 -0
  584. package/lib/dist/ui-server/api/index.js +332 -0
  585. package/lib/dist/ui-server/api/index.js.map +1 -0
  586. package/lib/dist/ui-server/api/map.d.ts +273 -0
  587. package/lib/dist/ui-server/api/map.d.ts.map +1 -0
  588. package/lib/dist/ui-server/api/map.js +781 -0
  589. package/lib/dist/ui-server/api/map.js.map +1 -0
  590. package/lib/dist/ui-server/api/node.d.ts +81 -0
  591. package/lib/dist/ui-server/api/node.d.ts.map +1 -0
  592. package/lib/dist/ui-server/api/node.js +394 -0
  593. package/lib/dist/ui-server/api/node.js.map +1 -0
  594. package/lib/dist/ui-server/api/nodes.d.ts +25 -0
  595. package/lib/dist/ui-server/api/nodes.d.ts.map +1 -0
  596. package/lib/dist/ui-server/api/nodes.js +45 -0
  597. package/lib/dist/ui-server/api/nodes.js.map +1 -0
  598. package/lib/dist/ui-server/api/program.d.ts +139 -0
  599. package/lib/dist/ui-server/api/program.d.ts.map +1 -0
  600. package/lib/dist/ui-server/api/program.js +315 -0
  601. package/lib/dist/ui-server/api/program.js.map +1 -0
  602. package/lib/dist/ui-server/api/respond.d.ts +76 -0
  603. package/lib/dist/ui-server/api/respond.d.ts.map +1 -0
  604. package/lib/dist/ui-server/api/respond.js +186 -0
  605. package/lib/dist/ui-server/api/respond.js.map +1 -0
  606. package/lib/dist/ui-server/api/route-roots.d.ts +45 -0
  607. package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -0
  608. package/lib/dist/ui-server/api/route-roots.js +117 -0
  609. package/lib/dist/ui-server/api/route-roots.js.map +1 -0
  610. package/lib/dist/ui-server/api/routes.d.ts +61 -0
  611. package/lib/dist/ui-server/api/routes.d.ts.map +1 -0
  612. package/lib/dist/ui-server/api/routes.js +164 -0
  613. package/lib/dist/ui-server/api/routes.js.map +1 -0
  614. package/lib/dist/ui-server/api/screens.d.ts +117 -0
  615. package/lib/dist/ui-server/api/screens.d.ts.map +1 -0
  616. package/lib/dist/ui-server/api/screens.js +626 -0
  617. package/lib/dist/ui-server/api/screens.js.map +1 -0
  618. package/lib/dist/ui-server/api/search.d.ts +29 -0
  619. package/lib/dist/ui-server/api/search.d.ts.map +1 -0
  620. package/lib/dist/ui-server/api/search.js +232 -0
  621. package/lib/dist/ui-server/api/search.js.map +1 -0
  622. package/lib/dist/ui-server/api/session.d.ts +52 -0
  623. package/lib/dist/ui-server/api/session.d.ts.map +1 -0
  624. package/lib/dist/ui-server/api/session.js +196 -0
  625. package/lib/dist/ui-server/api/session.js.map +1 -0
  626. package/lib/dist/ui-server/api/source.d.ts +200 -0
  627. package/lib/dist/ui-server/api/source.d.ts.map +1 -0
  628. package/lib/dist/ui-server/api/source.js +422 -0
  629. package/lib/dist/ui-server/api/source.js.map +1 -0
  630. package/lib/dist/ui-server/api/stats.d.ts +27 -0
  631. package/lib/dist/ui-server/api/stats.d.ts.map +1 -0
  632. package/lib/dist/ui-server/api/stats.js +164 -0
  633. package/lib/dist/ui-server/api/stats.js.map +1 -0
  634. package/lib/dist/ui-server/api/steps.d.ts +274 -0
  635. package/lib/dist/ui-server/api/steps.d.ts.map +1 -0
  636. package/lib/dist/ui-server/api/steps.js +1554 -0
  637. package/lib/dist/ui-server/api/steps.js.map +1 -0
  638. package/lib/dist/ui-server/api/trail-store.d.ts +142 -0
  639. package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -0
  640. package/lib/dist/ui-server/api/trail-store.js +323 -0
  641. package/lib/dist/ui-server/api/trail-store.js.map +1 -0
  642. package/lib/dist/ui-server/api/trails.d.ts +163 -0
  643. package/lib/dist/ui-server/api/trails.d.ts.map +1 -0
  644. package/lib/dist/ui-server/api/trails.js +370 -0
  645. package/lib/dist/ui-server/api/trails.js.map +1 -0
  646. package/lib/dist/ui-server/api/when.d.ts +133 -0
  647. package/lib/dist/ui-server/api/when.d.ts.map +1 -0
  648. package/lib/dist/ui-server/api/when.js +275 -0
  649. package/lib/dist/ui-server/api/when.js.map +1 -0
  650. package/lib/dist/ui-server/api/wire.d.ts +179 -0
  651. package/lib/dist/ui-server/api/wire.d.ts.map +1 -0
  652. package/lib/dist/ui-server/api/wire.js +231 -0
  653. package/lib/dist/ui-server/api/wire.js.map +1 -0
  654. package/lib/dist/ui-server/assets.d.ts +40 -0
  655. package/lib/dist/ui-server/assets.d.ts.map +1 -0
  656. package/lib/dist/ui-server/assets.js +110 -0
  657. package/lib/dist/ui-server/assets.js.map +1 -0
  658. package/lib/dist/ui-server/constants.d.ts +32 -0
  659. package/lib/dist/ui-server/constants.d.ts.map +1 -0
  660. package/lib/dist/ui-server/constants.js +35 -0
  661. package/lib/dist/ui-server/constants.js.map +1 -0
  662. package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts +28 -0
  663. package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts.map +1 -0
  664. package/lib/dist/ui-server/highlight/bounded-tokenize.js +139 -0
  665. package/lib/dist/ui-server/highlight/bounded-tokenize.js.map +1 -0
  666. package/lib/dist/ui-server/highlight/index.d.ts +113 -0
  667. package/lib/dist/ui-server/highlight/index.d.ts.map +1 -0
  668. package/lib/dist/ui-server/highlight/index.js +312 -0
  669. package/lib/dist/ui-server/highlight/index.js.map +1 -0
  670. package/lib/dist/ui-server/highlight/languages.d.ts +36 -0
  671. package/lib/dist/ui-server/highlight/languages.d.ts.map +1 -0
  672. package/lib/dist/ui-server/highlight/languages.js +50 -0
  673. package/lib/dist/ui-server/highlight/languages.js.map +1 -0
  674. package/lib/dist/ui-server/highlight/tokenize-worker.d.ts +7 -0
  675. package/lib/dist/ui-server/highlight/tokenize-worker.d.ts.map +1 -0
  676. package/lib/dist/ui-server/highlight/tokenize-worker.js +20 -0
  677. package/lib/dist/ui-server/highlight/tokenize-worker.js.map +1 -0
  678. package/lib/dist/ui-server/index.d.ts +92 -0
  679. package/lib/dist/ui-server/index.d.ts.map +1 -0
  680. package/lib/dist/ui-server/index.js +399 -0
  681. package/lib/dist/ui-server/index.js.map +1 -0
  682. package/lib/dist/ui-server/open-browser.d.ts +31 -0
  683. package/lib/dist/ui-server/open-browser.d.ts.map +1 -0
  684. package/lib/dist/ui-server/open-browser.js +79 -0
  685. package/lib/dist/ui-server/open-browser.js.map +1 -0
  686. package/lib/dist/ui-server/security.d.ts +127 -0
  687. package/lib/dist/ui-server/security.d.ts.map +1 -0
  688. package/lib/dist/ui-server/security.js +332 -0
  689. package/lib/dist/ui-server/security.js.map +1 -0
  690. package/lib/dist/ui-server/static.d.ts +45 -0
  691. package/lib/dist/ui-server/static.d.ts.map +1 -0
  692. package/lib/dist/ui-server/static.js +165 -0
  693. package/lib/dist/ui-server/static.js.map +1 -0
  694. package/lib/dist/upgrade/index.d.ts +43 -5
  695. package/lib/dist/upgrade/index.d.ts.map +1 -1
  696. package/lib/dist/upgrade/index.js +157 -35
  697. package/lib/dist/upgrade/index.js.map +1 -1
  698. package/lib/dist/utils.d.ts +14 -2
  699. package/lib/dist/utils.d.ts.map +1 -1
  700. package/lib/dist/utils.js +25 -10
  701. package/lib/dist/utils.js.map +1 -1
  702. package/lib/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  703. package/lib/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  704. package/lib/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  705. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
  706. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
  707. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  708. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  709. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  710. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  711. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  712. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  713. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
  714. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
  715. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  716. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  717. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  718. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  719. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  720. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  721. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
  722. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  723. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  724. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  725. package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  726. package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  727. package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  728. package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  729. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
  730. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
  731. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  732. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  733. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  734. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  735. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  736. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  737. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
  738. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
  739. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  740. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  741. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  742. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  743. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  744. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  745. package/lib/dist/viewer/assets/index-BSGpxBr9.js +99 -0
  746. package/lib/dist/viewer/assets/index-CF9yvio6.css +1 -0
  747. package/lib/dist/viewer/index.html +16 -0
  748. package/lib/dist/worker-teardown.d.ts +48 -0
  749. package/lib/dist/worker-teardown.d.ts.map +1 -0
  750. package/lib/dist/worker-teardown.js +100 -0
  751. package/lib/dist/worker-teardown.js.map +1 -0
  752. package/lib/kernel/codegraph-kernel.node +2 -2
  753. package/lib/node_modules/.package-lock.json +4 -4
  754. package/lib/node_modules/picomatch/README.md +56 -51
  755. package/lib/node_modules/picomatch/lib/constants.js +4 -0
  756. package/lib/node_modules/picomatch/lib/parse.js +341 -1
  757. package/lib/node_modules/picomatch/lib/picomatch.js +25 -5
  758. package/lib/node_modules/picomatch/lib/scan.js +30 -18
  759. package/lib/node_modules/picomatch/package.json +4 -4
  760. package/lib/package.json +9 -2
  761. package/package.json +1 -1
@@ -40,6 +40,23 @@ function isLowValueFile(filePath, generated) {
40
40
  (0, generated_detection_1.isGeneratedFile)(filePath));
41
41
  }
42
42
  const SQLITE_PARAM_CHUNK_SIZE = 500;
43
+ /**
44
+ * A SQL predicate: is the node aliased `alias` a member an INTERFACE declares?
45
+ *
46
+ * `method_signature` / `property_signature` enter the graph as `method` /
47
+ * `property` nodes hung off their interface by a `contains` edge (#1638). They
48
+ * have no body and originate no behaviour, so for a structural judgement about
49
+ * a FILE they are the interface restated, not an extra thing the file declares.
50
+ * See {@link QueryBuilder.getAmbientDeclarationPathsAmong}, the one caller, for
51
+ * why treating them as opaque would break that rule in three places at once.
52
+ *
53
+ * Seeks `idx_edges_target_kind`, so it costs a key lookup per row rather than a
54
+ * join over the whole edge table.
55
+ */
56
+ const IS_INTERFACE_MEMBER = (alias) => `EXISTS (
57
+ SELECT 1 FROM edges ce JOIN nodes owner ON owner.id = ce.source
58
+ WHERE ce.target = ${alias}.id AND ce.kind = 'contains' AND owner.kind = 'interface'
59
+ )`;
43
60
  /**
44
61
  * How much of the exact-name bonus a `deprioritize`d path keeps (#982). Damped
45
62
  * rather than zeroed: a query that genuinely targets that tree must still rank
@@ -139,9 +156,15 @@ class QueryBuilder {
139
156
  // Set once by the CodeGraph instance; empty by default (no down-weighting).
140
157
  projectNameTokens = new Set();
141
158
  isDeprioritizedPath;
159
+ // FTS5 availability flag — detected once at construction time (#1532)
160
+ _fts5Available;
142
161
  // Node cache for frequently accessed nodes (LRU-style, max 1000 entries)
143
162
  nodeCache = new Map();
144
163
  maxCacheSize = 1000;
164
+ // getDominantFile()'s answer, tagged with the database change stamp it was
165
+ // computed under (see getChangeStamp). Query-independent, so one value
166
+ // serves every explore until the database changes (#1864).
167
+ dominantFileMemo;
145
168
  // Prepared statements (lazily initialized)
146
169
  stmts = {};
147
170
  // Names whose segments were already written this session — skips re-splitting
@@ -158,6 +181,11 @@ class QueryBuilder {
158
181
  // (and therefore resolution's insertion-order disambiguation) is identical
159
182
  // to the one-row-per-run path.
160
183
  batchStmts = new Map();
184
+ // Kind-filtered edge reads build their SQL per call (a variable IN list),
185
+ // but from a handful of kind sets: prepare each shape once. Supertype walks
186
+ // and the member-lookup passes issue them per node, and preparing cost
187
+ // about a third of the read.
188
+ edgeKindStmts = new Map();
161
189
  static BATCH_SIZES = [128, 32, 8, 1];
162
190
  /**
163
191
  * Run `rows` through a multi-row `INSERT` built as `head + (tuple,)*n`,
@@ -193,6 +221,14 @@ class QueryBuilder {
193
221
  }
194
222
  constructor(db) {
195
223
  this.db = db;
224
+ // Detect FTS5 availability once (#1532)
225
+ try {
226
+ db.prepare("SELECT * FROM nodes_fts LIMIT 0").get();
227
+ this._fts5Available = true;
228
+ }
229
+ catch {
230
+ this._fts5Available = false;
231
+ }
196
232
  }
197
233
  /**
198
234
  * Swap the underlying connection in place. Used by pool workers'
@@ -210,6 +246,21 @@ class QueryBuilder {
210
246
  this.db = db;
211
247
  this.stmts = {};
212
248
  this.batchStmts.clear();
249
+ this.edgeKindStmts.clear();
250
+ // The change stamp is per connection, and fresh connections to two
251
+ // different databases report the same one — the memo goes with the old
252
+ // connection, or a worker following a rebuilt index keeps its answer (#1864).
253
+ this.dominantFileMemo = undefined;
254
+ }
255
+ edgeKindStmt(sql) {
256
+ let stmt = this.edgeKindStmts.get(sql);
257
+ if (!stmt) {
258
+ if (this.edgeKindStmts.size >= 64)
259
+ this.edgeKindStmts.delete(this.edgeKindStmts.keys().next().value);
260
+ stmt = this.db.prepare(sql);
261
+ this.edgeKindStmts.set(sql, stmt);
262
+ }
263
+ return stmt;
213
264
  }
214
265
  /** Set the normalized project-name tokens used to down-weight non-discriminative
215
266
  * query words in path scoring (#720). Called once when the project opens. */
@@ -380,6 +431,14 @@ class QueryBuilder {
380
431
  this.runBatched('insertNameSegments', 'INSERT OR IGNORE INTO name_segment_vocab (segment, name) VALUES ', '(?,?)', segmentRows);
381
432
  })();
382
433
  }
434
+ /**
435
+ * Run `fn` as one transaction. The write helpers called inside join it
436
+ * rather than committing on their own, so a crash part-way leaves none of
437
+ * `fn`'s writes behind.
438
+ */
439
+ runInTransaction(fn) {
440
+ return this.db.transaction(fn)();
441
+ }
383
442
  /**
384
443
  * Store one file's whole extraction bundle — nodes, edges, unresolved refs,
385
444
  * and the file record — in a SINGLE transaction. The bulk-index path calls
@@ -688,10 +747,16 @@ class QueryBuilder {
688
747
  const uniqueIds = [...new Set(ids)];
689
748
  for (let i = 0; i < uniqueIds.length; i += SQLITE_PARAM_CHUNK_SIZE) {
690
749
  const chunk = uniqueIds.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
691
- const placeholders = chunk.map(() => '?').join(',');
692
- const rows = this.db
693
- .prepare(`SELECT id FROM nodes WHERE id IN (${placeholders})`)
694
- .all(...chunk);
750
+ // Every edge insert checks its endpoints here, a chunk at a time: the
751
+ // full-size statement is prepared once, the final partial chunk ad hoc.
752
+ let stmt;
753
+ if (chunk.length === SQLITE_PARAM_CHUNK_SIZE) {
754
+ stmt = this.stmts.existingNodeIdsFull ??= this.db.prepare(`SELECT id FROM nodes WHERE id IN (${new Array(SQLITE_PARAM_CHUNK_SIZE).fill('?').join(',')})`);
755
+ }
756
+ else {
757
+ stmt = this.db.prepare(`SELECT id FROM nodes WHERE id IN (${chunk.map(() => '?').join(',')})`);
758
+ }
759
+ const rows = stmt.all(...chunk);
695
760
  for (const row of rows) {
696
761
  out.add(row.id);
697
762
  }
@@ -717,16 +782,78 @@ class QueryBuilder {
717
782
  clearCache() {
718
783
  this.nodeCache.clear();
719
784
  }
785
+ /**
786
+ * Whether any node in `filePath` is exported — `getNodesByFile(f).some((n) =>
787
+ * n.isExported)` as one indexed probe, without decoding the file's nodes.
788
+ */
789
+ fileHasExportedNode(filePath) {
790
+ if (!this.stmts.fileHasExportedNode) {
791
+ this.stmts.fileHasExportedNode = this.db.prepare('SELECT 1 FROM nodes WHERE file_path = ? AND is_exported = 1 LIMIT 1');
792
+ }
793
+ return this.stmts.fileHasExportedNode.get(filePath) !== undefined;
794
+ }
795
+ /** The exported nodes of a file, in {@link getNodesByFile} order, decoding only those rows. */
796
+ getExportedNodesByFile(filePath) {
797
+ if (!this.stmts.getExportedNodesByFile) {
798
+ this.stmts.getExportedNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? AND is_exported = 1 ORDER BY start_line, id');
799
+ }
800
+ return this.stmts.getExportedNodesByFile.all(filePath).map(rowToNode);
801
+ }
802
+ /** The nodes of a file with one name, in {@link getNodesByFile} order, decoding only those rows. */
803
+ getNodesByFileAndName(filePath, name) {
804
+ if (!this.stmts.getNodesByFileAndName) {
805
+ this.stmts.getNodesByFileAndName = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? AND name = ? ORDER BY start_line, id');
806
+ }
807
+ return this.stmts.getNodesByFileAndName.all(filePath, name).map(rowToNode);
808
+ }
720
809
  /**
721
810
  * Get all nodes in a file
722
811
  */
723
812
  getNodesByFile(filePath) {
724
813
  if (!this.stmts.getNodesByFile) {
725
- this.stmts.getNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? ORDER BY start_line');
814
+ this.stmts.getNodesByFile = this.db.prepare('SELECT * FROM nodes WHERE file_path = ? ORDER BY start_line, id');
726
815
  }
727
816
  const rows = this.stmts.getNodesByFile.all(filePath);
728
817
  return rows.map(rowToNode);
729
818
  }
819
+ /**
820
+ * The {@link NodeIdentity} of every node in a file, without decoding whole
821
+ * nodes. Read before a re-index deletes the file, so each incoming
822
+ * cross-file edge can follow its target to the node that replaces it (#2276).
823
+ */
824
+ getNodeIdentitiesByFile(filePath) {
825
+ if (!this.stmts.getNodeIdentitiesByFile) {
826
+ this.stmts.getNodeIdentitiesByFile = this.db.prepare('SELECT id, kind, name, qualified_name, signature, start_line, start_column FROM nodes WHERE file_path = ?');
827
+ }
828
+ const rows = this.stmts.getNodeIdentitiesByFile.all(filePath);
829
+ return rows.map((row) => ({
830
+ id: row.id,
831
+ kind: row.kind,
832
+ name: row.name,
833
+ qualifiedName: row.qualified_name,
834
+ signature: row.signature ?? undefined,
835
+ startLine: row.start_line,
836
+ startColumn: row.start_column,
837
+ }));
838
+ }
839
+ /**
840
+ * Get all nodes in several files at once — one chunked `IN` query rather than
841
+ * one {@link getNodesByFile} per file (#1975).
842
+ */
843
+ getNodesByFiles(filePaths) {
844
+ const unique = [...new Set(filePaths)];
845
+ const out = [];
846
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
847
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
848
+ const placeholders = chunk.map(() => '?').join(',');
849
+ const rows = this.db
850
+ .prepare(`SELECT * FROM nodes WHERE file_path IN (${placeholders})`)
851
+ .all(...chunk);
852
+ for (const row of rows)
853
+ out.push(rowToNode(row));
854
+ }
855
+ return out;
856
+ }
730
857
  /**
731
858
  * Find the file that holds the densest concentration of the project's
732
859
  * internal call graph — the "core" file. Used by context-builder to
@@ -744,8 +871,46 @@ class QueryBuilder {
744
871
  * Excludes test/spec files from candidacy via path-pattern. The agent's
745
872
  * typical question is "how does X work", not "how is X tested", so
746
873
  * boosting a test file's directory would be a misfire.
874
+ *
875
+ * The answer depends only on the graph, never on the query, and the
876
+ * aggregation behind it scans every edge — seconds on a large index, paid
877
+ * by every generic explore (#1864). So it is memoized per database change
878
+ * stamp: recomputed only after something wrote to the database.
747
879
  */
748
880
  getDominantFile() {
881
+ // total_changes() counts writes that are later rolled back, so a result
882
+ // read inside a transaction could outlive a ROLLBACK under an unchanged
883
+ // stamp. Never keep one; `undefined` (a runtime without the getter) is
884
+ // treated the same way.
885
+ if (this.db.inTransaction !== false) {
886
+ this.dominantFileMemo = undefined;
887
+ return this.computeDominantFile();
888
+ }
889
+ const stamp = this.getChangeStamp();
890
+ if (this.dominantFileMemo?.stamp === stamp)
891
+ return this.dominantFileMemo.value;
892
+ const value = this.computeDominantFile();
893
+ this.dominantFileMemo = { stamp, value };
894
+ return value;
895
+ }
896
+ /**
897
+ * A value that differs whenever the database content may have changed
898
+ * since the last call, whoever changed it: `total_changes()` counts the
899
+ * rows this connection inserted, updated or deleted, and
900
+ * `PRAGMA data_version` moves when any OTHER connection — another process's
901
+ * sync, a CLI `codegraph index` beside a running MCP server — commits. Both
902
+ * are O(1), so no write path has to remember to invalidate anything.
903
+ * Coarse on purpose: any write, not just one to nodes/edges, forces a
904
+ * recompute, which only costs time, never a stale answer.
905
+ */
906
+ getChangeStamp() {
907
+ if (!this.stmts.getChangeStamp) {
908
+ this.stmts.getChangeStamp = this.db.prepare('SELECT total_changes() AS changes, (SELECT data_version FROM pragma_data_version) AS version');
909
+ }
910
+ const row = this.stmts.getChangeStamp.get();
911
+ return `${row.changes}:${row.version}`;
912
+ }
913
+ computeDominantFile() {
749
914
  if (!this.stmts.getDominantFile) {
750
915
  // Pull top 20 candidates; we then filter out test/generated files
751
916
  // in code (regex-grade matching that SQL LIKE can't express). The
@@ -827,10 +992,14 @@ class QueryBuilder {
827
992
  if (!this.stmts.getRoutingManifest) {
828
993
  // Edge kind varies across framework resolvers: Spring/Rails/
829
994
  // Laravel/Drupal emit `references`, Express emits `calls`. Accept
830
- // both — the semantic is the same (route → its handler).
995
+ // both — the semantic is the same (route → its handler). A screen in
996
+ // a Vue / Svelte / Astro app is served by a `component`.
831
997
  this.stmts.getRoutingManifest = this.db.prepare(`
832
998
  SELECT
833
999
  r.name AS url,
1000
+ r.id AS route_id,
1001
+ r.file_path AS route_file,
1002
+ r.start_line AS route_line,
834
1003
  h.name AS handler,
835
1004
  h.file_path AS handler_file,
836
1005
  h.start_line AS handler_line,
@@ -840,7 +1009,7 @@ class QueryBuilder {
840
1009
  JOIN nodes h ON e.target = h.id
841
1010
  WHERE r.kind = 'route'
842
1011
  AND e.kind IN ('references', 'calls')
843
- AND h.kind IN ('function', 'method', 'class')
1012
+ AND h.kind IN ('function', 'method', 'class', 'constant', 'variable', 'component')
844
1013
  ORDER BY r.file_path, r.start_line
845
1014
  LIMIT ?
846
1015
  `);
@@ -871,6 +1040,9 @@ class QueryBuilder {
871
1040
  handlerFile: r.handler_file,
872
1041
  handlerLine: r.handler_line,
873
1042
  handlerKind: r.handler_kind,
1043
+ routeId: r.route_id,
1044
+ routeFile: r.route_file,
1045
+ routeLine: r.route_line,
874
1046
  })),
875
1047
  topHandlerFile,
876
1048
  topHandlerFileCount,
@@ -882,7 +1054,7 @@ class QueryBuilder {
882
1054
  */
883
1055
  getNodesByKind(kind) {
884
1056
  if (!this.stmts.getNodesByKind) {
885
- this.stmts.getNodesByKind = this.db.prepare('SELECT * FROM nodes WHERE kind = ?');
1057
+ this.stmts.getNodesByKind = this.db.prepare('SELECT * FROM nodes WHERE kind = ? ORDER BY file_path, start_line, id');
886
1058
  }
887
1059
  const rows = this.stmts.getNodesByKind.all(kind);
888
1060
  return rows.map(rowToNode);
@@ -897,11 +1069,29 @@ class QueryBuilder {
897
1069
  *iterateNodesByKind(kind) {
898
1070
  // Fresh statement per call (not a cached one): an iterator holds an open
899
1071
  // cursor, so a shared statement would conflict across overlapping scans.
900
- const stmt = this.db.prepare('SELECT * FROM nodes WHERE kind = ?');
1072
+ // Synthesis uses first/last-match precedence and caps: insertion order
1073
+ // changes on sync. idx_nodes_kind streams this canonical order without
1074
+ // materializing/sorting all of a large project's methods in memory.
1075
+ const stmt = this.db.prepare('SELECT * FROM nodes WHERE kind = ? ORDER BY file_path, start_line, id');
901
1076
  for (const row of stmt.iterate(kind)) {
902
1077
  yield rowToNode(row);
903
1078
  }
904
1079
  }
1080
+ /**
1081
+ * iterateNodesByKind narrowed to some languages, in the same canonical
1082
+ * order — the ORDER BY is total (`id` is unique), so this yields exactly the
1083
+ * nodes a caller filtering iterateNodesByKind by language would keep, in the
1084
+ * same sequence. A Go pass on a TypeScript monorepo otherwise materialized
1085
+ * every method in the project to find a couple of Go ones.
1086
+ */
1087
+ *iterateNodesByKindIn(kind, languages) {
1088
+ if (languages.length === 0)
1089
+ return;
1090
+ const stmt = this.db.prepare(`SELECT * FROM nodes WHERE kind = ? AND language IN (${languages.map(() => '?').join(', ')}) ORDER BY file_path, start_line, id`);
1091
+ for (const row of stmt.iterate(kind, ...languages)) {
1092
+ yield rowToNode(row);
1093
+ }
1094
+ }
905
1095
  /**
906
1096
  * Get all nodes in the database
907
1097
  */
@@ -921,7 +1111,7 @@ class QueryBuilder {
921
1111
  *iterateNodesByLanguageWithDecorator(language, decorator) {
922
1112
  // Fresh statement per call — an iterator holds an open cursor (see
923
1113
  // iterateNodesByKind).
924
- const stmt = this.db.prepare("SELECT * FROM nodes WHERE language = ? AND decorators LIKE '%' || ? || '%'");
1114
+ const stmt = this.db.prepare("SELECT * FROM nodes WHERE language = ? AND decorators LIKE '%' || ? || '%' ORDER BY file_path, start_line, id");
925
1115
  for (const row of stmt.iterate(language, `"${decorator}"`)) {
926
1116
  yield rowToNode(row);
927
1117
  }
@@ -956,7 +1146,7 @@ class QueryBuilder {
956
1146
  */
957
1147
  getNodesByName(name) {
958
1148
  if (!this.stmts.getNodesByName) {
959
- this.stmts.getNodesByName = this.db.prepare('SELECT * FROM nodes WHERE name = ? ORDER BY file_path, start_line');
1149
+ this.stmts.getNodesByName = this.db.prepare('SELECT * FROM nodes WHERE name = ? ORDER BY file_path, start_line, id');
960
1150
  }
961
1151
  const rows = this.stmts.getNodesByName.all(name);
962
1152
  return rows.map(rowToNode);
@@ -972,12 +1162,20 @@ class QueryBuilder {
972
1162
  const rows = this.stmts.getNodesByNamePrefix.all(prefix, prefix + '￿', limit);
973
1163
  return rows.map(rowToNode);
974
1164
  }
1165
+ /** File nodes whose basename starts with `prefix`, without a result cap. */
1166
+ getFileNodesByNamePrefix(prefix) {
1167
+ if (!this.stmts.getFileNodesByNamePrefix) {
1168
+ this.stmts.getFileNodesByNamePrefix = this.db.prepare("SELECT * FROM nodes WHERE kind = 'file' AND name >= ? AND name < ? ORDER BY name");
1169
+ }
1170
+ const rows = this.stmts.getFileNodesByNamePrefix.all(prefix, prefix + '￿');
1171
+ return rows.map(rowToNode);
1172
+ }
975
1173
  /**
976
1174
  * Get nodes by exact qualified name match (uses idx_nodes_qualified_name index)
977
1175
  */
978
1176
  getNodesByQualifiedNameExact(qualifiedName) {
979
1177
  if (!this.stmts.getNodesByQualifiedNameExact) {
980
- this.stmts.getNodesByQualifiedNameExact = this.db.prepare('SELECT * FROM nodes WHERE qualified_name = ?');
1178
+ this.stmts.getNodesByQualifiedNameExact = this.db.prepare('SELECT * FROM nodes WHERE qualified_name = ? ORDER BY file_path, start_line, id');
981
1179
  }
982
1180
  const rows = this.stmts.getNodesByQualifiedNameExact.all(qualifiedName);
983
1181
  return rows.map(rowToNode);
@@ -1033,9 +1231,9 @@ class QueryBuilder {
1033
1231
  const text = parsed.text;
1034
1232
  const kinds = mergedKinds;
1035
1233
  const languages = mergedLanguages;
1036
- // First try FTS5 with prefix matching
1234
+ // First try FTS5 with prefix matching (skip if FTS5 not available, #1532)
1037
1235
  let results = text
1038
- ? this.searchNodesFTS(text, { kinds, languages, limit, offset })
1236
+ ? (this._fts5Available !== false ? this.searchNodesFTS(text, { kinds, languages, limit, offset }) : [])
1039
1237
  // Over-fetch by 5× when running filter-only (no text). The
1040
1238
  // post-scoring path: + name: filters can be very selective, so
1041
1239
  // a smaller multiplier risks returning fewer than `limit`
@@ -1227,6 +1425,46 @@ class QueryBuilder {
1227
1425
  }
1228
1426
  return results;
1229
1427
  }
1428
+ /** Bounded miss diagnostics, independent of relevance filters and ranking. */
1429
+ getExploreMissDiagnostics(query) {
1430
+ const words = [...new Set((query.match(/[\p{L}\p{N}]+/gu) ?? []).map(w => w.toLowerCase()))];
1431
+ const checked = words.filter(w => w.length <= 64).slice(0, 16);
1432
+ const limited = checked.length !== words.length;
1433
+ if (checked.length === 0)
1434
+ return { matched: [], unmatched: [], candidates: [], limited };
1435
+ // EXISTS uses FTS postings and the segment primary key, never source scans.
1436
+ // Vocab rows can outlive deleted definitions, so verify them against nodes.
1437
+ const rows = this.db.prepare(`
1438
+ WITH words(word, pattern) AS (VALUES ${checked.map(() => '(?, ?)').join(', ')})
1439
+ SELECT word, (
1440
+ EXISTS (SELECT 1 FROM nodes_fts WHERE nodes_fts MATCH pattern)
1441
+ OR EXISTS (
1442
+ SELECT 1 FROM name_segment_vocab v WHERE v.segment = word
1443
+ AND EXISTS (SELECT 1 FROM nodes n WHERE n.name = v.name AND n.kind NOT IN ('file', 'import'))
1444
+ )
1445
+ ) AS matched FROM words
1446
+ `).all(...checked.flatMap(w => [w, `{name qualified_name signature docstring} : "${w}"*`]));
1447
+ const names = this.db.prepare(`
1448
+ SELECT name FROM (
1449
+ SELECT v.name FROM name_segment_vocab v
1450
+ WHERE v.segment IN (${checked.map(() => '?').join(', ')})
1451
+ AND EXISTS (SELECT 1 FROM nodes n WHERE n.name = v.name AND n.kind NOT IN ('file', 'import'))
1452
+ LIMIT 12
1453
+ )
1454
+ UNION ALL
1455
+ SELECT name FROM (
1456
+ SELECT n.name FROM nodes_fts JOIN nodes n ON n.rowid = nodes_fts.rowid
1457
+ WHERE nodes_fts MATCH ? AND n.kind NOT IN ('file', 'import')
1458
+ LIMIT 12
1459
+ )
1460
+ `).all(...checked, `name : (${checked.map(w => `"${w}"*`).join(' OR ')})`);
1461
+ return {
1462
+ matched: rows.filter(r => r.matched).map(r => r.word),
1463
+ unmatched: rows.filter(r => !r.matched).map(r => r.word),
1464
+ candidates: [...new Set(names.map(r => r.name))].slice(0, 12),
1465
+ limited,
1466
+ };
1467
+ }
1230
1468
  /**
1231
1469
  * FTS5 search with prefix matching
1232
1470
  */
@@ -1464,6 +1702,30 @@ class QueryBuilder {
1464
1702
  // ===========================================================================
1465
1703
  // Edge Operations
1466
1704
  // ===========================================================================
1705
+ /** Must run before file replacement/deletion cascades the endpoint edges. */
1706
+ hasSynthesizedEdgesTouchingFile(filePath) {
1707
+ const owned = "CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.synthesizedBy') END IS NOT NULL";
1708
+ for (const endpoint of ['source', 'target']) {
1709
+ if (this.db.prepare(`SELECT 1 FROM nodes n JOIN edges e ON e.${endpoint} = n.id
1710
+ WHERE n.file_path = ? AND ${owned} LIMIT 1`).get(filePath))
1711
+ return true;
1712
+ }
1713
+ // Wiring often lives in a third file, with neither endpoint in it.
1714
+ return !!this.db.prepare(`SELECT 1 FROM edges e WHERE ${owned}
1715
+ AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END >= ?
1716
+ AND CASE WHEN json_valid(e.metadata) THEN json_extract(e.metadata, '$.registeredAt') END < ? LIMIT 1`).get(`${filePath}:`, `${filePath};`);
1717
+ }
1718
+ wasSynthesisInput(filePath) {
1719
+ return !!this.db.prepare('SELECT 1 FROM synthesis_inputs WHERE file_path = ?').get(filePath);
1720
+ }
1721
+ replaceSynthesisInputs(files) {
1722
+ this.db.transaction(() => {
1723
+ this.db.exec('DELETE FROM synthesis_inputs');
1724
+ const insert = this.db.prepare('INSERT INTO synthesis_inputs(file_path) VALUES (?)');
1725
+ for (const file of files)
1726
+ insert.run(file);
1727
+ })();
1728
+ }
1467
1729
  /**
1468
1730
  * Insert a new edge
1469
1731
  */
@@ -1525,7 +1787,8 @@ class QueryBuilder {
1525
1787
  this.stmts.deleteEdgesBySource.run(sourceId);
1526
1788
  }
1527
1789
  /**
1528
- * Get outgoing edges from a node
1790
+ * Get outgoing edges from a node. Preserve the source/kind index order
1791
+ * (calls before imports/references), then break ties deterministically.
1529
1792
  */
1530
1793
  getOutgoingEdges(sourceId, kinds, provenance) {
1531
1794
  if ((kinds && kinds.length > 0) || provenance) {
@@ -1539,30 +1802,645 @@ class QueryBuilder {
1539
1802
  sql += ' AND provenance = ?';
1540
1803
  params.push(provenance);
1541
1804
  }
1542
- const rows = this.db.prepare(sql).all(...params);
1805
+ sql += ' ORDER BY kind, target, line, col';
1806
+ const rows = this.edgeKindStmt(sql).all(...params);
1543
1807
  return rows.map(rowToEdge);
1544
1808
  }
1545
1809
  if (!this.stmts.getEdgesBySource) {
1546
- this.stmts.getEdgesBySource = this.db.prepare('SELECT * FROM edges WHERE source = ?');
1810
+ this.stmts.getEdgesBySource = this.db.prepare('SELECT * FROM edges WHERE source = ? ORDER BY kind, target, line, col');
1547
1811
  }
1548
1812
  const rows = this.stmts.getEdgesBySource.all(sourceId);
1549
1813
  return rows.map(rowToEdge);
1550
1814
  }
1551
1815
  /**
1552
- * Get incoming edges to a node
1816
+ * Get incoming edges to a node. Kind must precede opaque source IDs:
1817
+ * file IDs sort before function IDs, so source-first ordering lets imports
1818
+ * displace actual calls in capped caller lists. Keep deterministic ties
1819
+ * without changing the target/kind index's established kind precedence.
1553
1820
  */
1554
1821
  getIncomingEdges(targetId, kinds) {
1555
1822
  if (kinds && kinds.length > 0) {
1556
- const sql = `SELECT * FROM edges WHERE target = ? AND kind IN (${kinds.map(() => '?').join(',')})`;
1557
- const rows = this.db.prepare(sql).all(targetId, ...kinds);
1823
+ const sql = `SELECT * FROM edges WHERE target = ? AND kind IN (${kinds.map(() => '?').join(',')}) ORDER BY kind, source, line, col`;
1824
+ const rows = this.edgeKindStmt(sql).all(targetId, ...kinds);
1558
1825
  return rows.map(rowToEdge);
1559
1826
  }
1560
1827
  if (!this.stmts.getEdgesByTarget) {
1561
- this.stmts.getEdgesByTarget = this.db.prepare('SELECT * FROM edges WHERE target = ?');
1828
+ this.stmts.getEdgesByTarget = this.db.prepare('SELECT * FROM edges WHERE target = ? ORDER BY kind, source, line, col');
1562
1829
  }
1563
1830
  const rows = this.stmts.getEdgesByTarget.all(targetId);
1564
1831
  return rows.map(rowToEdge);
1565
1832
  }
1833
+ /**
1834
+ * Outgoing edges for MANY source nodes in one query.
1835
+ *
1836
+ * The batch form of {@link getOutgoingEdges}. Building a nested outline needs
1837
+ * the `contains` edges of every container in a file at once; doing that one
1838
+ * source at a time is a query per symbol on files that have hundreds.
1839
+ */
1840
+ getOutgoingEdgesFrom(sourceIds, kinds) {
1841
+ if (sourceIds.length === 0)
1842
+ return [];
1843
+ const unique = [...new Set(sourceIds)];
1844
+ const out = [];
1845
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1846
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1847
+ const placeholders = chunk.map(() => '?').join(',');
1848
+ let sql = `SELECT * FROM edges WHERE source IN (${placeholders})`;
1849
+ const params = [...chunk];
1850
+ if (kinds && kinds.length > 0) {
1851
+ sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`;
1852
+ params.push(...kinds);
1853
+ }
1854
+ const rows = this.db.prepare(sql).all(...params);
1855
+ for (const row of rows)
1856
+ out.push(rowToEdge(row));
1857
+ }
1858
+ return out;
1859
+ }
1860
+ /**
1861
+ * Fan-in (total incoming edge count) for MANY nodes in one query.
1862
+ *
1863
+ * The per-node alternative — `getIncomingEdges(id).length` — is an indexed
1864
+ * lookup each, but a symbol screen rendering a couple of hundred callees
1865
+ * would issue a couple of hundred of them. Ids with no incoming edges are
1866
+ * absent from the map rather than present as 0, so callers can tell "no
1867
+ * edges" from "not asked about".
1868
+ */
1869
+ countIncomingEdges(ids) {
1870
+ const out = new Map();
1871
+ if (ids.length === 0)
1872
+ return out;
1873
+ const unique = [...new Set(ids)];
1874
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1875
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1876
+ const placeholders = chunk.map(() => '?').join(',');
1877
+ const rows = this.db
1878
+ .prepare(
1879
+ // A test's request onto a route (tier-synthesizer's `test-request`)
1880
+ // is not a production caller: forty tests hitting one endpoint must
1881
+ // not make it a hub the Steps walk refuses to enter.
1882
+ `SELECT target, COUNT(*) AS count FROM edges WHERE target IN (${placeholders})
1883
+ AND (metadata IS NULL OR metadata NOT LIKE '%"synthesizedBy":"test-request"%') GROUP BY target`)
1884
+ .all(...chunk);
1885
+ for (const row of rows)
1886
+ out.set(row.target, row.count);
1887
+ }
1888
+ return out;
1889
+ }
1890
+ /**
1891
+ * Incoming edges for MANY target nodes in one query — the mirror of
1892
+ * {@link getOutgoingEdgesFrom}. Needed wherever a whole file's inbound edges
1893
+ * are wanted at once ("which files import anything in this one?").
1894
+ */
1895
+ getIncomingEdgesTo(targetIds, kinds) {
1896
+ if (targetIds.length === 0)
1897
+ return [];
1898
+ const unique = [...new Set(targetIds)];
1899
+ const out = [];
1900
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1901
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1902
+ const placeholders = chunk.map(() => '?').join(',');
1903
+ let sql = `SELECT * FROM edges WHERE target IN (${placeholders})`;
1904
+ const params = [...chunk];
1905
+ if (kinds && kinds.length > 0) {
1906
+ sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`;
1907
+ params.push(...kinds);
1908
+ }
1909
+ const rows = this.db.prepare(sql).all(...params);
1910
+ for (const row of rows)
1911
+ out.push(rowToEdge(row));
1912
+ }
1913
+ return out;
1914
+ }
1915
+ /**
1916
+ * Fan-out (total outgoing edge count) for MANY nodes in one query — the
1917
+ * mirror of {@link countIncomingEdges}. Ids with no outgoing edges are absent
1918
+ * from the map rather than present as 0.
1919
+ */
1920
+ countOutgoingEdges(ids) {
1921
+ const out = new Map();
1922
+ if (ids.length === 0)
1923
+ return out;
1924
+ const unique = [...new Set(ids)];
1925
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1926
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1927
+ const placeholders = chunk.map(() => '?').join(',');
1928
+ const rows = this.db
1929
+ .prepare(`SELECT source, COUNT(*) AS count FROM edges WHERE source IN (${placeholders}) GROUP BY source`)
1930
+ .all(...chunk);
1931
+ for (const row of rows)
1932
+ out.set(row.source, row.count);
1933
+ }
1934
+ return out;
1935
+ }
1936
+ /**
1937
+ * Symbols nothing in the index points at — the candidate set behind the dead
1938
+ * code list (`src/graph/dead-code.ts`).
1939
+ *
1940
+ * "Points at" is every edge kind EXCEPT `contains`: a class containing a
1941
+ * method is structure, not use, and counting it would make every member look
1942
+ * reached by its own container. A self-edge is excluded for the same reason
1943
+ * a recursive function is not its own caller.
1944
+ *
1945
+ * One scan, one index probe per candidate. `NOT EXISTS` over
1946
+ * `idx_edges_target_kind` is what keeps it that way — the alternative
1947
+ * (`LEFT JOIN edges … GROUP BY`) builds a row per edge for the whole table
1948
+ * before discarding all but the empty groups. Ordered by position so the
1949
+ * answer is stable across runs and groups by file without a second sort.
1950
+ *
1951
+ * The result is deliberately NOT called dead code: an unreferenced symbol is
1952
+ * a symbol with no STATIC reference, and the caller applies the exclusions
1953
+ * (tests, generated files, overrides, unresolved names) that turn the
1954
+ * candidate set into a claim worth making.
1955
+ */
1956
+ getUnreferencedNodes(kinds, limit) {
1957
+ if (kinds.length === 0 || limit <= 0)
1958
+ return [];
1959
+ const placeholders = kinds.map(() => '?').join(',');
1960
+ const rows = this.db
1961
+ .prepare(`SELECT n.*, COALESCE(f.generated, 0) AS file_generated
1962
+ FROM nodes n
1963
+ LEFT JOIN files f ON f.path = n.file_path
1964
+ WHERE n.kind IN (${placeholders})
1965
+ AND NOT EXISTS (
1966
+ SELECT 1 FROM edges e
1967
+ WHERE e.target = n.id
1968
+ AND e.kind != 'contains'
1969
+ AND e.source != n.id
1970
+ )
1971
+ ORDER BY n.file_path, n.start_line, n.name
1972
+ LIMIT ?`)
1973
+ .all(...kinds, limit);
1974
+ return rows.map((row) => ({ node: rowToNode(row), generated: row.file_generated === 1 }));
1975
+ }
1976
+ /**
1977
+ * Which of `names` the index holds an UNRESOLVED reference to.
1978
+ *
1979
+ * The point is honesty about our own blind spots. A `failed` row in
1980
+ * `unresolved_refs` records that some file referenced a name and the resolver
1981
+ * could not decide what it meant — so a symbol with that name cannot be
1982
+ * called unreferenced, whatever the edge table says. It is deliberately
1983
+ * matched loosely, on the reference name AND on its tail (`util.greet` →
1984
+ * `greet`), because the question being asked is "could this name be the one
1985
+ * we failed to follow", and a maybe has to count as a yes.
1986
+ *
1987
+ * Bounded-lookup like {@link getGeneratedPathsAmong}: the caller holds a
1988
+ * candidate list, so this is a chunked probe over `idx_unresolved_name`, not
1989
+ * a scan of the table.
1990
+ */
1991
+ getUnresolvedNamesAmong(names) {
1992
+ const unique = [...new Set(names)].filter((name) => name.length > 0);
1993
+ const found = new Set();
1994
+ if (unique.length === 0)
1995
+ return found;
1996
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1997
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1998
+ const placeholders = chunk.map(() => '?').join(',');
1999
+ const rows = this.db
2000
+ .prepare(`SELECT DISTINCT reference_name AS name FROM unresolved_refs
2001
+ WHERE reference_name IN (${placeholders})
2002
+ UNION
2003
+ SELECT DISTINCT name_tail AS name FROM unresolved_refs
2004
+ WHERE name_tail IN (${placeholders})`)
2005
+ .all(...chunk, ...chunk);
2006
+ for (const row of rows)
2007
+ found.add(row.name);
2008
+ }
2009
+ return found;
2010
+ }
2011
+ /**
2012
+ * Which of `nodeIds` extend or implement a type the resolver could not follow.
2013
+ * An ancestor outside the index (`React.Component`, `stream.Transform`, a
2014
+ * framework interface) leaves no edge, only this `extends` / `implements`
2015
+ * row, so it is the one record that such an ancestor exists (#1973).
2016
+ * Chunked probe over `idx_unresolved_from_node`.
2017
+ */
2018
+ getUnresolvedSupertypeSourcesAmong(nodeIds) {
2019
+ const unique = [...new Set(nodeIds)];
2020
+ const found = new Set();
2021
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2022
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2023
+ const placeholders = chunk.map(() => '?').join(',');
2024
+ const rows = this.db
2025
+ .prepare(`SELECT DISTINCT from_node_id AS id FROM unresolved_refs
2026
+ WHERE from_node_id IN (${placeholders})
2027
+ AND reference_kind IN ('extends', 'implements')`)
2028
+ .all(...chunk);
2029
+ for (const row of rows)
2030
+ found.add(row.id);
2031
+ }
2032
+ return found;
2033
+ }
2034
+ /**
2035
+ * Which of `names` are carried by MORE THAN ONE symbol, at least one of which
2036
+ * something points at.
2037
+ *
2038
+ * The false positive this exists to kill: `CodeGraph.getTopRouteFile` calls
2039
+ * `this.queries.getTopRouteFile()`, and the resolver — which prefers a
2040
+ * same-name definition in the call site's own file — attaches that edge to
2041
+ * the *calling* method. One of the two ends up with a self-edge and the other
2042
+ * with nothing at all, and neither is unreferenced. From the edge table the
2043
+ * mis-resolution and a genuinely unused twin are the same picture, so the
2044
+ * claim is not made about either.
2045
+ *
2046
+ * Both halves of the condition are load-bearing. **More than one symbol**:
2047
+ * a uniquely-named function that only calls itself is genuinely dead, and
2048
+ * excluding every recursive function would gut the list. **Self-edges
2049
+ * counted**: the self-edge IS the fingerprint of the mis-resolution above, so
2050
+ * it has to count as evidence that this name resolves somewhere.
2051
+ *
2052
+ * Chunked probe over `idx_nodes_name`, bounded by the caller's candidate list.
2053
+ */
2054
+ getAmbiguousReferencedNames(names) {
2055
+ const unique = [...new Set(names)].filter((name) => name.length > 0);
2056
+ const found = new Set();
2057
+ if (unique.length === 0)
2058
+ return found;
2059
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2060
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2061
+ const placeholders = chunk.map(() => '?').join(',');
2062
+ const rows = this.db
2063
+ .prepare(`SELECT name FROM (
2064
+ SELECT n.name AS name,
2065
+ EXISTS (
2066
+ SELECT 1 FROM edges e
2067
+ WHERE e.target = n.id AND e.kind != 'contains'
2068
+ ) AS referenced
2069
+ FROM nodes n
2070
+ WHERE n.name IN (${placeholders})
2071
+ )
2072
+ GROUP BY name
2073
+ HAVING COUNT(*) > 1 AND SUM(referenced) > 0`)
2074
+ .all(...chunk);
2075
+ for (const row of rows)
2076
+ found.add(row.name);
2077
+ }
2078
+ return found;
2079
+ }
2080
+ /**
2081
+ * Which of the given languages the index records an EXPORT marker for.
2082
+ *
2083
+ * A self-measurement, and the honest basis for a whole class of exclusion.
2084
+ * The dead code report's strongest filter is "exported symbols may be reached
2085
+ * from outside this repository" — and that filter silently does nothing for a
2086
+ * language whose exports are not recorded, either because the extractor does
2087
+ * not record them (Rust `pub`) or because the language has no such concept at
2088
+ * all (Python, C, Ruby: the header or the module IS the surface). Rather than
2089
+ * carry a table of which is which, ask the index: if nothing in this language
2090
+ * is marked exported, the filter did not run, and no claim about outside
2091
+ * reachability can be made for it.
2092
+ *
2093
+ * `idx_nodes_language` covers the grouping; the caller passes the handful of
2094
+ * languages its candidates are actually in.
2095
+ */
2096
+ getLanguagesWithExports(languages) {
2097
+ const unique = [...new Set(languages)].filter((language) => language.length > 0);
2098
+ const found = new Set();
2099
+ if (unique.length === 0)
2100
+ return found;
2101
+ for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2102
+ const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2103
+ const placeholders = chunk.map(() => '?').join(',');
2104
+ const rows = this.db
2105
+ .prepare(`SELECT language, MAX(is_exported) AS any_exported
2106
+ FROM nodes
2107
+ WHERE language IN (${placeholders})
2108
+ GROUP BY language`)
2109
+ .all(...chunk);
2110
+ for (const row of rows)
2111
+ if (row.any_exported === 1)
2112
+ found.add(row.language);
2113
+ }
2114
+ return found;
2115
+ }
2116
+ /**
2117
+ * The nodes with the most DISTINCT dependents, most first.
2118
+ *
2119
+ * "Distinct" is the difference that matters: a helper called forty times from
2120
+ * one function has a fan-in of 40 but exactly one dependent. This counts the
2121
+ * second thing — the number a reader means by "N callers" — so the top of
2122
+ * this list is the set of symbols a change actually radiates furthest from.
2123
+ *
2124
+ * `contains` is excluded because it is structure, not dependency: counting it
2125
+ * would rank every file and class above the code they hold.
2126
+ */
2127
+ getTopDependedOn(limit) {
2128
+ if (limit <= 0)
2129
+ return [];
2130
+ const rows = this.db
2131
+ .prepare(`SELECT target AS nodeId, COUNT(DISTINCT source) AS dependents
2132
+ FROM edges
2133
+ WHERE kind != 'contains' AND source != target
2134
+ GROUP BY target
2135
+ ORDER BY dependents DESC
2136
+ LIMIT ?`)
2137
+ .all(limit);
2138
+ return rows;
2139
+ }
2140
+ /**
2141
+ * The graph's executable roots — files that RUN something at module level,
2142
+ * ranked by how much of the project they set in motion.
2143
+ *
2144
+ * The engine records a statement at the top level of a file as an edge from
2145
+ * the *file* node, so `src/bin/codegraph.ts` calling `program.parse()` at
2146
+ * module scope is a `calls` edge out of a `file`. That set is what makes the
2147
+ * roots of a dependency graph visible: a library module holds definitions and
2148
+ * runs nothing until someone imports it, while a CLI, a worker entry or a
2149
+ * build script does its work on the way down the file. `instantiates` counts
2150
+ * the same way — `new Server(...)` at module scope is the same act.
2151
+ *
2152
+ * A call made while initializing a module-level `variable` / `constant` —
2153
+ * `const service = new Service()`, `app = FastAPI()` — is attributed to the
2154
+ * declared name (#693), not to the file, so the file's own edges alone would
2155
+ * miss most of what a real entry point runs. Those names are the file's
2156
+ * top-level code too, so `tops` counts them alongside the file node.
2157
+ *
2158
+ * Ranking multiplies the two things an entry point does: it runs (calls), and
2159
+ * it wires the project together (distinct other files its symbols reach). One
2160
+ * alone is misleading — a registration table makes hundreds of module-level
2161
+ * calls into itself, and a barrel file imports everything and runs nothing.
2162
+ * The product puts the file that does both at the top.
2163
+ */
2164
+ getTopCallingFiles(limit) {
2165
+ if (limit <= 0)
2166
+ return [];
2167
+ return this.db
2168
+ .prepare(`WITH tops AS (
2169
+ SELECT n.id AS file_id, n.id AS src
2170
+ FROM nodes n
2171
+ WHERE n.kind = 'file'
2172
+ UNION ALL
2173
+ SELECT c.source AS file_id, c.target AS src
2174
+ FROM edges c
2175
+ JOIN nodes f ON f.id = c.source
2176
+ JOIN nodes v ON v.id = c.target
2177
+ WHERE c.kind = 'contains'
2178
+ AND f.kind = 'file'
2179
+ AND v.kind IN ('variable', 'constant')
2180
+ ),
2181
+ runs AS (
2182
+ SELECT t.file_id AS id, COUNT(*) AS calls
2183
+ FROM tops t
2184
+ JOIN edges e ON e.source = t.src
2185
+ WHERE e.kind IN ('calls', 'instantiates')
2186
+ GROUP BY t.file_id
2187
+ ),
2188
+ cand AS (
2189
+ SELECT r.id AS id, n.file_path AS fp, r.calls AS calls
2190
+ FROM runs r JOIN nodes n ON n.id = r.id
2191
+ ),
2192
+ wires AS (
2193
+ SELECT sn.file_path AS fp, COUNT(DISTINCT tn.file_path) AS reaches
2194
+ FROM edges e
2195
+ JOIN nodes sn ON sn.id = e.source
2196
+ JOIN nodes tn ON tn.id = e.target
2197
+ WHERE e.kind != 'contains'
2198
+ AND sn.file_path <> tn.file_path
2199
+ AND sn.file_path IN (SELECT fp FROM cand)
2200
+ GROUP BY sn.file_path
2201
+ )
2202
+ SELECT c.id AS nodeId,
2203
+ c.fp AS filePath,
2204
+ c.calls AS calls,
2205
+ COALESCE(w.reaches, 0) AS reaches,
2206
+ c.calls * (1 + COALESCE(w.reaches, 0)) AS score
2207
+ FROM cand c LEFT JOIN wires w ON w.fp = c.fp
2208
+ ORDER BY score DESC, calls DESC, filePath
2209
+ LIMIT ?`)
2210
+ .all(limit);
2211
+ }
2212
+ /**
2213
+ * How many OTHER files depend on each of the given files.
2214
+ *
2215
+ * Counted through the symbols, not the file nodes: an `imports` edge points
2216
+ * at the imported symbol, so a file node almost never receives one and
2217
+ * counting edges into it would report every file as depended on by nobody.
2218
+ * Same-file edges are excluded, which is what makes zero mean "nothing else
2219
+ * in the index reaches into this file" — the honest reading of a root.
2220
+ */
2221
+ getFileDependentCounts(filePaths) {
2222
+ if (filePaths.length === 0)
2223
+ return [];
2224
+ return this.db
2225
+ .prepare(`SELECT tn.file_path AS filePath, COUNT(DISTINCT sn.file_path) AS dependents
2226
+ FROM edges e
2227
+ JOIN nodes tn ON tn.id = e.target
2228
+ JOIN nodes sn ON sn.id = e.source
2229
+ WHERE e.kind != 'contains'
2230
+ AND tn.file_path IN (SELECT value FROM json_each(?))
2231
+ AND sn.file_path <> tn.file_path
2232
+ GROUP BY tn.file_path`)
2233
+ .all(JSON.stringify(filePaths));
2234
+ }
2235
+ /**
2236
+ * How far each of the given files reaches OUT: distinct other files its
2237
+ * symbols touch, and how many references that is.
2238
+ *
2239
+ * The mirror of {@link getFileDependentCounts}, and the same reasoning about
2240
+ * `contains` and same-file edges applies. It is driven from `nodes` rather
2241
+ * than from `edges` so the work is proportional to the files asked about —
2242
+ * the entry-points endpoint asks it about every test file in the index, and
2243
+ * an edge-first plan would scan the whole table to answer a question about a
2244
+ * tenth of it.
2245
+ */
2246
+ getFileReachCounts(filePaths) {
2247
+ if (filePaths.length === 0)
2248
+ return [];
2249
+ return this.db
2250
+ .prepare(`SELECT sn.file_path AS filePath,
2251
+ COUNT(DISTINCT tn.file_path) AS reaches,
2252
+ COUNT(*) AS refs
2253
+ FROM nodes sn
2254
+ JOIN edges e ON e.source = sn.id
2255
+ JOIN nodes tn ON tn.id = e.target
2256
+ WHERE sn.file_path IN (SELECT value FROM json_each(?))
2257
+ AND e.kind != 'contains'
2258
+ AND tn.file_path <> sn.file_path
2259
+ GROUP BY sn.file_path`)
2260
+ .all(JSON.stringify(filePaths));
2261
+ }
2262
+ /**
2263
+ * The `file` nodes for the given paths, in one query.
2264
+ *
2265
+ * A file's own node is what makes a file row navigable, and looking it up
2266
+ * with {@link getNodesInFile} means materialising every symbol in the file to
2267
+ * throw all but one away.
2268
+ */
2269
+ getFileNodes(filePaths) {
2270
+ if (filePaths.length === 0)
2271
+ return [];
2272
+ const rows = this.db
2273
+ .prepare(`SELECT * FROM nodes
2274
+ WHERE kind = 'file'
2275
+ AND file_path IN (SELECT value FROM json_each(?))`)
2276
+ .all(JSON.stringify(filePaths));
2277
+ return rows.map(rowToNode);
2278
+ }
2279
+ /**
2280
+ * Roll the whole edge table up to module granularity in one pass.
2281
+ *
2282
+ * The caller decides what a module IS — it hands in a file → module
2283
+ * assignment and gets back the cross-module traffic. That split is
2284
+ * deliberate: naming modules is a *policy* (top-level directories, a façade
2285
+ * file kept separate, a monorepo root) that belongs where the reader lives,
2286
+ * while grouping a million edges by it is *mechanics* that must happen in
2287
+ * SQLite. Doing the fold in JavaScript instead means materialising every
2288
+ * cross-file edge in memory; doing the naming in SQL means a tower of
2289
+ * `instr`/`substr` no one can read.
2290
+ *
2291
+ * The assignment lands in a TEMP table with a primary key, so the join is
2292
+ * indexed and the result set is bounded by modules², not by edges. Temp
2293
+ * tables live in SQLite's own temp database, so this stays valid against a
2294
+ * read-only main.
2295
+ *
2296
+ * Two result sets, because they need two different groupings over the same
2297
+ * join: `links` counts edges per (module, module, kind), and `pairs` names
2298
+ * the busiest symbol pairs behind each link (the map's tooltip). `pairs` is
2299
+ * ranked and cut inside SQLite — the un-cut grouping is the one thing here
2300
+ * that scales with distinct symbol names rather than with modules. Pairs are
2301
+ * ranked by `declared` before raw count, so a link's tooltip names the
2302
+ * symbols the source actually points at rather than whichever `has`/`get`
2303
+ * happened to name-match most often.
2304
+ *
2305
+ * `declared` is the subset of a link's edges that came from something the
2306
+ * source *writes down*: an import, a qualified name, an inheritance clause,
2307
+ * or a call through a typed receiver. It exists because bare name matching
2308
+ * (`resolvedBy: 'exact-match'`) is what invents cross-module links out of
2309
+ * common method names — `run`, `push`, `finish` — and a map that lets those
2310
+ * decide the layering puts the storage layer above the CLI.
2311
+ */
2312
+ aggregateModuleGraph(assignments, options) {
2313
+ if (assignments.length === 0 || options.kinds.length === 0)
2314
+ return { links: [], pairs: [] };
2315
+ const CONFIDENCE = `COALESCE(json_extract(e.metadata, '$.confidence'), 1)`;
2316
+ const DECLARED = `(json_extract(e.metadata, '$.resolvedBy') IN ('import', 'qualified-name')
2317
+ OR e.kind IN ('extends', 'implements')
2318
+ OR (json_extract(e.metadata, '$.resolvedBy') = 'instance-method'
2319
+ AND ${CONFIDENCE} >= 0.9))`;
2320
+ this.db.exec('DROP TABLE IF EXISTS temp.cg_module_map');
2321
+ this.db.exec('CREATE TEMP TABLE cg_module_map (path TEXT PRIMARY KEY, mod TEXT NOT NULL)');
2322
+ try {
2323
+ const insert = this.db.prepare('INSERT OR REPLACE INTO cg_module_map (path, mod) VALUES (?, ?)');
2324
+ this.db.exec('BEGIN');
2325
+ try {
2326
+ for (const row of assignments)
2327
+ insert.run(row.filePath, row.module);
2328
+ this.db.exec('COMMIT');
2329
+ }
2330
+ catch (err) {
2331
+ this.db.exec('ROLLBACK');
2332
+ throw err;
2333
+ }
2334
+ // ONE pass over the edge table. Grouping by the symbol names as well as
2335
+ // the modules costs nothing extra in scan time — the join is what is
2336
+ // expensive — and it buys both results from a single scan. Measured on
2337
+ // this index inflated to 1.6M edges: 1.66s for this query against 3.0s
2338
+ // for the module-level and name-level queries run separately, which is
2339
+ // the difference between meeting and missing the map's cold budget on a
2340
+ // ten-thousand-file repository.
2341
+ const rows = this.db
2342
+ .prepare(`SELECT ms.mod AS source, mt.mod AS target, e.kind AS kind,
2343
+ sn.name AS "from", tn.name AS "to",
2344
+ SUM(CASE WHEN ${CONFIDENCE} >= ? THEN 1 ELSE 0 END) AS count,
2345
+ SUM(CASE WHEN ${CONFIDENCE} >= ? AND ${DECLARED} THEN 1 ELSE 0 END) AS declared,
2346
+ SUM(CASE WHEN ${CONFIDENCE} < ? THEN 1 ELSE 0 END) AS uncertain
2347
+ FROM edges e
2348
+ JOIN nodes sn ON sn.id = e.source
2349
+ JOIN nodes tn ON tn.id = e.target
2350
+ JOIN cg_module_map ms ON ms.path = sn.file_path
2351
+ JOIN cg_module_map mt ON mt.path = tn.file_path
2352
+ WHERE e.kind IN (SELECT value FROM json_each(?))
2353
+ AND ms.mod <> mt.mod
2354
+ GROUP BY ms.mod, mt.mod, e.kind, sn.name, tn.name`)
2355
+ .all(options.minConfidence, options.minConfidence, options.minConfidence, JSON.stringify(options.kinds));
2356
+ return foldModuleRows(rows, options);
2357
+ }
2358
+ finally {
2359
+ this.db.exec('DROP TABLE IF EXISTS temp.cg_module_map');
2360
+ }
2361
+ }
2362
+ /**
2363
+ * Every ordered pair of files where one reaches into the other, once each.
2364
+ *
2365
+ * The input a cycle finder wants: file-level circular dependencies are the
2366
+ * strongly connected components of this graph. One query instead of the
2367
+ * dependency lookup per file that {@link GraphQueryManager.findCircularDependencies}
2368
+ * does — which matters because a cycle report is only interesting on a large
2369
+ * repo, and that is exactly where a query per file stops being affordable.
2370
+ *
2371
+ * `contains` is excluded (a file "contains" its own symbols, which is not a
2372
+ * dependency), and so are same-file edges and low-confidence name matches:
2373
+ * a cycle conjured by a common method name is a false alarm a reader cannot
2374
+ * check.
2375
+ */
2376
+ getCrossFileDependencyPairs(minConfidence) {
2377
+ return this.db
2378
+ .prepare(`SELECT DISTINCT sn.file_path AS source, tn.file_path AS target
2379
+ FROM edges e
2380
+ JOIN nodes sn ON sn.id = e.source
2381
+ JOIN nodes tn ON tn.id = e.target
2382
+ WHERE e.kind <> 'contains'
2383
+ AND sn.file_path <> tn.file_path
2384
+ AND COALESCE(json_extract(e.metadata, '$.confidence'), 1) >= ?`)
2385
+ .all(minConfidence);
2386
+ }
2387
+ /**
2388
+ * Every unresolved reference recorded in one FILE, ordered by line.
2389
+ *
2390
+ * The per-symbol form above answers "what does this body reach that the
2391
+ * index does not hold". A whole-file reader asks the same question of every
2392
+ * line at once, and asking it one symbol at a time is a query per symbol —
2393
+ * 153 of them on this repo's largest file. `unresolved_refs.file_path` is
2394
+ * indexed, so this is one lookup whatever the file holds.
2395
+ *
2396
+ * `limit` bounds the answer rather than the work: the caller draws a marker
2397
+ * per row, and a generated file with fifty thousand of them would ship
2398
+ * megabytes to say something a count already says. Rows come back in line
2399
+ * order, so a cap trims the END of the file, which is at least legible.
2400
+ */
2401
+ getUnresolvedReferencesInFile(filePath, limit = 5000) {
2402
+ if (!this.stmts.getUnresolvedInFile) {
2403
+ this.stmts.getUnresolvedInFile = this.db.prepare('SELECT * FROM unresolved_refs WHERE file_path = ? ORDER BY line, col LIMIT ?');
2404
+ }
2405
+ const rows = this.stmts.getUnresolvedInFile.all(filePath, limit);
2406
+ return rows.map((row) => ({
2407
+ fromNodeId: row.from_node_id,
2408
+ referenceName: row.reference_name,
2409
+ referenceKind: row.reference_kind,
2410
+ line: row.line,
2411
+ column: row.col,
2412
+ candidates: row.candidates ? (0, utils_1.safeJsonParse)(row.candidates, undefined) : undefined,
2413
+ filePath: row.file_path,
2414
+ language: row.language,
2415
+ rowId: row.id,
2416
+ }));
2417
+ }
2418
+ /**
2419
+ * References recorded against a symbol that never resolved to a node — the
2420
+ * calls and type mentions that leave the index (a third-party package, a
2421
+ * runtime builtin, a language construct extraction doesn't model).
2422
+ *
2423
+ * Read-only. It exists so a reader can say "N calls into symbols outside the
2424
+ * index" instead of silently showing a callee list shorter than the body's
2425
+ * call sites, which reads as "nothing else happens here".
2426
+ */
2427
+ getUnresolvedReferencesFrom(fromNodeId) {
2428
+ if (!this.stmts.getUnresolvedFromNode) {
2429
+ this.stmts.getUnresolvedFromNode = this.db.prepare('SELECT * FROM unresolved_refs WHERE from_node_id = ?');
2430
+ }
2431
+ const rows = this.stmts.getUnresolvedFromNode.all(fromNodeId);
2432
+ return rows.map((row) => ({
2433
+ fromNodeId: row.from_node_id,
2434
+ referenceName: row.reference_name,
2435
+ referenceKind: row.reference_kind,
2436
+ line: row.line,
2437
+ column: row.col,
2438
+ candidates: row.candidates ? (0, utils_1.safeJsonParse)(row.candidates, undefined) : undefined,
2439
+ filePath: row.file_path,
2440
+ language: row.language,
2441
+ rowId: row.id,
2442
+ }));
2443
+ }
1566
2444
  /**
1567
2445
  * Find all edges where both source and target are in the given node set.
1568
2446
  * Useful for recovering inter-node connectivity after BFS.
@@ -1626,13 +2504,14 @@ class QueryBuilder {
1626
2504
  }
1627
2505
  /**
1628
2506
  * Cross-file edges whose TARGET is a node in `filePath` and whose SOURCE is a
1629
- * node in a *different* file, paired with the target node's (name, kind) so a
1630
- * caller can re-resolve the edge to the re-indexed target's new ID (node IDs
1631
- * are `sha256(filePath:kind:name:line)`, so any line shift in the callee file
1632
- * changes target IDs and a naive re-insert by old ID silently drops them).
1633
- * Used by `storeExtractionResult` to preserve incoming edges across a file
1634
- * re-index (issue #899). Same edge-kind rules as
1635
- * {@link getDependentFilePaths}: all kinds except `contains`.
2507
+ * node in a *different* file, paired with the target node's (name, kind).
2508
+ * Node IDs are `sha256(filePath:kind:name:line)`, so any line shift in the
2509
+ * callee file changes target IDs and a naive re-insert by old ID silently
2510
+ * drops them; `storeExtractionResult` instead follows each old target to the
2511
+ * re-indexed node that replaces it (see {@link getNodeIdentitiesByFile}) to
2512
+ * preserve incoming edges across a file re-index (issue #899). Same
2513
+ * edge-kind rules as {@link getDependentFilePaths}: all kinds except
2514
+ * `contains`.
1636
2515
  */
1637
2516
  getCrossFileIncomingEdgesWithTarget(filePath) {
1638
2517
  const sql = `SELECT e.*, tgt.name AS target_name, tgt.kind AS target_kind,
@@ -1755,6 +2634,29 @@ class QueryBuilder {
1755
2634
  * restricted to the candidate list: the file that imports it is usually
1756
2635
  * not itself a candidate.
1757
2636
  *
2637
+ * ### Interface MEMBERS are transparent to all four conditions
2638
+ *
2639
+ * A `method_signature` / `property_signature` inside an interface enters the
2640
+ * graph as a `method` / `property` node (#1638). Read literally that would
2641
+ * break every condition here at once: condition 2 sees non-type kinds and
2642
+ * stops flagging, and — worse, because it is silent — condition 4 starts
2643
+ * seeing inbound `calls` edges the moment a call site through the shim's API
2644
+ * finally has a signature to land on. An ambient `.d.ts` would quietly lose
2645
+ * its damping precisely BECAUSE the platform API it declares is widely used.
2646
+ *
2647
+ * So an interface-owned member is treated the way `parameter` already is: it
2648
+ * neither qualifies, disqualifies, nor counts as inbound dependency. That is
2649
+ * not a new judgement call, it is what keeps the rule measuring what it was
2650
+ * measured on — before #1638 these nodes did not exist, so excluding them
2651
+ * reproduces the 0–4% flag rate the thresholds above were tuned against. It
2652
+ * is also the semantically right answer: a signature with no body is on the
2653
+ * same side of the line as the interface that owns it, and a call edge
2654
+ * landing on one is still not a file that can answer a flow question.
2655
+ *
2656
+ * The interface ITSELF is untouched: the `references` edges an importing
2657
+ * module aims at `UploadStorage` still disqualify the file under (4), which
2658
+ * is what keeps a depended-on `types.ts` out of the flag.
2659
+ *
1758
2660
  * Bounded-lookup like {@link getGeneratedPathsAmong}: callers hold a ranked
1759
2661
  * candidate list, so this is a partial-index probe over a handful of paths.
1760
2662
  */
@@ -1770,14 +2672,15 @@ class QueryBuilder {
1770
2672
  // things the file declares, so they neither qualify nor disqualify.
1771
2673
  const rows = this.db
1772
2674
  .prepare(`
1773
- SELECT file_path,
1774
- SUM(CASE WHEN kind NOT IN ('file','import','export','parameter')
2675
+ SELECT n.file_path AS file_path,
2676
+ SUM(CASE WHEN n.kind NOT IN ('file','import','export','parameter')
2677
+ AND NOT ${IS_INTERFACE_MEMBER('n')}
1775
2678
  THEN 1 ELSE 0 END) AS declared,
1776
- SUM(CASE WHEN kind IN ('interface','type_alias','enum','enum_member','namespace')
2679
+ SUM(CASE WHEN n.kind IN ('interface','type_alias','enum','enum_member','namespace')
1777
2680
  THEN 1 ELSE 0 END) AS typeDeclared
1778
- FROM nodes
1779
- WHERE file_path IN (${placeholders})
1780
- GROUP BY file_path
2681
+ FROM nodes n
2682
+ WHERE n.file_path IN (${placeholders})
2683
+ GROUP BY n.file_path
1781
2684
  `)
1782
2685
  .all(...chunk);
1783
2686
  let candidates = rows
@@ -1793,17 +2696,22 @@ class QueryBuilder {
1793
2696
  .all(...candidates).map((r) => r.file_path));
1794
2697
  candidates = candidates.filter((p) => !hit.has(p));
1795
2698
  };
1796
- // (3) originates behaviour
2699
+ // (3) originates behaviour — a signature has no body to originate from,
2700
+ // so an edge attributed to one is not evidence about this file.
1797
2701
  disqualify(`
1798
2702
  SELECT DISTINCT n.file_path AS file_path
1799
2703
  FROM edges e JOIN nodes n ON n.id = e.source
1800
2704
  WHERE e.kind IN ('calls','instantiates') AND n.file_path IN ($IN$)
2705
+ AND NOT ${IS_INTERFACE_MEMBER('n')}
1801
2706
  `);
1802
- // (4) something outside the file depends on it
2707
+ // (4) something outside the file depends on it — but a call that lands on
2708
+ // an interface's own signature is a use of the API, not a dependency on
2709
+ // this file's structure. The edges aimed at the interface still count.
1803
2710
  disqualify(`
1804
2711
  SELECT DISTINCT t.file_path AS file_path
1805
2712
  FROM edges e JOIN nodes t ON t.id = e.target JOIN nodes s ON s.id = e.source
1806
2713
  WHERE t.file_path IN ($IN$) AND s.file_path <> t.file_path
2714
+ AND NOT ${IS_INTERFACE_MEMBER('t')}
1807
2715
  `);
1808
2716
  for (const path of candidates)
1809
2717
  found.add(path);
@@ -1848,6 +2756,17 @@ class QueryBuilder {
1848
2756
  const row = this.stmts.getFileByPath.get(filePath);
1849
2757
  return row ? rowToFileRecord(row) : null;
1850
2758
  }
2759
+ /**
2760
+ * Whether any tracked file lives under the project-relative POSIX directory
2761
+ * `dir`. A range scan on the `path` primary key — `dir/` up to `dir0` ('0'
2762
+ * is the byte after '/') — so it costs one index probe at any repo size.
2763
+ */
2764
+ hasFilesUnder(dir) {
2765
+ if (!this.stmts.hasFilesUnder) {
2766
+ this.stmts.hasFilesUnder = this.db.prepare('SELECT 1 FROM files WHERE path >= ? AND path < ? LIMIT 1');
2767
+ }
2768
+ return this.stmts.hasFilesUnder.get(`${dir}/`, `${dir}0`) !== undefined;
2769
+ }
1851
2770
  /**
1852
2771
  * Get all tracked files
1853
2772
  */
@@ -1868,6 +2787,40 @@ class QueryBuilder {
1868
2787
  .get();
1869
2788
  return row?.last ?? null;
1870
2789
  }
2790
+ /**
2791
+ * The index's revision marker: how far the last sync got, and how many files
2792
+ * it left behind — one query, both numbers.
2793
+ *
2794
+ * This is the cheapest honest answer to "has the index moved since I last
2795
+ * looked". `MAX(indexed_at)` alone is not enough: a sync that only DELETES
2796
+ * files (a branch checkout that removed a directory) advances nothing, and
2797
+ * the graph the viewer is showing has still changed underneath it. The row
2798
+ * count catches exactly that case.
2799
+ */
2800
+ getIndexRevision() {
2801
+ const row = this.db
2802
+ .prepare('SELECT MAX(indexed_at) AS last, COUNT(*) AS files FROM files')
2803
+ .get();
2804
+ return { lastIndexedAt: row?.last ?? null, fileCount: row?.files ?? 0 };
2805
+ }
2806
+ /**
2807
+ * Files re-indexed strictly after `since` (ms since epoch), newest first.
2808
+ *
2809
+ * `total` is the real count; `paths` is capped at `limit`. Used by the
2810
+ * viewer's live channel to name what a sync just picked up. A file the same
2811
+ * sync DELETED cannot appear here — it has no row left — which is why the
2812
+ * caller compares {@link getIndexRevision} as well rather than treating an
2813
+ * empty list as "nothing happened".
2814
+ */
2815
+ getFilesIndexedSince(since, limit) {
2816
+ const count = this.db
2817
+ .prepare('SELECT COUNT(*) AS n FROM files WHERE indexed_at > ?')
2818
+ .get(since);
2819
+ const rows = this.db
2820
+ .prepare('SELECT path FROM files WHERE indexed_at > ? ORDER BY indexed_at DESC, path LIMIT ?')
2821
+ .all(since, Math.max(0, limit));
2822
+ return { paths: rows.map((r) => r.path), total: count?.n ?? rows.length };
2823
+ }
1871
2824
  /**
1872
2825
  * Get files that need re-indexing (hash changed)
1873
2826
  */
@@ -2022,11 +2975,19 @@ class QueryBuilder {
2022
2975
  * (§7a.2) — while the seek is O(batch) forever. `id` is the rowid alias, so
2023
2976
  * the enumeration order is identical to the OFFSET reader's.
2024
2977
  */
2025
- getUnresolvedReferencesBatchAfter(afterRowId, limit) {
2026
- if (!this.stmts.getUnresolvedBatchAfter) {
2027
- this.stmts.getUnresolvedBatchAfter = this.db.prepare("SELECT * FROM unresolved_refs WHERE status = 'pending' AND id > ? ORDER BY id LIMIT ?");
2028
- }
2029
- const rows = this.stmts.getUnresolvedBatchAfter.all(afterRowId, limit);
2978
+ getUnresolvedReferencesBatchAfter(afterRowId, limit, prerequisites) {
2979
+ // Resolution prerequisites must be committed before dependent calls,
2980
+ // even when an interrupted sync queued their rows in a different order
2981
+ // from a clean index (#1577). Each phase still seeks by row id in bounded
2982
+ // memory; the default preserves the public reader's original enumeration.
2983
+ const key = prerequisites === undefined ? 'getUnresolvedBatchAfter'
2984
+ : prerequisites ? 'getUnresolvedPrerequisitesAfter' : 'getUnresolvedDependentsAfter';
2985
+ if (!this.stmts[key]) {
2986
+ const filter = prerequisites === undefined ? ''
2987
+ : ` AND reference_kind ${prerequisites ? 'IN' : 'NOT IN'} ('imports', 'extends', 'implements')`;
2988
+ this.stmts[key] = this.db.prepare(`SELECT * FROM unresolved_refs WHERE status = 'pending' AND id > ?${filter} ORDER BY id LIMIT ?`);
2989
+ }
2990
+ const rows = this.stmts[key].all(afterRowId, limit);
2030
2991
  return rows.map((row) => ({
2031
2992
  fromNodeId: row.from_node_id,
2032
2993
  referenceName: row.reference_name,
@@ -2370,6 +3331,17 @@ class QueryBuilder {
2370
3331
  })();
2371
3332
  return changed;
2372
3333
  }
3334
+ /**
3335
+ * Replace resolution edges with their original unresolved references as one
3336
+ * transaction. If ref insertion fails, the edge deletion is rolled back.
3337
+ */
3338
+ replaceResolutionEdgesWithUnresolvedRefs(edgeIds, refs) {
3339
+ return this.db.transaction(() => {
3340
+ const changed = this.deleteEdgesByIds(edgeIds);
3341
+ this.insertUnresolvedRefsBatch(refs);
3342
+ return changed;
3343
+ })();
3344
+ }
2373
3345
  /**
2374
3346
  * Distinct node names present in the given files — the symbol names a sync
2375
3347
  * pass uses to look up retryable failed refs after those files changed.
@@ -2517,4 +3489,71 @@ class QueryBuilder {
2517
3489
  }
2518
3490
  }
2519
3491
  exports.QueryBuilder = QueryBuilder;
3492
+ function foldModuleRows(rows, options) {
3493
+ // A module id is a path and may contain anything printable, so the key
3494
+ // separator has to be something a path cannot hold.
3495
+ const SEP = '\u0000';
3496
+ const links = new Map();
3497
+ const pairKinds = new Set(options.pairKinds);
3498
+ const wantPairs = options.topPairsPerLink > 0 && pairKinds.size > 0;
3499
+ const pairTotals = new Map();
3500
+ for (const row of rows) {
3501
+ const linkKey = `${row.source}${SEP}${row.target}${SEP}${row.kind}`;
3502
+ const link = links.get(linkKey);
3503
+ if (link) {
3504
+ link.count += row.count;
3505
+ link.declared += row.declared;
3506
+ link.uncertain += row.uncertain;
3507
+ }
3508
+ else {
3509
+ links.set(linkKey, {
3510
+ source: row.source,
3511
+ target: row.target,
3512
+ kind: row.kind,
3513
+ count: row.count,
3514
+ declared: row.declared,
3515
+ uncertain: row.uncertain,
3516
+ });
3517
+ }
3518
+ // Only the confident half of a row can be named: an uncertain edge is a
3519
+ // guess, and printing "a to b, 12" for twelve guesses is the map claiming
3520
+ // something it does not know.
3521
+ if (!wantPairs || row.count === 0 || !pairKinds.has(row.kind))
3522
+ continue;
3523
+ const pairKey = `${row.source}${SEP}${row.target}${SEP}${row.from}${SEP}${row.to}`;
3524
+ const pair = pairTotals.get(pairKey);
3525
+ if (pair) {
3526
+ pair.count += row.count;
3527
+ pair.declared += row.declared;
3528
+ }
3529
+ else {
3530
+ pairTotals.set(pairKey, {
3531
+ source: row.source,
3532
+ target: row.target,
3533
+ from: row.from,
3534
+ to: row.to,
3535
+ count: row.count,
3536
+ declared: row.declared,
3537
+ });
3538
+ }
3539
+ }
3540
+ const byLink = new Map();
3541
+ for (const pair of pairTotals.values()) {
3542
+ const key = `${pair.source}${SEP}${pair.target}`;
3543
+ let list = byLink.get(key);
3544
+ if (!list)
3545
+ byLink.set(key, (list = []));
3546
+ list.push(pair);
3547
+ }
3548
+ const pairs = [];
3549
+ for (const list of byLink.values()) {
3550
+ list.sort((a, b) => b.declared - a.declared ||
3551
+ b.count - a.count ||
3552
+ a.from.localeCompare(b.from) ||
3553
+ a.to.localeCompare(b.to));
3554
+ for (const pair of list.slice(0, options.topPairsPerLink))
3555
+ pairs.push(pair);
3556
+ }
3557
+ return { links: [...links.values()], pairs };
3558
+ }
2520
3559
  //# sourceMappingURL=queries.js.map