optave-codegraph 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1672) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +984 -0
  3. package/dist/ast-analysis/engine.d.ts +19 -0
  4. package/dist/ast-analysis/engine.d.ts.map +1 -0
  5. package/dist/ast-analysis/engine.js +660 -0
  6. package/dist/ast-analysis/engine.js.map +1 -0
  7. package/dist/ast-analysis/metrics.d.ts +34 -0
  8. package/dist/ast-analysis/metrics.d.ts.map +1 -0
  9. package/dist/ast-analysis/metrics.js +123 -0
  10. package/dist/ast-analysis/metrics.js.map +1 -0
  11. package/dist/ast-analysis/rules/b2.d.ts +7 -0
  12. package/dist/ast-analysis/rules/b2.d.ts.map +1 -0
  13. package/dist/ast-analysis/rules/b2.js +240 -0
  14. package/dist/ast-analysis/rules/b2.js.map +1 -0
  15. package/dist/ast-analysis/rules/b3.d.ts +6 -0
  16. package/dist/ast-analysis/rules/b3.d.ts.map +1 -0
  17. package/dist/ast-analysis/rules/b3.js +105 -0
  18. package/dist/ast-analysis/rules/b3.js.map +1 -0
  19. package/dist/ast-analysis/rules/b4.d.ts +9 -0
  20. package/dist/ast-analysis/rules/b4.d.ts.map +1 -0
  21. package/dist/ast-analysis/rules/b4.js +361 -0
  22. package/dist/ast-analysis/rules/b4.js.map +1 -0
  23. package/dist/ast-analysis/rules/b5.d.ts +4 -0
  24. package/dist/ast-analysis/rules/b5.d.ts.map +1 -0
  25. package/dist/ast-analysis/rules/b5.js +52 -0
  26. package/dist/ast-analysis/rules/b5.js.map +1 -0
  27. package/dist/ast-analysis/rules/c.d.ts +4 -0
  28. package/dist/ast-analysis/rules/c.d.ts.map +1 -0
  29. package/dist/ast-analysis/rules/c.js +143 -0
  30. package/dist/ast-analysis/rules/c.js.map +1 -0
  31. package/dist/ast-analysis/rules/csharp.d.ts +7 -0
  32. package/dist/ast-analysis/rules/csharp.d.ts.map +1 -0
  33. package/dist/ast-analysis/rules/csharp.js +196 -0
  34. package/dist/ast-analysis/rules/csharp.js.map +1 -0
  35. package/dist/ast-analysis/rules/go.d.ts +7 -0
  36. package/dist/ast-analysis/rules/go.d.ts.map +1 -0
  37. package/dist/ast-analysis/rules/go.js +173 -0
  38. package/dist/ast-analysis/rules/go.js.map +1 -0
  39. package/dist/ast-analysis/rules/index.d.ts +13 -0
  40. package/dist/ast-analysis/rules/index.d.ts.map +1 -0
  41. package/dist/ast-analysis/rules/index.js +325 -0
  42. package/dist/ast-analysis/rules/index.js.map +1 -0
  43. package/dist/ast-analysis/rules/java.d.ts +7 -0
  44. package/dist/ast-analysis/rules/java.d.ts.map +1 -0
  45. package/dist/ast-analysis/rules/java.js +167 -0
  46. package/dist/ast-analysis/rules/java.js.map +1 -0
  47. package/dist/ast-analysis/rules/javascript.d.ts +7 -0
  48. package/dist/ast-analysis/rules/javascript.d.ts.map +1 -0
  49. package/dist/ast-analysis/rules/javascript.js +233 -0
  50. package/dist/ast-analysis/rules/javascript.js.map +1 -0
  51. package/dist/ast-analysis/rules/php.d.ts +7 -0
  52. package/dist/ast-analysis/rules/php.d.ts.map +1 -0
  53. package/dist/ast-analysis/rules/php.js +212 -0
  54. package/dist/ast-analysis/rules/php.js.map +1 -0
  55. package/dist/ast-analysis/rules/python.d.ts +7 -0
  56. package/dist/ast-analysis/rules/python.d.ts.map +1 -0
  57. package/dist/ast-analysis/rules/python.js +189 -0
  58. package/dist/ast-analysis/rules/python.js.map +1 -0
  59. package/dist/ast-analysis/rules/ruby.d.ts +7 -0
  60. package/dist/ast-analysis/rules/ruby.d.ts.map +1 -0
  61. package/dist/ast-analysis/rules/ruby.js +193 -0
  62. package/dist/ast-analysis/rules/ruby.js.map +1 -0
  63. package/dist/ast-analysis/rules/rust.d.ts +7 -0
  64. package/dist/ast-analysis/rules/rust.d.ts.map +1 -0
  65. package/dist/ast-analysis/rules/rust.js +166 -0
  66. package/dist/ast-analysis/rules/rust.js.map +1 -0
  67. package/dist/ast-analysis/shared.d.ts +12 -0
  68. package/dist/ast-analysis/shared.d.ts.map +1 -0
  69. package/dist/ast-analysis/shared.js +166 -0
  70. package/dist/ast-analysis/shared.js.map +1 -0
  71. package/dist/ast-analysis/visitor-utils.d.ts +70 -0
  72. package/dist/ast-analysis/visitor-utils.d.ts.map +1 -0
  73. package/dist/ast-analysis/visitor-utils.js +235 -0
  74. package/dist/ast-analysis/visitor-utils.js.map +1 -0
  75. package/dist/ast-analysis/visitor.d.ts +27 -0
  76. package/dist/ast-analysis/visitor.d.ts.map +1 -0
  77. package/dist/ast-analysis/visitor.js +178 -0
  78. package/dist/ast-analysis/visitor.js.map +1 -0
  79. package/dist/ast-analysis/visitors/ast-store-visitor.d.ts +4 -0
  80. package/dist/ast-analysis/visitors/ast-store-visitor.d.ts.map +1 -0
  81. package/dist/ast-analysis/visitors/ast-store-visitor.js +288 -0
  82. package/dist/ast-analysis/visitors/ast-store-visitor.js.map +1 -0
  83. package/dist/ast-analysis/visitors/cfg-conditionals.d.ts +5 -0
  84. package/dist/ast-analysis/visitors/cfg-conditionals.d.ts.map +1 -0
  85. package/dist/ast-analysis/visitors/cfg-conditionals.js +166 -0
  86. package/dist/ast-analysis/visitors/cfg-conditionals.js.map +1 -0
  87. package/dist/ast-analysis/visitors/cfg-loops.d.ts +7 -0
  88. package/dist/ast-analysis/visitors/cfg-loops.d.ts.map +1 -0
  89. package/dist/ast-analysis/visitors/cfg-loops.js +73 -0
  90. package/dist/ast-analysis/visitors/cfg-loops.js.map +1 -0
  91. package/dist/ast-analysis/visitors/cfg-shared.d.ts +56 -0
  92. package/dist/ast-analysis/visitors/cfg-shared.d.ts.map +1 -0
  93. package/dist/ast-analysis/visitors/cfg-shared.js +107 -0
  94. package/dist/ast-analysis/visitors/cfg-shared.js.map +1 -0
  95. package/dist/ast-analysis/visitors/cfg-try-catch.d.ts +4 -0
  96. package/dist/ast-analysis/visitors/cfg-try-catch.d.ts.map +1 -0
  97. package/dist/ast-analysis/visitors/cfg-try-catch.js +100 -0
  98. package/dist/ast-analysis/visitors/cfg-try-catch.js.map +1 -0
  99. package/dist/ast-analysis/visitors/cfg-visitor.d.ts +5 -0
  100. package/dist/ast-analysis/visitors/cfg-visitor.d.ts.map +1 -0
  101. package/dist/ast-analysis/visitors/cfg-visitor.js +231 -0
  102. package/dist/ast-analysis/visitors/cfg-visitor.js.map +1 -0
  103. package/dist/ast-analysis/visitors/complexity-visitor.d.ts +8 -0
  104. package/dist/ast-analysis/visitors/complexity-visitor.d.ts.map +1 -0
  105. package/dist/ast-analysis/visitors/complexity-visitor.js +233 -0
  106. package/dist/ast-analysis/visitors/complexity-visitor.js.map +1 -0
  107. package/dist/ast-analysis/visitors/dataflow-visitor.d.ts +5 -0
  108. package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -0
  109. package/dist/ast-analysis/visitors/dataflow-visitor.js +378 -0
  110. package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -0
  111. package/dist/cli/commands/ast.d.ts +3 -0
  112. package/dist/cli/commands/ast.d.ts.map +1 -0
  113. package/dist/cli/commands/ast.js +23 -0
  114. package/dist/cli/commands/ast.js.map +1 -0
  115. package/dist/cli/commands/audit.d.ts +3 -0
  116. package/dist/cli/commands/audit.d.ts.map +1 -0
  117. package/dist/cli/commands/audit.js +47 -0
  118. package/dist/cli/commands/audit.js.map +1 -0
  119. package/dist/cli/commands/batch.d.ts +3 -0
  120. package/dist/cli/commands/batch.d.ts.map +1 -0
  121. package/dist/cli/commands/batch.js +66 -0
  122. package/dist/cli/commands/batch.js.map +1 -0
  123. package/dist/cli/commands/branch-compare.d.ts +3 -0
  124. package/dist/cli/commands/branch-compare.d.ts.map +1 -0
  125. package/dist/cli/commands/branch-compare.js +26 -0
  126. package/dist/cli/commands/branch-compare.js.map +1 -0
  127. package/dist/cli/commands/brief.d.ts +3 -0
  128. package/dist/cli/commands/brief.d.ts.map +1 -0
  129. package/dist/cli/commands/brief.js +12 -0
  130. package/dist/cli/commands/brief.js.map +1 -0
  131. package/dist/cli/commands/build.d.ts +3 -0
  132. package/dist/cli/commands/build.d.ts.map +1 -0
  133. package/dist/cli/commands/build.js +33 -0
  134. package/dist/cli/commands/build.js.map +1 -0
  135. package/dist/cli/commands/cfg.d.ts +3 -0
  136. package/dist/cli/commands/cfg.d.ts.map +1 -0
  137. package/dist/cli/commands/cfg.js +27 -0
  138. package/dist/cli/commands/cfg.js.map +1 -0
  139. package/dist/cli/commands/check.d.ts +3 -0
  140. package/dist/cli/commands/check.d.ts.map +1 -0
  141. package/dist/cli/commands/check.js +65 -0
  142. package/dist/cli/commands/check.js.map +1 -0
  143. package/dist/cli/commands/children.d.ts +3 -0
  144. package/dist/cli/commands/children.d.ts.map +1 -0
  145. package/dist/cli/commands/children.js +33 -0
  146. package/dist/cli/commands/children.js.map +1 -0
  147. package/dist/cli/commands/co-change.d.ts +3 -0
  148. package/dist/cli/commands/co-change.d.ts.map +1 -0
  149. package/dist/cli/commands/co-change.js +66 -0
  150. package/dist/cli/commands/co-change.js.map +1 -0
  151. package/dist/cli/commands/communities.d.ts +3 -0
  152. package/dist/cli/commands/communities.d.ts.map +1 -0
  153. package/dist/cli/commands/communities.js +20 -0
  154. package/dist/cli/commands/communities.js.map +1 -0
  155. package/dist/cli/commands/complexity.d.ts +3 -0
  156. package/dist/cli/commands/complexity.d.ts.map +1 -0
  157. package/dist/cli/commands/complexity.js +47 -0
  158. package/dist/cli/commands/complexity.js.map +1 -0
  159. package/dist/cli/commands/config.d.ts +3 -0
  160. package/dist/cli/commands/config.d.ts.map +1 -0
  161. package/dist/cli/commands/config.js +275 -0
  162. package/dist/cli/commands/config.js.map +1 -0
  163. package/dist/cli/commands/context.d.ts +3 -0
  164. package/dist/cli/commands/context.d.ts.map +1 -0
  165. package/dist/cli/commands/context.js +35 -0
  166. package/dist/cli/commands/context.js.map +1 -0
  167. package/dist/cli/commands/cycles.d.ts +3 -0
  168. package/dist/cli/commands/cycles.d.ts.map +1 -0
  169. package/dist/cli/commands/cycles.js +33 -0
  170. package/dist/cli/commands/cycles.js.map +1 -0
  171. package/dist/cli/commands/dataflow.d.ts +3 -0
  172. package/dist/cli/commands/dataflow.d.ts.map +1 -0
  173. package/dist/cli/commands/dataflow.js +29 -0
  174. package/dist/cli/commands/dataflow.js.map +1 -0
  175. package/dist/cli/commands/deps.d.ts +3 -0
  176. package/dist/cli/commands/deps.d.ts.map +1 -0
  177. package/dist/cli/commands/deps.js +18 -0
  178. package/dist/cli/commands/deps.js.map +1 -0
  179. package/dist/cli/commands/diff-impact.d.ts +3 -0
  180. package/dist/cli/commands/diff-impact.d.ts.map +1 -0
  181. package/dist/cli/commands/diff-impact.js +29 -0
  182. package/dist/cli/commands/diff-impact.js.map +1 -0
  183. package/dist/cli/commands/embed.d.ts +3 -0
  184. package/dist/cli/commands/embed.d.ts.map +1 -0
  185. package/dist/cli/commands/embed.js +75 -0
  186. package/dist/cli/commands/embed.js.map +1 -0
  187. package/dist/cli/commands/export.d.ts +3 -0
  188. package/dist/cli/commands/export.d.ts.map +1 -0
  189. package/dist/cli/commands/export.js +72 -0
  190. package/dist/cli/commands/export.js.map +1 -0
  191. package/dist/cli/commands/exports.d.ts +3 -0
  192. package/dist/cli/commands/exports.d.ts.map +1 -0
  193. package/dist/cli/commands/exports.js +14 -0
  194. package/dist/cli/commands/exports.js.map +1 -0
  195. package/dist/cli/commands/flow.d.ts +3 -0
  196. package/dist/cli/commands/flow.d.ts.map +1 -0
  197. package/dist/cli/commands/flow.js +32 -0
  198. package/dist/cli/commands/flow.js.map +1 -0
  199. package/dist/cli/commands/fn-impact.d.ts +3 -0
  200. package/dist/cli/commands/fn-impact.d.ts.map +1 -0
  201. package/dist/cli/commands/fn-impact.js +33 -0
  202. package/dist/cli/commands/fn-impact.js.map +1 -0
  203. package/dist/cli/commands/impact.d.ts +3 -0
  204. package/dist/cli/commands/impact.d.ts.map +1 -0
  205. package/dist/cli/commands/impact.js +12 -0
  206. package/dist/cli/commands/impact.js.map +1 -0
  207. package/dist/cli/commands/implementations.d.ts +3 -0
  208. package/dist/cli/commands/implementations.d.ts.map +1 -0
  209. package/dist/cli/commands/implementations.js +29 -0
  210. package/dist/cli/commands/implementations.js.map +1 -0
  211. package/dist/cli/commands/info.d.ts +3 -0
  212. package/dist/cli/commands/info.d.ts.map +1 -0
  213. package/dist/cli/commands/info.js +67 -0
  214. package/dist/cli/commands/info.js.map +1 -0
  215. package/dist/cli/commands/interfaces.d.ts +3 -0
  216. package/dist/cli/commands/interfaces.d.ts.map +1 -0
  217. package/dist/cli/commands/interfaces.js +29 -0
  218. package/dist/cli/commands/interfaces.js.map +1 -0
  219. package/dist/cli/commands/map.d.ts +3 -0
  220. package/dist/cli/commands/map.d.ts.map +1 -0
  221. package/dist/cli/commands/map.js +19 -0
  222. package/dist/cli/commands/map.js.map +1 -0
  223. package/dist/cli/commands/mcp.d.ts +3 -0
  224. package/dist/cli/commands/mcp.d.ts.map +1 -0
  225. package/dist/cli/commands/mcp.js +18 -0
  226. package/dist/cli/commands/mcp.js.map +1 -0
  227. package/dist/cli/commands/models.d.ts +3 -0
  228. package/dist/cli/commands/models.d.ts.map +1 -0
  229. package/dist/cli/commands/models.js +19 -0
  230. package/dist/cli/commands/models.js.map +1 -0
  231. package/dist/cli/commands/owners.d.ts +3 -0
  232. package/dist/cli/commands/owners.d.ts.map +1 -0
  233. package/dist/cli/commands/owners.js +27 -0
  234. package/dist/cli/commands/owners.js.map +1 -0
  235. package/dist/cli/commands/path.d.ts +3 -0
  236. package/dist/cli/commands/path.d.ts.map +1 -0
  237. package/dist/cli/commands/path.js +41 -0
  238. package/dist/cli/commands/path.js.map +1 -0
  239. package/dist/cli/commands/plot.d.ts +3 -0
  240. package/dist/cli/commands/plot.d.ts.map +1 -0
  241. package/dist/cli/commands/plot.js +96 -0
  242. package/dist/cli/commands/plot.js.map +1 -0
  243. package/dist/cli/commands/query.d.ts +3 -0
  244. package/dist/cli/commands/query.d.ts.map +1 -0
  245. package/dist/cli/commands/query.js +51 -0
  246. package/dist/cli/commands/query.js.map +1 -0
  247. package/dist/cli/commands/registry.d.ts +3 -0
  248. package/dist/cli/commands/registry.d.ts.map +1 -0
  249. package/dist/cli/commands/registry.js +95 -0
  250. package/dist/cli/commands/registry.js.map +1 -0
  251. package/dist/cli/commands/roles.d.ts +3 -0
  252. package/dist/cli/commands/roles.d.ts.map +1 -0
  253. package/dist/cli/commands/roles.js +36 -0
  254. package/dist/cli/commands/roles.js.map +1 -0
  255. package/dist/cli/commands/search.d.ts +3 -0
  256. package/dist/cli/commands/search.d.ts.map +1 -0
  257. package/dist/cli/commands/search.js +43 -0
  258. package/dist/cli/commands/search.js.map +1 -0
  259. package/dist/cli/commands/sequence.d.ts +3 -0
  260. package/dist/cli/commands/sequence.d.ts.map +1 -0
  261. package/dist/cli/commands/sequence.js +29 -0
  262. package/dist/cli/commands/sequence.js.map +1 -0
  263. package/dist/cli/commands/snapshot.d.ts +3 -0
  264. package/dist/cli/commands/snapshot.d.ts.map +1 -0
  265. package/dist/cli/commands/snapshot.js +61 -0
  266. package/dist/cli/commands/snapshot.js.map +1 -0
  267. package/dist/cli/commands/stats.d.ts +3 -0
  268. package/dist/cli/commands/stats.d.ts.map +1 -0
  269. package/dist/cli/commands/stats.js +15 -0
  270. package/dist/cli/commands/stats.js.map +1 -0
  271. package/dist/cli/commands/structure.d.ts +3 -0
  272. package/dist/cli/commands/structure.d.ts.map +1 -0
  273. package/dist/cli/commands/structure.js +50 -0
  274. package/dist/cli/commands/structure.js.map +1 -0
  275. package/dist/cli/commands/triage.d.ts +3 -0
  276. package/dist/cli/commands/triage.d.ts.map +1 -0
  277. package/dist/cli/commands/triage.js +89 -0
  278. package/dist/cli/commands/triage.js.map +1 -0
  279. package/dist/cli/commands/watch.d.ts +3 -0
  280. package/dist/cli/commands/watch.d.ts.map +1 -0
  281. package/dist/cli/commands/watch.js +28 -0
  282. package/dist/cli/commands/watch.js.map +1 -0
  283. package/dist/cli/commands/where.d.ts +3 -0
  284. package/dist/cli/commands/where.d.ts.map +1 -0
  285. package/dist/cli/commands/where.js +20 -0
  286. package/dist/cli/commands/where.js.map +1 -0
  287. package/dist/cli/index.d.ts +22 -0
  288. package/dist/cli/index.d.ts.map +1 -0
  289. package/dist/cli/index.js +139 -0
  290. package/dist/cli/index.js.map +1 -0
  291. package/dist/cli/shared/open-graph.d.ts +11 -0
  292. package/dist/cli/shared/open-graph.d.ts.map +1 -0
  293. package/dist/cli/shared/open-graph.js +9 -0
  294. package/dist/cli/shared/open-graph.js.map +1 -0
  295. package/dist/cli/shared/options.d.ts +25 -0
  296. package/dist/cli/shared/options.d.ts.map +1 -0
  297. package/dist/cli/shared/options.js +66 -0
  298. package/dist/cli/shared/options.js.map +1 -0
  299. package/dist/cli/shared/output.d.ts +2 -0
  300. package/dist/cli/shared/output.d.ts.map +1 -0
  301. package/dist/cli/shared/output.js +2 -0
  302. package/dist/cli/shared/output.js.map +1 -0
  303. package/dist/cli/types.d.ts +32 -0
  304. package/dist/cli/types.d.ts.map +1 -0
  305. package/dist/cli/types.js +2 -0
  306. package/dist/cli/types.js.map +1 -0
  307. package/dist/cli.d.ts +3 -0
  308. package/dist/cli.d.ts.map +1 -0
  309. package/dist/cli.js +38 -0
  310. package/dist/cli.js.map +1 -0
  311. package/dist/db/better-sqlite3.d.ts +4 -0
  312. package/dist/db/better-sqlite3.d.ts.map +1 -0
  313. package/dist/db/better-sqlite3.js +19 -0
  314. package/dist/db/better-sqlite3.js.map +1 -0
  315. package/dist/db/connection.d.ts +82 -0
  316. package/dist/db/connection.d.ts.map +1 -0
  317. package/dist/db/connection.js +444 -0
  318. package/dist/db/connection.js.map +1 -0
  319. package/dist/db/index.d.ts +6 -0
  320. package/dist/db/index.d.ts.map +1 -0
  321. package/dist/db/index.js +6 -0
  322. package/dist/db/index.js.map +1 -0
  323. package/dist/db/migrations.d.ts +11 -0
  324. package/dist/db/migrations.d.ts.map +1 -0
  325. package/dist/db/migrations.js +416 -0
  326. package/dist/db/migrations.js.map +1 -0
  327. package/dist/db/query-builder.d.ts +88 -0
  328. package/dist/db/query-builder.d.ts.map +1 -0
  329. package/dist/db/query-builder.js +321 -0
  330. package/dist/db/query-builder.js.map +1 -0
  331. package/dist/db/repository/base.d.ts +103 -0
  332. package/dist/db/repository/base.d.ts.map +1 -0
  333. package/dist/db/repository/base.js +172 -0
  334. package/dist/db/repository/base.js.map +1 -0
  335. package/dist/db/repository/build-stmts.d.ts +16 -0
  336. package/dist/db/repository/build-stmts.d.ts.map +1 -0
  337. package/dist/db/repository/build-stmts.js +76 -0
  338. package/dist/db/repository/build-stmts.js.map +1 -0
  339. package/dist/db/repository/cached-stmt.d.ts +9 -0
  340. package/dist/db/repository/cached-stmt.d.ts.map +1 -0
  341. package/dist/db/repository/cached-stmt.js +15 -0
  342. package/dist/db/repository/cached-stmt.js.map +1 -0
  343. package/dist/db/repository/cfg.d.ts +34 -0
  344. package/dist/db/repository/cfg.d.ts.map +1 -0
  345. package/dist/db/repository/cfg.js +46 -0
  346. package/dist/db/repository/cfg.js.map +1 -0
  347. package/dist/db/repository/cochange.d.ts +14 -0
  348. package/dist/db/repository/cochange.d.ts.map +1 -0
  349. package/dist/db/repository/cochange.js +38 -0
  350. package/dist/db/repository/cochange.js.map +1 -0
  351. package/dist/db/repository/complexity.d.ts +7 -0
  352. package/dist/db/repository/complexity.d.ts.map +1 -0
  353. package/dist/db/repository/complexity.js +12 -0
  354. package/dist/db/repository/complexity.js.map +1 -0
  355. package/dist/db/repository/dataflow.d.ts +11 -0
  356. package/dist/db/repository/dataflow.d.ts.map +1 -0
  357. package/dist/db/repository/dataflow.js +30 -0
  358. package/dist/db/repository/dataflow.js.map +1 -0
  359. package/dist/db/repository/edges.d.ts +66 -0
  360. package/dist/db/repository/edges.d.ts.map +1 -0
  361. package/dist/db/repository/edges.js +175 -0
  362. package/dist/db/repository/edges.js.map +1 -0
  363. package/dist/db/repository/embeddings.d.ts +14 -0
  364. package/dist/db/repository/embeddings.d.ts.map +1 -0
  365. package/dist/db/repository/embeddings.js +40 -0
  366. package/dist/db/repository/embeddings.js.map +1 -0
  367. package/dist/db/repository/graph-read.d.ts +18 -0
  368. package/dist/db/repository/graph-read.d.ts.map +1 -0
  369. package/dist/db/repository/graph-read.js +33 -0
  370. package/dist/db/repository/graph-read.js.map +1 -0
  371. package/dist/db/repository/in-memory-repository.d.ts +88 -0
  372. package/dist/db/repository/in-memory-repository.d.ts.map +1 -0
  373. package/dist/db/repository/in-memory-repository.js +541 -0
  374. package/dist/db/repository/in-memory-repository.js.map +1 -0
  375. package/dist/db/repository/index.d.ts +16 -0
  376. package/dist/db/repository/index.d.ts.map +1 -0
  377. package/dist/db/repository/index.js +16 -0
  378. package/dist/db/repository/index.js.map +1 -0
  379. package/dist/db/repository/native-repository.d.ts +70 -0
  380. package/dist/db/repository/native-repository.d.ts.map +1 -0
  381. package/dist/db/repository/native-repository.js +418 -0
  382. package/dist/db/repository/native-repository.js.map +1 -0
  383. package/dist/db/repository/nodes.d.ts +86 -0
  384. package/dist/db/repository/nodes.d.ts.map +1 -0
  385. package/dist/db/repository/nodes.js +203 -0
  386. package/dist/db/repository/nodes.js.map +1 -0
  387. package/dist/db/repository/sqlite-repository.d.ts +59 -0
  388. package/dist/db/repository/sqlite-repository.d.ts.map +1 -0
  389. package/dist/db/repository/sqlite-repository.js +199 -0
  390. package/dist/db/repository/sqlite-repository.js.map +1 -0
  391. package/dist/domain/analysis/brief.d.ts +25 -0
  392. package/dist/domain/analysis/brief.d.ts.map +1 -0
  393. package/dist/domain/analysis/brief.js +136 -0
  394. package/dist/domain/analysis/brief.js.map +1 -0
  395. package/dist/domain/analysis/context.d.ts +241 -0
  396. package/dist/domain/analysis/context.d.ts.map +1 -0
  397. package/dist/domain/analysis/context.js +361 -0
  398. package/dist/domain/analysis/context.js.map +1 -0
  399. package/dist/domain/analysis/dependencies.d.ts +158 -0
  400. package/dist/domain/analysis/dependencies.d.ts.map +1 -0
  401. package/dist/domain/analysis/dependencies.js +522 -0
  402. package/dist/domain/analysis/dependencies.js.map +1 -0
  403. package/dist/domain/analysis/diff-impact.d.ts +90 -0
  404. package/dist/domain/analysis/diff-impact.d.ts.map +1 -0
  405. package/dist/domain/analysis/diff-impact.js +301 -0
  406. package/dist/domain/analysis/diff-impact.js.map +1 -0
  407. package/dist/domain/analysis/exports.d.ts +8 -0
  408. package/dist/domain/analysis/exports.d.ts.map +1 -0
  409. package/dist/domain/analysis/exports.js +178 -0
  410. package/dist/domain/analysis/exports.js.map +1 -0
  411. package/dist/domain/analysis/fn-impact.d.ts +61 -0
  412. package/dist/domain/analysis/fn-impact.d.ts.map +1 -0
  413. package/dist/domain/analysis/fn-impact.js +190 -0
  414. package/dist/domain/analysis/fn-impact.js.map +1 -0
  415. package/dist/domain/analysis/impact.d.ts +11 -0
  416. package/dist/domain/analysis/impact.d.ts.map +1 -0
  417. package/dist/domain/analysis/impact.js +11 -0
  418. package/dist/domain/analysis/impact.js.map +1 -0
  419. package/dist/domain/analysis/implementations.d.ts +59 -0
  420. package/dist/domain/analysis/implementations.d.ts.map +1 -0
  421. package/dist/domain/analysis/implementations.js +65 -0
  422. package/dist/domain/analysis/implementations.js.map +1 -0
  423. package/dist/domain/analysis/module-map.d.ts +86 -0
  424. package/dist/domain/analysis/module-map.d.ts.map +1 -0
  425. package/dist/domain/analysis/module-map.js +468 -0
  426. package/dist/domain/analysis/module-map.js.map +1 -0
  427. package/dist/domain/analysis/query-helpers.d.ts +27 -0
  428. package/dist/domain/analysis/query-helpers.d.ts.map +1 -0
  429. package/dist/domain/analysis/query-helpers.js +41 -0
  430. package/dist/domain/analysis/query-helpers.js.map +1 -0
  431. package/dist/domain/analysis/roles.d.ts +20 -0
  432. package/dist/domain/analysis/roles.d.ts.map +1 -0
  433. package/dist/domain/analysis/roles.js +74 -0
  434. package/dist/domain/analysis/roles.js.map +1 -0
  435. package/dist/domain/analysis/symbol-lookup.d.ts +125 -0
  436. package/dist/domain/analysis/symbol-lookup.d.ts.map +1 -0
  437. package/dist/domain/analysis/symbol-lookup.js +206 -0
  438. package/dist/domain/analysis/symbol-lookup.js.map +1 -0
  439. package/dist/domain/graph/builder/call-resolver.d.ts +89 -0
  440. package/dist/domain/graph/builder/call-resolver.d.ts.map +1 -0
  441. package/dist/domain/graph/builder/call-resolver.js +212 -0
  442. package/dist/domain/graph/builder/call-resolver.js.map +1 -0
  443. package/dist/domain/graph/builder/cha.d.ts +69 -0
  444. package/dist/domain/graph/builder/cha.d.ts.map +1 -0
  445. package/dist/domain/graph/builder/cha.js +158 -0
  446. package/dist/domain/graph/builder/cha.js.map +1 -0
  447. package/dist/domain/graph/builder/context.d.ts +91 -0
  448. package/dist/domain/graph/builder/context.d.ts.map +1 -0
  449. package/dist/domain/graph/builder/context.js +66 -0
  450. package/dist/domain/graph/builder/context.js.map +1 -0
  451. package/dist/domain/graph/builder/helpers.d.ts +97 -0
  452. package/dist/domain/graph/builder/helpers.d.ts.map +1 -0
  453. package/dist/domain/graph/builder/helpers.js +558 -0
  454. package/dist/domain/graph/builder/helpers.js.map +1 -0
  455. package/dist/domain/graph/builder/incremental.d.ts +53 -0
  456. package/dist/domain/graph/builder/incremental.d.ts.map +1 -0
  457. package/dist/domain/graph/builder/incremental.js +647 -0
  458. package/dist/domain/graph/builder/incremental.js.map +1 -0
  459. package/dist/domain/graph/builder/native-db-proxy.d.ts +24 -0
  460. package/dist/domain/graph/builder/native-db-proxy.d.ts.map +1 -0
  461. package/dist/domain/graph/builder/native-db-proxy.js +91 -0
  462. package/dist/domain/graph/builder/native-db-proxy.js.map +1 -0
  463. package/dist/domain/graph/builder/pipeline.d.ts +9 -0
  464. package/dist/domain/graph/builder/pipeline.d.ts.map +1 -0
  465. package/dist/domain/graph/builder/pipeline.js +448 -0
  466. package/dist/domain/graph/builder/pipeline.js.map +1 -0
  467. package/dist/domain/graph/builder/stages/build-edges.d.ts +3 -0
  468. package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -0
  469. package/dist/domain/graph/builder/stages/build-edges.js +1425 -0
  470. package/dist/domain/graph/builder/stages/build-edges.js.map +1 -0
  471. package/dist/domain/graph/builder/stages/build-structure.d.ts +3 -0
  472. package/dist/domain/graph/builder/stages/build-structure.d.ts.map +1 -0
  473. package/dist/domain/graph/builder/stages/build-structure.js +250 -0
  474. package/dist/domain/graph/builder/stages/build-structure.js.map +1 -0
  475. package/dist/domain/graph/builder/stages/collect-files.d.ts +3 -0
  476. package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -0
  477. package/dist/domain/graph/builder/stages/collect-files.js +161 -0
  478. package/dist/domain/graph/builder/stages/collect-files.js.map +1 -0
  479. package/dist/domain/graph/builder/stages/detect-changes.d.ts +27 -0
  480. package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -0
  481. package/dist/domain/graph/builder/stages/detect-changes.js +593 -0
  482. package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -0
  483. package/dist/domain/graph/builder/stages/finalize.d.ts +3 -0
  484. package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -0
  485. package/dist/domain/graph/builder/stages/finalize.js +274 -0
  486. package/dist/domain/graph/builder/stages/finalize.js.map +1 -0
  487. package/dist/domain/graph/builder/stages/insert-nodes.d.ts +35 -0
  488. package/dist/domain/graph/builder/stages/insert-nodes.d.ts.map +1 -0
  489. package/dist/domain/graph/builder/stages/insert-nodes.js +351 -0
  490. package/dist/domain/graph/builder/stages/insert-nodes.js.map +1 -0
  491. package/dist/domain/graph/builder/stages/native-db-lifecycle.d.ts +14 -0
  492. package/dist/domain/graph/builder/stages/native-db-lifecycle.d.ts.map +1 -0
  493. package/dist/domain/graph/builder/stages/native-db-lifecycle.js +77 -0
  494. package/dist/domain/graph/builder/stages/native-db-lifecycle.js.map +1 -0
  495. package/dist/domain/graph/builder/stages/native-orchestrator.d.ts +62 -0
  496. package/dist/domain/graph/builder/stages/native-orchestrator.d.ts.map +1 -0
  497. package/dist/domain/graph/builder/stages/native-orchestrator.js +1763 -0
  498. package/dist/domain/graph/builder/stages/native-orchestrator.js.map +1 -0
  499. package/dist/domain/graph/builder/stages/parse-files.d.ts +3 -0
  500. package/dist/domain/graph/builder/stages/parse-files.d.ts.map +1 -0
  501. package/dist/domain/graph/builder/stages/parse-files.js +22 -0
  502. package/dist/domain/graph/builder/stages/parse-files.js.map +1 -0
  503. package/dist/domain/graph/builder/stages/resolve-imports.d.ts +7 -0
  504. package/dist/domain/graph/builder/stages/resolve-imports.d.ts.map +1 -0
  505. package/dist/domain/graph/builder/stages/resolve-imports.js +231 -0
  506. package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -0
  507. package/dist/domain/graph/builder/stages/run-analyses.d.ts +3 -0
  508. package/dist/domain/graph/builder/stages/run-analyses.d.ts.map +1 -0
  509. package/dist/domain/graph/builder/stages/run-analyses.js +23 -0
  510. package/dist/domain/graph/builder/stages/run-analyses.js.map +1 -0
  511. package/dist/domain/graph/builder.d.ts +4 -0
  512. package/dist/domain/graph/builder.d.ts.map +1 -0
  513. package/dist/domain/graph/builder.js +6 -0
  514. package/dist/domain/graph/builder.js.map +1 -0
  515. package/dist/domain/graph/change-journal.d.ts +50 -0
  516. package/dist/domain/graph/change-journal.d.ts.map +1 -0
  517. package/dist/domain/graph/change-journal.js +97 -0
  518. package/dist/domain/graph/change-journal.js.map +1 -0
  519. package/dist/domain/graph/cycles.d.ts +19 -0
  520. package/dist/domain/graph/cycles.d.ts.map +1 -0
  521. package/dist/domain/graph/cycles.js +142 -0
  522. package/dist/domain/graph/cycles.js.map +1 -0
  523. package/dist/domain/graph/journal.d.ts +30 -0
  524. package/dist/domain/graph/journal.d.ts.map +1 -0
  525. package/dist/domain/graph/journal.js +360 -0
  526. package/dist/domain/graph/journal.js.map +1 -0
  527. package/dist/domain/graph/resolve.d.ts +67 -0
  528. package/dist/domain/graph/resolve.d.ts.map +1 -0
  529. package/dist/domain/graph/resolve.js +521 -0
  530. package/dist/domain/graph/resolve.js.map +1 -0
  531. package/dist/domain/graph/resolver/points-to.d.ts +53 -0
  532. package/dist/domain/graph/resolver/points-to.d.ts.map +1 -0
  533. package/dist/domain/graph/resolver/points-to.js +261 -0
  534. package/dist/domain/graph/resolver/points-to.js.map +1 -0
  535. package/dist/domain/graph/resolver/strategy.d.ts +61 -0
  536. package/dist/domain/graph/resolver/strategy.d.ts.map +1 -0
  537. package/dist/domain/graph/resolver/strategy.js +222 -0
  538. package/dist/domain/graph/resolver/strategy.js.map +1 -0
  539. package/dist/domain/graph/resolver/ts-resolver.d.ts +9 -0
  540. package/dist/domain/graph/resolver/ts-resolver.d.ts.map +1 -0
  541. package/dist/domain/graph/resolver/ts-resolver.js +476 -0
  542. package/dist/domain/graph/resolver/ts-resolver.js.map +1 -0
  543. package/dist/domain/graph/watcher.d.ts +23 -0
  544. package/dist/domain/graph/watcher.d.ts.map +1 -0
  545. package/dist/domain/graph/watcher.js +272 -0
  546. package/dist/domain/graph/watcher.js.map +1 -0
  547. package/dist/domain/parser.d.ts +128 -0
  548. package/dist/domain/parser.d.ts.map +1 -0
  549. package/dist/domain/parser.js +1246 -0
  550. package/dist/domain/parser.js.map +1 -0
  551. package/dist/domain/queries.d.ts +22 -0
  552. package/dist/domain/queries.d.ts.map +1 -0
  553. package/dist/domain/queries.js +26 -0
  554. package/dist/domain/queries.js.map +1 -0
  555. package/dist/domain/search/generator.d.ts +16 -0
  556. package/dist/domain/search/generator.d.ts.map +1 -0
  557. package/dist/domain/search/generator.js +181 -0
  558. package/dist/domain/search/generator.js.map +1 -0
  559. package/dist/domain/search/index.d.ts +15 -0
  560. package/dist/domain/search/index.d.ts.map +1 -0
  561. package/dist/domain/search/index.js +13 -0
  562. package/dist/domain/search/index.js.map +1 -0
  563. package/dist/domain/search/models.d.ts +63 -0
  564. package/dist/domain/search/models.d.ts.map +1 -0
  565. package/dist/domain/search/models.js +303 -0
  566. package/dist/domain/search/models.js.map +1 -0
  567. package/dist/domain/search/search/cli-formatter.d.ts +10 -0
  568. package/dist/domain/search/search/cli-formatter.d.ts.map +1 -0
  569. package/dist/domain/search/search/cli-formatter.js +134 -0
  570. package/dist/domain/search/search/cli-formatter.js.map +1 -0
  571. package/dist/domain/search/search/filters.d.ts +9 -0
  572. package/dist/domain/search/search/filters.d.ts.map +1 -0
  573. package/dist/domain/search/search/filters.js +31 -0
  574. package/dist/domain/search/search/filters.js.map +1 -0
  575. package/dist/domain/search/search/hybrid.d.ts +21 -0
  576. package/dist/domain/search/search/hybrid.d.ts.map +1 -0
  577. package/dist/domain/search/search/hybrid.js +122 -0
  578. package/dist/domain/search/search/hybrid.js.map +1 -0
  579. package/dist/domain/search/search/keyword.d.ts +18 -0
  580. package/dist/domain/search/search/keyword.d.ts.map +1 -0
  581. package/dist/domain/search/search/keyword.js +58 -0
  582. package/dist/domain/search/search/keyword.js.map +1 -0
  583. package/dist/domain/search/search/prepare.d.ts +25 -0
  584. package/dist/domain/search/search/prepare.d.ts.map +1 -0
  585. package/dist/domain/search/search/prepare.js +63 -0
  586. package/dist/domain/search/search/prepare.js.map +1 -0
  587. package/dist/domain/search/search/semantic.d.ts +41 -0
  588. package/dist/domain/search/search/semantic.d.ts.map +1 -0
  589. package/dist/domain/search/search/semantic.js +135 -0
  590. package/dist/domain/search/search/semantic.js.map +1 -0
  591. package/dist/domain/search/stores/fts5.d.ts +10 -0
  592. package/dist/domain/search/stores/fts5.d.ts.map +1 -0
  593. package/dist/domain/search/stores/fts5.js +27 -0
  594. package/dist/domain/search/stores/fts5.js.map +1 -0
  595. package/dist/domain/search/stores/sqlite-blob.d.ts +5 -0
  596. package/dist/domain/search/stores/sqlite-blob.d.ts.map +1 -0
  597. package/dist/domain/search/stores/sqlite-blob.js +16 -0
  598. package/dist/domain/search/stores/sqlite-blob.js.map +1 -0
  599. package/dist/domain/search/strategies/source.d.ts +6 -0
  600. package/dist/domain/search/strategies/source.d.ts.map +1 -0
  601. package/dist/domain/search/strategies/source.js +14 -0
  602. package/dist/domain/search/strategies/source.js.map +1 -0
  603. package/dist/domain/search/strategies/structured.d.ts +10 -0
  604. package/dist/domain/search/strategies/structured.d.ts.map +1 -0
  605. package/dist/domain/search/strategies/structured.js +35 -0
  606. package/dist/domain/search/strategies/structured.js.map +1 -0
  607. package/dist/domain/search/strategies/text-utils.d.ts +9 -0
  608. package/dist/domain/search/strategies/text-utils.d.ts.map +1 -0
  609. package/dist/domain/search/strategies/text-utils.js +45 -0
  610. package/dist/domain/search/strategies/text-utils.js.map +1 -0
  611. package/dist/domain/wasm-worker-entry.d.ts +24 -0
  612. package/dist/domain/wasm-worker-entry.d.ts.map +1 -0
  613. package/dist/domain/wasm-worker-entry.js +749 -0
  614. package/dist/domain/wasm-worker-entry.js.map +1 -0
  615. package/dist/domain/wasm-worker-pool.d.ts +59 -0
  616. package/dist/domain/wasm-worker-pool.d.ts.map +1 -0
  617. package/dist/domain/wasm-worker-pool.js +363 -0
  618. package/dist/domain/wasm-worker-pool.js.map +1 -0
  619. package/dist/domain/wasm-worker-protocol.d.ts +81 -0
  620. package/dist/domain/wasm-worker-protocol.d.ts.map +1 -0
  621. package/dist/domain/wasm-worker-protocol.js +13 -0
  622. package/dist/domain/wasm-worker-protocol.js.map +1 -0
  623. package/dist/extractors/bash.d.ts +6 -0
  624. package/dist/extractors/bash.d.ts.map +1 -0
  625. package/dist/extractors/bash.js +91 -0
  626. package/dist/extractors/bash.js.map +1 -0
  627. package/dist/extractors/c.d.ts +6 -0
  628. package/dist/extractors/c.d.ts.map +1 -0
  629. package/dist/extractors/c.js +223 -0
  630. package/dist/extractors/c.js.map +1 -0
  631. package/dist/extractors/clojure.d.ts +12 -0
  632. package/dist/extractors/clojure.d.ts.map +1 -0
  633. package/dist/extractors/clojure.js +245 -0
  634. package/dist/extractors/clojure.js.map +1 -0
  635. package/dist/extractors/cpp.d.ts +6 -0
  636. package/dist/extractors/cpp.d.ts.map +1 -0
  637. package/dist/extractors/cpp.js +365 -0
  638. package/dist/extractors/cpp.js.map +1 -0
  639. package/dist/extractors/csharp.d.ts +6 -0
  640. package/dist/extractors/csharp.d.ts.map +1 -0
  641. package/dist/extractors/csharp.js +430 -0
  642. package/dist/extractors/csharp.js.map +1 -0
  643. package/dist/extractors/cuda.d.ts +11 -0
  644. package/dist/extractors/cuda.d.ts.map +1 -0
  645. package/dist/extractors/cuda.js +419 -0
  646. package/dist/extractors/cuda.js.map +1 -0
  647. package/dist/extractors/dart.d.ts +6 -0
  648. package/dist/extractors/dart.d.ts.map +1 -0
  649. package/dist/extractors/dart.js +277 -0
  650. package/dist/extractors/dart.js.map +1 -0
  651. package/dist/extractors/elixir.d.ts +9 -0
  652. package/dist/extractors/elixir.d.ts.map +1 -0
  653. package/dist/extractors/elixir.js +327 -0
  654. package/dist/extractors/elixir.js.map +1 -0
  655. package/dist/extractors/erlang.d.ts +14 -0
  656. package/dist/extractors/erlang.d.ts.map +1 -0
  657. package/dist/extractors/erlang.js +275 -0
  658. package/dist/extractors/erlang.js.map +1 -0
  659. package/dist/extractors/fsharp.d.ts +20 -0
  660. package/dist/extractors/fsharp.d.ts.map +1 -0
  661. package/dist/extractors/fsharp.js +312 -0
  662. package/dist/extractors/fsharp.js.map +1 -0
  663. package/dist/extractors/gleam.d.ts +14 -0
  664. package/dist/extractors/gleam.d.ts.map +1 -0
  665. package/dist/extractors/gleam.js +225 -0
  666. package/dist/extractors/gleam.js.map +1 -0
  667. package/dist/extractors/go.d.ts +6 -0
  668. package/dist/extractors/go.d.ts.map +1 -0
  669. package/dist/extractors/go.js +460 -0
  670. package/dist/extractors/go.js.map +1 -0
  671. package/dist/extractors/groovy.d.ts +10 -0
  672. package/dist/extractors/groovy.d.ts.map +1 -0
  673. package/dist/extractors/groovy.js +403 -0
  674. package/dist/extractors/groovy.js.map +1 -0
  675. package/dist/extractors/haskell.d.ts +8 -0
  676. package/dist/extractors/haskell.d.ts.map +1 -0
  677. package/dist/extractors/haskell.js +261 -0
  678. package/dist/extractors/haskell.js.map +1 -0
  679. package/dist/extractors/hcl.d.ts +6 -0
  680. package/dist/extractors/hcl.d.ts.map +1 -0
  681. package/dist/extractors/hcl.js +114 -0
  682. package/dist/extractors/hcl.js.map +1 -0
  683. package/dist/extractors/helpers.d.ts +144 -0
  684. package/dist/extractors/helpers.d.ts.map +1 -0
  685. package/dist/extractors/helpers.js +360 -0
  686. package/dist/extractors/helpers.js.map +1 -0
  687. package/dist/extractors/index.d.ts +33 -0
  688. package/dist/extractors/index.d.ts.map +1 -0
  689. package/dist/extractors/index.js +33 -0
  690. package/dist/extractors/index.js.map +1 -0
  691. package/dist/extractors/java.d.ts +6 -0
  692. package/dist/extractors/java.d.ts.map +1 -0
  693. package/dist/extractors/java.js +390 -0
  694. package/dist/extractors/java.js.map +1 -0
  695. package/dist/extractors/javascript.d.ts +10 -0
  696. package/dist/extractors/javascript.d.ts.map +1 -0
  697. package/dist/extractors/javascript.js +3618 -0
  698. package/dist/extractors/javascript.js.map +1 -0
  699. package/dist/extractors/julia.d.ts +16 -0
  700. package/dist/extractors/julia.d.ts.map +1 -0
  701. package/dist/extractors/julia.js +411 -0
  702. package/dist/extractors/julia.js.map +1 -0
  703. package/dist/extractors/kotlin.d.ts +6 -0
  704. package/dist/extractors/kotlin.d.ts.map +1 -0
  705. package/dist/extractors/kotlin.js +340 -0
  706. package/dist/extractors/kotlin.js.map +1 -0
  707. package/dist/extractors/lua.d.ts +6 -0
  708. package/dist/extractors/lua.d.ts.map +1 -0
  709. package/dist/extractors/lua.js +162 -0
  710. package/dist/extractors/lua.js.map +1 -0
  711. package/dist/extractors/objc.d.ts +9 -0
  712. package/dist/extractors/objc.d.ts.map +1 -0
  713. package/dist/extractors/objc.js +543 -0
  714. package/dist/extractors/objc.js.map +1 -0
  715. package/dist/extractors/ocaml.d.ts +6 -0
  716. package/dist/extractors/ocaml.d.ts.map +1 -0
  717. package/dist/extractors/ocaml.js +310 -0
  718. package/dist/extractors/ocaml.js.map +1 -0
  719. package/dist/extractors/php.d.ts +6 -0
  720. package/dist/extractors/php.d.ts.map +1 -0
  721. package/dist/extractors/php.js +381 -0
  722. package/dist/extractors/php.js.map +1 -0
  723. package/dist/extractors/python.d.ts +6 -0
  724. package/dist/extractors/python.d.ts.map +1 -0
  725. package/dist/extractors/python.js +428 -0
  726. package/dist/extractors/python.js.map +1 -0
  727. package/dist/extractors/r.d.ts +13 -0
  728. package/dist/extractors/r.d.ts.map +1 -0
  729. package/dist/extractors/r.js +267 -0
  730. package/dist/extractors/r.js.map +1 -0
  731. package/dist/extractors/ruby.d.ts +6 -0
  732. package/dist/extractors/ruby.d.ts.map +1 -0
  733. package/dist/extractors/ruby.js +281 -0
  734. package/dist/extractors/ruby.js.map +1 -0
  735. package/dist/extractors/rust.d.ts +6 -0
  736. package/dist/extractors/rust.d.ts.map +1 -0
  737. package/dist/extractors/rust.js +354 -0
  738. package/dist/extractors/rust.js.map +1 -0
  739. package/dist/extractors/scala.d.ts +6 -0
  740. package/dist/extractors/scala.d.ts.map +1 -0
  741. package/dist/extractors/scala.js +315 -0
  742. package/dist/extractors/scala.js.map +1 -0
  743. package/dist/extractors/solidity.d.ts +9 -0
  744. package/dist/extractors/solidity.d.ts.map +1 -0
  745. package/dist/extractors/solidity.js +351 -0
  746. package/dist/extractors/solidity.js.map +1 -0
  747. package/dist/extractors/swift.d.ts +6 -0
  748. package/dist/extractors/swift.d.ts.map +1 -0
  749. package/dist/extractors/swift.js +326 -0
  750. package/dist/extractors/swift.js.map +1 -0
  751. package/dist/extractors/verilog.d.ts +9 -0
  752. package/dist/extractors/verilog.d.ts.map +1 -0
  753. package/dist/extractors/verilog.js +351 -0
  754. package/dist/extractors/verilog.js.map +1 -0
  755. package/dist/extractors/zig.d.ts +9 -0
  756. package/dist/extractors/zig.d.ts.map +1 -0
  757. package/dist/extractors/zig.js +274 -0
  758. package/dist/extractors/zig.js.map +1 -0
  759. package/dist/features/ast.d.ts +78 -0
  760. package/dist/features/ast.d.ts.map +1 -0
  761. package/dist/features/ast.js +228 -0
  762. package/dist/features/ast.js.map +1 -0
  763. package/dist/features/audit.d.ts +15 -0
  764. package/dist/features/audit.d.ts.map +1 -0
  765. package/dist/features/audit.js +275 -0
  766. package/dist/features/audit.js.map +1 -0
  767. package/dist/features/batch.d.ts +54 -0
  768. package/dist/features/batch.d.ts.map +1 -0
  769. package/dist/features/batch.js +97 -0
  770. package/dist/features/batch.js.map +1 -0
  771. package/dist/features/boundaries.d.ts +51 -0
  772. package/dist/features/boundaries.d.ts.map +1 -0
  773. package/dist/features/boundaries.js +248 -0
  774. package/dist/features/boundaries.js.map +1 -0
  775. package/dist/features/branch-compare.d.ts +71 -0
  776. package/dist/features/branch-compare.d.ts.map +1 -0
  777. package/dist/features/branch-compare.js +444 -0
  778. package/dist/features/branch-compare.js.map +1 -0
  779. package/dist/features/cfg.d.ts +79 -0
  780. package/dist/features/cfg.d.ts.map +1 -0
  781. package/dist/features/cfg.js +483 -0
  782. package/dist/features/cfg.js.map +1 -0
  783. package/dist/features/check.d.ts +84 -0
  784. package/dist/features/check.d.ts.map +1 -0
  785. package/dist/features/check.js +290 -0
  786. package/dist/features/check.js.map +1 -0
  787. package/dist/features/cochange.d.ts +68 -0
  788. package/dist/features/cochange.d.ts.map +1 -0
  789. package/dist/features/cochange.js +384 -0
  790. package/dist/features/cochange.js.map +1 -0
  791. package/dist/features/communities.d.ts +26 -0
  792. package/dist/features/communities.d.ts.map +1 -0
  793. package/dist/features/communities.js +149 -0
  794. package/dist/features/communities.js.map +1 -0
  795. package/dist/features/complexity-query.d.ts +37 -0
  796. package/dist/features/complexity-query.d.ts.map +1 -0
  797. package/dist/features/complexity-query.js +268 -0
  798. package/dist/features/complexity-query.js.map +1 -0
  799. package/dist/features/complexity.d.ts +52 -0
  800. package/dist/features/complexity.d.ts.map +1 -0
  801. package/dist/features/complexity.js +490 -0
  802. package/dist/features/complexity.js.map +1 -0
  803. package/dist/features/dataflow.d.ts +129 -0
  804. package/dist/features/dataflow.d.ts.map +1 -0
  805. package/dist/features/dataflow.js +1079 -0
  806. package/dist/features/dataflow.js.map +1 -0
  807. package/dist/features/export.d.ts +35 -0
  808. package/dist/features/export.d.ts.map +1 -0
  809. package/dist/features/export.js +340 -0
  810. package/dist/features/export.js.map +1 -0
  811. package/dist/features/flow.d.ts +21 -0
  812. package/dist/features/flow.d.ts.map +1 -0
  813. package/dist/features/flow.js +195 -0
  814. package/dist/features/flow.js.map +1 -0
  815. package/dist/features/graph-enrichment.d.ts +44 -0
  816. package/dist/features/graph-enrichment.d.ts.map +1 -0
  817. package/dist/features/graph-enrichment.js +312 -0
  818. package/dist/features/graph-enrichment.js.map +1 -0
  819. package/dist/features/manifesto.d.ts +23 -0
  820. package/dist/features/manifesto.d.ts.map +1 -0
  821. package/dist/features/manifesto.js +382 -0
  822. package/dist/features/manifesto.js.map +1 -0
  823. package/dist/features/owners.d.ts +60 -0
  824. package/dist/features/owners.d.ts.map +1 -0
  825. package/dist/features/owners.js +248 -0
  826. package/dist/features/owners.js.map +1 -0
  827. package/dist/features/sequence.d.ts +42 -0
  828. package/dist/features/sequence.d.ts.map +1 -0
  829. package/dist/features/sequence.js +271 -0
  830. package/dist/features/sequence.js.map +1 -0
  831. package/dist/features/shared/find-nodes.d.ts +7 -0
  832. package/dist/features/shared/find-nodes.d.ts.map +1 -0
  833. package/dist/features/shared/find-nodes.js +18 -0
  834. package/dist/features/shared/find-nodes.js.map +1 -0
  835. package/dist/features/snapshot.d.ts +25 -0
  836. package/dist/features/snapshot.d.ts.map +1 -0
  837. package/dist/features/snapshot.js +188 -0
  838. package/dist/features/snapshot.js.map +1 -0
  839. package/dist/features/structure-query.d.ts +76 -0
  840. package/dist/features/structure-query.d.ts.map +1 -0
  841. package/dist/features/structure-query.js +274 -0
  842. package/dist/features/structure-query.js.map +1 -0
  843. package/dist/features/structure.d.ts +39 -0
  844. package/dist/features/structure.d.ts.map +1 -0
  845. package/dist/features/structure.js +796 -0
  846. package/dist/features/structure.js.map +1 -0
  847. package/dist/features/triage.d.ts +47 -0
  848. package/dist/features/triage.d.ts.map +1 -0
  849. package/dist/features/triage.js +123 -0
  850. package/dist/features/triage.js.map +1 -0
  851. package/dist/graph/algorithms/bfs.d.ts +14 -0
  852. package/dist/graph/algorithms/bfs.d.ts.map +1 -0
  853. package/dist/graph/algorithms/bfs.js +72 -0
  854. package/dist/graph/algorithms/bfs.js.map +1 -0
  855. package/dist/graph/algorithms/centrality.d.ts +12 -0
  856. package/dist/graph/algorithms/centrality.d.ts.map +1 -0
  857. package/dist/graph/algorithms/centrality.js +42 -0
  858. package/dist/graph/algorithms/centrality.js.map +1 -0
  859. package/dist/graph/algorithms/index.d.ts +7 -0
  860. package/dist/graph/algorithms/index.d.ts.map +1 -0
  861. package/dist/graph/algorithms/index.js +7 -0
  862. package/dist/graph/algorithms/index.js.map +1 -0
  863. package/dist/graph/algorithms/leiden/adapter.d.ts +37 -0
  864. package/dist/graph/algorithms/leiden/adapter.d.ts.map +1 -0
  865. package/dist/graph/algorithms/leiden/adapter.js +173 -0
  866. package/dist/graph/algorithms/leiden/adapter.js.map +1 -0
  867. package/dist/graph/algorithms/leiden/cpm.d.ts +28 -0
  868. package/dist/graph/algorithms/leiden/cpm.d.ts.map +1 -0
  869. package/dist/graph/algorithms/leiden/cpm.js +48 -0
  870. package/dist/graph/algorithms/leiden/cpm.js.map +1 -0
  871. package/dist/graph/algorithms/leiden/index.d.ts +37 -0
  872. package/dist/graph/algorithms/leiden/index.d.ts.map +1 -0
  873. package/dist/graph/algorithms/leiden/index.js +157 -0
  874. package/dist/graph/algorithms/leiden/index.js.map +1 -0
  875. package/dist/graph/algorithms/leiden/modularity.d.ts +33 -0
  876. package/dist/graph/algorithms/leiden/modularity.d.ts.map +1 -0
  877. package/dist/graph/algorithms/leiden/modularity.js +80 -0
  878. package/dist/graph/algorithms/leiden/modularity.js.map +1 -0
  879. package/dist/graph/algorithms/leiden/optimiser.d.ts +62 -0
  880. package/dist/graph/algorithms/leiden/optimiser.d.ts.map +1 -0
  881. package/dist/graph/algorithms/leiden/optimiser.js +530 -0
  882. package/dist/graph/algorithms/leiden/optimiser.js.map +1 -0
  883. package/dist/graph/algorithms/leiden/partition.d.ts +44 -0
  884. package/dist/graph/algorithms/leiden/partition.d.ts.map +1 -0
  885. package/dist/graph/algorithms/leiden/partition.js +438 -0
  886. package/dist/graph/algorithms/leiden/partition.js.map +1 -0
  887. package/dist/graph/algorithms/leiden/rng.d.ts +9 -0
  888. package/dist/graph/algorithms/leiden/rng.d.ts.map +1 -0
  889. package/dist/graph/algorithms/leiden/rng.js +17 -0
  890. package/dist/graph/algorithms/leiden/rng.js.map +1 -0
  891. package/dist/graph/algorithms/louvain.d.ts +20 -0
  892. package/dist/graph/algorithms/louvain.d.ts.map +1 -0
  893. package/dist/graph/algorithms/louvain.js +52 -0
  894. package/dist/graph/algorithms/louvain.js.map +1 -0
  895. package/dist/graph/algorithms/shortest-path.d.ts +10 -0
  896. package/dist/graph/algorithms/shortest-path.d.ts.map +1 -0
  897. package/dist/graph/algorithms/shortest-path.js +55 -0
  898. package/dist/graph/algorithms/shortest-path.js.map +1 -0
  899. package/dist/graph/algorithms/tarjan.d.ts +9 -0
  900. package/dist/graph/algorithms/tarjan.d.ts.map +1 -0
  901. package/dist/graph/algorithms/tarjan.js +52 -0
  902. package/dist/graph/algorithms/tarjan.js.map +1 -0
  903. package/dist/graph/builders/dependency.d.ts +18 -0
  904. package/dist/graph/builders/dependency.d.ts.map +1 -0
  905. package/dist/graph/builders/dependency.js +101 -0
  906. package/dist/graph/builders/dependency.js.map +1 -0
  907. package/dist/graph/builders/index.d.ts +4 -0
  908. package/dist/graph/builders/index.d.ts.map +1 -0
  909. package/dist/graph/builders/index.js +4 -0
  910. package/dist/graph/builders/index.js.map +1 -0
  911. package/dist/graph/builders/structure.d.ts +10 -0
  912. package/dist/graph/builders/structure.d.ts.map +1 -0
  913. package/dist/graph/builders/structure.js +33 -0
  914. package/dist/graph/builders/structure.js.map +1 -0
  915. package/dist/graph/builders/temporal.d.ts +13 -0
  916. package/dist/graph/builders/temporal.d.ts.map +1 -0
  917. package/dist/graph/builders/temporal.js +29 -0
  918. package/dist/graph/builders/temporal.js.map +1 -0
  919. package/dist/graph/classifiers/index.d.ts +3 -0
  920. package/dist/graph/classifiers/index.d.ts.map +1 -0
  921. package/dist/graph/classifiers/index.js +3 -0
  922. package/dist/graph/classifiers/index.js.map +1 -0
  923. package/dist/graph/classifiers/risk.d.ts +39 -0
  924. package/dist/graph/classifiers/risk.d.ts.map +1 -0
  925. package/dist/graph/classifiers/risk.js +78 -0
  926. package/dist/graph/classifiers/risk.js.map +1 -0
  927. package/dist/graph/classifiers/roles.d.ts +48 -0
  928. package/dist/graph/classifiers/roles.d.ts.map +1 -0
  929. package/dist/graph/classifiers/roles.js +180 -0
  930. package/dist/graph/classifiers/roles.js.map +1 -0
  931. package/dist/graph/index.d.ts +5 -0
  932. package/dist/graph/index.d.ts.map +1 -0
  933. package/dist/graph/index.js +6 -0
  934. package/dist/graph/index.js.map +1 -0
  935. package/dist/graph/model.d.ts +57 -0
  936. package/dist/graph/model.d.ts.map +1 -0
  937. package/dist/graph/model.js +205 -0
  938. package/dist/graph/model.js.map +1 -0
  939. package/dist/index.cjs +16 -0
  940. package/dist/index.d.ts +37 -0
  941. package/dist/index.d.ts.map +1 -0
  942. package/dist/index.js +36 -0
  943. package/dist/index.js.map +1 -0
  944. package/dist/infrastructure/config.d.ts +281 -0
  945. package/dist/infrastructure/config.d.ts.map +1 -0
  946. package/dist/infrastructure/config.js +857 -0
  947. package/dist/infrastructure/config.js.map +1 -0
  948. package/dist/infrastructure/logger.d.ts +7 -0
  949. package/dist/infrastructure/logger.d.ts.map +1 -0
  950. package/dist/infrastructure/logger.js +21 -0
  951. package/dist/infrastructure/logger.js.map +1 -0
  952. package/dist/infrastructure/native.d.ts +38 -0
  953. package/dist/infrastructure/native.d.ts.map +1 -0
  954. package/dist/infrastructure/native.js +182 -0
  955. package/dist/infrastructure/native.js.map +1 -0
  956. package/dist/infrastructure/registry.d.ts +81 -0
  957. package/dist/infrastructure/registry.d.ts.map +1 -0
  958. package/dist/infrastructure/registry.js +229 -0
  959. package/dist/infrastructure/registry.js.map +1 -0
  960. package/dist/infrastructure/result-formatter.d.ts +2 -0
  961. package/dist/infrastructure/result-formatter.d.ts.map +1 -0
  962. package/dist/infrastructure/result-formatter.js +3 -0
  963. package/dist/infrastructure/result-formatter.js.map +1 -0
  964. package/dist/infrastructure/suppress.d.ts +25 -0
  965. package/dist/infrastructure/suppress.d.ts.map +1 -0
  966. package/dist/infrastructure/suppress.js +43 -0
  967. package/dist/infrastructure/suppress.js.map +1 -0
  968. package/dist/infrastructure/test-filter.d.ts +5 -0
  969. package/dist/infrastructure/test-filter.d.ts.map +1 -0
  970. package/dist/infrastructure/test-filter.js +7 -0
  971. package/dist/infrastructure/test-filter.js.map +1 -0
  972. package/dist/infrastructure/update-check.d.ts +26 -0
  973. package/dist/infrastructure/update-check.d.ts.map +1 -0
  974. package/dist/infrastructure/update-check.js +164 -0
  975. package/dist/infrastructure/update-check.js.map +1 -0
  976. package/dist/mcp/index.d.ts +3 -0
  977. package/dist/mcp/index.d.ts.map +1 -0
  978. package/dist/mcp/index.js +3 -0
  979. package/dist/mcp/index.js.map +1 -0
  980. package/dist/mcp/middleware.d.ts +26 -0
  981. package/dist/mcp/middleware.d.ts.map +1 -0
  982. package/dist/mcp/middleware.js +32 -0
  983. package/dist/mcp/middleware.js.map +1 -0
  984. package/dist/mcp/server.d.ts +14 -0
  985. package/dist/mcp/server.d.ts.map +1 -0
  986. package/dist/mcp/server.js +193 -0
  987. package/dist/mcp/server.js.map +1 -0
  988. package/dist/mcp/tool-registry.d.ts +21 -0
  989. package/dist/mcp/tool-registry.d.ts.map +1 -0
  990. package/dist/mcp/tool-registry.js +839 -0
  991. package/dist/mcp/tool-registry.js.map +1 -0
  992. package/dist/mcp/tools/ast-query.d.ts +14 -0
  993. package/dist/mcp/tools/ast-query.d.ts.map +1 -0
  994. package/dist/mcp/tools/ast-query.js +13 -0
  995. package/dist/mcp/tools/ast-query.js.map +1 -0
  996. package/dist/mcp/tools/audit.d.ts +15 -0
  997. package/dist/mcp/tools/audit.d.ts.map +1 -0
  998. package/dist/mcp/tools/audit.js +20 -0
  999. package/dist/mcp/tools/audit.js.map +1 -0
  1000. package/dist/mcp/tools/batch-query.d.ts +13 -0
  1001. package/dist/mcp/tools/batch-query.d.ts.map +1 -0
  1002. package/dist/mcp/tools/batch-query.js +11 -0
  1003. package/dist/mcp/tools/batch-query.js.map +1 -0
  1004. package/dist/mcp/tools/branch-compare.d.ts +12 -0
  1005. package/dist/mcp/tools/branch-compare.d.ts.map +1 -0
  1006. package/dist/mcp/tools/branch-compare.js +10 -0
  1007. package/dist/mcp/tools/branch-compare.js.map +1 -0
  1008. package/dist/mcp/tools/brief.d.ts +9 -0
  1009. package/dist/mcp/tools/brief.d.ts.map +1 -0
  1010. package/dist/mcp/tools/brief.js +8 -0
  1011. package/dist/mcp/tools/brief.js.map +1 -0
  1012. package/dist/mcp/tools/cfg.d.ts +14 -0
  1013. package/dist/mcp/tools/cfg.d.ts.map +1 -0
  1014. package/dist/mcp/tools/cfg.js +20 -0
  1015. package/dist/mcp/tools/cfg.js.map +1 -0
  1016. package/dist/mcp/tools/check.d.ts +20 -0
  1017. package/dist/mcp/tools/check.d.ts.map +1 -0
  1018. package/dist/mcp/tools/check.js +39 -0
  1019. package/dist/mcp/tools/check.js.map +1 -0
  1020. package/dist/mcp/tools/co-changes.d.ts +12 -0
  1021. package/dist/mcp/tools/co-changes.d.ts.map +1 -0
  1022. package/dist/mcp/tools/co-changes.js +19 -0
  1023. package/dist/mcp/tools/co-changes.js.map +1 -0
  1024. package/dist/mcp/tools/code-owners.d.ts +12 -0
  1025. package/dist/mcp/tools/code-owners.d.ts.map +1 -0
  1026. package/dist/mcp/tools/code-owners.js +12 -0
  1027. package/dist/mcp/tools/code-owners.js.map +1 -0
  1028. package/dist/mcp/tools/communities.d.ts +13 -0
  1029. package/dist/mcp/tools/communities.d.ts.map +1 -0
  1030. package/dist/mcp/tools/communities.js +14 -0
  1031. package/dist/mcp/tools/communities.js.map +1 -0
  1032. package/dist/mcp/tools/complexity.d.ts +16 -0
  1033. package/dist/mcp/tools/complexity.d.ts.map +1 -0
  1034. package/dist/mcp/tools/complexity.js +16 -0
  1035. package/dist/mcp/tools/complexity.js.map +1 -0
  1036. package/dist/mcp/tools/context.d.ts +16 -0
  1037. package/dist/mcp/tools/context.d.ts.map +1 -0
  1038. package/dist/mcp/tools/context.js +16 -0
  1039. package/dist/mcp/tools/context.js.map +1 -0
  1040. package/dist/mcp/tools/dataflow.d.ts +15 -0
  1041. package/dist/mcp/tools/dataflow.d.ts.map +1 -0
  1042. package/dist/mcp/tools/dataflow.js +25 -0
  1043. package/dist/mcp/tools/dataflow.js.map +1 -0
  1044. package/dist/mcp/tools/diff-impact.d.ts +14 -0
  1045. package/dist/mcp/tools/diff-impact.d.ts.map +1 -0
  1046. package/dist/mcp/tools/diff-impact.js +23 -0
  1047. package/dist/mcp/tools/diff-impact.js.map +1 -0
  1048. package/dist/mcp/tools/execution-flow.d.ts +15 -0
  1049. package/dist/mcp/tools/execution-flow.d.ts.map +1 -0
  1050. package/dist/mcp/tools/execution-flow.js +25 -0
  1051. package/dist/mcp/tools/execution-flow.js.map +1 -0
  1052. package/dist/mcp/tools/export-graph.d.ts +11 -0
  1053. package/dist/mcp/tools/export-graph.d.ts.map +1 -0
  1054. package/dist/mcp/tools/export-graph.js +57 -0
  1055. package/dist/mcp/tools/export-graph.js.map +1 -0
  1056. package/dist/mcp/tools/file-deps.d.ts +11 -0
  1057. package/dist/mcp/tools/file-deps.d.ts.map +1 -0
  1058. package/dist/mcp/tools/file-deps.js +11 -0
  1059. package/dist/mcp/tools/file-deps.js.map +1 -0
  1060. package/dist/mcp/tools/file-exports.d.ts +12 -0
  1061. package/dist/mcp/tools/file-exports.d.ts.map +1 -0
  1062. package/dist/mcp/tools/file-exports.js +12 -0
  1063. package/dist/mcp/tools/file-exports.js.map +1 -0
  1064. package/dist/mcp/tools/find-cycles.d.ts +7 -0
  1065. package/dist/mcp/tools/find-cycles.d.ts.map +1 -0
  1066. package/dist/mcp/tools/find-cycles.js +15 -0
  1067. package/dist/mcp/tools/find-cycles.js.map +1 -0
  1068. package/dist/mcp/tools/fn-impact.d.ts +14 -0
  1069. package/dist/mcp/tools/fn-impact.d.ts.map +1 -0
  1070. package/dist/mcp/tools/fn-impact.js +14 -0
  1071. package/dist/mcp/tools/fn-impact.js.map +1 -0
  1072. package/dist/mcp/tools/impact-analysis.d.ts +9 -0
  1073. package/dist/mcp/tools/impact-analysis.d.ts.map +1 -0
  1074. package/dist/mcp/tools/impact-analysis.js +8 -0
  1075. package/dist/mcp/tools/impact-analysis.js.map +1 -0
  1076. package/dist/mcp/tools/implementations.d.ts +13 -0
  1077. package/dist/mcp/tools/implementations.d.ts.map +1 -0
  1078. package/dist/mcp/tools/implementations.js +13 -0
  1079. package/dist/mcp/tools/implementations.js.map +1 -0
  1080. package/dist/mcp/tools/index.d.ts +7 -0
  1081. package/dist/mcp/tools/index.d.ts.map +1 -0
  1082. package/dist/mcp/tools/index.js +76 -0
  1083. package/dist/mcp/tools/index.js.map +1 -0
  1084. package/dist/mcp/tools/interfaces.d.ts +13 -0
  1085. package/dist/mcp/tools/interfaces.d.ts.map +1 -0
  1086. package/dist/mcp/tools/interfaces.js +13 -0
  1087. package/dist/mcp/tools/interfaces.js.map +1 -0
  1088. package/dist/mcp/tools/list-functions.d.ts +12 -0
  1089. package/dist/mcp/tools/list-functions.d.ts.map +1 -0
  1090. package/dist/mcp/tools/list-functions.js +13 -0
  1091. package/dist/mcp/tools/list-functions.js.map +1 -0
  1092. package/dist/mcp/tools/list-repos.d.ts +8 -0
  1093. package/dist/mcp/tools/list-repos.d.ts.map +1 -0
  1094. package/dist/mcp/tools/list-repos.js +11 -0
  1095. package/dist/mcp/tools/list-repos.js.map +1 -0
  1096. package/dist/mcp/tools/module-map.d.ts +9 -0
  1097. package/dist/mcp/tools/module-map.d.ts.map +1 -0
  1098. package/dist/mcp/tools/module-map.js +6 -0
  1099. package/dist/mcp/tools/module-map.js.map +1 -0
  1100. package/dist/mcp/tools/node-roles.d.ts +12 -0
  1101. package/dist/mcp/tools/node-roles.d.ts.map +1 -0
  1102. package/dist/mcp/tools/node-roles.js +13 -0
  1103. package/dist/mcp/tools/node-roles.js.map +1 -0
  1104. package/dist/mcp/tools/path.d.ts +15 -0
  1105. package/dist/mcp/tools/path.d.ts.map +1 -0
  1106. package/dist/mcp/tools/path.js +21 -0
  1107. package/dist/mcp/tools/path.js.map +1 -0
  1108. package/dist/mcp/tools/query.d.ts +20 -0
  1109. package/dist/mcp/tools/query.d.ts.map +1 -0
  1110. package/dist/mcp/tools/query.js +29 -0
  1111. package/dist/mcp/tools/query.js.map +1 -0
  1112. package/dist/mcp/tools/semantic-search.d.ts +13 -0
  1113. package/dist/mcp/tools/semantic-search.d.ts.map +1 -0
  1114. package/dist/mcp/tools/semantic-search.js +62 -0
  1115. package/dist/mcp/tools/semantic-search.js.map +1 -0
  1116. package/dist/mcp/tools/sequence.d.ts +16 -0
  1117. package/dist/mcp/tools/sequence.d.ts.map +1 -0
  1118. package/dist/mcp/tools/sequence.js +16 -0
  1119. package/dist/mcp/tools/sequence.js.map +1 -0
  1120. package/dist/mcp/tools/structure.d.ts +13 -0
  1121. package/dist/mcp/tools/structure.d.ts.map +1 -0
  1122. package/dist/mcp/tools/structure.js +14 -0
  1123. package/dist/mcp/tools/structure.js.map +1 -0
  1124. package/dist/mcp/tools/symbol-children.d.ts +13 -0
  1125. package/dist/mcp/tools/symbol-children.d.ts.map +1 -0
  1126. package/dist/mcp/tools/symbol-children.js +13 -0
  1127. package/dist/mcp/tools/symbol-children.js.map +1 -0
  1128. package/dist/mcp/tools/triage.d.ts +17 -0
  1129. package/dist/mcp/tools/triage.d.ts.map +1 -0
  1130. package/dist/mcp/tools/triage.js +34 -0
  1131. package/dist/mcp/tools/triage.js.map +1 -0
  1132. package/dist/mcp/tools/where.d.ts +12 -0
  1133. package/dist/mcp/tools/where.d.ts.map +1 -0
  1134. package/dist/mcp/tools/where.js +12 -0
  1135. package/dist/mcp/tools/where.js.map +1 -0
  1136. package/dist/mcp/types.d.ts +19 -0
  1137. package/dist/mcp/types.d.ts.map +1 -0
  1138. package/dist/mcp/types.js +6 -0
  1139. package/dist/mcp/types.js.map +1 -0
  1140. package/dist/presentation/audit.d.ts +15 -0
  1141. package/dist/presentation/audit.d.ts.map +1 -0
  1142. package/dist/presentation/audit.js +78 -0
  1143. package/dist/presentation/audit.js.map +1 -0
  1144. package/dist/presentation/batch.d.ts +20 -0
  1145. package/dist/presentation/batch.d.ts.map +1 -0
  1146. package/dist/presentation/batch.js +21 -0
  1147. package/dist/presentation/batch.js.map +1 -0
  1148. package/dist/presentation/branch-compare.d.ts +13 -0
  1149. package/dist/presentation/branch-compare.d.ts.map +1 -0
  1150. package/dist/presentation/branch-compare.js +91 -0
  1151. package/dist/presentation/branch-compare.js.map +1 -0
  1152. package/dist/presentation/brief.d.ts +9 -0
  1153. package/dist/presentation/brief.d.ts.map +1 -0
  1154. package/dist/presentation/brief.js +39 -0
  1155. package/dist/presentation/brief.js.map +1 -0
  1156. package/dist/presentation/cfg.d.ts +13 -0
  1157. package/dist/presentation/cfg.d.ts.map +1 -0
  1158. package/dist/presentation/cfg.js +62 -0
  1159. package/dist/presentation/cfg.js.map +1 -0
  1160. package/dist/presentation/check.d.ts +19 -0
  1161. package/dist/presentation/check.d.ts.map +1 -0
  1162. package/dist/presentation/check.js +74 -0
  1163. package/dist/presentation/check.js.map +1 -0
  1164. package/dist/presentation/cochange.d.ts +32 -0
  1165. package/dist/presentation/cochange.d.ts.map +1 -0
  1166. package/dist/presentation/cochange.js +33 -0
  1167. package/dist/presentation/cochange.js.map +1 -0
  1168. package/dist/presentation/colors.d.ts +12 -0
  1169. package/dist/presentation/colors.d.ts.map +1 -0
  1170. package/dist/presentation/colors.js +47 -0
  1171. package/dist/presentation/colors.js.map +1 -0
  1172. package/dist/presentation/communities.d.ts +11 -0
  1173. package/dist/presentation/communities.d.ts.map +1 -0
  1174. package/dist/presentation/communities.js +57 -0
  1175. package/dist/presentation/communities.js.map +1 -0
  1176. package/dist/presentation/complexity.d.ts +17 -0
  1177. package/dist/presentation/complexity.d.ts.map +1 -0
  1178. package/dist/presentation/complexity.js +59 -0
  1179. package/dist/presentation/complexity.js.map +1 -0
  1180. package/dist/presentation/dataflow.d.ts +14 -0
  1181. package/dist/presentation/dataflow.d.ts.map +1 -0
  1182. package/dist/presentation/dataflow.js +100 -0
  1183. package/dist/presentation/dataflow.js.map +1 -0
  1184. package/dist/presentation/diff-impact-mermaid.d.ts +11 -0
  1185. package/dist/presentation/diff-impact-mermaid.d.ts.map +1 -0
  1186. package/dist/presentation/diff-impact-mermaid.js +114 -0
  1187. package/dist/presentation/diff-impact-mermaid.js.map +1 -0
  1188. package/dist/presentation/export.d.ts +130 -0
  1189. package/dist/presentation/export.d.ts.map +1 -0
  1190. package/dist/presentation/export.js +311 -0
  1191. package/dist/presentation/export.js.map +1 -0
  1192. package/dist/presentation/flow.d.ts +16 -0
  1193. package/dist/presentation/flow.d.ts.map +1 -0
  1194. package/dist/presentation/flow.js +85 -0
  1195. package/dist/presentation/flow.js.map +1 -0
  1196. package/dist/presentation/manifesto.d.ts +13 -0
  1197. package/dist/presentation/manifesto.d.ts.map +1 -0
  1198. package/dist/presentation/manifesto.js +51 -0
  1199. package/dist/presentation/manifesto.js.map +1 -0
  1200. package/dist/presentation/owners.d.ts +16 -0
  1201. package/dist/presentation/owners.d.ts.map +1 -0
  1202. package/dist/presentation/owners.js +42 -0
  1203. package/dist/presentation/owners.js.map +1 -0
  1204. package/dist/presentation/queries-cli/exports.d.ts +12 -0
  1205. package/dist/presentation/queries-cli/exports.d.ts.map +1 -0
  1206. package/dist/presentation/queries-cli/exports.js +100 -0
  1207. package/dist/presentation/queries-cli/exports.js.map +1 -0
  1208. package/dist/presentation/queries-cli/impact.d.ts +23 -0
  1209. package/dist/presentation/queries-cli/impact.d.ts.map +1 -0
  1210. package/dist/presentation/queries-cli/impact.js +208 -0
  1211. package/dist/presentation/queries-cli/impact.js.map +1 -0
  1212. package/dist/presentation/queries-cli/index.d.ts +6 -0
  1213. package/dist/presentation/queries-cli/index.d.ts.map +1 -0
  1214. package/dist/presentation/queries-cli/index.js +6 -0
  1215. package/dist/presentation/queries-cli/index.js.map +1 -0
  1216. package/dist/presentation/queries-cli/inspect.d.ts +23 -0
  1217. package/dist/presentation/queries-cli/inspect.d.ts.map +1 -0
  1218. package/dist/presentation/queries-cli/inspect.js +376 -0
  1219. package/dist/presentation/queries-cli/inspect.js.map +1 -0
  1220. package/dist/presentation/queries-cli/overview.d.ts +19 -0
  1221. package/dist/presentation/queries-cli/overview.d.ts.map +1 -0
  1222. package/dist/presentation/queries-cli/overview.js +196 -0
  1223. package/dist/presentation/queries-cli/overview.js.map +1 -0
  1224. package/dist/presentation/queries-cli/path.d.ts +15 -0
  1225. package/dist/presentation/queries-cli/path.d.ts.map +1 -0
  1226. package/dist/presentation/queries-cli/path.js +101 -0
  1227. package/dist/presentation/queries-cli/path.js.map +1 -0
  1228. package/dist/presentation/queries-cli.d.ts +12 -0
  1229. package/dist/presentation/queries-cli.d.ts.map +1 -0
  1230. package/dist/presentation/queries-cli.js +12 -0
  1231. package/dist/presentation/queries-cli.js.map +1 -0
  1232. package/dist/presentation/query.d.ts +2 -0
  1233. package/dist/presentation/query.d.ts.map +1 -0
  1234. package/dist/presentation/query.js +2 -0
  1235. package/dist/presentation/query.js.map +1 -0
  1236. package/dist/presentation/result-formatter.d.ts +23 -0
  1237. package/dist/presentation/result-formatter.d.ts.map +1 -0
  1238. package/dist/presentation/result-formatter.js +122 -0
  1239. package/dist/presentation/result-formatter.js.map +1 -0
  1240. package/dist/presentation/sequence-renderer.d.ts +19 -0
  1241. package/dist/presentation/sequence-renderer.d.ts.map +1 -0
  1242. package/dist/presentation/sequence-renderer.js +23 -0
  1243. package/dist/presentation/sequence-renderer.js.map +1 -0
  1244. package/dist/presentation/sequence.d.ts +15 -0
  1245. package/dist/presentation/sequence.d.ts.map +1 -0
  1246. package/dist/presentation/sequence.js +26 -0
  1247. package/dist/presentation/sequence.js.map +1 -0
  1248. package/dist/presentation/structure.d.ts +46 -0
  1249. package/dist/presentation/structure.d.ts.map +1 -0
  1250. package/dist/presentation/structure.js +50 -0
  1251. package/dist/presentation/structure.js.map +1 -0
  1252. package/dist/presentation/table.d.ts +24 -0
  1253. package/dist/presentation/table.d.ts.map +1 -0
  1254. package/dist/presentation/table.js +33 -0
  1255. package/dist/presentation/table.js.map +1 -0
  1256. package/dist/presentation/triage.d.ts +19 -0
  1257. package/dist/presentation/triage.d.ts.map +1 -0
  1258. package/dist/presentation/triage.js +34 -0
  1259. package/dist/presentation/triage.js.map +1 -0
  1260. package/dist/presentation/viewer.d.ts +102 -0
  1261. package/dist/presentation/viewer.d.ts.map +1 -0
  1262. package/dist/presentation/viewer.js +618 -0
  1263. package/dist/presentation/viewer.js.map +1 -0
  1264. package/dist/shared/constants.d.ts +33 -0
  1265. package/dist/shared/constants.d.ts.map +1 -0
  1266. package/dist/shared/constants.js +54 -0
  1267. package/dist/shared/constants.js.map +1 -0
  1268. package/dist/shared/errors.d.ts +46 -0
  1269. package/dist/shared/errors.d.ts.map +1 -0
  1270. package/dist/shared/errors.js +69 -0
  1271. package/dist/shared/errors.js.map +1 -0
  1272. package/dist/shared/file-utils.d.ts +27 -0
  1273. package/dist/shared/file-utils.d.ts.map +1 -0
  1274. package/dist/shared/file-utils.js +186 -0
  1275. package/dist/shared/file-utils.js.map +1 -0
  1276. package/dist/shared/generators.d.ts +57 -0
  1277. package/dist/shared/generators.d.ts.map +1 -0
  1278. package/dist/shared/generators.js +106 -0
  1279. package/dist/shared/generators.js.map +1 -0
  1280. package/dist/shared/globs.d.ts +40 -0
  1281. package/dist/shared/globs.d.ts.map +1 -0
  1282. package/dist/shared/globs.js +126 -0
  1283. package/dist/shared/globs.js.map +1 -0
  1284. package/dist/shared/hierarchy.d.ts +9 -0
  1285. package/dist/shared/hierarchy.d.ts.map +1 -0
  1286. package/dist/shared/hierarchy.js +68 -0
  1287. package/dist/shared/hierarchy.js.map +1 -0
  1288. package/dist/shared/kinds.d.ts +12 -0
  1289. package/dist/shared/kinds.d.ts.map +1 -0
  1290. package/dist/shared/kinds.js +67 -0
  1291. package/dist/shared/kinds.js.map +1 -0
  1292. package/dist/shared/normalize.d.ts +49 -0
  1293. package/dist/shared/normalize.d.ts.map +1 -0
  1294. package/dist/shared/normalize.js +57 -0
  1295. package/dist/shared/normalize.js.map +1 -0
  1296. package/dist/shared/paginate.d.ts +32 -0
  1297. package/dist/shared/paginate.d.ts.map +1 -0
  1298. package/dist/shared/paginate.js +82 -0
  1299. package/dist/shared/paginate.js.map +1 -0
  1300. package/dist/shared/version.d.ts +2 -0
  1301. package/dist/shared/version.d.ts.map +1 -0
  1302. package/dist/shared/version.js +5 -0
  1303. package/dist/shared/version.js.map +1 -0
  1304. package/dist/types.d.ts +2468 -0
  1305. package/dist/types.d.ts.map +1 -0
  1306. package/dist/types.js +10 -0
  1307. package/dist/types.js.map +1 -0
  1308. package/grammars/tree-sitter-bash.wasm +0 -0
  1309. package/grammars/tree-sitter-c.wasm +0 -0
  1310. package/grammars/tree-sitter-c_sharp.wasm +0 -0
  1311. package/grammars/tree-sitter-clojure.wasm +0 -0
  1312. package/grammars/tree-sitter-cpp.wasm +0 -0
  1313. package/grammars/tree-sitter-cuda.wasm +0 -0
  1314. package/grammars/tree-sitter-dart.wasm +0 -0
  1315. package/grammars/tree-sitter-elixir.wasm +0 -0
  1316. package/grammars/tree-sitter-erlang.wasm +0 -0
  1317. package/grammars/tree-sitter-fsharp.wasm +0 -0
  1318. package/grammars/tree-sitter-fsharp_signature.wasm +0 -0
  1319. package/grammars/tree-sitter-gleam.wasm +0 -0
  1320. package/grammars/tree-sitter-go.wasm +0 -0
  1321. package/grammars/tree-sitter-groovy.wasm +0 -0
  1322. package/grammars/tree-sitter-haskell.wasm +0 -0
  1323. package/grammars/tree-sitter-hcl.wasm +0 -0
  1324. package/grammars/tree-sitter-java.wasm +0 -0
  1325. package/grammars/tree-sitter-javascript.wasm +0 -0
  1326. package/grammars/tree-sitter-julia.wasm +0 -0
  1327. package/grammars/tree-sitter-kotlin.wasm +0 -0
  1328. package/grammars/tree-sitter-lua.wasm +0 -0
  1329. package/grammars/tree-sitter-objc.wasm +0 -0
  1330. package/grammars/tree-sitter-ocaml.wasm +0 -0
  1331. package/grammars/tree-sitter-ocaml_interface.wasm +0 -0
  1332. package/grammars/tree-sitter-php.wasm +0 -0
  1333. package/grammars/tree-sitter-python.wasm +0 -0
  1334. package/grammars/tree-sitter-r.wasm +0 -0
  1335. package/grammars/tree-sitter-ruby.wasm +0 -0
  1336. package/grammars/tree-sitter-rust.wasm +0 -0
  1337. package/grammars/tree-sitter-scala.wasm +0 -0
  1338. package/grammars/tree-sitter-solidity.wasm +0 -0
  1339. package/grammars/tree-sitter-swift.wasm +0 -0
  1340. package/grammars/tree-sitter-tsx.wasm +0 -0
  1341. package/grammars/tree-sitter-typescript.wasm +0 -0
  1342. package/grammars/tree-sitter-verilog.wasm +0 -0
  1343. package/grammars/tree-sitter-zig.wasm +0 -0
  1344. package/package.json +188 -0
  1345. package/src/ast-analysis/engine.ts +926 -0
  1346. package/src/ast-analysis/metrics.ts +150 -0
  1347. package/src/ast-analysis/rules/b2.ts +263 -0
  1348. package/src/ast-analysis/rules/b3.ts +127 -0
  1349. package/src/ast-analysis/rules/b4.ts +378 -0
  1350. package/src/ast-analysis/rules/b5.ts +65 -0
  1351. package/src/ast-analysis/rules/c.ts +157 -0
  1352. package/src/ast-analysis/rules/csharp.ts +210 -0
  1353. package/src/ast-analysis/rules/go.ts +187 -0
  1354. package/src/ast-analysis/rules/index.ts +380 -0
  1355. package/src/ast-analysis/rules/java.ts +181 -0
  1356. package/src/ast-analysis/rules/javascript.ts +249 -0
  1357. package/src/ast-analysis/rules/php.ts +226 -0
  1358. package/src/ast-analysis/rules/python.ts +202 -0
  1359. package/src/ast-analysis/rules/ruby.ts +209 -0
  1360. package/src/ast-analysis/rules/rust.ts +179 -0
  1361. package/src/ast-analysis/shared.ts +223 -0
  1362. package/src/ast-analysis/visitor-utils.ts +278 -0
  1363. package/src/ast-analysis/visitor.ts +266 -0
  1364. package/src/ast-analysis/visitors/ast-store-visitor.ts +334 -0
  1365. package/src/ast-analysis/visitors/cfg-conditionals.ts +227 -0
  1366. package/src/ast-analysis/visitors/cfg-loops.ts +136 -0
  1367. package/src/ast-analysis/visitors/cfg-shared.ts +196 -0
  1368. package/src/ast-analysis/visitors/cfg-try-catch.ts +142 -0
  1369. package/src/ast-analysis/visitors/cfg-visitor.ts +367 -0
  1370. package/src/ast-analysis/visitors/complexity-visitor.ts +328 -0
  1371. package/src/ast-analysis/visitors/dataflow-visitor.ts +571 -0
  1372. package/src/cli/commands/ast.ts +24 -0
  1373. package/src/cli/commands/audit.ts +48 -0
  1374. package/src/cli/commands/batch.ts +66 -0
  1375. package/src/cli/commands/branch-compare.ts +27 -0
  1376. package/src/cli/commands/brief.ts +13 -0
  1377. package/src/cli/commands/build.ts +35 -0
  1378. package/src/cli/commands/cfg.ts +28 -0
  1379. package/src/cli/commands/check.ts +72 -0
  1380. package/src/cli/commands/children.ts +34 -0
  1381. package/src/cli/commands/co-change.ts +72 -0
  1382. package/src/cli/commands/communities.ts +21 -0
  1383. package/src/cli/commands/complexity.ts +48 -0
  1384. package/src/cli/commands/config.ts +353 -0
  1385. package/src/cli/commands/context.ts +36 -0
  1386. package/src/cli/commands/cycles.ts +33 -0
  1387. package/src/cli/commands/dataflow.ts +30 -0
  1388. package/src/cli/commands/deps.ts +18 -0
  1389. package/src/cli/commands/diff-impact.ts +30 -0
  1390. package/src/cli/commands/embed.ts +82 -0
  1391. package/src/cli/commands/export.ts +79 -0
  1392. package/src/cli/commands/exports.ts +15 -0
  1393. package/src/cli/commands/flow.ts +34 -0
  1394. package/src/cli/commands/fn-impact.ts +34 -0
  1395. package/src/cli/commands/impact.ts +13 -0
  1396. package/src/cli/commands/implementations.ts +30 -0
  1397. package/src/cli/commands/info.ts +79 -0
  1398. package/src/cli/commands/interfaces.ts +30 -0
  1399. package/src/cli/commands/map.ts +20 -0
  1400. package/src/cli/commands/mcp.ts +19 -0
  1401. package/src/cli/commands/models.ts +29 -0
  1402. package/src/cli/commands/owners.ts +28 -0
  1403. package/src/cli/commands/path.ts +42 -0
  1404. package/src/cli/commands/plot.ts +110 -0
  1405. package/src/cli/commands/query.ts +51 -0
  1406. package/src/cli/commands/registry.ts +106 -0
  1407. package/src/cli/commands/roles.ts +38 -0
  1408. package/src/cli/commands/search.ts +45 -0
  1409. package/src/cli/commands/sequence.ts +30 -0
  1410. package/src/cli/commands/snapshot.ts +67 -0
  1411. package/src/cli/commands/stats.ts +16 -0
  1412. package/src/cli/commands/structure.ts +55 -0
  1413. package/src/cli/commands/triage.ts +93 -0
  1414. package/src/cli/commands/watch.ts +29 -0
  1415. package/src/cli/commands/where.ts +21 -0
  1416. package/src/cli/index.ts +159 -0
  1417. package/src/cli/shared/open-graph.ts +13 -0
  1418. package/src/cli/shared/options.ts +69 -0
  1419. package/src/cli/shared/output.ts +1 -0
  1420. package/src/cli/types.ts +35 -0
  1421. package/src/cli.ts +37 -0
  1422. package/src/db/better-sqlite3.ts +21 -0
  1423. package/src/db/connection.ts +478 -0
  1424. package/src/db/index.ts +84 -0
  1425. package/src/db/migrations.ts +440 -0
  1426. package/src/db/query-builder.ts +371 -0
  1427. package/src/db/repository/base.ts +269 -0
  1428. package/src/db/repository/build-stmts.ts +126 -0
  1429. package/src/db/repository/cached-stmt.ts +20 -0
  1430. package/src/db/repository/cfg.ts +81 -0
  1431. package/src/db/repository/cochange.ts +48 -0
  1432. package/src/db/repository/complexity.ts +21 -0
  1433. package/src/db/repository/dataflow.ts +35 -0
  1434. package/src/db/repository/edges.ts +281 -0
  1435. package/src/db/repository/embeddings.ts +47 -0
  1436. package/src/db/repository/graph-read.ts +62 -0
  1437. package/src/db/repository/in-memory-repository.ts +657 -0
  1438. package/src/db/repository/index.ts +53 -0
  1439. package/src/db/repository/native-repository.ts +546 -0
  1440. package/src/db/repository/nodes.ts +322 -0
  1441. package/src/db/repository/sqlite-repository.ts +303 -0
  1442. package/src/domain/analysis/brief.ts +165 -0
  1443. package/src/domain/analysis/context.ts +537 -0
  1444. package/src/domain/analysis/dependencies.ts +738 -0
  1445. package/src/domain/analysis/diff-impact.ts +381 -0
  1446. package/src/domain/analysis/exports.ts +262 -0
  1447. package/src/domain/analysis/fn-impact.ts +311 -0
  1448. package/src/domain/analysis/impact.ts +11 -0
  1449. package/src/domain/analysis/implementations.ts +81 -0
  1450. package/src/domain/analysis/module-map.ts +576 -0
  1451. package/src/domain/analysis/query-helpers.ts +52 -0
  1452. package/src/domain/analysis/roles.ts +95 -0
  1453. package/src/domain/analysis/symbol-lookup.ts +284 -0
  1454. package/src/domain/graph/builder/call-resolver.ts +289 -0
  1455. package/src/domain/graph/builder/cha.ts +192 -0
  1456. package/src/domain/graph/builder/context.ts +120 -0
  1457. package/src/domain/graph/builder/helpers.ts +665 -0
  1458. package/src/domain/graph/builder/incremental.ts +987 -0
  1459. package/src/domain/graph/builder/native-db-proxy.ts +104 -0
  1460. package/src/domain/graph/builder/pipeline.ts +517 -0
  1461. package/src/domain/graph/builder/stages/build-edges.ts +1986 -0
  1462. package/src/domain/graph/builder/stages/build-structure.ts +330 -0
  1463. package/src/domain/graph/builder/stages/collect-files.ts +175 -0
  1464. package/src/domain/graph/builder/stages/detect-changes.ts +751 -0
  1465. package/src/domain/graph/builder/stages/finalize.ts +321 -0
  1466. package/src/domain/graph/builder/stages/insert-nodes.ts +489 -0
  1467. package/src/domain/graph/builder/stages/native-db-lifecycle.ts +74 -0
  1468. package/src/domain/graph/builder/stages/native-orchestrator.ts +2241 -0
  1469. package/src/domain/graph/builder/stages/parse-files.ts +26 -0
  1470. package/src/domain/graph/builder/stages/resolve-imports.ts +285 -0
  1471. package/src/domain/graph/builder/stages/run-analyses.ts +26 -0
  1472. package/src/domain/graph/builder.ts +11 -0
  1473. package/src/domain/graph/change-journal.ts +141 -0
  1474. package/src/domain/graph/cycles.ts +155 -0
  1475. package/src/domain/graph/journal.ts +377 -0
  1476. package/src/domain/graph/resolve.ts +579 -0
  1477. package/src/domain/graph/resolver/points-to.ts +377 -0
  1478. package/src/domain/graph/resolver/strategy.ts +265 -0
  1479. package/src/domain/graph/resolver/ts-resolver.ts +536 -0
  1480. package/src/domain/graph/watcher.ts +339 -0
  1481. package/src/domain/parser.ts +1437 -0
  1482. package/src/domain/queries.ts +50 -0
  1483. package/src/domain/search/generator.ts +260 -0
  1484. package/src/domain/search/index.ts +15 -0
  1485. package/src/domain/search/models.ts +356 -0
  1486. package/src/domain/search/search/cli-formatter.ts +179 -0
  1487. package/src/domain/search/search/filters.ts +38 -0
  1488. package/src/domain/search/search/hybrid.ts +197 -0
  1489. package/src/domain/search/search/keyword.ts +101 -0
  1490. package/src/domain/search/search/prepare.ts +95 -0
  1491. package/src/domain/search/search/semantic.ts +226 -0
  1492. package/src/domain/search/stores/fts5.ts +27 -0
  1493. package/src/domain/search/stores/sqlite-blob.ts +15 -0
  1494. package/src/domain/search/strategies/source.ts +19 -0
  1495. package/src/domain/search/strategies/structured.ts +48 -0
  1496. package/src/domain/search/strategies/text-utils.ts +41 -0
  1497. package/src/domain/wasm-worker-entry.ts +921 -0
  1498. package/src/domain/wasm-worker-pool.ts +375 -0
  1499. package/src/domain/wasm-worker-protocol.ts +98 -0
  1500. package/src/extractors/bash.ts +97 -0
  1501. package/src/extractors/c.ts +231 -0
  1502. package/src/extractors/clojure.ts +273 -0
  1503. package/src/extractors/cpp.ts +383 -0
  1504. package/src/extractors/csharp.ts +448 -0
  1505. package/src/extractors/cuda.ts +433 -0
  1506. package/src/extractors/dart.ts +304 -0
  1507. package/src/extractors/elixir.ts +350 -0
  1508. package/src/extractors/erlang.ts +295 -0
  1509. package/src/extractors/fsharp.ts +357 -0
  1510. package/src/extractors/gleam.ts +247 -0
  1511. package/src/extractors/go.ts +512 -0
  1512. package/src/extractors/groovy.ts +436 -0
  1513. package/src/extractors/haskell.ts +276 -0
  1514. package/src/extractors/hcl.ts +136 -0
  1515. package/src/extractors/helpers.ts +449 -0
  1516. package/src/extractors/index.ts +32 -0
  1517. package/src/extractors/java.ts +439 -0
  1518. package/src/extractors/javascript.ts +3844 -0
  1519. package/src/extractors/julia.ts +432 -0
  1520. package/src/extractors/kotlin.ts +358 -0
  1521. package/src/extractors/lua.ts +169 -0
  1522. package/src/extractors/objc.ts +555 -0
  1523. package/src/extractors/ocaml.ts +337 -0
  1524. package/src/extractors/php.ts +399 -0
  1525. package/src/extractors/python.ts +439 -0
  1526. package/src/extractors/r.ts +275 -0
  1527. package/src/extractors/ruby.ts +292 -0
  1528. package/src/extractors/rust.ts +371 -0
  1529. package/src/extractors/scala.ts +335 -0
  1530. package/src/extractors/solidity.ts +375 -0
  1531. package/src/extractors/swift.ts +337 -0
  1532. package/src/extractors/verilog.ts +383 -0
  1533. package/src/extractors/zig.ts +291 -0
  1534. package/src/features/ast.ts +405 -0
  1535. package/src/features/audit.ts +446 -0
  1536. package/src/features/batch.ts +182 -0
  1537. package/src/features/boundaries.ts +345 -0
  1538. package/src/features/branch-compare.ts +618 -0
  1539. package/src/features/cfg.ts +750 -0
  1540. package/src/features/check.ts +454 -0
  1541. package/src/features/cochange.ts +506 -0
  1542. package/src/features/communities.ts +232 -0
  1543. package/src/features/complexity-query.ts +388 -0
  1544. package/src/features/complexity.ts +753 -0
  1545. package/src/features/dataflow.ts +1654 -0
  1546. package/src/features/export.ts +486 -0
  1547. package/src/features/flow.ts +307 -0
  1548. package/src/features/graph-enrichment.ts +493 -0
  1549. package/src/features/manifesto.ts +508 -0
  1550. package/src/features/owners.ts +360 -0
  1551. package/src/features/sequence.ts +410 -0
  1552. package/src/features/shared/find-nodes.ts +28 -0
  1553. package/src/features/snapshot.ts +221 -0
  1554. package/src/features/structure-query.ts +456 -0
  1555. package/src/features/structure.ts +1100 -0
  1556. package/src/features/triage.ts +199 -0
  1557. package/src/graph/algorithms/bfs.ts +92 -0
  1558. package/src/graph/algorithms/centrality.ts +50 -0
  1559. package/src/graph/algorithms/index.ts +6 -0
  1560. package/src/graph/algorithms/leiden/LICENSE +24 -0
  1561. package/src/graph/algorithms/leiden/adapter.ts +252 -0
  1562. package/src/graph/algorithms/leiden/cpm.ts +77 -0
  1563. package/src/graph/algorithms/leiden/index.ts +224 -0
  1564. package/src/graph/algorithms/leiden/modularity.ts +122 -0
  1565. package/src/graph/algorithms/leiden/optimiser.ts +706 -0
  1566. package/src/graph/algorithms/leiden/partition.ts +577 -0
  1567. package/src/graph/algorithms/leiden/rng.ts +20 -0
  1568. package/src/graph/algorithms/louvain.ts +75 -0
  1569. package/src/graph/algorithms/shortest-path.ts +59 -0
  1570. package/src/graph/algorithms/tarjan.ts +55 -0
  1571. package/src/graph/builders/dependency.ts +148 -0
  1572. package/src/graph/builders/index.ts +3 -0
  1573. package/src/graph/builders/structure.ts +58 -0
  1574. package/src/graph/builders/temporal.ts +51 -0
  1575. package/src/graph/classifiers/index.ts +2 -0
  1576. package/src/graph/classifiers/risk.ts +123 -0
  1577. package/src/graph/classifiers/roles.ts +226 -0
  1578. package/src/graph/index.ts +13 -0
  1579. package/src/graph/model.ts +238 -0
  1580. package/src/index.cjs +16 -0
  1581. package/src/index.ts +72 -0
  1582. package/src/infrastructure/config.ts +954 -0
  1583. package/src/infrastructure/logger.ts +24 -0
  1584. package/src/infrastructure/native.ts +199 -0
  1585. package/src/infrastructure/registry.ts +313 -0
  1586. package/src/infrastructure/result-formatter.ts +2 -0
  1587. package/src/infrastructure/suppress.ts +47 -0
  1588. package/src/infrastructure/test-filter.ts +7 -0
  1589. package/src/infrastructure/update-check.ts +196 -0
  1590. package/src/mcp/index.ts +2 -0
  1591. package/src/mcp/middleware.ts +38 -0
  1592. package/src/mcp/server.ts +259 -0
  1593. package/src/mcp/tool-registry.ts +890 -0
  1594. package/src/mcp/tools/ast-query.ts +25 -0
  1595. package/src/mcp/tools/audit.ts +33 -0
  1596. package/src/mcp/tools/batch-query.ts +22 -0
  1597. package/src/mcp/tools/branch-compare.ts +22 -0
  1598. package/src/mcp/tools/brief.ts +15 -0
  1599. package/src/mcp/tools/cfg.ts +32 -0
  1600. package/src/mcp/tools/check.ts +60 -0
  1601. package/src/mcp/tools/co-changes.ts +29 -0
  1602. package/src/mcp/tools/code-owners.ts +22 -0
  1603. package/src/mcp/tools/communities.ts +25 -0
  1604. package/src/mcp/tools/complexity.ts +30 -0
  1605. package/src/mcp/tools/context.ts +30 -0
  1606. package/src/mcp/tools/dataflow.ts +38 -0
  1607. package/src/mcp/tools/diff-impact.ts +35 -0
  1608. package/src/mcp/tools/execution-flow.ts +38 -0
  1609. package/src/mcp/tools/export-graph.ts +67 -0
  1610. package/src/mcp/tools/file-deps.ts +20 -0
  1611. package/src/mcp/tools/file-exports.ts +22 -0
  1612. package/src/mcp/tools/find-cycles.ts +19 -0
  1613. package/src/mcp/tools/fn-impact.ts +26 -0
  1614. package/src/mcp/tools/impact-analysis.ts +15 -0
  1615. package/src/mcp/tools/implementations.ts +24 -0
  1616. package/src/mcp/tools/index.ts +81 -0
  1617. package/src/mcp/tools/interfaces.ts +24 -0
  1618. package/src/mcp/tools/list-functions.ts +23 -0
  1619. package/src/mcp/tools/list-repos.ts +17 -0
  1620. package/src/mcp/tools/module-map.ts +13 -0
  1621. package/src/mcp/tools/node-roles.ts +23 -0
  1622. package/src/mcp/tools/path.ts +34 -0
  1623. package/src/mcp/tools/query.ts +47 -0
  1624. package/src/mcp/tools/semantic-search.ts +76 -0
  1625. package/src/mcp/tools/sequence.ts +30 -0
  1626. package/src/mcp/tools/structure.ts +25 -0
  1627. package/src/mcp/tools/symbol-children.ts +24 -0
  1628. package/src/mcp/tools/triage.ts +50 -0
  1629. package/src/mcp/tools/where.ts +22 -0
  1630. package/src/mcp/types.ts +21 -0
  1631. package/src/presentation/audit.ts +109 -0
  1632. package/src/presentation/batch.ts +50 -0
  1633. package/src/presentation/branch-compare.ts +148 -0
  1634. package/src/presentation/brief.ts +63 -0
  1635. package/src/presentation/cfg.ts +103 -0
  1636. package/src/presentation/check.ts +138 -0
  1637. package/src/presentation/cochange.ts +57 -0
  1638. package/src/presentation/colors.ts +51 -0
  1639. package/src/presentation/communities.ts +114 -0
  1640. package/src/presentation/complexity.ts +127 -0
  1641. package/src/presentation/dataflow.ts +179 -0
  1642. package/src/presentation/diff-impact-mermaid.ts +169 -0
  1643. package/src/presentation/export.ts +509 -0
  1644. package/src/presentation/flow.ts +147 -0
  1645. package/src/presentation/manifesto.ts +92 -0
  1646. package/src/presentation/owners.ts +89 -0
  1647. package/src/presentation/queries-cli/exports.ts +152 -0
  1648. package/src/presentation/queries-cli/impact.ts +340 -0
  1649. package/src/presentation/queries-cli/index.ts +13 -0
  1650. package/src/presentation/queries-cli/inspect.ts +594 -0
  1651. package/src/presentation/queries-cli/overview.ts +375 -0
  1652. package/src/presentation/queries-cli/path.ts +187 -0
  1653. package/src/presentation/queries-cli.ts +30 -0
  1654. package/src/presentation/query.ts +17 -0
  1655. package/src/presentation/result-formatter.ts +161 -0
  1656. package/src/presentation/sequence-renderer.ts +46 -0
  1657. package/src/presentation/sequence.ts +43 -0
  1658. package/src/presentation/structure.ts +109 -0
  1659. package/src/presentation/table.ts +45 -0
  1660. package/src/presentation/triage.ts +84 -0
  1661. package/src/presentation/viewer.ts +715 -0
  1662. package/src/shared/constants.ts +70 -0
  1663. package/src/shared/errors.ts +85 -0
  1664. package/src/shared/file-utils.ts +233 -0
  1665. package/src/shared/generators.ts +176 -0
  1666. package/src/shared/globs.ts +121 -0
  1667. package/src/shared/hierarchy.ts +81 -0
  1668. package/src/shared/kinds.ts +85 -0
  1669. package/src/shared/normalize.ts +106 -0
  1670. package/src/shared/paginate.ts +93 -0
  1671. package/src/shared/version.ts +10 -0
  1672. package/src/types.ts +2871 -0
@@ -0,0 +1,1654 @@
1
+ /**
2
+ * Dataflow analysis — define/use chains and data movement edges.
3
+ *
4
+ * Adds three edge types to track how data moves through functions:
5
+ * - flows_to: parameter/variable flows into another function as an argument
6
+ * - returns: a call's return value is captured and used in the caller
7
+ * - mutates: a parameter-derived value is mutated (e.g. arr.push())
8
+ *
9
+ * Opt-in via `build --dataflow`. Supports all languages with DATAFLOW_RULES.
10
+ */
11
+
12
+ import fs from 'node:fs';
13
+ import path from 'node:path';
14
+ import { DATAFLOW_RULES } from '../ast-analysis/rules/index.js';
15
+ import {
16
+ makeDataflowRules as _makeDataflowRules,
17
+ buildExtensionSet,
18
+ buildExtToLangMap,
19
+ } from '../ast-analysis/shared.js';
20
+ import { walkWithVisitors } from '../ast-analysis/visitor.js';
21
+ import { createDataflowVisitor } from '../ast-analysis/visitors/dataflow-visitor.js';
22
+ import { hasDataflowTable, openReadonlyOrFail, openReadonlyWithNative } from '../db/index.js';
23
+ import { ALL_SYMBOL_KINDS, normalizeSymbol } from '../domain/queries.js';
24
+ import { debug, info } from '../infrastructure/logger.js';
25
+ import { isTestFile } from '../infrastructure/test-filter.js';
26
+ import type { NormalizedSymbol } from '../shared/normalize.js';
27
+ import { paginateResult } from '../shared/paginate.js';
28
+ import type { BetterSqlite3Database, NativeDatabase, NodeRow, TreeSitterNode } from '../types.js';
29
+ import { findNodes } from './shared/find-nodes.js';
30
+
31
+ // Re-export for backward compatibility
32
+ export { _makeDataflowRules as makeDataflowRules, DATAFLOW_RULES };
33
+
34
+ export const DATAFLOW_EXTENSIONS = buildExtensionSet(DATAFLOW_RULES);
35
+
36
+ // ── AST helpers (now in ast-analysis/visitor-utils.js, kept as re-exports) ──
37
+
38
+ // ── extractDataflow ──────────────────────────────────────────────────────────
39
+
40
+ // Note: This local DataflowResult intentionally differs from the canonical
41
+ // DataflowResult in types.ts. The canonical type describes the visitor's raw
42
+ // output shape, while this module's insertDataflowEdges casts fields to
43
+ // richer local interfaces (ArgFlow, Assignment, Mutation) with additional
44
+ // properties populated during resolution. Aligning them requires unifying
45
+ // the visitor output and DB-insertion shapes — tracked separately.
46
+ interface DataflowResult {
47
+ parameters: unknown[];
48
+ returns: unknown[];
49
+ assignments: unknown[];
50
+ argFlows: unknown[];
51
+ mutations: unknown[];
52
+ }
53
+
54
+ export function extractDataflow(
55
+ tree: { rootNode: TreeSitterNode },
56
+ _filePath: string,
57
+ _definitions: unknown[],
58
+ langId = 'javascript',
59
+ ): DataflowResult {
60
+ const rules = DATAFLOW_RULES.get(langId);
61
+ if (!rules) return { parameters: [], returns: [], assignments: [], argFlows: [], mutations: [] };
62
+
63
+ const visitor = createDataflowVisitor(rules);
64
+ const results = walkWithVisitors(tree.rootNode, [visitor], langId, {
65
+ functionNodeTypes: (rules as { functionNodes: Set<string> }).functionNodes,
66
+ getFunctionName: () => null, // dataflow visitor handles its own name extraction
67
+ });
68
+
69
+ return results.dataflow as DataflowResult;
70
+ }
71
+
72
+ // ── Build-Time Helpers ──────────────────────────────────────────────────────
73
+
74
+ interface FileSymbolsDataflow {
75
+ _tree?: { rootNode: TreeSitterNode } | null;
76
+ _langId?: string | null;
77
+ definitions: Array<{ name: string; kind: string; line: number }>;
78
+ dataflow?: DataflowResult | null;
79
+ }
80
+
81
+ async function initDataflowParsers(
82
+ fileSymbols: Map<string, FileSymbolsDataflow>,
83
+ ): Promise<{ parsers: unknown; getParserFn: ((parsers: any, absPath: string) => any) | null }> {
84
+ let needsFallback = false;
85
+
86
+ for (const [relPath, symbols] of fileSymbols) {
87
+ if (!symbols._tree && !symbols.dataflow) {
88
+ const ext = path.extname(relPath).toLowerCase();
89
+ if (DATAFLOW_EXTENSIONS.has(ext)) {
90
+ needsFallback = true;
91
+ break;
92
+ }
93
+ }
94
+ }
95
+
96
+ let parsers: unknown = null;
97
+ let getParserFn: ((parsers: any, absPath: string) => any) | null = null;
98
+
99
+ if (needsFallback) {
100
+ const { createParsers } = await import('../domain/parser.js');
101
+ parsers = await createParsers();
102
+ const mod = await import('../domain/parser.js');
103
+ getParserFn = mod.getParser;
104
+ }
105
+
106
+ return { parsers, getParserFn };
107
+ }
108
+
109
+ function getDataflowForFile(
110
+ symbols: FileSymbolsDataflow,
111
+ relPath: string,
112
+ rootDir: string,
113
+ extToLang: Map<string, string>,
114
+ parsers: unknown,
115
+ getParserFn: ((parsers: any, absPath: string) => any) | null,
116
+ ): DataflowResult | null {
117
+ if (symbols.dataflow) return symbols.dataflow;
118
+
119
+ let tree = symbols._tree;
120
+ let langId = symbols._langId;
121
+
122
+ if (!tree) {
123
+ if (!getParserFn) return null;
124
+ const ext = path.extname(relPath).toLowerCase();
125
+ langId = extToLang.get(ext);
126
+ if (!langId || !DATAFLOW_RULES.has(langId)) return null;
127
+
128
+ const absPath = path.join(rootDir, relPath);
129
+ let code: string;
130
+ try {
131
+ code = fs.readFileSync(absPath, 'utf-8');
132
+ } catch (e: unknown) {
133
+ debug(`dataflow: cannot read ${relPath}: ${(e as Error).message}`);
134
+ return null;
135
+ }
136
+
137
+ const parser = getParserFn(parsers, absPath);
138
+ if (!parser) return null;
139
+
140
+ try {
141
+ tree = parser.parse(code);
142
+ } catch (e: unknown) {
143
+ debug(`dataflow: parse failed for ${relPath}: ${(e as Error).message}`);
144
+ return null;
145
+ }
146
+ }
147
+
148
+ if (!langId) {
149
+ const ext = path.extname(relPath).toLowerCase();
150
+ langId = extToLang.get(ext);
151
+ if (!langId) return null;
152
+ }
153
+
154
+ if (!DATAFLOW_RULES.has(langId)) return null;
155
+
156
+ return extractDataflow(
157
+ tree as { rootNode: TreeSitterNode },
158
+ relPath,
159
+ symbols.definitions,
160
+ langId,
161
+ );
162
+ }
163
+
164
+ interface ArgFlow {
165
+ callerFunc: string;
166
+ calleeName: string;
167
+ argIndex: number;
168
+ expression: string;
169
+ line: number;
170
+ confidence: number;
171
+ }
172
+
173
+ interface Assignment {
174
+ sourceCallName: string;
175
+ callerFunc: string;
176
+ expression: string;
177
+ line: number;
178
+ }
179
+
180
+ interface Mutation {
181
+ funcName: string;
182
+ binding?: { type: string };
183
+ mutatingExpr: string;
184
+ line: number;
185
+ }
186
+
187
+ // ── P1: Visitor internal shapes ───────────────────────────────────────────────
188
+ // The visitor's finish() emits DataflowResultInternal with richer types than
189
+ // the public DataflowResult in types.ts. We cast here to access paramName,
190
+ // paramIndex, and referencedNames which the public type omits.
191
+
192
+ interface VisitorParam {
193
+ funcName: string;
194
+ paramName: string;
195
+ paramIndex: number;
196
+ line: number;
197
+ }
198
+
199
+ interface VisitorReturn {
200
+ funcName: string;
201
+ expression: string;
202
+ referencedNames: string[];
203
+ line: number;
204
+ }
205
+
206
+ interface VisitorAssignment {
207
+ varName: string;
208
+ callerFunc: string;
209
+ sourceCallName: string;
210
+ line: number;
211
+ }
212
+
213
+ interface VisitorArgFlow {
214
+ callerFunc: string;
215
+ calleeName: string;
216
+ argIndex: number;
217
+ argName: string;
218
+ binding: { type: string; index?: number };
219
+ confidence: number;
220
+ expression: string;
221
+ line: number;
222
+ }
223
+
224
+ interface VisitorMutation {
225
+ funcName: string;
226
+ binding: { type: string; index?: number };
227
+ }
228
+
229
+ // ── P2: interprocedural stitch data collected during per-file processing ──
230
+
231
+ /** A resolved argFlow candidate for the inter-procedural stitch post-pass. */
232
+ interface StitchCandidate {
233
+ callerFuncId: number;
234
+ calleeFuncId: number;
235
+ argIndex: number;
236
+ bindingType: string;
237
+ bindingIndex?: number;
238
+ argName: string;
239
+ expression: string;
240
+ line: number;
241
+ confidence: number;
242
+ }
243
+
244
+ /** An assignment that captures a function's return value into a local. */
245
+ interface ReturnCapture {
246
+ callerFuncId: number;
247
+ calleeFuncId: number;
248
+ varName: string;
249
+ }
250
+
251
+ function insertDataflowEdges(
252
+ insert: { run(...params: unknown[]): unknown },
253
+ data: DataflowResult,
254
+ resolveNode: (name: string) => { id: number } | null,
255
+ ): number {
256
+ let edgeCount = 0;
257
+
258
+ for (const flow of data.argFlows as ArgFlow[]) {
259
+ const sourceNode = resolveNode(flow.callerFunc);
260
+ const targetNode = resolveNode(flow.calleeName);
261
+ if (sourceNode && targetNode) {
262
+ insert.run(
263
+ sourceNode.id,
264
+ targetNode.id,
265
+ 'flows_to',
266
+ flow.argIndex,
267
+ flow.expression,
268
+ flow.line,
269
+ flow.confidence,
270
+ );
271
+ edgeCount++;
272
+ }
273
+ }
274
+
275
+ for (const assignment of data.assignments as Assignment[]) {
276
+ const producerNode = resolveNode(assignment.sourceCallName);
277
+ const consumerNode = resolveNode(assignment.callerFunc);
278
+ if (producerNode && consumerNode) {
279
+ insert.run(
280
+ producerNode.id,
281
+ consumerNode.id,
282
+ 'returns',
283
+ null,
284
+ assignment.expression,
285
+ assignment.line,
286
+ 1.0,
287
+ );
288
+ edgeCount++;
289
+ }
290
+ }
291
+
292
+ for (const mut of data.mutations as Mutation[]) {
293
+ const mutatorNode = resolveNode(mut.funcName);
294
+ if (mutatorNode && mut.binding?.type === 'param') {
295
+ insert.run(mutatorNode.id, mutatorNode.id, 'mutates', null, mut.mutatingExpr, mut.line, 1.0);
296
+ edgeCount++;
297
+ }
298
+ }
299
+
300
+ return edgeCount;
301
+ }
302
+
303
+ // ── P1: dataflow_vertices + intra def_use edges ───────────────────────────────
304
+
305
+ function prepareVertexStmts(db: BetterSqlite3Database): {
306
+ insertVertex: ReturnType<BetterSqlite3Database['prepare']>;
307
+ insertIntraEdge: ReturnType<BetterSqlite3Database['prepare']>;
308
+ available: boolean;
309
+ } {
310
+ try {
311
+ return {
312
+ insertVertex: db.prepare(
313
+ `INSERT INTO dataflow_vertices (func_id, kind, name, param_index, line, node_id)
314
+ VALUES (?, ?, ?, ?, ?, ?)`,
315
+ ),
316
+ insertIntraEdge: db.prepare(
317
+ `INSERT INTO dataflow
318
+ (source_id, target_id, kind, source_vertex, target_vertex, scope, expression, line, confidence)
319
+ VALUES (?, ?, 'def_use', ?, ?, 'intra', ?, ?, 1.0)`,
320
+ ),
321
+ available: true,
322
+ };
323
+ } catch {
324
+ return {
325
+ insertVertex: db.prepare('SELECT 1'),
326
+ insertIntraEdge: db.prepare('SELECT 1'),
327
+ available: false,
328
+ };
329
+ }
330
+ }
331
+
332
+ /**
333
+ * Build dataflow_vertices, intra def_use edges, and summaries for one file.
334
+ * Called alongside insertDataflowEdges in the same transaction.
335
+ *
336
+ * Returns stitch candidates and return captures for the P2 inter-procedural
337
+ * post-pass (run after all files are processed).
338
+ */
339
+ function buildDataflowVerticesAndEdges(
340
+ db: BetterSqlite3Database,
341
+ vstmts: ReturnType<typeof prepareVertexStmts>,
342
+ data: DataflowResult,
343
+ resolveNode: (name: string) => { id: number } | null,
344
+ ): { candidates: StitchCandidate[]; captures: ReturnCapture[] } {
345
+ const empty: { candidates: StitchCandidate[]; captures: ReturnCapture[] } = {
346
+ candidates: [],
347
+ captures: [],
348
+ };
349
+ if (!vstmts.available) return empty;
350
+
351
+ const params = data.parameters as unknown as VisitorParam[];
352
+ const returns = data.returns as unknown as VisitorReturn[];
353
+ const assignments = data.assignments as unknown as VisitorAssignment[];
354
+ const argFlows = data.argFlows as unknown as VisitorArgFlow[];
355
+ const mutations = data.mutations as unknown as VisitorMutation[];
356
+
357
+ // 1. param vertices
358
+ const paramVertexIds = new Map<string, number>(); // "funcName:paramName" → vertex id
359
+ const paramIndexByFuncAndIndex = new Map<string, number>(); // "funcId:paramIndex" → vertex id
360
+ for (const p of params) {
361
+ const fn = resolveNode(p.funcName);
362
+ if (!fn) continue;
363
+ const result = vstmts.insertVertex.run(fn.id, 'param', p.paramName, p.paramIndex, p.line, null);
364
+ const vid = (result as { lastInsertRowid: number }).lastInsertRowid;
365
+ paramVertexIds.set(`${p.funcName}:${p.paramName}`, vid);
366
+ paramIndexByFuncAndIndex.set(`${fn.id}:${p.paramIndex}`, vid);
367
+ }
368
+
369
+ // 2. return vertices (one per function that has a return statement)
370
+ const returnVertexIds = new Map<string, number>(); // funcName → vertex id
371
+ const returnFuncsSeen = new Set<string>();
372
+ for (const r of returns) {
373
+ if (returnFuncsSeen.has(r.funcName)) continue;
374
+ returnFuncsSeen.add(r.funcName);
375
+ const fn = resolveNode(r.funcName);
376
+ if (!fn) continue;
377
+ const result = vstmts.insertVertex.run(fn.id, 'return', null, null, r.line, null);
378
+ returnVertexIds.set(r.funcName, (result as { lastInsertRowid: number }).lastInsertRowid);
379
+ }
380
+
381
+ // 3. local vertices (from call-return assignments)
382
+ const localVertexIds = new Map<string, number>(); // "funcName:varName" → vertex id
383
+ const localsSeen = new Set<string>();
384
+ for (const a of assignments) {
385
+ const key = `${a.callerFunc}:${a.varName}`;
386
+ if (localsSeen.has(key)) continue;
387
+ localsSeen.add(key);
388
+ const fn = resolveNode(a.callerFunc);
389
+ if (!fn) continue;
390
+ const result = vstmts.insertVertex.run(fn.id, 'local', a.varName, null, a.line, null);
391
+ localVertexIds.set(key, (result as { lastInsertRowid: number }).lastInsertRowid);
392
+ }
393
+
394
+ // 4. intra def_use edges: param/local → return
395
+ for (const r of returns) {
396
+ const fn = resolveNode(r.funcName);
397
+ if (!fn) continue;
398
+ const returnVid = returnVertexIds.get(r.funcName);
399
+ if (!returnVid) continue;
400
+ for (const name of r.referencedNames) {
401
+ const paramVid = paramVertexIds.get(`${r.funcName}:${name}`);
402
+ if (paramVid) {
403
+ vstmts.insertIntraEdge.run(fn.id, fn.id, paramVid, returnVid, r.expression, r.line);
404
+ }
405
+ const localVid = localVertexIds.get(`${r.funcName}:${name}`);
406
+ if (localVid) {
407
+ vstmts.insertIntraEdge.run(fn.id, fn.id, localVid, returnVid, r.expression, r.line);
408
+ }
409
+ }
410
+ }
411
+
412
+ // 5. summaries: flows_to_return = direct def_use from param to function's return
413
+ const checkDefUse = db.prepare(
414
+ `SELECT 1 FROM dataflow WHERE source_vertex = ? AND target_vertex = ? AND kind = 'def_use' LIMIT 1`,
415
+ );
416
+ const insertSummary = db.prepare(
417
+ `INSERT OR REPLACE INTO dataflow_summary (func_id, param_index, flows_to_return, is_mutated) VALUES (?, ?, ?, ?)`,
418
+ );
419
+
420
+ for (const p of params) {
421
+ const fn = resolveNode(p.funcName);
422
+ if (!fn) continue;
423
+ const paramVid = paramVertexIds.get(`${p.funcName}:${p.paramName}`);
424
+ if (!paramVid) continue;
425
+ const returnVid = returnVertexIds.get(p.funcName);
426
+ const flowsToReturn = returnVid ? (checkDefUse.get(paramVid, returnVid) ? 1 : 0) : 0;
427
+ const isMutated = mutations.some(
428
+ (m) =>
429
+ m.funcName === p.funcName &&
430
+ m.binding?.type === 'param' &&
431
+ m.binding?.index === p.paramIndex,
432
+ )
433
+ ? 1
434
+ : 0;
435
+ insertSummary.run(fn.id, p.paramIndex, flowsToReturn, isMutated);
436
+ }
437
+
438
+ // 6. collect stitch candidates for P2 inter-procedural post-pass
439
+ const candidates: StitchCandidate[] = [];
440
+ for (const af of argFlows) {
441
+ const callerFn = resolveNode(af.callerFunc);
442
+ const calleeFn = resolveNode(af.calleeName);
443
+ if (!callerFn || !calleeFn) continue;
444
+ candidates.push({
445
+ callerFuncId: callerFn.id,
446
+ calleeFuncId: calleeFn.id,
447
+ argIndex: af.argIndex,
448
+ bindingType: af.binding.type,
449
+ bindingIndex: af.binding.index,
450
+ argName: af.argName,
451
+ expression: af.expression,
452
+ line: af.line,
453
+ confidence: af.confidence,
454
+ });
455
+ }
456
+
457
+ // 7. collect return captures (locals that hold a callee's return value)
458
+ const captures: ReturnCapture[] = [];
459
+ for (const a of assignments) {
460
+ const callerFn = resolveNode(a.callerFunc);
461
+ const calleeFn = resolveNode(a.sourceCallName);
462
+ if (!callerFn || !calleeFn) continue;
463
+ captures.push({ callerFuncId: callerFn.id, calleeFuncId: calleeFn.id, varName: a.varName });
464
+ }
465
+
466
+ return { candidates, captures };
467
+ }
468
+
469
+ // ── P2: interprocedural stitching ─────────────────────────────────────────────
470
+
471
+ /**
472
+ * Post-pass: connect arg-flow candidates to vertex-level inter-procedural edges.
473
+ * Runs after all per-file vertices + summaries have been committed.
474
+ *
475
+ * For each resolved argFlow (A calls B with arg x → B.param[j]):
476
+ * - Emits 'arg_in' inter edge: A's source vertex → B.param[j] vertex
477
+ * - If B's summary shows B.param[j] reaches B's return: emits 'return_out'
478
+ * inter edge: B.return → A's capture local (if any)
479
+ */
480
+ function buildInterproceduralStitch(
481
+ db: BetterSqlite3Database,
482
+ candidates: StitchCandidate[],
483
+ captures: ReturnCapture[],
484
+ ): number {
485
+ if (candidates.length === 0) return 0;
486
+
487
+ const getParamVertex = db.prepare(
488
+ `SELECT id FROM dataflow_vertices WHERE func_id = ? AND kind = 'param' AND param_index = ? LIMIT 1`,
489
+ );
490
+ const getLocalVertex = db.prepare(
491
+ `SELECT id FROM dataflow_vertices WHERE func_id = ? AND kind = 'local' AND name = ? LIMIT 1`,
492
+ );
493
+ const getReturnVertex = db.prepare(
494
+ `SELECT id FROM dataflow_vertices WHERE func_id = ? AND kind = 'return' LIMIT 1`,
495
+ );
496
+ const getCallEdge = db.prepare(
497
+ `SELECT id FROM edges WHERE source_id = ? AND target_id = ? AND kind = 'calls' LIMIT 1`,
498
+ );
499
+ const getSummary = db.prepare(
500
+ `SELECT flows_to_return FROM dataflow_summary WHERE func_id = ? AND param_index = ?`,
501
+ );
502
+ const insertInterEdge = db.prepare(
503
+ `INSERT INTO dataflow
504
+ (source_id, target_id, kind, source_vertex, target_vertex, scope, call_edge_id, expression, line, confidence)
505
+ VALUES (?, ?, ?, ?, ?, 'inter', ?, ?, ?, ?)`,
506
+ );
507
+
508
+ // Build capture map: "callerFuncId:calleeFuncId" → varName (first match wins)
509
+ const captureMap = new Map<string, string>();
510
+ for (const cap of captures) {
511
+ const key = `${cap.callerFuncId}:${cap.calleeFuncId}`;
512
+ if (!captureMap.has(key)) captureMap.set(key, cap.varName);
513
+ }
514
+
515
+ let count = 0;
516
+ const tx = db.transaction(() => {
517
+ for (const cand of candidates) {
518
+ // Resolve call edge for this site
519
+ const callEdge = getCallEdge.get(cand.callerFuncId, cand.calleeFuncId) as {
520
+ id: number;
521
+ } | null;
522
+ const callEdgeId = callEdge?.id ?? null;
523
+
524
+ // Find source vertex x in caller
525
+ let srcVertexId: number | null = null;
526
+ if (cand.bindingType === 'param' && cand.bindingIndex != null) {
527
+ const v = getParamVertex.get(cand.callerFuncId, cand.bindingIndex) as { id: number } | null;
528
+ srcVertexId = v?.id ?? null;
529
+ } else if (cand.bindingType === 'local') {
530
+ const v = getLocalVertex.get(cand.callerFuncId, cand.argName) as { id: number } | null;
531
+ srcVertexId = v?.id ?? null;
532
+ }
533
+
534
+ if (!srcVertexId) continue;
535
+
536
+ // Find callee's param[argIndex] vertex
537
+ const calleeParam = getParamVertex.get(cand.calleeFuncId, cand.argIndex) as {
538
+ id: number;
539
+ } | null;
540
+ if (!calleeParam) continue;
541
+
542
+ // arg_in: A's source → B.param[j]
543
+ insertInterEdge.run(
544
+ cand.callerFuncId,
545
+ cand.calleeFuncId,
546
+ 'arg_in',
547
+ srcVertexId,
548
+ calleeParam.id,
549
+ callEdgeId,
550
+ cand.expression,
551
+ cand.line,
552
+ cand.confidence,
553
+ );
554
+ count++;
555
+
556
+ // return_out: if B.param[j] reaches B's return, emit B.return → A's capture
557
+ const summary = getSummary.get(cand.calleeFuncId, cand.argIndex) as {
558
+ flows_to_return: number;
559
+ } | null;
560
+ if (summary?.flows_to_return) {
561
+ const calleeReturn = getReturnVertex.get(cand.calleeFuncId) as { id: number } | null;
562
+ if (calleeReturn) {
563
+ const captureVarName = captureMap.get(`${cand.callerFuncId}:${cand.calleeFuncId}`);
564
+ const captureVertex = captureVarName
565
+ ? (getLocalVertex.get(cand.callerFuncId, captureVarName) as { id: number } | null)
566
+ : null;
567
+ if (captureVertex) {
568
+ insertInterEdge.run(
569
+ cand.calleeFuncId,
570
+ cand.callerFuncId,
571
+ 'return_out',
572
+ calleeReturn.id,
573
+ captureVertex.id,
574
+ callEdgeId,
575
+ cand.expression,
576
+ cand.line,
577
+ cand.confidence,
578
+ );
579
+ count++;
580
+ }
581
+ }
582
+ }
583
+ }
584
+ });
585
+
586
+ tx();
587
+ return count;
588
+ }
589
+
590
+ // ── buildDataflowEdges ──────────────────────────────────────────────────────
591
+
592
+ // ── P4 helpers ───────────────────────────────────────────────────────────────
593
+
594
+ /** Return IDs of all function/method nodes in the given relative file paths. */
595
+ export function collectFuncIdsForFiles(
596
+ db: BetterSqlite3Database,
597
+ relPaths: Iterable<string>,
598
+ ): number[] {
599
+ const stmt = db.prepare(`SELECT id FROM nodes WHERE file = ? AND kind IN ('function', 'method')`);
600
+ const ids: number[] = [];
601
+ for (const p of relPaths) {
602
+ for (const row of stmt.all(p) as { id: number }[]) ids.push(row.id);
603
+ }
604
+ return ids;
605
+ }
606
+
607
+ /**
608
+ * P4: Re-collect stitch candidates from caller files that were NOT in the
609
+ * changed set but contain calls to functions that WERE changed.
610
+ *
611
+ * During an incremental build the changed files' param vertices are purged
612
+ * and recreated, but the callers' files are never re-parsed — so their
613
+ * arg_in edges (pointing to the old param vertices) are deleted and never
614
+ * replaced. This function reads those caller files from disk and rebuilds
615
+ * the StitchCandidate list so buildInterproceduralStitch can reconnect them.
616
+ */
617
+ export async function collectCallerStitchCandidates(
618
+ db: BetterSqlite3Database,
619
+ changedFuncIds: number[],
620
+ changedRelPaths: Set<string>,
621
+ rootDir: string,
622
+ extToLang: Map<string, string>,
623
+ parsers: unknown,
624
+ getParserFn: ((parsers: any, absPath: string) => any) | null,
625
+ ): Promise<{ candidates: StitchCandidate[]; captures: ReturnCapture[] }> {
626
+ if (changedFuncIds.length === 0) return { candidates: [], captures: [] };
627
+
628
+ // Find distinct caller files that have flows_to edges targeting any changed
629
+ // function and are NOT already in the changed file set (those are handled by
630
+ // the main per-file loop).
631
+ //
632
+ // Chunk the query to avoid exceeding SQLite's SQLITE_MAX_VARIABLE_NUMBER
633
+ // (999 on older builds, 32766 on SQLite ≥ 3.32). 500 is a safe batch size
634
+ // that works across all SQLite versions.
635
+ const CHUNK_SIZE = 500;
636
+ const callerFileSet = new Set<string>();
637
+ for (let i = 0; i < changedFuncIds.length; i += CHUNK_SIZE) {
638
+ const chunk = changedFuncIds.slice(i, i + CHUNK_SIZE);
639
+ const placeholders = chunk.map(() => '?').join(',');
640
+ const rows = db
641
+ .prepare(
642
+ `SELECT DISTINCT n.file AS caller_file
643
+ FROM dataflow d
644
+ JOIN nodes n ON n.id = d.source_id
645
+ WHERE d.target_id IN (${placeholders})
646
+ AND d.kind = 'flows_to'`,
647
+ )
648
+ .all(...chunk) as { caller_file: string }[];
649
+ for (const r of rows) callerFileSet.add(r.caller_file);
650
+ }
651
+ const callerFileRows = [...callerFileSet].map((f) => ({ caller_file: f }));
652
+
653
+ const callerFiles = callerFileRows
654
+ .map((r) => r.caller_file)
655
+ .filter((f) => !changedRelPaths.has(f));
656
+
657
+ if (callerFiles.length === 0) return { candidates: [], captures: [] };
658
+
659
+ // Ensure parsers are available — the main loop may have skipped loading them
660
+ // if all changed files came through the native bulk-insert path.
661
+ let activeParsers = parsers;
662
+ let activeGetParserFn = getParserFn;
663
+ if (!activeGetParserFn) {
664
+ const { createParsers, getParser } = await import('../domain/parser.js');
665
+ activeParsers = await createParsers();
666
+ activeGetParserFn = getParser;
667
+ }
668
+
669
+ const changedFuncIdSet = new Set(changedFuncIds);
670
+ const stmts = prepareNodeResolvers(db);
671
+ const candidates: StitchCandidate[] = [];
672
+ const captures: ReturnCapture[] = [];
673
+
674
+ for (const callerFile of callerFiles) {
675
+ // Read the caller file from disk without touching its existing DB rows.
676
+ // definitions: [] is an intentional stub — P4 only needs argFlow/assignment
677
+ // data from the visitor, not pre-loaded symbol definitions. extractDataflow
678
+ // does not currently use _definitions, so this is safe. If that changes,
679
+ // the stub must be replaced with the actual symbol list for the caller file.
680
+ const stub: FileSymbolsDataflow = { definitions: [], _langId: null, _tree: null };
681
+ const data = getDataflowForFile(
682
+ stub,
683
+ callerFile,
684
+ rootDir,
685
+ extToLang,
686
+ activeParsers,
687
+ activeGetParserFn,
688
+ );
689
+ if (!data) continue;
690
+
691
+ const resolver = makeNodeResolver(stmts, callerFile);
692
+ const argFlows = data.argFlows as unknown as VisitorArgFlow[];
693
+ const assignments = data.assignments as unknown as VisitorAssignment[];
694
+
695
+ for (const af of argFlows) {
696
+ const callerFn = resolver(af.callerFunc);
697
+ const calleeFn = resolver(af.calleeName);
698
+ if (!callerFn || !calleeFn) continue;
699
+ if (!changedFuncIdSet.has(calleeFn.id)) continue; // only re-stitch calls to changed callees
700
+ candidates.push({
701
+ callerFuncId: callerFn.id,
702
+ calleeFuncId: calleeFn.id,
703
+ argIndex: af.argIndex,
704
+ bindingType: af.binding.type,
705
+ bindingIndex: af.binding.index,
706
+ argName: af.argName,
707
+ expression: af.expression,
708
+ line: af.line,
709
+ confidence: af.confidence,
710
+ });
711
+ }
712
+
713
+ for (const a of assignments) {
714
+ const callerFn = resolver(a.callerFunc);
715
+ const calleeFn = resolver(a.sourceCallName);
716
+ if (!callerFn || !calleeFn) continue;
717
+ if (!changedFuncIdSet.has(calleeFn.id)) continue;
718
+ captures.push({ callerFuncId: callerFn.id, calleeFuncId: calleeFn.id, varName: a.varName });
719
+ }
720
+ }
721
+
722
+ debug(
723
+ `Dataflow P4: re-stitched ${candidates.length} candidate(s) from ${callerFiles.length} caller file(s)`,
724
+ );
725
+ return { candidates, captures };
726
+ }
727
+
728
+ function prepareNodeResolvers(db: BetterSqlite3Database): {
729
+ getNodeByNameAndFile: ReturnType<BetterSqlite3Database['prepare']>;
730
+ getNodeByName: ReturnType<BetterSqlite3Database['prepare']>;
731
+ } {
732
+ return {
733
+ getNodeByNameAndFile: db.prepare(
734
+ `SELECT id, name, kind, file, line FROM nodes
735
+ WHERE name = ? AND file = ? AND kind IN ('function', 'method')`,
736
+ ),
737
+ getNodeByName: db.prepare(
738
+ `SELECT id, name, kind, file, line FROM nodes
739
+ WHERE name = ? AND kind IN ('function', 'method')
740
+ ORDER BY file, line LIMIT 10`,
741
+ ),
742
+ };
743
+ }
744
+
745
+ function makeNodeResolver(
746
+ stmts: ReturnType<typeof prepareNodeResolvers>,
747
+ relPath: string,
748
+ ): (funcName: string) => { id: number } | null {
749
+ return (funcName: string): { id: number } | null => {
750
+ const local = stmts.getNodeByNameAndFile.all(funcName, relPath) as { id: number }[];
751
+ if (local.length > 0) return local[0]!;
752
+ const global = stmts.getNodeByName.all(funcName) as { id: number }[];
753
+ return global.length > 0 ? global[0]! : null;
754
+ };
755
+ }
756
+
757
+ function collectNativeEdges(
758
+ data: DataflowResult,
759
+ resolveNode: (name: string) => { id: number } | null,
760
+ edges: Array<Record<string, unknown>>,
761
+ ): void {
762
+ for (const flow of data.argFlows as ArgFlow[]) {
763
+ const sourceNode = resolveNode(flow.callerFunc);
764
+ const targetNode = resolveNode(flow.calleeName);
765
+ if (sourceNode && targetNode) {
766
+ edges.push({
767
+ sourceId: sourceNode.id,
768
+ targetId: targetNode.id,
769
+ kind: 'flows_to',
770
+ paramIndex: flow.argIndex,
771
+ expression: flow.expression,
772
+ line: flow.line,
773
+ confidence: flow.confidence,
774
+ });
775
+ }
776
+ }
777
+ for (const assignment of data.assignments as Assignment[]) {
778
+ const producerNode = resolveNode(assignment.sourceCallName);
779
+ const consumerNode = resolveNode(assignment.callerFunc);
780
+ if (producerNode && consumerNode) {
781
+ edges.push({
782
+ sourceId: producerNode.id,
783
+ targetId: consumerNode.id,
784
+ kind: 'returns',
785
+ paramIndex: undefined,
786
+ expression: assignment.expression,
787
+ line: assignment.line,
788
+ confidence: 1.0,
789
+ });
790
+ }
791
+ }
792
+ for (const mut of data.mutations as Mutation[]) {
793
+ const mutatorNode = resolveNode(mut.funcName);
794
+ if (mutatorNode && mut.binding?.type === 'param') {
795
+ edges.push({
796
+ sourceId: mutatorNode.id,
797
+ targetId: mutatorNode.id,
798
+ kind: 'mutates',
799
+ paramIndex: undefined,
800
+ expression: mut.mutatingExpr,
801
+ line: mut.line,
802
+ confidence: 1.0,
803
+ });
804
+ }
805
+ }
806
+ }
807
+
808
+ /**
809
+ * P6 vertex-only pass for the native orchestrator path.
810
+ *
811
+ * When the Rust orchestrator runs with analysisComplete=true it inserts
812
+ * flows_to/returns/mutates edges directly into the DB but never writes to
813
+ * dataflow_vertices or dataflow_summary. This function takes pre-extracted
814
+ * DataflowResult objects (from native.extractDataflowAnalysis) and builds
815
+ * the missing vertex rows and inter-procedural edges — without touching the
816
+ * already-correct function-level edges.
817
+ */
818
+ export function buildDataflowVerticesFromMap(
819
+ db: BetterSqlite3Database,
820
+ dataflowMap: Map<string, DataflowResult>,
821
+ extraCandidates?: StitchCandidate[],
822
+ extraCaptures?: ReturnCapture[],
823
+ ): number {
824
+ const vstmts = prepareVertexStmts(db);
825
+ if (!vstmts.available || dataflowMap.size === 0) return 0;
826
+
827
+ const stmts = prepareNodeResolvers(db);
828
+ const allCandidates: StitchCandidate[] = [];
829
+ const allCaptures: ReturnCapture[] = [];
830
+
831
+ const tx = db.transaction(() => {
832
+ for (const [relPath, data] of dataflowMap) {
833
+ const resolver = makeNodeResolver(stmts, relPath);
834
+ const { candidates, captures } = buildDataflowVerticesAndEdges(db, vstmts, data, resolver);
835
+ allCandidates.push(...candidates);
836
+ allCaptures.push(...captures);
837
+ }
838
+ });
839
+ tx();
840
+
841
+ // P4: merge in stitch candidates from unchanged caller files if provided.
842
+ if (extraCandidates && extraCandidates.length > 0) allCandidates.push(...extraCandidates);
843
+ if (extraCaptures && extraCaptures.length > 0) allCaptures.push(...extraCaptures);
844
+
845
+ return buildInterproceduralStitch(db, allCandidates, allCaptures);
846
+ }
847
+
848
+ /**
849
+ * P4 re-stitch pass for the native engine path.
850
+ *
851
+ * On incremental builds the changed files' param vertices are purged and
852
+ * recreated by the P6 vertex pass, but unchanged caller files are never
853
+ * re-parsed — so their arg_in edges (which pointed to the old param vertex
854
+ * IDs) are deleted and not replaced. This function re-parses those caller
855
+ * files and rebuilds the arg_in edges for any call that targets a function
856
+ * in one of the changed callee files.
857
+ *
858
+ * Called by the native orchestrator after buildDataflowVerticesFromMap.
859
+ * Safe to call on full builds — the guard below exits early when
860
+ * changedFiles covers all distinct files in the DB.
861
+ */
862
+ export async function buildDataflowP4ForNative(
863
+ db: BetterSqlite3Database,
864
+ changedFiles: string[],
865
+ rootDir: string,
866
+ ): Promise<void> {
867
+ if (changedFiles.length === 0) return;
868
+
869
+ // Deduplicate upfront so the full-build guard uses unique-file count, not
870
+ // raw array length (the orchestrator may emit the same path more than once).
871
+ const changedRelPaths = new Set(changedFiles);
872
+
873
+ // Skip on full builds — all files were in the changed set, so there are no
874
+ // unchanged callers to re-stitch.
875
+ const totalFilesInDb = (
876
+ db.prepare(`SELECT COUNT(DISTINCT file) AS n FROM nodes`).get() as { n: number }
877
+ ).n;
878
+ if (changedRelPaths.size >= totalFilesInDb) return;
879
+
880
+ const extToLang = buildExtToLangMap();
881
+ const changedFuncIds = collectFuncIdsForFiles(db, changedRelPaths);
882
+ if (changedFuncIds.length === 0) return;
883
+
884
+ // parsers=null, getParserFn=null → collectCallerStitchCandidates initialises
885
+ // WASM parsers lazily for the caller files it needs to re-parse.
886
+ const { candidates, captures } = await collectCallerStitchCandidates(
887
+ db,
888
+ changedFuncIds,
889
+ changedRelPaths,
890
+ rootDir,
891
+ extToLang,
892
+ null,
893
+ null,
894
+ );
895
+
896
+ if (candidates.length > 0) {
897
+ // Purge any existing arg_in edges targeting the changed callees from unchanged
898
+ // caller files. These edges were inserted by a previous P4 pass. Without this
899
+ // guard, repeated calls to buildDataflowP4ForNative insert duplicates because
900
+ // the dataflow table has no UNIQUE constraint on (source_vertex, target_vertex).
901
+ const placeholders = changedFuncIds.map(() => '?').join(',');
902
+ db.prepare(
903
+ `DELETE FROM dataflow
904
+ WHERE kind = 'arg_in'
905
+ AND target_id IN (${placeholders})
906
+ AND source_id NOT IN (${placeholders})`,
907
+ ).run(...changedFuncIds, ...changedFuncIds);
908
+
909
+ const count = buildInterproceduralStitch(db, candidates, captures);
910
+ if (count > 0) {
911
+ info(`Dataflow (native P4): ${count} inter-procedural edges re-stitched`);
912
+ }
913
+ }
914
+ }
915
+
916
+ export async function buildDataflowEdges(
917
+ db: BetterSqlite3Database,
918
+ fileSymbols: Map<string, FileSymbolsDataflow>,
919
+ rootDir: string,
920
+ engineOpts?: {
921
+ nativeDb?: { bulkInsertDataflow?(edges: Array<Record<string, unknown>>): number };
922
+ suspendJsDb?: () => void;
923
+ resumeJsDb?: () => void;
924
+ },
925
+ ): Promise<void> {
926
+ const extToLang = buildExtToLangMap();
927
+
928
+ // ── Native bulk-insert fast path ──────────────────────────────────────
929
+ const nativeDb = engineOpts?.nativeDb;
930
+ if (nativeDb?.bulkInsertDataflow) {
931
+ let needsJsFallback = false;
932
+ const nativeEdges: Array<Record<string, unknown>> = [];
933
+ const stmts = prepareNodeResolvers(db);
934
+
935
+ for (const [relPath, symbols] of fileSymbols) {
936
+ const ext = path.extname(relPath).toLowerCase();
937
+ if (!DATAFLOW_EXTENSIONS.has(ext)) continue;
938
+ if (!symbols.dataflow) {
939
+ needsJsFallback = true;
940
+ break;
941
+ }
942
+
943
+ collectNativeEdges(symbols.dataflow, makeNodeResolver(stmts, relPath), nativeEdges);
944
+ }
945
+
946
+ if (!needsJsFallback) {
947
+ if (nativeEdges.length > 0) {
948
+ let inserted: number;
949
+ try {
950
+ engineOpts?.suspendJsDb?.();
951
+ inserted = nativeDb.bulkInsertDataflow(nativeEdges);
952
+ } finally {
953
+ engineOpts?.resumeJsDb?.();
954
+ }
955
+ info(`Dataflow (native bulk): ${inserted} edges inserted`);
956
+ }
957
+
958
+ // P6: vertex extraction on the native path.
959
+ // Rust DataflowResult already contains parameters/returns — no re-parse needed.
960
+ const vstmts = prepareVertexStmts(db);
961
+ if (vstmts.available) {
962
+ const allCandidates: StitchCandidate[] = [];
963
+ const allCaptures: ReturnCapture[] = [];
964
+
965
+ const txVertex = db.transaction(() => {
966
+ for (const [relPath, symbols] of fileSymbols) {
967
+ if (!symbols.dataflow) continue;
968
+ const ext = path.extname(relPath).toLowerCase();
969
+ if (!DATAFLOW_EXTENSIONS.has(ext)) continue;
970
+ const resolver = makeNodeResolver(stmts, relPath);
971
+ const { candidates, captures } = buildDataflowVerticesAndEdges(
972
+ db,
973
+ vstmts,
974
+ symbols.dataflow,
975
+ resolver,
976
+ );
977
+ allCandidates.push(...candidates);
978
+ allCaptures.push(...captures);
979
+ }
980
+ });
981
+ txVertex();
982
+
983
+ // P4: Incremental re-stitch — unchanged caller files are not in
984
+ // fileSymbols so their arg_in edges to the old param vertices were
985
+ // deleted by the purge and never recreated. Re-collect stitch
986
+ // candidates from those caller files by parsing them from disk.
987
+ //
988
+ // Skip on full builds: fileSymbols covers every file in the DB, so
989
+ // there are no unchanged callers to re-stitch.
990
+ const totalFilesInDb = (
991
+ db.prepare(`SELECT COUNT(DISTINCT file) AS n FROM nodes`).get() as { n: number }
992
+ ).n;
993
+ let p4CallerCount = 0;
994
+ if (fileSymbols.size < totalFilesInDb) {
995
+ const changedRelPaths = new Set<string>(fileSymbols.keys());
996
+ const changedFuncIds = collectFuncIdsForFiles(db, changedRelPaths);
997
+ const extra = await collectCallerStitchCandidates(
998
+ db,
999
+ changedFuncIds,
1000
+ changedRelPaths,
1001
+ rootDir,
1002
+ extToLang,
1003
+ null,
1004
+ null,
1005
+ );
1006
+ allCandidates.push(...extra.candidates);
1007
+ allCaptures.push(...extra.captures);
1008
+ p4CallerCount = extra.candidates.length;
1009
+ }
1010
+
1011
+ const interCount = buildInterproceduralStitch(db, allCandidates, allCaptures);
1012
+ info(
1013
+ `Dataflow (native): ${interCount} inter-procedural edges inserted${p4CallerCount > 0 ? ` (P4: ${p4CallerCount} re-stitch candidate(s) from unchanged callers)` : ''}`,
1014
+ );
1015
+ }
1016
+
1017
+ return;
1018
+ }
1019
+ debug('Dataflow: some files lack pre-computed data — falling back to JS');
1020
+ }
1021
+
1022
+ // ── JS fallback path ─────────────────────────────────────────────────
1023
+ const { parsers, getParserFn } = await initDataflowParsers(fileSymbols);
1024
+
1025
+ const insert = db.prepare(
1026
+ `INSERT INTO dataflow (source_id, target_id, kind, param_index, expression, line, confidence)
1027
+ VALUES (?, ?, ?, ?, ?, ?, ?)`,
1028
+ );
1029
+
1030
+ const stmts = prepareNodeResolvers(db);
1031
+ const vstmts = prepareVertexStmts(db);
1032
+ let totalEdges = 0;
1033
+
1034
+ const allCandidates: StitchCandidate[] = [];
1035
+ const allCaptures: ReturnCapture[] = [];
1036
+
1037
+ const tx = db.transaction(() => {
1038
+ for (const [relPath, symbols] of fileSymbols) {
1039
+ const ext = path.extname(relPath).toLowerCase();
1040
+ if (!DATAFLOW_EXTENSIONS.has(ext)) continue;
1041
+
1042
+ const data = getDataflowForFile(symbols, relPath, rootDir, extToLang, parsers, getParserFn);
1043
+ if (!data) continue;
1044
+
1045
+ const resolver = makeNodeResolver(stmts, relPath);
1046
+ totalEdges += insertDataflowEdges(insert, data, resolver);
1047
+ const { candidates, captures } = buildDataflowVerticesAndEdges(db, vstmts, data, resolver);
1048
+ allCandidates.push(...candidates);
1049
+ allCaptures.push(...captures);
1050
+ }
1051
+ });
1052
+
1053
+ tx();
1054
+
1055
+ // P4: Incremental re-stitch — if only a subset of files changed, callers of
1056
+ // the changed functions were not in fileSymbols, so their arg_in edges were
1057
+ // deleted by the purge but never reconstructed. Re-collect stitch candidates
1058
+ // from those caller files now (read from disk, no DB writes).
1059
+ //
1060
+ // Skip P4 on full builds: when fileSymbols covers every file in the DB there
1061
+ // are no unchanged callers, and collectFuncIdsForFiles would issue one SELECT
1062
+ // per file for nothing. A single COUNT query is cheaper than N per-file SELECTs.
1063
+ const totalFilesInDb = (
1064
+ db.prepare(`SELECT COUNT(DISTINCT file) AS n FROM nodes`).get() as { n: number }
1065
+ ).n;
1066
+ if (vstmts.available && fileSymbols.size < totalFilesInDb) {
1067
+ const changedRelPaths = new Set<string>(fileSymbols.keys());
1068
+ const changedFuncIds = collectFuncIdsForFiles(db, changedRelPaths);
1069
+ const extra = await collectCallerStitchCandidates(
1070
+ db,
1071
+ changedFuncIds,
1072
+ changedRelPaths,
1073
+ rootDir,
1074
+ extToLang,
1075
+ parsers,
1076
+ getParserFn,
1077
+ );
1078
+ allCandidates.push(...extra.candidates);
1079
+ allCaptures.push(...extra.captures);
1080
+ }
1081
+
1082
+ // P2: inter-procedural stitch — runs after all per-file vertices + summaries committed
1083
+ const interCount = vstmts.available
1084
+ ? buildInterproceduralStitch(db, allCandidates, allCaptures)
1085
+ : 0;
1086
+
1087
+ info(`Dataflow: ${totalEdges} fn-level edges, ${interCount} inter-procedural edges inserted`);
1088
+ }
1089
+
1090
+ // ── Query functions ─────────────────────────────────────────────────────────
1091
+
1092
+ // findNodes imported from ./shared/find-nodes.js
1093
+
1094
+ interface DataflowStmts {
1095
+ flowsToOut: ReturnType<BetterSqlite3Database['prepare']>;
1096
+ flowsToIn: ReturnType<BetterSqlite3Database['prepare']>;
1097
+ returnsOut: ReturnType<BetterSqlite3Database['prepare']>;
1098
+ returnsIn: ReturnType<BetterSqlite3Database['prepare']>;
1099
+ mutatesOut: ReturnType<BetterSqlite3Database['prepare']>;
1100
+ mutatesIn: ReturnType<BetterSqlite3Database['prepare']>;
1101
+ }
1102
+
1103
+ function prepareDataflowStmts(db: BetterSqlite3Database): DataflowStmts {
1104
+ return {
1105
+ flowsToOut: db.prepare(
1106
+ `SELECT d.*, n.name AS target_name, n.kind AS target_kind, n.file AS target_file, n.line AS target_line
1107
+ FROM dataflow d JOIN nodes n ON d.target_id = n.id
1108
+ WHERE d.source_id = ? AND d.kind = 'flows_to'`,
1109
+ ),
1110
+ flowsToIn: db.prepare(
1111
+ `SELECT d.*, n.name AS source_name, n.kind AS source_kind, n.file AS source_file, n.line AS source_line
1112
+ FROM dataflow d JOIN nodes n ON d.source_id = n.id
1113
+ WHERE d.target_id = ? AND d.kind = 'flows_to'`,
1114
+ ),
1115
+ returnsOut: db.prepare(
1116
+ `SELECT d.*, n.name AS target_name, n.kind AS target_kind, n.file AS target_file, n.line AS target_line
1117
+ FROM dataflow d JOIN nodes n ON d.target_id = n.id
1118
+ WHERE d.source_id = ? AND d.kind = 'returns'`,
1119
+ ),
1120
+ returnsIn: db.prepare(
1121
+ `SELECT d.*, n.name AS source_name, n.kind AS source_kind, n.file AS source_file, n.line AS source_line
1122
+ FROM dataflow d JOIN nodes n ON d.source_id = n.id
1123
+ WHERE d.target_id = ? AND d.kind = 'returns'`,
1124
+ ),
1125
+ mutatesOut: db.prepare(
1126
+ `SELECT d.*, n.name AS target_name, n.kind AS target_kind, n.file AS target_file, n.line AS target_line
1127
+ FROM dataflow d JOIN nodes n ON d.target_id = n.id
1128
+ WHERE d.source_id = ? AND d.kind = 'mutates'`,
1129
+ ),
1130
+ mutatesIn: db.prepare(
1131
+ `SELECT d.*, n.name AS source_name, n.kind AS source_kind, n.file AS source_file, n.line AS source_line
1132
+ FROM dataflow d JOIN nodes n ON d.source_id = n.id
1133
+ WHERE d.target_id = ? AND d.kind = 'mutates'`,
1134
+ ),
1135
+ };
1136
+ }
1137
+
1138
+ // ─── Shared dataflow result builder ──────────────────────────────────
1139
+
1140
+ /** Pre-mapped raw dataflow edge arrays shared between SQL and native paths. */
1141
+ interface RawDataflowEdges {
1142
+ flowsTo: {
1143
+ target: string;
1144
+ kind: string;
1145
+ file: string;
1146
+ line: number;
1147
+ paramIndex: number;
1148
+ expression: string;
1149
+ confidence: number;
1150
+ }[];
1151
+ flowsFrom: {
1152
+ source: string;
1153
+ kind: string;
1154
+ file: string;
1155
+ line: number;
1156
+ paramIndex: number;
1157
+ expression: string;
1158
+ confidence: number;
1159
+ }[];
1160
+ returnConsumers: {
1161
+ consumer: string;
1162
+ kind: string;
1163
+ file: string;
1164
+ line: number;
1165
+ expression: string;
1166
+ }[];
1167
+ returnedBy: { producer: string; kind: string; file: string; line: number; expression: string }[];
1168
+ mutatesTargets: { target: string; expression: string; line: number }[];
1169
+ mutatedBy: { source: string; expression: string; line: number }[];
1170
+ }
1171
+
1172
+ /**
1173
+ * Build a unified dataflow result from pre-mapped edge data.
1174
+ * Shared between the SQL and native code paths.
1175
+ */
1176
+ function buildDataflowResult(
1177
+ sym: NormalizedSymbol,
1178
+ edges: RawDataflowEdges,
1179
+ noTests: boolean,
1180
+ ): Record<string, unknown> {
1181
+ if (noTests) {
1182
+ const filter = (arr: any[]) => arr.filter((r: any) => !isTestFile(r.file));
1183
+ return {
1184
+ ...sym,
1185
+ flowsTo: filter(edges.flowsTo),
1186
+ flowsFrom: filter(edges.flowsFrom),
1187
+ returns: edges.returnConsumers.filter((r: any) => !isTestFile(r.file)),
1188
+ returnedBy: edges.returnedBy.filter((r: any) => !isTestFile(r.file)),
1189
+ mutates: edges.mutatesTargets,
1190
+ mutatedBy: edges.mutatedBy,
1191
+ };
1192
+ }
1193
+
1194
+ return {
1195
+ ...sym,
1196
+ flowsTo: edges.flowsTo,
1197
+ flowsFrom: edges.flowsFrom,
1198
+ returns: edges.returnConsumers,
1199
+ returnedBy: edges.returnedBy,
1200
+ mutates: edges.mutatesTargets,
1201
+ mutatedBy: edges.mutatedBy,
1202
+ };
1203
+ }
1204
+
1205
+ function buildNodeDataflowResult(
1206
+ node: NodeRow,
1207
+ stmts: DataflowStmts,
1208
+ db: BetterSqlite3Database,
1209
+ hc: Map<string, string | null>,
1210
+ noTests: boolean,
1211
+ ): Record<string, unknown> {
1212
+ const sym = normalizeSymbol(node, db, hc);
1213
+ const edges: RawDataflowEdges = {
1214
+ flowsTo: stmts.flowsToOut.all(node.id).map((r: any) => ({
1215
+ target: r.target_name,
1216
+ kind: r.target_kind,
1217
+ file: r.target_file,
1218
+ line: r.line,
1219
+ paramIndex: r.param_index,
1220
+ expression: r.expression,
1221
+ confidence: r.confidence,
1222
+ })),
1223
+ flowsFrom: stmts.flowsToIn.all(node.id).map((r: any) => ({
1224
+ source: r.source_name,
1225
+ kind: r.source_kind,
1226
+ file: r.source_file,
1227
+ line: r.line,
1228
+ paramIndex: r.param_index,
1229
+ expression: r.expression,
1230
+ confidence: r.confidence,
1231
+ })),
1232
+ returnConsumers: stmts.returnsOut.all(node.id).map((r: any) => ({
1233
+ consumer: r.target_name,
1234
+ kind: r.target_kind,
1235
+ file: r.target_file,
1236
+ line: r.line,
1237
+ expression: r.expression,
1238
+ })),
1239
+ returnedBy: stmts.returnsIn.all(node.id).map((r: any) => ({
1240
+ producer: r.source_name,
1241
+ kind: r.source_kind,
1242
+ file: r.source_file,
1243
+ line: r.line,
1244
+ expression: r.expression,
1245
+ })),
1246
+ mutatesTargets: stmts.mutatesOut.all(node.id).map((r: any) => ({
1247
+ target: r.target_name,
1248
+ expression: r.expression,
1249
+ line: r.line,
1250
+ })),
1251
+ mutatedBy: stmts.mutatesIn.all(node.id).map((r: any) => ({
1252
+ source: r.source_name,
1253
+ expression: r.expression,
1254
+ line: r.line,
1255
+ })),
1256
+ };
1257
+ return buildDataflowResult(sym, edges, noTests);
1258
+ }
1259
+
1260
+ function buildNativeDataflowResult(
1261
+ node: NodeRow,
1262
+ nativeDb: NativeDatabase,
1263
+ db: BetterSqlite3Database,
1264
+ hc: Map<string, string | null>,
1265
+ noTests: boolean,
1266
+ ): Record<string, unknown> {
1267
+ const sym = normalizeSymbol(node, db, hc);
1268
+ const d = nativeDb.getDataflowEdges!(node.id);
1269
+ const edges: RawDataflowEdges = {
1270
+ flowsTo: d.flowsToOut.map((r: any) => ({
1271
+ target: r.name,
1272
+ kind: r.kind,
1273
+ file: r.file,
1274
+ line: r.line,
1275
+ paramIndex: r.paramIndex,
1276
+ expression: r.expression,
1277
+ confidence: r.confidence,
1278
+ })),
1279
+ flowsFrom: d.flowsToIn.map((r: any) => ({
1280
+ source: r.name,
1281
+ kind: r.kind,
1282
+ file: r.file,
1283
+ line: r.line,
1284
+ paramIndex: r.paramIndex,
1285
+ expression: r.expression,
1286
+ confidence: r.confidence,
1287
+ })),
1288
+ returnConsumers: d.returnsOut.map((r: any) => ({
1289
+ consumer: r.name,
1290
+ kind: r.kind,
1291
+ file: r.file,
1292
+ line: r.line,
1293
+ expression: r.expression,
1294
+ })),
1295
+ returnedBy: d.returnsIn.map((r: any) => ({
1296
+ producer: r.name,
1297
+ kind: r.kind,
1298
+ file: r.file,
1299
+ line: r.line,
1300
+ expression: r.expression,
1301
+ })),
1302
+ mutatesTargets: d.mutatesOut.map((r: any) => ({
1303
+ target: r.name,
1304
+ expression: r.expression,
1305
+ line: r.line,
1306
+ })),
1307
+ mutatedBy: d.mutatesIn.map((r: any) => ({
1308
+ source: r.name,
1309
+ expression: r.expression,
1310
+ line: r.line,
1311
+ })),
1312
+ };
1313
+ return buildDataflowResult(sym, edges, noTests);
1314
+ }
1315
+
1316
+ export function dataflowData(
1317
+ name: string,
1318
+ customDbPath?: string,
1319
+ opts: { noTests?: boolean; file?: string; kind?: string; limit?: number; offset?: number } = {},
1320
+ ): Record<string, unknown> {
1321
+ const { db, nativeDb, close } = openReadonlyWithNative(customDbPath);
1322
+ try {
1323
+ const noTests = opts.noTests || false;
1324
+
1325
+ if (!hasDataflowTable(db)) {
1326
+ return {
1327
+ name,
1328
+ results: [],
1329
+ warning:
1330
+ 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).',
1331
+ };
1332
+ }
1333
+
1334
+ const nodes = findNodes(
1335
+ db,
1336
+ name,
1337
+ { noTests, file: opts.file, kind: opts.kind },
1338
+ ALL_SYMBOL_KINDS as unknown as string[],
1339
+ );
1340
+ if (nodes.length === 0) {
1341
+ return { name, results: [] };
1342
+ }
1343
+
1344
+ // ── Native fast path: 6 queries per node → 1 napi call per node ──
1345
+ if (nativeDb?.getDataflowEdges) {
1346
+ const hc = new Map<string, string | null>();
1347
+ const results = nodes.map((node: NodeRow) =>
1348
+ buildNativeDataflowResult(node, nativeDb, db, hc, noTests),
1349
+ );
1350
+ const base = { name, results };
1351
+ return paginateResult(base, 'results', { limit: opts.limit, offset: opts.offset });
1352
+ }
1353
+
1354
+ // ── JS fallback ───────────────────────────────────────────────────
1355
+ const stmts = prepareDataflowStmts(db);
1356
+ const hc = new Map<string, string | null>();
1357
+ const results = nodes.map((node: NodeRow) =>
1358
+ buildNodeDataflowResult(node, stmts, db, hc, noTests),
1359
+ );
1360
+
1361
+ const base = { name, results };
1362
+ return paginateResult(base, 'results', { limit: opts.limit, offset: opts.offset });
1363
+ } finally {
1364
+ close();
1365
+ }
1366
+ }
1367
+
1368
+ interface BfsParentEntry {
1369
+ parentId: number;
1370
+ edgeKind: string;
1371
+ expression: string;
1372
+ }
1373
+
1374
+ type DataflowNeighbor = {
1375
+ id: number;
1376
+ file: string;
1377
+ edge_kind: string;
1378
+ expression: string;
1379
+ };
1380
+
1381
+ interface DataflowBfsState {
1382
+ visited: Set<number>;
1383
+ parent: Map<number, BfsParentEntry>;
1384
+ nextQueue: number[];
1385
+ found: boolean;
1386
+ }
1387
+
1388
+ /**
1389
+ * Process a single neighbor in the dataflow BFS. Returns true once the target
1390
+ * has been reached so the caller can stop expanding.
1391
+ */
1392
+ function processDataflowNeighbor(
1393
+ n: DataflowNeighbor,
1394
+ currentId: number,
1395
+ targetId: number,
1396
+ noTests: boolean,
1397
+ state: DataflowBfsState,
1398
+ ): boolean {
1399
+ if (noTests && isTestFile(n.file)) return false;
1400
+ const entry: BfsParentEntry = {
1401
+ parentId: currentId,
1402
+ edgeKind: n.edge_kind,
1403
+ expression: n.expression,
1404
+ };
1405
+ if (n.id === targetId) {
1406
+ if (!state.found) {
1407
+ state.found = true;
1408
+ state.parent.set(n.id, entry);
1409
+ }
1410
+ return true;
1411
+ }
1412
+ if (state.visited.has(n.id)) return false;
1413
+ state.visited.add(n.id);
1414
+ state.parent.set(n.id, entry);
1415
+ state.nextQueue.push(n.id);
1416
+ return false;
1417
+ }
1418
+
1419
+ /** BFS through dataflow edges to find a path from source to target. */
1420
+ function bfsDataflowPath(
1421
+ db: BetterSqlite3Database,
1422
+ sourceId: number,
1423
+ targetId: number,
1424
+ maxDepth: number,
1425
+ noTests: boolean,
1426
+ ): Map<number, BfsParentEntry> | null {
1427
+ const neighborStmt = db.prepare(
1428
+ `SELECT n.id, n.name, n.kind, n.file, n.line, d.kind AS edge_kind, d.expression
1429
+ FROM dataflow d JOIN nodes n ON d.target_id = n.id
1430
+ WHERE d.source_id = ? AND d.kind IN ('flows_to', 'returns')`,
1431
+ );
1432
+
1433
+ const state: DataflowBfsState = {
1434
+ visited: new Set<number>([sourceId]),
1435
+ parent: new Map<number, BfsParentEntry>(),
1436
+ nextQueue: [],
1437
+ found: false,
1438
+ };
1439
+ let queue = [sourceId];
1440
+
1441
+ for (let depth = 1; depth <= maxDepth; depth++) {
1442
+ state.nextQueue = [];
1443
+ for (const currentId of queue) {
1444
+ const neighbors = neighborStmt.all(currentId) as DataflowNeighbor[];
1445
+ for (const n of neighbors) {
1446
+ processDataflowNeighbor(n, currentId, targetId, noTests, state);
1447
+ }
1448
+ }
1449
+ if (state.found) break;
1450
+ queue = state.nextQueue;
1451
+ if (queue.length === 0) break;
1452
+ }
1453
+
1454
+ return state.found ? state.parent : null;
1455
+ }
1456
+
1457
+ /** Reconstruct a path from BFS parent map. */
1458
+ function reconstructDataflowPath(
1459
+ db: BetterSqlite3Database,
1460
+ parent: Map<number, BfsParentEntry>,
1461
+ sourceId: number,
1462
+ targetId: number,
1463
+ ): Array<Record<string, unknown>> {
1464
+ const nodeById = db.prepare('SELECT * FROM nodes WHERE id = ?');
1465
+ const hc = new Map<string, string | null>();
1466
+ const pathItems: Array<Record<string, unknown>> = [];
1467
+ let cur: number | undefined = targetId;
1468
+ while (cur !== undefined) {
1469
+ const nodeRow = nodeById.get(cur) as NodeRow;
1470
+ const parentInfo = parent.get(cur);
1471
+ pathItems.unshift({
1472
+ ...normalizeSymbol(nodeRow, db, hc),
1473
+ edgeKind: parentInfo?.edgeKind ?? null,
1474
+ expression: parentInfo?.expression ?? null,
1475
+ });
1476
+ cur = parentInfo?.parentId;
1477
+ if (cur === sourceId) {
1478
+ const srcRow = nodeById.get(cur) as NodeRow;
1479
+ pathItems.unshift({
1480
+ ...normalizeSymbol(srcRow, db, hc),
1481
+ edgeKind: null,
1482
+ expression: null,
1483
+ });
1484
+ break;
1485
+ }
1486
+ }
1487
+ return pathItems;
1488
+ }
1489
+
1490
+ export function dataflowPathData(
1491
+ from: string,
1492
+ to: string,
1493
+ customDbPath?: string,
1494
+ opts: {
1495
+ noTests?: boolean;
1496
+ maxDepth?: number;
1497
+ fromFile?: string;
1498
+ toFile?: string;
1499
+ kind?: string;
1500
+ limit?: number;
1501
+ offset?: number;
1502
+ } = {},
1503
+ ): Record<string, unknown> {
1504
+ const db = openReadonlyOrFail(customDbPath);
1505
+ try {
1506
+ const noTests = opts.noTests || false;
1507
+ const maxDepth = opts.maxDepth || 10;
1508
+
1509
+ if (!hasDataflowTable(db)) {
1510
+ return {
1511
+ from,
1512
+ to,
1513
+ found: false,
1514
+ warning:
1515
+ 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).',
1516
+ };
1517
+ }
1518
+
1519
+ const fromNodes = findNodes(
1520
+ db,
1521
+ from,
1522
+ { noTests, file: opts.fromFile, kind: opts.kind },
1523
+ ALL_SYMBOL_KINDS as unknown as string[],
1524
+ );
1525
+ if (fromNodes.length === 0) {
1526
+ return { from, to, found: false, error: `No symbol matching "${from}"` };
1527
+ }
1528
+
1529
+ const toNodes = findNodes(
1530
+ db,
1531
+ to,
1532
+ { noTests, file: opts.toFile, kind: opts.kind },
1533
+ ALL_SYMBOL_KINDS as unknown as string[],
1534
+ );
1535
+ if (toNodes.length === 0) {
1536
+ return { from, to, found: false, error: `No symbol matching "${to}"` };
1537
+ }
1538
+
1539
+ const sourceNode = fromNodes[0] as NodeRow;
1540
+ const targetNode = toNodes[0] as NodeRow;
1541
+
1542
+ if (sourceNode.id === targetNode.id) {
1543
+ const hc = new Map<string, string | null>();
1544
+ const sym = normalizeSymbol(sourceNode, db, hc);
1545
+ return { from, to, found: true, hops: 0, path: [{ ...sym, edgeKind: null }] };
1546
+ }
1547
+
1548
+ const parent = bfsDataflowPath(db, sourceNode.id, targetNode.id, maxDepth, noTests);
1549
+ if (!parent) {
1550
+ return { from, to, found: false };
1551
+ }
1552
+
1553
+ const pathItems = reconstructDataflowPath(db, parent, sourceNode.id, targetNode.id);
1554
+ return { from, to, found: true, hops: pathItems.length - 1, path: pathItems };
1555
+ } finally {
1556
+ db.close();
1557
+ }
1558
+ }
1559
+
1560
+ /** BFS forward through return-value consumers to build impact levels. */
1561
+ function bfsReturnConsumers(
1562
+ node: NodeRow,
1563
+ consumersStmt: ReturnType<BetterSqlite3Database['prepare']>,
1564
+ db: BetterSqlite3Database,
1565
+ hc: Map<string, string | null>,
1566
+ maxDepth: number,
1567
+ noTests: boolean,
1568
+ ): { levels: Record<number, unknown[]>; totalAffected: number } {
1569
+ const visited = new Set<number>([node.id]);
1570
+ const levels: Record<number, unknown[]> = {};
1571
+ let frontier = [node.id];
1572
+
1573
+ for (let d = 1; d <= maxDepth; d++) {
1574
+ const nextFrontier: number[] = [];
1575
+ for (const fid of frontier) {
1576
+ const consumers = consumersStmt.all(fid) as NodeRow[];
1577
+ for (const c of consumers) {
1578
+ if (!visited.has(c.id) && (!noTests || !isTestFile(c.file))) {
1579
+ visited.add(c.id);
1580
+ nextFrontier.push(c.id);
1581
+ if (!levels[d]) levels[d] = [];
1582
+ levels[d]!.push(normalizeSymbol(c, db, hc));
1583
+ }
1584
+ }
1585
+ }
1586
+ frontier = nextFrontier;
1587
+ if (frontier.length === 0) break;
1588
+ }
1589
+
1590
+ return { levels, totalAffected: visited.size - 1 };
1591
+ }
1592
+
1593
+ export function dataflowImpactData(
1594
+ name: string,
1595
+ customDbPath?: string,
1596
+ opts: {
1597
+ noTests?: boolean;
1598
+ depth?: number;
1599
+ file?: string;
1600
+ kind?: string;
1601
+ limit?: number;
1602
+ offset?: number;
1603
+ } = {},
1604
+ ): Record<string, unknown> {
1605
+ const db = openReadonlyOrFail(customDbPath);
1606
+ try {
1607
+ const maxDepth = opts.depth || 5;
1608
+ const noTests = opts.noTests || false;
1609
+
1610
+ if (!hasDataflowTable(db)) {
1611
+ return {
1612
+ name,
1613
+ results: [],
1614
+ warning:
1615
+ 'No dataflow data found. Rebuild with `codegraph build` (dataflow is now included by default).',
1616
+ };
1617
+ }
1618
+
1619
+ const nodes = findNodes(
1620
+ db,
1621
+ name,
1622
+ { noTests, file: opts.file, kind: opts.kind },
1623
+ ALL_SYMBOL_KINDS as unknown as string[],
1624
+ );
1625
+ if (nodes.length === 0) {
1626
+ return { name, results: [] };
1627
+ }
1628
+
1629
+ const consumersStmt = db.prepare(
1630
+ `SELECT DISTINCT n.*
1631
+ FROM dataflow d JOIN nodes n ON d.target_id = n.id
1632
+ WHERE d.source_id = ? AND d.kind = 'returns'`,
1633
+ );
1634
+
1635
+ const hc = new Map<string, string | null>();
1636
+ const results = nodes.map((node: NodeRow) => {
1637
+ const sym = normalizeSymbol(node, db, hc);
1638
+ const { levels, totalAffected } = bfsReturnConsumers(
1639
+ node,
1640
+ consumersStmt,
1641
+ db,
1642
+ hc,
1643
+ maxDepth,
1644
+ noTests,
1645
+ );
1646
+ return { ...sym, levels, totalAffected };
1647
+ });
1648
+
1649
+ const base = { name, results };
1650
+ return paginateResult(base, 'results', { limit: opts.limit, offset: opts.offset });
1651
+ } finally {
1652
+ db.close();
1653
+ }
1654
+ }