@bharanidev/bhgraph-darwin-arm64 1.0.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 (842) hide show
  1. package/bin/bhgraph +19 -0
  2. package/lib/dist/bin/bhgraph.d.ts +26 -0
  3. package/lib/dist/bin/bhgraph.d.ts.map +1 -0
  4. package/lib/dist/bin/bhgraph.js +2207 -0
  5. package/lib/dist/bin/bhgraph.js.map +1 -0
  6. package/lib/dist/bin/command-supervision.d.ts +12 -0
  7. package/lib/dist/bin/command-supervision.d.ts.map +1 -0
  8. package/lib/dist/bin/command-supervision.js +89 -0
  9. package/lib/dist/bin/command-supervision.js.map +1 -0
  10. package/lib/dist/bin/fatal-handler.d.ts +20 -0
  11. package/lib/dist/bin/fatal-handler.d.ts.map +1 -0
  12. package/lib/dist/bin/fatal-handler.js +118 -0
  13. package/lib/dist/bin/fatal-handler.js.map +1 -0
  14. package/lib/dist/bin/node-version-check.d.ts +37 -0
  15. package/lib/dist/bin/node-version-check.d.ts.map +1 -0
  16. package/lib/dist/bin/node-version-check.js +79 -0
  17. package/lib/dist/bin/node-version-check.js.map +1 -0
  18. package/lib/dist/bin/uninstall.d.ts +14 -0
  19. package/lib/dist/bin/uninstall.d.ts.map +1 -0
  20. package/lib/dist/bin/uninstall.js +36 -0
  21. package/lib/dist/bin/uninstall.js.map +1 -0
  22. package/lib/dist/context/formatter.d.ts +30 -0
  23. package/lib/dist/context/formatter.d.ts.map +1 -0
  24. package/lib/dist/context/formatter.js +263 -0
  25. package/lib/dist/context/formatter.js.map +1 -0
  26. package/lib/dist/context/index.d.ts +119 -0
  27. package/lib/dist/context/index.d.ts.map +1 -0
  28. package/lib/dist/context/index.js +1296 -0
  29. package/lib/dist/context/index.js.map +1 -0
  30. package/lib/dist/context/markers.d.ts +19 -0
  31. package/lib/dist/context/markers.d.ts.map +1 -0
  32. package/lib/dist/context/markers.js +22 -0
  33. package/lib/dist/context/markers.js.map +1 -0
  34. package/lib/dist/db/index.d.ts +142 -0
  35. package/lib/dist/db/index.d.ts.map +1 -0
  36. package/lib/dist/db/index.js +335 -0
  37. package/lib/dist/db/index.js.map +1 -0
  38. package/lib/dist/db/migrations.d.ts +44 -0
  39. package/lib/dist/db/migrations.d.ts.map +1 -0
  40. package/lib/dist/db/migrations.js +182 -0
  41. package/lib/dist/db/migrations.js.map +1 -0
  42. package/lib/dist/db/queries.d.ts +452 -0
  43. package/lib/dist/db/queries.d.ts.map +1 -0
  44. package/lib/dist/db/queries.js +1740 -0
  45. package/lib/dist/db/queries.js.map +1 -0
  46. package/lib/dist/db/schema.sql +182 -0
  47. package/lib/dist/db/sqlite-adapter.d.ts +53 -0
  48. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -0
  49. package/lib/dist/db/sqlite-adapter.js +117 -0
  50. package/lib/dist/db/sqlite-adapter.js.map +1 -0
  51. package/lib/dist/directory.d.ts +183 -0
  52. package/lib/dist/directory.d.ts.map +1 -0
  53. package/lib/dist/directory.js +797 -0
  54. package/lib/dist/directory.js.map +1 -0
  55. package/lib/dist/errors.d.ts +136 -0
  56. package/lib/dist/errors.d.ts.map +1 -0
  57. package/lib/dist/errors.js +219 -0
  58. package/lib/dist/errors.js.map +1 -0
  59. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  60. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  61. package/lib/dist/extraction/astro-extractor.js +320 -0
  62. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  63. package/lib/dist/extraction/cfml-extractor.d.ts +107 -0
  64. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -0
  65. package/lib/dist/extraction/cfml-extractor.js +494 -0
  66. package/lib/dist/extraction/cfml-extractor.js.map +1 -0
  67. package/lib/dist/extraction/dfm-extractor.d.ts +31 -0
  68. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -0
  69. package/lib/dist/extraction/dfm-extractor.js +151 -0
  70. package/lib/dist/extraction/dfm-extractor.js.map +1 -0
  71. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  72. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  73. package/lib/dist/extraction/extraction-version.js +28 -0
  74. package/lib/dist/extraction/extraction-version.js.map +1 -0
  75. package/lib/dist/extraction/function-ref.d.ts +118 -0
  76. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  77. package/lib/dist/extraction/function-ref.js +727 -0
  78. package/lib/dist/extraction/function-ref.js.map +1 -0
  79. package/lib/dist/extraction/generated-detection.d.ts +30 -0
  80. package/lib/dist/extraction/generated-detection.d.ts.map +1 -0
  81. package/lib/dist/extraction/generated-detection.js +83 -0
  82. package/lib/dist/extraction/generated-detection.js.map +1 -0
  83. package/lib/dist/extraction/grammars.d.ts +123 -0
  84. package/lib/dist/extraction/grammars.d.ts.map +1 -0
  85. package/lib/dist/extraction/grammars.js +589 -0
  86. package/lib/dist/extraction/grammars.js.map +1 -0
  87. package/lib/dist/extraction/index.d.ts +232 -0
  88. package/lib/dist/extraction/index.d.ts.map +1 -0
  89. package/lib/dist/extraction/index.js +2269 -0
  90. package/lib/dist/extraction/index.js.map +1 -0
  91. package/lib/dist/extraction/languages/arkts.d.ts +3 -0
  92. package/lib/dist/extraction/languages/arkts.d.ts.map +1 -0
  93. package/lib/dist/extraction/languages/arkts.js +127 -0
  94. package/lib/dist/extraction/languages/arkts.js.map +1 -0
  95. package/lib/dist/extraction/languages/c-cpp.d.ts +110 -0
  96. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  97. package/lib/dist/extraction/languages/c-cpp.js +837 -0
  98. package/lib/dist/extraction/languages/c-cpp.js.map +1 -0
  99. package/lib/dist/extraction/languages/cfquery.d.ts +12 -0
  100. package/lib/dist/extraction/languages/cfquery.d.ts.map +1 -0
  101. package/lib/dist/extraction/languages/cfquery.js +28 -0
  102. package/lib/dist/extraction/languages/cfquery.js.map +1 -0
  103. package/lib/dist/extraction/languages/cfscript.d.ts +3 -0
  104. package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -0
  105. package/lib/dist/extraction/languages/cfscript.js +73 -0
  106. package/lib/dist/extraction/languages/cfscript.js.map +1 -0
  107. package/lib/dist/extraction/languages/cobol.d.ts +33 -0
  108. package/lib/dist/extraction/languages/cobol.d.ts.map +1 -0
  109. package/lib/dist/extraction/languages/cobol.js +499 -0
  110. package/lib/dist/extraction/languages/cobol.js.map +1 -0
  111. package/lib/dist/extraction/languages/csharp.d.ts +25 -0
  112. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -0
  113. package/lib/dist/extraction/languages/csharp.js +175 -0
  114. package/lib/dist/extraction/languages/csharp.js.map +1 -0
  115. package/lib/dist/extraction/languages/dart.d.ts +3 -0
  116. package/lib/dist/extraction/languages/dart.d.ts.map +1 -0
  117. package/lib/dist/extraction/languages/dart.js +374 -0
  118. package/lib/dist/extraction/languages/dart.js.map +1 -0
  119. package/lib/dist/extraction/languages/erlang.d.ts +3 -0
  120. package/lib/dist/extraction/languages/erlang.d.ts.map +1 -0
  121. package/lib/dist/extraction/languages/erlang.js +350 -0
  122. package/lib/dist/extraction/languages/erlang.js.map +1 -0
  123. package/lib/dist/extraction/languages/go.d.ts +3 -0
  124. package/lib/dist/extraction/languages/go.d.ts.map +1 -0
  125. package/lib/dist/extraction/languages/go.js +111 -0
  126. package/lib/dist/extraction/languages/go.js.map +1 -0
  127. package/lib/dist/extraction/languages/index.d.ts +10 -0
  128. package/lib/dist/extraction/languages/index.d.ts.map +1 -0
  129. package/lib/dist/extraction/languages/index.js +71 -0
  130. package/lib/dist/extraction/languages/index.js.map +1 -0
  131. package/lib/dist/extraction/languages/java.d.ts +3 -0
  132. package/lib/dist/extraction/languages/java.d.ts.map +1 -0
  133. package/lib/dist/extraction/languages/java.js +315 -0
  134. package/lib/dist/extraction/languages/java.js.map +1 -0
  135. package/lib/dist/extraction/languages/javascript.d.ts +3 -0
  136. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -0
  137. package/lib/dist/extraction/languages/javascript.js +106 -0
  138. package/lib/dist/extraction/languages/javascript.js.map +1 -0
  139. package/lib/dist/extraction/languages/kotlin.d.ts +3 -0
  140. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -0
  141. package/lib/dist/extraction/languages/kotlin.js +379 -0
  142. package/lib/dist/extraction/languages/kotlin.js.map +1 -0
  143. package/lib/dist/extraction/languages/lua.d.ts +3 -0
  144. package/lib/dist/extraction/languages/lua.d.ts.map +1 -0
  145. package/lib/dist/extraction/languages/lua.js +150 -0
  146. package/lib/dist/extraction/languages/lua.js.map +1 -0
  147. package/lib/dist/extraction/languages/luau.d.ts +3 -0
  148. package/lib/dist/extraction/languages/luau.d.ts.map +1 -0
  149. package/lib/dist/extraction/languages/luau.js +37 -0
  150. package/lib/dist/extraction/languages/luau.js.map +1 -0
  151. package/lib/dist/extraction/languages/nix.d.ts +3 -0
  152. package/lib/dist/extraction/languages/nix.d.ts.map +1 -0
  153. package/lib/dist/extraction/languages/nix.js +294 -0
  154. package/lib/dist/extraction/languages/nix.js.map +1 -0
  155. package/lib/dist/extraction/languages/objc.d.ts +3 -0
  156. package/lib/dist/extraction/languages/objc.d.ts.map +1 -0
  157. package/lib/dist/extraction/languages/objc.js +175 -0
  158. package/lib/dist/extraction/languages/objc.js.map +1 -0
  159. package/lib/dist/extraction/languages/pascal.d.ts +3 -0
  160. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -0
  161. package/lib/dist/extraction/languages/pascal.js +77 -0
  162. package/lib/dist/extraction/languages/pascal.js.map +1 -0
  163. package/lib/dist/extraction/languages/php.d.ts +3 -0
  164. package/lib/dist/extraction/languages/php.d.ts.map +1 -0
  165. package/lib/dist/extraction/languages/php.js +196 -0
  166. package/lib/dist/extraction/languages/php.js.map +1 -0
  167. package/lib/dist/extraction/languages/python.d.ts +3 -0
  168. package/lib/dist/extraction/languages/python.d.ts.map +1 -0
  169. package/lib/dist/extraction/languages/python.js +56 -0
  170. package/lib/dist/extraction/languages/python.js.map +1 -0
  171. package/lib/dist/extraction/languages/r.d.ts +3 -0
  172. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  173. package/lib/dist/extraction/languages/r.js +314 -0
  174. package/lib/dist/extraction/languages/r.js.map +1 -0
  175. package/lib/dist/extraction/languages/ruby.d.ts +3 -0
  176. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -0
  177. package/lib/dist/extraction/languages/ruby.js +149 -0
  178. package/lib/dist/extraction/languages/ruby.js.map +1 -0
  179. package/lib/dist/extraction/languages/rust.d.ts +3 -0
  180. package/lib/dist/extraction/languages/rust.d.ts.map +1 -0
  181. package/lib/dist/extraction/languages/rust.js +142 -0
  182. package/lib/dist/extraction/languages/rust.js.map +1 -0
  183. package/lib/dist/extraction/languages/scala.d.ts +3 -0
  184. package/lib/dist/extraction/languages/scala.d.ts.map +1 -0
  185. package/lib/dist/extraction/languages/scala.js +209 -0
  186. package/lib/dist/extraction/languages/scala.js.map +1 -0
  187. package/lib/dist/extraction/languages/solidity.d.ts +3 -0
  188. package/lib/dist/extraction/languages/solidity.d.ts.map +1 -0
  189. package/lib/dist/extraction/languages/solidity.js +293 -0
  190. package/lib/dist/extraction/languages/solidity.js.map +1 -0
  191. package/lib/dist/extraction/languages/swift.d.ts +3 -0
  192. package/lib/dist/extraction/languages/swift.d.ts.map +1 -0
  193. package/lib/dist/extraction/languages/swift.js +152 -0
  194. package/lib/dist/extraction/languages/swift.js.map +1 -0
  195. package/lib/dist/extraction/languages/terraform.d.ts +3 -0
  196. package/lib/dist/extraction/languages/terraform.d.ts.map +1 -0
  197. package/lib/dist/extraction/languages/terraform.js +641 -0
  198. package/lib/dist/extraction/languages/terraform.js.map +1 -0
  199. package/lib/dist/extraction/languages/typescript.d.ts +16 -0
  200. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -0
  201. package/lib/dist/extraction/languages/typescript.js +167 -0
  202. package/lib/dist/extraction/languages/typescript.js.map +1 -0
  203. package/lib/dist/extraction/languages/vbnet.d.ts +11 -0
  204. package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -0
  205. package/lib/dist/extraction/languages/vbnet.js +141 -0
  206. package/lib/dist/extraction/languages/vbnet.js.map +1 -0
  207. package/lib/dist/extraction/liquid-extractor.d.ts +59 -0
  208. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -0
  209. package/lib/dist/extraction/liquid-extractor.js +357 -0
  210. package/lib/dist/extraction/liquid-extractor.js.map +1 -0
  211. package/lib/dist/extraction/mybatis-extractor.d.ts +68 -0
  212. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  213. package/lib/dist/extraction/mybatis-extractor.js +300 -0
  214. package/lib/dist/extraction/mybatis-extractor.js.map +1 -0
  215. package/lib/dist/extraction/parse-pool.d.ts +126 -0
  216. package/lib/dist/extraction/parse-pool.d.ts.map +1 -0
  217. package/lib/dist/extraction/parse-pool.js +319 -0
  218. package/lib/dist/extraction/parse-pool.js.map +1 -0
  219. package/lib/dist/extraction/parse-worker.d.ts +8 -0
  220. package/lib/dist/extraction/parse-worker.d.ts.map +1 -0
  221. package/lib/dist/extraction/parse-worker.js +97 -0
  222. package/lib/dist/extraction/parse-worker.js.map +1 -0
  223. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  224. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  225. package/lib/dist/extraction/razor-extractor.js +285 -0
  226. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  227. package/lib/dist/extraction/svelte-extractor.d.ts +56 -0
  228. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -0
  229. package/lib/dist/extraction/svelte-extractor.js +275 -0
  230. package/lib/dist/extraction/svelte-extractor.js.map +1 -0
  231. package/lib/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  232. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  233. package/lib/dist/extraction/tree-sitter-helpers.js +153 -0
  234. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -0
  235. package/lib/dist/extraction/tree-sitter-types.d.ts +258 -0
  236. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  237. package/lib/dist/extraction/tree-sitter-types.js +10 -0
  238. package/lib/dist/extraction/tree-sitter-types.js.map +1 -0
  239. package/lib/dist/extraction/tree-sitter.d.ts +706 -0
  240. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -0
  241. package/lib/dist/extraction/tree-sitter.js +6506 -0
  242. package/lib/dist/extraction/tree-sitter.js.map +1 -0
  243. package/lib/dist/extraction/vue-extractor.d.ts +51 -0
  244. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -0
  245. package/lib/dist/extraction/vue-extractor.js +254 -0
  246. package/lib/dist/extraction/vue-extractor.js.map +1 -0
  247. package/lib/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  248. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  249. package/lib/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  250. package/lib/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  251. package/lib/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  252. package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  253. package/lib/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  254. package/lib/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  255. package/lib/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  256. package/lib/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  257. package/lib/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  258. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  259. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  260. package/lib/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  261. package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  262. package/lib/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  263. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  264. package/lib/dist/extraction/wasm-runtime-flags.js +106 -0
  265. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -0
  266. package/lib/dist/graph/index.d.ts +8 -0
  267. package/lib/dist/graph/index.d.ts.map +1 -0
  268. package/lib/dist/graph/index.js +13 -0
  269. package/lib/dist/graph/index.js.map +1 -0
  270. package/lib/dist/graph/queries.d.ts +106 -0
  271. package/lib/dist/graph/queries.d.ts.map +1 -0
  272. package/lib/dist/graph/queries.js +339 -0
  273. package/lib/dist/graph/queries.js.map +1 -0
  274. package/lib/dist/graph/traversal.d.ts +127 -0
  275. package/lib/dist/graph/traversal.d.ts.map +1 -0
  276. package/lib/dist/graph/traversal.js +599 -0
  277. package/lib/dist/graph/traversal.js.map +1 -0
  278. package/lib/dist/index.d.ts +642 -0
  279. package/lib/dist/index.d.ts.map +1 -0
  280. package/lib/dist/index.js +1387 -0
  281. package/lib/dist/index.js.map +1 -0
  282. package/lib/dist/installer/config-writer.d.ts +28 -0
  283. package/lib/dist/installer/config-writer.d.ts.map +1 -0
  284. package/lib/dist/installer/config-writer.js +91 -0
  285. package/lib/dist/installer/config-writer.js.map +1 -0
  286. package/lib/dist/installer/index.d.ts +100 -0
  287. package/lib/dist/installer/index.d.ts.map +1 -0
  288. package/lib/dist/installer/index.js +526 -0
  289. package/lib/dist/installer/index.js.map +1 -0
  290. package/lib/dist/installer/instructions-template.d.ts +41 -0
  291. package/lib/dist/installer/instructions-template.d.ts.map +1 -0
  292. package/lib/dist/installer/instructions-template.js +53 -0
  293. package/lib/dist/installer/instructions-template.js.map +1 -0
  294. package/lib/dist/installer/targets/antigravity.d.ts +57 -0
  295. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -0
  296. package/lib/dist/installer/targets/antigravity.js +308 -0
  297. package/lib/dist/installer/targets/antigravity.js.map +1 -0
  298. package/lib/dist/installer/targets/claude.d.ts +62 -0
  299. package/lib/dist/installer/targets/claude.d.ts.map +1 -0
  300. package/lib/dist/installer/targets/claude.js +454 -0
  301. package/lib/dist/installer/targets/claude.js.map +1 -0
  302. package/lib/dist/installer/targets/codex.d.ts +18 -0
  303. package/lib/dist/installer/targets/codex.d.ts.map +1 -0
  304. package/lib/dist/installer/targets/codex.js +185 -0
  305. package/lib/dist/installer/targets/codex.js.map +1 -0
  306. package/lib/dist/installer/targets/cursor.d.ts +35 -0
  307. package/lib/dist/installer/targets/cursor.d.ts.map +1 -0
  308. package/lib/dist/installer/targets/cursor.js +254 -0
  309. package/lib/dist/installer/targets/cursor.js.map +1 -0
  310. package/lib/dist/installer/targets/gemini.d.ts +26 -0
  311. package/lib/dist/installer/targets/gemini.d.ts.map +1 -0
  312. package/lib/dist/installer/targets/gemini.js +165 -0
  313. package/lib/dist/installer/targets/gemini.js.map +1 -0
  314. package/lib/dist/installer/targets/hermes.d.ts +18 -0
  315. package/lib/dist/installer/targets/hermes.d.ts.map +1 -0
  316. package/lib/dist/installer/targets/hermes.js +359 -0
  317. package/lib/dist/installer/targets/hermes.js.map +1 -0
  318. package/lib/dist/installer/targets/kiro.d.ts +27 -0
  319. package/lib/dist/installer/targets/kiro.d.ts.map +1 -0
  320. package/lib/dist/installer/targets/kiro.js +178 -0
  321. package/lib/dist/installer/targets/kiro.js.map +1 -0
  322. package/lib/dist/installer/targets/opencode.d.ts +38 -0
  323. package/lib/dist/installer/targets/opencode.d.ts.map +1 -0
  324. package/lib/dist/installer/targets/opencode.js +288 -0
  325. package/lib/dist/installer/targets/opencode.js.map +1 -0
  326. package/lib/dist/installer/targets/registry.d.ts +35 -0
  327. package/lib/dist/installer/targets/registry.d.ts.map +1 -0
  328. package/lib/dist/installer/targets/registry.js +91 -0
  329. package/lib/dist/installer/targets/registry.js.map +1 -0
  330. package/lib/dist/installer/targets/shared.d.ts +101 -0
  331. package/lib/dist/installer/targets/shared.d.ts.map +1 -0
  332. package/lib/dist/installer/targets/shared.js +264 -0
  333. package/lib/dist/installer/targets/shared.js.map +1 -0
  334. package/lib/dist/installer/targets/toml.d.ts +52 -0
  335. package/lib/dist/installer/targets/toml.d.ts.map +1 -0
  336. package/lib/dist/installer/targets/toml.js +147 -0
  337. package/lib/dist/installer/targets/toml.js.map +1 -0
  338. package/lib/dist/installer/targets/types.d.ts +108 -0
  339. package/lib/dist/installer/targets/types.d.ts.map +1 -0
  340. package/lib/dist/installer/targets/types.js +16 -0
  341. package/lib/dist/installer/targets/types.js.map +1 -0
  342. package/lib/dist/mcp/daemon-manager.d.ts +42 -0
  343. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -0
  344. package/lib/dist/mcp/daemon-manager.js +129 -0
  345. package/lib/dist/mcp/daemon-manager.js.map +1 -0
  346. package/lib/dist/mcp/daemon-paths.d.ts +73 -0
  347. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -0
  348. package/lib/dist/mcp/daemon-paths.js +165 -0
  349. package/lib/dist/mcp/daemon-paths.js.map +1 -0
  350. package/lib/dist/mcp/daemon-registry.d.ts +47 -0
  351. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -0
  352. package/lib/dist/mcp/daemon-registry.js +233 -0
  353. package/lib/dist/mcp/daemon-registry.js.map +1 -0
  354. package/lib/dist/mcp/daemon.d.ts +290 -0
  355. package/lib/dist/mcp/daemon.d.ts.map +1 -0
  356. package/lib/dist/mcp/daemon.js +840 -0
  357. package/lib/dist/mcp/daemon.js.map +1 -0
  358. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  359. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  360. package/lib/dist/mcp/dynamic-boundaries.js +360 -0
  361. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  362. package/lib/dist/mcp/early-ppid.d.ts +26 -0
  363. package/lib/dist/mcp/early-ppid.d.ts.map +1 -0
  364. package/lib/dist/mcp/early-ppid.js +29 -0
  365. package/lib/dist/mcp/early-ppid.js.map +1 -0
  366. package/lib/dist/mcp/engine.d.ts +122 -0
  367. package/lib/dist/mcp/engine.d.ts.map +1 -0
  368. package/lib/dist/mcp/engine.js +350 -0
  369. package/lib/dist/mcp/engine.js.map +1 -0
  370. package/lib/dist/mcp/index.d.ts +113 -0
  371. package/lib/dist/mcp/index.d.ts.map +1 -0
  372. package/lib/dist/mcp/index.js +498 -0
  373. package/lib/dist/mcp/index.js.map +1 -0
  374. package/lib/dist/mcp/liveness-watchdog.d.ts +18 -0
  375. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  376. package/lib/dist/mcp/liveness-watchdog.js +207 -0
  377. package/lib/dist/mcp/liveness-watchdog.js.map +1 -0
  378. package/lib/dist/mcp/ppid-watchdog.d.ts +62 -0
  379. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  380. package/lib/dist/mcp/ppid-watchdog.js +64 -0
  381. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  382. package/lib/dist/mcp/proxy.d.ts +87 -0
  383. package/lib/dist/mcp/proxy.d.ts.map +1 -0
  384. package/lib/dist/mcp/proxy.js +659 -0
  385. package/lib/dist/mcp/proxy.js.map +1 -0
  386. package/lib/dist/mcp/query-pool.d.ts +94 -0
  387. package/lib/dist/mcp/query-pool.d.ts.map +1 -0
  388. package/lib/dist/mcp/query-pool.js +297 -0
  389. package/lib/dist/mcp/query-pool.js.map +1 -0
  390. package/lib/dist/mcp/query-worker.d.ts +24 -0
  391. package/lib/dist/mcp/query-worker.d.ts.map +1 -0
  392. package/lib/dist/mcp/query-worker.js +87 -0
  393. package/lib/dist/mcp/query-worker.js.map +1 -0
  394. package/lib/dist/mcp/server-instructions.d.ts +34 -0
  395. package/lib/dist/mcp/server-instructions.d.ts.map +1 -0
  396. package/lib/dist/mcp/server-instructions.js +106 -0
  397. package/lib/dist/mcp/server-instructions.js.map +1 -0
  398. package/lib/dist/mcp/session.d.ts +79 -0
  399. package/lib/dist/mcp/session.d.ts.map +1 -0
  400. package/lib/dist/mcp/session.js +330 -0
  401. package/lib/dist/mcp/session.js.map +1 -0
  402. package/lib/dist/mcp/startup-handshake.d.ts +44 -0
  403. package/lib/dist/mcp/startup-handshake.d.ts.map +1 -0
  404. package/lib/dist/mcp/startup-handshake.js +73 -0
  405. package/lib/dist/mcp/startup-handshake.js.map +1 -0
  406. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  407. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  408. package/lib/dist/mcp/stdin-teardown.js +49 -0
  409. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  410. package/lib/dist/mcp/tools.d.ts +613 -0
  411. package/lib/dist/mcp/tools.d.ts.map +1 -0
  412. package/lib/dist/mcp/tools.js +4424 -0
  413. package/lib/dist/mcp/tools.js.map +1 -0
  414. package/lib/dist/mcp/transport.d.ts +188 -0
  415. package/lib/dist/mcp/transport.d.ts.map +1 -0
  416. package/lib/dist/mcp/transport.js +359 -0
  417. package/lib/dist/mcp/transport.js.map +1 -0
  418. package/lib/dist/mcp/version.d.ts +19 -0
  419. package/lib/dist/mcp/version.d.ts.map +1 -0
  420. package/lib/dist/mcp/version.js +71 -0
  421. package/lib/dist/mcp/version.js.map +1 -0
  422. package/lib/dist/project-config.d.ts +94 -0
  423. package/lib/dist/project-config.d.ts.map +1 -0
  424. package/lib/dist/project-config.js +374 -0
  425. package/lib/dist/project-config.js.map +1 -0
  426. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
  427. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  428. package/lib/dist/resolution/c-fnptr-synthesizer.js +1038 -0
  429. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  430. package/lib/dist/resolution/callback-synthesizer.d.ts +15 -0
  431. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  432. package/lib/dist/resolution/callback-synthesizer.js +3658 -0
  433. package/lib/dist/resolution/callback-synthesizer.js.map +1 -0
  434. package/lib/dist/resolution/cooperative-yield.d.ts +32 -0
  435. package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -0
  436. package/lib/dist/resolution/cooperative-yield.js +42 -0
  437. package/lib/dist/resolution/cooperative-yield.js.map +1 -0
  438. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  439. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  440. package/lib/dist/resolution/frameworks/astro.js +169 -0
  441. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  442. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  443. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  444. package/lib/dist/resolution/frameworks/cargo-workspace.js +225 -0
  445. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  446. package/lib/dist/resolution/frameworks/cics.d.ts +20 -0
  447. package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -0
  448. package/lib/dist/resolution/frameworks/cics.js +90 -0
  449. package/lib/dist/resolution/frameworks/cics.js.map +1 -0
  450. package/lib/dist/resolution/frameworks/csharp.d.ts +8 -0
  451. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  452. package/lib/dist/resolution/frameworks/csharp.js +241 -0
  453. package/lib/dist/resolution/frameworks/csharp.js.map +1 -0
  454. package/lib/dist/resolution/frameworks/drupal.d.ts +51 -0
  455. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  456. package/lib/dist/resolution/frameworks/drupal.js +367 -0
  457. package/lib/dist/resolution/frameworks/drupal.js.map +1 -0
  458. package/lib/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  459. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  460. package/lib/dist/resolution/frameworks/expo-modules.js +148 -0
  461. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -0
  462. package/lib/dist/resolution/frameworks/express.d.ts +8 -0
  463. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -0
  464. package/lib/dist/resolution/frameworks/express.js +308 -0
  465. package/lib/dist/resolution/frameworks/express.js.map +1 -0
  466. package/lib/dist/resolution/frameworks/fabric.d.ts +3 -0
  467. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  468. package/lib/dist/resolution/frameworks/fabric.js +354 -0
  469. package/lib/dist/resolution/frameworks/fabric.js.map +1 -0
  470. package/lib/dist/resolution/frameworks/go.d.ts +8 -0
  471. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -0
  472. package/lib/dist/resolution/frameworks/go.js +161 -0
  473. package/lib/dist/resolution/frameworks/go.js.map +1 -0
  474. package/lib/dist/resolution/frameworks/goframe.d.ts +41 -0
  475. package/lib/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  476. package/lib/dist/resolution/frameworks/goframe.js +112 -0
  477. package/lib/dist/resolution/frameworks/goframe.js.map +1 -0
  478. package/lib/dist/resolution/frameworks/index.d.ts +50 -0
  479. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -0
  480. package/lib/dist/resolution/frameworks/index.js +175 -0
  481. package/lib/dist/resolution/frameworks/index.js.map +1 -0
  482. package/lib/dist/resolution/frameworks/java.d.ts +8 -0
  483. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -0
  484. package/lib/dist/resolution/frameworks/java.js +517 -0
  485. package/lib/dist/resolution/frameworks/java.js.map +1 -0
  486. package/lib/dist/resolution/frameworks/laravel.d.ts +13 -0
  487. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  488. package/lib/dist/resolution/frameworks/laravel.js +257 -0
  489. package/lib/dist/resolution/frameworks/laravel.js.map +1 -0
  490. package/lib/dist/resolution/frameworks/nestjs.d.ts +26 -0
  491. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  492. package/lib/dist/resolution/frameworks/nestjs.js +698 -0
  493. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -0
  494. package/lib/dist/resolution/frameworks/play.d.ts +19 -0
  495. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -0
  496. package/lib/dist/resolution/frameworks/play.js +111 -0
  497. package/lib/dist/resolution/frameworks/play.js.map +1 -0
  498. package/lib/dist/resolution/frameworks/python.d.ts +10 -0
  499. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -0
  500. package/lib/dist/resolution/frameworks/python.js +400 -0
  501. package/lib/dist/resolution/frameworks/python.js.map +1 -0
  502. package/lib/dist/resolution/frameworks/react-native.d.ts +3 -0
  503. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  504. package/lib/dist/resolution/frameworks/react-native.js +410 -0
  505. package/lib/dist/resolution/frameworks/react-native.js.map +1 -0
  506. package/lib/dist/resolution/frameworks/react.d.ts +8 -0
  507. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -0
  508. package/lib/dist/resolution/frameworks/react.js +334 -0
  509. package/lib/dist/resolution/frameworks/react.js.map +1 -0
  510. package/lib/dist/resolution/frameworks/ruby.d.ts +8 -0
  511. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  512. package/lib/dist/resolution/frameworks/ruby.js +302 -0
  513. package/lib/dist/resolution/frameworks/ruby.js.map +1 -0
  514. package/lib/dist/resolution/frameworks/rust.d.ts +8 -0
  515. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -0
  516. package/lib/dist/resolution/frameworks/rust.js +304 -0
  517. package/lib/dist/resolution/frameworks/rust.js.map +1 -0
  518. package/lib/dist/resolution/frameworks/svelte.d.ts +9 -0
  519. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  520. package/lib/dist/resolution/frameworks/svelte.js +253 -0
  521. package/lib/dist/resolution/frameworks/svelte.js.map +1 -0
  522. package/lib/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  523. package/lib/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  524. package/lib/dist/resolution/frameworks/swift-objc.js +252 -0
  525. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -0
  526. package/lib/dist/resolution/frameworks/swift.d.ts +10 -0
  527. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -0
  528. package/lib/dist/resolution/frameworks/swift.js +400 -0
  529. package/lib/dist/resolution/frameworks/swift.js.map +1 -0
  530. package/lib/dist/resolution/frameworks/terraform.d.ts +38 -0
  531. package/lib/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  532. package/lib/dist/resolution/frameworks/terraform.js +277 -0
  533. package/lib/dist/resolution/frameworks/terraform.js.map +1 -0
  534. package/lib/dist/resolution/frameworks/vue.d.ts +9 -0
  535. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -0
  536. package/lib/dist/resolution/frameworks/vue.js +303 -0
  537. package/lib/dist/resolution/frameworks/vue.js.map +1 -0
  538. package/lib/dist/resolution/go-module.d.ts +26 -0
  539. package/lib/dist/resolution/go-module.d.ts.map +1 -0
  540. package/lib/dist/resolution/go-module.js +78 -0
  541. package/lib/dist/resolution/go-module.js.map +1 -0
  542. package/lib/dist/resolution/goframe-synthesizer.d.ts +28 -0
  543. package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  544. package/lib/dist/resolution/goframe-synthesizer.js +158 -0
  545. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -0
  546. package/lib/dist/resolution/import-resolver.d.ts +85 -0
  547. package/lib/dist/resolution/import-resolver.d.ts.map +1 -0
  548. package/lib/dist/resolution/import-resolver.js +1974 -0
  549. package/lib/dist/resolution/import-resolver.js.map +1 -0
  550. package/lib/dist/resolution/index.d.ts +238 -0
  551. package/lib/dist/resolution/index.d.ts.map +1 -0
  552. package/lib/dist/resolution/index.js +1633 -0
  553. package/lib/dist/resolution/index.js.map +1 -0
  554. package/lib/dist/resolution/lru-cache.d.ts +24 -0
  555. package/lib/dist/resolution/lru-cache.d.ts.map +1 -0
  556. package/lib/dist/resolution/lru-cache.js +62 -0
  557. package/lib/dist/resolution/lru-cache.js.map +1 -0
  558. package/lib/dist/resolution/name-matcher.d.ts +112 -0
  559. package/lib/dist/resolution/name-matcher.d.ts.map +1 -0
  560. package/lib/dist/resolution/name-matcher.js +1701 -0
  561. package/lib/dist/resolution/name-matcher.js.map +1 -0
  562. package/lib/dist/resolution/path-aliases.d.ts +68 -0
  563. package/lib/dist/resolution/path-aliases.d.ts.map +1 -0
  564. package/lib/dist/resolution/path-aliases.js +238 -0
  565. package/lib/dist/resolution/path-aliases.js.map +1 -0
  566. package/lib/dist/resolution/strip-comments.d.ts +27 -0
  567. package/lib/dist/resolution/strip-comments.d.ts.map +1 -0
  568. package/lib/dist/resolution/strip-comments.js +492 -0
  569. package/lib/dist/resolution/strip-comments.js.map +1 -0
  570. package/lib/dist/resolution/swift-objc-bridge.d.ts +134 -0
  571. package/lib/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  572. package/lib/dist/resolution/swift-objc-bridge.js +256 -0
  573. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -0
  574. package/lib/dist/resolution/types.d.ts +253 -0
  575. package/lib/dist/resolution/types.d.ts.map +1 -0
  576. package/lib/dist/resolution/types.js +8 -0
  577. package/lib/dist/resolution/types.js.map +1 -0
  578. package/lib/dist/resolution/workspace-packages.d.ts +58 -0
  579. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  580. package/lib/dist/resolution/workspace-packages.js +346 -0
  581. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  582. package/lib/dist/search/identifier-segments.d.ts +60 -0
  583. package/lib/dist/search/identifier-segments.d.ts.map +1 -0
  584. package/lib/dist/search/identifier-segments.js +176 -0
  585. package/lib/dist/search/identifier-segments.js.map +1 -0
  586. package/lib/dist/search/query-parser.d.ts +57 -0
  587. package/lib/dist/search/query-parser.d.ts.map +1 -0
  588. package/lib/dist/search/query-parser.js +177 -0
  589. package/lib/dist/search/query-parser.js.map +1 -0
  590. package/lib/dist/search/query-utils.d.ts +87 -0
  591. package/lib/dist/search/query-utils.d.ts.map +1 -0
  592. package/lib/dist/search/query-utils.js +449 -0
  593. package/lib/dist/search/query-utils.js.map +1 -0
  594. package/lib/dist/sync/git-hooks.d.ts +45 -0
  595. package/lib/dist/sync/git-hooks.d.ts.map +1 -0
  596. package/lib/dist/sync/git-hooks.js +227 -0
  597. package/lib/dist/sync/git-hooks.js.map +1 -0
  598. package/lib/dist/sync/index.d.ts +19 -0
  599. package/lib/dist/sync/index.d.ts.map +1 -0
  600. package/lib/dist/sync/index.js +35 -0
  601. package/lib/dist/sync/index.js.map +1 -0
  602. package/lib/dist/sync/watch-policy.d.ts +48 -0
  603. package/lib/dist/sync/watch-policy.d.ts.map +1 -0
  604. package/lib/dist/sync/watch-policy.js +124 -0
  605. package/lib/dist/sync/watch-policy.js.map +1 -0
  606. package/lib/dist/sync/watcher.d.ts +355 -0
  607. package/lib/dist/sync/watcher.d.ts.map +1 -0
  608. package/lib/dist/sync/watcher.js +848 -0
  609. package/lib/dist/sync/watcher.js.map +1 -0
  610. package/lib/dist/sync/worktree.d.ts +63 -0
  611. package/lib/dist/sync/worktree.d.ts.map +1 -0
  612. package/lib/dist/sync/worktree.js +182 -0
  613. package/lib/dist/sync/worktree.js.map +1 -0
  614. package/lib/dist/telemetry/index.d.ts +143 -0
  615. package/lib/dist/telemetry/index.d.ts.map +1 -0
  616. package/lib/dist/telemetry/index.js +541 -0
  617. package/lib/dist/telemetry/index.js.map +1 -0
  618. package/lib/dist/types.d.ts +415 -0
  619. package/lib/dist/types.d.ts.map +1 -0
  620. package/lib/dist/types.js +91 -0
  621. package/lib/dist/types.js.map +1 -0
  622. package/lib/dist/ui/glyphs.d.ts +42 -0
  623. package/lib/dist/ui/glyphs.d.ts.map +1 -0
  624. package/lib/dist/ui/glyphs.js +78 -0
  625. package/lib/dist/ui/glyphs.js.map +1 -0
  626. package/lib/dist/ui/shimmer-progress.d.ts +11 -0
  627. package/lib/dist/ui/shimmer-progress.d.ts.map +1 -0
  628. package/lib/dist/ui/shimmer-progress.js +90 -0
  629. package/lib/dist/ui/shimmer-progress.js.map +1 -0
  630. package/lib/dist/ui/shimmer-worker.d.ts +2 -0
  631. package/lib/dist/ui/shimmer-worker.d.ts.map +1 -0
  632. package/lib/dist/ui/shimmer-worker.js +118 -0
  633. package/lib/dist/ui/shimmer-worker.js.map +1 -0
  634. package/lib/dist/ui/types.d.ts +17 -0
  635. package/lib/dist/ui/types.d.ts.map +1 -0
  636. package/lib/dist/ui/types.js +3 -0
  637. package/lib/dist/ui/types.js.map +1 -0
  638. package/lib/dist/upgrade/index.d.ts +132 -0
  639. package/lib/dist/upgrade/index.d.ts.map +1 -0
  640. package/lib/dist/upgrade/index.js +498 -0
  641. package/lib/dist/upgrade/index.js.map +1 -0
  642. package/lib/dist/utils.d.ts +224 -0
  643. package/lib/dist/utils.d.ts.map +1 -0
  644. package/lib/dist/utils.js +583 -0
  645. package/lib/dist/utils.js.map +1 -0
  646. package/lib/node_modules/.package-lock.json +125 -0
  647. package/lib/node_modules/@clack/core/CHANGELOG.md +348 -0
  648. package/lib/node_modules/@clack/core/LICENSE +9 -0
  649. package/lib/node_modules/@clack/core/README.md +22 -0
  650. package/lib/node_modules/@clack/core/dist/index.d.mts +363 -0
  651. package/lib/node_modules/@clack/core/dist/index.mjs +17 -0
  652. package/lib/node_modules/@clack/core/dist/index.mjs.map +1 -0
  653. package/lib/node_modules/@clack/core/package.json +63 -0
  654. package/lib/node_modules/@clack/prompts/CHANGELOG.md +591 -0
  655. package/lib/node_modules/@clack/prompts/LICENSE +9 -0
  656. package/lib/node_modules/@clack/prompts/README.md +375 -0
  657. package/lib/node_modules/@clack/prompts/dist/index.d.mts +396 -0
  658. package/lib/node_modules/@clack/prompts/dist/index.mjs +144 -0
  659. package/lib/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
  660. package/lib/node_modules/@clack/prompts/package.json +68 -0
  661. package/lib/node_modules/commander/LICENSE +22 -0
  662. package/lib/node_modules/commander/Readme.md +1176 -0
  663. package/lib/node_modules/commander/esm.mjs +16 -0
  664. package/lib/node_modules/commander/index.js +24 -0
  665. package/lib/node_modules/commander/lib/argument.js +150 -0
  666. package/lib/node_modules/commander/lib/command.js +2777 -0
  667. package/lib/node_modules/commander/lib/error.js +39 -0
  668. package/lib/node_modules/commander/lib/help.js +747 -0
  669. package/lib/node_modules/commander/lib/option.js +380 -0
  670. package/lib/node_modules/commander/lib/suggestSimilar.js +101 -0
  671. package/lib/node_modules/commander/package-support.json +19 -0
  672. package/lib/node_modules/commander/package.json +82 -0
  673. package/lib/node_modules/commander/typings/esm.d.mts +3 -0
  674. package/lib/node_modules/commander/typings/index.d.ts +1113 -0
  675. package/lib/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  676. package/lib/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  677. package/lib/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  678. package/lib/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  679. package/lib/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  680. package/lib/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  681. package/lib/node_modules/fast-string-truncated-width/license +21 -0
  682. package/lib/node_modules/fast-string-truncated-width/package.json +35 -0
  683. package/lib/node_modules/fast-string-truncated-width/readme.md +59 -0
  684. package/lib/node_modules/fast-string-width/dist/index.d.ts +4 -0
  685. package/lib/node_modules/fast-string-width/dist/index.js +14 -0
  686. package/lib/node_modules/fast-string-width/license +21 -0
  687. package/lib/node_modules/fast-string-width/package.json +34 -0
  688. package/lib/node_modules/fast-string-width/readme.md +42 -0
  689. package/lib/node_modules/fast-wrap-ansi/LICENSE +23 -0
  690. package/lib/node_modules/fast-wrap-ansi/README.md +26 -0
  691. package/lib/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  692. package/lib/node_modules/fast-wrap-ansi/lib/main.js +219 -0
  693. package/lib/node_modules/fast-wrap-ansi/lib/main.js.map +1 -0
  694. package/lib/node_modules/fast-wrap-ansi/package.json +51 -0
  695. package/lib/node_modules/ignore/LICENSE-MIT +21 -0
  696. package/lib/node_modules/ignore/README.md +452 -0
  697. package/lib/node_modules/ignore/index.d.ts +81 -0
  698. package/lib/node_modules/ignore/index.js +784 -0
  699. package/lib/node_modules/ignore/legacy.js +681 -0
  700. package/lib/node_modules/ignore/package.json +87 -0
  701. package/lib/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  702. package/lib/node_modules/jsonc-parser/LICENSE.md +21 -0
  703. package/lib/node_modules/jsonc-parser/README.md +364 -0
  704. package/lib/node_modules/jsonc-parser/SECURITY.md +41 -0
  705. package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  706. package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  707. package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  708. package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  709. package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  710. package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  711. package/lib/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  712. package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  713. package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  714. package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  715. package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  716. package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  717. package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  718. package/lib/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  719. package/lib/node_modules/jsonc-parser/package.json +37 -0
  720. package/lib/node_modules/picomatch/LICENSE +21 -0
  721. package/lib/node_modules/picomatch/README.md +738 -0
  722. package/lib/node_modules/picomatch/index.js +17 -0
  723. package/lib/node_modules/picomatch/lib/constants.js +180 -0
  724. package/lib/node_modules/picomatch/lib/parse.js +1085 -0
  725. package/lib/node_modules/picomatch/lib/picomatch.js +341 -0
  726. package/lib/node_modules/picomatch/lib/scan.js +391 -0
  727. package/lib/node_modules/picomatch/lib/utils.js +72 -0
  728. package/lib/node_modules/picomatch/package.json +83 -0
  729. package/lib/node_modules/picomatch/posix.js +3 -0
  730. package/lib/node_modules/sisteransi/license +21 -0
  731. package/lib/node_modules/sisteransi/package.json +34 -0
  732. package/lib/node_modules/sisteransi/readme.md +113 -0
  733. package/lib/node_modules/sisteransi/src/index.js +58 -0
  734. package/lib/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  735. package/lib/node_modules/tree-sitter-wasms/LICENSE +24 -0
  736. package/lib/node_modules/tree-sitter-wasms/README.md +23 -0
  737. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  738. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  739. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  740. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  741. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  742. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  743. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  744. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  745. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  746. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  747. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  748. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  749. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  750. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  751. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  752. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  753. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  754. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  755. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  756. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  757. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  758. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  759. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  760. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  761. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  762. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  763. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  764. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  765. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  766. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  767. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  768. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  769. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  770. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  771. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  772. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  773. package/lib/node_modules/tree-sitter-wasms/package.json +64 -0
  774. package/lib/node_modules/web-tree-sitter/LICENSE +21 -0
  775. package/lib/node_modules/web-tree-sitter/README.md +269 -0
  776. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs +4558 -0
  777. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +7 -0
  778. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js +4516 -0
  779. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js.map +7 -0
  780. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
  781. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +31 -0
  782. package/lib/node_modules/web-tree-sitter/lib/alloc.c +48 -0
  783. package/lib/node_modules/web-tree-sitter/lib/alloc.h +41 -0
  784. package/lib/node_modules/web-tree-sitter/lib/array.h +291 -0
  785. package/lib/node_modules/web-tree-sitter/lib/atomic.h +68 -0
  786. package/lib/node_modules/web-tree-sitter/lib/clock.h +146 -0
  787. package/lib/node_modules/web-tree-sitter/lib/error_costs.h +11 -0
  788. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.c +523 -0
  789. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.h +36 -0
  790. package/lib/node_modules/web-tree-sitter/lib/host.h +21 -0
  791. package/lib/node_modules/web-tree-sitter/lib/language.c +293 -0
  792. package/lib/node_modules/web-tree-sitter/lib/language.h +293 -0
  793. package/lib/node_modules/web-tree-sitter/lib/length.h +52 -0
  794. package/lib/node_modules/web-tree-sitter/lib/lexer.c +483 -0
  795. package/lib/node_modules/web-tree-sitter/lib/lexer.h +54 -0
  796. package/lib/node_modules/web-tree-sitter/lib/lib.c +12 -0
  797. package/lib/node_modules/web-tree-sitter/lib/node.c +875 -0
  798. package/lib/node_modules/web-tree-sitter/lib/parser.c +2297 -0
  799. package/lib/node_modules/web-tree-sitter/lib/parser.h +286 -0
  800. package/lib/node_modules/web-tree-sitter/lib/point.h +48 -0
  801. package/lib/node_modules/web-tree-sitter/lib/query.c +4347 -0
  802. package/lib/node_modules/web-tree-sitter/lib/reduce_action.h +34 -0
  803. package/lib/node_modules/web-tree-sitter/lib/reusable_node.h +95 -0
  804. package/lib/node_modules/web-tree-sitter/lib/stack.c +912 -0
  805. package/lib/node_modules/web-tree-sitter/lib/stack.h +133 -0
  806. package/lib/node_modules/web-tree-sitter/lib/subtree.c +1034 -0
  807. package/lib/node_modules/web-tree-sitter/lib/subtree.h +399 -0
  808. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.c +987 -0
  809. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
  810. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm +0 -0
  811. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
  812. package/lib/node_modules/web-tree-sitter/lib/tree.c +170 -0
  813. package/lib/node_modules/web-tree-sitter/lib/tree.h +31 -0
  814. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.c +716 -0
  815. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.h +48 -0
  816. package/lib/node_modules/web-tree-sitter/lib/ts_assert.h +11 -0
  817. package/lib/node_modules/web-tree-sitter/lib/unicode.h +75 -0
  818. package/lib/node_modules/web-tree-sitter/lib/wasm_store.c +1937 -0
  819. package/lib/node_modules/web-tree-sitter/lib/wasm_store.h +31 -0
  820. package/lib/node_modules/web-tree-sitter/package.json +98 -0
  821. package/lib/node_modules/web-tree-sitter/src/bindings.ts +26 -0
  822. package/lib/node_modules/web-tree-sitter/src/constants.ts +133 -0
  823. package/lib/node_modules/web-tree-sitter/src/index.ts +31 -0
  824. package/lib/node_modules/web-tree-sitter/src/language.ts +291 -0
  825. package/lib/node_modules/web-tree-sitter/src/lookahead_iterator.ts +75 -0
  826. package/lib/node_modules/web-tree-sitter/src/marshal.ts +176 -0
  827. package/lib/node_modules/web-tree-sitter/src/node.ts +646 -0
  828. package/lib/node_modules/web-tree-sitter/src/parser.ts +325 -0
  829. package/lib/node_modules/web-tree-sitter/src/query.ts +973 -0
  830. package/lib/node_modules/web-tree-sitter/src/tree.ts +145 -0
  831. package/lib/node_modules/web-tree-sitter/src/tree_cursor.ts +318 -0
  832. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs +4031 -0
  833. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs.map +7 -0
  834. package/lib/node_modules/web-tree-sitter/tree-sitter.js +3980 -0
  835. package/lib/node_modules/web-tree-sitter/tree-sitter.js.map +7 -0
  836. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  837. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm.map +30 -0
  838. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1030 -0
  839. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +56 -0
  840. package/lib/package.json +64 -0
  841. package/node +0 -0
  842. package/package.json +17 -0
@@ -0,0 +1,3658 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.synthesizeCallbackEdges = synthesizeCallbackEdges;
4
+ const generated_detection_1 = require("../extraction/generated-detection");
5
+ const strip_comments_1 = require("./strip-comments");
6
+ const c_fnptr_synthesizer_1 = require("./c-fnptr-synthesizer");
7
+ const goframe_synthesizer_1 = require("./goframe-synthesizer");
8
+ const cooperative_yield_1 = require("./cooperative-yield");
9
+ const REGISTRAR_NAME = /^(on[A-Z]\w*|subscribe|addListener|addEventListener|register|watch|listen|addCallback)$/;
10
+ const DISPATCHER_NAME = /(emit|trigger|notify|dispatch|fire|publish|flush)/i;
11
+ const MAX_CALLBACKS_PER_CHANNEL = 40;
12
+ const EVENT_FANOUT_CAP = 6; // skip events with more handlers/dispatchers than this (too generic without type info)
13
+ const ON_RE = /\.(?:on|once|addListener)\(\s*['"]([^'"]+)['"]\s*,\s*(?:function\s+(\w+)|(?:this\.)?(\w+))/g;
14
+ const EMIT_RE = /\.(?:emit|fire|dispatchEvent)\(\s*['"]([^'"]+)['"]/g;
15
+ const SETSTATE_RE = /this\.setState\s*\(/;
16
+ const FLUTTER_SETSTATE_RE = /\bsetState\s*\(/; // Flutter: setState((){…}) / this.setState
17
+ const JSX_TAG_RE = /<([A-Z][A-Za-z0-9_]*)[\s/>]/g;
18
+ const MAX_JSX_CHILDREN = 30;
19
+ // Vue SFC templates: kebab-case child components (<el-button> → ElButton) and
20
+ // event bindings (@click="fn" / v-on:click="fn"). PascalCase children (<VPNav/>)
21
+ // are already caught by JSX_TAG_RE via the SFC component node.
22
+ const VUE_KEBAB_RE = /<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)[\s/>]/g;
23
+ // PascalCase component tags — `<MediaCard ...>`, `<NavBar/>`. HTML elements are
24
+ // lowercase, so an uppercase-initial tag is a component usage; built-ins
25
+ // (`<NuxtLink>`, `<Transition>`) simply resolve to nothing and emit no edge.
26
+ const VUE_PASCAL_RE = /<([A-Z][A-Za-z0-9]*)[\s/>]/g;
27
+ const VUE_HANDLER_RE = /(?:@|v-on:)([a-zA-Z][\w-]*)(?:\.[\w]+)*\s*=\s*"([^"]+)"/g;
28
+ // Composable/hook destructure: `const { close: closeSidebar } = useSidebarControl()`.
29
+ // Captures the destructure body + the called composable; only `use*` calls qualify.
30
+ const VUE_DESTRUCTURE_RE = /(?:const|let|var)\s*\{([^}]+)\}\s*=\s*(\w+)\s*\(/g;
31
+ // Closure-collection dynamic dispatch (language-agnostic, Swift-first). A method
32
+ // appends a closure to a collection property; another method iterates that
33
+ // property *invoking each element* (`coll.forEach { $0() }` / `{ it() }`). The
34
+ // element-invoke (`$0(` / `it(`) PROVES the collection holds closures, so pairing
35
+ // a dispatcher to same-named registrars (`.append`/`.add`/`.push`/`.insert`,
36
+ // incl. Swift `prop.write { $0.append }`) is high-precision. Cross-file/class by
37
+ // design: Alamofire appends in `DataRequest.validate` but iterates in the base
38
+ // `Request.didCompleteTask` — neither same-file nor same-class pairing reaches it.
39
+ const CC_DISPATCH_RE = /(\w+)\.forEach\s*\{\s*(?:\$0|it)\s*\(/g;
40
+ const CC_APPEND_WRITE_RE = /(\w+)\.write\s*\{\s*\$0(?:\.(\w+))?\.(?:append|add|push|insert)\s*\(/g;
41
+ const CC_APPEND_DIRECT_RE = /(\w+)\.(?:append|add|push|insert)\s*\(/g;
42
+ const CC_FANOUT_CAP = 8; // skip a field name with more dispatchers/registrars than this (too generic to pair confidently)
43
+ function kebabToPascal(s) {
44
+ return s.split('-').map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join('');
45
+ }
46
+ /**
47
+ * Nuxt auto-import name for a component, derived from its path UNDER `components/`:
48
+ * `components/media/Card.vue` → `MediaCard`, `components/base/foo/Bar.vue` →
49
+ * `BaseFooBar`. Each directory segment and the filename is PascalCased and
50
+ * concatenated; a directory whose PascalCase name prefixes the next segment is
51
+ * collapsed (Nuxt's de-dup: `base/BaseButton.vue` → `BaseButton`, not
52
+ * `BaseBaseButton`). Returns null for a flat component (`components/NavBar.vue`)
53
+ * — its node is already named by basename, so a direct tag match finds it.
54
+ */
55
+ function nuxtComponentName(filePath) {
56
+ const marker = filePath.lastIndexOf('components/');
57
+ if (marker === -1)
58
+ return null;
59
+ const rel = filePath.slice(marker + 'components/'.length).replace(/\.(vue|ts|tsx|js|jsx)$/i, '');
60
+ const segs = rel.split('/').filter(Boolean).map(kebabToPascal);
61
+ if (segs.length < 2)
62
+ return null;
63
+ const out = [];
64
+ for (const s of segs) {
65
+ const prev = out[out.length - 1];
66
+ if (prev && s.startsWith(prev))
67
+ out[out.length - 1] = s;
68
+ else
69
+ out.push(s);
70
+ }
71
+ return out.join('');
72
+ }
73
+ function sliceLines(content, startLine, endLine) {
74
+ if (!startLine || !endLine)
75
+ return null;
76
+ return content.split('\n').slice(startLine - 1, endLine).join('\n');
77
+ }
78
+ function registrarField(src) {
79
+ const m = src.match(/this\.(\w+)\.(?:add|push|set)\(/);
80
+ return m ? m[1] : null;
81
+ }
82
+ function dispatcherField(src) {
83
+ const forOf = src.match(/\bof\s+(?:Array\.from\(\s*)?this\.(\w+)/);
84
+ if (forOf && /\b\w+\s*\(/.test(src))
85
+ return forOf[1];
86
+ const forEach = src.match(/this\.(\w+)\.forEach\(/);
87
+ if (forEach)
88
+ return forEach[1];
89
+ return null;
90
+ }
91
+ const FN_KINDS = new Set(['method', 'function', 'component']);
92
+ /** Innermost function/method node whose line range contains `line`. */
93
+ function enclosingFn(nodesInFile, line) {
94
+ let best = null;
95
+ for (const n of nodesInFile) {
96
+ if (!FN_KINDS.has(n.kind))
97
+ continue;
98
+ const end = n.endLine ?? n.startLine;
99
+ if (n.startLine <= line && end >= line) {
100
+ if (!best || n.startLine >= best.startLine)
101
+ best = n; // prefer the tightest (latest-starting) encloser
102
+ }
103
+ }
104
+ return best;
105
+ }
106
+ /**
107
+ * Stream method + function nodes lazily. The synthesizers only scan-and-filter
108
+ * down to a tiny matched subset, so materializing every function/method (which
109
+ * is gigabytes on a symbol-dense project) just to iterate it once is what OOM'd
110
+ * #610. Iterating keeps memory O(1) in the node count.
111
+ */
112
+ function* methodAndFunctionNodes(queries) {
113
+ yield* queries.iterateNodesByKind('method');
114
+ yield* queries.iterateNodesByKind('function');
115
+ }
116
+ /** Phase 1: field-backed observer channels (registrar/dispatcher share a store). */
117
+ async function fieldChannelEdges(queries, ctx, onYield) {
118
+ const registrars = [];
119
+ const dispatchers = [];
120
+ let scanned = 0;
121
+ for (const m of methodAndFunctionNodes(queries)) {
122
+ if ((++scanned & 255) === 0)
123
+ await onYield(); // #1091: yield mid-scan on huge graphs
124
+ const isReg = REGISTRAR_NAME.test(m.name);
125
+ const isDisp = DISPATCHER_NAME.test(m.name);
126
+ if (!isReg && !isDisp)
127
+ continue;
128
+ const content = ctx.readFile(m.filePath);
129
+ const src = content && sliceLines(content, m.startLine, m.endLine);
130
+ if (!src)
131
+ continue;
132
+ if (isReg) {
133
+ const f = registrarField(src);
134
+ if (f)
135
+ registrars.push({ node: m, field: f });
136
+ }
137
+ if (isDisp) {
138
+ const f = dispatcherField(src);
139
+ if (f)
140
+ dispatchers.push({ node: m, field: f });
141
+ }
142
+ }
143
+ const edges = [];
144
+ const seen = new Set();
145
+ for (const reg of registrars) {
146
+ const chDispatchers = dispatchers.filter((d) => d.node.filePath === reg.node.filePath && d.field === reg.field);
147
+ if (chDispatchers.length === 0)
148
+ continue;
149
+ const argRe = new RegExp(`${reg.node.name}\\s*\\(\\s*(?:this\\.)?(\\w+)`);
150
+ let added = 0;
151
+ for (const e of queries.getIncomingEdges(reg.node.id, ['calls'])) {
152
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
153
+ break;
154
+ if (!e.line)
155
+ continue;
156
+ const caller = queries.getNodeById(e.source);
157
+ if (!caller)
158
+ continue;
159
+ const line = ctx.readFile(caller.filePath)?.split('\n')[e.line - 1];
160
+ const am = line?.match(argRe);
161
+ if (!am)
162
+ continue;
163
+ const fn = ctx.getNodesByName(am[1]).find((n) => n.kind === 'method' || n.kind === 'function');
164
+ if (!fn)
165
+ continue;
166
+ for (const disp of chDispatchers) {
167
+ if (disp.node.id === fn.id)
168
+ continue;
169
+ const key = `${disp.node.id}>${fn.id}`;
170
+ if (seen.has(key))
171
+ continue;
172
+ seen.add(key);
173
+ edges.push({
174
+ source: disp.node.id, target: fn.id, kind: 'calls', line: disp.node.startLine,
175
+ provenance: 'heuristic',
176
+ metadata: {
177
+ synthesizedBy: 'callback', via: reg.node.name, field: reg.field,
178
+ // Where the callback was wired up (`scene.onUpdate(this.triggerRender)`).
179
+ // This is the #1 thing an agent reads/greps to explain the flow — surface
180
+ // it so node/trace/context can show it without a callers() + Read round-trip.
181
+ registeredAt: `${caller.filePath}:${e.line}`,
182
+ },
183
+ });
184
+ added++;
185
+ }
186
+ }
187
+ }
188
+ return edges;
189
+ }
190
+ /**
191
+ * Closure-collection dispatch: dispatcher iterates a closure-collection property
192
+ * invoking each element; registrar appends a closure to the same-named property.
193
+ * Emits dispatcher → registrar so a flow reaches the registration site (where the
194
+ * appended closure's body — and its callers — live). High-precision: the
195
+ * dispatcher's element-invoke is the gate (a `.forEach` that does NOT invoke its
196
+ * element is ignored), so a repo with no closure-collection dispatch yields zero
197
+ * edges regardless of how many `.append`/`.push` sites it has.
198
+ *
199
+ * Pairs globally by field name (cross-file/class is required — see Alamofire's
200
+ * base-class `Request.didCompleteTask` iterating `validators` appended by the
201
+ * subclass `DataRequest.validate`), bounded by a fan-out cap so a generic field
202
+ * name shared across unrelated classes can't fan out into noise.
203
+ */
204
+ async function closureCollectionEdges(queries, ctx, onYield) {
205
+ const dispatchers = new Map(); // field → dispatcher methods + forEach line
206
+ const registrars = new Map(); // field → registrar methods + append line
207
+ const addReg = (field, node, absLine) => {
208
+ if (!field || /^\d+$/.test(field))
209
+ return; // `$0.append` mis-captures the `0`; the write-RE owns that field
210
+ const arr = registrars.get(field) ?? [];
211
+ if (!arr.some((r) => r.node.id === node.id))
212
+ arr.push({ node, line: absLine });
213
+ registrars.set(field, arr);
214
+ };
215
+ // Slices EVERY method/function's source (no cheap name-gate), so on a repo
216
+ // with a huge file this is the heaviest synthesis pass — yield mid-scan so it
217
+ // can't wedge the #850 watchdog on its own (#1091).
218
+ let scanned = 0;
219
+ for (const m of methodAndFunctionNodes(queries)) {
220
+ if ((++scanned & 127) === 0)
221
+ await onYield();
222
+ const content = ctx.readFile(m.filePath);
223
+ const src = content && sliceLines(content, m.startLine, m.endLine);
224
+ if (!src)
225
+ continue;
226
+ const hasForEach = src.includes('.forEach');
227
+ const hasAppend = src.includes('.append(') || src.includes('.add(') || src.includes('.push(') || src.includes('.insert(');
228
+ if (!hasForEach && !hasAppend)
229
+ continue;
230
+ const lineAt = (idx) => (m.startLine ?? 1) + src.slice(0, idx).split('\n').length - 1;
231
+ if (hasForEach) {
232
+ CC_DISPATCH_RE.lastIndex = 0;
233
+ let d;
234
+ while ((d = CC_DISPATCH_RE.exec(src))) {
235
+ const arr = dispatchers.get(d[1]) ?? [];
236
+ if (!arr.some((n) => n.node.id === m.id))
237
+ arr.push({ node: m, line: lineAt(d.index) });
238
+ dispatchers.set(d[1], arr);
239
+ }
240
+ }
241
+ if (hasAppend) {
242
+ CC_APPEND_WRITE_RE.lastIndex = 0;
243
+ let w;
244
+ while ((w = CC_APPEND_WRITE_RE.exec(src)))
245
+ addReg(w[2] || w[1], m, lineAt(w.index)); // nested `$0.streams` else the `.write` receiver
246
+ CC_APPEND_DIRECT_RE.lastIndex = 0;
247
+ let a;
248
+ while ((a = CC_APPEND_DIRECT_RE.exec(src)))
249
+ addReg(a[1], m, lineAt(a.index));
250
+ }
251
+ }
252
+ const edges = [];
253
+ const seen = new Set();
254
+ for (const [field, disps] of dispatchers) {
255
+ const regs = registrars.get(field);
256
+ if (!regs || regs.length === 0)
257
+ continue;
258
+ if (disps.length > CC_FANOUT_CAP || regs.length > CC_FANOUT_CAP)
259
+ continue; // generic field — can't pair confidently
260
+ for (const disp of disps)
261
+ for (const reg of regs) {
262
+ if (disp.node.id === reg.node.id)
263
+ continue;
264
+ const key = `${disp.node.id}>${reg.node.id}`;
265
+ if (seen.has(key))
266
+ continue;
267
+ seen.add(key);
268
+ edges.push({
269
+ source: disp.node.id, target: reg.node.id, kind: 'calls', line: disp.line,
270
+ provenance: 'heuristic',
271
+ metadata: { synthesizedBy: 'closure-collection', field, registeredAt: `${reg.node.filePath}:${reg.line}` },
272
+ });
273
+ }
274
+ }
275
+ return edges;
276
+ }
277
+ /** Phase 2: string-keyed EventEmitter channels (on('e', fn) ↔ emit('e')). */
278
+ async function eventEmitterEdges(ctx, onYield) {
279
+ const emitsByEvent = new Map(); // event → dispatcher node ids
280
+ const handlersByEvent = new Map(); // event → handler id → registration site (file:line)
281
+ let scanned = 0;
282
+ for (const file of ctx.getAllFiles()) {
283
+ if ((++scanned & 255) === 0)
284
+ await onYield(); // #1091: yield mid-scan on huge graphs
285
+ const content = ctx.readFile(file);
286
+ if (!content)
287
+ continue;
288
+ const hasEmit = content.includes('.emit(') || content.includes('.fire(') || content.includes('.dispatchEvent(');
289
+ const hasOn = content.includes('.on(') || content.includes('.once(') || content.includes('.addListener(');
290
+ if (!hasEmit && !hasOn)
291
+ continue;
292
+ const nodesInFile = ctx.getNodesInFile(file);
293
+ const lineOf = (idx) => content.slice(0, idx).split('\n').length;
294
+ if (hasEmit) {
295
+ EMIT_RE.lastIndex = 0;
296
+ let m;
297
+ while ((m = EMIT_RE.exec(content))) {
298
+ const disp = enclosingFn(nodesInFile, lineOf(m.index));
299
+ if (!disp)
300
+ continue;
301
+ const set = emitsByEvent.get(m[1]) ?? new Set();
302
+ set.add(disp.id);
303
+ emitsByEvent.set(m[1], set);
304
+ }
305
+ }
306
+ if (hasOn) {
307
+ ON_RE.lastIndex = 0;
308
+ let m;
309
+ while ((m = ON_RE.exec(content))) {
310
+ const handlerName = m[2] || m[3];
311
+ if (!handlerName)
312
+ continue;
313
+ const handler = ctx.getNodesByName(handlerName).find((n) => n.kind === 'function' || n.kind === 'method');
314
+ if (!handler)
315
+ continue;
316
+ const map = handlersByEvent.get(m[1]) ?? new Map();
317
+ map.set(handler.id, `${file}:${lineOf(m.index)}`);
318
+ handlersByEvent.set(m[1], map);
319
+ }
320
+ }
321
+ }
322
+ const edges = [];
323
+ const seen = new Set();
324
+ for (const [event, dispatchers] of emitsByEvent) {
325
+ const handlers = handlersByEvent.get(event);
326
+ if (!handlers)
327
+ continue;
328
+ // Precision guard: a generic event name with many handlers/dispatchers can't
329
+ // be matched without receiver-type info (Phase 3) — skip rather than over-link.
330
+ if (dispatchers.size > EVENT_FANOUT_CAP || handlers.size > EVENT_FANOUT_CAP)
331
+ continue;
332
+ for (const d of dispatchers)
333
+ for (const [h, registeredAt] of handlers) {
334
+ if (d === h)
335
+ continue;
336
+ const key = `${d}>${h}`;
337
+ if (seen.has(key))
338
+ continue;
339
+ seen.add(key);
340
+ edges.push({ source: d, target: h, kind: 'calls', provenance: 'heuristic', metadata: { synthesizedBy: 'event-emitter', event, registeredAt } });
341
+ }
342
+ }
343
+ return edges;
344
+ }
345
+ /**
346
+ * Phase 4: React class-component re-render. `this.setState(...)` re-runs the
347
+ * component's `render()`, but that hop is React-internal — no static edge — so a
348
+ * flow like "mutation → setState → canvas repaint" dead-ends at setState even
349
+ * though `render → getRenderableElements → …` is fully call-connected after it.
350
+ * Bridge it: for each class that has a `render` method, link every sibling method
351
+ * whose body calls `this.setState(` → `render`. The setState gate keeps this to
352
+ * React class components (a non-React class with a `render` method won't call
353
+ * `this.setState`). Over-approximation (all setState methods reach render) is
354
+ * accepted — it's reachability-correct, like the callback channels.
355
+ */
356
+ function reactRenderEdges(queries, ctx) {
357
+ const edges = [];
358
+ const seen = new Set();
359
+ for (const cls of queries.getNodesByKind('class')) {
360
+ const children = queries.getOutgoingEdges(cls.id, ['contains'])
361
+ .map((e) => queries.getNodeById(e.target))
362
+ .filter((n) => !!n && n.kind === 'method');
363
+ const render = children.find((n) => n.name === 'render');
364
+ if (!render)
365
+ continue;
366
+ let added = 0;
367
+ for (const m of children) {
368
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
369
+ break;
370
+ if (m.id === render.id)
371
+ continue;
372
+ const content = ctx.readFile(m.filePath);
373
+ const src = content && sliceLines(content, m.startLine, m.endLine);
374
+ if (!src || !SETSTATE_RE.test(src))
375
+ continue;
376
+ const key = `${m.id}>${render.id}`;
377
+ if (seen.has(key))
378
+ continue;
379
+ seen.add(key);
380
+ edges.push({
381
+ source: m.id, target: render.id, kind: 'calls', line: m.startLine,
382
+ provenance: 'heuristic',
383
+ metadata: { synthesizedBy: 'react-render', via: 'setState', registeredAt: `${render.filePath}:${render.startLine}` },
384
+ });
385
+ added++;
386
+ }
387
+ }
388
+ return edges;
389
+ }
390
+ /**
391
+ * Phase 4b: Flutter setState → build (the Dart analog of react-render). In a
392
+ * StatefulWidget's State class, `setState(() {…})` re-runs `build(context)`, but
393
+ * that hop is framework-internal (Flutter calls build), so a flow like
394
+ * "onPressed → _increment → setState → rebuilt UI" dead-ends at setState. Bridge
395
+ * it: for each Dart class with a `build` method, link every sibling method whose
396
+ * body calls `setState(` → `build`. The setState gate + `.dart` file keep this to
397
+ * Flutter State classes. Over-approximation accepted (reachability-correct).
398
+ */
399
+ function flutterBuildEdges(queries, ctx) {
400
+ const edges = [];
401
+ const seen = new Set();
402
+ for (const cls of queries.getNodesByKind('class')) {
403
+ const children = queries.getOutgoingEdges(cls.id, ['contains'])
404
+ .map((e) => queries.getNodeById(e.target))
405
+ .filter((n) => !!n && n.kind === 'method');
406
+ const build = children.find((n) => n.name === 'build');
407
+ if (!build || !build.filePath.endsWith('.dart'))
408
+ continue;
409
+ let added = 0;
410
+ for (const m of children) {
411
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
412
+ break;
413
+ if (m.id === build.id)
414
+ continue;
415
+ const content = ctx.readFile(m.filePath);
416
+ const src = content && sliceLines(content, m.startLine, m.endLine);
417
+ if (!src || !FLUTTER_SETSTATE_RE.test(src))
418
+ continue;
419
+ const key = `${m.id}>${build.id}`;
420
+ if (seen.has(key))
421
+ continue;
422
+ seen.add(key);
423
+ edges.push({
424
+ source: m.id, target: build.id, kind: 'calls', line: m.startLine,
425
+ provenance: 'heuristic',
426
+ metadata: { synthesizedBy: 'flutter-build', via: 'setState', registeredAt: `${build.filePath}:${build.startLine}` },
427
+ });
428
+ added++;
429
+ }
430
+ }
431
+ return edges;
432
+ }
433
+ /**
434
+ * Reactive ArkUI property decorators: assigning a property carrying one of
435
+ * these re-runs the owning struct's `build()`. Covers both state models —
436
+ * V1 (`@Component`: State/Prop/Link/Provide/Consume/Storage*) and V2
437
+ * (`@ComponentV2`: Local/Provider/Consumer; `@Param` is read-only in V2 so
438
+ * the assignment gate never fires on it, and `@Trace` lives on `@ObservedV2`
439
+ * data classes, not struct properties).
440
+ */
441
+ const ARKUI_REACTIVE_DECORATORS = new Set([
442
+ 'State', 'Prop', 'Link', 'Provide', 'Consume', 'StorageLink', 'StorageProp',
443
+ 'LocalStorageLink', 'LocalStorageProp', 'ObjectLink',
444
+ 'Local', 'Provider', 'Consumer',
445
+ ]);
446
+ /** ArkUI-observed array mutators — `this.todos.push(x)` re-renders like an assignment. */
447
+ const ARKUI_ARRAY_MUTATORS = 'push|pop|shift|unshift|splice|sort|reverse|fill';
448
+ /**
449
+ * Phase 4b-ets: ArkUI state → build (the ArkTS analog of react-render /
450
+ * flutter-build). Assigning a reactive-decorated property (`@State count`,
451
+ * `@Link selected`, …) re-runs the `@Component struct`'s `build()`, but that
452
+ * hop is framework-internal — no static edge — so "onClick → markAllDone →
453
+ * this.todos = […] → rebuilt list" dead-ends at the assignment. Bridge it:
454
+ * for each arkts struct with a `build()` method and at least one reactive
455
+ * property, link every sibling method whose body ASSIGNS (or array-mutates)
456
+ * one of those properties → `build`. Assignment-gated on the struct's OWN
457
+ * reactive property names — a method that merely reads state, or a struct
458
+ * with no reactive properties, gets nothing (this is the precision line the
459
+ * all-sibling-methods design would erase).
460
+ */
461
+ function arkuiStateBuildEdges(queries, ctx) {
462
+ const edges = [];
463
+ const seen = new Set();
464
+ for (const struct of queries.getNodesByKind('struct')) {
465
+ if (struct.language !== 'arkts')
466
+ continue;
467
+ const children = queries.getOutgoingEdges(struct.id, ['contains'])
468
+ .map((e) => queries.getNodeById(e.target))
469
+ .filter((n) => !!n);
470
+ const build = children.find((n) => n.kind === 'method' && n.name === 'build');
471
+ if (!build)
472
+ continue;
473
+ const reactiveProps = children.filter((n) => n.kind === 'property' && (n.decorators ?? []).some((d) => ARKUI_REACTIVE_DECORATORS.has(d)));
474
+ if (reactiveProps.length === 0)
475
+ continue;
476
+ const propAlternation = reactiveProps
477
+ .map((p) => p.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
478
+ .join('|');
479
+ // `this.count = …` / `+=` / `++` / `--` / `this.todos.push(…)`. The
480
+ // `=(?!=)` keeps `this.done == x` comparisons out.
481
+ const mutationRe = new RegExp(`this\\.(?:${propAlternation})\\s*(?:=(?!=)|\\+\\+|--|[+\\-*/%&|^]=|\\.(?:${ARKUI_ARRAY_MUTATORS})\\s*\\()`);
482
+ let added = 0;
483
+ for (const m of children) {
484
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
485
+ break;
486
+ if (m.kind !== 'method' || m.id === build.id)
487
+ continue;
488
+ const content = ctx.readFile(m.filePath);
489
+ const src = content && sliceLines(content, m.startLine, m.endLine);
490
+ if (!src || !mutationRe.test((0, strip_comments_1.stripCommentsForRegex)(src, 'typescript')))
491
+ continue;
492
+ const key = `${m.id}>${build.id}`;
493
+ if (seen.has(key))
494
+ continue;
495
+ seen.add(key);
496
+ edges.push({
497
+ source: m.id, target: build.id, kind: 'calls', line: m.startLine,
498
+ provenance: 'heuristic',
499
+ metadata: { synthesizedBy: 'arkui-state', via: 'state assignment', registeredAt: `${build.filePath}:${build.startLine}` },
500
+ });
501
+ added++;
502
+ }
503
+ }
504
+ return edges;
505
+ }
506
+ /** Emit/subscribe call sites of HarmonyOS's `@ohos.events.emitter` bus. */
507
+ const ARKUI_EMITTER_CALL_RE = /\bemitter\s*\.\s*(emit|on|once)\s*\(\s*([A-Za-z_$][\w$.]*|\{[^)]{0,120}?\beventId\s*:\s*[^,}]+[^)]*?\})/g;
508
+ /** Cap per event bucket — a generic key with many parties is dynamic routing, not a static pair. */
509
+ const ARKUI_EMITTER_FANOUT_CAP = 8;
510
+ /**
511
+ * Phase 4b-ets2: HarmonyOS `@ohos.events.emitter` bridge. The cross-component
512
+ * bus — `emitter.emit(eventId)` fires `emitter.on(eventId, cb)` — is
513
+ * framework-internal, so an order flow riding it (OrangeShopping's
514
+ * add-to-cart) dead-ends at the emit. Link emit-site enclosing
515
+ * function/method → on/once-site enclosing function/method when both
516
+ * reference the SAME statically-recoverable event key.
517
+ *
518
+ * Key recovery, per call site (comment-stripped enclosing-file source): the
519
+ * first argument is an `{ eventId: K }` literal, a `Names.Dotted` constant, or
520
+ * a local whose same-file declaration is `new EventsId(K)` / `= K` — chase one
521
+ * level. Precision scoping learned from the samples monorepo (thousands of
522
+ * unrelated samples, most using eventId 1): NUMERIC keys pair within the same
523
+ * FILE only; NAMED keys pair within the same workspace module directory (or
524
+ * the whole project when it declares no modules — the single-app case), both
525
+ * behind a fan-out cap. Inline `on(id, (e) => {…})` arrows need no special
526
+ * handling — their bodies' calls already attribute to the registering method,
527
+ * so targeting that method keeps the chain connected.
528
+ */
529
+ function arkuiEmitterEdges(ctx) {
530
+ // bucket key -> emit sites / handler sites
531
+ const emits = new Map();
532
+ const handlers = new Map();
533
+ const moduleDirs = (() => {
534
+ const ws = ctx.getWorkspacePackages?.();
535
+ return ws ? [...new Set(ws.byName.values())].sort((a, b) => b.length - a.length) : [];
536
+ })();
537
+ const moduleScopeOf = (file) => {
538
+ for (const dir of moduleDirs) {
539
+ if (file === dir || file.startsWith(dir + '/'))
540
+ return dir;
541
+ }
542
+ return '';
543
+ };
544
+ for (const file of ctx.getAllFiles()) {
545
+ if (!file.endsWith('.ets'))
546
+ continue;
547
+ const content = ctx.readFile(file);
548
+ if (!content || !content.includes('emitter.'))
549
+ continue;
550
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'typescript');
551
+ const nodes = ctx.getNodesInFile(file)
552
+ .filter((n) => n.kind === 'method' || n.kind === 'function');
553
+ ARKUI_EMITTER_CALL_RE.lastIndex = 0;
554
+ let m;
555
+ while ((m = ARKUI_EMITTER_CALL_RE.exec(safe))) {
556
+ const verb = m[1];
557
+ const arg = m[2].trim();
558
+ const line = safe.slice(0, m.index).split('\n').length;
559
+ const encl = nodes
560
+ .filter((n) => n.startLine <= line && n.endLine >= line)
561
+ .sort((a, b) => (a.endLine - a.startLine) - (b.endLine - b.startLine))[0];
562
+ if (!encl)
563
+ continue;
564
+ // Recover the event key from the first argument.
565
+ let key = null;
566
+ const idLit = arg.startsWith('{') ? arg.match(/\beventId\s*:\s*([\w$.]+)/)?.[1] : undefined;
567
+ const token = idLit ?? arg;
568
+ if (token !== undefined) {
569
+ if (/^\d+$/.test(token)) {
570
+ key = `num:${file}:${token}`; // numeric: same-file only
571
+ }
572
+ else if (token.includes('.')) {
573
+ key = `name:${moduleScopeOf(file)}:${token}`;
574
+ }
575
+ else {
576
+ // Local variable — chase its same-file declaration one level:
577
+ // `let x = new EventsId(K)` / `const x = K`.
578
+ const declRe = new RegExp(`\\b${token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b\\s*(?::[^=\\n]+)?=\\s*(?:new\\s+[\\w$.]+\\(\\s*([^)\\n]+?)\\s*\\)|([\\w$.]+))`);
579
+ const decl = safe.match(declRe);
580
+ const inner = (decl?.[1] ?? decl?.[2])?.trim();
581
+ if (inner && /^\d+$/.test(inner))
582
+ key = `num:${file}:${inner}`;
583
+ else if (inner && /^[\w$.]+$/.test(inner))
584
+ key = `name:${moduleScopeOf(file)}:${inner}`;
585
+ }
586
+ }
587
+ if (!key)
588
+ continue;
589
+ const site = { nodeId: encl.id, file, line };
590
+ if (verb === 'emit') {
591
+ (emits.get(key) ?? emits.set(key, []).get(key)).push(site);
592
+ }
593
+ else {
594
+ (handlers.get(key) ?? handlers.set(key, []).get(key)).push(site);
595
+ }
596
+ }
597
+ }
598
+ const edges = [];
599
+ const seen = new Set();
600
+ for (const [key, emitSites] of emits) {
601
+ const handlerSites = handlers.get(key);
602
+ if (!handlerSites)
603
+ continue;
604
+ if (emitSites.length > ARKUI_EMITTER_FANOUT_CAP || handlerSites.length > ARKUI_EMITTER_FANOUT_CAP)
605
+ continue;
606
+ const eventLabel = key.slice(key.lastIndexOf(':') + 1);
607
+ for (const e of emitSites)
608
+ for (const h of handlerSites) {
609
+ if (e.nodeId === h.nodeId)
610
+ continue;
611
+ const dedupe = `${e.nodeId}>${h.nodeId}`;
612
+ if (seen.has(dedupe))
613
+ continue;
614
+ seen.add(dedupe);
615
+ edges.push({
616
+ source: e.nodeId, target: h.nodeId, kind: 'calls', line: e.line,
617
+ provenance: 'heuristic',
618
+ metadata: { synthesizedBy: 'arkui-emitter', event: eventLabel, registeredAt: `${h.file}:${h.line}` },
619
+ });
620
+ }
621
+ }
622
+ return edges;
623
+ }
624
+ /** `router.pushUrl({ url: 'pages/Detail' })` / replaceUrl — literal urls only. */
625
+ const ARKUI_ROUTER_RE = /\brouter\s*\.\s*(?:pushUrl|replaceUrl)\s*\(\s*\{[^)]{0,200}?\burl\s*:\s*['"]([\w\-./]+)['"]/g;
626
+ /**
627
+ * Phase 4b-ets3: HarmonyOS page navigation. `router.pushUrl({ url:
628
+ * 'pages/Detail' })` reaches the `@Entry struct` of
629
+ * `<module>/src/main/ets/pages/Detail.ets`, but the hop is a string — no
630
+ * static edge — so "tap → openDetail → ???" ends at the router call. Bridge
631
+ * literal urls to the page struct: the url resolves against the standard
632
+ * `src/main/ets/` layout (what main_pages.json entries name); candidates
633
+ * prefer the caller's own workspace module (routes are module-scoped), and
634
+ * anything still ambiguous is dropped rather than guessed. Only `@Entry`
635
+ * structs qualify as targets — the decorator is what makes a file a page.
636
+ */
637
+ function arkuiRouterEdges(ctx) {
638
+ const edges = [];
639
+ const seen = new Set();
640
+ const allFiles = ctx.getAllFiles();
641
+ const moduleDirs = (() => {
642
+ const ws = ctx.getWorkspacePackages?.();
643
+ return ws ? [...new Set(ws.byName.values())].sort((a, b) => b.length - a.length) : [];
644
+ })();
645
+ const moduleScopeOf = (file) => {
646
+ for (const dir of moduleDirs) {
647
+ if (file === dir || file.startsWith(dir + '/'))
648
+ return dir;
649
+ }
650
+ return '';
651
+ };
652
+ for (const file of allFiles) {
653
+ if (!file.endsWith('.ets'))
654
+ continue;
655
+ const content = ctx.readFile(file);
656
+ if (!content || !content.includes('router.'))
657
+ continue;
658
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'typescript');
659
+ const nodes = ctx.getNodesInFile(file)
660
+ .filter((n) => n.kind === 'method' || n.kind === 'function');
661
+ ARKUI_ROUTER_RE.lastIndex = 0;
662
+ let m;
663
+ while ((m = ARKUI_ROUTER_RE.exec(safe))) {
664
+ const url = m[1];
665
+ const line = safe.slice(0, m.index).split('\n').length;
666
+ const encl = nodes
667
+ .filter((n) => n.startLine <= line && n.endLine >= line)
668
+ .sort((a, b) => (a.endLine - a.startLine) - (b.endLine - b.startLine))[0];
669
+ if (!encl)
670
+ continue;
671
+ const suffix = `/src/main/ets/${url}.ets`;
672
+ let candidates = allFiles.filter((f) => f.endsWith(suffix));
673
+ if (candidates.length > 1) {
674
+ const scope = moduleScopeOf(file);
675
+ const sameModule = candidates.filter((f) => moduleScopeOf(f) === scope);
676
+ if (sameModule.length > 0)
677
+ candidates = sameModule;
678
+ }
679
+ if (candidates.length !== 1)
680
+ continue; // ambiguous or unresolved — never guess
681
+ const page = ctx.getNodesInFile(candidates[0]).find((n) => n.kind === 'struct' && (n.decorators ?? []).includes('Entry'));
682
+ if (!page)
683
+ continue;
684
+ const key = `${encl.id}>${page.id}`;
685
+ if (seen.has(key))
686
+ continue;
687
+ seen.add(key);
688
+ edges.push({
689
+ source: encl.id, target: page.id, kind: 'calls', line,
690
+ provenance: 'heuristic',
691
+ metadata: { synthesizedBy: 'arkui-route', event: url, registeredAt: `${candidates[0]}:${page.startLine}` },
692
+ });
693
+ }
694
+ }
695
+ return edges;
696
+ }
697
+ /**
698
+ * Phase 4c: C++ virtual override. A call through a base/interface pointer
699
+ * (`db->Get(...)`, `iter->Next()`) dispatches at runtime to a subclass override,
700
+ * but that hop is a vtable indirection — no static call edge — so a flow stops at
701
+ * the abstract base method. Bridge it like react-render: for each C++ class that
702
+ * `extends` a base, link each base method → the subclass method of the same name
703
+ * (the override), so trace/callees from the interface method reach the
704
+ * implementation(s). Over-approximation accepted (reachability-correct); capped
705
+ * per class and gated to C++ to avoid touching other languages' dispatch.
706
+ */
707
+ function cppOverrideEdges(queries) {
708
+ const edges = [];
709
+ const seen = new Set();
710
+ const methodsOf = (classId) => queries
711
+ .getOutgoingEdges(classId, ['contains'])
712
+ .map((e) => queries.getNodeById(e.target))
713
+ .filter((n) => !!n && n.kind === 'method');
714
+ for (const cls of queries.getNodesByKind('class')) {
715
+ const subMethods = methodsOf(cls.id).filter((n) => n.language === 'cpp');
716
+ if (subMethods.length === 0)
717
+ continue;
718
+ for (const ext of queries.getOutgoingEdges(cls.id, ['extends'])) {
719
+ const base = queries.getNodeById(ext.target);
720
+ if (!base || base.language !== 'cpp' || base.id === cls.id)
721
+ continue;
722
+ const baseMethods = new Map(methodsOf(base.id).map((m) => [m.name, m]));
723
+ let added = 0;
724
+ for (const m of subMethods) {
725
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
726
+ break;
727
+ const bm = baseMethods.get(m.name);
728
+ if (!bm || bm.id === m.id)
729
+ continue;
730
+ const key = `${bm.id}>${m.id}`;
731
+ if (seen.has(key))
732
+ continue;
733
+ seen.add(key);
734
+ edges.push({
735
+ source: bm.id,
736
+ target: m.id,
737
+ kind: 'calls',
738
+ line: bm.startLine,
739
+ provenance: 'heuristic',
740
+ metadata: { synthesizedBy: 'cpp-override', via: m.name, registeredAt: `${m.filePath}:${m.startLine}` },
741
+ });
742
+ added++;
743
+ }
744
+ }
745
+ }
746
+ return edges;
747
+ }
748
+ /**
749
+ * Phase 5.5: interface / abstract dispatch (Java, Kotlin). A call through an
750
+ * injected interface (`@Autowired FooService svc; svc.list()`) or an abstract
751
+ * base dispatches at runtime to the implementing class's override — a vtable
752
+ * indirection with no static call edge — so a request→service flow stops at the
753
+ * interface method. Bridge it like cpp-override: for each class that
754
+ * `implements` an interface (or `extends` an abstract base), link each
755
+ * base/interface method → the class's same-name method (the override) so
756
+ * trace/callees reach the implementation. Over-approximation accepted
757
+ * (reachability-correct); capped per class, gated to JVM languages.
758
+ */
759
+ // Languages whose static `implements`/`extends` edges should bridge an
760
+ // interface (or abstract base) method to the matching concrete-class method.
761
+ // The set is "languages with explicit nominal subtyping and a single class
762
+ // kind that holds methods" — i.e. the shape this loop expects. Swift and
763
+ // Scala fit shape-wise (Swift `protocol`/`class`, Scala `trait`/`class`)
764
+ // and are added below; their concrete-side nodes can be a `struct` (Swift)
765
+ // or an `object` (Scala) so the loop also iterates those kinds.
766
+ const IFACE_OVERRIDE_LANGS = new Set([
767
+ 'java', 'kotlin', 'csharp', 'typescript', 'javascript', 'swift', 'scala', 'go', 'rust',
768
+ 'arkts',
769
+ ]);
770
+ /**
771
+ * Go implicit interface satisfaction (#584). Go has no `implements` keyword — a
772
+ * struct satisfies an interface structurally when its method set covers the
773
+ * interface's. Synthesize the missing `implements` edge (struct → interface) by
774
+ * matching method-NAME sets, so impl-navigation works and the interface-dispatch
775
+ * bridge ({@link interfaceOverrideEdges}, now 'go'-enabled) can link an interface
776
+ * method call to the concrete overrides.
777
+ *
778
+ * Name-only matching (signatures ignored) — over-approximation accepted, in line
779
+ * with the other dispatch synthesizers; capped per interface. Empty interfaces
780
+ * (`any`) are skipped so they don't match every struct.
781
+ */
782
+ function goImplementsEdges(queries) {
783
+ const edges = [];
784
+ const seen = new Set();
785
+ const methodNameSet = (id) => new Set(queries
786
+ .getOutgoingEdges(id, ['contains'])
787
+ .map((e) => queries.getNodeById(e.target))
788
+ .filter((n) => !!n && n.kind === 'method')
789
+ .map((n) => n.name));
790
+ const goStructs = queries.getNodesByKind('struct').filter((s) => s.language === 'go');
791
+ const structMethods = new Map();
792
+ for (const s of goStructs)
793
+ structMethods.set(s.id, methodNameSet(s.id));
794
+ for (const iface of queries.getNodesByKind('interface')) {
795
+ if (iface.language !== 'go')
796
+ continue;
797
+ const want = methodNameSet(iface.id);
798
+ if (want.size === 0)
799
+ continue; // empty interface (`any`) — would match everything
800
+ let added = 0;
801
+ for (const s of goStructs) {
802
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
803
+ break;
804
+ const have = structMethods.get(s.id);
805
+ if (!have || have.size < want.size)
806
+ continue;
807
+ let all = true;
808
+ for (const m of want) {
809
+ if (!have.has(m)) {
810
+ all = false;
811
+ break;
812
+ }
813
+ }
814
+ if (!all)
815
+ continue;
816
+ const key = `${s.id}>${iface.id}`;
817
+ if (seen.has(key))
818
+ continue;
819
+ seen.add(key);
820
+ edges.push({
821
+ source: s.id,
822
+ target: iface.id,
823
+ kind: 'implements',
824
+ line: s.startLine,
825
+ provenance: 'heuristic',
826
+ metadata: { synthesizedBy: 'go-implements', via: iface.name, registeredAt: `${s.filePath}:${s.startLine}` },
827
+ });
828
+ added++;
829
+ }
830
+ }
831
+ return edges;
832
+ }
833
+ /**
834
+ * Cross-file Go method → receiver-type `contains` edges. In Go a type's methods
835
+ * are commonly declared in a different file from the `type` declaration itself
836
+ * (`type User struct{…}` in `user.go`, `func (u *User) Save()` in
837
+ * `user_store.go`). Extraction attaches the struct→method `contains` edge only
838
+ * when the receiver type is in the SAME file — the owner lookup in
839
+ * `tree-sitter.ts` is scoped to the file being parsed — so a cross-file method
840
+ * is left orphaned from its type (it's still `contains`ed by its file, just not
841
+ * its struct). That breaks `bhgraph_node` member outlines, any
842
+ * callers/callees/impact traversal that goes through the type's `contains`
843
+ * edges, and the {@link goImplementsEdges} method-set computation (which derives
844
+ * a struct's method set from those same edges, so it under-counts interfaces a
845
+ * cross-file struct satisfies).
846
+ *
847
+ * Go guarantees a method's receiver type is declared in the SAME PACKAGE as the
848
+ * method, and a Go package is a single directory — so this is a deterministic
849
+ * structural link, not a heuristic: find the same-named type in the method's own
850
+ * directory and add the missing `contains` edge (no `provenance: 'heuristic'`,
851
+ * matching the same-file edges extraction already emits). Skips methods that
852
+ * already have a type parent (the same-file case). (#583, cross-file half)
853
+ */
854
+ function goCrossFileMethodContainsEdges(queries) {
855
+ const edges = [];
856
+ const seen = new Set();
857
+ const TYPE_KINDS = new Set(['struct', 'class', 'interface', 'enum', 'type_alias']);
858
+ const dirOf = (p) => {
859
+ const i = p.replace(/\\/g, '/').lastIndexOf('/');
860
+ return i >= 0 ? p.slice(0, i) : '';
861
+ };
862
+ for (const method of queries.getNodesByKind('method')) {
863
+ if (method.language !== 'go')
864
+ continue;
865
+ // The receiver type is encoded in the method's qualifiedName as `Recv::name`
866
+ // (extraction sets `${receiverType}::${name}` for receiver methods).
867
+ const qn = method.qualifiedName;
868
+ if (!qn)
869
+ continue;
870
+ const sep = qn.lastIndexOf('::');
871
+ if (sep <= 0)
872
+ continue;
873
+ const receiver = qn.slice(0, sep);
874
+ if (!receiver)
875
+ continue;
876
+ // Already attached to its type (same-file case handled at extraction)?
877
+ const hasTypeParent = queries
878
+ .getIncomingEdges(method.id, ['contains'])
879
+ .some((e) => {
880
+ const src = queries.getNodeById(e.source);
881
+ return src != null && TYPE_KINDS.has(src.kind);
882
+ });
883
+ if (hasTypeParent)
884
+ continue;
885
+ // Find the receiver type in the SAME directory (= same Go package). Go forbids
886
+ // duplicate type names within a package, so a same-name same-dir match is
887
+ // unambiguous; scoping to the directory avoids linking to a same-named type
888
+ // in another package.
889
+ const dir = dirOf(method.filePath);
890
+ const owner = queries
891
+ .getNodesByName(receiver)
892
+ .find((n) => n.language === 'go' && TYPE_KINDS.has(n.kind) && dirOf(n.filePath) === dir);
893
+ if (!owner)
894
+ continue;
895
+ const key = `${owner.id}>${method.id}`;
896
+ if (seen.has(key))
897
+ continue;
898
+ seen.add(key);
899
+ edges.push({ source: owner.id, target: method.id, kind: 'contains', line: method.startLine });
900
+ }
901
+ return edges;
902
+ }
903
+ /**
904
+ * Kotlin Multiplatform `expect`/`actual` linking. A `common` source set declares
905
+ * `expect fun foo()` / `expect class Bar`; each platform source set (jvm, native,
906
+ * js, …) provides an `actual` implementation with the IDENTICAL fully-qualified
907
+ * name in a different file. Callers in common code resolve to the `expect`
908
+ * declaration, so every `actual` impl ends up with zero dependents — invisible to
909
+ * impact/affected even though editing it can break every caller of the API.
910
+ *
911
+ * Synthesize a `calls` edge from the common declaration to each platform `actual`
912
+ * (mirroring the interface-impl bridge: abstract → concrete), so editing a
913
+ * platform impl surfaces the common `expect` and its callers, and the impl file
914
+ * participates in the graph.
915
+ *
916
+ * `expect`/`actual` are captured onto the node's `decorators` list at extraction
917
+ * (kotlin.ts `extractModifiers`). Members of an `expect class` are NOT themselves
918
+ * keyword-marked, so the declaration side is matched as the same-FQN, same-kind
919
+ * node that is NOT marked `actual`. Requiring an `actual`-marked counterpart also
920
+ * gates out plain cross-file overloads (neither side is marked).
921
+ */
922
+ // Kinds that an `expect`/`actual` pair may legitimately straddle. `expect class`
923
+ // is routinely fulfilled by an `actual typealias` (e.g. `actual typealias
924
+ // CancellationException = …`, `actual typealias SchedulerTask = Task`), so a
925
+ // strict kind match would miss those one-line alias files. Same-FQN + the
926
+ // `actual` marker already gates out unrelated symbols, so widening to the
927
+ // type-like kinds is safe.
928
+ const KMP_TYPE_KINDS = new Set(['class', 'interface', 'struct', 'enum', 'type_alias']);
929
+ function kmpKindsCompatible(a, b) {
930
+ return a === b || (KMP_TYPE_KINDS.has(a) && KMP_TYPE_KINDS.has(b));
931
+ }
932
+ function kotlinExpectActualEdges(queries) {
933
+ const edges = [];
934
+ const seen = new Set();
935
+ const actuals = queries
936
+ .getAllNodes()
937
+ .filter((n) => n.language === 'kotlin' && !!n.decorators?.includes('actual'));
938
+ for (const act of actuals) {
939
+ let added = 0;
940
+ for (const cand of queries.getNodesByQualifiedNameExact(act.qualifiedName)) {
941
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
942
+ break;
943
+ // The declaration side: same FQN + compatible kind, a different file, NOT
944
+ // itself an `actual` (that would be a sibling platform impl, not the decl).
945
+ if (cand.language !== 'kotlin' || cand.id === act.id)
946
+ continue;
947
+ if (!kmpKindsCompatible(cand.kind, act.kind) || cand.filePath === act.filePath)
948
+ continue;
949
+ if (cand.decorators?.includes('actual'))
950
+ continue;
951
+ const key = `${cand.id}>${act.id}`;
952
+ if (seen.has(key))
953
+ continue;
954
+ seen.add(key);
955
+ edges.push({
956
+ source: cand.id,
957
+ target: act.id,
958
+ kind: 'calls',
959
+ line: cand.startLine,
960
+ provenance: 'heuristic',
961
+ metadata: {
962
+ synthesizedBy: 'kotlin-expect-actual',
963
+ via: act.name,
964
+ registeredAt: `${act.filePath}:${act.startLine}`,
965
+ },
966
+ });
967
+ added++;
968
+ }
969
+ }
970
+ return edges;
971
+ }
972
+ function interfaceOverrideEdges(queries) {
973
+ const edges = [];
974
+ const seen = new Set();
975
+ const methodsOf = (classId) => queries
976
+ .getOutgoingEdges(classId, ['contains'])
977
+ .map((e) => queries.getNodeById(e.target))
978
+ .filter((n) => !!n && n.kind === 'method');
979
+ // Concrete-side kinds vary by language: `class` covers Java / Kotlin /
980
+ // C# / TS / Swift-classes / Scala-classes; `struct` covers Swift value
981
+ // types that conform to protocols. Iterate both.
982
+ const concreteKinds = ['class', 'struct'];
983
+ for (const kind of concreteKinds) {
984
+ for (const cls of queries.getNodesByKind(kind)) {
985
+ const implMethods = methodsOf(cls.id).filter((n) => IFACE_OVERRIDE_LANGS.has(n.language));
986
+ if (implMethods.length === 0)
987
+ continue;
988
+ for (const sup of queries.getOutgoingEdges(cls.id, ['implements', 'extends'])) {
989
+ const base = queries.getNodeById(sup.target);
990
+ if (!base || !IFACE_OVERRIDE_LANGS.has(base.language) || base.id === cls.id)
991
+ continue;
992
+ // Group impl methods by name to handle OVERLOADS: an interface `list()` and
993
+ // `list(params)` are distinct nodes and a call may resolve to either, so
994
+ // link every base overload → every same-name impl overload (keying by name
995
+ // alone would drop all but one and miss the resolved overload).
996
+ const implByName = new Map();
997
+ for (const m of implMethods) {
998
+ const arr = implByName.get(m.name);
999
+ if (arr)
1000
+ arr.push(m);
1001
+ else
1002
+ implByName.set(m.name, [m]);
1003
+ }
1004
+ let added = 0;
1005
+ for (const bm of methodsOf(base.id)) {
1006
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1007
+ break;
1008
+ for (const m of implByName.get(bm.name) ?? []) {
1009
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1010
+ break;
1011
+ if (bm.id === m.id)
1012
+ continue;
1013
+ const key = `${bm.id}>${m.id}`;
1014
+ if (seen.has(key))
1015
+ continue;
1016
+ seen.add(key);
1017
+ edges.push({
1018
+ source: bm.id,
1019
+ target: m.id,
1020
+ kind: 'calls',
1021
+ line: bm.startLine,
1022
+ provenance: 'heuristic',
1023
+ metadata: { synthesizedBy: 'interface-impl', via: m.name, registeredAt: `${m.filePath}:${m.startLine}` },
1024
+ });
1025
+ added++;
1026
+ }
1027
+ }
1028
+ }
1029
+ }
1030
+ }
1031
+ return edges;
1032
+ }
1033
+ /**
1034
+ * Go gRPC stub → impl bridge. The protoc-gen-go-grpc codegen emits an
1035
+ * `UnimplementedXxxServer` struct in `*_grpc.pb.go` carrying one method
1036
+ * per service RPC; the real handler is a hand-written struct in another
1037
+ * file (`x/bank/keeper/msg_server.go::msgServer.Send` in cosmos-sdk).
1038
+ * Go's structural typing means no `implements` edge exists for our
1039
+ * resolver to follow, so `trace("Send","SendCoins")` lands on the
1040
+ * empty stub and reports "no path" (validated empirically — the cosmos
1041
+ * Q1 r1 trace failure that drove this work).
1042
+ *
1043
+ * Bridge: for each `UnimplementedXxxServer` whose RPC-method names are
1044
+ * a SUBSET of some other Go struct's method names, emit `calls` edges
1045
+ * `stub.method → impl.method` (paired by name). Excludes the gRPC
1046
+ * internal markers `mustEmbedUnimplementedXxxServer` and
1047
+ * `testEmbeddedByValue`, and skips candidate impls that themselves
1048
+ * live in a generated file (their `xxxClient` / sibling stubs would
1049
+ * otherwise look like impls).
1050
+ *
1051
+ * Multiple candidates is allowed and capped at MAX_CALLBACKS_PER_CHANNEL —
1052
+ * a service often has both a production impl and one or more test
1053
+ * mocks; linking to all preserves trace utility without false-favoring.
1054
+ *
1055
+ * Provenance: `heuristic`, `synthesizedBy: 'go-grpc-stub-impl'`. The
1056
+ * stub's source line is the wiring site shown in the trace trail.
1057
+ */
1058
+ function goGrpcStubImplEdges(queries) {
1059
+ const edges = [];
1060
+ const seen = new Set();
1061
+ const STUB_RE = /^Unimplemented.*Server$/;
1062
+ // gRPC internal-helper methods that appear on every Unimplemented*Server;
1063
+ // not part of the service contract, so exclude when computing the RPC-method
1064
+ // signature used to match impls.
1065
+ const isInternalMarker = (n) => n.startsWith('mustEmbed') || n === 'testEmbeddedByValue';
1066
+ // Methods directly contained by each Go struct, name-only. Built once.
1067
+ const methodNamesByStruct = new Map();
1068
+ const methodNodesByStruct = new Map();
1069
+ const goStructs = [];
1070
+ for (const s of queries.getNodesByKind('struct')) {
1071
+ if (s.language !== 'go')
1072
+ continue;
1073
+ goStructs.push(s);
1074
+ const ms = queries
1075
+ .getOutgoingEdges(s.id, ['contains'])
1076
+ .map((e) => queries.getNodeById(e.target))
1077
+ .filter((n) => !!n && n.kind === 'method');
1078
+ methodNodesByStruct.set(s.id, ms);
1079
+ methodNamesByStruct.set(s.id, new Set(ms.map((m) => m.name)));
1080
+ }
1081
+ for (const stub of goStructs) {
1082
+ if (!STUB_RE.test(stub.name))
1083
+ continue;
1084
+ // The stub MUST live in a generated file — that's what tells us this is
1085
+ // a protoc-emitted scaffold rather than someone naming a struct
1086
+ // `UnimplementedXxxServer` by hand. Without this gate we'd also bridge
1087
+ // such hand-written structs and create misleading edges.
1088
+ if (!(0, generated_detection_1.isGeneratedFile)(stub.filePath))
1089
+ continue;
1090
+ const stubMethods = (methodNodesByStruct.get(stub.id) ?? []).filter((m) => !isInternalMarker(m.name));
1091
+ if (stubMethods.length === 0)
1092
+ continue;
1093
+ const stubMethodNames = stubMethods.map((m) => m.name);
1094
+ for (const cand of goStructs) {
1095
+ if (cand.id === stub.id)
1096
+ continue;
1097
+ // Skip generated-file candidates — they're siblings (msgClient,
1098
+ // UnsafeMsgServer, …) whose method sets coincidentally match.
1099
+ if ((0, generated_detection_1.isGeneratedFile)(cand.filePath))
1100
+ continue;
1101
+ const candNames = methodNamesByStruct.get(cand.id);
1102
+ if (!candNames)
1103
+ continue;
1104
+ // Subset: every RPC method must exist on the candidate by name.
1105
+ // Signature-level match would tighten this further, but name-match
1106
+ // alone already gives one-to-one pairing in real codebases because
1107
+ // gRPC method-name sets are highly distinctive (Send + MultiSend +
1108
+ // UpdateParams + SetSendEnabled is unique to bank's MsgServer).
1109
+ if (!stubMethodNames.every((n) => candNames.has(n)))
1110
+ continue;
1111
+ const candMethods = methodNodesByStruct.get(cand.id) ?? [];
1112
+ let added = 0;
1113
+ for (const sm of stubMethods) {
1114
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1115
+ break;
1116
+ for (const cm of candMethods) {
1117
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1118
+ break;
1119
+ if (cm.name !== sm.name)
1120
+ continue;
1121
+ const key = `${sm.id}>${cm.id}`;
1122
+ if (seen.has(key))
1123
+ continue;
1124
+ seen.add(key);
1125
+ edges.push({
1126
+ source: sm.id,
1127
+ target: cm.id,
1128
+ kind: 'calls',
1129
+ line: sm.startLine,
1130
+ provenance: 'heuristic',
1131
+ metadata: {
1132
+ synthesizedBy: 'go-grpc-stub-impl',
1133
+ via: cm.name,
1134
+ registeredAt: `${cm.filePath}:${cm.startLine}`,
1135
+ },
1136
+ });
1137
+ added++;
1138
+ }
1139
+ }
1140
+ }
1141
+ }
1142
+ return edges;
1143
+ }
1144
+ /**
1145
+ * Phase 5: React JSX child rendering. A component that returns `<Child .../>`
1146
+ * mounts Child — React calls it — but JSX instantiation isn't a static call edge,
1147
+ * so a render tree (App.render → StaticCanvas → renderStaticScene) breaks at the
1148
+ * JSX hop. Link parent → each capitalized JSX child it renders. File-oriented
1149
+ * (read each JSX file once). Precision gate: the child name must resolve to a
1150
+ * component/function/class node — TS generics like `Array<Foo>` resolve to a type
1151
+ * (or nothing) and are dropped.
1152
+ */
1153
+ async function reactJsxChildEdges(ctx, onYield) {
1154
+ const edges = [];
1155
+ const seen = new Set();
1156
+ const PARENT_KINDS = new Set(['method', 'function', 'component']);
1157
+ let scanned = 0;
1158
+ for (const file of ctx.getAllFiles()) {
1159
+ if ((++scanned & 255) === 0)
1160
+ await onYield(); // #1091: yield mid-scan on huge graphs
1161
+ const content = ctx.readFile(file);
1162
+ if (!content || (!content.includes('</') && !content.includes('/>')))
1163
+ continue; // JSX-file gate
1164
+ const parents = ctx.getNodesInFile(file).filter((n) => PARENT_KINDS.has(n.kind));
1165
+ for (const parent of parents) {
1166
+ const src = sliceLines(content, parent.startLine, parent.endLine);
1167
+ if (!src || (!src.includes('</') && !src.includes('/>')))
1168
+ continue;
1169
+ const names = new Set();
1170
+ JSX_TAG_RE.lastIndex = 0;
1171
+ let m;
1172
+ while ((m = JSX_TAG_RE.exec(src)))
1173
+ names.add(m[1]);
1174
+ let added = 0;
1175
+ for (const name of names) {
1176
+ if (added >= MAX_JSX_CHILDREN)
1177
+ break;
1178
+ const child = ctx.getNodesByName(name).find((n) => n.kind === 'component' || n.kind === 'function' || n.kind === 'class');
1179
+ if (!child || child.id === parent.id)
1180
+ continue;
1181
+ const key = `${parent.id}>${child.id}`;
1182
+ if (seen.has(key))
1183
+ continue;
1184
+ seen.add(key);
1185
+ edges.push({
1186
+ source: parent.id, target: child.id, kind: 'calls', line: parent.startLine,
1187
+ provenance: 'heuristic',
1188
+ metadata: { synthesizedBy: 'jsx-render', via: name },
1189
+ });
1190
+ added++;
1191
+ }
1192
+ }
1193
+ }
1194
+ return edges;
1195
+ }
1196
+ /**
1197
+ * Phase 6: Vue SFC templates. The `.vue` extractor only parses `<script>`, so
1198
+ * template usage is invisible — child components and event handlers used ONLY in
1199
+ * the template have no edge to them. PascalCase children (`<VPNav/>`) are already
1200
+ * caught by reactJsxChildEdges (which scans the SFC component node), so this adds
1201
+ * the two Vue-specific shapes:
1202
+ * - kebab-case children: `<el-button>` → `ElButton` component (renders).
1203
+ * - event bindings: `@click="onClick"` / `v-on:submit="save"` → handler method.
1204
+ * Scoped to the `<template>` block of `.vue` files; resolution gate (kebab→
1205
+ * component, handler→function/method) keeps precision; inline arrows / `$emit`
1206
+ * skipped.
1207
+ */
1208
+ function vueTemplateEdges(ctx) {
1209
+ const edges = [];
1210
+ const seen = new Set();
1211
+ const COMPONENT_KINDS = new Set(['component', 'function', 'class']);
1212
+ const HANDLER_KINDS = new Set(['method', 'function']);
1213
+ // A composable's returned member may be a fn (`function close(){}`) or an
1214
+ // arrow assigned to a const (`const close = () => {}`).
1215
+ const RETURN_KINDS = new Set(['method', 'function', 'variable', 'constant']);
1216
+ // Nuxt auto-imports nested components by a DIRECTORY-PREFIXED name —
1217
+ // `components/media/Card.vue` is used as `<MediaCard/>`, not `<Card/>` — but
1218
+ // the component node is named by basename (`Card`), so a direct tag match
1219
+ // misses it (flat components match by basename and don't need this). Map each
1220
+ // nested component's Nuxt name → node so those template usages resolve.
1221
+ const nuxtComponents = new Map();
1222
+ for (const c of ctx.getNodesByKind('component')) {
1223
+ const nn = nuxtComponentName(c.filePath);
1224
+ if (nn && !nuxtComponents.has(nn))
1225
+ nuxtComponents.set(nn, c);
1226
+ }
1227
+ for (const file of ctx.getAllFiles()) {
1228
+ if (!file.endsWith('.vue'))
1229
+ continue;
1230
+ const content = ctx.readFile(file);
1231
+ const tpl = content && content.match(/<template[^>]*>([\s\S]*)<\/template>/i)?.[1];
1232
+ if (!tpl)
1233
+ continue;
1234
+ const comp = ctx.getNodesInFile(file).find((n) => n.kind === 'component');
1235
+ if (!comp)
1236
+ continue;
1237
+ // Composable-destructure map: alias → { composable, key }. Lets us resolve a
1238
+ // template handler that isn't a local function but a destructured composable
1239
+ // return (`@click="closeSidebar"` ← `const { close: closeSidebar } = useSidebarControl()`).
1240
+ const script = content.match(/<script[^>]*>([\s\S]*?)<\/script>/i)?.[1] ?? '';
1241
+ const destructured = new Map();
1242
+ VUE_DESTRUCTURE_RE.lastIndex = 0;
1243
+ let dm;
1244
+ while ((dm = VUE_DESTRUCTURE_RE.exec(script))) {
1245
+ if (!/^use[A-Z]/.test(dm[2]))
1246
+ continue; // composables / hooks only
1247
+ for (const part of dm[1].split(',')) {
1248
+ const pm = part.trim().match(/^(\w+)\s*(?::\s*(\w+))?$/); // key | key: alias
1249
+ if (pm)
1250
+ destructured.set(pm[2] || pm[1], { composable: dm[2], key: pm[1] });
1251
+ }
1252
+ }
1253
+ let added = 0;
1254
+ const addEdge = (target, meta) => {
1255
+ if (added >= MAX_JSX_CHILDREN || !target || target.id === comp.id)
1256
+ return;
1257
+ const k = `${comp.id}>${target.id}>${meta.synthesizedBy}`;
1258
+ if (seen.has(k))
1259
+ return;
1260
+ seen.add(k);
1261
+ edges.push({ source: comp.id, target: target.id, kind: 'calls', line: comp.startLine, provenance: 'heuristic', metadata: meta });
1262
+ added++;
1263
+ };
1264
+ // Prefer a target in THIS SFC (handlers live in the same file's script) —
1265
+ // avoids cross-file mis-match when a name repeats across a monorepo.
1266
+ const resolve = (name, kinds) => {
1267
+ const matches = ctx.getNodesByName(name).filter((n) => kinds.has(n.kind));
1268
+ return matches.find((n) => n.filePath === file) ?? matches[0];
1269
+ };
1270
+ let m;
1271
+ VUE_KEBAB_RE.lastIndex = 0;
1272
+ while ((m = VUE_KEBAB_RE.exec(tpl))) {
1273
+ const tag = kebabToPascal(m[1]);
1274
+ addEdge(resolve(tag, COMPONENT_KINDS) ?? nuxtComponents.get(tag), { synthesizedBy: 'jsx-render', via: m[1] });
1275
+ }
1276
+ // PascalCase component tags. Try a direct name match first (flat components
1277
+ // and explicit registrations), then the Nuxt dir-prefixed auto-import name
1278
+ // (`<MediaCard>` → components/media/Card.vue). Built-ins match neither → no edge.
1279
+ VUE_PASCAL_RE.lastIndex = 0;
1280
+ while ((m = VUE_PASCAL_RE.exec(tpl))) {
1281
+ const tag = m[1];
1282
+ addEdge(resolve(tag, COMPONENT_KINDS) ?? nuxtComponents.get(tag), { synthesizedBy: 'jsx-render', via: tag });
1283
+ }
1284
+ VUE_HANDLER_RE.lastIndex = 0;
1285
+ while ((m = VUE_HANDLER_RE.exec(tpl))) {
1286
+ const event = m[1];
1287
+ const expr = m[2].trim();
1288
+ if (expr.includes('=>') || expr.startsWith('$'))
1289
+ continue; // inline arrow / $emit
1290
+ const name = expr.match(/^([A-Za-z_]\w*)/)?.[1];
1291
+ if (!name)
1292
+ continue;
1293
+ const direct = resolve(name, HANDLER_KINDS);
1294
+ if (direct) {
1295
+ addEdge(direct, { synthesizedBy: 'vue-handler', event });
1296
+ continue;
1297
+ }
1298
+ // Composable-destructure handler → resolve to the composable's returned fn.
1299
+ const d = destructured.get(name);
1300
+ if (!d)
1301
+ continue;
1302
+ const composable = resolve(d.composable, HANDLER_KINDS);
1303
+ // Resolve to the SPECIFIC returned member (e.g. `close`) defined in the
1304
+ // composable's file. No fallback to the composable itself — the component
1305
+ // already has a static `useX()` call edge, so that would just be redundant
1306
+ // and less precise.
1307
+ const keyFn = composable
1308
+ ? ctx.getNodesByName(d.key).find((n) => RETURN_KINDS.has(n.kind) && n.filePath === composable.filePath)
1309
+ : undefined;
1310
+ if (keyFn)
1311
+ addEdge(keyFn, { synthesizedBy: 'vue-handler', event, via: d.composable });
1312
+ }
1313
+ }
1314
+ return edges;
1315
+ }
1316
+ /**
1317
+ * React Native cross-language event channel (Phase 3 of the mixed-iOS/RN
1318
+ * bridging effort). Same shape as `eventEmitterEdges` but cross-language:
1319
+ *
1320
+ * Native (ObjC, on RCTEventEmitter subclass):
1321
+ * [self sendEventWithName:@"locationUpdate" body:@{...}];
1322
+ *
1323
+ * Native (Java/Kotlin, via the JS module dispatcher):
1324
+ * emitter.emit("locationUpdate", body);
1325
+ * reactContext.getJSModule(RCTDeviceEventEmitter.class).emit("locationUpdate", body);
1326
+ *
1327
+ * JS (subscriber):
1328
+ * new NativeEventEmitter(NativeModules.Geo).addListener("locationUpdate", handler);
1329
+ * DeviceEventEmitter.addListener("locationUpdate", handler);
1330
+ *
1331
+ * Synthesize: native dispatch site → JS handler, keyed by the literal
1332
+ * event name. Only matches NAMED handlers (the existing `ON_RE` named-
1333
+ * capture form). Inline arrow handlers like `addListener('x', d => …)`
1334
+ * aren't named at extraction time and would need link-through-body
1335
+ * support; matches the deliberate scope of the in-language synthesizer.
1336
+ *
1337
+ * Provenance `'heuristic'`, synthesizedBy `'rn-event-channel'`.
1338
+ */
1339
+ // ObjC's `[self sendEventWithName:@"X" body:...]` shape (bracket syntax,
1340
+ // `@` string literals).
1341
+ const RN_OBJC_SEND_RE = /\bsendEventWithName\s*:\s*@"([^"]+)"/g;
1342
+ // Swift's `sendEvent(withName: "X", body: ...)` shape — same RCTEventEmitter
1343
+ // method, different call syntax. Both Objective-C and Swift subclass
1344
+ // RCTEventEmitter so this catches the Swift-side equivalent emission sites
1345
+ // (e.g. RNFusedLocation.swift's `sendEvent(withName: "geolocationDidChange",
1346
+ // body: locationData)`).
1347
+ const RN_SWIFT_SEND_RE = /\bsendEvent\s*\(\s*withName\s*:\s*"([^"]+)"/g;
1348
+ // JVM-side emitter calls: `emitter.emit("X", body)`. Matches both Java
1349
+ // and Kotlin syntax because the call form is identical. Restricted to
1350
+ // JVM source files in the consumer so we don't re-process JS emits
1351
+ // (which `eventEmitterEdges` already handles).
1352
+ const RN_JVM_EMIT_RE = /\.emit\s*\(\s*"([^"]+)"\s*,/g;
1353
+ // Custom `sendEvent(reactContext, "X", body)` wrapper — extremely common
1354
+ // (react-native-device-info and many libs wrap `DeviceEventManagerModule…emit`
1355
+ // behind a helper whose `.emit(eventName, …)` uses a VARIABLE, so RN_JVM_EMIT_RE
1356
+ // misses it; the literal lives in the wrapper CALL instead). Captures the first
1357
+ // string literal inside a `sendEvent(...)` call. `[^;{}]*?` keeps it on one
1358
+ // statement and stops at a block boundary, so the wrapper DEFINITION (whose `(`
1359
+ // is followed by `… ) {`) never matches. Multi-line tolerant. (java/kotlin/swift)
1360
+ const RN_NATIVE_SENDEVENT_RE = /\bsendEvent\s*\([^;{}]*?"([^"]+)"/g;
1361
+ function rnEventEdges(ctx) {
1362
+ // Native dispatchers (source = the native method whose body sends the
1363
+ // event) and JS handlers (target = the function/method registered as
1364
+ // the listener) keyed by event name.
1365
+ const nativeDispatchersByEvent = new Map();
1366
+ const jsHandlersByEvent = new Map();
1367
+ for (const file of ctx.getAllFiles()) {
1368
+ const content = ctx.readFile(file);
1369
+ if (!content)
1370
+ continue;
1371
+ const nodesInFile = ctx.getNodesInFile(file);
1372
+ const lineOf = (idx) => content.slice(0, idx).split('\n').length;
1373
+ const addDispatcher = (event, line) => {
1374
+ const disp = enclosingFn(nodesInFile, line);
1375
+ if (!disp)
1376
+ return;
1377
+ const set = nativeDispatchersByEvent.get(event) ?? new Set();
1378
+ set.add(disp.id);
1379
+ nativeDispatchersByEvent.set(event, set);
1380
+ };
1381
+ // ObjC side: `sendEventWithName:@"X"` only fires inside `.m`/`.mm`
1382
+ // files (RCTEventEmitter subclasses).
1383
+ if (file.endsWith('.m') || file.endsWith('.mm')) {
1384
+ RN_OBJC_SEND_RE.lastIndex = 0;
1385
+ let m;
1386
+ while ((m = RN_OBJC_SEND_RE.exec(content))) {
1387
+ if (m[1])
1388
+ addDispatcher(m[1], lineOf(m.index));
1389
+ }
1390
+ }
1391
+ // Swift side: same RCTEventEmitter method, parens/named-args syntax.
1392
+ if (file.endsWith('.swift')) {
1393
+ RN_SWIFT_SEND_RE.lastIndex = 0;
1394
+ let m;
1395
+ while ((m = RN_SWIFT_SEND_RE.exec(content))) {
1396
+ if (m[1])
1397
+ addDispatcher(m[1], lineOf(m.index));
1398
+ }
1399
+ RN_NATIVE_SENDEVENT_RE.lastIndex = 0;
1400
+ while ((m = RN_NATIVE_SENDEVENT_RE.exec(content))) {
1401
+ if (m[1])
1402
+ addDispatcher(m[1], lineOf(m.index));
1403
+ }
1404
+ }
1405
+ // JVM side: `.emit("X", …)` in Java/Kotlin, plus the common
1406
+ // `sendEvent(ctx, "X", body)` wrapper. (We pattern-match anywhere in the
1407
+ // file; the JS in-language path uses a separate emitter object pattern and
1408
+ // is already handled by eventEmitterEdges.)
1409
+ if (file.endsWith('.java') || file.endsWith('.kt')) {
1410
+ let m;
1411
+ RN_JVM_EMIT_RE.lastIndex = 0;
1412
+ while ((m = RN_JVM_EMIT_RE.exec(content))) {
1413
+ if (m[1])
1414
+ addDispatcher(m[1], lineOf(m.index));
1415
+ }
1416
+ RN_NATIVE_SENDEVENT_RE.lastIndex = 0;
1417
+ while ((m = RN_NATIVE_SENDEVENT_RE.exec(content))) {
1418
+ if (m[1])
1419
+ addDispatcher(m[1], lineOf(m.index));
1420
+ }
1421
+ }
1422
+ // JS subscribers (.addListener("X", handler)). Restrict to JS-family
1423
+ // files so a native file's `addListener:` (the ObjC method) doesn't
1424
+ // get mistaken for a JS subscription — they're entirely different
1425
+ // things despite sharing a name.
1426
+ if (file.endsWith('.js') ||
1427
+ file.endsWith('.jsx') ||
1428
+ file.endsWith('.ts') ||
1429
+ file.endsWith('.tsx') ||
1430
+ file.endsWith('.mjs') ||
1431
+ file.endsWith('.cjs')) {
1432
+ // Match BOTH the named-handler form (`.addListener('x', fn)`) and
1433
+ // an unnamed-handler form (`.addListener('x', listener)` where
1434
+ // `listener` is a parameter — common in RN wrapper APIs like
1435
+ // RNFirebase's `messaging().onMessageReceived(listener)`). For the
1436
+ // unnamed case we attribute the subscription to the ENCLOSING JS
1437
+ // function (the abstraction layer), giving a reachability-correct
1438
+ // hop even when the actual user-side handler lives one call up.
1439
+ const ADDLISTENER_ANY = /\.(?:on|once|addListener)\(\s*['"]([^'"]+)['"]\s*,\s*([A-Za-z_][\w.]*)/g;
1440
+ ADDLISTENER_ANY.lastIndex = 0;
1441
+ let m;
1442
+ while ((m = ADDLISTENER_ANY.exec(content))) {
1443
+ const event = m[1];
1444
+ const arg = m[2];
1445
+ if (!event || !arg)
1446
+ continue;
1447
+ const bareName = arg.includes('.') ? arg.slice(arg.lastIndexOf('.') + 1) : arg;
1448
+ // Try a named-symbol match first (matches the in-language semantic).
1449
+ const namedHandler = ctx
1450
+ .getNodesByName(bareName)
1451
+ .find((n) => n.kind === 'function' || n.kind === 'method');
1452
+ let targetId = namedHandler?.id ?? null;
1453
+ if (!targetId) {
1454
+ // Fall back to the enclosing function — the subscribe-wrapper
1455
+ // pattern means the event fires THROUGH this function on its
1456
+ // way to user code. Reachability-correct attribution.
1457
+ const enclosing = enclosingFn(nodesInFile, lineOf(m.index));
1458
+ targetId = enclosing?.id ?? null;
1459
+ }
1460
+ if (!targetId) {
1461
+ // Broader fallback for JS object-literal API shape
1462
+ // (`const Foo = { watchX(...) { … addListener(...) … } }`):
1463
+ // method shorthand inside an object literal isn't extracted
1464
+ // as a method node, so enclosingFn returns null. Attribute to
1465
+ // the smallest enclosing `constant` / `variable` node — that's
1466
+ // the API surface a downstream caller would `import` and
1467
+ // invoke. Reachability-correct.
1468
+ const line = lineOf(m.index);
1469
+ let smallest = null;
1470
+ for (const n of nodesInFile) {
1471
+ if (n.kind !== 'constant' && n.kind !== 'variable')
1472
+ continue;
1473
+ const end = n.endLine ?? n.startLine;
1474
+ if (n.startLine <= line && end >= line) {
1475
+ if (!smallest || n.startLine >= smallest.startLine)
1476
+ smallest = n;
1477
+ }
1478
+ }
1479
+ targetId = smallest?.id ?? null;
1480
+ }
1481
+ if (!targetId)
1482
+ continue;
1483
+ const map = jsHandlersByEvent.get(event) ?? new Map();
1484
+ map.set(targetId, `${file}:${lineOf(m.index)}`);
1485
+ jsHandlersByEvent.set(event, map);
1486
+ }
1487
+ }
1488
+ }
1489
+ const edges = [];
1490
+ const seen = new Set();
1491
+ for (const [event, dispatchers] of nativeDispatchersByEvent) {
1492
+ const handlers = jsHandlersByEvent.get(event);
1493
+ if (!handlers)
1494
+ continue;
1495
+ // Same fan-out guard as the in-language channel: generic event names
1496
+ // (e.g. 'change', 'error', 'data') with many handlers/dispatchers
1497
+ // can't be matched precisely without receiver-type info.
1498
+ if (dispatchers.size > EVENT_FANOUT_CAP || handlers.size > EVENT_FANOUT_CAP)
1499
+ continue;
1500
+ for (const d of dispatchers) {
1501
+ for (const [h, registeredAt] of handlers) {
1502
+ if (d === h)
1503
+ continue;
1504
+ const key = `${d}>${h}`;
1505
+ if (seen.has(key))
1506
+ continue;
1507
+ seen.add(key);
1508
+ edges.push({
1509
+ source: d,
1510
+ target: h,
1511
+ kind: 'calls',
1512
+ provenance: 'heuristic',
1513
+ metadata: { synthesizedBy: 'rn-event-channel', event, registeredAt },
1514
+ });
1515
+ }
1516
+ }
1517
+ }
1518
+ return edges;
1519
+ }
1520
+ /**
1521
+ * Phase 6 — React Native Fabric/Codegen view component bridge.
1522
+ *
1523
+ * The Fabric framework extractor (`frameworks/fabric.ts`) emits
1524
+ * `component` nodes named after the JS-visible component (e.g.
1525
+ * `RNSScreenStack`) from each `codegenNativeComponent<Props>('Name')`
1526
+ * spec declaration. The native implementation lives in an ObjC++/.mm or
1527
+ * Kotlin/Java class whose name follows one of RN's conventions:
1528
+ *
1529
+ * - Exact: `RNSScreenStack`
1530
+ * - With suffix: `RNSScreenStackView`, `RNSScreenStackViewManager`,
1531
+ * `RNSScreenStackComponentView`, `RNSScreenStackManager`
1532
+ *
1533
+ * This synthesizer walks every Fabric component node and looks for a
1534
+ * native class matching one of those names; when found, emits a
1535
+ * `calls` edge `component → native class` (provenance `'heuristic'`,
1536
+ * `synthesizedBy:'fabric-native-impl'`) so trace from JSX usage of the
1537
+ * component continues into native.
1538
+ *
1539
+ * The convention-based suffix lookup is precise: there's no name
1540
+ * collision in RN view-manager codebases by design (Codegen output would
1541
+ * conflict otherwise).
1542
+ */
1543
+ const FABRIC_NATIVE_SUFFIXES = ['', 'View', 'ViewManager', 'ComponentView', 'Manager'];
1544
+ /**
1545
+ * Expo Modules cross-platform pairing. An Expo Module exposes the SAME
1546
+ * JS-visible method (`AsyncFunction("getBatteryLevelAsync")`) from BOTH an iOS
1547
+ * (Swift) and an Android (Kotlin) implementation. A JS callsite name-resolves to
1548
+ * only ONE of them, so the other platform's impl looked like nothing called it
1549
+ * (and editing it showed no blast radius). Link the iOS and Android impls of the
1550
+ * same `<module>.<method>` to each other (both directions), so a JS call that
1551
+ * reaches one platform reaches the other, and editing either surfaces the JS
1552
+ * caller. The Expo method nodes are id-prefixed `expo-module:` and qualified
1553
+ * `<file>::<module>.<method>` by the framework extractor.
1554
+ */
1555
+ function expoCrossPlatformEdges(queries) {
1556
+ const edges = [];
1557
+ const seen = new Set();
1558
+ const byKey = new Map();
1559
+ for (const m of queries.getNodesByKind('method')) {
1560
+ if (!m.id.startsWith('expo-module:'))
1561
+ continue;
1562
+ const key = m.qualifiedName.split('::').pop(); // `<module>.<method>`
1563
+ if (!key)
1564
+ continue;
1565
+ const arr = byKey.get(key);
1566
+ if (arr)
1567
+ arr.push(m);
1568
+ else
1569
+ byKey.set(key, [m]);
1570
+ }
1571
+ for (const group of byKey.values()) {
1572
+ if (group.length < 2)
1573
+ continue;
1574
+ for (const a of group) {
1575
+ for (const b of group) {
1576
+ if (a.id === b.id || a.language === b.language)
1577
+ continue; // cross-platform only
1578
+ const key = `${a.id}>${b.id}`;
1579
+ if (seen.has(key))
1580
+ continue;
1581
+ seen.add(key);
1582
+ edges.push({
1583
+ source: a.id,
1584
+ target: b.id,
1585
+ kind: 'calls',
1586
+ line: a.startLine,
1587
+ provenance: 'heuristic',
1588
+ metadata: { synthesizedBy: 'expo-cross-platform', via: a.name },
1589
+ });
1590
+ }
1591
+ }
1592
+ }
1593
+ return edges;
1594
+ }
1595
+ /**
1596
+ * Classic React Native NativeModules cross-platform pairing. A native module
1597
+ * method (`@ReactMethod` on Android, `RCT_EXPORT_METHOD` on iOS) is implemented
1598
+ * on BOTH platforms, but a JS callsite name-resolves to only ONE — so the other
1599
+ * platform's impl looked like nothing called it. A native method that HAS a JS
1600
+ * caller is a confirmed bridge method; link it to the same-named native method
1601
+ * in another language (the other platform's impl) so a JS call reaching one
1602
+ * platform reaches the other, and editing either surfaces the JS caller.
1603
+ *
1604
+ * Names are normalized to the first selector keyword (`getFreeDiskStorage:` →
1605
+ * `getFreeDiskStorage`) — that's the JS-visible name, and how the iOS selector
1606
+ * lines up with the bare Android method name.
1607
+ */
1608
+ function rnCrossPlatformEdges(queries) {
1609
+ const edges = [];
1610
+ const seen = new Set();
1611
+ const NATIVE = new Set(['java', 'kotlin', 'objc', 'cpp']);
1612
+ const JS = new Set(['typescript', 'tsx', 'javascript', 'jsx']);
1613
+ // RN module INFRASTRUCTURE methods exist on every native module (called by the
1614
+ // RN runtime, not user JS), so pairing them by name would cross-link unrelated
1615
+ // modules in a multi-module repo. Skip them — they aren't user-facing methods.
1616
+ const RN_INFRA = new Set([
1617
+ 'addListener', 'removeListeners', 'getConstants', 'constantsToExport', 'getName',
1618
+ 'invalidate', 'initialize', 'getDefaultEventTypes', 'supportedEvents',
1619
+ 'requiresMainQueueSetup', 'methodQueue',
1620
+ ]);
1621
+ const norm = (name) => {
1622
+ const i = name.indexOf(':');
1623
+ return i >= 0 ? name.slice(0, i) : name;
1624
+ };
1625
+ // Index native methods by their JS-visible (normalized) name. Only names with
1626
+ // impls in ≥2 native languages can pair, so the per-method JS-caller check
1627
+ // below only runs for genuine cross-platform candidates.
1628
+ const byName = new Map();
1629
+ for (const m of queries.iterateNodesByKind('method')) {
1630
+ if (!NATIVE.has(m.language))
1631
+ continue;
1632
+ const key = norm(m.name);
1633
+ const arr = byName.get(key);
1634
+ if (arr)
1635
+ arr.push(m);
1636
+ else
1637
+ byName.set(key, [m]);
1638
+ }
1639
+ for (const [groupName, group] of byName) {
1640
+ if (RN_INFRA.has(groupName))
1641
+ continue;
1642
+ const langs = new Set(group.map((m) => m.language));
1643
+ if (langs.size < 2)
1644
+ continue; // single-platform — nothing to pair
1645
+ for (const m of group) {
1646
+ // Is m a bridge method? (a JS-language `calls` edge points at it)
1647
+ const incoming = queries.getIncomingEdges(m.id, ['calls']);
1648
+ if (incoming.length === 0)
1649
+ continue;
1650
+ const sources = queries.getNodesByIds(incoming.map((e) => e.source));
1651
+ const isBridge = incoming.some((e) => {
1652
+ const s = sources.get(e.source);
1653
+ return !!s && JS.has(s.language);
1654
+ });
1655
+ if (!isBridge)
1656
+ continue;
1657
+ // Link to the other-platform impls (both directions).
1658
+ for (const sib of group) {
1659
+ if (sib.id === m.id || sib.language === m.language)
1660
+ continue;
1661
+ for (const [a, b] of [[m, sib], [sib, m]]) {
1662
+ const key = `${a.id}>${b.id}`;
1663
+ if (seen.has(key))
1664
+ continue;
1665
+ seen.add(key);
1666
+ edges.push({
1667
+ source: a.id,
1668
+ target: b.id,
1669
+ kind: 'calls',
1670
+ line: a.startLine,
1671
+ provenance: 'heuristic',
1672
+ metadata: { synthesizedBy: 'rn-cross-platform', via: norm(m.name) },
1673
+ });
1674
+ }
1675
+ }
1676
+ }
1677
+ }
1678
+ return edges;
1679
+ }
1680
+ function fabricNativeImplEdges(ctx) {
1681
+ const edges = [];
1682
+ const seen = new Set();
1683
+ // The Fabric extractor IDs are prefixed `fabric-component:` so we can
1684
+ // filter to just those without iterating all `component` nodes.
1685
+ const components = ctx.getNodesByKind('component').filter((n) => n.id.startsWith('fabric-component:'));
1686
+ if (components.length === 0)
1687
+ return edges;
1688
+ // Pre-index native classes by name for O(1) lookup.
1689
+ const nativeClassesByName = new Map();
1690
+ for (const n of ctx.getNodesByKind('class')) {
1691
+ if (n.language !== 'objc' && n.language !== 'kotlin' && n.language !== 'java' && n.language !== 'cpp')
1692
+ continue;
1693
+ const arr = nativeClassesByName.get(n.name);
1694
+ if (arr)
1695
+ arr.push(n);
1696
+ else
1697
+ nativeClassesByName.set(n.name, [n]);
1698
+ }
1699
+ for (const component of components) {
1700
+ for (const suffix of FABRIC_NATIVE_SUFFIXES) {
1701
+ const candidate = component.name + suffix;
1702
+ const matches = nativeClassesByName.get(candidate);
1703
+ if (!matches || matches.length === 0)
1704
+ continue;
1705
+ // Link the component node to every matching native class (iOS +
1706
+ // Android each have one).
1707
+ for (const native of matches) {
1708
+ const key = `${component.id}>${native.id}`;
1709
+ if (seen.has(key))
1710
+ continue;
1711
+ seen.add(key);
1712
+ edges.push({
1713
+ source: component.id,
1714
+ target: native.id,
1715
+ kind: 'calls',
1716
+ provenance: 'heuristic',
1717
+ metadata: {
1718
+ synthesizedBy: 'fabric-native-impl',
1719
+ viaSuffix: suffix || '(exact)',
1720
+ componentName: component.name,
1721
+ },
1722
+ });
1723
+ }
1724
+ }
1725
+ }
1726
+ return edges;
1727
+ }
1728
+ /**
1729
+ * MyBatis: link a Java mapper interface method to the XML statement that holds
1730
+ * its SQL. The XML extractor (`src/extraction/mybatis-extractor.ts`) qualifies
1731
+ * each `<select|insert|update|delete|sql id="X">` as `<namespace>::<id>` where
1732
+ * `<namespace>` is the Java FQN of the mapper interface. A Java method's
1733
+ * qualifiedName ends with `<ClassName>::<methodName>`, so we suffix-match the
1734
+ * last two segments of the XML qualified name to find a unique Java method by
1735
+ * `<ClassName>::<methodName>` (`ClassName` = last dotted segment of the XML
1736
+ * namespace). Cross-mapper `<include refid="other.X">` references go through
1737
+ * the normal qualified-name resolver — only the Java↔XML bridge is synthetic.
1738
+ *
1739
+ * Precision over recall: ambiguous mappers (multiple Java classes with the
1740
+ * same simple name) are dropped. We need-not bridge by package because Java
1741
+ * mapper interfaces are typically uniquely named within a project.
1742
+ */
1743
+ function mybatisJavaXmlEdges(queries) {
1744
+ const edges = [];
1745
+ const seen = new Set();
1746
+ // Index Java methods by `<ClassName>::<methodName>` for O(1) lookup.
1747
+ const javaIndex = new Map();
1748
+ for (const m of queries.iterateNodesByKind('method')) {
1749
+ if (m.language !== 'java' && m.language !== 'kotlin')
1750
+ continue;
1751
+ const parts = m.qualifiedName.split('::');
1752
+ const last = parts[parts.length - 1];
1753
+ const cls = parts[parts.length - 2];
1754
+ if (!last || !cls)
1755
+ continue;
1756
+ const key = `${cls}::${last}`;
1757
+ const arr = javaIndex.get(key);
1758
+ if (arr)
1759
+ arr.push(m);
1760
+ else
1761
+ javaIndex.set(key, [m]);
1762
+ }
1763
+ for (const xml of queries.iterateNodesByKind('method')) {
1764
+ if (xml.language !== 'xml')
1765
+ continue;
1766
+ // Qualified name: `<namespace>::<id>`. Extract the simple class name.
1767
+ const colonIdx = xml.qualifiedName.lastIndexOf('::');
1768
+ if (colonIdx < 0)
1769
+ continue;
1770
+ const namespace = xml.qualifiedName.slice(0, colonIdx);
1771
+ const id = xml.qualifiedName.slice(colonIdx + 2);
1772
+ if (!namespace || !id)
1773
+ continue;
1774
+ const dotIdx = namespace.lastIndexOf('.');
1775
+ const className = dotIdx >= 0 ? namespace.slice(dotIdx + 1) : namespace;
1776
+ const candidates = javaIndex.get(`${className}::${id}`);
1777
+ if (!candidates || candidates.length === 0)
1778
+ continue;
1779
+ // Drop ambiguous matches (multiple same-name classes); the user can
1780
+ // disambiguate by adding the package-suffix match in a future enhancement.
1781
+ if (candidates.length > 1)
1782
+ continue;
1783
+ const java = candidates[0];
1784
+ const key = `${java.id}>${xml.id}`;
1785
+ if (seen.has(key))
1786
+ continue;
1787
+ seen.add(key);
1788
+ edges.push({
1789
+ source: java.id,
1790
+ target: xml.id,
1791
+ kind: 'calls',
1792
+ line: java.startLine,
1793
+ provenance: 'heuristic',
1794
+ metadata: {
1795
+ synthesizedBy: 'mybatis-java-xml',
1796
+ via: `${className}.${id}`,
1797
+ registeredAt: `${xml.filePath}:${xml.startLine}`,
1798
+ },
1799
+ });
1800
+ }
1801
+ return edges;
1802
+ }
1803
+ /**
1804
+ * Gin middleware chain. Gin runs its entire handler chain through one dynamic
1805
+ * line in `(*Context).Next`:
1806
+ * for c.index < len(c.handlers) { c.handlers[c.index](c); c.index++ }
1807
+ * `c.handlers` is a `HandlersChain` (`[]HandlerFunc`) assembled at registration
1808
+ * time by `combineHandlers` from the funcs passed to `r.Use(...)` /
1809
+ * `r.GET("/path", h...)` / `r.Handle(...)`. Because the call is a computed index
1810
+ * into a runtime-built slice, tree-sitter resolves `c.handlers[c.index](c)` to
1811
+ * NOTHING — so `callees(Next)` is just the `len()` helper and the flow
1812
+ * `ServeHTTP → handleHTTPRequest → Next` dead-ends at the exact symbol the
1813
+ * "how do requests flow through the middleware chain" question is about. The
1814
+ * agent then re-queries Next and falls back to Read/grep (validated: the gin
1815
+ * WITH-arm rabbit-holed on precisely this dead-end).
1816
+ *
1817
+ * Bridge it: find the chain DISPATCHER (a Go method whose body invokes a
1818
+ * `handlers` slice by index) and link it → every HandlerFunc registered via a
1819
+ * gin registration call, so `callees(Next)` and `trace(ServeHTTP, <handler>)`
1820
+ * connect end-to-end. Named handlers only (`gin.Logger()` → `Logger`,
1821
+ * `authMiddleware`); inline closures are anonymous and skipped. Like
1822
+ * react-render / interface-impl this is a deliberate over-approximation —
1823
+ * reachability-correct (any registered handler CAN run for some route), capped,
1824
+ * and gated on the dispatcher existing so it never runs on non-gin Go repos.
1825
+ * Provenance `heuristic`, `synthesizedBy:'gin-middleware-chain'`; `registeredAt`
1826
+ * is the `.Use`/`.GET` site an agent would otherwise grep for.
1827
+ */
1828
+ const GIN_DISPATCH_RE = /\.handlers\s*\[[^\]]*\]\s*\(/; // c.handlers[c.index](c)
1829
+ const GIN_REG_RE = /\.(?:Use|GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|Any|Handle)\s*\(/g;
1830
+ /** Balanced `(...)` body starting at the '(' index; null if unbalanced. */
1831
+ function goBalancedArgs(s, openIdx) {
1832
+ let depth = 0;
1833
+ for (let i = openIdx; i < s.length; i++) {
1834
+ const c = s[i];
1835
+ if (c === '(')
1836
+ depth++;
1837
+ else if (c === ')') {
1838
+ depth--;
1839
+ if (depth === 0)
1840
+ return s.slice(openIdx + 1, i);
1841
+ }
1842
+ }
1843
+ return null;
1844
+ }
1845
+ /** Split a top-level comma list, respecting nested () [] {}. */
1846
+ function goSplitArgs(args) {
1847
+ const out = [];
1848
+ let depth = 0, cur = '';
1849
+ for (const c of args) {
1850
+ if (c === '(' || c === '[' || c === '{') {
1851
+ depth++;
1852
+ cur += c;
1853
+ }
1854
+ else if (c === ')' || c === ']' || c === '}') {
1855
+ depth--;
1856
+ cur += c;
1857
+ }
1858
+ else if (c === ',' && depth === 0) {
1859
+ out.push(cur);
1860
+ cur = '';
1861
+ }
1862
+ else
1863
+ cur += c;
1864
+ }
1865
+ if (cur.trim())
1866
+ out.push(cur);
1867
+ return out;
1868
+ }
1869
+ /** Tail ident of a handler arg: `gin.Logger()`→`Logger`, `mw`→`mw`; null for string paths / closures. */
1870
+ function goHandlerIdent(expr) {
1871
+ const cleaned = expr.trim().replace(/\(\s*\)$/, ''); // drop a trailing call ()
1872
+ if (!cleaned || cleaned.startsWith('"') || cleaned.startsWith('`') || cleaned.startsWith('func'))
1873
+ return null;
1874
+ const m = cleaned.match(/(?:\.|^)([A-Za-z_]\w*)$/);
1875
+ return m ? m[1] : null;
1876
+ }
1877
+ function ginMiddlewareChainEdges(queries, ctx) {
1878
+ // 1. Find the chain dispatcher(s): a Go method that invokes a `handlers` slice by index.
1879
+ const dispatchers = [];
1880
+ for (const n of queries.iterateNodesByKind('method')) {
1881
+ if (n.language !== 'go')
1882
+ continue;
1883
+ const content = ctx.readFile(n.filePath);
1884
+ const src = content && sliceLines(content, n.startLine, n.endLine);
1885
+ if (src && GIN_DISPATCH_RE.test(src))
1886
+ dispatchers.push(n);
1887
+ }
1888
+ if (dispatchers.length === 0)
1889
+ return []; // not a gin repo — bail
1890
+ // 2. Collect handler identifiers registered via gin registration calls
1891
+ // (.Use / .GET / … / .Handle). String args (paths/methods) and inline
1892
+ // closures are dropped by goHandlerIdent; the rest are HandlerFuncs.
1893
+ const registered = new Map(); // name → registeredAt (file:line)
1894
+ for (const file of ctx.getAllFiles()) {
1895
+ if (!file.endsWith('.go'))
1896
+ continue;
1897
+ const content = ctx.readFile(file);
1898
+ if (!content || (!content.includes('.Use(') && !/\.(?:GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|Any|Handle)\(/.test(content)))
1899
+ continue;
1900
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'go');
1901
+ GIN_REG_RE.lastIndex = 0;
1902
+ let m;
1903
+ while ((m = GIN_REG_RE.exec(safe))) {
1904
+ const parenIdx = m.index + m[0].length - 1;
1905
+ const argStr = goBalancedArgs(safe, parenIdx);
1906
+ if (!argStr)
1907
+ continue;
1908
+ const line = safe.slice(0, m.index).split('\n').length;
1909
+ for (const arg of goSplitArgs(argStr)) {
1910
+ const name = goHandlerIdent(arg);
1911
+ if (name && !registered.has(name))
1912
+ registered.set(name, `${file}:${line}`);
1913
+ }
1914
+ }
1915
+ }
1916
+ if (registered.size === 0)
1917
+ return [];
1918
+ // 3. Link each dispatcher → each registered handler node (dedup, capped).
1919
+ const edges = [];
1920
+ const seen = new Set();
1921
+ for (const disp of dispatchers) {
1922
+ let added = 0;
1923
+ for (const [name, registeredAt] of registered) {
1924
+ if (added >= MAX_CALLBACKS_PER_CHANNEL)
1925
+ break;
1926
+ const handler = ctx.getNodesByName(name).find((n) => (n.kind === 'function' || n.kind === 'method') && n.language === 'go');
1927
+ if (!handler || handler.id === disp.id)
1928
+ continue;
1929
+ const key = `${disp.id}>${handler.id}`;
1930
+ if (seen.has(key))
1931
+ continue;
1932
+ seen.add(key);
1933
+ edges.push({
1934
+ source: disp.id, target: handler.id, kind: 'calls', line: disp.startLine,
1935
+ provenance: 'heuristic',
1936
+ metadata: { synthesizedBy: 'gin-middleware-chain', via: name, registeredAt },
1937
+ });
1938
+ added++;
1939
+ }
1940
+ }
1941
+ return edges;
1942
+ }
1943
+ /**
1944
+ * Delphi form code-behind: a form unit `UFRMAbout.pas` owns its visual form
1945
+ * definition `UFRMAbout.dfm` (VCL) / `.fmx` (FireMonkey) — paired by basename in
1946
+ * the same directory, wired by the `{$R *.dfm}` directive rather than a `uses`
1947
+ * clause. Link the unit → its form so a `.dfm`/`.fmx` used only as a form
1948
+ * definition isn't orphaned, and editing the form surfaces its code-behind unit.
1949
+ */
1950
+ function pascalFormEdges(ctx) {
1951
+ const edges = [];
1952
+ const allFiles = new Set(ctx.getAllFiles());
1953
+ for (const file of allFiles) {
1954
+ if (!/\.(dfm|fmx)$/i.test(file))
1955
+ continue;
1956
+ const pasFile = file.replace(/\.(dfm|fmx)$/i, '.pas');
1957
+ if (!allFiles.has(pasFile))
1958
+ continue;
1959
+ const formNode = ctx.getNodesInFile(file).find((n) => n.kind === 'file');
1960
+ const unitNode = ctx.getNodesInFile(pasFile).find((n) => n.kind === 'file');
1961
+ if (!formNode || !unitNode)
1962
+ continue;
1963
+ edges.push({
1964
+ source: unitNode.id,
1965
+ target: formNode.id,
1966
+ kind: 'references',
1967
+ line: unitNode.startLine,
1968
+ provenance: 'heuristic',
1969
+ metadata: { synthesizedBy: 'pascal-form', registeredAt: pasFile },
1970
+ });
1971
+ }
1972
+ return edges;
1973
+ }
1974
+ /**
1975
+ * SvelteKit file-convention data flow. A route directory's `+page.svelte` (a
1976
+ * `component` node) receives its `data` from the sibling `+page.server.{ts,js}`
1977
+ * / `+page.{ts,js}` `load` function and posts forms to its `actions` — wired by
1978
+ * the framework BY FILE PATH, with no static import between them. So editing a
1979
+ * `load` shows no impact on the page it feeds, and the page looks like it has no
1980
+ * server-side dependency. Link the page component to its sibling loader's
1981
+ * `load` / `actions` (same for `+layout`). The pairing is path-deterministic
1982
+ * (same directory, matching `+page`/`+layout` prefix), so it's precise — but
1983
+ * it's a framework-convention edge, so provenance stays `heuristic`.
1984
+ *
1985
+ * Direction: page → load, so `getImpactRadius(load)` surfaces the page (editing
1986
+ * a loader's data shows the page it feeds) and the page's dependencies include
1987
+ * its loader.
1988
+ */
1989
+ function svelteKitLoadEdges(ctx) {
1990
+ const edges = [];
1991
+ const allFiles = new Set(ctx.getAllFiles());
1992
+ const HOOKS = new Set(['load', 'actions']);
1993
+ const HOOK_KINDS = new Set(['function', 'method', 'constant', 'variable']);
1994
+ for (const file of allFiles) {
1995
+ const m = file.match(/(.*\/)(\+(?:page|layout))\.svelte$/);
1996
+ if (!m)
1997
+ continue;
1998
+ const dir = m[1];
1999
+ const prefix = m[2];
2000
+ const page = ctx.getNodesInFile(file).find((n) => n.kind === 'component');
2001
+ if (!page)
2002
+ continue;
2003
+ for (const ext of ['.server.ts', '.server.js', '.ts', '.js']) {
2004
+ const loaderFile = `${dir}${prefix}${ext}`;
2005
+ if (!allFiles.has(loaderFile))
2006
+ continue;
2007
+ for (const hook of ctx.getNodesInFile(loaderFile)) {
2008
+ if (!HOOK_KINDS.has(hook.kind) || !HOOKS.has(hook.name))
2009
+ continue;
2010
+ edges.push({
2011
+ source: page.id,
2012
+ target: hook.id,
2013
+ kind: 'references',
2014
+ line: page.startLine,
2015
+ provenance: 'heuristic',
2016
+ metadata: {
2017
+ synthesizedBy: 'sveltekit-load',
2018
+ via: hook.name,
2019
+ registeredAt: `${loaderFile}:${hook.startLine ?? 0}`,
2020
+ },
2021
+ });
2022
+ }
2023
+ }
2024
+ }
2025
+ return edges;
2026
+ }
2027
+ /**
2028
+ * Redux-thunk dispatch chain. `export const X = createAsyncThunk(prefix, async (a, api) => {...})`
2029
+ * (or a wrapper like trezor's `createThunk(...)`) passes the async body as an ARGUMENT, so
2030
+ * tree-sitter never extracts it as a function node: `X` is a `constant` whose body's calls are
2031
+ * ORPHANED. The `dispatch(nextThunk(...))` calls that drive a thunk chain forward therefore produce
2032
+ * no edges, so `callees(X)` is empty and a flow `dispatch(X(...)) → X → nextThunk` dead-ends at the
2033
+ * constant (validated on trezor-suite: the signXxxThunk constants had ZERO outgoing edges). Bridge
2034
+ * it: body-scan each thunk constant for `dispatch(Y(...))` and link `X → Y`, so the dispatch chain
2035
+ * connects. High-precision — the `dispatch(` keyword plus `Y` must resolve to a function/constant/
2036
+ * method node; capped; gated on thunk constants existing so it never runs on non-RTK repos.
2037
+ * Cross-file by design (a suite thunk dispatches a wallet-core thunk). Provenance `heuristic`,
2038
+ * `synthesizedBy:'redux-thunk'`; `registeredAt` is the dispatch site.
2039
+ */
2040
+ const THUNK_DECL_RE = /create(?:Async)?Thunk/;
2041
+ const THUNK_DISPATCH_RE = /\bdispatch\s*\(\s*([A-Za-z_]\w*)\s*[(),]/g;
2042
+ const THUNK_FANOUT_CAP = 24;
2043
+ function reduxThunkEdges(queries, ctx) {
2044
+ const edges = [];
2045
+ const seen = new Set();
2046
+ for (const node of queries.iterateNodesByKind('constant')) {
2047
+ // Cheap gate: the initializer (captured in `signature`) must be a create(Async)Thunk call —
2048
+ // avoids reading every constant's body on a large repo.
2049
+ if (!node.signature || !THUNK_DECL_RE.test(node.signature))
2050
+ continue;
2051
+ const content = ctx.readFile(node.filePath);
2052
+ const src = content && sliceLines(content, node.startLine, node.endLine);
2053
+ if (!src)
2054
+ continue;
2055
+ // Thunks are TS/JS-family (same // and /* */ comment syntax); map to a CommentLang.
2056
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(src, node.language === 'javascript' || node.language === 'jsx' ? 'javascript' : 'typescript');
2057
+ THUNK_DISPATCH_RE.lastIndex = 0;
2058
+ let m;
2059
+ let added = 0;
2060
+ while ((m = THUNK_DISPATCH_RE.exec(safe)) && added < THUNK_FANOUT_CAP) {
2061
+ const name = m[1];
2062
+ if (name === node.name)
2063
+ continue; // self-dispatch (recursive thunk) — skip
2064
+ // Resolve the dispatched name, PREFERRING the thunk/action-creator over a same-named
2065
+ // service function. `dispatch(X(...))` dispatches a thunk or an action-creator (both
2066
+ // `constant`s) — never an unrelated helper that merely shares the name. On octo-call,
2067
+ // `leaveCall` is BOTH a `createAsyncThunk` const AND a service function, and the bare
2068
+ // `.find()` picked the function (wrong). Order: thunk const > other const > same-file
2069
+ // callable > first match. A single candidate (no collision) is unaffected.
2070
+ const cands = ctx
2071
+ .getNodesByName(name)
2072
+ .filter((n) => n.kind === 'constant' || n.kind === 'function' || n.kind === 'method');
2073
+ const target = cands.find((n) => !!n.signature && THUNK_DECL_RE.test(n.signature)) ??
2074
+ cands.find((n) => n.kind === 'constant') ??
2075
+ cands.find((n) => n.filePath === node.filePath) ??
2076
+ cands[0];
2077
+ if (!target || target.id === node.id)
2078
+ continue;
2079
+ const key = `${node.id}>${target.id}`;
2080
+ if (seen.has(key))
2081
+ continue;
2082
+ seen.add(key);
2083
+ const line = node.startLine + safe.slice(0, m.index).split('\n').length - 1;
2084
+ edges.push({
2085
+ source: node.id,
2086
+ target: target.id,
2087
+ kind: 'calls',
2088
+ line,
2089
+ provenance: 'heuristic',
2090
+ metadata: { synthesizedBy: 'redux-thunk', via: name, registeredAt: `${node.filePath}:${line}` },
2091
+ });
2092
+ added++;
2093
+ }
2094
+ }
2095
+ return edges;
2096
+ }
2097
+ // ── Object-literal registry dispatch ─────────────────────────────────────────
2098
+ // A command/handler registry maps string keys → handler class/function symbols in an
2099
+ // object literal, then dispatches by a RUNTIME key static parsing can't follow:
2100
+ // this.commands = { [Cmd.ADD]: AddObjectCommand, ... } // registration
2101
+ // new this.commands[command](args).execute() // dynamic dispatch
2102
+ // Bridge it like gin-middleware-chain: link each dispatching function → each registered
2103
+ // handler's callable entry (a class's execute/run/handle/… method — preferring the method
2104
+ // chained at the dispatch site — or the function value). Scoped to a registry + dispatch in
2105
+ // the SAME file (the cross-file barrel-namespace variant, e.g. trezor's getMethod, is
2106
+ // deferred). Gated on a real object literal with ≥2 entries that RESOLVE to callables (a
2107
+ // `{ width: 5 }` literal resolves to nothing → no edges); fan-out capped.
2108
+ const REGISTRY_ASSIGN_RE = /(?:(?:const|let|var)\s+([A-Za-z_$][\w$]*)|((?:this\.)?[A-Za-z_$][\w$]*))\s*=\s*\{/g;
2109
+ const REGISTRY_DISPATCH_RE = /(?:\bnew\s+)?((?:this\.)?[A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$.]*)\s*\]\s*(?:\(|\.[A-Za-z_$])/g;
2110
+ const REGISTRY_MIN_ENTRIES = 2;
2111
+ const REGISTRY_FANOUT_CAP = 40;
2112
+ const REGISTRY_CLASS_ENTRY = new Set(['execute', 'run', 'handle', 'perform', 'process', 'call', 'apply', 'dispatch']);
2113
+ const REGISTRY_JS_EXT = /\.(?:ts|tsx|js|jsx|mjs|cjs)$/;
2114
+ /** From the index of an opening `{`, return the brace-balanced body up to its matching `}`. */
2115
+ function braceBody(src, openIdx) {
2116
+ let depth = 0;
2117
+ for (let i = openIdx; i < src.length; i++) {
2118
+ if (src[i] === '{')
2119
+ depth++;
2120
+ else if (src[i] === '}' && --depth === 0)
2121
+ return src.slice(openIdx + 1, i);
2122
+ }
2123
+ return null;
2124
+ }
2125
+ /** Top-level `key: Identifier` entries of an object-literal body. DEPTH-AWARE: only depth-0
2126
+ * segments are considered, so method-shorthand bodies (`number(a,b){…}`), arrow values
2127
+ * (`x: () => …`), and nested objects (`x: { … }`) don't leak their inner `k: v` pairs as
2128
+ * bogus handlers. The per-segment anchor (`^… key: Ident …$`) keeps only pure identifier
2129
+ * values — a data value (`x: 5`), call, or arrow fails to match. */
2130
+ function registryEntryNames(body) {
2131
+ const segs = [];
2132
+ let depth = 0;
2133
+ let start = 0;
2134
+ for (let i = 0; i < body.length; i++) {
2135
+ const c = body[i];
2136
+ if (c === '{' || c === '(' || c === '[')
2137
+ depth++;
2138
+ else if (c === '}' || c === ')' || c === ']')
2139
+ depth--;
2140
+ else if (c === ',' && depth === 0) {
2141
+ segs.push(body.slice(start, i));
2142
+ start = i + 1;
2143
+ }
2144
+ }
2145
+ segs.push(body.slice(start));
2146
+ const names = [];
2147
+ for (const seg of segs) {
2148
+ const m = /^\s*(?:\[[^\]]+\]|['"]?[\w$]+['"]?)\s*:\s*([A-Za-z_$][\w$]*)\s*$/.exec(seg);
2149
+ if (m && m[1].length >= 3 && !names.includes(m[1]))
2150
+ names.push(m[1]);
2151
+ }
2152
+ return names;
2153
+ }
2154
+ /** Resolve a registered handler name to its callable entry: a function value, or a class's
2155
+ * `execute`-like method (preferring the method chained at the dispatch site), else the class. */
2156
+ function resolveRegistryHandler(ctx, name, chained) {
2157
+ const cands = ctx.getNodesByName(name);
2158
+ const fn = cands.find((n) => n.kind === 'function');
2159
+ if (fn)
2160
+ return fn;
2161
+ const cls = cands.find((n) => n.kind === 'class' || n.kind === 'struct');
2162
+ if (cls) {
2163
+ const methods = ctx
2164
+ .getNodesInFile(cls.filePath)
2165
+ .filter((n) => n.kind === 'method' && n.startLine >= cls.startLine && n.startLine <= (cls.endLine ?? cls.startLine));
2166
+ const want = chained && REGISTRY_CLASS_ENTRY.has(chained) ? chained : null;
2167
+ const entry = (want && methods.find((m) => m.name === want)) ||
2168
+ methods.find((m) => REGISTRY_CLASS_ENTRY.has(m.name)) ||
2169
+ methods.find((m) => m.name === 'constructor');
2170
+ return entry ?? cls;
2171
+ }
2172
+ // Require a CALLABLE target — a registry dispatched as `reg[k](…)` invokes a function/
2173
+ // method, never a data `constant` (dropping it removes false positives like a `{ x: URL }`
2174
+ // entry resolving to the global URL constant).
2175
+ return cands.find((n) => n.kind === 'method') ?? null;
2176
+ }
2177
+ async function objectRegistryEdges(ctx, onYield) {
2178
+ const edges = [];
2179
+ const seen = new Set();
2180
+ let scanned = 0;
2181
+ for (const file of ctx.getAllFiles()) {
2182
+ if ((++scanned & 255) === 0)
2183
+ await onYield(); // #1091: yield mid-scan on huge graphs
2184
+ if (!REGISTRY_JS_EXT.test(file))
2185
+ continue;
2186
+ const content = ctx.readFile(file);
2187
+ // Cheap pre-filter: a computed member access BY NAME (`ident[ident`) — the dispatch shape.
2188
+ if (!content || !/[\w$]\s*\[\s*[A-Za-z_$]/.test(content))
2189
+ continue;
2190
+ // Skip minified/generated bundles (draco, three.min, base64…): their pervasive `h[x](...)`
2191
+ // calls + single-letter `{a:b}` literals are a false-positive minefield. Average line
2192
+ // length is the reliable tell — real source ~30–80, minified in the hundreds/thousands.
2193
+ const newlines = (content.match(/\n/g)?.length ?? 0) + 1;
2194
+ if (content.length / newlines > 200)
2195
+ continue;
2196
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, /\.(?:jsx?|mjs|cjs)$/.test(file) ? 'javascript' : 'typescript');
2197
+ // 1. Dispatch sites: `(new )?<ref>[<ident-key>]` followed by a call or a chained method.
2198
+ // A quoted-string key (`['save']`) does NOT match — that's a static access, not dispatch.
2199
+ REGISTRY_DISPATCH_RE.lastIndex = 0;
2200
+ const dispatches = [];
2201
+ let dm;
2202
+ while ((dm = REGISTRY_DISPATCH_RE.exec(safe))) {
2203
+ const win = safe.slice(dm.index, dm.index + 160);
2204
+ const cm = /\]\s*\([^)]*\)\s*\.\s*([A-Za-z_$][\w$]*)/.exec(win) || /\]\s*\.\s*([A-Za-z_$][\w$]*)/.exec(win);
2205
+ dispatches.push({ ref: dm[1], line: safe.slice(0, dm.index).split('\n').length, chained: cm ? cm[1] : null });
2206
+ }
2207
+ if (!dispatches.length)
2208
+ continue;
2209
+ // Normalize a leading `this.` so a class FIELD-INITIALIZER registry (`commands = {…}`)
2210
+ // matches a `this.commands[k]` dispatch, not just the constructor form `this.commands = {…}`.
2211
+ const norm = (r) => r.replace(/^this\./, '');
2212
+ const refs = new Set(dispatches.map((d) => norm(d.ref)));
2213
+ // 2. Registries: an object literal assigned to a dispatched ref, ≥2 entries resolving to callables.
2214
+ REGISTRY_ASSIGN_RE.lastIndex = 0;
2215
+ const registries = new Map();
2216
+ let am;
2217
+ while ((am = REGISTRY_ASSIGN_RE.exec(safe))) {
2218
+ const lhs = norm(am[1] ?? am[2]);
2219
+ if (!refs.has(lhs) || registries.has(lhs))
2220
+ continue;
2221
+ const body = braceBody(safe, am.index + am[0].length - 1);
2222
+ if (!body)
2223
+ continue;
2224
+ const names = registryEntryNames(body); // depth-0 `key: Identifier` entries only
2225
+ if (names.length >= REGISTRY_MIN_ENTRIES) {
2226
+ registries.set(lhs, { names, line: safe.slice(0, am.index).split('\n').length });
2227
+ }
2228
+ }
2229
+ if (!registries.size)
2230
+ continue;
2231
+ // 3. Link each dispatcher → each registered handler's callable entry.
2232
+ const nodesInFile = ctx.getNodesInFile(file);
2233
+ for (const d of dispatches) {
2234
+ const reg = registries.get(norm(d.ref));
2235
+ if (!reg)
2236
+ continue;
2237
+ const disp = enclosingFn(nodesInFile, d.line);
2238
+ if (!disp)
2239
+ continue;
2240
+ let added = 0;
2241
+ for (const name of reg.names) {
2242
+ if (added >= REGISTRY_FANOUT_CAP)
2243
+ break;
2244
+ const target = resolveRegistryHandler(ctx, name, d.chained);
2245
+ if (!target || target.id === disp.id)
2246
+ continue;
2247
+ const key = `${disp.id}>${target.id}`;
2248
+ if (seen.has(key))
2249
+ continue;
2250
+ seen.add(key);
2251
+ edges.push({
2252
+ source: disp.id,
2253
+ target: target.id,
2254
+ kind: 'calls',
2255
+ line: d.line,
2256
+ provenance: 'heuristic',
2257
+ metadata: { synthesizedBy: 'object-registry', via: name, registeredAt: `${file}:${reg.line}` },
2258
+ });
2259
+ added++;
2260
+ }
2261
+ }
2262
+ }
2263
+ return edges;
2264
+ }
2265
+ // ── RTK Query generated-hook → endpoint ──────────────────────────────────────
2266
+ // RTK Query generates one `useGetXQuery`/`useUpdateYMutation` hook per endpoint
2267
+ // (`createApi({ endpoints: b => ({ getX: b.query(...) }) })`). Components call the
2268
+ // hook; the fetch logic lives in the endpoint's queryFn. The hook↔endpoint link is
2269
+ // pure NAMING CONVENTION (no static edge): strip `use` + the optional `Lazy`
2270
+ // variant + the `Query|Mutation` suffix, lowercase the head → the endpoint key.
2271
+ // Both are extracted as function nodes (the hook from its `export const {…}=api`
2272
+ // binding, carrying a sentinel signature; the endpoint from the createApi object),
2273
+ // so bridging hook→endpoint connects `component → useGetXQuery → getX → queryFn`.
2274
+ // Gated on the extraction sentinel so it only ever fires on genuinely-generated
2275
+ // hooks (never a hand-written `useFooQuery`), and on a SAME-FILE endpoint (RTK
2276
+ // colocates the hooks and their api in one module) — 0 on any non-RTK repo.
2277
+ const RTK_HOOK_DERIVE_RE = /^use([A-Z][A-Za-z0-9]*?)(?:Query|Mutation)$/;
2278
+ // MUST match the signature set in tree-sitter.ts `extractRtkHookBindings`.
2279
+ const RTK_GENERATED_HOOK_SIGNATURE = '= RTK Query generated hook';
2280
+ /** Derive the endpoint key from a generated-hook name (`useLazyGetRecordsQuery`
2281
+ * → `getRecords`), or null if it doesn't fit the convention. */
2282
+ function rtkEndpointNameFromHook(hook) {
2283
+ const m = RTK_HOOK_DERIVE_RE.exec(hook);
2284
+ if (!m)
2285
+ return null;
2286
+ let mid = m[1];
2287
+ if (mid.startsWith('Lazy'))
2288
+ mid = mid.slice(4); // useLazyGetX → getX (same endpoint)
2289
+ if (!mid)
2290
+ return null;
2291
+ return mid.charAt(0).toLowerCase() + mid.slice(1);
2292
+ }
2293
+ function rtkQueryEdges(queries, ctx) {
2294
+ const edges = [];
2295
+ const seen = new Set();
2296
+ for (const hook of queries.iterateNodesByKind('function')) {
2297
+ // Only our extracted generated-hook bindings (sentinel) — not a real hook fn.
2298
+ if (hook.signature !== RTK_GENERATED_HOOK_SIGNATURE)
2299
+ continue;
2300
+ const endpointName = rtkEndpointNameFromHook(hook.name);
2301
+ if (!endpointName)
2302
+ continue;
2303
+ // The endpoint is a same-file function by the derived name (RTK colocates the
2304
+ // api definition and its generated-hook exports in one module).
2305
+ const target = ctx
2306
+ .getNodesByName(endpointName)
2307
+ .find((n) => n.kind === 'function' && n.filePath === hook.filePath);
2308
+ if (!target || target.id === hook.id)
2309
+ continue;
2310
+ const key = `${hook.id}>${target.id}`;
2311
+ if (seen.has(key))
2312
+ continue;
2313
+ seen.add(key);
2314
+ edges.push({
2315
+ source: hook.id,
2316
+ target: target.id,
2317
+ kind: 'calls',
2318
+ line: hook.startLine,
2319
+ provenance: 'heuristic',
2320
+ metadata: { synthesizedBy: 'rtk-query', via: endpointName, registeredAt: `${hook.filePath}:${hook.startLine}` },
2321
+ });
2322
+ }
2323
+ return edges;
2324
+ }
2325
+ // ── Pinia useStore().action() dispatch bridge ────────────────────────────────
2326
+ // A Pinia store factory `export const useXStore = defineStore(...)` exposes its
2327
+ // actions as methods on the store instance; a consumer does `const s = useXStore()`
2328
+ // then `s.action()`. The call is a method-on-instance with no static edge to the
2329
+ // action (which lives in the store's module). Bridge it: map each factory → its
2330
+ // file, bind `const <var> = useXStore()` per consumer file, and link the enclosing
2331
+ // function → the `<var>.method()` action node IN THE STORE'S FILE. The same-store-
2332
+ // file gate keeps it precise (a Pinia built-in like `$patch` or an unrelated
2333
+ // same-named method resolves to nothing). Covers both the options and setup store
2334
+ // forms uniformly (the action is a function node in the store file either way).
2335
+ const PINIA_CONSUMER_EXT = /\.(?:ts|tsx|js|jsx|mjs|cjs|vue)$/;
2336
+ const PINIA_FACTORY_RE = /\b(?:export\s+)?const\s+(\w+)\s*=\s*defineStore\s*\(/g;
2337
+ const PINIA_BIND_RE = /\bconst\s+(\w+)\s*=\s*(?:await\s+)?(\w+)\s*\(/g;
2338
+ const PINIA_CALL_RE = /(\w+)\s*\.\s*(\w+)\s*\(/g;
2339
+ const PINIA_FANOUT_CAP = 80;
2340
+ function piniaStoreEdges(ctx) {
2341
+ // 1. Map each `const useXStore = defineStore(...)` factory → its store file.
2342
+ const factoryFile = new Map();
2343
+ for (const file of ctx.getAllFiles()) {
2344
+ if (!PINIA_CONSUMER_EXT.test(file))
2345
+ continue;
2346
+ const content = ctx.readFile(file);
2347
+ if (!content || !content.includes('defineStore'))
2348
+ continue;
2349
+ PINIA_FACTORY_RE.lastIndex = 0;
2350
+ let m;
2351
+ while ((m = PINIA_FACTORY_RE.exec(content)))
2352
+ factoryFile.set(m[1], file);
2353
+ }
2354
+ if (!factoryFile.size)
2355
+ return [];
2356
+ const edges = [];
2357
+ const seen = new Set();
2358
+ for (const file of ctx.getAllFiles()) {
2359
+ if (!PINIA_CONSUMER_EXT.test(file))
2360
+ continue;
2361
+ const content = ctx.readFile(file);
2362
+ if (!content || !content.includes('Store'))
2363
+ continue;
2364
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, /\.(?:jsx?|mjs|cjs)$/.test(file) ? 'javascript' : 'typescript');
2365
+ // 2. Bind store vars in this file: `const <var> = <known-factory>(...)`.
2366
+ const varStore = new Map();
2367
+ PINIA_BIND_RE.lastIndex = 0;
2368
+ let bm;
2369
+ while ((bm = PINIA_BIND_RE.exec(safe))) {
2370
+ const sf = factoryFile.get(bm[2]);
2371
+ if (sf)
2372
+ varStore.set(bm[1], sf);
2373
+ }
2374
+ if (!varStore.size)
2375
+ continue;
2376
+ // 3. Link `<var>.<method>(` → the action function node in the store's file.
2377
+ const nodesInFile = ctx.getNodesInFile(file);
2378
+ const fallbackDispatcher = nodesInFile.find((n) => n.kind === 'component'); // .vue top-level setup
2379
+ PINIA_CALL_RE.lastIndex = 0;
2380
+ let cm;
2381
+ let added = 0;
2382
+ while ((cm = PINIA_CALL_RE.exec(safe)) && added < PINIA_FANOUT_CAP) {
2383
+ const storeFile = varStore.get(cm[1]);
2384
+ if (!storeFile)
2385
+ continue;
2386
+ const method = cm[2];
2387
+ const line = safe.slice(0, cm.index).split('\n').length;
2388
+ const disp = enclosingFn(nodesInFile, line) ?? fallbackDispatcher;
2389
+ if (!disp)
2390
+ continue;
2391
+ const target = ctx
2392
+ .getNodesByName(method)
2393
+ .find((n) => n.kind === 'function' && n.filePath === storeFile);
2394
+ if (!target || target.id === disp.id)
2395
+ continue;
2396
+ const key = `${disp.id}>${target.id}`;
2397
+ if (seen.has(key))
2398
+ continue;
2399
+ seen.add(key);
2400
+ edges.push({
2401
+ source: disp.id,
2402
+ target: target.id,
2403
+ kind: 'calls',
2404
+ line,
2405
+ provenance: 'heuristic',
2406
+ metadata: { synthesizedBy: 'pinia-store', via: method, registeredAt: `${file}:${line}` },
2407
+ });
2408
+ added++;
2409
+ }
2410
+ }
2411
+ return edges;
2412
+ }
2413
+ // ── Vuex string-keyed dispatch / commit bridge ───────────────────────────────
2414
+ // Vuex dispatches actions/mutations by a runtime STRING key: `dispatch('user/login')`
2415
+ // / `commit('SET_TOKEN')` / `this.$store.dispatch('app/toggleDevice')`. The action
2416
+ // & mutation definitions are object-literal methods in store module files (now
2417
+ // extracted as function nodes). Bridge the string key to its node: the LAST `/`
2418
+ // segment is the action/mutation name; the preceding segment is the namespace
2419
+ // (≈ the store module's file). Resolve the name to a function node IN A STORE FILE
2420
+ // (the store-file gate excludes a same-named `api/` helper — `getInfo`/`login`
2421
+ // commonly collide), disambiguated by the namespace appearing in the path (or, for
2422
+ // a root key, the same file — Vuex's local-module `commit('M')` inside an action).
2423
+ const VUEX_DISPATCH_RE = /\b(?:dispatch|commit)\s*\(\s*['"]([A-Za-z][\w/]*)['"]/g;
2424
+ const VUEX_STORE_SIGNAL = /\bdefineStore\b|\bcreateStore\b|\bVuex\b|\bmutations\b|\bactions\b|\bgetters\b|\bnamespaced\b/g;
2425
+ const VUEX_FANOUT_CAP = 120;
2426
+ /** A path segment (dir or filename stem) equals `seg` — `…/modules/user.js` has
2427
+ * the segment `user` for namespace `user`. */
2428
+ function pathHasSegment(filePath, seg) {
2429
+ return new RegExp('[\\\\/]' + seg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '[\\\\/.]').test(filePath);
2430
+ }
2431
+ function vuexDispatchEdges(ctx) {
2432
+ const storeFileCache = new Map();
2433
+ const isStoreFile = (file) => {
2434
+ let v = storeFileCache.get(file);
2435
+ if (v === undefined) {
2436
+ const c = ctx.readFile(file);
2437
+ const seen = new Set();
2438
+ if (c) {
2439
+ VUEX_STORE_SIGNAL.lastIndex = 0;
2440
+ let sm;
2441
+ while ((sm = VUEX_STORE_SIGNAL.exec(c))) {
2442
+ seen.add(sm[0]);
2443
+ if (seen.size >= 2)
2444
+ break;
2445
+ }
2446
+ }
2447
+ v = seen.size >= 2;
2448
+ storeFileCache.set(file, v);
2449
+ }
2450
+ return v;
2451
+ };
2452
+ const resolve = (key, dispatchFile) => {
2453
+ const segs = key.split('/');
2454
+ const action = segs[segs.length - 1];
2455
+ const cands = ctx.getNodesByName(action).filter((n) => n.kind === 'function' && isStoreFile(n.filePath));
2456
+ if (!cands.length)
2457
+ return null;
2458
+ if (segs.length > 1) {
2459
+ const mod = segs[segs.length - 2]; // immediate namespace ≈ the module file
2460
+ return cands.find((c) => pathHasSegment(c.filePath, mod)) ?? (cands.length === 1 ? cands[0] : null);
2461
+ }
2462
+ // Root key: a local `commit('M')` inside an action targets the same module file;
2463
+ // otherwise accept only an unambiguous single store-wide match.
2464
+ return cands.find((c) => c.filePath === dispatchFile) ?? (cands.length === 1 ? cands[0] : null);
2465
+ };
2466
+ const edges = [];
2467
+ const seen = new Set();
2468
+ for (const file of ctx.getAllFiles()) {
2469
+ if (!PINIA_CONSUMER_EXT.test(file))
2470
+ continue;
2471
+ const content = ctx.readFile(file);
2472
+ if (!content || (!content.includes('dispatch(') && !content.includes('commit(')))
2473
+ continue;
2474
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, /\.(?:jsx?|mjs|cjs)$/.test(file) ? 'javascript' : 'typescript');
2475
+ const nodesInFile = ctx.getNodesInFile(file);
2476
+ const fallback = nodesInFile.find((n) => n.kind === 'component'); // .vue top-level
2477
+ VUEX_DISPATCH_RE.lastIndex = 0;
2478
+ let m;
2479
+ let added = 0;
2480
+ while ((m = VUEX_DISPATCH_RE.exec(safe)) && added < VUEX_FANOUT_CAP) {
2481
+ const key = m[1];
2482
+ const line = safe.slice(0, m.index).split('\n').length;
2483
+ const disp = enclosingFn(nodesInFile, line) ?? fallback;
2484
+ if (!disp)
2485
+ continue;
2486
+ const target = resolve(key, file);
2487
+ if (!target || target.id === disp.id)
2488
+ continue;
2489
+ const edgeKey = `${disp.id}>${target.id}`;
2490
+ if (seen.has(edgeKey))
2491
+ continue;
2492
+ seen.add(edgeKey);
2493
+ edges.push({
2494
+ source: disp.id,
2495
+ target: target.id,
2496
+ kind: 'calls',
2497
+ line,
2498
+ provenance: 'heuristic',
2499
+ metadata: { synthesizedBy: 'vuex-dispatch', via: key, registeredAt: `${file}:${line}` },
2500
+ });
2501
+ added++;
2502
+ }
2503
+ }
2504
+ return edges;
2505
+ }
2506
+ // ── Celery task dispatch (Python) ─────────────────────────────────────────────
2507
+ // Celery decouples a task's call site from its body through async dispatch:
2508
+ // # tasks.py
2509
+ // @shared_task # also @app.task / @celery_app.task / @<app>.task / @task
2510
+ // def process(account_ids): ...
2511
+ // # views.py — a DIFFERENT module
2512
+ // process.apply_async(kwargs={...}) # or process.delay(...) — dynamic, no static edge
2513
+ // Bridge it: link the enclosing function/method at each `.delay(`/`.apply_async(` site → the
2514
+ // task function body. Precision rests on the DECORATOR gate — the dispatched name must resolve
2515
+ // to a Python function carrying a celery task decorator (read from the source lines above its
2516
+ // `def`, since the def's own startLine excludes the decorator). A `.delay()` on a non-task
2517
+ // object resolves to no task node → no edge, so a Celery-free repo yields 0. Same-file /
2518
+ // unique-candidate disambiguation like vuex. (Canvas forms — `group(t).delay()`, `t.s()`/`.si()`
2519
+ // — have no single identifier before `.delay`/`.apply_async`, so they're skipped, not mis-bridged.)
2520
+ const CELERY_DISPATCH_RE = /\b([A-Za-z_]\w*)\s*\.\s*(?:delay|apply_async)\s*\(/g;
2521
+ // A task decorator: bare `@shared_task`/`@task` or attribute `@app.task`/`@celery_app.task`,
2522
+ // each optionally called with args. `\b`-bounded and `@`-anchored so `@mytask`, or a symbol
2523
+ // merely named `task`, can't match. No `/g`, so `.test()` is stateless across reuse.
2524
+ const CELERY_TASK_DECORATOR_RE = /@\s*(?:[A-Za-z_][\w.]*\.)?(?:shared_task|task)\b/;
2525
+ const CELERY_PY_EXT = /\.py$/;
2526
+ const CELERY_FANOUT_CAP = 80;
2527
+ const CELERY_DECORATOR_LOOKBACK = 12; // max lines above a `def` to scan for its decorators
2528
+ function celeryDispatchEdges(ctx) {
2529
+ // Memoize the decorator check per task-candidate node: it reads the file and scans a few
2530
+ // lines above the def. Only called on names that are actually `.delay`/`.apply_async`
2531
+ // receivers, so the candidate set stays small.
2532
+ const taskCache = new Map();
2533
+ const isCeleryTask = (node) => {
2534
+ let v = taskCache.get(node.id);
2535
+ if (v !== undefined)
2536
+ return v;
2537
+ v = false;
2538
+ if (node.kind === 'function' && CELERY_PY_EXT.test(node.filePath)) {
2539
+ const content = ctx.readFile(node.filePath);
2540
+ if (content) {
2541
+ const lines = content.split('\n');
2542
+ // startLine is the `def` line (decorators sit ABOVE it). Walk upward, stopping at the
2543
+ // previous declaration so a non-task def can never inherit the prior def's decorator.
2544
+ const stop = Math.max(0, node.startLine - 1 - CELERY_DECORATOR_LOOKBACK);
2545
+ for (let i = node.startLine - 2; i >= stop; i--) {
2546
+ const t = (lines[i] ?? '').trim();
2547
+ if (/^(?:async\s+def|def|class)\b/.test(t))
2548
+ break; // previous decl → stop
2549
+ if (CELERY_TASK_DECORATOR_RE.test(t)) {
2550
+ v = true;
2551
+ break;
2552
+ }
2553
+ }
2554
+ }
2555
+ }
2556
+ taskCache.set(node.id, v);
2557
+ return v;
2558
+ };
2559
+ const resolve = (name, dispatchFile) => {
2560
+ const cands = ctx.getNodesByName(name).filter((n) => n.kind === 'function' && isCeleryTask(n));
2561
+ if (!cands.length)
2562
+ return null;
2563
+ if (cands.length === 1)
2564
+ return cands[0];
2565
+ // Cross-module name collision: prefer a task defined in the dispatching file, else bail
2566
+ // (ambiguous — precision over recall, like vuex's root-key resolution).
2567
+ return cands.find((c) => c.filePath === dispatchFile) ?? null;
2568
+ };
2569
+ const edges = [];
2570
+ const seen = new Set();
2571
+ for (const file of ctx.getAllFiles()) {
2572
+ if (!CELERY_PY_EXT.test(file))
2573
+ continue;
2574
+ const content = ctx.readFile(file);
2575
+ if (!content || (!content.includes('.delay(') && !content.includes('.apply_async(')))
2576
+ continue;
2577
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'python');
2578
+ const nodesInFile = ctx.getNodesInFile(file);
2579
+ CELERY_DISPATCH_RE.lastIndex = 0;
2580
+ let m;
2581
+ let added = 0;
2582
+ while ((m = CELERY_DISPATCH_RE.exec(safe)) && added < CELERY_FANOUT_CAP) {
2583
+ const name = m[1];
2584
+ const line = safe.slice(0, m.index).split('\n').length;
2585
+ const disp = enclosingFn(nodesInFile, line);
2586
+ if (!disp)
2587
+ continue; // module-level dispatch — no source symbol to attribute
2588
+ const target = resolve(name, file);
2589
+ if (!target || target.id === disp.id)
2590
+ continue;
2591
+ const key = `${disp.id}>${target.id}`;
2592
+ if (seen.has(key))
2593
+ continue;
2594
+ seen.add(key);
2595
+ edges.push({
2596
+ source: disp.id,
2597
+ target: target.id,
2598
+ kind: 'calls',
2599
+ line,
2600
+ provenance: 'heuristic',
2601
+ metadata: { synthesizedBy: 'celery-dispatch', via: name, registeredAt: `${file}:${line}` },
2602
+ });
2603
+ added++;
2604
+ }
2605
+ }
2606
+ return edges;
2607
+ }
2608
+ // ── Spring application events (Java) ──────────────────────────────────────────
2609
+ // Spring decouples an event PUBLISHER from its LISTENER(s) through the application
2610
+ // event bus, linked by the EVENT TYPE (not a name):
2611
+ // // SomeService.java
2612
+ // eventPublisher.publishEvent(new PasswordChangedEvent(this, username)); // publish
2613
+ // // RememberMeTokenRevoker.java — a DIFFERENT file
2614
+ // @EventListener(PasswordChangedEvent.class) // listen
2615
+ // public void onPasswordChanged(PasswordChangedEvent event) { ... }
2616
+ // Bridge it: link the enclosing method at each `publishEvent(new XEvent(...))` site →
2617
+ // every listener method of XEvent. Listeners are `@EventListener` / `@TransactionalEventListener`
2618
+ // methods (event type = the first param type, or the `@EventListener(X.class)` value form) and
2619
+ // the older `class … implements ApplicationListener<X> { void onApplicationEvent(X e) }`. Keyed
2620
+ // by exact type name, usually cross-file. A repo with no `@EventListener`/`publishEvent` yields 0.
2621
+ // (Java method nodes INCLUDE their leading annotations in the range — startLine is the first
2622
+ // `@…` line — so the annotation block is scanned DOWNWARD from startLine, bounded to consecutive
2623
+ // `@`-lines so it can't bleed into an adjacent method.)
2624
+ const SPRING_PUBLISH_RE = /\.publishEvent\s*\(\s*new\s+([A-Z][A-Za-z0-9_]*)/g;
2625
+ const SPRING_LISTENER_ANNO_RE = /@(?:EventListener|TransactionalEventListener)\b/;
2626
+ const SPRING_ANNO_TYPE_RE = /@(?:EventListener|TransactionalEventListener)\s*\(\s*([A-Z][A-Za-z0-9_]*)\.class/;
2627
+ const SPRING_APP_LISTENER_RE = /\bApplicationListener\s*</;
2628
+ const SPRING_JAVA_EXT = /\.java$/;
2629
+ const SPRING_FANOUT_CAP = 80;
2630
+ /** The first parameter's type from a Java method `signature` (`"void (XEvent e)"` → `XEvent`).
2631
+ * Skips a leading `final`/`@Anno`, strips generics, and requires a PascalCase class name (event
2632
+ * types are classes) — so a no-arg or primitive-param method yields null. */
2633
+ function springFirstParamType(sig) {
2634
+ if (!sig)
2635
+ return null;
2636
+ const open = sig.indexOf('(');
2637
+ if (open < 0)
2638
+ return null;
2639
+ const close = sig.indexOf(')', open);
2640
+ const inner = sig.slice(open + 1, close < 0 ? sig.length : close).trim();
2641
+ if (!inner)
2642
+ return null;
2643
+ const first = inner.split(',')[0].trim();
2644
+ const toks = first.split(/\s+/).filter((t) => t && t !== 'final' && !t.startsWith('@'));
2645
+ if (toks.length < 2)
2646
+ return null; // need `Type name`
2647
+ const type = toks[toks.length - 2].replace(/<.*$/, ''); // drop generic args
2648
+ return /^[A-Z][A-Za-z0-9_]*$/.test(type) ? type : null;
2649
+ }
2650
+ function springEventEdges(ctx) {
2651
+ // Pass 1 — event-type → listener methods, scanning only event-relevant files.
2652
+ const listeners = new Map();
2653
+ for (const file of ctx.getAllFiles()) {
2654
+ if (!SPRING_JAVA_EXT.test(file))
2655
+ continue;
2656
+ const content = ctx.readFile(file);
2657
+ if (!content)
2658
+ continue;
2659
+ const hasAnno = content.includes('@EventListener') || content.includes('@TransactionalEventListener');
2660
+ const hasAppListener = SPRING_APP_LISTENER_RE.test(content);
2661
+ if (!hasAnno && !hasAppListener)
2662
+ continue;
2663
+ const lines = content.split('\n');
2664
+ for (const node of ctx.getNodesInFile(file)) {
2665
+ if (node.kind !== 'method')
2666
+ continue;
2667
+ // Collect this method's own leading annotation block (consecutive `@`-lines from startLine).
2668
+ const annoLines = [];
2669
+ for (let i = node.startLine - 1; i < lines.length && i < node.startLine + 7; i++) {
2670
+ const t = (lines[i] ?? '').trim();
2671
+ if (!t.startsWith('@'))
2672
+ break; // reached the declaration → stop (no bleed into next method)
2673
+ annoLines.push(t);
2674
+ }
2675
+ const head = annoLines.join('\n');
2676
+ const annotated = hasAnno && SPRING_LISTENER_ANNO_RE.test(head);
2677
+ const isAppListener = hasAppListener && node.name === 'onApplicationEvent';
2678
+ if (!annotated && !isAppListener)
2679
+ continue;
2680
+ let type = springFirstParamType(node.signature);
2681
+ if (!type && annotated) {
2682
+ const m = SPRING_ANNO_TYPE_RE.exec(head);
2683
+ if (m)
2684
+ type = m[1];
2685
+ }
2686
+ if (!type)
2687
+ continue;
2688
+ let arr = listeners.get(type);
2689
+ if (!arr) {
2690
+ arr = [];
2691
+ listeners.set(type, arr);
2692
+ }
2693
+ arr.push(node);
2694
+ }
2695
+ }
2696
+ if (!listeners.size)
2697
+ return [];
2698
+ // Pass 2 — link each publishEvent(new XEvent(...)) site → every listener of XEvent.
2699
+ const edges = [];
2700
+ const seen = new Set();
2701
+ for (const file of ctx.getAllFiles()) {
2702
+ if (!SPRING_JAVA_EXT.test(file))
2703
+ continue;
2704
+ const content = ctx.readFile(file);
2705
+ if (!content || !content.includes('.publishEvent('))
2706
+ continue;
2707
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'java');
2708
+ const nodesInFile = ctx.getNodesInFile(file);
2709
+ SPRING_PUBLISH_RE.lastIndex = 0;
2710
+ let m;
2711
+ let added = 0;
2712
+ while ((m = SPRING_PUBLISH_RE.exec(safe)) && added < SPRING_FANOUT_CAP) {
2713
+ const targets = listeners.get(m[1]);
2714
+ if (!targets || !targets.length)
2715
+ continue;
2716
+ const line = safe.slice(0, m.index).split('\n').length;
2717
+ const disp = enclosingFn(nodesInFile, line);
2718
+ if (!disp)
2719
+ continue;
2720
+ for (const target of targets) {
2721
+ if (target.id === disp.id)
2722
+ continue;
2723
+ const key = `${disp.id}>${target.id}`;
2724
+ if (seen.has(key))
2725
+ continue;
2726
+ seen.add(key);
2727
+ edges.push({
2728
+ source: disp.id,
2729
+ target: target.id,
2730
+ kind: 'calls',
2731
+ line,
2732
+ provenance: 'heuristic',
2733
+ metadata: { synthesizedBy: 'spring-event', via: m[1], registeredAt: `${file}:${line}` },
2734
+ });
2735
+ added++;
2736
+ }
2737
+ }
2738
+ }
2739
+ return edges;
2740
+ }
2741
+ // ── MediatR request/notification dispatch (C#/.NET) ───────────────────────────
2742
+ // MediatR decouples a Send/Publish call site from its Handle method through a mediator,
2743
+ // linked by the request/notification TYPE (the IRequestHandler<T,…> generic):
2744
+ // // CancelOrderCommandHandler.cs — the handler
2745
+ // public class CancelOrderCommandHandler : IRequestHandler<CancelOrderCommand, bool> {
2746
+ // public async Task<bool> Handle(CancelOrderCommand request, CancellationToken ct) { … }
2747
+ // // some controller — the dispatch (usually a DIFFERENT file)
2748
+ // var command = new CancelOrderCommand(orderId); await _mediator.Send(command);
2749
+ // Bridge it: link the enclosing method at each mediator `.Send(x)`/`.Publish(x)` site → the
2750
+ // `Handle` method of the handler for x's type. The sent type is resolved from the argument —
2751
+ // inline `new X(…)`, a local `var v = new X(…)`, or a parameter/local declared `X v` — bounded
2752
+ // to the enclosing method. Precision rests on TWO gates: the receiver must be mediator-ish
2753
+ // (`mediator`/`sender`/`publisher`, so MAUI `MessagingCenter.Send` is ignored) AND the resolved
2754
+ // type must be a known handler request type (so a same-named non-request DTO is never bridged).
2755
+ // C# has no `signature` on method nodes, so the handler's request type is read from the class
2756
+ // base-list source (`: IRequestHandler<X,…>`), not a param signature.
2757
+ const MEDIATR_HANDLER_BASE_RE = /(?:IRequestHandler|INotificationHandler)\s*<\s*([A-Za-z_]\w*)/;
2758
+ const MEDIATR_DISPATCH_RE = /([A-Za-z_][\w.]*)\s*\.\s*(?:Send|Publish)\s*\(\s*(new\s+[A-Z]\w*|[A-Za-z_]\w*)/g;
2759
+ const MEDIATR_RECEIVER_RE = /(?:mediator|sender|publisher)/i;
2760
+ const MEDIATR_CS_EXT = /\.cs$/;
2761
+ const MEDIATR_FANOUT_CAP = 80;
2762
+ const MEDIATR_HANDLER_DECL_LOOKAHEAD = 4; // lines from a class startLine to find a wrapped base list
2763
+ /** The type sent at a MediatR `.Send(arg)`/`.Publish(arg)` site: an inline `new X(…)`, else
2764
+ * `arg` as an identifier resolved within the enclosing method — a `… arg = new X(…)` assignment
2765
+ * (wins), or a parameter/local declared `X arg`. Returns null when the type can't be seen. */
2766
+ function resolveMediatrArgType(arg, lines, methodStart, dispatchLine) {
2767
+ const inl = /^new\s+([A-Z]\w*)/.exec(arg);
2768
+ if (inl)
2769
+ return inl[1];
2770
+ if (!/^[A-Za-z_]\w*$/.test(arg))
2771
+ return null;
2772
+ const assignRe = new RegExp(`\\b${arg}\\b\\s*=\\s*new\\s+([A-Z]\\w*)`);
2773
+ const declRe = new RegExp(`\\b([A-Z]\\w*)\\b\\s+${arg}\\b`);
2774
+ let declType = null;
2775
+ for (let i = Math.max(0, methodStart - 1); i < dispatchLine && i < lines.length; i++) {
2776
+ const ln = lines[i] ?? '';
2777
+ const a = assignRe.exec(ln);
2778
+ if (a)
2779
+ return a[1]; // an explicit `arg = new X` is the most specific — take it
2780
+ if (!declType) {
2781
+ const d = declRe.exec(ln);
2782
+ if (d)
2783
+ declType = d[1]; // a `X arg` declaration — remember, but keep scanning for an assignment
2784
+ }
2785
+ }
2786
+ return declType;
2787
+ }
2788
+ function mediatrDispatchEdges(ctx) {
2789
+ // Pass 1 — request/notification type → the Handle method of each handler class.
2790
+ const handlers = new Map();
2791
+ for (const file of ctx.getAllFiles()) {
2792
+ if (!MEDIATR_CS_EXT.test(file))
2793
+ continue;
2794
+ const content = ctx.readFile(file);
2795
+ if (!content || (!content.includes('IRequestHandler<') && !content.includes('INotificationHandler<')))
2796
+ continue;
2797
+ const lines = content.split('\n');
2798
+ const nodesInFile = ctx.getNodesInFile(file);
2799
+ for (const cls of nodesInFile) {
2800
+ if (cls.kind !== 'class')
2801
+ continue;
2802
+ const decl = lines.slice(cls.startLine - 1, cls.startLine - 1 + MEDIATR_HANDLER_DECL_LOOKAHEAD).join('\n');
2803
+ const m = MEDIATR_HANDLER_BASE_RE.exec(decl);
2804
+ if (!m)
2805
+ continue;
2806
+ const type = m[1];
2807
+ const end = cls.endLine ?? cls.startLine;
2808
+ const handle = nodesInFile.find((n) => n.kind === 'method' && n.name === 'Handle' && n.startLine >= cls.startLine && n.startLine <= end);
2809
+ if (!handle)
2810
+ continue;
2811
+ let arr = handlers.get(type);
2812
+ if (!arr) {
2813
+ arr = [];
2814
+ handlers.set(type, arr);
2815
+ }
2816
+ arr.push(handle);
2817
+ }
2818
+ }
2819
+ if (!handlers.size)
2820
+ return [];
2821
+ // Pass 2 — link each mediator-ish .Send(x)/.Publish(x) → the handler of x's type.
2822
+ const edges = [];
2823
+ const seen = new Set();
2824
+ for (const file of ctx.getAllFiles()) {
2825
+ if (!MEDIATR_CS_EXT.test(file))
2826
+ continue;
2827
+ const content = ctx.readFile(file);
2828
+ if (!content || (!content.includes('.Send(') && !content.includes('.Publish(')))
2829
+ continue;
2830
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'csharp');
2831
+ const safeLines = safe.split('\n');
2832
+ const nodesInFile = ctx.getNodesInFile(file);
2833
+ MEDIATR_DISPATCH_RE.lastIndex = 0;
2834
+ let m;
2835
+ let added = 0;
2836
+ while ((m = MEDIATR_DISPATCH_RE.exec(safe)) && added < MEDIATR_FANOUT_CAP) {
2837
+ if (!MEDIATR_RECEIVER_RE.test(m[1]))
2838
+ continue; // not a mediator (MessagingCenter, HttpClient, …)
2839
+ const line = safe.slice(0, m.index).split('\n').length;
2840
+ const disp = enclosingFn(nodesInFile, line);
2841
+ if (!disp)
2842
+ continue;
2843
+ const type = resolveMediatrArgType(m[2], safeLines, disp.startLine, line);
2844
+ if (!type)
2845
+ continue;
2846
+ const targets = handlers.get(type);
2847
+ if (!targets)
2848
+ continue;
2849
+ for (const target of targets) {
2850
+ if (target.id === disp.id)
2851
+ continue;
2852
+ const key = `${disp.id}>${target.id}`;
2853
+ if (seen.has(key))
2854
+ continue;
2855
+ seen.add(key);
2856
+ edges.push({
2857
+ source: disp.id,
2858
+ target: target.id,
2859
+ kind: 'calls',
2860
+ line,
2861
+ provenance: 'heuristic',
2862
+ metadata: { synthesizedBy: 'mediatr-dispatch', via: type, registeredAt: `${file}:${line}` },
2863
+ });
2864
+ added++;
2865
+ }
2866
+ }
2867
+ }
2868
+ return edges;
2869
+ }
2870
+ // ── Sidekiq job dispatch (Ruby) ───────────────────────────────────────────────
2871
+ // Sidekiq decouples a job's enqueue site from the worker's `perform`, linked by the WORKER
2872
+ // CLASS NAME:
2873
+ // # app/workers/destroy_user_worker.rb
2874
+ // class DestroyUserWorker
2875
+ // include Sidekiq::Worker # or Sidekiq::Job (the modern alias)
2876
+ // def perform(user_id) … end
2877
+ // # app/services/… — a DIFFERENT file
2878
+ // DestroyUserWorker.perform_async(user.id) # also .perform_in(t, …) / .perform_at(t, …)
2879
+ // Bridge it: link the enclosing method at each `Worker.perform_async/_in/_at(…)` site → that
2880
+ // worker's instance `perform`. Name-keyed (like Celery): the receiver class must be a Sidekiq
2881
+ // worker — gated by reading `include Sidekiq::Job|Worker` from the class body, since that mixin
2882
+ // is an external gem module that forms no resolvable edge. ActiveJob's `perform_later`/`_now` is
2883
+ // a different shape and deliberately not matched, so an ActiveJob-only app yields 0.
2884
+ const SIDEKIQ_DISPATCH_RE = /([A-Z][A-Za-z0-9_]*(?:::[A-Z][A-Za-z0-9_]*)*)\s*\.\s*perform_(?:async|in|at)\b/g;
2885
+ const SIDEKIQ_WORKER_RE = /\binclude\s+Sidekiq::(?:Job|Worker)\b/;
2886
+ const SIDEKIQ_RB_EXT = /\.rb$/;
2887
+ const SIDEKIQ_FANOUT_CAP = 80;
2888
+ function sidekiqDispatchEdges(ctx) {
2889
+ // class node id → its instance `perform` method (null if the class isn't a Sidekiq worker),
2890
+ // memoized. Reads the class body for the mixin; only consulted for actual dispatch receivers.
2891
+ const performCache = new Map();
2892
+ const performOf = (cls) => {
2893
+ let v = performCache.get(cls.id);
2894
+ if (v !== undefined)
2895
+ return v;
2896
+ v = null;
2897
+ const content = ctx.readFile(cls.filePath);
2898
+ if (content) {
2899
+ const end = cls.endLine ?? cls.startLine;
2900
+ const body = content.split('\n').slice(cls.startLine - 1, end).join('\n');
2901
+ if (SIDEKIQ_WORKER_RE.test(body)) {
2902
+ v = ctx.getNodesInFile(cls.filePath).find((n) => n.kind === 'method' && n.name === 'perform' && n.startLine >= cls.startLine && n.startLine <= end) ?? null;
2903
+ }
2904
+ }
2905
+ performCache.set(cls.id, v);
2906
+ return v;
2907
+ };
2908
+ // Resolve a (possibly namespaced) worker reference to its `perform`. A namespaced ref is
2909
+ // matched by EXACT qualified name first, so same-named workers in different namespaces
2910
+ // (forem has four `SendEmailNotificationWorker`s) resolve to the right one; an unqualified
2911
+ // ref falls back to the simple name and links only when a single worker bears it — an
2912
+ // ambiguous collision bails (precision over recall).
2913
+ const resolve = (ref) => {
2914
+ if (ref.includes('::')) {
2915
+ const q = ctx.getNodesByQualifiedName(ref).find((n) => n.kind === 'class' && performOf(n));
2916
+ if (q)
2917
+ return performOf(q);
2918
+ }
2919
+ const workers = ctx.getNodesByName(ref.split('::').pop()).filter((n) => n.kind === 'class' && performOf(n));
2920
+ return workers.length === 1 ? performOf(workers[0]) : null;
2921
+ };
2922
+ const edges = [];
2923
+ const seen = new Set();
2924
+ for (const file of ctx.getAllFiles()) {
2925
+ if (!SIDEKIQ_RB_EXT.test(file))
2926
+ continue;
2927
+ const content = ctx.readFile(file);
2928
+ if (!content || !/\.perform_(?:async|in|at)\b/.test(content))
2929
+ continue;
2930
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'ruby');
2931
+ const nodesInFile = ctx.getNodesInFile(file);
2932
+ SIDEKIQ_DISPATCH_RE.lastIndex = 0;
2933
+ let m;
2934
+ let added = 0;
2935
+ while ((m = SIDEKIQ_DISPATCH_RE.exec(safe)) && added < SIDEKIQ_FANOUT_CAP) {
2936
+ const line = safe.slice(0, m.index).split('\n').length;
2937
+ const disp = enclosingFn(nodesInFile, line);
2938
+ if (!disp)
2939
+ continue;
2940
+ const target = resolve(m[1]);
2941
+ if (!target || target.id === disp.id)
2942
+ continue;
2943
+ const key = `${disp.id}>${target.id}`;
2944
+ if (seen.has(key))
2945
+ continue;
2946
+ seen.add(key);
2947
+ edges.push({
2948
+ source: disp.id,
2949
+ target: target.id,
2950
+ kind: 'calls',
2951
+ line,
2952
+ provenance: 'heuristic',
2953
+ metadata: { synthesizedBy: 'sidekiq-dispatch', via: m[1], registeredAt: `${file}:${line}` },
2954
+ });
2955
+ added++;
2956
+ }
2957
+ }
2958
+ return edges;
2959
+ }
2960
+ // ── Erlang behaviour-callback dispatch ────────────────────────────────────────
2961
+ // An Erlang behaviour is a compile-checked callback contract: the behaviour
2962
+ // module declares `-callback init(...) -> ...`, implementers declare
2963
+ // `-behaviour(B)` and export the callbacks, and the framework side dispatches
2964
+ // through a VARIABLE module — cowboy's `Handler:init(Req, Opts)` and
2965
+ // `Middleware:execute(Req, Env)` folds, ejabberd's `Mod:start/2`. Extraction
2966
+ // deliberately leaves var-module calls silent (no static target), so the flow
2967
+ // breaks at exactly the hop agents ask about (request → handler init). Bridge:
2968
+ //
2969
+ // dispatch site `Var:fn(args…)` → every in-repo implementer of the behaviour
2970
+ // declaring `fn` with the SITE's arity — provided exactly ONE in-repo
2971
+ // behaviour declares (fn, arity); a name+arity collision across behaviours
2972
+ // bails (silent beats wrong) — and the implementer defines and exports `fn`.
2973
+ //
2974
+ // Behaviours are discovered by scanning every Erlang file for `-callback`
2975
+ // declarations (not just `implements` targets), so a behaviour with zero
2976
+ // implementers still participates in the ambiguity gate. Fan-out control: a
2977
+ // mega-behaviour (ejabberd's gen_mod, ~200 mod_* implementers) would mint
2978
+ // hundreds of edges per site that READ as complete coverage while being
2979
+ // arbitrary — above the cap the site is skipped entirely and the boundary
2980
+ // stays visibly dynamic (explore's boundary announcer covers it) instead of
2981
+ // silently truncated.
2982
+ const ERLANG_EXT = /\.(?:erl|hrl)$/;
2983
+ // `Var:fn(` — variable (capitalized) module, lowercase function, immediate
2984
+ // open-paren. The leading char class rejects `?MODULE:fn(` (macro), `a:b(`
2985
+ // (static remote call, already linked), and mid-word matches.
2986
+ const ERLANG_DISPATCH_RE = /(^|[^?\w@'])([A-Z][A-Za-z0-9_@]*):([a-z][A-Za-z0-9_@]*)\(/g;
2987
+ const ERLANG_CALLBACK_DECL_RE = /(^|\n)\s*-callback\s+('[^'\n]+'|[a-z][A-Za-z0-9_@]*)\s*\(/g;
2988
+ const ERLANG_BEHAVIOUR_FANOUT_CAP = 24;
2989
+ /**
2990
+ * Argument count of the call/declaration whose `(` sits at `openIdx` —
2991
+ * top-level commas + 1, `()` → 0, unbalanced/oversized → -1. Skips nested
2992
+ * (), [], {}, <<>> content, `"strings"`, `'atoms'`, and `$c` char literals,
2993
+ * so `-callback init(fun((a, b) -> ok), #{k => v}) -> ok.` counts 2.
2994
+ */
2995
+ function erlangArityAt(src, openIdx) {
2996
+ let depth = 1;
2997
+ let commas = 0;
2998
+ let sawArg = false;
2999
+ const limit = Math.min(src.length, openIdx + 4000);
3000
+ for (let i = openIdx + 1; i < limit; i++) {
3001
+ const ch = src[i];
3002
+ if (ch === '"' || ch === "'") {
3003
+ i++;
3004
+ while (i < limit && src[i] !== ch) {
3005
+ if (src[i] === '\\')
3006
+ i++;
3007
+ i++;
3008
+ }
3009
+ sawArg = true;
3010
+ continue;
3011
+ }
3012
+ if (ch === '$') {
3013
+ i++;
3014
+ if (src[i] === '\\')
3015
+ i++;
3016
+ sawArg = true;
3017
+ continue;
3018
+ }
3019
+ if (ch === '(' || ch === '[' || ch === '{') {
3020
+ depth++;
3021
+ sawArg = true;
3022
+ continue;
3023
+ }
3024
+ if (ch === ')' || ch === ']' || ch === '}') {
3025
+ depth--;
3026
+ if (depth === 0)
3027
+ return sawArg ? commas + 1 : 0;
3028
+ continue;
3029
+ }
3030
+ if (ch === ',' && depth === 1) {
3031
+ commas++;
3032
+ continue;
3033
+ }
3034
+ if (!/\s/.test(ch))
3035
+ sawArg = true;
3036
+ }
3037
+ return -1;
3038
+ }
3039
+ /**
3040
+ * Nix module-system option wiring. A NixOS/home-manager/nix-darwin option is
3041
+ * DECLARED in one module (`options.launchd.user.agents = mkOption { ... }`)
3042
+ * and SET in others (`launchd.user.agents.yabai = { ... }` inside a module's
3043
+ * config) — the connection happens by option-path unification inside the
3044
+ * module-system evaluator, so there is no static call/import edge to follow
3045
+ * and flow questions ("how does services.yabai.enable become a launchd
3046
+ * service?") go dark at the module boundary.
3047
+ *
3048
+ * This pass links each config-write binding to the option declaration whose
3049
+ * path is the longest static-segment prefix of the write path. Precision gates:
3050
+ * - only STATIC segments participate: plain identifiers, plus quoted segments
3051
+ * (`"git/config"`, `"com.apple.dock"`) as opaque verbatim tokens that match
3052
+ * only quote-exactly; an interpolated (`${name}`) segment ends the prefix,
3053
+ * so dynamic paths never match beyond their static head;
3054
+ * - matched prefixes must be ≥2 segments: 1-segment paths would wrongly link
3055
+ * every package's `meta = { ... }` attrset to nixos's `options.meta`;
3056
+ * - a prefix declared in more than one file is ambiguous → no edge (a wrong
3057
+ * edge is worse than none);
3058
+ * - writes physically inside an options block are declaration internals
3059
+ * (types, defaults, examples), never config writes → excluded.
3060
+ * Both declaration spellings register: flat (`options.a.b = ...`) by name, and
3061
+ * nested (`options = { a.b = ...; }`) by line-span containment.
3062
+ */
3063
+ function nixLeadingPlainSegments(name) {
3064
+ const segs = [];
3065
+ let i = 0;
3066
+ const n = name.length;
3067
+ while (i < n) {
3068
+ if (name[i] === '"') {
3069
+ // Quoted segment — an opaque verbatim token (quotes kept, so it can
3070
+ // never collide with a plain identifier). `NSGlobalDomain."com.apple.
3071
+ // mouse.tapBehavior"` must match ITS OWN quoted declaration, not
3072
+ // whichever sibling registered the shared plain prefix first.
3073
+ let j = i + 1;
3074
+ while (j < n && name[j] !== '"') {
3075
+ if (name[j] === '\\')
3076
+ j++;
3077
+ j++;
3078
+ }
3079
+ if (j >= n)
3080
+ return segs; // unterminated — stop at the static head
3081
+ const tok = name.slice(i, j + 1);
3082
+ if (tok.includes('${'))
3083
+ return segs; // interpolated → dynamic → stop
3084
+ segs.push(tok);
3085
+ i = j + 1;
3086
+ if (i >= n)
3087
+ break;
3088
+ if (name[i] !== '.')
3089
+ return segs;
3090
+ i++;
3091
+ continue;
3092
+ }
3093
+ let j = i;
3094
+ while (j < n && name[j] !== '.') {
3095
+ if (name[j] === '"' || (name[j] === '$' && name[j + 1] === '{'))
3096
+ return segs;
3097
+ j++;
3098
+ }
3099
+ const seg = name.slice(i, j);
3100
+ if (!/^[A-Za-z_][A-Za-z0-9_'-]*$/.test(seg))
3101
+ return segs;
3102
+ segs.push(seg);
3103
+ i = j + 1;
3104
+ }
3105
+ return segs;
3106
+ }
3107
+ async function nixOptionPathEdges(queries, onYield) {
3108
+ // One streaming pass over nix bindings (variables + the odd function-valued
3109
+ // option); memory stays O(bindings-kept), not O(all nodes) (#610).
3110
+ const byFile = new Map();
3111
+ let scanned = 0;
3112
+ for (const kind of ['variable', 'function']) {
3113
+ for (const node of queries.iterateNodesByKind(kind)) {
3114
+ if ((++scanned & 0x3fff) === 0 && onYield)
3115
+ await onYield();
3116
+ if (node.language !== 'nix')
3117
+ continue;
3118
+ const segs = nixLeadingPlainSegments(node.name);
3119
+ if (segs.length === 0)
3120
+ continue;
3121
+ const rec = {
3122
+ id: node.id,
3123
+ filePath: node.filePath,
3124
+ startLine: node.startLine,
3125
+ endLine: node.endLine,
3126
+ segs,
3127
+ };
3128
+ const arr = byFile.get(node.filePath);
3129
+ if (arr)
3130
+ arr.push(rec);
3131
+ else
3132
+ byFile.set(node.filePath, [rec]);
3133
+ }
3134
+ }
3135
+ // Per file: walk bindings outermost-first with a stack of active option
3136
+ // spans, composing nested declaration paths (`options = { services.foo = {
3137
+ // enable = mkOption ...; }; }` registers services.foo AND services.foo.enable).
3138
+ // An `options` binding nested inside another option span is a SUBMODULE's
3139
+ // own namespace (`attrsOf (submodule { options = ...; })`) — its internals
3140
+ // are not globally addressable, so the sentinel blocks registration below it
3141
+ // while still excluding the region from write candidates.
3142
+ const SUBMODULE = 'submodule';
3143
+ const decls = new Map();
3144
+ const writes = [];
3145
+ const register = (path, rec) => {
3146
+ if (path.length < 2 || path.includes(SUBMODULE))
3147
+ return;
3148
+ const key = path.join('.');
3149
+ const arr = decls.get(key);
3150
+ if (arr)
3151
+ arr.push(rec);
3152
+ else
3153
+ decls.set(key, [rec]);
3154
+ };
3155
+ for (const recs of byFile.values()) {
3156
+ recs.sort((a, b) => a.startLine - b.startLine || b.endLine - a.endLine);
3157
+ const stack = [];
3158
+ for (const rec of recs) {
3159
+ while (stack.length > 0 && stack[stack.length - 1].end < rec.startLine)
3160
+ stack.pop();
3161
+ // Strict containment at line granularity: a one-line nested binding is
3162
+ // indistinguishable from its container, so it stays unclassified (rare
3163
+ // in module code, where option blocks are multi-line).
3164
+ const enclosing = stack.length > 0 &&
3165
+ rec.startLine >= stack[stack.length - 1].start &&
3166
+ rec.endLine <= stack[stack.length - 1].end &&
3167
+ !(rec.startLine === stack[stack.length - 1].start && rec.endLine === stack[stack.length - 1].end)
3168
+ ? stack[stack.length - 1]
3169
+ : null;
3170
+ if (rec.segs[0] === 'options') {
3171
+ const ownPath = rec.segs.slice(1); // [] for the bare `options = { ... }` spelling
3172
+ const prefix = enclosing ? [SUBMODULE] : ownPath;
3173
+ register(prefix, rec);
3174
+ stack.push({ start: rec.startLine, end: rec.endLine, prefix });
3175
+ continue;
3176
+ }
3177
+ if (enclosing) {
3178
+ const composed = [...enclosing.prefix, ...rec.segs];
3179
+ register(composed, rec);
3180
+ stack.push({ start: rec.startLine, end: rec.endLine, prefix: composed });
3181
+ continue;
3182
+ }
3183
+ if (rec.segs.length >= 2) {
3184
+ writes.push(rec);
3185
+ }
3186
+ }
3187
+ }
3188
+ if (decls.size === 0 || writes.length === 0)
3189
+ return [];
3190
+ const edges = [];
3191
+ for (const w of writes) {
3192
+ // `config.services.x = ...` spells the same write with an explicit prefix.
3193
+ const segs = w.segs[0] === 'config' ? w.segs.slice(1) : w.segs;
3194
+ if (segs.length < 2)
3195
+ continue;
3196
+ // Longest prefix wins; an ambiguous longest match does NOT fall back to a
3197
+ // shorter one (that would link `services.nginx.virtualHosts.x` to
3198
+ // `options.services.nginx` when virtualHosts is the contested path).
3199
+ for (let len = Math.min(segs.length, 6); len >= 2; len--) {
3200
+ const candidates = decls.get(segs.slice(0, len).join('.'));
3201
+ if (!candidates || candidates.length === 0)
3202
+ continue;
3203
+ const files = new Set(candidates.map((c) => c.filePath));
3204
+ if (files.size === 1) {
3205
+ const target = candidates[0];
3206
+ if (target.id !== w.id) {
3207
+ edges.push({
3208
+ source: w.id,
3209
+ target: target.id,
3210
+ kind: 'references',
3211
+ line: w.startLine,
3212
+ provenance: 'heuristic',
3213
+ metadata: {
3214
+ synthesizedBy: 'nix-option-path',
3215
+ optionPath: segs.slice(0, len).join('.'),
3216
+ registeredAt: `${target.filePath}:${target.startLine}`,
3217
+ },
3218
+ });
3219
+ }
3220
+ }
3221
+ break; // longest hit decides, matched or ambiguous
3222
+ }
3223
+ }
3224
+ return edges;
3225
+ }
3226
+ function erlangBehaviourDispatchEdges(queries, ctx) {
3227
+ // Cheap language gate: no Erlang modules → no cost beyond one kind query.
3228
+ const erlangModules = queries.getNodesByKind('namespace').filter((n) => n.language === 'erlang');
3229
+ if (erlangModules.length === 0)
3230
+ return [];
3231
+ // Pass 1 — scan every Erlang file with `-callback` decls: behaviour module →
3232
+ // its (name, arity) callback set, and the global `name/arity` → declaring
3233
+ // behaviours map that drives the ambiguity gate.
3234
+ const moduleByFile = new Map();
3235
+ for (const ns of erlangModules) {
3236
+ if (!moduleByFile.has(ns.filePath))
3237
+ moduleByFile.set(ns.filePath, ns);
3238
+ }
3239
+ const declaringBehaviours = new Map(); // `fn/arity` → behaviour namespaces
3240
+ const callbackNames = new Set();
3241
+ for (const file of ctx.getAllFiles()) {
3242
+ if (!ERLANG_EXT.test(file))
3243
+ continue;
3244
+ const behaviour = moduleByFile.get(file);
3245
+ if (!behaviour)
3246
+ continue; // a .hrl or module-less file can't be a behaviour
3247
+ const content = ctx.readFile(file);
3248
+ if (!content || !content.includes('-callback'))
3249
+ continue;
3250
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'erlang');
3251
+ ERLANG_CALLBACK_DECL_RE.lastIndex = 0;
3252
+ let m;
3253
+ while ((m = ERLANG_CALLBACK_DECL_RE.exec(safe))) {
3254
+ const name = m[2].replace(/^'|'$/g, '');
3255
+ const arity = erlangArityAt(safe, m.index + m[0].length - 1);
3256
+ if (arity < 0)
3257
+ continue;
3258
+ const key = `${name}/${arity}`;
3259
+ const arr = declaringBehaviours.get(key);
3260
+ if (arr) {
3261
+ if (!arr.some((b) => b.id === behaviour.id))
3262
+ arr.push(behaviour);
3263
+ }
3264
+ else {
3265
+ declaringBehaviours.set(key, [behaviour]);
3266
+ }
3267
+ callbackNames.add(name);
3268
+ }
3269
+ }
3270
+ if (declaringBehaviours.size === 0)
3271
+ return [];
3272
+ // Implementer target lookup, lazy per (behaviour, fn): implementers come
3273
+ // from the `implements` edges extraction resolved, and the target is the
3274
+ // implementer module's own exported `fn` function node.
3275
+ const targetCache = new Map();
3276
+ const targetsOf = (behaviour, fn) => {
3277
+ const cacheKey = `${behaviour.id}#${fn}`;
3278
+ let targets = targetCache.get(cacheKey);
3279
+ if (targets)
3280
+ return targets;
3281
+ targets = [];
3282
+ for (const e of queries.getIncomingEdges(behaviour.id, ['implements'])) {
3283
+ const impl = queries.getNodeById(e.source);
3284
+ if (!impl || impl.language !== 'erlang' || impl.kind !== 'namespace')
3285
+ continue;
3286
+ const fnNode = ctx
3287
+ .getNodesInFile(impl.filePath)
3288
+ .find((n) => n.kind === 'function' && n.name === fn && n.isExported !== false);
3289
+ if (fnNode)
3290
+ targets.push(fnNode);
3291
+ }
3292
+ targetCache.set(cacheKey, targets);
3293
+ return targets;
3294
+ };
3295
+ // Pass 2 — dispatch sites. Only files containing a var-module call shape are
3296
+ // scanned in full.
3297
+ const edges = [];
3298
+ const seen = new Set();
3299
+ for (const file of ctx.getAllFiles()) {
3300
+ if (!ERLANG_EXT.test(file))
3301
+ continue;
3302
+ const content = ctx.readFile(file);
3303
+ if (!content || !/[A-Z][A-Za-z0-9_@]*:[a-z]/.test(content))
3304
+ continue;
3305
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'erlang');
3306
+ const nodesInFile = ctx.getNodesInFile(file);
3307
+ ERLANG_DISPATCH_RE.lastIndex = 0;
3308
+ let m;
3309
+ while ((m = ERLANG_DISPATCH_RE.exec(safe))) {
3310
+ const fn = m[3];
3311
+ if (!callbackNames.has(fn))
3312
+ continue;
3313
+ const openIdx = m.index + m[0].length - 1;
3314
+ const arity = erlangArityAt(safe, openIdx);
3315
+ if (arity < 0)
3316
+ continue;
3317
+ const behaviours = declaringBehaviours.get(`${fn}/${arity}`);
3318
+ if (!behaviours || behaviours.length !== 1)
3319
+ continue; // unknown or ambiguous
3320
+ const behaviour = behaviours[0];
3321
+ const targets = targetsOf(behaviour, fn);
3322
+ if (targets.length === 0 || targets.length > ERLANG_BEHAVIOUR_FANOUT_CAP)
3323
+ continue;
3324
+ const line = safe.slice(0, m.index).split('\n').length;
3325
+ const disp = enclosingFn(nodesInFile, line);
3326
+ if (!disp)
3327
+ continue;
3328
+ for (const target of targets) {
3329
+ if (target.id === disp.id)
3330
+ continue;
3331
+ const key = `${disp.id}>${target.id}`;
3332
+ if (seen.has(key))
3333
+ continue;
3334
+ seen.add(key);
3335
+ edges.push({
3336
+ source: disp.id,
3337
+ target: target.id,
3338
+ kind: 'calls',
3339
+ line,
3340
+ provenance: 'heuristic',
3341
+ metadata: {
3342
+ synthesizedBy: 'erlang-behaviour',
3343
+ via: `${behaviour.name}:${fn}/${arity}`,
3344
+ registeredAt: `${file}:${line}`,
3345
+ },
3346
+ });
3347
+ }
3348
+ }
3349
+ }
3350
+ return edges;
3351
+ }
3352
+ // ── Laravel events (PHP) ──────────────────────────────────────────────────────
3353
+ // Laravel decouples an event dispatch from its listener(s), linked by the EVENT CLASS:
3354
+ // // app/Events/PlaybackStarted.php + app/Listeners/UpdateLastfmNowPlaying.php
3355
+ // class UpdateLastfmNowPlaying { public function handle(PlaybackStarted $event) { … } }
3356
+ // // a controller / service — a DIFFERENT file
3357
+ // event(new PlaybackStarted($song, $user));
3358
+ // Bridge it: link the enclosing method at each `event(new XEvent(...))` site → every listener's
3359
+ // `handle` for XEvent. Listeners come from TWO registration mechanisms (both real, both needed):
3360
+ // (A) auto-discovery — a `handle(EventType $e)` typed first param (also splits a union A|B);
3361
+ // (B) the `protected $listen = [ XEvent::class => [Listener::class, …] ]` map in an
3362
+ // EventServiceProvider, which also covers a listener whose `handle()` is UNTYPED.
3363
+ // Only `event(new X)` is matched — queued JOBS dispatch via `::dispatch()` and their `handle()`
3364
+ // takes an injected service, never an event type, so jobs are excluded by construction.
3365
+ const LARAVEL_DISPATCH_RE = /\bevent\s*\(\s*new\s+\\?([A-Za-z_][\w\\]*)/g;
3366
+ const LARAVEL_PHP_EXT = /\.php$/;
3367
+ const LARAVEL_FANOUT_CAP = 200;
3368
+ // A `$listen` entry: `Event::class => [Listener::class, …]`, key/values as `::class` or strings.
3369
+ const LISTEN_ENTRY_RE = /(?:([A-Za-z_\\][\w\\]*)::class|'([^']+)'|"([^"]+)")\s*=>\s*\[([^\]]*)\]/g;
3370
+ const LISTEN_CLASS_RE = /(?:([A-Za-z_\\][\w\\]*)::class|'([^']+)'|"([^"]+)")/g;
3371
+ /** Short class name from a PHP reference: `\App\Events\Foo` / `App\Events::Foo` → `Foo`. */
3372
+ function phpSimpleName(s) {
3373
+ return s.replace(/^\\/, '').split('\\').pop().split('::').pop().trim();
3374
+ }
3375
+ /** The first-parameter class type(s) of a `handle(...)` declaration — union-split, short-named,
3376
+ * primitives dropped. `handle(A|B $e)` → [A, B]; `handle(string $x)` / `handle()` → []. */
3377
+ function laravelHandleEventTypes(decl) {
3378
+ const m = /function\s+handle\s*\(\s*(?:\.\.\.\s*)?(\??[A-Za-z_\\][\w\\|]*)\s+&?\s*(?:\.\.\.\s*)?\$/.exec(decl);
3379
+ if (!m)
3380
+ return [];
3381
+ return m[1]
3382
+ .replace(/^\?/, '')
3383
+ .split('|')
3384
+ .map((t) => phpSimpleName(t))
3385
+ .filter((t) => /^[A-Z]\w*$/.test(t));
3386
+ }
3387
+ /** From an opening `[`, the bracket-balanced body up to its matching `]`. */
3388
+ function phpArrayBody(src, openIdx) {
3389
+ let depth = 0;
3390
+ for (let i = openIdx; i < src.length; i++) {
3391
+ if (src[i] === '[')
3392
+ depth++;
3393
+ else if (src[i] === ']' && --depth === 0)
3394
+ return src.slice(openIdx + 1, i);
3395
+ }
3396
+ return null;
3397
+ }
3398
+ function laravelEventEdges(ctx) {
3399
+ // event short name → its listener `handle` methods (deduped by node id).
3400
+ const listeners = new Map();
3401
+ const add = (event, handle) => {
3402
+ let m = listeners.get(event);
3403
+ if (!m) {
3404
+ m = new Map();
3405
+ listeners.set(event, m);
3406
+ }
3407
+ m.set(handle.id, handle);
3408
+ };
3409
+ const handleOf = (cls) => ctx
3410
+ .getNodesInFile(cls.filePath)
3411
+ .find((n) => n.kind === 'method' && n.name === 'handle'
3412
+ && n.startLine >= cls.startLine && n.startLine <= (cls.endLine ?? cls.startLine)) ?? null;
3413
+ // Pass 1 — build the event→handle map from both registration mechanisms.
3414
+ for (const file of ctx.getAllFiles()) {
3415
+ if (!LARAVEL_PHP_EXT.test(file))
3416
+ continue;
3417
+ const content = ctx.readFile(file);
3418
+ if (!content)
3419
+ continue;
3420
+ // (A) typed listener handles — node-driven, so a commented-out method can't leak in.
3421
+ if (content.includes('function handle')) {
3422
+ const lines = content.split('\n');
3423
+ for (const node of ctx.getNodesInFile(file)) {
3424
+ if (node.kind !== 'method' || node.name !== 'handle')
3425
+ continue;
3426
+ const decl = lines.slice(node.startLine - 1, node.startLine + 2).join('\n');
3427
+ for (const ev of laravelHandleEventTypes(decl))
3428
+ add(ev, node);
3429
+ }
3430
+ }
3431
+ // (B) the EventServiceProvider `$listen` map — parsed from comment-stripped source so a
3432
+ // fully-commented map (firefly's, on auto-discovery) contributes nothing.
3433
+ if (content.includes('$listen')) {
3434
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'php');
3435
+ const decl = safe.search(/\$listen\s*=\s*\[/);
3436
+ const body = decl >= 0 ? phpArrayBody(safe, safe.indexOf('[', decl)) : null;
3437
+ if (body) {
3438
+ LISTEN_ENTRY_RE.lastIndex = 0;
3439
+ let em;
3440
+ while ((em = LISTEN_ENTRY_RE.exec(body))) {
3441
+ const event = phpSimpleName(em[1] ?? em[2] ?? em[3] ?? '');
3442
+ LISTEN_CLASS_RE.lastIndex = 0;
3443
+ let lm;
3444
+ while ((lm = LISTEN_CLASS_RE.exec(em[4]))) {
3445
+ const ln = phpSimpleName(lm[1] ?? lm[2] ?? lm[3] ?? '');
3446
+ const cls = ctx.getNodesByName(ln).find((n) => n.kind === 'class' && handleOf(n));
3447
+ if (cls)
3448
+ add(event, handleOf(cls));
3449
+ }
3450
+ }
3451
+ }
3452
+ }
3453
+ }
3454
+ if (!listeners.size)
3455
+ return [];
3456
+ // Pass 2 — link each event(new X(...)) site → every listener of X.
3457
+ const edges = [];
3458
+ const seen = new Set();
3459
+ for (const file of ctx.getAllFiles()) {
3460
+ if (!LARAVEL_PHP_EXT.test(file))
3461
+ continue;
3462
+ const content = ctx.readFile(file);
3463
+ if (!content || !content.includes('event('))
3464
+ continue;
3465
+ const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'php');
3466
+ const nodesInFile = ctx.getNodesInFile(file);
3467
+ LARAVEL_DISPATCH_RE.lastIndex = 0;
3468
+ let m;
3469
+ let added = 0;
3470
+ while ((m = LARAVEL_DISPATCH_RE.exec(safe)) && added < LARAVEL_FANOUT_CAP) {
3471
+ const targets = listeners.get(phpSimpleName(m[1]));
3472
+ if (!targets)
3473
+ continue;
3474
+ const line = safe.slice(0, m.index).split('\n').length;
3475
+ const disp = enclosingFn(nodesInFile, line);
3476
+ if (!disp)
3477
+ continue;
3478
+ for (const target of targets.values()) {
3479
+ if (target.id === disp.id)
3480
+ continue;
3481
+ const key = `${disp.id}>${target.id}`;
3482
+ if (seen.has(key))
3483
+ continue;
3484
+ seen.add(key);
3485
+ edges.push({
3486
+ source: disp.id,
3487
+ target: target.id,
3488
+ kind: 'calls',
3489
+ line,
3490
+ provenance: 'heuristic',
3491
+ metadata: { synthesizedBy: 'laravel-event', via: phpSimpleName(m[1]), registeredAt: `${file}:${line}` },
3492
+ });
3493
+ added++;
3494
+ }
3495
+ }
3496
+ }
3497
+ return edges;
3498
+ }
3499
+ /**
3500
+ * Synthesize dispatcher→callback edges (field observers + EventEmitters +
3501
+ * React re-render + JSX children + Vue templates + SvelteKit load + RN event
3502
+ * channel + Fabric native-impl + MyBatis Java↔XML + Gin middleware chain +
3503
+ * Redux-thunk dispatch chain + object-literal registry dispatch + RTK Query
3504
+ * generated-hook → endpoint + Pinia useStore().action() + Vuex string dispatch +
3505
+ * Celery task .delay()/.apply_async() → task body + Spring publishEvent → @EventListener +
3506
+ * MediatR Send/Publish → IRequestHandler/INotificationHandler +
3507
+ * Sidekiq Worker.perform_async → #perform + Laravel event(new X) → listener handle).
3508
+ * Returns the count added. Never throws into indexing — callers wrap in try/catch.
3509
+ */
3510
+ async function synthesizeCallbackEdges(queries, ctx) {
3511
+ // Each sub-pass below is a whole-graph scan, and there are ~30 of them, all
3512
+ // running synchronously on the indexer's main thread. Their AGGREGATE can run
3513
+ // for well over a minute on a large repo — long enough for the #850 liveness
3514
+ // watchdog to SIGKILL the process mid-index (#1091), since its heartbeat lives
3515
+ // on this same thread. Yield between passes so the heartbeat can fire; a pass
3516
+ // that itself hangs (a real wedge) never reaches the next yield, so the
3517
+ // watchdog still catches that. See ./cooperative-yield.
3518
+ const yieldToLoop = (0, cooperative_yield_1.createYielder)();
3519
+ // Cross-file Go method→type `contains` edges must be synthesized AND persisted
3520
+ // FIRST: a method declared in a different file from its receiver type is
3521
+ // otherwise orphaned from the struct, and goImplementsEdges (next) derives a
3522
+ // struct's method set from its `contains` edges — so without this it would
3523
+ // under-count the interfaces a cross-file struct satisfies. (#583)
3524
+ const goMethodContains = goCrossFileMethodContainsEdges(queries);
3525
+ if (goMethodContains.length > 0)
3526
+ queries.insertEdges(goMethodContains);
3527
+ await yieldToLoop();
3528
+ // Go implicit `implements` edges must be synthesized AND persisted next: the
3529
+ // interface-dispatch bridge below reads `implements` edges from the DB, and
3530
+ // Go has none statically. (Other languages already have static implements
3531
+ // edges from extraction, so they don't need this pre-pass.)
3532
+ const goImpl = goImplementsEdges(queries);
3533
+ if (goImpl.length > 0)
3534
+ queries.insertEdges(goImpl);
3535
+ await yieldToLoop();
3536
+ const fieldEdges = await fieldChannelEdges(queries, ctx, yieldToLoop);
3537
+ await yieldToLoop();
3538
+ const closureCollEdges = await closureCollectionEdges(queries, ctx, yieldToLoop);
3539
+ await yieldToLoop();
3540
+ const emitterEdges = await eventEmitterEdges(ctx, yieldToLoop);
3541
+ await yieldToLoop();
3542
+ const renderEdges = reactRenderEdges(queries, ctx);
3543
+ await yieldToLoop();
3544
+ const jsxEdges = await reactJsxChildEdges(ctx, yieldToLoop);
3545
+ await yieldToLoop();
3546
+ const vueEdges = vueTemplateEdges(ctx);
3547
+ await yieldToLoop();
3548
+ const svelteKitEdges = svelteKitLoadEdges(ctx);
3549
+ await yieldToLoop();
3550
+ const pascalEdges = pascalFormEdges(ctx);
3551
+ await yieldToLoop();
3552
+ const flutterEdges = flutterBuildEdges(queries, ctx);
3553
+ await yieldToLoop();
3554
+ const arkuiStateEdges = arkuiStateBuildEdges(queries, ctx);
3555
+ await yieldToLoop();
3556
+ const arkuiEmitter = arkuiEmitterEdges(ctx);
3557
+ await yieldToLoop();
3558
+ const arkuiRoutes = arkuiRouterEdges(ctx);
3559
+ await yieldToLoop();
3560
+ const cppEdges = cppOverrideEdges(queries);
3561
+ await yieldToLoop();
3562
+ const ifaceEdges = interfaceOverrideEdges(queries);
3563
+ await yieldToLoop();
3564
+ const kotlinExpectActual = kotlinExpectActualEdges(queries);
3565
+ await yieldToLoop();
3566
+ const goGrpcEdges = goGrpcStubImplEdges(queries);
3567
+ await yieldToLoop();
3568
+ const rnEventEdgesList = rnEventEdges(ctx);
3569
+ await yieldToLoop();
3570
+ const fabricNativeEdges = fabricNativeImplEdges(ctx);
3571
+ await yieldToLoop();
3572
+ const expoXPlatEdges = expoCrossPlatformEdges(queries);
3573
+ await yieldToLoop();
3574
+ const rnXPlatEdges = rnCrossPlatformEdges(queries);
3575
+ await yieldToLoop();
3576
+ const mybatisEdges = mybatisJavaXmlEdges(queries);
3577
+ await yieldToLoop();
3578
+ const ginEdges = ginMiddlewareChainEdges(queries, ctx);
3579
+ await yieldToLoop();
3580
+ const thunkEdges = reduxThunkEdges(queries, ctx);
3581
+ await yieldToLoop();
3582
+ const registryEdges = await objectRegistryEdges(ctx, yieldToLoop);
3583
+ await yieldToLoop();
3584
+ const rtkEdges = rtkQueryEdges(queries, ctx);
3585
+ await yieldToLoop();
3586
+ const piniaEdges = piniaStoreEdges(ctx);
3587
+ await yieldToLoop();
3588
+ const vuexEdges = vuexDispatchEdges(ctx);
3589
+ await yieldToLoop();
3590
+ const celeryEdges = celeryDispatchEdges(ctx);
3591
+ await yieldToLoop();
3592
+ const springEdges = springEventEdges(ctx);
3593
+ await yieldToLoop();
3594
+ const mediatrEdges = mediatrDispatchEdges(ctx);
3595
+ await yieldToLoop();
3596
+ const sidekiqEdges = sidekiqDispatchEdges(ctx);
3597
+ await yieldToLoop();
3598
+ const erlangBehaviourEdges = erlangBehaviourDispatchEdges(queries, ctx);
3599
+ await yieldToLoop();
3600
+ const laravelEdges = laravelEventEdges(ctx);
3601
+ await yieldToLoop();
3602
+ const cFnPtrEdges = (0, c_fnptr_synthesizer_1.cFnPointerDispatchEdges)(queries, ctx);
3603
+ await yieldToLoop();
3604
+ const goframeEdges = (0, goframe_synthesizer_1.goframeRouteEdges)(ctx);
3605
+ await yieldToLoop();
3606
+ const nixOptionEdges = await nixOptionPathEdges(queries, yieldToLoop);
3607
+ await yieldToLoop();
3608
+ const merged = [];
3609
+ const seen = new Set();
3610
+ for (const e of [
3611
+ ...fieldEdges,
3612
+ ...closureCollEdges,
3613
+ ...emitterEdges,
3614
+ ...renderEdges,
3615
+ ...jsxEdges,
3616
+ ...vueEdges,
3617
+ ...svelteKitEdges,
3618
+ ...pascalEdges,
3619
+ ...flutterEdges,
3620
+ ...arkuiStateEdges,
3621
+ ...arkuiEmitter,
3622
+ ...arkuiRoutes,
3623
+ ...cppEdges,
3624
+ ...ifaceEdges,
3625
+ ...kotlinExpectActual,
3626
+ ...goGrpcEdges,
3627
+ ...rnEventEdgesList,
3628
+ ...fabricNativeEdges,
3629
+ ...expoXPlatEdges,
3630
+ ...rnXPlatEdges,
3631
+ ...mybatisEdges,
3632
+ ...ginEdges,
3633
+ ...thunkEdges,
3634
+ ...registryEdges,
3635
+ ...rtkEdges,
3636
+ ...piniaEdges,
3637
+ ...vuexEdges,
3638
+ ...celeryEdges,
3639
+ ...springEdges,
3640
+ ...mediatrEdges,
3641
+ ...sidekiqEdges,
3642
+ ...erlangBehaviourEdges,
3643
+ ...laravelEdges,
3644
+ ...cFnPtrEdges,
3645
+ ...goframeEdges,
3646
+ ...nixOptionEdges,
3647
+ ]) {
3648
+ const key = `${e.source}>${e.target}`;
3649
+ if (seen.has(key))
3650
+ continue;
3651
+ seen.add(key);
3652
+ merged.push(e);
3653
+ }
3654
+ if (merged.length > 0)
3655
+ queries.insertEdges(merged);
3656
+ return merged.length + goImpl.length + goMethodContains.length;
3657
+ }
3658
+ //# sourceMappingURL=callback-synthesizer.js.map