homegraph 0.9.10 → 1.1.1

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 (436) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +243 -193
  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 +6 -6
  8. package/dist/bin/homegraph.js +532 -109
  9. package/dist/bin/homegraph.js.map +1 -1
  10. package/dist/bin/node-version-check.d.ts +4 -4
  11. package/dist/bin/node-version-check.js +12 -12
  12. package/dist/bin/uninstall.d.ts +1 -1
  13. package/dist/bin/uninstall.js +1 -1
  14. package/dist/context/index.d.ts.map +1 -1
  15. package/dist/context/index.js +8 -1
  16. package/dist/context/index.js.map +1 -1
  17. package/dist/db/index.d.ts +22 -1
  18. package/dist/db/index.d.ts.map +1 -1
  19. package/dist/db/index.js +48 -2
  20. package/dist/db/index.js.map +1 -1
  21. package/dist/db/migrations.d.ts +1 -1
  22. package/dist/db/migrations.d.ts.map +1 -1
  23. package/dist/db/migrations.js +26 -17
  24. package/dist/db/migrations.js.map +1 -1
  25. package/dist/db/queries.d.ts +21 -1
  26. package/dist/db/queries.d.ts.map +1 -1
  27. package/dist/db/queries.js +180 -137
  28. package/dist/db/queries.js.map +1 -1
  29. package/dist/db/schema.sql +152 -151
  30. package/dist/db/sqlite-adapter.d.ts +1 -1
  31. package/dist/db/sqlite-adapter.js +3 -3
  32. package/dist/directory.d.ts +87 -6
  33. package/dist/directory.d.ts.map +1 -1
  34. package/dist/directory.js +319 -57
  35. package/dist/directory.js.map +1 -1
  36. package/dist/errors.d.ts +15 -15
  37. package/dist/errors.js +20 -20
  38. package/dist/extraction/astro-extractor.d.ts +79 -0
  39. package/dist/extraction/astro-extractor.d.ts.map +1 -0
  40. package/dist/extraction/astro-extractor.js +320 -0
  41. package/dist/extraction/astro-extractor.js.map +1 -0
  42. package/dist/extraction/context.d.ts +1 -1
  43. package/dist/extraction/context.js +1 -1
  44. package/dist/extraction/extraction-version.d.ts +2 -2
  45. package/dist/extraction/extraction-version.d.ts.map +1 -1
  46. package/dist/extraction/extraction-version.js +2 -2
  47. package/dist/extraction/extraction-version.js.map +1 -1
  48. package/dist/extraction/function-ref.d.ts +118 -0
  49. package/dist/extraction/function-ref.d.ts.map +1 -0
  50. package/dist/extraction/function-ref.js +727 -0
  51. package/dist/extraction/function-ref.js.map +1 -0
  52. package/dist/extraction/generated-detection.d.ts.map +1 -1
  53. package/dist/extraction/generated-detection.js +3 -0
  54. package/dist/extraction/generated-detection.js.map +1 -1
  55. package/dist/extraction/grammars.d.ts +15 -5
  56. package/dist/extraction/grammars.d.ts.map +1 -1
  57. package/dist/extraction/grammars.js +44 -10
  58. package/dist/extraction/grammars.js.map +1 -1
  59. package/dist/extraction/index.d.ts +37 -0
  60. package/dist/extraction/index.d.ts.map +1 -1
  61. package/dist/extraction/index.js +562 -70
  62. package/dist/extraction/index.js.map +1 -1
  63. package/dist/extraction/languages/arkts-viewtree.d.ts +22 -0
  64. package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -0
  65. package/dist/extraction/languages/arkts-viewtree.js +133 -0
  66. package/dist/extraction/languages/arkts-viewtree.js.map +1 -0
  67. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  68. package/dist/extraction/languages/arkts.js +211 -20
  69. package/dist/extraction/languages/arkts.js.map +1 -1
  70. package/dist/extraction/languages/c-cpp.d.ts +8 -0
  71. package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  72. package/dist/extraction/languages/c-cpp.js +104 -2
  73. package/dist/extraction/languages/c-cpp.js.map +1 -1
  74. package/dist/extraction/languages/csharp.d.ts.map +1 -1
  75. package/dist/extraction/languages/csharp.js +58 -3
  76. package/dist/extraction/languages/csharp.js.map +1 -1
  77. package/dist/extraction/languages/dart.d.ts.map +1 -1
  78. package/dist/extraction/languages/dart.js +183 -1
  79. package/dist/extraction/languages/dart.js.map +1 -1
  80. package/dist/extraction/languages/go.d.ts.map +1 -1
  81. package/dist/extraction/languages/go.js +37 -0
  82. package/dist/extraction/languages/go.js.map +1 -1
  83. package/dist/extraction/languages/index.d.ts.map +1 -1
  84. package/dist/extraction/languages/index.js +2 -0
  85. package/dist/extraction/languages/index.js.map +1 -1
  86. package/dist/extraction/languages/java.d.ts.map +1 -1
  87. package/dist/extraction/languages/java.js +241 -0
  88. package/dist/extraction/languages/java.js.map +1 -1
  89. package/dist/extraction/languages/javascript.d.ts.map +1 -1
  90. package/dist/extraction/languages/javascript.js +16 -0
  91. package/dist/extraction/languages/javascript.js.map +1 -1
  92. package/dist/extraction/languages/kotlin.d.ts.map +1 -1
  93. package/dist/extraction/languages/kotlin.js +94 -0
  94. package/dist/extraction/languages/kotlin.js.map +1 -1
  95. package/dist/extraction/languages/objc.d.ts.map +1 -1
  96. package/dist/extraction/languages/objc.js +42 -0
  97. package/dist/extraction/languages/objc.js.map +1 -1
  98. package/dist/extraction/languages/pascal.d.ts.map +1 -1
  99. package/dist/extraction/languages/pascal.js +11 -0
  100. package/dist/extraction/languages/pascal.js.map +1 -1
  101. package/dist/extraction/languages/php.d.ts.map +1 -1
  102. package/dist/extraction/languages/php.js +77 -1
  103. package/dist/extraction/languages/php.js.map +1 -1
  104. package/dist/extraction/languages/r.d.ts +3 -0
  105. package/dist/extraction/languages/r.d.ts.map +1 -0
  106. package/dist/extraction/languages/r.js +314 -0
  107. package/dist/extraction/languages/r.js.map +1 -0
  108. package/dist/extraction/languages/rust.d.ts.map +1 -1
  109. package/dist/extraction/languages/rust.js +29 -0
  110. package/dist/extraction/languages/rust.js.map +1 -1
  111. package/dist/extraction/languages/scala.d.ts.map +1 -1
  112. package/dist/extraction/languages/scala.js +44 -9
  113. package/dist/extraction/languages/scala.js.map +1 -1
  114. package/dist/extraction/languages/swift.d.ts.map +1 -1
  115. package/dist/extraction/languages/swift.js +61 -0
  116. package/dist/extraction/languages/swift.js.map +1 -1
  117. package/dist/extraction/languages/typescript.d.ts +13 -0
  118. package/dist/extraction/languages/typescript.d.ts.map +1 -1
  119. package/dist/extraction/languages/typescript.js +38 -0
  120. package/dist/extraction/languages/typescript.js.map +1 -1
  121. package/dist/extraction/liquid-extractor.d.ts.map +1 -1
  122. package/dist/extraction/liquid-extractor.js +4 -1
  123. package/dist/extraction/liquid-extractor.js.map +1 -1
  124. package/dist/extraction/parse-worker.js +4 -1
  125. package/dist/extraction/parse-worker.js.map +1 -1
  126. package/dist/extraction/svelte-extractor.d.ts.map +1 -1
  127. package/dist/extraction/svelte-extractor.js +6 -3
  128. package/dist/extraction/svelte-extractor.js.map +1 -1
  129. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  130. package/dist/extraction/tree-sitter-helpers.js +59 -10
  131. package/dist/extraction/tree-sitter-helpers.js.map +1 -1
  132. package/dist/extraction/tree-sitter-types.d.ts +29 -0
  133. package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  134. package/dist/extraction/tree-sitter.d.ts +192 -0
  135. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  136. package/dist/extraction/tree-sitter.js +1553 -45
  137. package/dist/extraction/tree-sitter.js.map +1 -1
  138. package/dist/extraction/vue-extractor.d.ts.map +1 -1
  139. package/dist/extraction/vue-extractor.js +6 -3
  140. package/dist/extraction/vue-extractor.js.map +1 -1
  141. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  142. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  143. package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  144. package/dist/graph/traversal.d.ts.map +1 -1
  145. package/dist/graph/traversal.js +11 -2
  146. package/dist/graph/traversal.js.map +1 -1
  147. package/dist/index.d.ts +64 -23
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +137 -41
  150. package/dist/index.js.map +1 -1
  151. package/dist/installer/config-writer.d.ts +1 -1
  152. package/dist/installer/config-writer.js +1 -1
  153. package/dist/installer/index.d.ts +4 -4
  154. package/dist/installer/index.d.ts.map +1 -1
  155. package/dist/installer/index.js +100 -73
  156. package/dist/installer/index.js.map +1 -1
  157. package/dist/installer/instructions-template.d.ts +34 -11
  158. package/dist/installer/instructions-template.d.ts.map +1 -1
  159. package/dist/installer/instructions-template.js +44 -12
  160. package/dist/installer/instructions-template.js.map +1 -1
  161. package/dist/installer/targets/antigravity.d.ts +6 -6
  162. package/dist/installer/targets/antigravity.js +14 -14
  163. package/dist/installer/targets/claude.d.ts +19 -13
  164. package/dist/installer/targets/claude.d.ts.map +1 -1
  165. package/dist/installer/targets/claude.js +97 -29
  166. package/dist/installer/targets/claude.js.map +1 -1
  167. package/dist/installer/targets/codebuddy.d.ts +17 -0
  168. package/dist/installer/targets/codebuddy.d.ts.map +1 -0
  169. package/dist/installer/targets/codebuddy.js +150 -0
  170. package/dist/installer/targets/codebuddy.js.map +1 -0
  171. package/dist/installer/targets/codex.js +5 -7
  172. package/dist/installer/targets/codex.js.map +1 -1
  173. package/dist/installer/targets/cursor.d.ts +1 -1
  174. package/dist/installer/targets/cursor.js +7 -7
  175. package/dist/installer/targets/deveco.d.ts +23 -0
  176. package/dist/installer/targets/deveco.d.ts.map +1 -0
  177. package/dist/installer/targets/deveco.js +217 -0
  178. package/dist/installer/targets/deveco.js.map +1 -0
  179. package/dist/installer/targets/gemini.js +5 -7
  180. package/dist/installer/targets/gemini.js.map +1 -1
  181. package/dist/installer/targets/hermes.js +15 -15
  182. package/dist/installer/targets/kiro.d.ts +1 -1
  183. package/dist/installer/targets/kiro.js +4 -4
  184. package/dist/installer/targets/opencode.d.ts +9 -1
  185. package/dist/installer/targets/opencode.d.ts.map +1 -1
  186. package/dist/installer/targets/opencode.js +92 -41
  187. package/dist/installer/targets/opencode.js.map +1 -1
  188. package/dist/installer/targets/registry.d.ts.map +1 -1
  189. package/dist/installer/targets/registry.js +4 -0
  190. package/dist/installer/targets/registry.js.map +1 -1
  191. package/dist/installer/targets/shared.d.ts +28 -4
  192. package/dist/installer/targets/shared.d.ts.map +1 -1
  193. package/dist/installer/targets/shared.js +32 -15
  194. package/dist/installer/targets/shared.js.map +1 -1
  195. package/dist/installer/targets/types.d.ts +9 -2
  196. package/dist/installer/targets/types.d.ts.map +1 -1
  197. package/dist/mcp/daemon-manager.d.ts +42 -0
  198. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  199. package/dist/mcp/daemon-manager.js +129 -0
  200. package/dist/mcp/daemon-manager.js.map +1 -0
  201. package/dist/mcp/daemon-paths.d.ts +1 -1
  202. package/dist/mcp/daemon-paths.js +3 -3
  203. package/dist/mcp/daemon-registry.d.ts +47 -0
  204. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  205. package/dist/mcp/daemon-registry.js +229 -0
  206. package/dist/mcp/daemon-registry.js.map +1 -0
  207. package/dist/mcp/daemon.d.ts.map +1 -1
  208. package/dist/mcp/daemon.js +27 -6
  209. package/dist/mcp/daemon.js.map +1 -1
  210. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  211. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  212. package/dist/mcp/dynamic-boundaries.js +359 -0
  213. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  214. package/dist/mcp/engine.d.ts +4 -4
  215. package/dist/mcp/engine.d.ts.map +1 -1
  216. package/dist/mcp/engine.js +32 -24
  217. package/dist/mcp/engine.js.map +1 -1
  218. package/dist/mcp/index.d.ts +8 -7
  219. package/dist/mcp/index.d.ts.map +1 -1
  220. package/dist/mcp/index.js +39 -18
  221. package/dist/mcp/index.js.map +1 -1
  222. package/dist/mcp/liveness-watchdog.d.ts +18 -0
  223. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  224. package/dist/mcp/liveness-watchdog.js +207 -0
  225. package/dist/mcp/liveness-watchdog.js.map +1 -0
  226. package/dist/mcp/proxy.d.ts +6 -0
  227. package/dist/mcp/proxy.d.ts.map +1 -1
  228. package/dist/mcp/proxy.js +75 -18
  229. package/dist/mcp/proxy.js.map +1 -1
  230. package/dist/mcp/server-instructions.d.ts +22 -7
  231. package/dist/mcp/server-instructions.d.ts.map +1 -1
  232. package/dist/mcp/server-instructions.js +91 -59
  233. package/dist/mcp/server-instructions.js.map +1 -1
  234. package/dist/mcp/session.d.ts +3 -1
  235. package/dist/mcp/session.d.ts.map +1 -1
  236. package/dist/mcp/session.js +43 -7
  237. package/dist/mcp/session.js.map +1 -1
  238. package/dist/mcp/stdin-teardown.d.ts +27 -0
  239. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  240. package/dist/mcp/stdin-teardown.js +49 -0
  241. package/dist/mcp/stdin-teardown.js.map +1 -0
  242. package/dist/mcp/tools.d.ts +137 -16
  243. package/dist/mcp/tools.d.ts.map +1 -1
  244. package/dist/mcp/tools.js +1271 -219
  245. package/dist/mcp/tools.js.map +1 -1
  246. package/dist/mcp/transport.d.ts +1 -1
  247. package/dist/mcp/transport.d.ts.map +1 -1
  248. package/dist/mcp/transport.js +20 -4
  249. package/dist/mcp/transport.js.map +1 -1
  250. package/dist/mcp/version.d.ts +1 -1
  251. package/dist/mcp/version.js +2 -2
  252. package/dist/project-config.d.ts +36 -0
  253. package/dist/project-config.d.ts.map +1 -0
  254. package/dist/project-config.js +235 -0
  255. package/dist/project-config.js.map +1 -0
  256. package/dist/reasoning/config.d.ts +45 -0
  257. package/dist/reasoning/config.d.ts.map +1 -0
  258. package/dist/reasoning/config.js +171 -0
  259. package/dist/reasoning/config.js.map +1 -0
  260. package/dist/reasoning/credentials.d.ts +5 -0
  261. package/dist/reasoning/credentials.d.ts.map +1 -0
  262. package/dist/reasoning/credentials.js +83 -0
  263. package/dist/reasoning/credentials.js.map +1 -0
  264. package/dist/reasoning/login.d.ts +21 -0
  265. package/dist/reasoning/login.d.ts.map +1 -0
  266. package/dist/reasoning/login.js +85 -0
  267. package/dist/reasoning/login.js.map +1 -0
  268. package/dist/reasoning/reasoner.d.ts +43 -0
  269. package/dist/reasoning/reasoner.d.ts.map +1 -0
  270. package/dist/reasoning/reasoner.js +308 -0
  271. package/dist/reasoning/reasoner.js.map +1 -0
  272. package/dist/resolution/c-fnptr-synthesizer.d.ts +33 -0
  273. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  274. package/dist/resolution/c-fnptr-synthesizer.js +352 -0
  275. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  276. package/dist/resolution/callback-synthesizer.d.ts +6 -1
  277. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  278. package/dist/resolution/callback-synthesizer.js +1197 -1
  279. package/dist/resolution/callback-synthesizer.js.map +1 -1
  280. package/dist/resolution/frameworks/arkts-entry.d.ts +12 -0
  281. package/dist/resolution/frameworks/arkts-entry.d.ts.map +1 -0
  282. package/dist/resolution/frameworks/arkts-entry.js +214 -0
  283. package/dist/resolution/frameworks/arkts-entry.js.map +1 -0
  284. package/dist/resolution/frameworks/arkts-napi.d.ts +3 -0
  285. package/dist/resolution/frameworks/arkts-napi.d.ts.map +1 -0
  286. package/dist/resolution/frameworks/arkts-napi.js +166 -0
  287. package/dist/resolution/frameworks/arkts-napi.js.map +1 -0
  288. package/dist/resolution/frameworks/astro.d.ts +9 -0
  289. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  290. package/dist/resolution/frameworks/astro.js +169 -0
  291. package/dist/resolution/frameworks/astro.js.map +1 -0
  292. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  293. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  294. package/dist/resolution/frameworks/goframe.js +112 -0
  295. package/dist/resolution/frameworks/goframe.js.map +1 -0
  296. package/dist/resolution/frameworks/index.d.ts +3 -0
  297. package/dist/resolution/frameworks/index.d.ts.map +1 -1
  298. package/dist/resolution/frameworks/index.js +17 -1
  299. package/dist/resolution/frameworks/index.js.map +1 -1
  300. package/dist/resolution/frameworks/java.js +6 -1
  301. package/dist/resolution/frameworks/java.js.map +1 -1
  302. package/dist/resolution/frameworks/react.d.ts.map +1 -1
  303. package/dist/resolution/frameworks/react.js +32 -63
  304. package/dist/resolution/frameworks/react.js.map +1 -1
  305. package/dist/resolution/frameworks/svelte.js +6 -2
  306. package/dist/resolution/frameworks/svelte.js.map +1 -1
  307. package/dist/resolution/frameworks/vue.js +24 -27
  308. package/dist/resolution/frameworks/vue.js.map +1 -1
  309. package/dist/resolution/goframe-synthesizer.d.ts +28 -0
  310. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  311. package/dist/resolution/goframe-synthesizer.js +158 -0
  312. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  313. package/dist/resolution/import-resolver.d.ts +10 -0
  314. package/dist/resolution/import-resolver.d.ts.map +1 -1
  315. package/dist/resolution/import-resolver.js +125 -2
  316. package/dist/resolution/import-resolver.js.map +1 -1
  317. package/dist/resolution/index.d.ts +37 -0
  318. package/dist/resolution/index.d.ts.map +1 -1
  319. package/dist/resolution/index.js +306 -3
  320. package/dist/resolution/index.js.map +1 -1
  321. package/dist/resolution/name-matcher.d.ts +41 -0
  322. package/dist/resolution/name-matcher.d.ts.map +1 -1
  323. package/dist/resolution/name-matcher.js +519 -14
  324. package/dist/resolution/name-matcher.js.map +1 -1
  325. package/dist/resolution/strip-comments.d.ts +1 -1
  326. package/dist/resolution/strip-comments.d.ts.map +1 -1
  327. package/dist/resolution/strip-comments.js +2 -0
  328. package/dist/resolution/strip-comments.js.map +1 -1
  329. package/dist/resolution/types.d.ts +20 -3
  330. package/dist/resolution/types.d.ts.map +1 -1
  331. package/dist/search/query-utils.d.ts +17 -1
  332. package/dist/search/query-utils.d.ts.map +1 -1
  333. package/dist/search/query-utils.js +79 -10
  334. package/dist/search/query-utils.js.map +1 -1
  335. package/dist/sync/git-hooks.d.ts +4 -4
  336. package/dist/sync/git-hooks.js +5 -5
  337. package/dist/sync/watcher.d.ts +69 -2
  338. package/dist/sync/watcher.d.ts.map +1 -1
  339. package/dist/sync/watcher.js +226 -21
  340. package/dist/sync/watcher.js.map +1 -1
  341. package/dist/sync/worktree.d.ts +3 -3
  342. package/dist/sync/worktree.js +5 -5
  343. package/dist/telemetry/index.d.ts +143 -0
  344. package/dist/telemetry/index.d.ts.map +1 -0
  345. package/dist/telemetry/index.js +541 -0
  346. package/dist/telemetry/index.js.map +1 -0
  347. package/dist/types.d.ts +18 -3
  348. package/dist/types.d.ts.map +1 -1
  349. package/dist/types.js +3 -1
  350. package/dist/types.js.map +1 -1
  351. package/dist/upgrade/index.d.ts.map +1 -1
  352. package/dist/upgrade/index.js +46 -10
  353. package/dist/upgrade/index.js.map +1 -1
  354. package/dist/utils.d.ts +46 -27
  355. package/dist/utils.d.ts.map +1 -1
  356. package/dist/utils.js +87 -53
  357. package/dist/utils.js.map +1 -1
  358. package/package.json +57 -57
  359. package/scripts/add-lang/bench.sh +60 -60
  360. package/scripts/add-lang/check-grammar.mjs +75 -75
  361. package/scripts/add-lang/dump-ast.mjs +103 -103
  362. package/scripts/add-lang/verify-extraction.mjs +70 -70
  363. package/scripts/agent-eval/ab-adoption.sh +91 -0
  364. package/scripts/agent-eval/ab-hook.sh +86 -0
  365. package/scripts/agent-eval/ab-impl.sh +78 -0
  366. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
  367. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  368. package/scripts/agent-eval/arms-F.sh +21 -21
  369. package/scripts/agent-eval/arms-matrix.sh +37 -37
  370. package/scripts/agent-eval/audit.sh +68 -68
  371. package/scripts/agent-eval/bench-readme.sh +28 -28
  372. package/scripts/agent-eval/bench-why-repo.sh +22 -22
  373. package/scripts/agent-eval/block-read-hook.sh +19 -19
  374. package/scripts/agent-eval/hook-settings.json +15 -15
  375. package/scripts/agent-eval/itrun.sh +120 -120
  376. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  377. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  378. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  379. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  380. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  381. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  382. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  383. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  384. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  385. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  386. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  387. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  388. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  389. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  390. package/scripts/agent-eval/offload-eval.md +76 -0
  391. package/scripts/agent-eval/parse-arms.mjs +116 -116
  392. package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
  393. package/scripts/agent-eval/parse-run.mjs +45 -45
  394. package/scripts/agent-eval/parse-session.mjs +93 -93
  395. package/scripts/agent-eval/probe-context.mjs +21 -21
  396. package/scripts/agent-eval/probe-explore.mjs +40 -40
  397. package/scripts/agent-eval/probe-node.mjs +20 -20
  398. package/scripts/agent-eval/probe-sweep.mjs +119 -119
  399. package/scripts/agent-eval/probe-trace.mjs +20 -20
  400. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  401. package/scripts/agent-eval/run-agent.sh +34 -34
  402. package/scripts/agent-eval/run-all.sh +69 -67
  403. package/scripts/agent-eval/run-arms.sh +56 -56
  404. package/scripts/agent-eval/seq-matrix.mjs +137 -137
  405. package/scripts/build-bundle.sh +118 -118
  406. package/scripts/extract-release-notes.mjs +130 -130
  407. package/scripts/local-install.sh +41 -41
  408. package/scripts/npm-sdk.js +75 -75
  409. package/scripts/npm-shim.js +246 -246
  410. package/scripts/pack-npm.sh +119 -119
  411. package/scripts/prepare-release.mjs +270 -270
  412. package/scripts/qa_eval/README.md +400 -0
  413. package/scripts/qa_eval/agent_runner.py +526 -0
  414. package/scripts/qa_eval/data/.gitignore +4 -0
  415. package/scripts/qa_eval/data/test-set.jsonl +22 -0
  416. package/scripts/qa_eval/eval_metrics.py +233 -0
  417. package/scripts/qa_eval/external_agent.py +577 -0
  418. package/scripts/qa_eval/llm_config.py +92 -0
  419. package/scripts/qa_eval/memory_monitor.py +132 -0
  420. package/scripts/qa_eval/my_answer_accuracy.py +187 -0
  421. package/scripts/qa_eval/requirements.txt +2 -0
  422. package/scripts/qa_eval/run_pipeline.py +702 -0
  423. package/scripts/qa_eval/stats_efficiency.py +279 -0
  424. package/scripts/qa_eval/stats_scores.py +207 -0
  425. package/dist/bin/codegraph.d.ts +0 -26
  426. package/dist/bin/codegraph.d.ts.map +0 -1
  427. package/dist/bin/codegraph.js +0 -1572
  428. package/dist/bin/codegraph.js.map +0 -1
  429. package/dist/extraction/arkanalyzer-extractor.d.ts +0 -6
  430. package/dist/extraction/arkanalyzer-extractor.d.ts.map +0 -1
  431. package/dist/extraction/arkanalyzer-extractor.js +0 -11
  432. package/dist/extraction/arkanalyzer-extractor.js.map +0 -1
  433. package/dist/extraction/arkanalyzer-project.d.ts +0 -20
  434. package/dist/extraction/arkanalyzer-project.d.ts.map +0 -1
  435. package/dist/extraction/arkanalyzer-project.js +0 -596
  436. package/dist/extraction/arkanalyzer-project.js.map +0 -1
@@ -9,8 +9,12 @@ exports.matchByFilePath = matchByFilePath;
9
9
  exports.sameLanguageFamily = sameLanguageFamily;
10
10
  exports.isKnownLanguageFamily = isKnownLanguageFamily;
11
11
  exports.crossesKnownFamily = crossesKnownFamily;
12
+ exports.matchFunctionRef = matchFunctionRef;
12
13
  exports.matchByExactName = matchByExactName;
13
14
  exports.matchByQualifiedName = matchByQualifiedName;
15
+ exports.matchCppCallChain = matchCppCallChain;
16
+ exports.matchScopedCallChain = matchScopedCallChain;
17
+ exports.matchDottedCallChain = matchDottedCallChain;
14
18
  exports.matchMethodCall = matchMethodCall;
15
19
  exports.matchFuzzy = matchFuzzy;
16
20
  exports.matchReference = matchReference;
@@ -153,7 +157,7 @@ function crossesKnownFamily(a, b) {
153
157
  * both-known filter so `.vue`/`.svelte` (own tag) importing `.ts` survives.
154
158
  */
155
159
  function applyLanguageGate(candidates, ref) {
156
- if (ref.referenceKind === 'references') {
160
+ if (ref.referenceKind === 'references' || ref.referenceKind === 'function_ref') {
157
161
  return candidates.filter((c) => sameLanguageFamily(c.language, ref.language));
158
162
  }
159
163
  if (ref.referenceKind === 'imports') {
@@ -161,11 +165,152 @@ function applyLanguageGate(candidates, ref) {
161
165
  }
162
166
  return candidates;
163
167
  }
168
+ /**
169
+ * Resolve a function-as-value reference (#756) — a function name used as a
170
+ * callback/function-pointer value (`register(handler)`, `o->cb = handler`,
171
+ * `{ .cb = handler }`, `signal(SIGINT, handler)`). The ONLY strategy allowed
172
+ * for `function_ref` refs: exact name, function/method targets only, same
173
+ * language family, same-file first, and cross-file only when the match is
174
+ * UNIQUE. No fuzzy fallback, no qualified-name walking — a wrong callback
175
+ * edge is worse than none.
176
+ */
177
+ function matchFunctionRef(ref, context) {
178
+ // `this.<member>` refs are resolved ONLY by the class-scoped resolver in
179
+ // resolveOne (resolveThisMemberFnRef) — never by name matching here.
180
+ if (ref.referenceName.startsWith('this.'))
181
+ return null;
182
+ // In JS/TS/Python a bare identifier can never be a method value (methods
183
+ // are only reachable through a receiver — `this.m` / `self.m` /
184
+ // `Cls.m`), so bare fn-refs match FUNCTIONS only. This also sidesteps the
185
+ // pre-existing TS quirk of class fields extracting as method-kind nodes,
186
+ // which otherwise soaked up local names passed as arguments (excalidraw
187
+ // A/B finding; same pattern in vendored docopt.py). Python's `self.m`
188
+ // form keeps method targets via its own capture shape. C++ likewise: a
189
+ // bare identifier can only be a FREE function (member values need
190
+ // `&Cls::method`). PHP string callables name global FUNCTIONS (methods
191
+ // need the `[$obj, 'm']` array form, which carries its own shape). Other
192
+ // languages keep method targets: C# method groups, Swift/Dart
193
+ // implicit-self, Java/Kotlin method references.
194
+ const bareFnOnly = ref.language === 'typescript' || ref.language === 'tsx' ||
195
+ ref.language === 'javascript' || ref.language === 'jsx' ||
196
+ ref.language === 'cpp' || ref.language === 'python' ||
197
+ ref.language === 'php';
198
+ // Qualified member-pointer (`&Widget::on_click` → "Widget::on_click"):
199
+ // resolve the member ON THAT SCOPE — exempt from bareFnOnly (the `&Cls::m`
200
+ // shape is an explicit member reference). Unique-or-drop like everything else.
201
+ if (ref.referenceName.includes('::')) {
202
+ const memberName = ref.referenceName.slice(ref.referenceName.lastIndexOf('::') + 2);
203
+ const scoped = context
204
+ .getNodesByName(memberName)
205
+ .filter((n) => (n.kind === 'function' || n.kind === 'method') &&
206
+ sameLanguageFamily(n.language, ref.language) &&
207
+ n.id !== ref.fromNodeId &&
208
+ (n.qualifiedName === ref.referenceName ||
209
+ n.qualifiedName.endsWith(`::${ref.referenceName}`)));
210
+ if (scoped.length === 0)
211
+ return null;
212
+ const sameFileScoped = scoped.filter((n) => n.filePath === ref.filePath);
213
+ const pool = sameFileScoped.length > 0 ? sameFileScoped : scoped;
214
+ if (sameFileScoped.length === 0 && scoped.length > 1)
215
+ return null;
216
+ const target = pool.reduce((a, b) => (a.startLine <= b.startLine ? a : b));
217
+ return {
218
+ original: ref,
219
+ targetNodeId: target.id,
220
+ confidence: 0.9,
221
+ resolvedBy: 'function-ref',
222
+ };
223
+ }
224
+ let candidates = context
225
+ .getNodesByName(ref.referenceName)
226
+ .filter((n) => (n.kind === 'function' || (!bareFnOnly && n.kind === 'method')) &&
227
+ sameLanguageFamily(n.language, ref.language) &&
228
+ n.id !== ref.fromNodeId // a function registering itself is not a dependency edge
229
+ );
230
+ if (candidates.length === 0)
231
+ return null;
232
+ // Swift implicit-self: a bare identifier can name a METHOD only of the
233
+ // ENCLOSING type (`Button(action: handleTap)` written inside that type) —
234
+ // a same-named method on any OTHER class is a parameter collision
235
+ // (Alamofire: a `request` parameter resolving to EventMonitor::request).
236
+ // Scope method candidates to the from-symbol's type; top-level code has no
237
+ // implicit self, so method targets are excluded there entirely. Free
238
+ // functions are unaffected.
239
+ if (ref.language === 'swift' && candidates.some((n) => n.kind === 'method')) {
240
+ const fromNode = context.getNodeById?.(ref.fromNodeId);
241
+ const sep = fromNode ? fromNode.qualifiedName.lastIndexOf('::') : -1;
242
+ const classPrefix = fromNode && sep > 0 ? fromNode.qualifiedName.slice(0, sep) : null;
243
+ candidates = candidates.filter((n) => {
244
+ if (n.kind !== 'method')
245
+ return true;
246
+ if (!classPrefix)
247
+ return false;
248
+ const mSep = n.qualifiedName.lastIndexOf('::');
249
+ if (mSep <= 0)
250
+ return false;
251
+ const methodPrefix = n.qualifiedName.slice(0, mSep);
252
+ // Accept exact-scope matches plus suffix relationships either way, so
253
+ // extension-declared members (`Holder::m`) still match a nested
254
+ // from-scope (`Module::Holder::wire`) and vice versa.
255
+ return (methodPrefix === classPrefix ||
256
+ methodPrefix.endsWith(`::${classPrefix}`) ||
257
+ classPrefix.endsWith(`::${methodPrefix}`));
258
+ });
259
+ if (candidates.length === 0)
260
+ return null;
261
+ }
262
+ // Same-file definition wins — the extraction gate guarantees most survivors
263
+ // have one, and it's the dominant C pattern (static callback registered in
264
+ // a same-file ops struct).
265
+ const sameFile = candidates.filter((n) => n.filePath === ref.filePath);
266
+ if (sameFile.length > 0) {
267
+ // Swift: several same-named METHODS in one file is an API overload family
268
+ // (`Session.request(...)` × N), and a bare identifier hitting it is almost
269
+ // always a same-named parameter, not a method value (Alamofire A/B
270
+ // finding) — refuse rather than guess. A single method (SwiftUI's
271
+ // `action: handleTap`) still resolves.
272
+ if (ref.language === 'swift' &&
273
+ sameFile.length > 1 &&
274
+ sameFile.every((n) => n.kind === 'method')) {
275
+ return null;
276
+ }
277
+ // Same-name overloads in one file are the same conceptual symbol; pick
278
+ // the first by position for determinism.
279
+ const target = sameFile.reduce((a, b) => (a.startLine <= b.startLine ? a : b));
280
+ return {
281
+ original: ref,
282
+ targetNodeId: target.id,
283
+ confidence: sameFile.length === 1 ? 0.95 : 0.9,
284
+ resolvedBy: 'function-ref',
285
+ };
286
+ }
287
+ // Cross-file (imported names the import resolver didn't already claim):
288
+ // only an unambiguous match resolves.
289
+ if (candidates.length === 1) {
290
+ return {
291
+ original: ref,
292
+ targetNodeId: candidates[0].id,
293
+ confidence: 0.8,
294
+ resolvedBy: 'function-ref',
295
+ };
296
+ }
297
+ return null;
298
+ }
164
299
  /**
165
300
  * Try to resolve a reference by exact name match
166
301
  */
167
302
  function matchByExactName(ref, context) {
168
- const candidates = applyLanguageGate(context.getNodesByName(ref.referenceName), ref);
303
+ // `import`-kind nodes are import STATEMENTS, not definitions, so a reference
304
+ // resolving to a sibling file's `import` is a meaningless edge — the real
305
+ // import→definition resolution is the import resolver's job (resolveViaImport),
306
+ // never name-matching here. Excluding them also removes a quadratic blow-up:
307
+ // a ubiquitous package (`react`, `@superset-ui/core`, Python `logging`/`typing`)
308
+ // is re-declared as an `import` node in every file that imports it, so K
309
+ // unresolved import refs each scored K same-named import candidates through
310
+ // findBestMatch — O(K²) per package, the dominant cost of "Resolving refs" on
311
+ // large import-heavy (front-end + back-end) repos (#915).
312
+ const candidates = applyLanguageGate(context.getNodesByName(ref.referenceName), ref)
313
+ .filter((n) => n.kind !== 'import');
169
314
  if (candidates.length === 0) {
170
315
  return null;
171
316
  }
@@ -238,7 +383,9 @@ function resolveMethodOnType(typeName, methodName, ref, context, confidence, res
238
383
  * file-path-suffix picks the right one — the disambiguation
239
384
  * signal Java imports carry but the call site doesn't (#314).
240
385
  */
241
- preferredFqn) {
386
+ preferredFqn,
387
+ /** Recursion guard for the supertype/conformance walk. */
388
+ depth = 0) {
242
389
  // Look up methods by name and match by qualifiedName ending in
243
390
  // `<typeName>::<methodName>`. This works whether the method is defined
244
391
  // in-class (`class Foo { int bar() { ... } }`) or out-of-line in a separate
@@ -257,8 +404,23 @@ preferredFqn) {
257
404
  matches.push(m);
258
405
  }
259
406
  }
260
- if (matches.length === 0)
407
+ if (matches.length === 0) {
408
+ // Conformance fallback: the method may be defined on a supertype `typeName`
409
+ // extends, or on a protocol / trait it conforms to (e.g. a Swift protocol-
410
+ // extension method, a C# default-interface or extension method, a Kotlin
411
+ // extension on a supertype). Walk supertypes transitively (depth-capped) via
412
+ // the resolved implements/extends edges — empty in the first resolution pass,
413
+ // populated in the conformance pass. Still VALIDATED (the method must exist on
414
+ // a supertype), so a wrong inference produces no edge.
415
+ if (depth < 4 && context.getSupertypes) {
416
+ for (const supertype of context.getSupertypes(typeName, ref.language)) {
417
+ const via = resolveMethodOnType(supertype, methodName, ref, context, confidence, resolvedBy, preferredFqn, depth + 1);
418
+ if (via)
419
+ return via;
420
+ }
421
+ }
261
422
  return null;
423
+ }
262
424
  if (matches.length > 1 && preferredFqn) {
263
425
  const ext = ref.language === 'kotlin' ? '.kt' : '.java';
264
426
  const fqnPath = preferredFqn.replace(/\./g, '/') + ext;
@@ -315,7 +477,7 @@ function normalizeCppTypeName(typeName) {
315
477
  function buildDeclaratorRegex(escapedReceiver) {
316
478
  return new RegExp(`([A-Za-z_][\\w:]*(?:\\s*<[^;=(){}]+>)?(?:\\s*[*&]+)?)\\s*\\b${escapedReceiver}\\b\\s*(?=[;=,)\\[{(]|$)`);
317
479
  }
318
- function inferCppReceiverType(receiverName, ref, context) {
480
+ function inferCppReceiverType(receiverName, ref, context, depth = 0) {
319
481
  const source = context.readFile(ref.filePath);
320
482
  if (!source)
321
483
  return null;
@@ -331,8 +493,17 @@ function inferCppReceiverType(receiverName, ref, context) {
331
493
  const declaratorMatch = line.match(declaratorRegex);
332
494
  if (declaratorMatch) {
333
495
  const normalized = normalizeCppTypeName(declaratorMatch[1] ?? '');
334
- if (normalized)
496
+ if (normalized === 'auto') {
497
+ // `auto x = Foo::instance();` — the declared type is deduced; recover it
498
+ // from the initializer (call return type / construction) (#645).
499
+ const initType = inferCppAutoInitializerType(line, receiverName, ref, context, depth);
500
+ if (initType)
501
+ return initType;
502
+ // No usable initializer on this line — keep scanning earlier ones.
503
+ }
504
+ else if (normalized) {
335
505
  return normalized;
506
+ }
336
507
  }
337
508
  }
338
509
  const headerCandidates = [
@@ -353,12 +524,273 @@ function inferCppReceiverType(receiverName, ref, context) {
353
524
  if (!declaratorMatch)
354
525
  continue;
355
526
  const normalized = normalizeCppTypeName(declaratorMatch[1] ?? '');
356
- if (normalized)
527
+ if (normalized && normalized !== 'auto')
357
528
  return normalized;
358
529
  }
359
530
  }
360
531
  return null;
361
532
  }
533
+ /**
534
+ * Last `::`-separated segment of a (possibly namespace-qualified) C++ name.
535
+ */
536
+ function cppLastSegment(name) {
537
+ const parts = name.split('::').filter(Boolean);
538
+ return parts[parts.length - 1] ?? name;
539
+ }
540
+ /**
541
+ * Return type captured at extraction for `Class::method` (or a free function),
542
+ * read off the indexed node's `returnType` — used by the C++ (#645) and PHP
543
+ * (#608) chained-call resolvers. Language-filtered. Null when not indexed or no
544
+ * return type was recorded (a `void`/primitive return).
545
+ */
546
+ function lookupCalleeReturnType(callee, ref, context) {
547
+ let method = callee;
548
+ let cls = null;
549
+ if (callee.includes('::')) {
550
+ const parts = callee.split('::').filter(Boolean);
551
+ method = parts[parts.length - 1] ?? callee;
552
+ cls = parts.slice(0, -1).join('::');
553
+ }
554
+ const candidates = context.getNodesByName(method).filter((n) => (n.kind === 'method' || n.kind === 'function') &&
555
+ n.language === ref.language &&
556
+ !!n.returnType);
557
+ if (cls) {
558
+ const want = `${cls}::${method}`;
559
+ // The call site may name the class with MORE namespace qualification than
560
+ // the stored node (`details::registry::instance` at the call vs
561
+ // `registry::instance` on the node — the receiver type only carries the
562
+ // immediate class), or LESS. Accept an exact match or either being a
563
+ // namespace-suffix of the other; the shared `::<class>::<method>` tail keeps
564
+ // it specific.
565
+ const m = candidates.find((n) => n.qualifiedName === want ||
566
+ n.qualifiedName.endsWith(`::${want}`) ||
567
+ want.endsWith(`::${n.qualifiedName}`));
568
+ return m?.returnType ?? null;
569
+ }
570
+ return candidates.find((n) => n.kind === 'function')?.returnType ?? null;
571
+ }
572
+ /** Does the graph contain a class/struct named `name`'s last segment? */
573
+ function cppClassExists(name, ref, context) {
574
+ const last = cppLastSegment(name);
575
+ return context
576
+ .getNodesByName(last)
577
+ .some((n) => (n.kind === 'class' || n.kind === 'struct') && n.language === ref.language);
578
+ }
579
+ /**
580
+ * Infer the class produced by a C++ call/construction expression, using return
581
+ * types captured at extraction (#645). Handles, in order:
582
+ * - `make_unique<T>()` / `make_shared<T>()` → T
583
+ * - single-level member call `recv.method()` → recv's type, then method's return
584
+ * - `Class::method()` / free `func()` → the callee's recorded return type
585
+ * - direct construction `Type()` / `ns::Type()` → Type
586
+ * Returns null when undeterminable. Callers MUST still validate the outer method
587
+ * exists on the result before creating an edge, so a wrong guess stays silent.
588
+ */
589
+ function resolveCppCallResultType(inner, ref, context, depth = 0) {
590
+ if (depth > 3)
591
+ return null; // guard against pathological mutual recursion
592
+ const expr = inner.trim();
593
+ const make = expr.match(/(?:^|::)(?:make_unique|make_shared)\s*<\s*([A-Za-z_]\w*)/);
594
+ if (make)
595
+ return make[1] ?? null;
596
+ // Single-level member call `recv.method` (the `manager.view().render()` shape).
597
+ const dotIdx = expr.lastIndexOf('.');
598
+ if (dotIdx > 0) {
599
+ const recv = expr.slice(0, dotIdx);
600
+ const method = expr.slice(dotIdx + 1);
601
+ if (recv.includes('.') || recv.includes('(') || recv.includes('::'))
602
+ return null; // single level only
603
+ const recvType = inferCppReceiverType(recv, ref, context, depth + 1);
604
+ if (!recvType)
605
+ return null;
606
+ return lookupCalleeReturnType(`${recvType}::${method}`, ref, context);
607
+ }
608
+ const ret = lookupCalleeReturnType(expr, ref, context);
609
+ if (ret)
610
+ return ret;
611
+ // Direct construction — the callee itself names a class/struct.
612
+ if (cppClassExists(expr, ref, context))
613
+ return cppLastSegment(expr);
614
+ return null;
615
+ }
616
+ /**
617
+ * Recover the type of an `auto`-declared local from its initializer on the
618
+ * declaration line — `auto x = Foo::instance();`, `auto w = make_unique<W>();`,
619
+ * `auto p = new W();`, `auto w = Widget();` (#645).
620
+ */
621
+ function inferCppAutoInitializerType(line, receiverName, ref, context, depth) {
622
+ const escaped = receiverName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
623
+ const m = line.match(new RegExp(`\\b${escaped}\\b\\s*=\\s*([^;]+)`));
624
+ if (!m || !m[1])
625
+ return null;
626
+ const init = m[1].trim();
627
+ const neu = init.match(/^new\s+([A-Za-z_][\w:]*)/);
628
+ if (neu && neu[1])
629
+ return cppLastSegment(neu[1]);
630
+ // A call or construction: `Foo(...)`, `A::b(...)`, `make_unique<T>(...)`.
631
+ const call = init.match(/^([A-Za-z_][\w:]*(?:\s*<[^>;]*>)?)\s*\(/);
632
+ if (call && call[1])
633
+ return resolveCppCallResultType(call[1].replace(/\s+/g, ''), ref, context, depth + 1);
634
+ return null;
635
+ }
636
+ /**
637
+ * Resolve a C++ chained call whose receiver is itself a call — encoded by the
638
+ * extractor as `<innerCallee>().<method>` (#645). The receiver's type is what
639
+ * the inner call returns; the outer method is then resolved and VALIDATED on it
640
+ * (resolveMethodOnType requires `cls::method` to exist), so a wrong inference
641
+ * produces no edge rather than a wrong one.
642
+ */
643
+ function matchCppCallChain(ref, context) {
644
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
645
+ if (!m || !m[1] || !m[2])
646
+ return null;
647
+ const cls = resolveCppCallResultType(m[1], ref, context);
648
+ if (!cls)
649
+ return null;
650
+ return resolveMethodOnType(cls, m[2], ref, context, 0.85, 'instance-method');
651
+ }
652
+ /**
653
+ * Resolve a `::`-scoped factory chain whose receiver is a scoped/static call —
654
+ * PHP `Cls::for($x)->method()` (#608, the per-credential Laravel client idiom) or
655
+ * Rust `Foo::new().bar()` (an associated-function call) — both encoded by the
656
+ * extractor as `Cls::factory().method`. The receiver's type is what `Cls::factory`
657
+ * returns: a `self` marker (PHP `: self`/`: static`, Rust `-> Self`) resolves to
658
+ * the factory's own type, a concrete return type to that type. The outer method is
659
+ * then resolved and VALIDATED on it (resolveMethodOnType requires the method to
660
+ * exist on the type or a supertype it conforms to), so a wrong inference yields no
661
+ * edge rather than a wrong one. Shared by the `::`-receiver languages (PHP, Rust).
662
+ */
663
+ function matchScopedCallChain(ref, context) {
664
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
665
+ if (!m || !m[1] || !m[2])
666
+ return null;
667
+ const inner = m[1];
668
+ const method = m[2];
669
+ if (!inner.includes('::'))
670
+ return null; // only static-factory (`Cls::method`) chains
671
+ const factoryClass = inner.slice(0, inner.lastIndexOf('::'));
672
+ const ret = lookupCalleeReturnType(inner, ref, context);
673
+ if (!ret)
674
+ return null;
675
+ // `self` (the extractor's marker for self/static/$this) → the factory's class.
676
+ const resolvedClass = ret === 'self' ? factoryClass : ret;
677
+ return resolveMethodOnType(resolvedClass, method, ref, context, 0.85, 'instance-method');
678
+ }
679
+ /**
680
+ * Languages where an unprefixed capitalized call `Foo(args)` constructs the
681
+ * class (so a `Foo(args).method()` receiver's type is `Foo`). Java/C# need `new`,
682
+ * so a bare `Foo()` there is a method call, not construction — excluded. Scala's
683
+ * `Foo(args)` is a case-class / companion `apply`, which conventionally returns
684
+ * `Foo` — and resolveMethodOnType validates, so a non-conventional `apply` that
685
+ * returns another type simply yields no edge rather than a wrong one. Pascal/Delphi:
686
+ * a `TFoo(x)` is a TYPECAST whose result is a `TFoo`, so `TFoo(x).method()` resolves
687
+ * the method on `TFoo` — same shape, same validation.
688
+ */
689
+ const CONSTRUCTS_VIA_BARE_CALL = new Set(['kotlin', 'swift', 'scala', 'dart', 'pascal']);
690
+ /**
691
+ * Resolve a dotted chained call whose receiver is a static factory / fluent call —
692
+ * `Foo.getInstance().bar()`, encoded by the extractor as `Foo.getInstance().bar`
693
+ * (#645/#608 mechanism). The receiver's type is what `Foo.getInstance` returns
694
+ * (its declared return type); the outer method is then resolved and VALIDATED on
695
+ * it (resolveMethodOnType requires `Type::method` to exist), so a wrong inference
696
+ * yields no edge rather than a wrong one (e.g. a same-named `bar()` on an
697
+ * unrelated class is never matched). Shared by the dot-notation languages
698
+ * (Java, Kotlin, C#, Swift) — same receiver shape, same `Class::method` qualified names.
699
+ */
700
+ function matchDottedCallChain(ref, context) {
701
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
702
+ if (!m || !m[1] || !m[2])
703
+ return null;
704
+ const inner = m[1]; // `Foo.getInstance`
705
+ const method = m[2]; // `bar`
706
+ const lastDot = inner.lastIndexOf('.');
707
+ if (lastDot <= 0) {
708
+ // Go: bare package-level factory FUNCTION `New().method()` — the receiver's
709
+ // type is what `New` returns; resolve the method on that.
710
+ if (ref.language === 'go') {
711
+ const ret = lookupCalleeReturnType(inner, ref, context);
712
+ if (ret) {
713
+ return resolveMethodOnType(ret, method, ref, context, 0.85, 'instance-method', importedFqnOf(ret, ref, context));
714
+ }
715
+ // `inner` isn't a function with a captured return type — typically a
716
+ // package-level VARIABLE holding a function value (e.g. gin's `engine()`),
717
+ // whose type we can't recover. Fall back to bare-name resolution of the
718
+ // method so we don't DROP an edge the un-re-encoded bare path would have
719
+ // found. (When `inner` IS a real factory function but the method doesn't
720
+ // exist on its return type, `ret` is truthy and we returned no edge above —
721
+ // the absent-method safety guarantee is preserved.)
722
+ //
723
+ // CRITICAL: resolve the TARGET via a synthetic bare-name ref, but return the
724
+ // match tied to the ORIGINAL `ref` (referenceName `inner().method`). The
725
+ // batched resolver (resolveAndPersistBatched) reads unresolved rows from
726
+ // offset 0 every pass and relies on deleteSpecificResolvedReferences —
727
+ // keyed on referenceName — to clear each resolved row so the batch empties.
728
+ // If we propagated the synthetic ref's bare `method` as `.original`, the
729
+ // delete would never match the stored `inner().method` row, the batch would
730
+ // never drain, and the loop would re-resolve + re-insert forever (a runaway
731
+ // that grew gin's graph to 5M edges / 1.4 GB before this fix).
732
+ const bareRef = { ...ref, referenceName: method };
733
+ const bareMatch = matchByExactName(bareRef, context) ?? matchFuzzy(bareRef, context);
734
+ return bareMatch ? { ...bareMatch, original: ref } : null;
735
+ }
736
+ // Constructor receiver `Foo(args).method()` (encoded `Foo().method`): a bare,
737
+ // capitalized inner is a class construction, so the receiver's type is the
738
+ // class itself — resolve the method on it. Only in languages where an
739
+ // unprefixed capitalized call constructs the class (Kotlin, Swift); in Java/C#
740
+ // a bare `Foo()` is a method call (constructors need `new`), so we must not
741
+ // assume construction. A lowercase bare inner is a top-level `factory().method()`
742
+ // whose type we can't recover — bail.
743
+ if (!CONSTRUCTS_VIA_BARE_CALL.has(ref.language) || !/^[A-Z]/.test(inner))
744
+ return null;
745
+ return resolveMethodOnType(inner, method, ref, context, 0.85, 'instance-method', importedFqnOf(inner, ref, context));
746
+ }
747
+ // Factory/fluent receiver `Receiver.factory(args).method()`: the receiver's
748
+ // type is what `Receiver.factory` returns (its declared return type).
749
+ const factoryClass = inner.slice(0, lastDot).split('.').pop(); // simple class name
750
+ const factoryMethod = inner.slice(lastDot + 1);
751
+ if (!factoryClass || !factoryMethod)
752
+ return null;
753
+ const ret = lookupCalleeReturnType(`${factoryClass}::${factoryMethod}`, ref, context);
754
+ if (!ret) {
755
+ // Objective-C: a class-message factory — `[X alloc]`, `[X new]`,
756
+ // `[X sharedFoo]` — returns an instance of the RECEIVER class `X` by
757
+ // convention (`instancetype`). So when the factory's own return type isn't
758
+ // recoverable (its selector returns `instancetype`, or `alloc`/`new` aren't
759
+ // user-defined nodes at all), the receiver's type is the class `X` itself.
760
+ // This resolves the ubiquitous `[[X alloc] init]` and singleton chains.
761
+ // resolveMethodOnType validates against X (and its supertypes), so a class
762
+ // whose method actually lives elsewhere yields NO edge, not a wrong one — and
763
+ // crucially this does NOT fire when a concrete return type WAS captured but
764
+ // simply lacks the method (that already returned null above: absent-method
765
+ // safety, so a same-named decoy is still never matched).
766
+ if (ref.language === 'objc' && /^[A-Z]/.test(factoryClass)) {
767
+ return resolveMethodOnType(factoryClass, method, ref, context, 0.8, 'instance-method', importedFqnOf(factoryClass, ref, context));
768
+ }
769
+ // Pascal/Delphi: the extractor only re-encodes a `TFoo`/`IFoo`-prefixed chain
770
+ // (the type-naming convention), so `factoryClass` is always a real class here.
771
+ // A factory whose return type wasn't captured is a CONSTRUCTOR
772
+ // (`TFileMem.Create().SetCachePerformance` — `constructor Create` has no `:
773
+ // TBar` annotation but returns its own class) or an unannotated function. In
774
+ // both cases the receiver's type is the class itself, so resolve the method on
775
+ // `factoryClass`. resolveMethodOnType validates against it (and its
776
+ // supertypes), so a wrong inference yields no edge — and this never fires when
777
+ // a return type WAS captured but lacks the method (absent-method safety above).
778
+ if (ref.language === 'pascal' && /^[TI]/.test(factoryClass)) {
779
+ return resolveMethodOnType(factoryClass, method, ref, context, 0.8, 'instance-method', importedFqnOf(factoryClass, ref, context));
780
+ }
781
+ return null;
782
+ }
783
+ return resolveMethodOnType(ret, method, ref, context, 0.85, 'instance-method', importedFqnOf(ret, ref, context));
784
+ }
785
+ /**
786
+ * When several classes share a simple type name, the caller file's import of
787
+ * that type is the only signal that names WHICH one (#314). Returns the imported
788
+ * FQN for `typeName` in the ref's file, or undefined.
789
+ */
790
+ function importedFqnOf(typeName, ref, context) {
791
+ const imports = context.getImportMappings(ref.filePath, ref.language);
792
+ return imports.find((i) => i.localName === typeName)?.source;
793
+ }
362
794
  /**
363
795
  * Java/Kotlin: infer a receiver's declared type by walking field declarations
364
796
  * in the class enclosing the call site. The field's `signature` is already in
@@ -563,15 +995,21 @@ function splitCamelCase(str) {
563
995
  .filter(w => w.length > 1);
564
996
  }
565
997
  /**
566
- * Compute directory proximity between two file paths.
567
- * Returns a score based on the number of shared directory segments.
998
+ * Compute directory proximity from a pre-split list of directory segments
999
+ * (`filePath1` minus its filename) and a second file path.
1000
+ * Returns a score based on the number of shared leading directory segments.
568
1001
  * Higher score = closer in directory tree.
1002
+ *
1003
+ * Split into a pre-split variant because findBestMatch scores every candidate
1004
+ * against the SAME `ref.filePath`; re-splitting it per candidate was a hot spot
1005
+ * on large repos (#915), so the caller splits it once and passes the segments.
569
1006
  */
570
- function computePathProximity(filePath1, filePath2) {
571
- const dir1 = filePath1.split('/').slice(0, -1);
572
- const dir2 = filePath2.split('/').slice(0, -1);
1007
+ function pathProximityFromDirs(dir1, filePath2) {
1008
+ const dir2 = filePath2.split('/');
1009
+ dir2.pop(); // drop filename — matches the original slice(0, -1) on both paths
573
1010
  let shared = 0;
574
- for (let i = 0; i < Math.min(dir1.length, dir2.length); i++) {
1011
+ const limit = Math.min(dir1.length, dir2.length);
1012
+ for (let i = 0; i < limit; i++) {
575
1013
  if (dir1[i] === dir2[i]) {
576
1014
  shared++;
577
1015
  }
@@ -582,6 +1020,15 @@ function computePathProximity(filePath1, filePath2) {
582
1020
  // Each shared directory segment contributes 15 points, capped at 80
583
1021
  return Math.min(shared * 15, 80);
584
1022
  }
1023
+ /**
1024
+ * Compute directory proximity between two file paths.
1025
+ * Returns a score based on the number of shared directory segments.
1026
+ */
1027
+ function computePathProximity(filePath1, filePath2) {
1028
+ const dir1 = filePath1.split('/');
1029
+ dir1.pop();
1030
+ return pathProximityFromDirs(dir1, filePath2);
1031
+ }
585
1032
  /**
586
1033
  * Find the best matching node when there are multiple candidates
587
1034
  */
@@ -594,14 +1041,29 @@ function findBestMatch(ref, candidates, _context) {
594
1041
  // 5. Exported > non-exported
595
1042
  let bestScore = -1;
596
1043
  let bestNode = null;
1044
+ // Split the ref's path once (it's the same across every candidate) instead of
1045
+ // re-splitting it inside computePathProximity per candidate (#915 hot spot).
1046
+ const refDirs = ref.filePath.split('/');
1047
+ refDirs.pop();
1048
+ // A same-language candidate ALWAYS outscores a cross-language one: same-language
1049
+ // scores at least +50 (language bonus), while a cross-language candidate maxes
1050
+ // out at +35 (−80 language, +80 proximity, +25 kind, +10 exported; it can never
1051
+ // be in the same file). So when any same-language candidate exists, skip the
1052
+ // cross-language ones — provably the same winner, without paying the per-candidate
1053
+ // scoring. Cuts the candidate set to same-language size on mixed front-end +
1054
+ // back-end repos (#915). When ALL candidates are cross-language (a legitimate
1055
+ // cross-language `calls` bridge), none are skipped and behavior is unchanged.
1056
+ const hasSameLanguage = candidates.some((c) => c.language === ref.language);
597
1057
  for (const candidate of candidates) {
1058
+ if (hasSameLanguage && candidate.language !== ref.language)
1059
+ continue;
598
1060
  let score = 0;
599
1061
  // Same file bonus
600
1062
  if (candidate.filePath === ref.filePath) {
601
1063
  score += 100;
602
1064
  }
603
1065
  // Directory proximity bonus — strongly prefer same module/package
604
- score += computePathProximity(ref.filePath, candidate.filePath);
1066
+ score += pathProximityFromDirs(refDirs, candidate.filePath);
605
1067
  // Language matching: strongly prefer same language, penalize cross-language
606
1068
  if (candidate.language === ref.language) {
607
1069
  score += 50;
@@ -680,6 +1142,12 @@ function matchFuzzy(ref, context) {
680
1142
  * Match all strategies in order of confidence
681
1143
  */
682
1144
  function matchReference(ref, context) {
1145
+ // Function-as-value refs (#756) resolve ONLY through the dedicated matcher —
1146
+ // never the fuzzy/qualified fallthrough below (a wrong callback edge is
1147
+ // worse than none).
1148
+ if (ref.referenceKind === 'function_ref') {
1149
+ return matchFunctionRef(ref, context);
1150
+ }
683
1151
  // Try strategies in order of confidence
684
1152
  let result;
685
1153
  // 0. File path match (e.g., "snippets/drawer-menu.liquid" → file node)
@@ -690,6 +1158,43 @@ function matchReference(ref, context) {
690
1158
  result = matchByQualifiedName(ref, context);
691
1159
  if (result)
692
1160
  return result;
1161
+ // 1b. C++ chained call whose receiver is another call — `Foo::instance().bar()`
1162
+ // encoded as `Foo::instance().bar` by the extractor (#645). Resolve the
1163
+ // receiver's type from what the inner call returns, then the method on it.
1164
+ if (ref.language === 'cpp' || ref.language === 'c') {
1165
+ result = matchCppCallChain(ref, context);
1166
+ if (result)
1167
+ return result;
1168
+ }
1169
+ // 1c. `::`-scoped factory chain — PHP `Cls::for($x)->method()` (#608) or Rust
1170
+ // `Foo::new().bar()`, both encoded as `Cls::factory().method`. The receiver's
1171
+ // type is the factory's `self` (PHP `: self`/`: static`, Rust `-> Self`) or
1172
+ // concrete return type.
1173
+ if (ref.language === 'php' || ref.language === 'rust') {
1174
+ result = matchScopedCallChain(ref, context);
1175
+ if (result)
1176
+ return result;
1177
+ }
1178
+ // 1d. Dotted chained static-factory / fluent call (Java / Kotlin / C# / Swift /
1179
+ // Go / Scala / Dart / Objective-C) — `Foo.getInstance().bar()` encoded as
1180
+ // `Foo.getInstance().bar`, Go's bare-factory `New().Method()` as `New().Method`,
1181
+ // Scala's companion factory, Dart's static factory / factory-constructor, or
1182
+ // ObjC's chained message send `[[Foo create] doIt]` encoded as `Foo.create().doIt`
1183
+ // (#645/#608 mechanism). Resolve the method's class from the inner call's
1184
+ // declared return type, then validate it.
1185
+ if (ref.language === 'java' ||
1186
+ ref.language === 'kotlin' ||
1187
+ ref.language === 'csharp' ||
1188
+ ref.language === 'swift' ||
1189
+ ref.language === 'go' ||
1190
+ ref.language === 'scala' ||
1191
+ ref.language === 'dart' ||
1192
+ ref.language === 'objc' ||
1193
+ ref.language === 'pascal') {
1194
+ result = matchDottedCallChain(ref, context);
1195
+ if (result)
1196
+ return result;
1197
+ }
693
1198
  // 2. Method call pattern
694
1199
  result = matchMethodCall(ref, context);
695
1200
  if (result)