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,1425 @@
1
+ /**
2
+ * Stage: buildEdges
3
+ *
4
+ * Builds import, call, receiver, extends, and implements edges.
5
+ * Uses pre-loaded node lookup maps (N+1 optimization).
6
+ */
7
+ import path from 'node:path';
8
+ import { performance } from 'node:perf_hooks';
9
+ import { getNodeId } from '../../../../db/index.js';
10
+ import { setTypeMapEntry } from '../../../../extractors/helpers.js';
11
+ import { PROPAGATION_HOP_PENALTY } from '../../../../extractors/javascript.js';
12
+ import { debug } from '../../../../infrastructure/logger.js';
13
+ import { loadNative } from '../../../../infrastructure/native.js';
14
+ import { TS_NATIVE_CONFIDENCE_FLOOR } from '../../../../shared/constants.js';
15
+ import { computeConfidence } from '../../resolve.js';
16
+ import { buildPointsToMap, resolveViaPointsTo } from '../../resolver/points-to.js';
17
+ import { enrichTypeMapWithTsc } from '../../resolver/ts-resolver.js';
18
+ import { findCaller, isModuleScopedLanguage, resolveCallTargets, resolveReceiverEdge, } from '../call-resolver.js';
19
+ import { buildChaContext, resolveChaTargets, resolveThisDispatch } from '../cha.js';
20
+ import { BUILTIN_RECEIVERS, batchInsertEdges, CHA_DISPATCH_PENALTY, CHA_TYPED_DISPATCH_CONFIDENCE, runChaPostPass, } from '../helpers.js';
21
+ import { getResolved, isBarrelFile, resolveBarrelExportCached } from './resolve-imports.js';
22
+ // ── Node lookup setup ───────────────────────────────────────────────────
23
+ function makeGetNodeIdStmt(db) {
24
+ return {
25
+ get: (name, kind, file, line) => {
26
+ const id = getNodeId(db, name, kind, file, line);
27
+ return id != null ? { id } : undefined;
28
+ },
29
+ };
30
+ }
31
+ function setupNodeLookups(ctx, allNodes) {
32
+ ctx.nodesByName = new Map();
33
+ for (const node of allNodes) {
34
+ if (!ctx.nodesByName.has(node.name))
35
+ ctx.nodesByName.set(node.name, []);
36
+ ctx.nodesByName.get(node.name).push(node);
37
+ }
38
+ ctx.nodesByNameAndFile = new Map();
39
+ for (const node of allNodes) {
40
+ const key = `${node.name}|${node.file}`;
41
+ if (!ctx.nodesByNameAndFile.has(key))
42
+ ctx.nodesByNameAndFile.set(key, []);
43
+ ctx.nodesByNameAndFile.get(key).push(node);
44
+ }
45
+ }
46
+ // ── Import edges ────────────────────────────────────────────────────────
47
+ /** Pick the edge kind for an import statement based on its modifiers. */
48
+ function importEdgeKind(imp) {
49
+ if (imp.reexport)
50
+ return 'reexports';
51
+ if (imp.typeOnly)
52
+ return 'imports-type';
53
+ if (imp.dynamicImport)
54
+ return 'dynamic-imports';
55
+ return 'imports';
56
+ }
57
+ /**
58
+ * For a `import type` statement, emit symbol-level `imports-type` edges so
59
+ * the target symbols get fan-in credit and aren't classified as dead code.
60
+ */
61
+ function emitTypeOnlySymbolEdges(ctx, imp, resolvedPath, fileNodeId, allEdgeRows) {
62
+ if (!ctx.nodesByNameAndFile)
63
+ return;
64
+ for (const name of imp.names) {
65
+ const cleanName = name.replace(/^\*\s+as\s+/, '');
66
+ let targetFile = resolvedPath;
67
+ if (isBarrelFile(ctx, resolvedPath)) {
68
+ const actual = resolveBarrelExportCached(ctx, resolvedPath, cleanName);
69
+ if (actual)
70
+ targetFile = actual;
71
+ }
72
+ const candidates = ctx.nodesByNameAndFile.get(`${cleanName}|${targetFile}`);
73
+ if (candidates && candidates.length > 0) {
74
+ allEdgeRows.push([fileNodeId, candidates[0].id, 'imports-type', 1.0, 0, null, null]);
75
+ }
76
+ }
77
+ }
78
+ /**
79
+ * Process a single import statement and emit all resulting edges (file→file,
80
+ * type-only symbol-level, and barrel re-export targets).
81
+ */
82
+ function emitEdgesForImport(ctx, imp, fileNodeId, relPath, getNodeIdStmt, allEdgeRows) {
83
+ const resolvedPath = getResolved(ctx, path.join(ctx.rootDir, relPath), imp.source);
84
+ const targetRow = getNodeIdStmt.get(resolvedPath, 'file', resolvedPath, 0);
85
+ if (!targetRow)
86
+ return;
87
+ const edgeKind = importEdgeKind(imp);
88
+ allEdgeRows.push([fileNodeId, targetRow.id, edgeKind, 1.0, 0, null, null]);
89
+ if (imp.typeOnly) {
90
+ emitTypeOnlySymbolEdges(ctx, imp, resolvedPath, fileNodeId, allEdgeRows);
91
+ }
92
+ if (!imp.reexport && isBarrelFile(ctx, resolvedPath)) {
93
+ buildBarrelEdges(ctx, imp, resolvedPath, fileNodeId, edgeKind, getNodeIdStmt, allEdgeRows);
94
+ }
95
+ }
96
+ function buildImportEdges(ctx, getNodeIdStmt, allEdgeRows) {
97
+ const { fileSymbols, barrelOnlyFiles } = ctx;
98
+ for (const [relPath, symbols] of fileSymbols) {
99
+ const isBarrelOnly = barrelOnlyFiles.has(relPath);
100
+ const fileNodeRow = getNodeIdStmt.get(relPath, 'file', relPath, 0);
101
+ if (!fileNodeRow)
102
+ continue;
103
+ const fileNodeId = fileNodeRow.id;
104
+ for (const imp of symbols.imports) {
105
+ // Barrel-only files: only emit reexport edges, skip regular imports
106
+ if (isBarrelOnly && !imp.reexport)
107
+ continue;
108
+ emitEdgesForImport(ctx, imp, fileNodeId, relPath, getNodeIdStmt, allEdgeRows);
109
+ }
110
+ }
111
+ }
112
+ function buildBarrelEdges(ctx, imp, resolvedPath, fileNodeId, edgeKind, getNodeIdStmt, edgeRows) {
113
+ const resolvedSources = new Set();
114
+ for (const name of imp.names) {
115
+ const cleanName = name.replace(/^\*\s+as\s+/, '');
116
+ const actualSource = resolveBarrelExportCached(ctx, resolvedPath, cleanName);
117
+ if (actualSource && actualSource !== resolvedPath && !resolvedSources.has(actualSource)) {
118
+ resolvedSources.add(actualSource);
119
+ const actualRow = getNodeIdStmt.get(actualSource, 'file', actualSource, 0);
120
+ if (actualRow) {
121
+ const kind = edgeKind === 'imports-type'
122
+ ? 'imports-type'
123
+ : edgeKind === 'dynamic-imports'
124
+ ? 'dynamic-imports'
125
+ : 'imports';
126
+ edgeRows.push([fileNodeId, actualRow.id, kind, 0.9, 0, null, null]);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ function createFileNodeIdRegistry(getNodeIdStmt) {
132
+ const ids = [];
133
+ const seen = new Set();
134
+ const cache = new Map();
135
+ return {
136
+ ids,
137
+ add(relPath) {
138
+ if (seen.has(relPath))
139
+ return cache.get(relPath);
140
+ const row = getNodeIdStmt.get(relPath, 'file', relPath, 0);
141
+ if (row) {
142
+ seen.add(relPath);
143
+ ids.push({ file: relPath, nodeId: row.id });
144
+ cache.set(relPath, row);
145
+ }
146
+ return row;
147
+ },
148
+ };
149
+ }
150
+ function toNativeImportInfo(imp) {
151
+ return {
152
+ source: imp.source,
153
+ names: imp.names,
154
+ reexport: !!imp.reexport,
155
+ typeOnly: !!imp.typeOnly,
156
+ dynamicImport: !!imp.dynamicImport,
157
+ wildcardReexport: !!imp.wildcardReexport,
158
+ };
159
+ }
160
+ /**
161
+ * Pre-resolve every import for the given files, registering each resolved
162
+ * target with the registry so the native side has full node-id coverage.
163
+ *
164
+ * Resolved-import keys use forward-slash-normalized rootDir + "/" + relPath to
165
+ * match the Rust lookup format. On Windows, rootDir has backslashes but Rust
166
+ * normalizes them — the JS side must do the same or every key lookup misses
167
+ * (#750).
168
+ */
169
+ function buildNativeFileInputs(ctx, registry) {
170
+ const { fileSymbols, barrelOnlyFiles, rootDir } = ctx;
171
+ const fwdRootDir = rootDir.replace(/\\/g, '/');
172
+ const files = [];
173
+ const resolvedImports = [];
174
+ for (const [relPath, symbols] of fileSymbols) {
175
+ const fileNodeRow = registry.add(relPath);
176
+ if (!fileNodeRow)
177
+ continue;
178
+ const importInfos = [];
179
+ for (const imp of symbols.imports) {
180
+ const resolvedPath = getResolved(ctx, path.join(rootDir, relPath), imp.source);
181
+ registry.add(resolvedPath);
182
+ resolvedImports.push({ key: `${fwdRootDir}/${relPath}|${imp.source}`, resolvedPath });
183
+ importInfos.push(toNativeImportInfo(imp));
184
+ }
185
+ files.push({
186
+ file: relPath,
187
+ fileNodeId: fileNodeRow.id,
188
+ isBarrelOnly: barrelOnlyFiles.has(relPath),
189
+ imports: importInfos,
190
+ definitionNames: symbols.definitions.map((d) => d.name),
191
+ });
192
+ }
193
+ return { files, resolvedImports };
194
+ }
195
+ /** Flatten `ctx.reexportMap` into the array shape the native side expects. */
196
+ function buildNativeReexports(ctx, registry) {
197
+ const fileReexports = [];
198
+ if (!ctx.reexportMap)
199
+ return fileReexports;
200
+ for (const [file, entries] of ctx.reexportMap) {
201
+ const reexports = entries.map((re) => ({
202
+ source: re.source,
203
+ names: re.names,
204
+ wildcardReexport: !!re.wildcardReexport,
205
+ }));
206
+ fileReexports.push({ file, reexports });
207
+ for (const re of reexports) {
208
+ registry.add(re.source);
209
+ }
210
+ }
211
+ return fileReexports;
212
+ }
213
+ function collectBarrelFiles(ctx) {
214
+ const barrelFiles = [];
215
+ for (const [relPath] of ctx.fileSymbols) {
216
+ if (isBarrelFile(ctx, relPath))
217
+ barrelFiles.push(relPath);
218
+ }
219
+ return barrelFiles;
220
+ }
221
+ function collectSymbolNodes(ctx) {
222
+ const symbolNodes = [];
223
+ if (!ctx.nodesByNameAndFile)
224
+ return symbolNodes;
225
+ for (const [key, nodes] of ctx.nodesByNameAndFile) {
226
+ if (nodes.length === 0)
227
+ continue;
228
+ const [name, file] = key.split('|');
229
+ symbolNodes.push({ name: name, file: file, nodeId: nodes[0].id });
230
+ }
231
+ return symbolNodes;
232
+ }
233
+ function buildImportEdgesNative(ctx, getNodeIdStmt, allEdgeRows, native) {
234
+ const registry = createFileNodeIdRegistry(getNodeIdStmt);
235
+ const { files, resolvedImports } = buildNativeFileInputs(ctx, registry);
236
+ const fileReexports = buildNativeReexports(ctx, registry);
237
+ const barrelFiles = collectBarrelFiles(ctx);
238
+ const symbolNodes = collectSymbolNodes(ctx);
239
+ const nativeEdges = native.buildImportEdges(files, resolvedImports, fileReexports, registry.ids, barrelFiles, ctx.rootDir, symbolNodes);
240
+ for (const e of nativeEdges) {
241
+ allEdgeRows.push([e.sourceId, e.targetId, e.kind, e.confidence, e.dynamic, null, null]);
242
+ }
243
+ }
244
+ // ── Phase 8.2: Cross-file return-type propagation ───────────────────────
245
+ /**
246
+ * Augment each file's typeMap with return types from imported functions.
247
+ *
248
+ * The per-file extractor already resolves same-file call assignments (intra-file
249
+ * propagation). This function handles the cross-file case: when a file imports a
250
+ * function from another file and assigns its return value to a variable, we look up
251
+ * the callee's return type in the source file's returnTypeMap and inject it.
252
+ *
253
+ * Called once before call-edge building so both the native and JS paths benefit.
254
+ */
255
+ function propagateReturnTypesAcrossFiles(fileSymbols, ctx, rootDir) {
256
+ // Index: filePath → per-file return-type map
257
+ const returnTypeIndex = new Map();
258
+ for (const [relPath, symbols] of fileSymbols) {
259
+ if (symbols.returnTypeMap?.size)
260
+ returnTypeIndex.set(relPath, symbols.returnTypeMap);
261
+ }
262
+ if (returnTypeIndex.size === 0)
263
+ return;
264
+ // Flat global map for qualified method lookups (TypeName.methodName → entry).
265
+ // Conflicts resolved by keeping the highest-confidence entry.
266
+ const globalReturnTypeMap = new Map();
267
+ for (const rtm of returnTypeIndex.values()) {
268
+ for (const [name, entry] of rtm) {
269
+ const existing = globalReturnTypeMap.get(name);
270
+ if (!existing || entry.confidence > existing.confidence)
271
+ globalReturnTypeMap.set(name, entry);
272
+ }
273
+ }
274
+ for (const [relPath, symbols] of fileSymbols) {
275
+ if (!symbols.callAssignments?.length)
276
+ continue;
277
+ // Phase 8.4 side-effect: buildImportedNamesMap now traces through barrel
278
+ // files (traceBarrel), so `importedFrom` resolves to the leaf definition
279
+ // file rather than the barrel. This means returnTypeIndex.get(importedFrom)
280
+ // now finds entries it previously missed, improving cross-file return-type
281
+ // propagation through re-export chains (Phase 8.2 improvement).
282
+ const importedNamesMap = buildImportedNamesMap(ctx, relPath, symbols, rootDir);
283
+ for (const ca of symbols.callAssignments) {
284
+ if (symbols.typeMap.has(ca.varName))
285
+ continue; // already resolved locally
286
+ let returnEntry;
287
+ if (ca.receiverTypeName) {
288
+ returnEntry = globalReturnTypeMap.get(`${ca.receiverTypeName}.${ca.calleeName}`);
289
+ }
290
+ else {
291
+ const importedFrom = importedNamesMap.get(ca.calleeName);
292
+ if (importedFrom)
293
+ returnEntry = returnTypeIndex.get(importedFrom)?.get(ca.calleeName);
294
+ }
295
+ if (returnEntry) {
296
+ const propagatedConf = returnEntry.confidence - PROPAGATION_HOP_PENALTY;
297
+ if (propagatedConf > 0)
298
+ setTypeMapEntry(symbols.typeMap, ca.varName, returnEntry.type, propagatedConf);
299
+ }
300
+ }
301
+ }
302
+ }
303
+ // ── Call edges (native engine) ──────────────────────────────────────────
304
+ function buildCallEdgesNative(ctx, getNodeIdStmt, allEdgeRows, allNodes, native) {
305
+ const { fileSymbols, barrelOnlyFiles, rootDir } = ctx;
306
+ const nativeFiles = [];
307
+ for (const [relPath, symbols] of fileSymbols) {
308
+ if (barrelOnlyFiles.has(relPath))
309
+ continue;
310
+ const fileNodeRow = getNodeIdStmt.get(relPath, 'file', relPath, 0);
311
+ if (!fileNodeRow)
312
+ continue;
313
+ const importedNames = buildImportedNamesForNative(ctx, relPath, symbols, rootDir);
314
+ const typeMapRaw = symbols.typeMap instanceof Map
315
+ ? [...symbols.typeMap.entries()].map(([name, entry]) => ({
316
+ name,
317
+ typeName: typeof entry === 'string' ? entry : entry.type,
318
+ confidence: typeof entry === 'object' ? entry.confidence : 0.9,
319
+ }))
320
+ : Array.isArray(symbols.typeMap)
321
+ ? symbols.typeMap
322
+ : [];
323
+ // Deduplicate: keep highest-confidence entry per name (first-wins on tie),
324
+ // matching JS setTypeMapEntry semantics. The Map branch is already
325
+ // deduped by setTypeMapEntry — this loop is only needed for the Array
326
+ // branch (pre-rebuilt native addon) but runs unconditionally as
327
+ // belt-and-suspenders since it's a cheap O(n) pass.
328
+ const typeMapDedup = new Map();
329
+ for (const entry of typeMapRaw) {
330
+ const existing = typeMapDedup.get(entry.name);
331
+ if (!existing || entry.confidence > existing.confidence) {
332
+ typeMapDedup.set(entry.name, entry);
333
+ }
334
+ }
335
+ const typeMap = [...typeMapDedup.values()];
336
+ nativeFiles.push({
337
+ file: relPath,
338
+ fileNodeId: fileNodeRow.id,
339
+ definitions: symbols.definitions.map((d) => {
340
+ const params = d.children?.filter((c) => c.kind === 'parameter').map((c) => c.name);
341
+ return {
342
+ name: d.name,
343
+ kind: d.kind,
344
+ line: d.line,
345
+ endLine: d.endLine ?? null,
346
+ params: params?.length ? params : undefined,
347
+ };
348
+ }),
349
+ calls: symbols.calls,
350
+ importedNames,
351
+ classes: symbols.classes,
352
+ typeMap,
353
+ fnRefBindings: symbols.fnRefBindings?.length ? symbols.fnRefBindings : undefined,
354
+ paramBindings: symbols.paramBindings?.length ? symbols.paramBindings : undefined,
355
+ thisCallBindings: symbols.thisCallBindings?.length ? symbols.thisCallBindings : undefined,
356
+ arrayElemBindings: symbols.arrayElemBindings?.length ? symbols.arrayElemBindings : undefined,
357
+ spreadArgBindings: symbols.spreadArgBindings?.length ? symbols.spreadArgBindings : undefined,
358
+ forOfBindings: symbols.forOfBindings?.length ? symbols.forOfBindings : undefined,
359
+ arrayCallbackBindings: symbols.arrayCallbackBindings?.length
360
+ ? symbols.arrayCallbackBindings
361
+ : undefined,
362
+ objectRestParamBindings: symbols.objectRestParamBindings?.length
363
+ ? symbols.objectRestParamBindings
364
+ : undefined,
365
+ objectPropBindings: symbols.objectPropBindings?.length
366
+ ? symbols.objectPropBindings
367
+ : undefined,
368
+ });
369
+ }
370
+ const nativeEdges = native.buildCallEdges(nativeFiles, allNodes, [
371
+ ...BUILTIN_RECEIVERS,
372
+ ]);
373
+ for (const e of nativeEdges) {
374
+ allEdgeRows.push([
375
+ e.sourceId,
376
+ e.targetId,
377
+ e.kind,
378
+ e.confidence,
379
+ e.dynamic,
380
+ e.kind === 'calls' ? 'ts-native' : null,
381
+ e.dynamic_kind ?? null,
382
+ ]);
383
+ }
384
+ }
385
+ /**
386
+ * Object.defineProperty accessor post-pass for the native call-edge path.
387
+ *
388
+ * When a function is registered as a getter/setter via
389
+ * `Object.defineProperty(obj, "bar", { get: getter })`, calls to `this.X()`
390
+ * inside `getter` need to resolve against `obj` (because `this === obj` when
391
+ * the accessor is invoked). The native Rust engine has no knowledge of
392
+ * `definePropertyReceivers`, so this JS post-pass adds the missing edges.
393
+ */
394
+ function buildDefinePropertyPostPass(ctx, getNodeIdStmt, allEdgeRows, sharedLookup) {
395
+ const filesWithReceivers = [...ctx.fileSymbols].filter(([, symbols]) => symbols.definePropertyReceivers && symbols.definePropertyReceivers.size > 0);
396
+ if (filesWithReceivers.length === 0)
397
+ return;
398
+ const seenByPair = new Set();
399
+ for (const [srcId, tgtId] of allEdgeRows) {
400
+ seenByPair.add(`${srcId}|${tgtId}`);
401
+ }
402
+ const { barrelOnlyFiles, rootDir } = ctx;
403
+ const lookup = sharedLookup ?? makeContextLookup(ctx, getNodeIdStmt);
404
+ for (const [relPath, symbols] of filesWithReceivers) {
405
+ if (barrelOnlyFiles.has(relPath))
406
+ continue;
407
+ const fileNodeRow = getNodeIdStmt.get(relPath, 'file', relPath, 0);
408
+ if (!fileNodeRow)
409
+ continue;
410
+ const importedNames = buildImportedNamesMap(ctx, relPath, symbols, rootDir);
411
+ const typeMap = symbols.typeMap || new Map();
412
+ const definePropertyReceivers = symbols.definePropertyReceivers;
413
+ for (const call of symbols.calls) {
414
+ if (call.receiver !== 'this')
415
+ continue;
416
+ const caller = findCaller(lookup, call, symbols.definitions, relPath, fileNodeRow);
417
+ if (!caller.callerName)
418
+ continue;
419
+ const receiverVarName = definePropertyReceivers.get(caller.callerName);
420
+ if (!receiverVarName)
421
+ continue;
422
+ // Only add edges the native engine missed (no direct target already).
423
+ const { targets: directTargets } = resolveCallTargets(lookup, call, relPath, importedNames, typeMap, caller.callerName);
424
+ if (directTargets.length > 0)
425
+ continue;
426
+ // Resolve via receiver type
427
+ let targets = [];
428
+ const typeEntry = typeMap.get(receiverVarName);
429
+ const typeName = typeEntry
430
+ ? typeof typeEntry === 'string'
431
+ ? typeEntry
432
+ : typeEntry.type
433
+ : null;
434
+ if (typeName) {
435
+ const qualifiedName = `${typeName}.${call.name}`;
436
+ targets = lookup.byNameAndFile(qualifiedName, relPath);
437
+ }
438
+ // Same-file fallback for plain object-literal methods
439
+ if (targets.length === 0) {
440
+ targets = lookup.byNameAndFile(call.name, relPath);
441
+ }
442
+ for (const t of targets) {
443
+ const edgeKey = `${caller.id}|${t.id}`;
444
+ if (t.id !== caller.id && !seenByPair.has(edgeKey)) {
445
+ const conf = computeConfidence(relPath, t.file, null);
446
+ if (conf > 0) {
447
+ seenByPair.add(edgeKey);
448
+ allEdgeRows.push([caller.id, t.id, 'calls', conf, 0, 'ts-native', null]);
449
+ }
450
+ }
451
+ }
452
+ }
453
+ }
454
+ }
455
+ /**
456
+ * Phase 8.5: CHA + RTA post-pass for the native call-edge path.
457
+ *
458
+ * The native Rust engine has no knowledge of the CHA context, so `this.method()`
459
+ * calls and interface method dispatches are not expanded to their concrete
460
+ * implementations. This JS post-pass runs after the native edges and adds only
461
+ * the CHA-resolved edges that the native engine missed.
462
+ *
463
+ * Seeds seenByPair from the current allEdgeRows snapshot to avoid duplicating
464
+ * edges the native engine already produced.
465
+ */
466
+ function buildChaPostPass(ctx, getNodeIdStmt, allEdgeRows, chaCtx) {
467
+ // Fast-exit when the CHA context is empty (no class hierarchy in the project)
468
+ if (chaCtx.implementors.size === 0 && chaCtx.parents.size === 0)
469
+ return;
470
+ // Seed only from 'calls' edges — import/extends/implements edges share (src,tgt) pairs
471
+ // with real call edges at the file-node level and would cause false dedup if included.
472
+ const seenByPair = new Set();
473
+ for (const row of allEdgeRows) {
474
+ if (row[2] === 'calls')
475
+ seenByPair.add(`${row[0]}|${row[1]}`);
476
+ }
477
+ const { fileSymbols, barrelOnlyFiles } = ctx;
478
+ const lookup = makeContextLookup(ctx, getNodeIdStmt);
479
+ for (const [relPath, symbols] of fileSymbols) {
480
+ if (barrelOnlyFiles.has(relPath))
481
+ continue;
482
+ const fileNodeRow = getNodeIdStmt.get(relPath, 'file', relPath, 0);
483
+ if (!fileNodeRow)
484
+ continue;
485
+ const typeMap = symbols.typeMap || new Map();
486
+ for (const call of symbols.calls) {
487
+ if (!call.receiver)
488
+ continue;
489
+ if (BUILTIN_RECEIVERS.has(call.receiver))
490
+ continue;
491
+ const caller = findCaller(lookup, call, symbols.definitions, relPath, fileNodeRow);
492
+ let chaTargets = [];
493
+ let isTypedReceiverDispatch = false;
494
+ if (call.receiver === 'this' || call.receiver === 'self' || call.receiver === 'super') {
495
+ chaTargets = resolveThisDispatch(call.name, caller.callerName, call.receiver, chaCtx, lookup, relPath);
496
+ }
497
+ else {
498
+ const typeEntry = typeMap.get(call.receiver);
499
+ const typeName = typeEntry
500
+ ? typeof typeEntry === 'string'
501
+ ? typeEntry
502
+ : typeEntry.type
503
+ : null;
504
+ if (typeName) {
505
+ chaTargets = resolveChaTargets(typeName, call.name, chaCtx, lookup);
506
+ isTypedReceiverDispatch = true;
507
+ }
508
+ }
509
+ for (const t of chaTargets) {
510
+ const edgeKey = `${caller.id}|${t.id}`;
511
+ if (t.id !== caller.id && !seenByPair.has(edgeKey)) {
512
+ // Typed-receiver (interface/CHA) dispatch: use CHA_TYPED_DISPATCH_CONFIDENCE
513
+ // — file proximity is not meaningful for virtual dispatch confidence.
514
+ // this/super dispatch keeps computeConfidence-based proximity scoring to
515
+ // match runPostNativeThisDispatch (native-orchestrator.ts).
516
+ const conf = isTypedReceiverDispatch
517
+ ? CHA_TYPED_DISPATCH_CONFIDENCE
518
+ : computeConfidence(relPath, t.file, null) - CHA_DISPATCH_PENALTY;
519
+ if (conf > 0) {
520
+ seenByPair.add(edgeKey);
521
+ // Tag super-dispatch edges distinctly so runChaPostPass can exclude them
522
+ // from further CHA expansion (super calls are not virtual dispatch).
523
+ const technique = call.receiver === 'super' ? 'super-dispatch' : 'cha';
524
+ allEdgeRows.push([caller.id, t.id, 'calls', conf, 0, technique, null]);
525
+ }
526
+ }
527
+ }
528
+ }
529
+ }
530
+ }
531
+ function buildImportedNamesForNative(ctx, relPath, symbols, rootDir) {
532
+ const importedNames = [];
533
+ // Process dynamic imports first (lower priority), then static imports
534
+ // (higher priority). Rust HashMap::collect keeps the last entry per key,
535
+ // so static imports win when both contribute the same name.
536
+ const addImports = (imp) => {
537
+ const resolvedPath = getResolved(ctx, path.join(rootDir, relPath), imp.source);
538
+ for (const name of imp.names) {
539
+ const cleanName = name.replace(/^\*\s+as\s+/, '');
540
+ let targetFile = resolvedPath;
541
+ if (isBarrelFile(ctx, resolvedPath)) {
542
+ const actual = resolveBarrelExportCached(ctx, resolvedPath, cleanName);
543
+ if (actual)
544
+ targetFile = actual;
545
+ }
546
+ importedNames.push({ name: cleanName, file: targetFile });
547
+ }
548
+ };
549
+ for (const imp of symbols.imports) {
550
+ if (imp.dynamicImport)
551
+ addImports(imp);
552
+ }
553
+ for (const imp of symbols.imports) {
554
+ if (!imp.dynamicImport)
555
+ addImports(imp);
556
+ }
557
+ return importedNames;
558
+ }
559
+ // ── Call edges (JS fallback) ────────────────────────────────────────────
560
+ function buildCallEdgesJS(ctx, getNodeIdStmt, allEdgeRows, chaCtx) {
561
+ const { fileSymbols, barrelOnlyFiles, rootDir } = ctx;
562
+ const lookup = makeContextLookup(ctx, getNodeIdStmt);
563
+ for (const [relPath, symbols] of fileSymbols) {
564
+ if (barrelOnlyFiles.has(relPath))
565
+ continue;
566
+ const fileNodeRow = getNodeIdStmt.get(relPath, 'file', relPath, 0);
567
+ if (!fileNodeRow)
568
+ continue;
569
+ const importedNames = buildImportedNamesMap(ctx, relPath, symbols, rootDir);
570
+ const typeMap = new Map(symbols.typeMap instanceof Map ? symbols.typeMap : []);
571
+ // Phase 8.3f: seed typeMap[callee::restName] = { type: argName } for each
572
+ // object-destructuring rest parameter binding × call-site argument binding.
573
+ // Keys are scoped so two functions with the same rest-param name in the same
574
+ // file don't collide (#1358). When only one callee uses a given rest name,
575
+ // also seed the unscoped key as a null-callerName fallback.
576
+ if (symbols.objectRestParamBindings?.length && symbols.paramBindings?.length) {
577
+ const restNameCallees = new Map();
578
+ for (const orpb of symbols.objectRestParamBindings) {
579
+ if (!restNameCallees.has(orpb.restName))
580
+ restNameCallees.set(orpb.restName, new Set());
581
+ restNameCallees.get(orpb.restName).add(orpb.callee);
582
+ }
583
+ for (const orpb of symbols.objectRestParamBindings) {
584
+ for (const pb of symbols.paramBindings) {
585
+ if (pb.callee === orpb.callee && pb.argIndex === orpb.argIndex) {
586
+ const scopedKey = `${orpb.callee}::${orpb.restName}`;
587
+ if (!typeMap.has(scopedKey)) {
588
+ typeMap.set(scopedKey, { type: pb.argName, confidence: 0.65 });
589
+ if (restNameCallees.get(orpb.restName).size === 1 && !typeMap.has(orpb.restName)) {
590
+ typeMap.set(orpb.restName, { type: pb.argName, confidence: 0.65 });
591
+ }
592
+ }
593
+ }
594
+ }
595
+ }
596
+ }
597
+ const seenCallEdges = new Set();
598
+ const ptsMap = buildPointsToMapForFile(symbols, importedNames);
599
+ buildFileCallEdges(relPath, symbols, fileNodeRow, importedNames, seenCallEdges, lookup, allEdgeRows, typeMap, ptsMap, chaCtx);
600
+ buildClassHierarchyEdges(ctx, relPath, symbols, allEdgeRows);
601
+ }
602
+ }
603
+ function buildImportedNamesMap(ctx, relPath, symbols, rootDir) {
604
+ const importedNames = new Map();
605
+ // Process dynamic imports first (lower priority), then static imports
606
+ // (higher priority). Static imports represent direct bindings while dynamic
607
+ // imports often use aliased destructuring (`{ foo: bar } = await import(…)`).
608
+ // When both contribute the same name, the static binding is authoritative.
609
+ //
610
+ // Phase 8.4: trace through barrel files so that symbol names map to their
611
+ // actual definition file, not the re-exporting barrel. Mirrors the tracing
612
+ // already done in buildImportedNamesForNative (the native path).
613
+ const traceBarrel = (resolvedPath, cleanName) => {
614
+ if (!isBarrelFile(ctx, resolvedPath))
615
+ return resolvedPath;
616
+ const actual = resolveBarrelExportCached(ctx, resolvedPath, cleanName);
617
+ return actual ?? resolvedPath;
618
+ };
619
+ for (const imp of symbols.imports) {
620
+ if (!imp.dynamicImport)
621
+ continue;
622
+ const resolvedPath = getResolved(ctx, path.join(rootDir, relPath), imp.source);
623
+ for (const name of imp.names) {
624
+ const cleanName = name.replace(/^\*\s+as\s+/, '');
625
+ importedNames.set(cleanName, traceBarrel(resolvedPath, cleanName));
626
+ }
627
+ }
628
+ for (const imp of symbols.imports) {
629
+ if (imp.dynamicImport)
630
+ continue;
631
+ const resolvedPath = getResolved(ctx, path.join(rootDir, relPath), imp.source);
632
+ for (const name of imp.names) {
633
+ const cleanName = name.replace(/^\*\s+as\s+/, '');
634
+ importedNames.set(cleanName, traceBarrel(resolvedPath, cleanName));
635
+ }
636
+ }
637
+ return importedNames;
638
+ }
639
+ function makeContextLookup(ctx, getNodeIdStmt) {
640
+ return {
641
+ byNameAndFile: (name, file) => ctx.nodesByNameAndFile.get(`${name}|${file}`) ?? [],
642
+ byName: (name) => ctx.nodesByName.get(name) ?? [],
643
+ isBarrel: (file) => isBarrelFile(ctx, file),
644
+ resolveBarrel: (barrelFile, symbolName) => resolveBarrelExportCached(ctx, barrelFile, symbolName),
645
+ nodeId: (name, kind, file, line) => getNodeIdStmt.get(name, kind, file, line),
646
+ };
647
+ }
648
+ /**
649
+ * Build a per-file points-to map for Phase 8.3 alias resolution.
650
+ * Returns null fast when the file has no function-reference bindings.
651
+ *
652
+ * Only callable definitions (function/method) are seeded as concrete targets.
653
+ * Class and interface names are intentionally excluded — aliasing a constructor
654
+ * (`const Svc = MyService`) is an uncommon pattern that would require tracking
655
+ * `new`-expression flows separately from the alias chain. That is left to Phase
656
+ * 8.2 call-assignment propagation, which already handles constructor assignments.
657
+ */
658
+ function buildPointsToMapForFile(symbols, importedNames) {
659
+ const hasThisCallBindings = !!symbols.thisCallBindings?.length;
660
+ if (!symbols.fnRefBindings?.length &&
661
+ !symbols.paramBindings?.length &&
662
+ !symbols.arrayElemBindings?.length &&
663
+ !symbols.spreadArgBindings?.length &&
664
+ !symbols.forOfBindings?.length &&
665
+ !symbols.arrayCallbackBindings?.length &&
666
+ !symbols.objectRestParamBindings?.length &&
667
+ !symbols.objectPropBindings?.length &&
668
+ !hasThisCallBindings)
669
+ return null;
670
+ const defNames = new Set(symbols.definitions
671
+ .filter((d) => d.kind === 'function' || d.kind === 'method')
672
+ .map((d) => d.name));
673
+ const definitionParams = buildDefinitionParamsMap(symbols.definitions);
674
+ // Convert thisCallBindings into scoped fnRefBindings: `fn::this → namedCtx`.
675
+ // The scoped key `fn::this` is looked up when `this()` calls are resolved inside
676
+ // function `fn` — caller.callerName='fn', call.name='this' → scopedPtsKey='fn::this'.
677
+ let allFnRefBindings = symbols.fnRefBindings ?? [];
678
+ if (hasThisCallBindings) {
679
+ const extra = (symbols.thisCallBindings ?? []).map((b) => ({
680
+ lhs: `${b.callee}::this`,
681
+ rhs: b.thisArg,
682
+ }));
683
+ allFnRefBindings = [...allFnRefBindings, ...extra];
684
+ }
685
+ return buildPointsToMap(allFnRefBindings, defNames, importedNames, symbols.paramBindings, definitionParams, symbols.arrayElemBindings, symbols.spreadArgBindings, symbols.forOfBindings, symbols.arrayCallbackBindings, symbols.objectRestParamBindings, symbols.objectPropBindings);
686
+ }
687
+ function buildDefinitionParamsMap(definitions) {
688
+ const map = new Map();
689
+ for (const def of definitions) {
690
+ if ((def.kind === 'function' || def.kind === 'method') && def.children) {
691
+ const params = def.children.filter((c) => c.kind === 'parameter').map((c) => c.name);
692
+ if (params.length > 0) {
693
+ if (map.has(def.name)) {
694
+ // Two definitions share the same name (e.g. overloads, same-named method and
695
+ // function, or conditional redeclaration). Keep the first entry — using the
696
+ // wrong parameter list would map argIndex to the wrong parameter name.
697
+ debug(`buildDefinitionParamsMap: duplicate def name "${def.name}" (kind=${def.kind}, line=${def.line}) — skipping; first entry kept`);
698
+ }
699
+ else {
700
+ map.set(def.name, params);
701
+ }
702
+ }
703
+ }
704
+ }
705
+ return map;
706
+ }
707
+ // ── Per-call resolution helpers ─────────────────────────────────────────
708
+ /**
709
+ * Resolve targets for a single call site with all JS-path fallbacks applied.
710
+ *
711
+ * Runs in order:
712
+ * 1. Primary resolution via `resolveCallTargets` (importedNames + typeMap).
713
+ * 2. Same-class `this.method()` fallback (non-super receivers only).
714
+ * 3. Same-class bare-call fallback for non-JS/TS class-scoped languages.
715
+ * 4. Object.defineProperty accessor fallback (this-calls inside getter/setter).
716
+ *
717
+ * Returns the resolved targets array and the importedFrom hint for confidence scoring.
718
+ */
719
+ function resolveFallbackTargets(call, caller, relPath, importedNames, lookup, typeMap, definePropertyReceivers) {
720
+ let { targets, importedFrom } = resolveCallTargets(lookup, call, relPath, importedNames, typeMap, caller.callerName);
721
+ // Same-class `this.method()` fallback: when the call receiver is `this` and
722
+ // resolveCallTargets found nothing, derive the enclosing class name from the
723
+ // caller (e.g. `Logger.info` → class prefix `Logger`) and retry with the
724
+ // qualified method name `Logger._write`. This mirrors what the native Rust
725
+ // engine does implicitly via its class-scoped symbol table.
726
+ // NOTE: restricted to `this` only — `super.method()` targets a parent class,
727
+ // not the enclosing class, so qualifying with the child class name would
728
+ // produce a false edge when the child also defines a same-named method.
729
+ if (targets.length === 0 && call.receiver === 'this' && caller.callerName != null) {
730
+ const lastDot = caller.callerName.lastIndexOf('.');
731
+ if (lastDot > 0) {
732
+ const prevDot = caller.callerName.lastIndexOf('.', lastDot - 1);
733
+ const className = caller.callerName.slice(prevDot + 1, lastDot);
734
+ const qualified = lookup
735
+ .byNameAndFile(`${className}.${call.name}`, relPath)
736
+ .filter((n) => n.kind === 'method');
737
+ if (qualified.length > 0)
738
+ targets = qualified;
739
+ }
740
+ }
741
+ // Same-class bare-call fallback: when a no-receiver call can't be resolved
742
+ // globally, try the caller's own class as a qualifier. Handles C# static
743
+ // sibling calls: `IsValidEmail()` inside `Validators.ValidateUser` resolves
744
+ // to `Validators.IsValidEmail`. Skipped for JS/TS where bare calls are
745
+ // module-scoped, not class-scoped.
746
+ if (targets.length === 0 &&
747
+ !call.receiver &&
748
+ caller.callerName != null &&
749
+ !isModuleScopedLanguage(relPath)) {
750
+ const lastDot = caller.callerName.lastIndexOf('.');
751
+ if (lastDot > 0) {
752
+ const prevDot = caller.callerName.lastIndexOf('.', lastDot - 1);
753
+ const className = caller.callerName.slice(prevDot + 1, lastDot);
754
+ const qualified = lookup
755
+ .byNameAndFile(`${className}.${call.name}`, relPath)
756
+ .filter((n) => n.kind === 'method');
757
+ if (qualified.length > 0)
758
+ targets = qualified;
759
+ }
760
+ }
761
+ // Object.defineProperty accessor fallback: when a function is registered as
762
+ // a getter/setter via `Object.defineProperty(obj, "bar", { get: getter })`,
763
+ // calls to `this.X()` inside `getter` resolve against `obj` (this === obj
764
+ // when the accessor is invoked). If the same-class fallback above found
765
+ // nothing, try treating `obj` as the receiver and look up `obj.X` in the
766
+ // typeMap, or fall back to a same-file lookup of any definition named X
767
+ // that belongs to the object literal or its type.
768
+ if (targets.length === 0 &&
769
+ call.receiver === 'this' &&
770
+ caller.callerName != null &&
771
+ definePropertyReceivers) {
772
+ const receiverVarName = definePropertyReceivers.get(caller.callerName);
773
+ if (receiverVarName) {
774
+ const typeEntry = typeMap.get(receiverVarName);
775
+ const typeName = typeEntry
776
+ ? typeof typeEntry === 'string'
777
+ ? typeEntry
778
+ : typeEntry.type
779
+ : null;
780
+ if (typeName) {
781
+ const qualified = lookup.byNameAndFile(`${typeName}.${call.name}`, relPath);
782
+ if (qualified.length > 0)
783
+ targets = [...qualified];
784
+ }
785
+ // If still no targets, search for any definition named `call.name` in
786
+ // the same file — handles plain object literals where the method isn't
787
+ // qualified (e.g. `const obj = { baz() {} }` defines `baz` directly).
788
+ // Note: this is intentionally broad — it matches any same-file definition
789
+ // with the called name, not just members of the receiver object. This is
790
+ // the same behaviour used by the native post-pass path (buildDefinePropertyPostPass).
791
+ if (targets.length === 0) {
792
+ const sameFile = lookup.byNameAndFile(call.name, relPath);
793
+ if (sameFile.length > 0)
794
+ targets = [...sameFile];
795
+ }
796
+ }
797
+ }
798
+ return { targets, importedFrom };
799
+ }
800
+ /**
801
+ * Emit direct-call edges for the resolved targets of a single call site.
802
+ *
803
+ * Sorts targets by confidence descending first, then for each target:
804
+ * - Skips self-edges and already-seen edges.
805
+ * - If a pts edge already exists for this pair, upgrades it in-place to
806
+ * direct-call confidence and promotes to seenCallEdges.
807
+ * - Otherwise records a new `calls` edge with `ts-native` technique.
808
+ */
809
+ function emitDirectCallEdgesForCall(caller, targets, importedFrom, isDynamic, relPath, seenCallEdges, ptsEdgeRows, allEdgeRows) {
810
+ // Sort targets by confidence descending before emitting edges.
811
+ // For multi-target calls with duplicate (source_id, target_id) pairs the
812
+ // stored confidence depends on which duplicate is processed last — sorting
813
+ // here guarantees the highest-confidence target wins on dedup, matching the
814
+ // native engine's sort_targets_by_confidence call in build_edges.rs.
815
+ const sorted = targets.length > 1
816
+ ? [...targets].sort((a, b) => computeConfidence(relPath, b.file, importedFrom ?? null) -
817
+ computeConfidence(relPath, a.file, importedFrom ?? null))
818
+ : targets;
819
+ for (const t of sorted) {
820
+ const edgeKey = `${caller.id}|${t.id}`;
821
+ if (t.id === caller.id)
822
+ continue;
823
+ const confidence = computeConfidence(relPath, t.file, importedFrom ?? null);
824
+ if (seenCallEdges.has(edgeKey))
825
+ continue;
826
+ const ptsIdx = ptsEdgeRows.get(edgeKey);
827
+ if (ptsIdx !== undefined) {
828
+ // A pts-resolved edge already exists for this caller→target pair with a
829
+ // penalised confidence. Upgrade it to the direct-call confidence in-place,
830
+ // then promote to seenCallEdges so no further processing is needed.
831
+ const ptsRow = allEdgeRows[ptsIdx];
832
+ if (ptsRow) {
833
+ ptsRow[3] = confidence;
834
+ ptsRow[4] = isDynamic; // upgrade is_dynamic: direct call overrides the pts-alias dynamic flag
835
+ ptsRow[5] = 'ts-native'; // promoted from pts to direct-call resolution
836
+ }
837
+ ptsEdgeRows.delete(edgeKey);
838
+ seenCallEdges.add(edgeKey);
839
+ }
840
+ else {
841
+ seenCallEdges.add(edgeKey);
842
+ allEdgeRows.push([caller.id, t.id, 'calls', confidence, isDynamic, 'ts-native', null]);
843
+ }
844
+ }
845
+ }
846
+ /**
847
+ * Phase 8.3 / 8.3c / bind: emit pts-resolved edges for unresolved no-receiver calls.
848
+ *
849
+ * Fires for three cases:
850
+ * (a) dynamic=true: alias calls emitted by extractCallbackReferenceCalls.
851
+ * Looks up `call.name` directly (alias entries are flat-keyed).
852
+ * (b) non-dynamic: parameter variable calls (fn() where fn is a param).
853
+ * Looks up the scoped key `callerName::call.name` to avoid spurious
854
+ * edges from same-named parameters across different functions.
855
+ * (c) non-dynamic: module-level alias bindings — `f = fn.bind(ctx)` or
856
+ * `const f = handler` — where pts('f') was seeded by fnRefBindings.
857
+ * Checked against fnRefBindingLhs so case (c) only fires for genuine
858
+ * bind/alias entries and never for self-seeded local definitions.
859
+ *
860
+ * Pts edges are added to ptsEdgeRows (not seenCallEdges) so that a later
861
+ * direct call to the same target can upgrade confidence rather than being
862
+ * silently dropped by the dedup guard.
863
+ */
864
+ function emitPtsNoReceiverEdges(call, caller, isDynamic, relPath, importedNames, lookup, typeMap, ptsMap, fnRefBindingLhs, seenCallEdges, ptsEdgeRows, allEdgeRows) {
865
+ const scopedPtsKey = caller.callerName != null ? `${caller.callerName}::${call.name}` : null;
866
+ // Module-level calls (callerName === null) use the '<module>' sentinel emitted by
867
+ // extractSpreadForOfWalk for top-level for-of loops. Look it up as a fallback so
868
+ // that `for (const f of arr) { f(); }` at module scope resolves correctly.
869
+ const modulePtsKey = caller.callerName === null && ptsMap.has(`<module>::${call.name}`)
870
+ ? `<module>::${call.name}`
871
+ : null;
872
+ const flatPtsKey = !call.dynamic && fnRefBindingLhs.has(call.name) && ptsMap.has(call.name) ? call.name : null;
873
+ if (!(call.dynamic ||
874
+ (scopedPtsKey != null && ptsMap.has(scopedPtsKey)) ||
875
+ modulePtsKey != null ||
876
+ flatPtsKey != null))
877
+ return;
878
+ const ptsLookupName = call.dynamic
879
+ ? call.name
880
+ : scopedPtsKey != null && ptsMap.has(scopedPtsKey)
881
+ ? scopedPtsKey
882
+ : modulePtsKey != null
883
+ ? modulePtsKey
884
+ : // flatPtsKey != null is guaranteed: if neither call.dynamic nor scopedPtsKey
885
+ // nor modulePtsKey matched, flatPtsKey must be non-null.
886
+ flatPtsKey;
887
+ for (const alias of resolveViaPointsTo(ptsLookupName, ptsMap)) {
888
+ // Resolve the concrete alias target. Only `name` is needed here — receiver
889
+ // and line are not relevant for alias resolution (we are looking up the
890
+ // aliased function by name, not dispatching a method call).
891
+ const { targets: aliasTargets, importedFrom: aliasFrom } = resolveCallTargets(lookup, { name: alias }, relPath, importedNames, typeMap);
892
+ const sortedAliasTargets = aliasTargets.length > 1
893
+ ? [...aliasTargets].sort((a, b) => computeConfidence(relPath, b.file, aliasFrom ?? null) -
894
+ computeConfidence(relPath, a.file, aliasFrom ?? null))
895
+ : aliasTargets;
896
+ for (const t of sortedAliasTargets) {
897
+ const edgeKey = `${caller.id}|${t.id}`;
898
+ if (t.id !== caller.id && !seenCallEdges.has(edgeKey) && !ptsEdgeRows.has(edgeKey)) {
899
+ const conf = computeConfidence(relPath, t.file, aliasFrom ?? null) - PROPAGATION_HOP_PENALTY;
900
+ if (conf > 0) {
901
+ ptsEdgeRows.set(edgeKey, allEdgeRows.length);
902
+ allEdgeRows.push([caller.id, t.id, 'calls', conf, isDynamic, 'points-to', null]);
903
+ }
904
+ }
905
+ }
906
+ }
907
+ }
908
+ /**
909
+ * Phase 8.3f: emit pts-resolved edges for unresolved receiver calls via
910
+ * object-rest param bindings.
911
+ *
912
+ * Fires when `rest.prop()` is encountered and `rest` was seeded as
913
+ * `pts["rest.prop"]` by the object-rest dispatch chain
914
+ * (ObjectRestParamBinding + paramBinding + ObjectPropBinding).
915
+ */
916
+ function emitPtsReceiverEdges(call, caller, isDynamic, relPath, importedNames, lookup, typeMap, ptsMap, seenCallEdges, ptsEdgeRows, allEdgeRows) {
917
+ const receiverKey = `${call.receiver}.${call.name}`;
918
+ if (!ptsMap.has(receiverKey))
919
+ return;
920
+ for (const alias of resolveViaPointsTo(receiverKey, ptsMap)) {
921
+ const { targets: aliasTargets, importedFrom: aliasFrom } = resolveCallTargets(lookup, { name: alias }, relPath, importedNames, typeMap);
922
+ const sortedAliasTargets = aliasTargets.length > 1
923
+ ? [...aliasTargets].sort((a, b) => computeConfidence(relPath, b.file, aliasFrom ?? null) -
924
+ computeConfidence(relPath, a.file, aliasFrom ?? null))
925
+ : aliasTargets;
926
+ for (const t of sortedAliasTargets) {
927
+ const edgeKey = `${caller.id}|${t.id}`;
928
+ if (t.id !== caller.id && !seenCallEdges.has(edgeKey) && !ptsEdgeRows.has(edgeKey)) {
929
+ const conf = computeConfidence(relPath, t.file, aliasFrom ?? null) - PROPAGATION_HOP_PENALTY;
930
+ if (conf > 0) {
931
+ ptsEdgeRows.set(edgeKey, allEdgeRows.length);
932
+ allEdgeRows.push([caller.id, t.id, 'calls', conf, isDynamic, 'points-to', null]);
933
+ }
934
+ }
935
+ }
936
+ }
937
+ }
938
+ /**
939
+ * Phase 8.5: emit CHA + RTA dispatch edges for a single call site.
940
+ *
941
+ * For `this`/`self`/`super` calls: resolve through the class hierarchy.
942
+ * For typed receiver calls: expand to all instantiated concrete implementations.
943
+ */
944
+ function emitChaCallEdgesForCall(call, caller, relPath, typeMap, lookup, chaCtx, seenCallEdges, ptsEdgeRows, allEdgeRows) {
945
+ let chaTargets = [];
946
+ let isTypedReceiverDispatch = false;
947
+ if (call.receiver === 'this' || call.receiver === 'self' || call.receiver === 'super') {
948
+ chaTargets = resolveThisDispatch(call.name, caller.callerName, call.receiver, chaCtx, lookup, relPath);
949
+ }
950
+ else if (!BUILTIN_RECEIVERS.has(call.receiver)) {
951
+ const typeEntry = typeMap.get(call.receiver);
952
+ const typeName = typeEntry
953
+ ? typeof typeEntry === 'string'
954
+ ? typeEntry
955
+ : typeEntry.type
956
+ : null;
957
+ if (typeName) {
958
+ chaTargets = resolveChaTargets(typeName, call.name, chaCtx, lookup);
959
+ isTypedReceiverDispatch = true;
960
+ }
961
+ }
962
+ for (const t of chaTargets) {
963
+ const edgeKey = `${caller.id}|${t.id}`;
964
+ if (t.id !== caller.id && !seenCallEdges.has(edgeKey) && !ptsEdgeRows.has(edgeKey)) {
965
+ // Typed-receiver (interface/CHA) dispatch: use CHA_TYPED_DISPATCH_CONFIDENCE
966
+ // — file proximity is not meaningful for virtual dispatch confidence.
967
+ // this/super dispatch keeps computeConfidence-based proximity scoring to
968
+ // match runPostNativeThisDispatch (native-orchestrator.ts).
969
+ const conf = isTypedReceiverDispatch
970
+ ? CHA_TYPED_DISPATCH_CONFIDENCE
971
+ : computeConfidence(relPath, t.file, null) - CHA_DISPATCH_PENALTY;
972
+ if (conf > 0) {
973
+ seenCallEdges.add(edgeKey);
974
+ allEdgeRows.push([caller.id, t.id, 'calls', conf, 0, 'cha', null]);
975
+ }
976
+ }
977
+ }
978
+ }
979
+ /**
980
+ * Dynamic kinds that can never be resolved statically — emit a sink edge to the
981
+ * file node instead of silently dropping the call site. confidence=0.0 keeps
982
+ * these below DEFAULT_MIN_CONFIDENCE so they never appear in normal query results.
983
+ */
984
+ const FLAG_ONLY_KINDS = new Set([
985
+ 'eval',
986
+ 'computed-key',
987
+ 'unresolved-dynamic',
988
+ ]);
989
+ /**
990
+ * Build call edges for all calls in a single file (WASM/JS engine path).
991
+ *
992
+ * Iterates over `symbols.calls` and dispatches each call through the full
993
+ * JS resolution cascade:
994
+ * 1. `resolveFallbackTargets` — primary + class-fallback + defineProperty fallback
995
+ * 2. `emitDirectCallEdgesForCall` — emit direct-call edges (upgrading any pts pair)
996
+ * 3. `emitPtsNoReceiverEdges` — Phase 8.3/8.3c pts fallback for no-receiver calls
997
+ * 4. `emitPtsReceiverEdges` — Phase 8.3f pts fallback for rest-param receiver calls
998
+ * 5. Inline `resolveReceiverEdge` — emit `receiver` edge for external receivers
999
+ * 6. `emitChaCallEdgesForCall` — Phase 8.5 CHA + RTA dispatch expansion
1000
+ * 7. Sink edge for flag-only dynamic kinds (eval, computed-key, unresolved-dynamic)
1001
+ */
1002
+ function buildFileCallEdges(relPath, symbols, fileNodeRow, importedNames, seenCallEdges, lookup, allEdgeRows, typeMap, ptsMap, chaCtx) {
1003
+ // Tracks edges that were inserted by the pts fallback (edgeKey → allEdgeRows index).
1004
+ // Kept separate from seenCallEdges so that a subsequent direct-call edge for the same
1005
+ // caller→target pair can upgrade the confidence in-place rather than being silently
1006
+ // dropped by the dedup guard. Once upgraded, the key moves to seenCallEdges and is
1007
+ // no longer tracked here.
1008
+ const ptsEdgeRows = new Map();
1009
+ // Pre-compute the set of names that appear as lhs in fnRefBindings so that
1010
+ // case (c) of the pts gate below only fires for names that are genuine
1011
+ // bind/alias entries, not for every locally-defined function or import that
1012
+ // buildPointsToMap seeds with a self-pointing entry.
1013
+ const fnRefBindingLhs = new Set(symbols.fnRefBindings?.map((b) => b.lhs) ?? []);
1014
+ for (const call of symbols.calls) {
1015
+ if (call.receiver && BUILTIN_RECEIVERS.has(call.receiver))
1016
+ continue;
1017
+ const caller = findCaller(lookup, call, symbols.definitions, relPath, fileNodeRow);
1018
+ const isDynamic = call.dynamic ? 1 : 0;
1019
+ // Step 1: Resolve targets with all JS-path fallbacks.
1020
+ const { targets, importedFrom } = resolveFallbackTargets(call, caller, relPath, importedNames, lookup, typeMap, symbols.definePropertyReceivers);
1021
+ // Step 2: Emit direct-call edges (upgrades any pending pts edge in-place).
1022
+ emitDirectCallEdgesForCall(caller, targets, importedFrom, isDynamic, relPath, seenCallEdges, ptsEdgeRows, allEdgeRows);
1023
+ // Step 3: Phase 8.3/8.3c pts fallback for unresolved no-receiver calls.
1024
+ if (targets.length === 0 && !call.receiver && ptsMap) {
1025
+ emitPtsNoReceiverEdges(call, caller, isDynamic, relPath, importedNames, lookup, typeMap, ptsMap, fnRefBindingLhs, seenCallEdges, ptsEdgeRows, allEdgeRows);
1026
+ }
1027
+ // Step 4: Phase 8.3f pts fallback for unresolved receiver calls (rest params).
1028
+ if (targets.length === 0 &&
1029
+ call.receiver &&
1030
+ !BUILTIN_RECEIVERS.has(call.receiver) &&
1031
+ call.receiver !== 'this' &&
1032
+ call.receiver !== 'self' &&
1033
+ call.receiver !== 'super' &&
1034
+ ptsMap) {
1035
+ emitPtsReceiverEdges(call, caller, isDynamic, relPath, importedNames, lookup, typeMap, ptsMap, seenCallEdges, ptsEdgeRows, allEdgeRows);
1036
+ }
1037
+ // Step 5: Emit receiver edge for external (non-this/self/super) receivers.
1038
+ if (call.receiver &&
1039
+ !BUILTIN_RECEIVERS.has(call.receiver) &&
1040
+ call.receiver !== 'this' &&
1041
+ call.receiver !== 'self' &&
1042
+ call.receiver !== 'super') {
1043
+ const recv = resolveReceiverEdge(lookup, { name: call.name, receiver: call.receiver }, caller, relPath, typeMap, seenCallEdges, importedNames);
1044
+ if (recv) {
1045
+ allEdgeRows.push([
1046
+ recv.callerId,
1047
+ recv.receiverId,
1048
+ 'receiver',
1049
+ recv.confidence,
1050
+ 0,
1051
+ null,
1052
+ null,
1053
+ ]);
1054
+ }
1055
+ }
1056
+ // Step 6: Phase 8.5 CHA + RTA dispatch expansion.
1057
+ if (chaCtx && call.receiver) {
1058
+ emitChaCallEdgesForCall(call, caller, relPath, typeMap, lookup, chaCtx, seenCallEdges, ptsEdgeRows, allEdgeRows);
1059
+ }
1060
+ // Step 7: Flag-only dynamic kinds with no resolved target → sink edge to the
1061
+ // file node. confidence=0.0 keeps it below DEFAULT_MIN_CONFIDENCE so it never
1062
+ // appears in normal query results, but is queryable via `codegraph roles --dynamic`.
1063
+ if (targets.length === 0 && call.dynamicKind && FLAG_ONLY_KINDS.has(call.dynamicKind)) {
1064
+ // Key per (caller, file, kind) so each kind gets at most one sink edge per caller.
1065
+ const sinkKey = `${caller.id}:${fileNodeRow.id}:${call.dynamicKind}`;
1066
+ if (!seenCallEdges.has(sinkKey)) {
1067
+ seenCallEdges.add(sinkKey);
1068
+ allEdgeRows.push([caller.id, fileNodeRow.id, 'calls', 0.0, 1, null, call.dynamicKind]);
1069
+ }
1070
+ }
1071
+ }
1072
+ }
1073
+ // ── Class hierarchy edges ───────────────────────────────────────────────
1074
+ const HIERARCHY_SOURCE_KINDS = new Set(['class', 'struct', 'record', 'enum']);
1075
+ const EXTENDS_TARGET_KINDS = new Set(['class', 'struct', 'trait', 'record']);
1076
+ const IMPLEMENTS_TARGET_KINDS = new Set(['interface', 'trait', 'class']);
1077
+ function buildClassHierarchyEdges(ctx, relPath, symbols, allEdgeRows) {
1078
+ for (const cls of symbols.classes) {
1079
+ if (cls.extends) {
1080
+ const sourceRow = (ctx.nodesByNameAndFile.get(`${cls.name}|${relPath}`) || []).find((n) => HIERARCHY_SOURCE_KINDS.has(n.kind));
1081
+ const targetRows = (ctx.nodesByName.get(cls.extends) || []).filter((n) => EXTENDS_TARGET_KINDS.has(n.kind));
1082
+ if (sourceRow) {
1083
+ for (const t of targetRows) {
1084
+ allEdgeRows.push([sourceRow.id, t.id, 'extends', 1.0, 0, null, null]);
1085
+ }
1086
+ }
1087
+ }
1088
+ if (cls.implements) {
1089
+ const sourceRow = (ctx.nodesByNameAndFile.get(`${cls.name}|${relPath}`) || []).find((n) => HIERARCHY_SOURCE_KINDS.has(n.kind));
1090
+ const targetRows = (ctx.nodesByName.get(cls.implements) || []).filter((n) => IMPLEMENTS_TARGET_KINDS.has(n.kind));
1091
+ if (sourceRow) {
1092
+ for (const t of targetRows) {
1093
+ allEdgeRows.push([sourceRow.id, t.id, 'implements', 1.0, 0, null, null]);
1094
+ }
1095
+ }
1096
+ }
1097
+ }
1098
+ }
1099
+ // ── Native bulk-insert technique back-fill ──────────────────────────────
1100
+ /**
1101
+ * After native bulkInsertEdges (which does not write the technique column),
1102
+ * apply technique values from the in-memory row array back to the DB, and lift
1103
+ * any resolved ts-native edge below TS_NATIVE_CONFIDENCE_FLOOR to that floor.
1104
+ *
1105
+ * Rows with an explicit technique get a targeted UPDATE by (source_id, target_id).
1106
+ * The catch-all 'ts-native' tag is scoped to only the source_ids present in this
1107
+ * batch — this prevents mis-tagging pre-migration NULL-technique edges from
1108
+ * unchanged files that were never purged and re-inserted.
1109
+ */
1110
+ function applyEdgeTechniquesAfterNativeInsert(db, rows) {
1111
+ const callRows = rows.filter((r) => r[2] === 'calls');
1112
+ if (callRows.length === 0)
1113
+ return;
1114
+ const taggedRows = callRows.filter((r) => r[5] != null);
1115
+ // Collect distinct source IDs for this batch so the catch-all UPDATE is scoped
1116
+ // to edges inserted in the current run, not the entire table.
1117
+ const sourceIds = [...new Set(callRows.map((r) => r[0]))];
1118
+ // Chunk to stay within SQLite's SQLITE_LIMIT_VARIABLE_NUMBER (999 on older builds).
1119
+ const CHUNK_SIZE = 500;
1120
+ // Rows that carry an explicit dynamic_kind (sink edges for flagged dynamic calls).
1121
+ const dynamicKindRows = callRows.filter((r) => r[6] != null);
1122
+ const tx = db.transaction(() => {
1123
+ if (taggedRows.length > 0) {
1124
+ const stmt = db.prepare("UPDATE edges SET technique = ? WHERE kind = 'calls' AND source_id = ? AND target_id = ? AND technique IS NULL");
1125
+ for (const r of taggedRows)
1126
+ stmt.run(r[5], r[0], r[1]);
1127
+ }
1128
+ for (let i = 0; i < sourceIds.length; i += CHUNK_SIZE) {
1129
+ const chunk = sourceIds.slice(i, i + CHUNK_SIZE);
1130
+ const placeholders = chunk.map(() => '?').join(',');
1131
+ db.prepare(`UPDATE edges SET technique = 'ts-native' WHERE kind = 'calls' AND technique IS NULL AND source_id IN (${placeholders})`).run(...chunk);
1132
+ // Lift resolved ts-native edges below the confidence floor for this chunk.
1133
+ db.prepare(`UPDATE edges SET confidence = ?
1134
+ WHERE kind = 'calls' AND technique = 'ts-native'
1135
+ AND confidence > 0 AND confidence < ?
1136
+ AND source_id IN (${placeholders})`).run(TS_NATIVE_CONFIDENCE_FLOOR, TS_NATIVE_CONFIDENCE_FLOOR, ...chunk);
1137
+ }
1138
+ // Back-fill dynamic_kind for flagged sink edges emitted by the native engine.
1139
+ // Native bulkInsertEdges uses INSERT OR IGNORE and does not write dynamic_kind, so
1140
+ // this UPDATE is the only way to set it for natively-inserted sink edges.
1141
+ //
1142
+ // Scope to confidence=0.0 AND dynamic=1 so we only touch sink edges (never normal
1143
+ // call edges that happen to share the same (source_id, target_id) pair).
1144
+ // Include dynamic_kind in the WHERE so two sink edges from the same caller to the
1145
+ // same file with different kinds don't clobber each other across incremental runs.
1146
+ if (dynamicKindRows.length > 0) {
1147
+ const stmt = db.prepare("UPDATE edges SET dynamic_kind = ? WHERE kind = 'calls' AND source_id = ? AND target_id = ? AND confidence = 0.0 AND dynamic = 1 AND (dynamic_kind IS NULL OR dynamic_kind = ?)");
1148
+ for (const r of dynamicKindRows)
1149
+ stmt.run(r[6], r[0], r[1], r[6]);
1150
+ }
1151
+ });
1152
+ tx();
1153
+ }
1154
+ // ── Reverse-dep edge reconnection (#932, #933) ─────────────────────────
1155
+ /**
1156
+ * Reconnect edges that were saved before changed-file purge.
1157
+ *
1158
+ * Each saved edge records: sourceId (still valid — reverse-dep nodes were not
1159
+ * purged) and target attributes (name, kind, file, line). The target node was
1160
+ * deleted and re-inserted with a new ID by insertNodes. We look up the new ID
1161
+ * by (name, kind, file) and re-create the edge.
1162
+ */
1163
+ function reconnectReverseDepEdges(ctx) {
1164
+ const { db } = ctx;
1165
+ const findNodeStmt = db.prepare('SELECT id FROM nodes WHERE name = ? AND kind = ? AND file = ? ORDER BY ABS(line - ?) LIMIT 1');
1166
+ const reconnectedRows = [];
1167
+ let dropped = 0;
1168
+ for (const saved of ctx.savedReverseDepEdges) {
1169
+ const newTarget = findNodeStmt.get(saved.tgtName, saved.tgtKind, saved.tgtFile, saved.tgtLine);
1170
+ if (newTarget) {
1171
+ reconnectedRows.push([
1172
+ saved.sourceId,
1173
+ newTarget.id,
1174
+ saved.edgeKind,
1175
+ saved.confidence,
1176
+ saved.dynamic,
1177
+ saved.technique,
1178
+ saved.dynamicKind ?? null,
1179
+ ]);
1180
+ }
1181
+ else {
1182
+ // Target was removed or renamed in the changed file — edge is stale
1183
+ dropped++;
1184
+ }
1185
+ }
1186
+ if (reconnectedRows.length > 0) {
1187
+ if (ctx.nativeDb?.bulkInsertEdges) {
1188
+ const nativeEdges = reconnectedRows.map((r) => ({
1189
+ sourceId: r[0],
1190
+ targetId: r[1],
1191
+ kind: r[2],
1192
+ confidence: r[3],
1193
+ dynamic: r[4],
1194
+ }));
1195
+ const ok = ctx.nativeDb.bulkInsertEdges(nativeEdges);
1196
+ if (!ok) {
1197
+ batchInsertEdges(db, reconnectedRows);
1198
+ }
1199
+ else {
1200
+ applyEdgeTechniquesAfterNativeInsert(db, reconnectedRows);
1201
+ }
1202
+ }
1203
+ else {
1204
+ batchInsertEdges(db, reconnectedRows);
1205
+ }
1206
+ }
1207
+ debug(`Reconnected ${reconnectedRows.length} reverse-dep edges` +
1208
+ (dropped > 0 ? ` (${dropped} dropped — targets removed/renamed)` : ''));
1209
+ }
1210
+ // ── Main entry point ────────────────────────────────────────────────────
1211
+ /**
1212
+ * For small incremental builds (≤5 changed files on a large codebase), scope
1213
+ * the node loading query to only files that are relevant: changed files +
1214
+ * their import targets. Falls back to loading ALL nodes for full builds or
1215
+ * larger incremental changes.
1216
+ */
1217
+ const NODE_KIND_FILTER_SQL = `kind IN ('function','method','class','interface','struct','type','module','enum','trait','record','constant','variable')`;
1218
+ function loadNodes(ctx) {
1219
+ const { db, fileSymbols, isFullBuild, batchResolved } = ctx;
1220
+ const nodeKindFilter = NODE_KIND_FILTER_SQL;
1221
+ // Gate: only scope for small incremental on large codebases
1222
+ if (!isFullBuild && fileSymbols.size <= ctx.config.build.smallFilesThreshold) {
1223
+ const existingFileCount = db.prepare("SELECT COUNT(*) as c FROM nodes WHERE kind = 'file'").get().c;
1224
+ if (existingFileCount > 20) {
1225
+ // Collect relevant files: changed files + their import targets
1226
+ const relevantFiles = new Set(fileSymbols.keys());
1227
+ if (batchResolved) {
1228
+ for (const resolvedPath of batchResolved.values()) {
1229
+ relevantFiles.add(resolvedPath);
1230
+ }
1231
+ }
1232
+ // Also add barrel-only files
1233
+ for (const barrelPath of ctx.barrelOnlyFiles) {
1234
+ relevantFiles.add(barrelPath);
1235
+ }
1236
+ const placeholders = [...relevantFiles].map(() => '?').join(',');
1237
+ const rows = db
1238
+ .prepare(`SELECT id, name, kind, file, line FROM nodes WHERE ${nodeKindFilter} AND file IN (${placeholders})`)
1239
+ .all(...relevantFiles);
1240
+ return { rows, scoped: true };
1241
+ }
1242
+ }
1243
+ const rows = db
1244
+ .prepare(`SELECT id, name, kind, file, line FROM nodes WHERE ${nodeKindFilter}`)
1245
+ .all();
1246
+ return { rows, scoped: false };
1247
+ }
1248
+ /**
1249
+ * For scoped node loading, patch nodesByName.get with a lazy SQL fallback
1250
+ * so global name-only lookups (resolveByMethodOrGlobal)
1251
+ * can still find nodes outside the scoped set.
1252
+ */
1253
+ function addLazyFallback(ctx, scopedLoad) {
1254
+ if (!scopedLoad)
1255
+ return;
1256
+ const { db } = ctx;
1257
+ // Match the upfront kind filter exactly. Using `kind != 'file'` here lets
1258
+ // parameters, properties, and other non-definition kinds leak into call
1259
+ // resolution, producing bogus call edges like `parser.ts → <a parameter
1260
+ // with the same name>` (#1174 follow-up). Calls only ever target the
1261
+ // definition kinds, so the fallback's filter must agree with `loadNodes`.
1262
+ const fallbackStmt = db.prepare(`SELECT id, name, kind, file, line FROM nodes WHERE name = ? AND ${NODE_KIND_FILTER_SQL}`);
1263
+ const originalGet = ctx.nodesByName.get.bind(ctx.nodesByName);
1264
+ ctx.nodesByName.get = (name) => {
1265
+ const result = originalGet(name);
1266
+ if (result !== undefined)
1267
+ return result;
1268
+ const rows = fallbackStmt.all(name);
1269
+ if (rows.length > 0) {
1270
+ ctx.nodesByName.set(name, rows);
1271
+ return rows;
1272
+ }
1273
+ return undefined;
1274
+ };
1275
+ }
1276
+ export async function buildEdges(ctx) {
1277
+ const { db, engineName } = ctx;
1278
+ const getNodeIdStmt = makeGetNodeIdStmt(db);
1279
+ const { rows: allNodesBefore, scoped: scopedLoad } = loadNodes(ctx);
1280
+ setupNodeLookups(ctx, allNodesBefore);
1281
+ addLazyFallback(ctx, scopedLoad);
1282
+ const t0 = performance.now();
1283
+ // Enrich typeMap for .ts/.tsx files using the TypeScript compiler API.
1284
+ // Runs before call-edge construction so the accurate types are available
1285
+ // for method-call resolution. Gated on config so users can opt out.
1286
+ //
1287
+ // Skip for small incremental builds: TypeScript program creation requires
1288
+ // loading the entire tsconfig file list (~700ms startup on the codegraph
1289
+ // corpus), which dominates the 1-file rebuild time. Native engine bypasses
1290
+ // this entirely via the Rust orchestrator; WASM/JS engines need this gate
1291
+ // to match native's effective behaviour on tiny incremental changes.
1292
+ // Mirrors the smallFilesThreshold gates for nativeDb and native call-edges.
1293
+ const isSmallIncremental = !ctx.isFullBuild && ctx.fileSymbols.size <= ctx.config.build.smallFilesThreshold;
1294
+ if (ctx.config.build.typescriptResolver && !isSmallIncremental) {
1295
+ await enrichTypeMapWithTsc(ctx.rootDir, ctx.fileSymbols);
1296
+ }
1297
+ const native = engineName === 'native' ? loadNative() : null;
1298
+ // Phase 8.2: Augment typeMaps with cross-file return-type propagation before
1299
+ // the transaction opens. This is pure in-memory mutation (no DB I/O) and must
1300
+ // run outside the transaction to avoid leaving ctx.fileSymbols in a partial
1301
+ // state if the transaction rolls back unexpectedly.
1302
+ propagateReturnTypesAcrossFiles(ctx.fileSymbols, ctx, ctx.rootDir);
1303
+ // Phase 8.5: Build CHA context after propagation so typeMap confidence values
1304
+ // (used for RTA seeding) reflect any cross-file propagated types.
1305
+ const chaCtx = buildChaContext(ctx.fileSymbols);
1306
+ // Phase 1: Compute edges inside a better-sqlite3 transaction.
1307
+ // Barrel-edge deletion lives here so that the JS path (which also inserts
1308
+ // edges in this transaction) keeps deletion + insertion atomic.
1309
+ // When using the native rusqlite path, insertion happens in Phase 2 on a
1310
+ // separate connection — a crash between Phase 1 and Phase 2 would leave
1311
+ // barrel edges missing until the next incremental rebuild re-creates them.
1312
+ const allEdgeRows = [];
1313
+ const computeEdgesTx = db.transaction(() => {
1314
+ if (ctx.barrelOnlyFiles.size > 0) {
1315
+ const deleteOutgoingEdges = db.prepare('DELETE FROM edges WHERE source_id IN (SELECT id FROM nodes WHERE file = ?)');
1316
+ for (const relPath of ctx.barrelOnlyFiles) {
1317
+ deleteOutgoingEdges.run(relPath);
1318
+ }
1319
+ }
1320
+ // Skip native import-edge path for small incremental builds: napi-rs
1321
+ // marshaling overhead (~13ms) exceeds Rust computation savings at this scale.
1322
+ const useNativeImportEdges = native?.buildImportEdges &&
1323
+ (ctx.isFullBuild || ctx.fileSymbols.size > ctx.config.build.smallFilesThreshold);
1324
+ if (useNativeImportEdges) {
1325
+ const beforeLen = allEdgeRows.length;
1326
+ buildImportEdgesNative(ctx, getNodeIdStmt, allEdgeRows, native);
1327
+ // Fallback: if native produced 0 import edges but there are imports to
1328
+ // process, the native binary may have a key-format mismatch (e.g. Windows
1329
+ // path separators — #750). Retry with the JS implementation.
1330
+ // NOTE: This also fires for codebases where every import targets an
1331
+ // external package (npm deps) that the resolver intentionally skips.
1332
+ // In that case the JS path resolves zero edges too, so the only cost
1333
+ // is the redundant JS traversal — no correctness impact.
1334
+ const hasImports = [...ctx.fileSymbols.values()].some((s) => s.imports.length > 0);
1335
+ if (allEdgeRows.length === beforeLen && hasImports) {
1336
+ debug('Native buildImportEdges produced 0 edges — falling back to JS');
1337
+ buildImportEdges(ctx, getNodeIdStmt, allEdgeRows);
1338
+ }
1339
+ }
1340
+ else {
1341
+ buildImportEdges(ctx, getNodeIdStmt, allEdgeRows);
1342
+ }
1343
+ // Skip native call-edge path for small incremental builds: napi-rs
1344
+ // marshaling overhead for allNodes exceeds Rust computation savings.
1345
+ const useNativeCallEdges = native?.buildCallEdges &&
1346
+ (ctx.isFullBuild || ctx.fileSymbols.size > ctx.config.build.smallFilesThreshold);
1347
+ if (useNativeCallEdges) {
1348
+ buildCallEdgesNative(ctx, getNodeIdStmt, allEdgeRows, allNodesBefore, native);
1349
+ // The native engine receives all pts bindings (paramBindings,
1350
+ // fnRefBindings, thisCallBindings, objectRestParamBindings, …) through
1351
+ // NativeFileEntry and runs the same points-to solver as the JS path, so
1352
+ // no pts post-passes are needed here. Only capabilities that remain
1353
+ // JS-only run as post-passes below.
1354
+ const sharedLookup = makeContextLookup(ctx, getNodeIdStmt);
1355
+ // Object.defineProperty accessor post-pass: resolve this-dispatch inside
1356
+ // getter/setter functions registered via Object.defineProperty.
1357
+ buildDefinePropertyPostPass(ctx, getNodeIdStmt, allEdgeRows, sharedLookup);
1358
+ // Phase 8.5 post-pass: augment native call edges with CHA-resolved dispatch.
1359
+ // The native Rust engine has no knowledge of the CHA context, so this/self
1360
+ // calls and interface dispatch are not expanded to concrete implementations.
1361
+ buildChaPostPass(ctx, getNodeIdStmt, allEdgeRows, chaCtx);
1362
+ }
1363
+ else {
1364
+ buildCallEdgesJS(ctx, getNodeIdStmt, allEdgeRows, chaCtx);
1365
+ }
1366
+ // Apply ts-native confidence floor to allEdgeRows in-memory. The proximity
1367
+ // heuristic returns 0.3 for cross-module calls with no import-path evidence,
1368
+ // but both WASM and native engines perform actual name-based symbol lookup,
1369
+ // which is stronger evidence than pure proximity. Clamping to
1370
+ // TS_NATIVE_CONFIDENCE_FLOOR (0.5) avoids unfairly dragging down the
1371
+ // call-confidence metric. Sink edges (confidence = 0.0) are excluded so
1372
+ // they remain below DEFAULT_MIN_CONFIDENCE.
1373
+ for (const r of allEdgeRows) {
1374
+ if (r[2] === 'calls' &&
1375
+ r[5] === 'ts-native' &&
1376
+ r[3] > 0 &&
1377
+ r[3] < TS_NATIVE_CONFIDENCE_FLOOR) {
1378
+ r[3] = TS_NATIVE_CONFIDENCE_FLOOR;
1379
+ }
1380
+ }
1381
+ // When using native edge insert, skip JS insert here — do it after tx commits.
1382
+ // Otherwise insert edges within this transaction for atomicity.
1383
+ const useNativeEdgeInsert = ctx.engineName === 'native' && !!ctx.nativeDb?.bulkInsertEdges;
1384
+ if (!useNativeEdgeInsert) {
1385
+ batchInsertEdges(db, allEdgeRows);
1386
+ }
1387
+ });
1388
+ computeEdgesTx();
1389
+ // Phase 2: Native rusqlite bulk insert (outside better-sqlite3 transaction
1390
+ // to avoid SQLITE_BUSY contention). Uses NativeDatabase persistent connection.
1391
+ // Standalone napi functions were removed in 6.17.
1392
+ if (ctx.engineName === 'native' && ctx.nativeDb?.bulkInsertEdges && allEdgeRows.length > 0) {
1393
+ const nativeEdges = allEdgeRows.map((r) => ({
1394
+ sourceId: r[0],
1395
+ targetId: r[1],
1396
+ kind: r[2],
1397
+ confidence: r[3],
1398
+ dynamic: r[4],
1399
+ }));
1400
+ const ok = ctx.nativeDb.bulkInsertEdges(nativeEdges);
1401
+ if (!ok) {
1402
+ debug('Native bulkInsertEdges failed — falling back to JS batchInsertEdges');
1403
+ batchInsertEdges(ctx.db, allEdgeRows);
1404
+ }
1405
+ else {
1406
+ applyEdgeTechniquesAfterNativeInsert(ctx.db, allEdgeRows);
1407
+ }
1408
+ }
1409
+ // Phase 3: Reconnect saved reverse-dep edges (#932, #933).
1410
+ // When the WASM/JS path purged changed files, edges FROM reverse-dep files TO
1411
+ // those files were deleted (target-side). The reverse-dep files were NOT
1412
+ // reparsed — instead we saved the edge topology before purge and now reconnect
1413
+ // each edge to the new node IDs created by insertNodes.
1414
+ if (ctx.savedReverseDepEdges.length > 0) {
1415
+ reconnectReverseDepEdges(ctx);
1416
+ }
1417
+ // Phase 4: CHA post-pass — expand virtual-dispatch edges for class hierarchies
1418
+ // and interface implementations. Runs after all call + hierarchy edges are
1419
+ // committed so the DB is consistent.
1420
+ // Note: the native orchestrator success path runs this independently in
1421
+ // tryNativeOrchestrator; this phase covers the WASM and native-fallback paths.
1422
+ runChaPostPass(db);
1423
+ ctx.timing.edgesMs = performance.now() - t0;
1424
+ }
1425
+ //# sourceMappingURL=build-edges.js.map