@saluzi/codegraph 0.1.0 → 0.2.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 (712) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +885 -0
  3. package/dist/bin/codegraph.d.ts +2 -1
  4. package/dist/bin/codegraph.d.ts.map +1 -0
  5. package/dist/bin/codegraph.js +2248 -0
  6. package/dist/bin/codegraph.js.map +1 -0
  7. package/dist/bin/command-supervision.d.ts +49 -0
  8. package/dist/bin/command-supervision.d.ts.map +1 -0
  9. package/dist/bin/command-supervision.js +95 -0
  10. package/dist/bin/command-supervision.js.map +1 -0
  11. package/dist/bin/fatal-handler.d.ts +20 -0
  12. package/dist/bin/fatal-handler.d.ts.map +1 -0
  13. package/dist/bin/fatal-handler.js +118 -0
  14. package/dist/bin/fatal-handler.js.map +1 -0
  15. package/dist/bin/node-version-check.d.ts.map +1 -0
  16. package/dist/bin/node-version-check.js +79 -0
  17. package/dist/bin/node-version-check.js.map +1 -0
  18. package/dist/bin/uninstall.d.ts.map +1 -0
  19. package/dist/bin/uninstall.js +36 -0
  20. package/dist/bin/uninstall.js.map +1 -0
  21. package/dist/context/formatter.d.ts +6 -9
  22. package/dist/context/formatter.d.ts.map +1 -0
  23. package/dist/context/formatter.js +25 -6
  24. package/dist/context/formatter.js.map +1 -0
  25. package/dist/context/index.d.ts +102 -100
  26. package/dist/context/index.d.ts.map +1 -0
  27. package/dist/context/index.js +252 -6
  28. package/dist/context/index.js.map +1 -0
  29. package/dist/context/markers.d.ts +19 -0
  30. package/dist/context/markers.d.ts.map +1 -0
  31. package/dist/context/markers.js +22 -0
  32. package/dist/context/markers.js.map +1 -0
  33. package/dist/db/index.d.ts +185 -85
  34. package/dist/db/index.d.ts.map +1 -0
  35. package/dist/db/index.js +257 -14
  36. package/dist/db/index.js.map +1 -0
  37. package/dist/db/migrations.d.ts +15 -18
  38. package/dist/db/migrations.d.ts.map +1 -0
  39. package/dist/db/migrations.js +82 -1
  40. package/dist/db/migrations.js.map +1 -0
  41. package/dist/db/queries.d.ts +503 -281
  42. package/dist/db/queries.d.ts.map +1 -0
  43. package/dist/db/queries.js +644 -107
  44. package/dist/db/queries.js.map +1 -0
  45. package/dist/db/schema.sql +69 -26
  46. package/dist/db/sqlite-adapter.d.ts +26 -22
  47. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  48. package/dist/db/sqlite-adapter.js +11 -35
  49. package/dist/db/sqlite-adapter.js.map +1 -0
  50. package/dist/db/wal-valve.d.ts +106 -0
  51. package/dist/db/wal-valve.d.ts.map +1 -0
  52. package/dist/db/wal-valve.js +208 -0
  53. package/dist/db/wal-valve.js.map +1 -0
  54. package/dist/directory.d.ts +140 -19
  55. package/dist/directory.d.ts.map +1 -0
  56. package/dist/directory.js +568 -35
  57. package/dist/directory.js.map +1 -0
  58. package/dist/errors.d.ts +32 -45
  59. package/dist/errors.d.ts.map +1 -0
  60. package/dist/errors.js.map +1 -0
  61. package/dist/extraction/astro-extractor.d.ts +79 -0
  62. package/dist/extraction/astro-extractor.d.ts.map +1 -0
  63. package/dist/extraction/astro-extractor.js +320 -0
  64. package/dist/extraction/astro-extractor.js.map +1 -0
  65. package/dist/extraction/cfml-extractor.d.ts +107 -0
  66. package/dist/extraction/cfml-extractor.d.ts.map +1 -0
  67. package/dist/extraction/cfml-extractor.js +494 -0
  68. package/dist/extraction/cfml-extractor.js.map +1 -0
  69. package/dist/extraction/dfm-extractor.d.ts +17 -17
  70. package/dist/extraction/dfm-extractor.d.ts.map +1 -0
  71. package/dist/extraction/dfm-extractor.js.map +1 -0
  72. package/dist/extraction/extraction-version.d.ts +25 -0
  73. package/dist/extraction/extraction-version.d.ts.map +1 -0
  74. package/dist/extraction/extraction-version.js +28 -0
  75. package/dist/extraction/extraction-version.js.map +1 -0
  76. package/dist/extraction/function-ref.d.ts +118 -0
  77. package/dist/extraction/function-ref.d.ts.map +1 -0
  78. package/dist/extraction/function-ref.js +727 -0
  79. package/dist/extraction/function-ref.js.map +1 -0
  80. package/dist/extraction/generated-detection.d.ts +30 -0
  81. package/dist/extraction/generated-detection.d.ts.map +1 -0
  82. package/dist/extraction/generated-detection.js +83 -0
  83. package/dist/extraction/generated-detection.js.map +1 -0
  84. package/dist/extraction/grammars.d.ts +74 -30
  85. package/dist/extraction/grammars.d.ts.map +1 -0
  86. package/dist/extraction/grammars.js +289 -15
  87. package/dist/extraction/grammars.js.map +1 -0
  88. package/dist/extraction/index.d.ts +193 -109
  89. package/dist/extraction/index.d.ts.map +1 -0
  90. package/dist/extraction/index.js +1485 -362
  91. package/dist/extraction/index.js.map +1 -0
  92. package/dist/extraction/languages/arkts.d.ts +3 -0
  93. package/dist/extraction/languages/arkts.d.ts.map +1 -0
  94. package/dist/extraction/languages/arkts.js +127 -0
  95. package/dist/extraction/languages/arkts.js.map +1 -0
  96. package/dist/extraction/languages/c-cpp.d.ts +110 -4
  97. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  98. package/dist/extraction/languages/c-cpp.js +713 -2
  99. package/dist/extraction/languages/c-cpp.js.map +1 -0
  100. package/dist/extraction/languages/cfquery.d.ts +12 -0
  101. package/dist/extraction/languages/cfquery.d.ts.map +1 -0
  102. package/dist/extraction/languages/cfquery.js +28 -0
  103. package/dist/extraction/languages/cfquery.js.map +1 -0
  104. package/dist/extraction/languages/cfscript.d.ts +3 -0
  105. package/dist/extraction/languages/cfscript.d.ts.map +1 -0
  106. package/dist/extraction/languages/cfscript.js +73 -0
  107. package/dist/extraction/languages/cfscript.js.map +1 -0
  108. package/dist/extraction/languages/cobol.d.ts +33 -0
  109. package/dist/extraction/languages/cobol.d.ts.map +1 -0
  110. package/dist/extraction/languages/cobol.js +499 -0
  111. package/dist/extraction/languages/cobol.js.map +1 -0
  112. package/dist/extraction/languages/csharp.d.ts +25 -3
  113. package/dist/extraction/languages/csharp.d.ts.map +1 -0
  114. package/dist/extraction/languages/csharp.js +106 -3
  115. package/dist/extraction/languages/csharp.js.map +1 -0
  116. package/dist/extraction/languages/dart.d.ts +3 -3
  117. package/dist/extraction/languages/dart.d.ts.map +1 -0
  118. package/dist/extraction/languages/dart.js +183 -1
  119. package/dist/extraction/languages/dart.js.map +1 -0
  120. package/dist/extraction/languages/erlang.d.ts +3 -0
  121. package/dist/extraction/languages/erlang.d.ts.map +1 -0
  122. package/dist/extraction/languages/erlang.js +350 -0
  123. package/dist/extraction/languages/erlang.js.map +1 -0
  124. package/dist/extraction/languages/go.d.ts +3 -3
  125. package/dist/extraction/languages/go.d.ts.map +1 -0
  126. package/dist/extraction/languages/go.js +55 -2
  127. package/dist/extraction/languages/go.js.map +1 -0
  128. package/dist/extraction/languages/index.d.ts +4 -4
  129. package/dist/extraction/languages/index.d.ts.map +1 -0
  130. package/dist/extraction/languages/index.js +22 -0
  131. package/dist/extraction/languages/index.js.map +1 -0
  132. package/dist/extraction/languages/java.d.ts +3 -3
  133. package/dist/extraction/languages/java.d.ts.map +1 -0
  134. package/dist/extraction/languages/java.js +252 -1
  135. package/dist/extraction/languages/java.js.map +1 -0
  136. package/dist/extraction/languages/javascript.d.ts +3 -3
  137. package/dist/extraction/languages/javascript.d.ts.map +1 -0
  138. package/dist/extraction/languages/javascript.js +16 -0
  139. package/dist/extraction/languages/javascript.js.map +1 -0
  140. package/dist/extraction/languages/kotlin.d.ts +3 -3
  141. package/dist/extraction/languages/kotlin.d.ts.map +1 -0
  142. package/dist/extraction/languages/kotlin.js +126 -0
  143. package/dist/extraction/languages/kotlin.js.map +1 -0
  144. package/dist/extraction/languages/lua.d.ts +3 -3
  145. package/dist/extraction/languages/lua.d.ts.map +1 -0
  146. package/dist/extraction/languages/lua.js.map +1 -0
  147. package/dist/extraction/languages/luau.d.ts +3 -3
  148. package/dist/extraction/languages/luau.d.ts.map +1 -0
  149. package/dist/extraction/languages/luau.js.map +1 -0
  150. package/dist/extraction/languages/nix.d.ts +3 -0
  151. package/dist/extraction/languages/nix.d.ts.map +1 -0
  152. package/dist/extraction/languages/nix.js +294 -0
  153. package/dist/extraction/languages/nix.js.map +1 -0
  154. package/dist/extraction/languages/objc.d.ts +3 -0
  155. package/dist/extraction/languages/objc.d.ts.map +1 -0
  156. package/dist/extraction/languages/objc.js +175 -0
  157. package/dist/extraction/languages/objc.js.map +1 -0
  158. package/dist/extraction/languages/pascal.d.ts +3 -3
  159. package/dist/extraction/languages/pascal.d.ts.map +1 -0
  160. package/dist/extraction/languages/pascal.js +11 -0
  161. package/dist/extraction/languages/pascal.js.map +1 -0
  162. package/dist/extraction/languages/php.d.ts +3 -3
  163. package/dist/extraction/languages/php.d.ts.map +1 -0
  164. package/dist/extraction/languages/php.js +90 -1
  165. package/dist/extraction/languages/php.js.map +1 -0
  166. package/dist/extraction/languages/python.d.ts +3 -3
  167. package/dist/extraction/languages/python.d.ts.map +1 -0
  168. package/dist/extraction/languages/python.js.map +1 -0
  169. package/dist/extraction/languages/r.d.ts +3 -0
  170. package/dist/extraction/languages/r.d.ts.map +1 -0
  171. package/dist/extraction/languages/r.js +314 -0
  172. package/dist/extraction/languages/r.js.map +1 -0
  173. package/dist/extraction/languages/ruby.d.ts +3 -3
  174. package/dist/extraction/languages/ruby.d.ts.map +1 -0
  175. package/dist/extraction/languages/ruby.js +35 -0
  176. package/dist/extraction/languages/ruby.js.map +1 -0
  177. package/dist/extraction/languages/rust.d.ts +3 -3
  178. package/dist/extraction/languages/rust.d.ts.map +1 -0
  179. package/dist/extraction/languages/rust.js +35 -2
  180. package/dist/extraction/languages/rust.js.map +1 -0
  181. package/dist/extraction/languages/scala.d.ts +3 -3
  182. package/dist/extraction/languages/scala.d.ts.map +1 -0
  183. package/dist/extraction/languages/scala.js +80 -10
  184. package/dist/extraction/languages/scala.js.map +1 -0
  185. package/dist/extraction/languages/solidity.d.ts +3 -0
  186. package/dist/extraction/languages/solidity.d.ts.map +1 -0
  187. package/dist/extraction/languages/solidity.js +293 -0
  188. package/dist/extraction/languages/solidity.js.map +1 -0
  189. package/dist/extraction/languages/swift.d.ts +3 -3
  190. package/dist/extraction/languages/swift.d.ts.map +1 -0
  191. package/dist/extraction/languages/swift.js +61 -0
  192. package/dist/extraction/languages/swift.js.map +1 -0
  193. package/dist/extraction/languages/terraform.d.ts +3 -0
  194. package/dist/extraction/languages/terraform.d.ts.map +1 -0
  195. package/dist/extraction/languages/terraform.js +641 -0
  196. package/dist/extraction/languages/terraform.js.map +1 -0
  197. package/dist/extraction/languages/typescript.d.ts +16 -3
  198. package/dist/extraction/languages/typescript.d.ts.map +1 -0
  199. package/dist/extraction/languages/typescript.js +38 -0
  200. package/dist/extraction/languages/typescript.js.map +1 -0
  201. package/dist/extraction/languages/vbnet.d.ts +11 -0
  202. package/dist/extraction/languages/vbnet.d.ts.map +1 -0
  203. package/dist/extraction/languages/vbnet.js +141 -0
  204. package/dist/extraction/languages/vbnet.js.map +1 -0
  205. package/dist/extraction/liquid-extractor.d.ts +48 -41
  206. package/dist/extraction/liquid-extractor.d.ts.map +1 -0
  207. package/dist/extraction/liquid-extractor.js +53 -9
  208. package/dist/extraction/liquid-extractor.js.map +1 -0
  209. package/dist/extraction/mybatis-extractor.d.ts +68 -0
  210. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  211. package/dist/extraction/mybatis-extractor.js +300 -0
  212. package/dist/extraction/mybatis-extractor.js.map +1 -0
  213. package/dist/extraction/parse-pool.d.ts +152 -0
  214. package/dist/extraction/parse-pool.d.ts.map +1 -0
  215. package/dist/extraction/parse-pool.js +387 -0
  216. package/dist/extraction/parse-pool.js.map +1 -0
  217. package/dist/extraction/parse-worker.d.ts +2 -2
  218. package/dist/extraction/parse-worker.d.ts.map +1 -0
  219. package/dist/extraction/parse-worker.js +13 -3
  220. package/dist/extraction/parse-worker.js.map +1 -0
  221. package/dist/extraction/razor-extractor.d.ts +42 -0
  222. package/dist/extraction/razor-extractor.d.ts.map +1 -0
  223. package/dist/extraction/razor-extractor.js +285 -0
  224. package/dist/extraction/razor-extractor.js.map +1 -0
  225. package/dist/extraction/svelte-extractor.d.ts +42 -42
  226. package/dist/extraction/svelte-extractor.d.ts.map +1 -0
  227. package/dist/extraction/svelte-extractor.js +6 -3
  228. package/dist/extraction/svelte-extractor.js.map +1 -0
  229. package/dist/extraction/tree-sitter-helpers.d.ts +7 -18
  230. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  231. package/dist/extraction/tree-sitter-helpers.js +60 -10
  232. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  233. package/dist/extraction/tree-sitter-types.d.ts +224 -157
  234. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  235. package/dist/extraction/tree-sitter-types.js.map +1 -0
  236. package/dist/extraction/tree-sitter.d.ts +689 -221
  237. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  238. package/dist/extraction/tree-sitter.js +4193 -117
  239. package/dist/extraction/tree-sitter.js.map +1 -0
  240. package/dist/extraction/vue-extractor.d.ts +40 -25
  241. package/dist/extraction/vue-extractor.d.ts.map +1 -0
  242. package/dist/extraction/vue-extractor.js +94 -3
  243. package/dist/extraction/vue-extractor.js.map +1 -0
  244. package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  245. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  246. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  247. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  248. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  249. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  250. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  251. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  252. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  253. package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  254. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  255. package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  256. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  257. package/dist/extraction/wasm-runtime-flags.d.ts +6 -14
  258. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  259. package/dist/extraction/wasm-runtime-flags.js +1 -0
  260. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  261. package/dist/graph/index.d.ts +3 -3
  262. package/dist/graph/index.d.ts.map +1 -0
  263. package/dist/graph/index.js.map +1 -0
  264. package/dist/graph/queries.d.ts +96 -99
  265. package/dist/graph/queries.d.ts.map +1 -0
  266. package/dist/graph/queries.js +13 -40
  267. package/dist/graph/queries.js.map +1 -0
  268. package/dist/graph/traversal.d.ts +117 -127
  269. package/dist/graph/traversal.d.ts.map +1 -0
  270. package/dist/graph/traversal.js +92 -21
  271. package/dist/graph/traversal.js.map +1 -0
  272. package/dist/index.d.ts +615 -481
  273. package/dist/index.d.ts.map +1 -0
  274. package/dist/index.js +709 -18
  275. package/dist/index.js.map +1 -0
  276. package/dist/installer/config-writer.d.ts +13 -14
  277. package/dist/installer/config-writer.d.ts.map +1 -0
  278. package/dist/installer/config-writer.js +91 -0
  279. package/dist/installer/config-writer.js.map +1 -0
  280. package/dist/installer/index.d.ts +84 -82
  281. package/dist/installer/index.d.ts.map +1 -0
  282. package/dist/installer/index.js +619 -0
  283. package/dist/installer/index.js.map +1 -0
  284. package/dist/installer/instructions-template.d.ts +35 -24
  285. package/dist/installer/instructions-template.d.ts.map +1 -0
  286. package/dist/installer/instructions-template.js +53 -0
  287. package/dist/installer/instructions-template.js.map +1 -0
  288. package/dist/installer/targets/antigravity.d.ts +57 -0
  289. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  290. package/dist/installer/targets/antigravity.js +308 -0
  291. package/dist/installer/targets/antigravity.js.map +1 -0
  292. package/dist/installer/targets/claude.d.ts +34 -27
  293. package/dist/installer/targets/claude.d.ts.map +1 -0
  294. package/dist/installer/targets/claude.js +454 -0
  295. package/dist/installer/targets/claude.js.map +1 -0
  296. package/dist/installer/targets/codex.d.ts +3 -3
  297. package/dist/installer/targets/codex.d.ts.map +1 -0
  298. package/dist/installer/targets/codex.js +185 -0
  299. package/dist/installer/targets/codex.js.map +1 -0
  300. package/dist/installer/targets/cursor.d.ts +3 -3
  301. package/dist/installer/targets/cursor.d.ts.map +1 -0
  302. package/dist/installer/targets/cursor.js +254 -0
  303. package/dist/installer/targets/cursor.js.map +1 -0
  304. package/dist/installer/targets/gemini.d.ts +26 -0
  305. package/dist/installer/targets/gemini.d.ts.map +1 -0
  306. package/dist/installer/targets/gemini.js +165 -0
  307. package/dist/installer/targets/gemini.js.map +1 -0
  308. package/dist/installer/targets/hermes.d.ts +3 -3
  309. package/dist/installer/targets/hermes.d.ts.map +1 -0
  310. package/dist/installer/targets/hermes.js +359 -0
  311. package/dist/installer/targets/hermes.js.map +1 -0
  312. package/dist/installer/targets/kiro.d.ts +27 -0
  313. package/dist/installer/targets/kiro.d.ts.map +1 -0
  314. package/dist/installer/targets/kiro.js +178 -0
  315. package/dist/installer/targets/kiro.js.map +1 -0
  316. package/dist/installer/targets/opencode.d.ts +12 -4
  317. package/dist/installer/targets/opencode.d.ts.map +1 -0
  318. package/dist/installer/targets/opencode.js +288 -0
  319. package/dist/installer/targets/opencode.js.map +1 -0
  320. package/dist/installer/targets/registry.d.ts +9 -12
  321. package/dist/installer/targets/registry.d.ts.map +1 -0
  322. package/dist/installer/targets/registry.js +91 -0
  323. package/dist/installer/targets/registry.js.map +1 -0
  324. package/dist/installer/targets/shared.d.ts +38 -29
  325. package/dist/installer/targets/shared.d.ts.map +1 -0
  326. package/dist/installer/targets/shared.js +264 -0
  327. package/dist/installer/targets/shared.js.map +1 -0
  328. package/dist/installer/targets/toml.d.ts +11 -23
  329. package/dist/installer/targets/toml.d.ts.map +1 -0
  330. package/dist/installer/targets/toml.js +147 -0
  331. package/dist/installer/targets/toml.js.map +1 -0
  332. package/dist/installer/targets/types.d.ts +62 -76
  333. package/dist/installer/targets/types.d.ts.map +1 -0
  334. package/dist/installer/targets/types.js +16 -0
  335. package/dist/installer/targets/types.js.map +1 -0
  336. package/dist/mcp/daemon-manager.d.ts +42 -0
  337. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  338. package/dist/mcp/daemon-manager.js +129 -0
  339. package/dist/mcp/daemon-manager.js.map +1 -0
  340. package/dist/mcp/daemon-paths.d.ts +73 -0
  341. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  342. package/dist/mcp/daemon-paths.js +165 -0
  343. package/dist/mcp/daemon-paths.js.map +1 -0
  344. package/dist/mcp/daemon-registry.d.ts +47 -0
  345. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  346. package/dist/mcp/daemon-registry.js +233 -0
  347. package/dist/mcp/daemon-registry.js.map +1 -0
  348. package/dist/mcp/daemon.d.ts +290 -0
  349. package/dist/mcp/daemon.d.ts.map +1 -0
  350. package/dist/mcp/daemon.js +862 -0
  351. package/dist/mcp/daemon.js.map +1 -0
  352. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  353. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  354. package/dist/mcp/dynamic-boundaries.js +360 -0
  355. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  356. package/dist/mcp/early-ppid.d.ts +26 -0
  357. package/dist/mcp/early-ppid.d.ts.map +1 -0
  358. package/dist/mcp/early-ppid.js +29 -0
  359. package/dist/mcp/early-ppid.js.map +1 -0
  360. package/dist/mcp/engine.d.ts +122 -0
  361. package/dist/mcp/engine.d.ts.map +1 -0
  362. package/dist/mcp/engine.js +350 -0
  363. package/dist/mcp/engine.js.map +1 -0
  364. package/dist/mcp/index.d.ts +89 -74
  365. package/dist/mcp/index.d.ts.map +1 -0
  366. package/dist/mcp/index.js +506 -0
  367. package/dist/mcp/index.js.map +1 -0
  368. package/dist/mcp/liveness-watchdog.d.ts +35 -0
  369. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  370. package/dist/mcp/liveness-watchdog.js +267 -0
  371. package/dist/mcp/liveness-watchdog.js.map +1 -0
  372. package/dist/mcp/ppid-watchdog.d.ts +62 -0
  373. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  374. package/dist/mcp/ppid-watchdog.js +64 -0
  375. package/dist/mcp/ppid-watchdog.js.map +1 -0
  376. package/dist/mcp/proxy.d.ts +87 -0
  377. package/dist/mcp/proxy.d.ts.map +1 -0
  378. package/dist/mcp/proxy.js +667 -0
  379. package/dist/mcp/proxy.js.map +1 -0
  380. package/dist/mcp/query-pool.d.ts +108 -0
  381. package/dist/mcp/query-pool.d.ts.map +1 -0
  382. package/dist/mcp/query-pool.js +315 -0
  383. package/dist/mcp/query-pool.js.map +1 -0
  384. package/dist/mcp/query-worker.d.ts +24 -0
  385. package/dist/mcp/query-worker.d.ts.map +1 -0
  386. package/dist/mcp/query-worker.js +87 -0
  387. package/dist/mcp/query-worker.js.map +1 -0
  388. package/dist/mcp/server-instructions.d.ts +22 -8
  389. package/dist/mcp/server-instructions.d.ts.map +1 -0
  390. package/dist/mcp/server-instructions.js +106 -0
  391. package/dist/mcp/server-instructions.js.map +1 -0
  392. package/dist/mcp/session.d.ts +93 -0
  393. package/dist/mcp/session.d.ts.map +1 -0
  394. package/dist/mcp/session.js +357 -0
  395. package/dist/mcp/session.js.map +1 -0
  396. package/dist/mcp/startup-handshake.d.ts +44 -0
  397. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  398. package/dist/mcp/startup-handshake.js +73 -0
  399. package/dist/mcp/startup-handshake.js.map +1 -0
  400. package/dist/mcp/stdin-teardown.d.ts +27 -0
  401. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  402. package/dist/mcp/stdin-teardown.js +49 -0
  403. package/dist/mcp/stdin-teardown.js.map +1 -0
  404. package/dist/mcp/tools.d.ts +557 -213
  405. package/dist/mcp/tools.d.ts.map +1 -0
  406. package/dist/mcp/tools.js +4477 -0
  407. package/dist/mcp/tools.js.map +1 -0
  408. package/dist/mcp/transport.d.ts +158 -87
  409. package/dist/mcp/transport.d.ts.map +1 -0
  410. package/dist/mcp/transport.js +377 -0
  411. package/dist/mcp/transport.js.map +1 -0
  412. package/dist/mcp/version.d.ts +19 -0
  413. package/dist/mcp/version.d.ts.map +1 -0
  414. package/dist/mcp/version.js +71 -0
  415. package/dist/mcp/version.js.map +1 -0
  416. package/dist/project-config.d.ts +94 -0
  417. package/dist/project-config.d.ts.map +1 -0
  418. package/dist/project-config.js +374 -0
  419. package/dist/project-config.js.map +1 -0
  420. package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  421. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  422. package/dist/resolution/c-fnptr-synthesizer.js +1062 -0
  423. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  424. package/dist/resolution/callback-synthesizer.d.ts +15 -0
  425. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  426. package/dist/resolution/callback-synthesizer.js +3938 -0
  427. package/dist/resolution/callback-synthesizer.js.map +1 -0
  428. package/dist/resolution/cooperative-yield.d.ts +32 -0
  429. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  430. package/dist/resolution/cooperative-yield.js +42 -0
  431. package/dist/resolution/cooperative-yield.js.map +1 -0
  432. package/dist/resolution/frameworks/astro.d.ts +9 -0
  433. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  434. package/dist/resolution/frameworks/astro.js +169 -0
  435. package/dist/resolution/frameworks/astro.js.map +1 -0
  436. package/dist/resolution/frameworks/cargo-workspace.d.ts +3 -5
  437. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  438. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  439. package/dist/resolution/frameworks/cics.d.ts +20 -0
  440. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  441. package/dist/resolution/frameworks/cics.js +90 -0
  442. package/dist/resolution/frameworks/cics.js.map +1 -0
  443. package/dist/resolution/frameworks/csharp.d.ts +3 -3
  444. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  445. package/dist/resolution/frameworks/csharp.js +36 -8
  446. package/dist/resolution/frameworks/csharp.js.map +1 -0
  447. package/dist/resolution/frameworks/drupal.d.ts +3 -3
  448. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  449. package/dist/resolution/frameworks/drupal.js +44 -12
  450. package/dist/resolution/frameworks/drupal.js.map +1 -0
  451. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  452. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  453. package/dist/resolution/frameworks/expo-modules.js +148 -0
  454. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  455. package/dist/resolution/frameworks/express.d.ts +3 -3
  456. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  457. package/dist/resolution/frameworks/express.js +102 -19
  458. package/dist/resolution/frameworks/express.js.map +1 -0
  459. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  460. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  461. package/dist/resolution/frameworks/fabric.js +354 -0
  462. package/dist/resolution/frameworks/fabric.js.map +1 -0
  463. package/dist/resolution/frameworks/go.d.ts +3 -3
  464. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  465. package/dist/resolution/frameworks/go.js +6 -3
  466. package/dist/resolution/frameworks/go.js.map +1 -0
  467. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  468. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  469. package/dist/resolution/frameworks/goframe.js +112 -0
  470. package/dist/resolution/frameworks/goframe.js.map +1 -0
  471. package/dist/resolution/frameworks/index.d.ts +29 -31
  472. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  473. package/dist/resolution/frameworks/index.js +39 -1
  474. package/dist/resolution/frameworks/index.js.map +1 -0
  475. package/dist/resolution/frameworks/java.d.ts +3 -3
  476. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  477. package/dist/resolution/frameworks/java.js +352 -12
  478. package/dist/resolution/frameworks/java.js.map +1 -0
  479. package/dist/resolution/frameworks/laravel.d.ts +4 -4
  480. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  481. package/dist/resolution/frameworks/laravel.js +17 -8
  482. package/dist/resolution/frameworks/laravel.js.map +1 -0
  483. package/dist/resolution/frameworks/nestjs.d.ts +3 -3
  484. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  485. package/dist/resolution/frameworks/nestjs.js +324 -0
  486. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  487. package/dist/resolution/frameworks/play.d.ts +19 -0
  488. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  489. package/dist/resolution/frameworks/play.js +111 -0
  490. package/dist/resolution/frameworks/play.js.map +1 -0
  491. package/dist/resolution/frameworks/python.d.ts +5 -5
  492. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  493. package/dist/resolution/frameworks/python.js +138 -16
  494. package/dist/resolution/frameworks/python.js.map +1 -0
  495. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  496. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  497. package/dist/resolution/frameworks/react-native.js +410 -0
  498. package/dist/resolution/frameworks/react-native.js.map +1 -0
  499. package/dist/resolution/frameworks/react.d.ts +3 -3
  500. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  501. package/dist/resolution/frameworks/react.js +122 -60
  502. package/dist/resolution/frameworks/react.js.map +1 -0
  503. package/dist/resolution/frameworks/ruby.d.ts +3 -3
  504. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  505. package/dist/resolution/frameworks/ruby.js +106 -2
  506. package/dist/resolution/frameworks/ruby.js.map +1 -0
  507. package/dist/resolution/frameworks/rust.d.ts +3 -3
  508. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  509. package/dist/resolution/frameworks/rust.js +102 -5
  510. package/dist/resolution/frameworks/rust.js.map +1 -0
  511. package/dist/resolution/frameworks/svelte.d.ts +3 -3
  512. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  513. package/dist/resolution/frameworks/svelte.js +5 -1
  514. package/dist/resolution/frameworks/svelte.js.map +1 -0
  515. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  516. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  517. package/dist/resolution/frameworks/swift-objc.js +252 -0
  518. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  519. package/dist/resolution/frameworks/swift.d.ts +5 -5
  520. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  521. package/dist/resolution/frameworks/swift.js +30 -6
  522. package/dist/resolution/frameworks/swift.js.map +1 -0
  523. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  524. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  525. package/dist/resolution/frameworks/terraform.js +277 -0
  526. package/dist/resolution/frameworks/terraform.js.map +1 -0
  527. package/dist/resolution/frameworks/vue.d.ts +3 -3
  528. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  529. package/dist/resolution/frameworks/vue.js +24 -27
  530. package/dist/resolution/frameworks/vue.js.map +1 -0
  531. package/dist/resolution/go-module.d.ts +26 -0
  532. package/dist/resolution/go-module.d.ts.map +1 -0
  533. package/dist/resolution/go-module.js +78 -0
  534. package/dist/resolution/go-module.js.map +1 -0
  535. package/dist/resolution/goframe-synthesizer.d.ts +29 -0
  536. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  537. package/dist/resolution/goframe-synthesizer.js +163 -0
  538. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  539. package/dist/resolution/import-resolver.d.ts +53 -29
  540. package/dist/resolution/import-resolver.d.ts.map +1 -0
  541. package/dist/resolution/import-resolver.js +1319 -8
  542. package/dist/resolution/import-resolver.js.map +1 -0
  543. package/dist/resolution/index.d.ts +243 -103
  544. package/dist/resolution/index.d.ts.map +1 -0
  545. package/dist/resolution/index.js +1055 -53
  546. package/dist/resolution/index.js.map +1 -0
  547. package/dist/resolution/lru-cache.d.ts +9 -9
  548. package/dist/resolution/lru-cache.d.ts.map +1 -0
  549. package/dist/resolution/lru-cache.js.map +1 -0
  550. package/dist/resolution/name-matcher.d.ts +91 -29
  551. package/dist/resolution/name-matcher.d.ts.map +1 -0
  552. package/dist/resolution/name-matcher.js +1478 -32
  553. package/dist/resolution/name-matcher.js.map +1 -0
  554. package/dist/resolution/path-aliases.d.ts +23 -27
  555. package/dist/resolution/path-aliases.d.ts.map +1 -0
  556. package/dist/resolution/path-aliases.js.map +1 -0
  557. package/dist/resolution/strip-comments.d.ts +3 -16
  558. package/dist/resolution/strip-comments.d.ts.map +1 -0
  559. package/dist/resolution/strip-comments.js +51 -0
  560. package/dist/resolution/strip-comments.js.map +1 -0
  561. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  562. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  563. package/dist/resolution/swift-objc-bridge.js +256 -0
  564. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  565. package/dist/resolution/types.d.ts +217 -136
  566. package/dist/resolution/types.d.ts.map +1 -0
  567. package/dist/resolution/types.js.map +1 -0
  568. package/dist/resolution/workspace-packages.d.ts +58 -0
  569. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  570. package/dist/resolution/workspace-packages.js +346 -0
  571. package/dist/resolution/workspace-packages.js.map +1 -0
  572. package/dist/search/identifier-segments.d.ts +60 -0
  573. package/dist/search/identifier-segments.d.ts.map +1 -0
  574. package/dist/search/identifier-segments.js +176 -0
  575. package/dist/search/identifier-segments.js.map +1 -0
  576. package/dist/search/query-parser.d.ts +14 -18
  577. package/dist/search/query-parser.d.ts.map +1 -0
  578. package/dist/search/query-parser.js.map +1 -0
  579. package/dist/search/query-utils.d.ts +45 -17
  580. package/dist/search/query-utils.d.ts.map +1 -0
  581. package/dist/search/query-utils.js +113 -47
  582. package/dist/search/query-utils.js.map +1 -0
  583. package/dist/sync/git-hooks.d.ts +13 -22
  584. package/dist/sync/git-hooks.d.ts.map +1 -0
  585. package/dist/sync/git-hooks.js +4 -0
  586. package/dist/sync/git-hooks.js.map +1 -0
  587. package/dist/sync/index.d.ts +6 -12
  588. package/dist/sync/index.d.ts.map +1 -0
  589. package/dist/sync/index.js +8 -1
  590. package/dist/sync/index.js.map +1 -0
  591. package/dist/sync/watch-policy.d.ts +8 -11
  592. package/dist/sync/watch-policy.d.ts.map +1 -0
  593. package/dist/sync/watch-policy.js.map +1 -0
  594. package/dist/sync/watcher.d.ts +335 -63
  595. package/dist/sync/watcher.d.ts.map +1 -0
  596. package/dist/sync/watcher.js +709 -53
  597. package/dist/sync/watcher.js.map +1 -0
  598. package/dist/sync/worktree.d.ts +63 -0
  599. package/dist/sync/worktree.d.ts.map +1 -0
  600. package/dist/sync/worktree.js +182 -0
  601. package/dist/sync/worktree.js.map +1 -0
  602. package/dist/telemetry/index.d.ts +143 -0
  603. package/dist/telemetry/index.d.ts.map +1 -0
  604. package/dist/telemetry/index.js +541 -0
  605. package/dist/telemetry/index.js.map +1 -0
  606. package/dist/types.d.ts +308 -326
  607. package/dist/types.d.ts.map +1 -0
  608. package/dist/types.js +16 -0
  609. package/dist/types.js.map +1 -0
  610. package/dist/ui/glyphs.d.ts +20 -20
  611. package/dist/ui/glyphs.d.ts.map +1 -0
  612. package/dist/ui/glyphs.js +78 -0
  613. package/dist/ui/glyphs.js.map +1 -0
  614. package/dist/ui/shimmer-progress.d.ts +7 -7
  615. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  616. package/dist/ui/shimmer-progress.js +90 -0
  617. package/dist/ui/shimmer-progress.js.map +1 -0
  618. package/dist/ui/shimmer-worker.d.ts +2 -2
  619. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  620. package/dist/ui/shimmer-worker.js +118 -0
  621. package/dist/ui/shimmer-worker.js.map +1 -0
  622. package/dist/ui/types.d.ts +14 -17
  623. package/dist/ui/types.d.ts.map +1 -0
  624. package/dist/ui/types.js +3 -0
  625. package/dist/ui/types.js.map +1 -0
  626. package/dist/upgrade/index.d.ts +164 -0
  627. package/dist/upgrade/index.d.ts.map +1 -0
  628. package/dist/upgrade/index.js +646 -0
  629. package/dist/upgrade/index.js.map +1 -0
  630. package/dist/upgrade/remove-binary.d.ts +87 -0
  631. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  632. package/dist/upgrade/remove-binary.js +289 -0
  633. package/dist/upgrade/remove-binary.js.map +1 -0
  634. package/dist/upgrade/update-check.d.ts +92 -0
  635. package/dist/upgrade/update-check.d.ts.map +1 -0
  636. package/dist/upgrade/update-check.js +258 -0
  637. package/dist/upgrade/update-check.js.map +1 -0
  638. package/dist/utils.d.ts +116 -123
  639. package/dist/utils.d.ts.map +1 -0
  640. package/dist/utils.js +83 -49
  641. package/dist/utils.js.map +1 -0
  642. package/package.json +42 -10
  643. package/scripts/add-lang/bench.sh +60 -0
  644. package/scripts/add-lang/check-grammar.mjs +75 -0
  645. package/scripts/add-lang/dump-ast.mjs +103 -0
  646. package/scripts/add-lang/verify-extraction.mjs +70 -0
  647. package/scripts/agent-eval/ab-adoption.sh +91 -0
  648. package/scripts/agent-eval/ab-hook.sh +86 -0
  649. package/scripts/agent-eval/ab-impl.sh +78 -0
  650. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
  651. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  652. package/scripts/agent-eval/arms-F.sh +21 -0
  653. package/scripts/agent-eval/arms-matrix.sh +37 -0
  654. package/scripts/agent-eval/audit.sh +68 -0
  655. package/scripts/agent-eval/bench-readme.sh +28 -0
  656. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  657. package/scripts/agent-eval/block-read-hook.sh +19 -0
  658. package/scripts/agent-eval/hook-settings.json +15 -0
  659. package/scripts/agent-eval/itrun.sh +120 -0
  660. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  661. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  662. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  663. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  664. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  665. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  666. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  667. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  668. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  669. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  670. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  671. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  672. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  673. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  674. package/scripts/agent-eval/offload-eval.md +76 -0
  675. package/scripts/agent-eval/parse-arms.mjs +116 -0
  676. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  677. package/scripts/agent-eval/parse-run.mjs +45 -0
  678. package/scripts/agent-eval/parse-session.mjs +93 -0
  679. package/scripts/agent-eval/probe-context.mjs +21 -0
  680. package/scripts/agent-eval/probe-explore.mjs +40 -0
  681. package/scripts/agent-eval/probe-node.mjs +20 -0
  682. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  683. package/scripts/agent-eval/probe-trace.mjs +20 -0
  684. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  685. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  686. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  687. package/scripts/agent-eval/run-agent.sh +34 -0
  688. package/scripts/agent-eval/run-all.sh +75 -0
  689. package/scripts/agent-eval/run-arms.sh +56 -0
  690. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  691. package/scripts/build-bundle.sh +123 -0
  692. package/scripts/extract-release-notes.mjs +130 -0
  693. package/scripts/local-install.sh +41 -0
  694. package/scripts/npm-sdk.js +75 -0
  695. package/scripts/npm-shim.js +275 -0
  696. package/scripts/pack-npm.sh +119 -0
  697. package/scripts/prepare-release.mjs +270 -0
  698. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  699. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  700. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  701. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  702. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  703. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  704. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  705. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  706. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  707. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  708. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  709. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  710. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  711. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  712. package/dist/installer/claude-md-template.d.ts +0 -19
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env bash
2
+ # Drive an INTERACTIVE Claude Code session in tmux, send a prompt, wait for the
3
+ # agent to finish, then print the tool-call breakdown from the session logs.
4
+ #
5
+ # Why interactive (not `claude -p`): headless print-mode picks the
6
+ # general-purpose subagent, while real interactive sessions delegate to the
7
+ # Explore subagent (or drive codegraph from the main thread). Only the
8
+ # interactive TUI reproduces the behavior users actually see. (Idle-detection
9
+ # technique borrowed from devpit's WaitForIdle.)
10
+ #
11
+ # Usage: itrun.sh <repo-path> <label> "<prompt>"
12
+ # Output dir: $AGENT_EVAL_OUT (default /tmp/agent-eval)
13
+ # Requires: tmux 3.0+, a logged-in `claude` CLI, codegraph MCP configured.
14
+ set -uo pipefail
15
+ REPO="$1"; LABEL="$2"; PROMPT="$3"
16
+ SESSION="cgt_${LABEL}"
17
+ OUT_DIR="${AGENT_EVAL_OUT:-/tmp/agent-eval}"; mkdir -p "$OUT_DIR"
18
+ OUT="$OUT_DIR/itrun-${LABEL}.txt"
19
+ HERE="$(cd "$(dirname "$0")" && pwd)"
20
+
21
+ cap() { tmux capture-pane -p -t "$SESSION" -S -40; }
22
+
23
+ tmux kill-session -t "$SESSION" 2>/dev/null
24
+
25
+ # Wide pane so the TUI doesn't hard-wrap tool lines.
26
+ tmux new-session -d -s "$SESSION" -x 230 -y 60
27
+ tmux send-keys -t "$SESSION" "cd $REPO && claude --dangerously-skip-permissions ${CLAUDE_EXTRA_ARGS:-}" Enter
28
+
29
+ # Wait for the ❯ prompt (claude drew its UI), up to 60s. NOTE: ❯ appears on the
30
+ # welcome screen seconds before the input actually accepts keystrokes, so this is
31
+ # necessary but NOT sufficient — the type-and-verify loop below is what proves
32
+ # the input is live.
33
+ ready=0
34
+ for _ in $(seq 1 120); do
35
+ cap | grep -q "❯" && { ready=1; break; }
36
+ sleep 0.5
37
+ done
38
+ [ "$ready" = 1 ] || { echo "claude never drew its UI"; cap; tmux kill-session -t "$SESSION" 2>/dev/null; exit 1; }
39
+
40
+ # Accept the per-folder "Is this a project you trust?" dialog if it shows (first
41
+ # time claude opens a given repo). Option 1 ("Yes, I trust this folder") is
42
+ # pre-selected, so Enter accepts. This dialog also contains ❯, so it must be
43
+ # cleared before the type-and-verify loop or keystrokes land on the menu.
44
+ for _ in $(seq 1 20); do
45
+ cap | grep -q "trust this folder" || break
46
+ tmux send-keys -t "$SESSION" Enter
47
+ sleep 1
48
+ done
49
+
50
+ # Type-and-verify: send the prompt, confirm a distinctive chunk of it actually
51
+ # landed in the input box, retry if it didn't (handles the early-❯ race where
52
+ # the welcome screen shows the prompt glyph but MCP init is still eating keys).
53
+ needle="${PROMPT:0:24}"
54
+ typed=0
55
+ for _ in $(seq 1 30); do
56
+ tmux send-keys -l -t "$SESSION" "$PROMPT"
57
+ sleep 1
58
+ if cap | grep -Fq "$needle"; then typed=1; break; fi
59
+ # Clear whatever partial text may have landed, then retry.
60
+ tmux send-keys -t "$SESSION" C-u
61
+ sleep 1
62
+ done
63
+ [ "$typed" = 1 ] || { echo "prompt never landed in the input box"; cap; tmux kill-session -t "$SESSION" 2>/dev/null; exit 1; }
64
+ sleep 0.5
65
+ tmux send-keys -t "$SESSION" Enter
66
+
67
+ # Busy signals. The robust one is the spinner's elapsed-time-in-parens, which
68
+ # EVERY working state shows — both the pre-stream thinking phase
69
+ # "(8s · thinking with max effort)" and the streaming phase
70
+ # "(24s · ↑ 2.5k tokens · …)", and it survives the 32s→"1m 3s" rollover. We OR
71
+ # in the token arrows, "esc to interrupt", and "Initializing" as belt-and-braces
72
+ # (some TUI versions/states show one but not the others).
73
+ BUSY_RE='esc to interrupt|↓ [0-9]|↑ [0-9]|Initializing|\(([0-9]+m )?[0-9]+s ·'
74
+
75
+ # Wait for work to START (busy indicator appears), up to 60s. If it never starts,
76
+ # fail loudly rather than silently reporting an empty run.
77
+ started=0
78
+ for _ in $(seq 1 120); do
79
+ cap | grep -qE "$BUSY_RE" && { started=1; break; }
80
+ sleep 0.5
81
+ done
82
+ [ "$started" = 1 ] || { echo "agent never started working"; cap; tmux kill-session -t "$SESSION" 2>/dev/null; exit 1; }
83
+
84
+ # Poll for idle. CRITICAL: Opus 4.8 (extended thinking) renders NO spinner /
85
+ # "esc to interrupt" / timer while it STREAMS its final answer — those appear
86
+ # only during the thinking + tool-use phases ("✻ Marinating… (32s · ↓ 1.3k
87
+ # tokens · thinking with max effort)"). So BUSY_RE reads "not busy" for the whole
88
+ # 10-30s answer stream, and any short not-busy threshold kills the run mid-answer
89
+ # (the truncation bug). We therefore detect "done" by CONTENT STABILITY, not by a
90
+ # spinner string: while the agent streams, the captured pane changes every poll,
91
+ # so stability never accrues; it accrues only once the agent has finished and the
92
+ # static "✻ Brewed for 1m 9s" summary is all that is left. BUSY_RE still hard-
93
+ # resets stability (covers thinking/tool-use/live-timer, where text can briefly
94
+ # sit still). Need STABLE_NEEDED polls (~8s) of zero pane change + ❯ present.
95
+ # Content-stability is model-agnostic — it survives future spinner re-wordings.
96
+ STABLE_NEEDED=16
97
+ prev=""; stable=0
98
+ for _ in $(seq 1 2400); do # up to ~20 min
99
+ pane="$(cap)"
100
+ sig="$(printf '%s' "$pane" | tr -s '[:space:]' ' ')"
101
+ if printf '%s' "$pane" | grep -qE "$BUSY_RE"; then
102
+ stable=0 # thinking / tool use / live timer → busy
103
+ elif [ -n "$sig" ] && [ "$sig" = "$prev" ] && printf '%s' "$pane" | grep -q "❯"; then
104
+ stable=$((stable+1)); [ "$stable" -ge "$STABLE_NEEDED" ] && break
105
+ else
106
+ stable=0 # answer still streaming → pane changing
107
+ fi
108
+ prev="$sig"
109
+ sleep 0.5
110
+ done
111
+ sleep 1
112
+
113
+ tmux capture-pane -p -t "$SESSION" -S - > "$OUT"
114
+ echo "captured $(wc -l < "$OUT") lines -> $OUT"
115
+ grep -oE "Done \([^)]*\)|[A-Z][a-z]+ for ([0-9]+m )?[0-9]+s" "$OUT" | tail -1
116
+ grep -oE "[0-9.]+k?/[0-9.]+M" "$OUT" | tail -1 | sed 's/^/Context /'
117
+ tmux kill-session -t "$SESSION" 2>/dev/null
118
+
119
+ # Clean tool breakdown from the session logs (main + subagents).
120
+ node "$HERE/parse-session.mjs" "$REPO" 2>/dev/null || true
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bash
2
+ # 3-arm offload eval for ONE indexed repo + ONE question, n reps each.
3
+ # ARM offload : codegraph attached, managed offload ON (per-run AI usage log)
4
+ # ARM raw : codegraph attached, CODEGRAPH_OFFLOAD_DISABLE=1 (raw source)
5
+ # ARM nocg : no codegraph (empty MCP config) -> Read/Grep baseline
6
+ # All arms: claude -p sonnet --effort high. One JSON metrics line/run -> $RESULTS.
7
+ #
8
+ # Usage: offload-eval-3arm.sh <indexed-repo> <tier> <reps> "<question>"
9
+ # Env: MODEL=sonnet EFFORT=high RESULTS=<file> AGENT_EVAL_OUT=<scratch dir>
10
+ set -uo pipefail
11
+ HERE="$(cd "$(dirname "$0")" && pwd)"
12
+ ENGINE="$(cd "$HERE/../.." && pwd)"
13
+ BIN="$ENGINE/dist/bin/codegraph.js"
14
+ OUT="${AGENT_EVAL_OUT:-/tmp/cg-offload-eval}"
15
+ TARGET="${1:?usage: offload-eval-3arm.sh <indexed-repo> <tier> <reps> \"<question>\"}"
16
+ TIER="${2:?tier}"; REPS="${3:?reps}"; Q="${4:?question}"
17
+ RUNS="$OUT/runs"
18
+ EXTRACT="$HERE/offload-eval-metrics.mjs"
19
+ RESULTS="${RESULTS:-$OUT/results.jsonl}"
20
+ REPO=$(basename "$TARGET")
21
+ mkdir -p "$RUNS"
22
+ command -v claude >/dev/null || { echo "no claude on PATH"; exit 1; }
23
+ [ -d "$TARGET/.codegraph" ] || { echo "not indexed: $TARGET (run offload-eval-setup.sh first)"; exit 1; }
24
+ # Physical path so pkill matches the daemon's real cmdline (macOS /tmp->/private/tmp symlink
25
+ # otherwise makes the kill miss the daemon, and the next arm connects to the SURVIVING daemon
26
+ # — contaminating the raw arm with offload).
27
+ TARGET=$(cd "$TARGET" && pwd -P)
28
+
29
+ prewarm() { # path extra-env (e.g. "FOO=bar")
30
+ pkill -9 -f "serve --mcp --path $1" 2>/dev/null; rm -f "$1/.codegraph/daemon.sock" 2>/dev/null; sleep 0.6
31
+ env ${2:-} CODEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
32
+ node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.codegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" \
33
+ && echo " daemon warm" || echo " WARN daemon never bound"
34
+ }
35
+
36
+ run() { # arm rep mcp-config usage-log-or-dash
37
+ local arm="$1" rep="$2" cfg="$3" usage="$4" tag="$REPO-$1-$2"
38
+ [ "$usage" != "-" ] && : > "$usage"
39
+ # DISALLOW (optional): block sub-agent delegation across all arms so the A/B
40
+ # measures the retrieval mode, not whether Sonnet decides to spawn a codegraph-blind
41
+ # Explore subagent (which thrashes regardless and adds huge variance).
42
+ ( cd "$TARGET" && claude -p "$Q" \
43
+ --output-format stream-json --verbose --permission-mode bypassPermissions \
44
+ --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
45
+ ${DISALLOW:+--disallowedTools "$DISALLOW"} \
46
+ --strict-mcp-config --mcp-config "$cfg" \
47
+ </dev/null > "$RUNS/$tag.jsonl" 2>"$RUNS/$tag.err" )
48
+ node "$EXTRACT" --run "$RUNS/$tag.jsonl" --usage "$usage" --arm "$arm" --rep "$rep" \
49
+ --repo "$REPO" --tier "$TIER" --q "$Q" >> "$RESULTS"
50
+ node -e 'const o=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8").trim().split("\n").pop());console.log(` [${o.arm} #${o.rep}] ${o.durationSec}s | main $${o.costUsdMain} ${o.tokBillable} tok | read=${o.read} grep=${o.grep} explore=${o.explore} offload=${o.offloadFired} | AI ${o.ai.calls}call/${o.ai.totalTokens}tok/$${o.ai.costUsd.toFixed(4)} | ok=${o.ok}`)' "$RESULTS"
51
+ }
52
+
53
+ CFG_OFF="$RUNS/mcp-offload-$REPO.json"; CFG_RAW="$RUNS/mcp-raw-$REPO.json"; CFG_NOCG="$RUNS/mcp-nocg.json"
54
+ USAGE="$RUNS/$REPO-usage.jsonl"
55
+ printf '{"mcpServers":{"codegraph":{"command":"env","args":["CODEGRAPH_WASM_RELAUNCHED=1","CODEGRAPH_OFFLOAD_USAGE_LOG=%s","node","%s","serve","--mcp","--path","%s"]}}}' "$USAGE" "$BIN" "$TARGET" > "$CFG_OFF"
56
+ printf '{"mcpServers":{"codegraph":{"command":"env","args":["CODEGRAPH_WASM_RELAUNCHED=1","CODEGRAPH_OFFLOAD_DISABLE=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$TARGET" > "$CFG_RAW"
57
+ printf '{"mcpServers":{}}' > "$CFG_NOCG"
58
+
59
+ # REP_START lets a later batch ADD reps without clobbering earlier jsonls
60
+ # (e.g. REP_START=4 REPS=3 -> reps 4,5,6; default starts at 1).
61
+ START="${REP_START:-1}"; END=$((START + REPS - 1))
62
+ echo "###### repo=$REPO tier=$TIER reps=$START..$END model=${MODEL:-sonnet}/${EFFORT:-high}"
63
+ echo "###### Q=$Q"
64
+ echo "== ARM offload =="; prewarm "$TARGET" "CODEGRAPH_OFFLOAD_USAGE_LOG=$USAGE"
65
+ for r in $(seq "$START" "$END"); do run offload "$r" "$CFG_OFF" "$USAGE"; done
66
+ pkill -9 -f "serve --mcp --path $TARGET" 2>/dev/null; rm -f "$TARGET/.codegraph/daemon.sock" 2>/dev/null; sleep 1
67
+ echo "== ARM raw =="; prewarm "$TARGET" "CODEGRAPH_OFFLOAD_DISABLE=1"
68
+ for r in $(seq "$START" "$END"); do run raw "$r" "$CFG_RAW" "-"; done
69
+ pkill -9 -f "serve --mcp --path $TARGET" 2>/dev/null; rm -f "$TARGET/.codegraph/daemon.sock" 2>/dev/null; sleep 1
70
+ echo "== ARM nocg =="
71
+ for r in $(seq "$START" "$END"); do run nocg "$r" "$CFG_NOCG" "-"; done
72
+ echo "###### DONE $REPO"
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ // Cost/token analysis for the 3-arm offload eval, with a MAIN-vs-SUBAGENT split.
3
+ //
4
+ // The explore-subagent question. With delegation ALLOWED, the nocg arm spawns a
5
+ // Claude Code Explore subagent; the codegraph arms do all work in the main agent.
6
+ // Two facts make naive accounting wrong:
7
+ // 1. The Explore subagent runs on HAIKU 4.5; the main agent on SONNET 4.6.
8
+ // So per-token cost differs ~3x between them — you cannot price both the same.
9
+ // 2. The subagent's consumption is ~95% cache-reads. At Haiku's $0.10/MTok
10
+ // cache-read rate, a huge TOKEN volume is a small DOLLAR cost.
11
+ //
12
+ // Rather than re-derive cost from raw token counts (and guess the cache TTL —
13
+ // Claude Code uses 1-hour ephemeral cache here, 2x write, not 5-min), we read
14
+ // Claude Code's OWN authoritative accounting from the `result` event:
15
+ // result.modelUsage[model].costUSD — per-model cost CC itself billed
16
+ // result.total_cost_usd — their sum (INCLUDES the Haiku subagent;
17
+ // the handoff's "excludes subagent" was wrong)
18
+ // The model split IS the agent split here: sonnet => main, haiku => Explore subagent
19
+ // (only nocg spawns one, and only nocg shows haiku usage). Token volume is still
20
+ // summed per-model from modelUsage for the separate "tokens" story.
21
+ //
22
+ // Usage: offload-eval-cost.mjs <runs-dir> <repo> [reps]
23
+ // e.g. offload-eval-cost.mjs /tmp/cg-offload-eval/runs trezor 3
24
+ import { readFileSync, existsSync } from 'fs';
25
+
26
+ const MAIN_TIER = /sonnet/; // main agent
27
+ const SUB_TIER = /haiku/; // Claude Code Explore subagent
28
+
29
+ const [,, runsDir, repo, repsArg] = process.argv;
30
+ if (!runsDir || !repo) { console.error('usage: offload-eval-cost.mjs <runs-dir> <repo> [reps] (env ARMS=nocg,raw,offload)'); process.exit(1); }
31
+ const REPS = Number(repsArg || 3);
32
+ // Arms to analyze (file stems `<repo>-<arm>-<rep>.jsonl`). Override for the style A/B:
33
+ // ARMS=raw,refs,map,src. nocg's Haiku subagent is the only sub-tier; the rest are main-only.
34
+ const ARMS = (process.env.ARMS || 'nocg,raw,offload').split(',').map((s) => s.trim()).filter(Boolean);
35
+
36
+ const toks = (u) => (u.inputTokens||0)+(u.outputTokens||0)+(u.cacheReadInputTokens||0)+(u.cacheCreationInputTokens||0);
37
+
38
+ function analyzeRun(file) {
39
+ let result = null, agentCalls = 0;
40
+ const tools = {}, subPids = new Set();
41
+ for (const line of readFileSync(file, 'utf8').split('\n')) {
42
+ if (!line) continue;
43
+ let e; try { e = JSON.parse(line); } catch { continue; }
44
+ if (e.parent_tool_use_id && e.message?.usage) subPids.add(e.parent_tool_use_id);
45
+ if (e.type === 'assistant' && Array.isArray(e.message?.content))
46
+ for (const b of e.message.content)
47
+ if (b.type === 'tool_use') { tools[b.name] = (tools[b.name]||0)+1; if (b.name === 'Agent') agentCalls++; }
48
+ if (e.type === 'result') result = e;
49
+ }
50
+ // Authoritative cost + tokens from Claude Code's per-model accounting.
51
+ const mu = result?.modelUsage || {};
52
+ const main = { cost: 0, tok: 0 }, sub = { cost: 0, tok: 0 };
53
+ for (const [model, u] of Object.entries(mu)) {
54
+ const bucket = SUB_TIER.test(model) ? sub : main; // sonnet/anything-else => main
55
+ bucket.cost += u.costUSD || 0;
56
+ bucket.tok += toks(u);
57
+ }
58
+ return {
59
+ main, sub, subagents: subPids.size, agentCalls,
60
+ ccTotal: result?.total_cost_usd ?? null,
61
+ ok: result?.subtype === 'success',
62
+ durationSec: result?.duration_ms ? +(result.duration_ms/1000).toFixed(1) : null,
63
+ models: Object.keys(mu), tools,
64
+ };
65
+ }
66
+
67
+ const k = (n) => (n/1000).toFixed(0).padStart(5) + 'K';
68
+ const d = (n) => '$' + n.toFixed(3);
69
+ const cost = (b) => b.cost;
70
+ const tot = (b) => b.tok;
71
+
72
+ const byArm = {};
73
+ for (const arm of ARMS) {
74
+ const runs = [];
75
+ for (let r = 1; r <= REPS; r++) {
76
+ const f = `${runsDir}/${repo}-${arm}-${r}.jsonl`;
77
+ if (existsSync(f)) runs.push({ rep: r, ...analyzeRun(f) });
78
+ }
79
+ byArm[arm] = runs;
80
+ }
81
+
82
+ // Per-run detail. Cost is Claude Code's own modelUsage.costUSD (authoritative,
83
+ // per-model pricing + correct cache TTL). MAIN=Sonnet, SUB=Haiku Explore subagent.
84
+ // cc-check: main$+sub$ must equal result.total_cost_usd (delta should be ~0).
85
+ console.log(`\n=== ${repo}: per-run main(Sonnet)/sub(Haiku) split — Claude Code's own cost accounting ===`);
86
+ console.log('arm rep | subAg | MAIN(sonnet) tok / $ | SUB(haiku) tok / $ | TOTAL tok / $ | cc_total Δ | dur reads');
87
+ for (const arm of ARMS) for (const r of byArm[arm]) {
88
+ const mC = cost(r.main), sC = cost(r.sub), mT = tot(r.main), sT = tot(r.sub);
89
+ const reads = r.tools['Read'] || 0, grep = (r.tools['Grep']||0)+(r.tools['Bash']||0)+(r.tools['Glob']||0);
90
+ const explore = r.tools['mcp__codegraph__codegraph_explore'] || 0;
91
+ const delta = (mC + sC) - (r.ccTotal || 0); // should be ~0
92
+ console.log(
93
+ `${arm.padEnd(8)} #${r.rep} | ${String(r.subagents).padStart(2)} | ${k(mT)} ${d(mC).padStart(7)} | ${k(sT)} ${d(sC).padStart(7)} | ${k(mT+sT)} ${d(mC+sC).padStart(7)} | ${d(r.ccTotal||0).padStart(7)} ${(delta>=0?'+':'')+delta.toFixed(4)} | ${String(r.durationSec).padStart(5)} r=${reads} g=${grep} x=${explore}`
94
+ );
95
+ }
96
+
97
+ // Per-arm means
98
+ const mean = (arr, f) => arr.length ? arr.reduce((s,x)=>s+f(x),0)/arr.length : 0;
99
+ console.log(`\n=== ${repo}: per-arm MEANS (n per arm) ===`);
100
+ console.log('arm n | main $ sub $ TOTAL $ | main tok sub tok TOTAL tok | %$ in sub | %tok in sub');
101
+ for (const arm of ARMS) {
102
+ const runs = byArm[arm]; if (!runs.length) continue;
103
+ const mC = mean(runs, r=>cost(r.main)), sC = mean(runs, r=>cost(r.sub));
104
+ const mT = mean(runs, r=>tot(r.main)), sT = mean(runs, r=>tot(r.sub));
105
+ const pctSubC = (mC+sC) ? (100*sC/(mC+sC)) : 0;
106
+ const pctSubT = (mT+sT) ? (100*sT/(mT+sT)) : 0;
107
+ console.log(
108
+ `${arm.padEnd(8)} ${runs.length} | ${d(mC).padStart(7)} ${d(sC).padStart(7)} ${d(mC+sC).padStart(7)} | ${k(mT)} ${k(sT)} ${k(mT+sT)} | ${pctSubC.toFixed(0).padStart(3)}% | ${pctSubT.toFixed(0).padStart(3)}%`
109
+ );
110
+ }
111
+
112
+ // Headline ladders — cost, tokens, duration, all vs a baseline (nocg if present, else first arm).
113
+ console.log(`\n=== Ladders (mean, incl. subagent) ===`);
114
+ const totals = ARMS.map(a => ({ a, c: mean(byArm[a], r=>cost(r.main)+cost(r.sub)), t: mean(byArm[a], r=>tot(r.main)+tot(r.sub)) })).filter(x=>byArm[x.a].length);
115
+ const base = totals.find(x=>x.a==='nocg') ?? totals[0];
116
+ const bn = base?.a ?? '?';
117
+ console.log(` COST (vs ${bn}):`);
118
+ for (const x of totals) {
119
+ const vs = base && base.c ? ` (${((x.c/base.c-1)*100>=0?'+':'')}${((x.c/base.c-1)*100).toFixed(0)}%)` : '';
120
+ console.log(` ${x.a.padEnd(8)} ${d(x.c)}${vs}`);
121
+ }
122
+ console.log(` TOKENS (vs ${bn}):`);
123
+ for (const x of totals) {
124
+ const vs = base && base.t ? ` (${((x.t/base.t-1)*100>=0?'+':'')}${((x.t/base.t-1)*100).toFixed(0)}%)` : '';
125
+ console.log(` ${x.a.padEnd(8)} ${k(x.t)}${vs}`);
126
+ }
127
+ console.log(` DURATION (wall-clock, vs ${bn}):`);
128
+ const durs = ARMS.map(a => ({ a, s: mean(byArm[a].filter(r=>r.durationSec!=null), r=>r.durationSec) })).filter(x=>byArm[x.a].length);
129
+ const dbase = durs.find(x=>x.a==='nocg') ?? durs[0];
130
+ for (const x of durs) {
131
+ const vs = dbase && dbase.s ? ` (${((x.s/dbase.s-1)*100>=0?'+':'')}${((x.s/dbase.s-1)*100).toFixed(0)}%)` : '';
132
+ console.log(` ${x.a.padEnd(8)} ${x.s.toFixed(0)}s${vs}`);
133
+ }
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ // Effort A/B — does CODEGRAPH_OFFLOAD_EFFORT=high improve offload SYNTHESIS FIDELITY vs low?
3
+ // Probe-based (no agent): for each repo × effort × rep, run codegraph_explore with the offload
4
+ // ON on the canonical question, capture the synthesized answer + AI tokens/cost/latency, then
5
+ // Sonnet-judge that answer's fidelity vs source-verified ground truth. Isolates the synthesis
6
+ // from agent/adoption noise. Requires `codegraph login` (managed offload) + indexed repos.
7
+ //
8
+ // Env: REPS (default 3) · CG_ENGINE (engine repo) · AGENT_EVAL_OUT (repos under /repos) · CONC (judge concurrency)
9
+ import { pathToFileURL, fileURLToPath } from 'node:url';
10
+ import { resolve, dirname, join } from 'node:path';
11
+ import { readFileSync, writeFileSync, existsSync, rmSync } from 'node:fs';
12
+ import { execFile } from 'node:child_process';
13
+ import { tmpdir } from 'node:os';
14
+
15
+ const HERE = dirname(fileURLToPath(import.meta.url));
16
+ const ENGINE = process.env.CG_ENGINE || resolve(HERE, '..', '..');
17
+ const OUT = process.env.AGENT_EVAL_OUT || '/tmp/cg-offload-eval';
18
+ const REPOS = join(OUT, 'repos');
19
+ const GT = JSON.parse(readFileSync(resolve(HERE, 'offload-eval-ground-truth.json'), 'utf8'));
20
+ const REPS = Number(process.env.REPS || 3);
21
+ const CONC = Number(process.env.CONC || 4);
22
+ const EFFORTS = (process.env.EFFORTS_FILTER || 'low,high').split(',');
23
+ const ONLY = process.env.REPOS_FILTER ? new Set(process.env.REPOS_FILTER.split(',')) : null;
24
+ const TIER = { mtkruto: 'small', postybirb: 'medium', shapeshift: 'complex', trezor: 'large' };
25
+
26
+ const load = async (rel) => import(pathToFileURL(resolve(ENGINE, rel)).href);
27
+ const idx = await load('dist/index.js');
28
+ const toolsMod = await load('dist/mcp/tools.js');
29
+ const CodeGraph = idx.default?.default ?? idx.default ?? idx.CodeGraph;
30
+ const ToolHandler = toolsMod.ToolHandler ?? toolsMod.default?.ToolHandler;
31
+ if (typeof CodeGraph?.openSync !== 'function' || typeof ToolHandler !== 'function') {
32
+ console.error('could not load engine from', ENGINE); process.exit(2);
33
+ }
34
+
35
+ const fidPrompt = (gt, ans) => `You are scoring the FIDELITY of a machine-synthesized code-exploration answer against verified ground truth. Do NOT use any tools.
36
+
37
+ QUESTION: ${gt.question}
38
+
39
+ VERIFIED GROUND TRUTH (the actual call path + files):
40
+ ${gt.truth}
41
+
42
+ SYNTHESIZED ANSWER (to score):
43
+ ${ans || '(empty)'}
44
+
45
+ Judge: (1) is the traced call path correct vs ground truth? (2) are the cited files/symbols correct (not fabricated)? (3) if it gave a "Coverage:" verdict, was it honest? A confident WRONG trace is the worst outcome — penalize it harder than an honest partial.
46
+ Output ONLY minified JSON: {"verdict":"pass|partial|fail","score":<0-100>,"fabrication":<true|false>,"coverageHonest":<true|false>,"note":"<=20 words"}`;
47
+
48
+ const askJudge = (prompt) => new Promise((res) => {
49
+ execFile('claude', ['-p', prompt, '--model', 'sonnet', '--effort', 'high', '--max-budget-usd', '0.5',
50
+ '--strict-mcp-config', '--mcp-config', '{"mcpServers":{}}'],
51
+ { cwd: OUT, maxBuffer: 1 << 24, timeout: 120000 }, (err, stdout) => {
52
+ const m = (stdout || '').match(/\{[\s\S]*\}/);
53
+ if (!m) return res({ verdict: 'error', score: null, note: (err ? err.message : 'no json').slice(0, 60) });
54
+ try { res(JSON.parse(m[0])); } catch { res({ verdict: 'error', score: null }); }
55
+ });
56
+ });
57
+
58
+ // ---- 1. Probe: collect synthesized answers at each effort -------------------
59
+ const records = [];
60
+ for (const repo of Object.keys(GT)) {
61
+ if (ONLY && !ONLY.has(repo)) continue;
62
+ const dir = join(REPOS, repo);
63
+ if (!existsSync(join(dir, '.codegraph'))) { console.error('skip (not indexed):', repo); continue; }
64
+ const cg = CodeGraph.openSync(dir);
65
+ const h = new ToolHandler(cg);
66
+ for (const effort of EFFORTS) {
67
+ for (let rep = 1; rep <= REPS; rep++) {
68
+ process.env.CODEGRAPH_OFFLOAD_EFFORT = effort;
69
+ const usageLog = join(tmpdir(), `effort-${repo}-${effort}-${rep}.jsonl`);
70
+ try { rmSync(usageLog); } catch { /* none */ }
71
+ process.env.CODEGRAPH_OFFLOAD_USAGE_LOG = usageLog;
72
+ let answer = '';
73
+ try { answer = (await h.execute('codegraph_explore', { query: GT[repo].question }))?.content?.[0]?.text ?? ''; }
74
+ catch (e) { console.error(` ${repo}/${effort}#${rep} explore failed: ${e?.message}`); }
75
+ const fired = /Synthesized by CodeGraph/.test(answer);
76
+ const ai = { tokens: 0, cost: 0, ms: 0 };
77
+ if (existsSync(usageLog)) for (const e of readFileSync(usageLog, 'utf8').split('\n').filter(Boolean).map(JSON.parse)) {
78
+ ai.tokens += e.totalTokens || 0; ai.cost += e.costUsd || 0; ai.ms += e.ms || 0;
79
+ }
80
+ records.push({ repo, tier: TIER[repo], effort, rep, fired, ai, answer });
81
+ console.error(` ${repo}/${effort}#${rep}: fired=${fired} ${ai.tokens}tok $${ai.cost.toFixed(4)} ${ai.ms}ms`);
82
+ }
83
+ }
84
+ try { cg.close?.(); } catch { /* none */ }
85
+ }
86
+
87
+ // ---- 2. Judge fidelity (concurrency) ---------------------------------------
88
+ console.error(`\njudging ${records.length} answers (concurrency ${CONC})...`);
89
+ let done = 0;
90
+ const q = [...records];
91
+ async function worker() { while (q.length) { const r = q.shift(); r.fid = await askJudge(fidPrompt(GT[r.repo], r.answer)); console.error(` [${++done}/${records.length}] ${r.repo}/${r.effort}#${r.rep}: ${r.fid.verdict} ${r.fid.score ?? ''}`); } }
92
+ await Promise.all(Array.from({ length: CONC }, worker));
93
+ writeFileSync(join(OUT, 'effort-results.jsonl'), records.map((r) => JSON.stringify(r)).join('\n') + '\n');
94
+
95
+ // ---- 3. Aggregate: low vs high per repo ------------------------------------
96
+ const med = (a) => { a = a.filter((x) => x != null).sort((x, y) => x - y); return a.length ? (a.length % 2 ? a[(a.length - 1) / 2] : (a[a.length / 2 - 1] + a[a.length / 2]) / 2) : null; };
97
+ console.log(`\n${'='.repeat(80)}\nEFFORT A/B — offload synthesis fidelity (probe, n=${REPS}/cell)\n${'='.repeat(80)}`);
98
+ console.log(`${'repo'.padEnd(11)} ${'tier'.padEnd(8)} ${'effort'.padEnd(6)} fired ${'fid(med)'.padStart(8)} ${'fab%'.padStart(5)} ${'AItok'.padStart(7)} ${'AIcost'.padStart(8)} ${'ms(med)'.padStart(8)}`);
99
+ for (const repo of Object.keys(GT)) {
100
+ for (const effort of EFFORTS) {
101
+ const rs = records.filter((r) => r.repo === repo && r.effort === effort);
102
+ if (!rs.length) continue;
103
+ const fids = rs.map((r) => r.fid?.score).filter((x) => x != null);
104
+ const fab = rs.filter((r) => r.fid?.fabrication === true).length;
105
+ console.log(`${repo.padEnd(11)} ${TIER[repo].padEnd(8)} ${effort.padEnd(6)} ${rs.filter((r) => r.fired).length}/${rs.length} ${String(med(fids) ?? '—').padStart(8)} ${String(Math.round(100 * fab / rs.length) + '%').padStart(5)} ${String(Math.round(med(rs.map((r) => r.ai.tokens)) / 1000) + 'k').padStart(7)} ${('$' + (med(rs.map((r) => r.ai.cost)) ?? 0).toFixed(4)).padStart(8)} ${String(med(rs.map((r) => r.ai.ms)) ?? '—').padStart(8)}`);
106
+ }
107
+ }
108
+ console.log('');
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ # Run the FRONTLOAD arm across all 4 tiers (n reps), then judge + merge with the existing
3
+ # matrix (offload/raw/nocg in $OUT/judged.jsonl, if present) + emit a combined summary.
4
+ # Env: REPS (default 3) AGENT_EVAL_OUT=<scratch dir>
5
+ set -uo pipefail
6
+ HERE="$(cd "$(dirname "$0")" && pwd)"
7
+ OUT="${AGENT_EVAL_OUT:-/tmp/cg-offload-eval}"
8
+ GT="$HERE/offload-eval-ground-truth.json"
9
+ REPS="${REPS:-3}"
10
+ export RESULTS="$OUT/results-fl.jsonl"
11
+ : > "$RESULTS"; rm -f "$OUT/runs/hook-debug.log"
12
+ for repo in mtkruto postybirb shapeshift trezor; do
13
+ case "$repo" in mtkruto) tier=small;; postybirb) tier=medium;; shapeshift) tier=complex;; trezor) tier=large;; esac
14
+ Q=$(node -e "console.log(JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'))[process.argv[2]].question)" "$GT" "$repo")
15
+ echo ""; echo "### $repo ($tier) $(date +%H:%M:%S)"
16
+ bash "$HERE/offload-eval-frontload.sh" "$OUT/repos/$repo" "$tier" "$REPS" "$Q"
17
+ done
18
+ echo ""
19
+ echo "frontload: $(wc -l < "$RESULTS") runs | hook injections: $(grep -c INJECTED "$OUT/runs/hook-debug.log" 2>/dev/null) | errors: $(grep -c ERROR "$OUT/runs/hook-debug.log" 2>/dev/null)"
20
+ echo "=== JUDGE frontload ==="
21
+ node "$HERE/offload-eval-judge.mjs" --results "$RESULTS" --truth "$GT" --out "$OUT/judged-fl.jsonl" --concurrency 4 2>&1 | tail -4
22
+ if [ -f "$OUT/judged.jsonl" ]; then cat "$OUT/judged.jsonl" "$OUT/judged-fl.jsonl" > "$OUT/judged-all.jsonl"; else cp "$OUT/judged-fl.jsonl" "$OUT/judged-all.jsonl"; fi
23
+ echo "=== COMBINED SUMMARY ==="
24
+ node "$HERE/offload-eval-summarize.mjs" "$OUT/judged-all.jsonl"
25
+ echo "###### FRONTLOAD MATRIX DONE"
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env bash
2
+ # FRONTLOAD arm (approach 1): codegraph attached (offload-disabled) + the front-load
3
+ # UserPromptSubmit hook (offload-eval-hook.mjs), n reps, appended to $RESULTS. Compare against
4
+ # the matrix's raw/nocg baselines. Usage: offload-eval-frontload.sh <indexed-repo> <tier> <reps> "<Q>"
5
+ # Env: MODEL=sonnet EFFORT=high RESULTS=<file> AGENT_EVAL_OUT=<scratch dir>
6
+ set -uo pipefail
7
+ HERE="$(cd "$(dirname "$0")" && pwd)"
8
+ ENGINE="$(cd "$HERE/../.." && pwd)"
9
+ BIN="$ENGINE/dist/bin/codegraph.js"
10
+ OUT="${AGENT_EVAL_OUT:-/tmp/cg-offload-eval}"
11
+ TARGET="${1:?repo}"; TIER="${2:?tier}"; REPS="${3:?reps}"; Q="${4:?question}"
12
+ RUNS="$OUT/runs"
13
+ EXTRACT="$HERE/offload-eval-metrics.mjs"
14
+ RESULTS="${RESULTS:-$OUT/results-fl.jsonl}"
15
+ REPO=$(basename "$TARGET")
16
+ mkdir -p "$RUNS"
17
+ [ -d "$TARGET/.codegraph" ] || { echo "not indexed: $TARGET"; exit 1; }
18
+ TARGET=$(cd "$TARGET" && pwd -P)
19
+
20
+ CFG="$RUNS/mcp-fl-$REPO.json"
21
+ printf '{"mcpServers":{"codegraph":{"command":"env","args":["CODEGRAPH_WASM_RELAUNCHED=1","CODEGRAPH_OFFLOAD_DISABLE=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$TARGET" > "$CFG"
22
+ # Generate the hook settings pointing at the persisted hook; enable its debug log so we can
23
+ # count injections (claude passes this env down to the spawned hook process).
24
+ HOOKCFG="$RUNS/frontload-settings.json"
25
+ printf '{"hooks":{"UserPromptSubmit":[{"hooks":[{"type":"command","command":"node %s/offload-eval-hook.mjs"}]}]}}' "$HERE" > "$HOOKCFG"
26
+ export CG_FRONTLOAD_DEBUG="$RUNS/hook-debug.log"
27
+
28
+ prewarm() {
29
+ pkill -9 -f "serve --mcp --path $1" 2>/dev/null; rm -f "$1/.codegraph/daemon.sock" 2>/dev/null; sleep 0.6
30
+ env CODEGRAPH_OFFLOAD_DISABLE=1 CODEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
31
+ node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.codegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" \
32
+ && echo " daemon warm" || echo " WARN no daemon"
33
+ }
34
+
35
+ echo "###### FRONTLOAD repo=$REPO tier=$TIER reps=$REPS"
36
+ prewarm "$TARGET"
37
+ for r in $(seq 1 "$REPS"); do
38
+ tag="$REPO-frontload-$r"
39
+ ( cd "$TARGET" && claude -p "$Q" --output-format stream-json --verbose --permission-mode bypassPermissions \
40
+ --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
41
+ --strict-mcp-config --mcp-config "$CFG" --settings "$HOOKCFG" \
42
+ </dev/null > "$RUNS/$tag.jsonl" 2>"$RUNS/$tag.err" )
43
+ node "$EXTRACT" --run "$RUNS/$tag.jsonl" --usage "-" --arm frontload --rep "$r" --repo "$REPO" --tier "$TIER" --q "$Q" >> "$RESULTS"
44
+ node -e 'const o=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8").trim().split("\n").pop());console.log(` [frontload #${o.rep}] ${o.durationSec}s | main $${o.costUsdMain} ${o.tokBillable}tok | read=${o.read} grep=${o.grep} agentExplore=${o.explore} | ok=${o.ok}`)' "$RESULTS"
45
+ done
46
+ pkill -9 -f "serve --mcp --path $TARGET" 2>/dev/null; rm -f "$TARGET/.codegraph/daemon.sock" 2>/dev/null
47
+ echo "###### FRONTLOAD DONE $REPO (cumulative hook injections: $(grep -c INJECTED "$CG_FRONTLOAD_DEBUG" 2>/dev/null))"
@@ -0,0 +1,18 @@
1
+ {
2
+ "mtkruto": {
3
+ "question": "How does calling the high-level client.sendMessage() method get the message serialized into a TL/MTProto request and sent over the network transport to Telegram's servers? Trace the call path.",
4
+ "truth": "Verified call path (small TS Telegram-client lib):\n1. Client.sendMessage — client/6_client.ts:1852 → calls this.#messageManager.sendMessage(...) (1853)\n2. MessageManager.sendMessage — client/3_message_manager.ts:330 → builds the TL function {_:\"messages.sendMessage\", peer, message,...} and calls this.#c.invoke(...) (~377)\n3. c.invoke closure / Client.#invoke — client/6_client.ts:279/887 → resolves a ClientEncrypted and calls client.invoke(function_) (897)\n4. ClientEncrypted.invoke — client/2_client_encrypted.ts:324 → this.#send(function_) (325)\n5. ClientEncrypted.#send — client/2_client_encrypted.ts:261 → SERIALIZES via Api.serializeObject(function_) (290), then this.session.send(body) (296)\n - Serialization: Api.serializeObject (tl/2_telegram.ts:38) → new TLWriter().writeObject(...) (tl/1_tl_writer.ts) writes constructor id + fields\n6. SessionEncrypted.send — session/2_session_encrypted.ts:193 → ENQUEUES a PendingMessage and wakes the send loop (#awakeSendLoop) [DYNAMIC: async queue, not a direct call]\n7. SessionEncrypted.#sendLoopBody (AbortableLoop) — session/2_session_encrypted.ts:282 → #encryptMessage (serializeMessage tl/2_message.ts + IGE-256 AES) then this.transport.transport.send(payload) (339)\n8. Transport.send — TransportAbridged.send (transport/1_transport_abridged.ts:71) or TransportIntermediate → this.#connection.write(encrypt(framed))\n9. ConnectionTCP.write (connection/1_connection_tcp.ts:96) or ConnectionWebSocket.write — bytes exit the process.\nKEY SYMBOLS a correct answer must hit: sendMessage → MessageManager.sendMessage → invoke (ClientEncrypted.invoke/#send) → Api.serializeObject/TLWriter → SessionEncrypted.send (queue) → #sendLoopBody/#encryptMessage → Transport.send → Connection.write.\nDYNAMIC BOUNDARIES: the invoke indirection (closure→#invoke→ClientEncrypted), and the send-loop QUEUE between SessionEncrypted.send and #sendLoopBody (async, no direct edge)."
5
+ },
6
+ "postybirb": {
7
+ "question": "How does submitting/queueing a post reach the website-specific code that actually uploads to a target website? Trace the path from the submission entry point in the NestJS server to a concrete website service's post implementation.",
8
+ "truth": "Verified call path (NestJS+Electron, server under electron-app/src/server/):\n1. Entry: PostController.queue (submission/post/post.controller.ts:33, POST queue/:id) OR SubmissionService.queueScheduledSubmissions (submission/submission.service.ts, @Interval(60000) scheduler) — both call PostService.queue\n2. PostService.queue — submission/post/post.service.ts:68 → this.post(submission)\n3. PostService.post (private) — post.service.ts:206 → this.createPoster(...) for each non-default SubmissionPart\n4. PostService.createPoster — post.service.ts:373 → website = this.websites.getWebsiteModule(part.website) [part.website is a STRING]\n5. WebsiteProvider.getWebsiteModule — websites/website-provider.service.ts:86 → websiteModulesMap[name.toLowerCase()] [DYNAMIC: string-keyed registry of DI-injected Website singletons]; then new Poster(..., website, ...)\n6. Poster constructor — submission/post/poster.ts:117 → setTimeout(this.post.bind(this), delay) [DYNAMIC: async timer, min ~5s]\n7. Poster.post (poster.ts:131) → performPost (171) → attemptPost (217)\n8. Poster.attemptPost — poster.ts:217 → this.website.postFileSubmission(token, data, accountData) [DYNAMIC: polymorphic dispatch on abstract Website] (or postNotificationSubmission)\n9. Website.postFileSubmission (abstract) — websites/website.base.ts:102\n10. Concrete e.g. FurAffinity.postFileSubmission — websites/fur-affinity/fur-affinity.service.ts:231 → multi-step HTTP upload (GET /submit, POST /submit/upload multipart, POST /submit/finalize)\nKEY SYMBOLS: PostService.queue → PostService.post → createPoster → WebsiteProvider.getWebsiteModule (registry) → Poster (setTimeout) → Poster.attemptPost → Website.postFileSubmission (abstract base) → a concrete website service (e.g. FurAffinity).\nDYNAMIC BOUNDARIES: NestJS DI builds the website registry; string-keyed map lookup; setTimeout defers Poster.post; polymorphic dispatch on the abstract Website base. A correct answer must reach a concrete website's post via the registry + base class, not stop at PostService."
9
+ },
10
+ "shapeshift": {
11
+ "question": "How does executing a swap work in ShapeShift — from the code that fetches quotes and selects a swapper down to a specific swapper's execute/trade? Name the swapper interface, the registry, and one concrete swapper, and trace the path.",
12
+ "truth": "Verified call path (large multi-package monorepo; swap logic in packages/swapper + execution in src/lib):\nQUOTE/REGISTRY layer:\n- Swapper interface = the `Swapper` type (execute methods) + `SwapperApi` type (getTradeQuote/getUnsignedTx) — packages/swapper/src/types.ts (~846/897)\n- Registry = `swappers: Record<SwapperName,(SwapperApi & Swapper)>` — packages/swapper/src/constants.ts:52 (merges e.g. thorchainSwapper + thorchainApi)\n- Aggregator: swapperApi RTK endpoint getTradeQuote/getTradeRates (src/state/apis/swapper/swapperApi.ts:78/156) → getTradeQuotes (packages/swapper/src/swapper.ts:18/26): swapper = swappers[swapperName]; swapper.getTradeQuote(...) [DYNAMIC interface dispatch]\n- Concrete (THORChain): thorchainApi.getTradeQuote (swappers/ThorchainSwapper/endpoints.ts → getTradeQuote/getTradeQuote.ts:15) → getL1RateOrQuote → getQuote (thorService HTTP)\nSELECTION: tradeQuoteSlice selectors rank quotes (selectSortedTradeQuotes / selectActiveSwapperName) [DYNAMIC: winner chosen by ranking/user]\nEXECUTION layer:\n- useTradeExecution (src/components/MultiHopTrade/.../hooks/useTradeExecution.tsx:200/476) → new TradeExecution(); execution.execEvmTransaction(...) (CowSwap: execEvmMessage)\n- TradeExecution.execEvmTransaction — src/lib/tradeExecution.ts:326 → _execWalletAgnostic(...) (372)\n- TradeExecution._execWalletAgnostic — tradeExecution.ts:136 → swapper = swappers[swapperName] (149) [DYNAMIC registry]; buildSignBroadcast → swapper.getUnsignedEvmTransaction(...) (355) then swapper.executeEvmTransaction(unsignedTx, {signAndBroadcastTransaction}) (367) [DYNAMIC SwapperApi/Swapper interface]\n- Concrete (THORChain): thorchainSwapper.executeEvmTransaction (swappers/ThorchainSwapper/ThorchainSwapper.ts → utils.ts:181) delegates to callbacks.signAndBroadcastTransaction (wallet). CowSwap alt: cowSwapper.executeEvmMessage → signCowOrder + cowService.post.\nKEY SYMBOLS: Swapper/SwapperApi types, swappers registry (constants.ts), getTradeQuotes (swapper.ts), TradeExecution._execWalletAgnostic, swapper.getUnsignedEvmTransaction/executeEvmTransaction, one concrete swapper (thorchainSwapper/zrxSwapper/cowSwapper).\nDYNAMIC BOUNDARIES: swappers[name] registry lookup (2 sites); all hops into a concrete swapper are via the Swapper/SwapperApi interface, never a direct function. A correct answer must name the interface + registry and reach a concrete swapper through interface dispatch."
13
+ },
14
+ "trezor": {
15
+ "question": "How does sending a crypto transaction flow from the send form's review/sign action through to signing it via @trezor/connect (TrezorConnect.signTransaction)? Trace the call path.",
16
+ "truth": "Verified call path (trezor-suite monorepo; app in packages/suite, shared logic in suite-common/wallet-core, device API in packages/connect):\n1. ReviewButton.handleButtonReviewClick — packages/suite/src/views/wallet/send/TotalSent/ReviewButton.tsx:120 → signTransaction() (= useSendForm's sign)\n2. useSendForm.sign (exported as signTransaction) — packages/suite/src/hooks/wallet/useSendForm.ts:278 → dispatch(signAndPushSendFormTransactionThunk({formState, precomposedTransaction, selectedAccount})) [DYNAMIC: redux thunk]\n3. signAndPushSendFormTransactionThunk — packages/suite/src/actions/wallet/send/sendFormThunks.ts:237 → (first enhancePrecomposedTransactionThunk) then dispatch(signTransactionThunk({...})) [cross-package: thunk from suite-common/wallet-core]\n4. signTransactionThunk (coin-routing hub) — suite-common/wallet-core/src/send/sendFormThunks.ts:532/573 → networkType branch → dispatch(signBitcoinSendFormTransactionThunk) (ethereum→signEthereumSendFormTransactionThunk, etc.) [DYNAMIC: runtime coin dispatch]\n5. signBitcoinSendFormTransactionThunk — suite-common/wallet-core/src/send/sendFormBitcoinThunks.ts:394 → await TrezorConnect.signTransaction(signPayload)\n6. TrezorConnect.signTransaction (facade) — packages/connect-common/src/factory.ts → closure calls impl.call({method:'signTransaction',...}) [DYNAMIC: facade / iframe-or-module boundary]\n7. CoreInModule.call — packages/connect/src/impl/core-in-module.ts:171 → posts CORE_CALL to core (deferred promise)\n8. Core.onCall → getMethod — packages/connect/src/core/index.ts → getMethod resolves 'signTransaction' → new SignTransaction(message) [DYNAMIC: name→class]\n9. SignTransaction.run — packages/connect/src/api/signTransaction.ts:317 → signTx via device.getCommands().typedCall (protobuf to device). After signing, signAndPushSendFormTransactionThunk → pushSendFormTransactionThunk → TrezorConnect.pushTransaction.\nKEY SYMBOLS: ReviewButton → useSendForm.sign → signAndPushSendFormTransactionThunk (suite) → signTransactionThunk (wallet-core, coin hub) → signBitcoinSendFormTransactionThunk → TrezorConnect.signTransaction → connect factory/CoreInModule.call → SignTransaction.run.\nDYNAMIC BOUNDARIES: every suite→wallet-core hop is a redux thunk dispatch; signTransactionThunk branches by networkType at runtime; TrezorConnect is a dynamically-built facade crossing an iframe/module boundary; the SignTransaction class is resolved by name. A correct answer must cross suite→wallet-core→connect and reach TrezorConnect.signTransaction / SignTransaction.run, not stop at the UI."
17
+ }
18
+ }
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ // UserPromptSubmit hook — APPROACH 1: additive context-injection.
3
+ // Front-loads codegraph's structural answer for flow/impact/"how/where" prompts so the
4
+ // agent's reflex grep/read has nothing left to find. Strictly additive (never blocks),
5
+ // gated to structural prompts (no cost otherwise), and uses RAW explore (offload disabled)
6
+ // so the injected context is accurate — never the (currently low-fidelity) synthesis.
7
+ //
8
+ // Reads {prompt, cwd} as JSON on stdin; prints the explore result to stdout (which Claude
9
+ // Code injects into the agent's context). Any failure -> silent exit 0 (degradable).
10
+ import { pathToFileURL, fileURLToPath } from 'node:url';
11
+ import { resolve, join, dirname } from 'node:path';
12
+ import { existsSync, readFileSync, appendFileSync } from 'node:fs';
13
+
14
+ // Resolve the engine repo from this script's own location (scripts/agent-eval/ -> ../..),
15
+ // overridable with CG_ENGINE. The hook ships inside the repo, so it finds its own dist.
16
+ const HERE = dirname(fileURLToPath(import.meta.url));
17
+ const ENGINE = process.env.CG_ENGINE || resolve(HERE, '..', '..');
18
+ const BUDGET = Number(process.env.CG_FRONTLOAD_BUDGET || 16000);
19
+
20
+ // Debug log only when CG_FRONTLOAD_DEBUG is set to a file path (the harness points it at a
21
+ // log to count injections); off by default so the shipped hook writes nothing extra.
22
+ const DBG = process.env.CG_FRONTLOAD_DEBUG;
23
+ const dbg = (m) => { if (!DBG) return; try { appendFileSync(DBG, `[${new Date().toISOString()}] ${m}\n`); } catch { /* ignore */ } };
24
+
25
+ let input = {};
26
+ try { input = JSON.parse(readFileSync(0, 'utf8')); } catch (e) { dbg('stdin parse fail: ' + e.message); }
27
+ const prompt = String(input.prompt || '');
28
+ const cwd = String(input.cwd || process.cwd());
29
+ dbg(`invoked: promptLen=${prompt.length} cwd=${cwd}`);
30
+
31
+ // Gate: only structural / flow / impact / where-how questions. Cheap regex; silent no-op
32
+ // otherwise so non-structural prompts ("fix this typo") cost nothing.
33
+ const STRUCTURAL = /\b(how|where|trace|flow|path|reach(es|ed)?|call(s|ed|er|ers|ee)?|depend|impact|affect|wire[ds]?|connect|implement|architect|structure|breaks?|what calls|why does)\b/i;
34
+ if (!prompt || !STRUCTURAL.test(prompt)) { dbg('gate: non-structural, no-op'); process.exit(0); }
35
+ dbg('gate: structural PASS');
36
+
37
+ // Find the index: cwd, then walk up a few levels.
38
+ let root = cwd, found = null;
39
+ for (let i = 0; i < 6 && root; i++) {
40
+ if (existsSync(join(root, '.codegraph'))) { found = root; break; }
41
+ const parent = resolve(root, '..'); if (parent === root) break; root = parent;
42
+ }
43
+ if (!found) { dbg(`no .codegraph found from cwd=${cwd}`); process.exit(0); }
44
+ dbg(`found index at ${found}`);
45
+
46
+ try {
47
+ process.env.CODEGRAPH_OFFLOAD_DISABLE = '1'; // raw, accurate — never the unfixed offload
48
+ process.env.CODEGRAPH_TELEMETRY = '0'; process.env.DO_NOT_TRACK = '1';
49
+ const load = async (rel) => import(pathToFileURL(resolve(ENGINE, rel)).href);
50
+ const idx = await load('dist/index.js');
51
+ const tools = await load('dist/mcp/tools.js');
52
+ const CodeGraph = idx.default?.default ?? idx.default ?? idx.CodeGraph;
53
+ const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler;
54
+ if (typeof CodeGraph?.openSync !== 'function' || typeof ToolHandler !== 'function') process.exit(0);
55
+
56
+ // Retry once on a transient busy/locked index (the hook's openSync can race a
57
+ // freshly-warming daemon on the first prompt of a session).
58
+ let text = '';
59
+ for (let attempt = 1; attempt <= 2; attempt++) {
60
+ try {
61
+ const cg = CodeGraph.openSync(found);
62
+ const h = new ToolHandler(cg);
63
+ const res = await h.execute('codegraph_explore', { query: prompt });
64
+ text = res?.content?.[0]?.text ?? '';
65
+ try { cg.close?.(); } catch { /* ignore */ }
66
+ dbg(`explore attempt ${attempt} returned ${text.length} chars`);
67
+ break;
68
+ } catch (e) {
69
+ dbg(`explore attempt ${attempt} failed: ${e?.message || e}`);
70
+ if (attempt === 2) throw e;
71
+ await new Promise((r) => setTimeout(r, 800));
72
+ }
73
+ }
74
+ if (!text.trim()) { dbg('empty explore result, no-op'); process.exit(0); }
75
+ if (text.length > BUDGET) text = text.slice(0, BUDGET) + '\n…[front-load truncated to budget]';
76
+
77
+ process.stdout.write(
78
+ `## CodeGraph structural context (auto-retrieved for this question)\n` +
79
+ `The code graph was queried for your question; the relevant symbols, source, and call flow are below. ` +
80
+ `Treat the quoted source as already read. If you need more, call codegraph_explore with specific symbol names rather than grepping or reading files.\n\n` +
81
+ text + '\n'
82
+ );
83
+ dbg(`INJECTED ${text.length} chars`);
84
+ } catch (e) { dbg('ERROR: ' + (e?.stack || e?.message || e)); process.exit(0); } // degradable