homegraph 1.0.0 → 1.1.2

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