homegraph 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (361) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +268 -243
  3. package/dist/arkts/ohos-api-index.d.ts +15 -0
  4. package/dist/arkts/ohos-api-index.d.ts.map +1 -0
  5. package/dist/arkts/ohos-api-index.js +190 -0
  6. package/dist/arkts/ohos-api-index.js.map +1 -0
  7. package/dist/arkts/ohos-sdk-input.d.ts +36 -0
  8. package/dist/arkts/ohos-sdk-input.d.ts.map +1 -0
  9. package/dist/arkts/ohos-sdk-input.js +214 -0
  10. package/dist/arkts/ohos-sdk-input.js.map +1 -0
  11. package/dist/bin/command-supervision.d.ts +12 -0
  12. package/dist/bin/command-supervision.d.ts.map +1 -0
  13. package/dist/bin/command-supervision.js +86 -0
  14. package/dist/bin/command-supervision.js.map +1 -0
  15. package/dist/bin/homegraph.d.ts +1 -1
  16. package/dist/bin/homegraph.js +971 -71
  17. package/dist/bin/homegraph.js.map +1 -1
  18. package/dist/db/index.d.ts +20 -0
  19. package/dist/db/index.d.ts.map +1 -1
  20. package/dist/db/index.js +39 -0
  21. package/dist/db/index.js.map +1 -1
  22. package/dist/db/migrations.d.ts +1 -1
  23. package/dist/db/migrations.d.ts.map +1 -1
  24. package/dist/db/migrations.js +58 -19
  25. package/dist/db/migrations.js.map +1 -1
  26. package/dist/db/queries.d.ts +14 -0
  27. package/dist/db/queries.d.ts.map +1 -1
  28. package/dist/db/queries.js +314 -143
  29. package/dist/db/queries.js.map +1 -1
  30. package/dist/db/schema.sql +172 -152
  31. package/dist/directory.d.ts +32 -0
  32. package/dist/directory.d.ts.map +1 -1
  33. package/dist/directory.js +88 -5
  34. package/dist/directory.js.map +1 -1
  35. package/dist/extraction/arkts-batch-worker.d.ts +2 -0
  36. package/dist/extraction/arkts-batch-worker.d.ts.map +1 -0
  37. package/dist/extraction/arkts-batch-worker.js +28 -0
  38. package/dist/extraction/arkts-batch-worker.js.map +1 -0
  39. package/dist/extraction/context.d.ts +11 -0
  40. package/dist/extraction/context.d.ts.map +1 -1
  41. package/dist/extraction/context.js +20 -0
  42. package/dist/extraction/context.js.map +1 -1
  43. package/dist/extraction/index.d.ts +16 -2
  44. package/dist/extraction/index.d.ts.map +1 -1
  45. package/dist/extraction/index.js +619 -380
  46. package/dist/extraction/index.js.map +1 -1
  47. package/dist/extraction/languages/arkts-state-decorators.d.ts +13 -0
  48. package/dist/extraction/languages/arkts-state-decorators.d.ts.map +1 -0
  49. package/dist/extraction/languages/arkts-state-decorators.js +26 -0
  50. package/dist/extraction/languages/arkts-state-decorators.js.map +1 -0
  51. package/dist/extraction/languages/arkts-viewtree.d.ts +4 -2
  52. package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
  53. package/dist/extraction/languages/arkts-viewtree.js +21 -6
  54. package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
  55. package/dist/extraction/languages/arkts.d.ts +98 -2
  56. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  57. package/dist/extraction/languages/arkts.js +1290 -61
  58. package/dist/extraction/languages/arkts.js.map +1 -1
  59. package/dist/extraction/languages/c-cpp.d.ts +56 -0
  60. package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  61. package/dist/extraction/languages/c-cpp.js +198 -1
  62. package/dist/extraction/languages/c-cpp.js.map +1 -1
  63. package/dist/extraction/languages/ohos-api-consumer.d.ts +34 -0
  64. package/dist/extraction/languages/ohos-api-consumer.d.ts.map +1 -0
  65. package/dist/extraction/languages/ohos-api-consumer.js +283 -0
  66. package/dist/extraction/languages/ohos-api-consumer.js.map +1 -0
  67. package/dist/extraction/parse-pool.d.ts +126 -0
  68. package/dist/extraction/parse-pool.d.ts.map +1 -0
  69. package/dist/extraction/parse-pool.js +319 -0
  70. package/dist/extraction/parse-pool.js.map +1 -0
  71. package/dist/extraction/tree-sitter-types.d.ts +17 -0
  72. package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  73. package/dist/extraction/tree-sitter.d.ts +21 -0
  74. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  75. package/dist/extraction/tree-sitter.js +198 -27
  76. package/dist/extraction/tree-sitter.js.map +1 -1
  77. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  78. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  79. package/dist/graph/traversal.d.ts.map +1 -1
  80. package/dist/graph/traversal.js +76 -17
  81. package/dist/graph/traversal.js.map +1 -1
  82. package/dist/index.d.ts +25 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +78 -4
  85. package/dist/index.js.map +1 -1
  86. package/dist/installer/instructions-template.js +9 -9
  87. package/dist/installer/targets/shared.d.ts +5 -6
  88. package/dist/installer/targets/shared.d.ts.map +1 -1
  89. package/dist/installer/targets/shared.js +5 -6
  90. package/dist/installer/targets/shared.js.map +1 -1
  91. package/dist/mcp/daemon-paths.d.ts +30 -3
  92. package/dist/mcp/daemon-paths.d.ts.map +1 -1
  93. package/dist/mcp/daemon-paths.js +50 -10
  94. package/dist/mcp/daemon-paths.js.map +1 -1
  95. package/dist/mcp/daemon-registry.d.ts.map +1 -1
  96. package/dist/mcp/daemon-registry.js +7 -3
  97. package/dist/mcp/daemon-registry.js.map +1 -1
  98. package/dist/mcp/daemon.d.ts +48 -0
  99. package/dist/mcp/daemon.d.ts.map +1 -1
  100. package/dist/mcp/daemon.js +196 -32
  101. package/dist/mcp/daemon.js.map +1 -1
  102. package/dist/mcp/engine.d.ts +17 -0
  103. package/dist/mcp/engine.d.ts.map +1 -1
  104. package/dist/mcp/engine.js +73 -1
  105. package/dist/mcp/engine.js.map +1 -1
  106. package/dist/mcp/index.d.ts.map +1 -1
  107. package/dist/mcp/index.js +25 -43
  108. package/dist/mcp/index.js.map +1 -1
  109. package/dist/mcp/liveness-watchdog.js +16 -16
  110. package/dist/mcp/ppid-watchdog.d.ts +18 -0
  111. package/dist/mcp/ppid-watchdog.d.ts.map +1 -1
  112. package/dist/mcp/ppid-watchdog.js +37 -0
  113. package/dist/mcp/ppid-watchdog.js.map +1 -1
  114. package/dist/mcp/query-cache.d.ts +25 -0
  115. package/dist/mcp/query-cache.d.ts.map +1 -0
  116. package/dist/mcp/query-cache.js +191 -0
  117. package/dist/mcp/query-cache.js.map +1 -0
  118. package/dist/mcp/query-pool.d.ts +94 -0
  119. package/dist/mcp/query-pool.d.ts.map +1 -0
  120. package/dist/mcp/query-pool.js +297 -0
  121. package/dist/mcp/query-pool.js.map +1 -0
  122. package/dist/mcp/query-worker.d.ts +24 -0
  123. package/dist/mcp/query-worker.d.ts.map +1 -0
  124. package/dist/mcp/query-worker.js +87 -0
  125. package/dist/mcp/query-worker.js.map +1 -0
  126. package/dist/mcp/server-instructions.d.ts +5 -7
  127. package/dist/mcp/server-instructions.d.ts.map +1 -1
  128. package/dist/mcp/server-instructions.js +72 -74
  129. package/dist/mcp/server-instructions.js.map +1 -1
  130. package/dist/mcp/tools.d.ts +94 -4
  131. package/dist/mcp/tools.d.ts.map +1 -1
  132. package/dist/mcp/tools.js +877 -71
  133. package/dist/mcp/tools.js.map +1 -1
  134. package/dist/project-config.d.ts +20 -0
  135. package/dist/project-config.d.ts.map +1 -1
  136. package/dist/project-config.js +42 -2
  137. package/dist/project-config.js.map +1 -1
  138. package/dist/reasoning/login.js +1 -1
  139. package/dist/reasoning/login.js.map +1 -1
  140. package/dist/reasoning/reasoner.js +32 -32
  141. package/dist/resolution/c-fnptr-synthesizer.d.ts +0 -28
  142. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  143. package/dist/resolution/c-fnptr-synthesizer.js +765 -79
  144. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  145. package/dist/resolution/callback-synthesizer.d.ts +1 -1
  146. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  147. package/dist/resolution/callback-synthesizer.js +72 -11
  148. package/dist/resolution/callback-synthesizer.js.map +1 -1
  149. package/dist/resolution/cooperative-yield.d.ts +32 -0
  150. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  151. package/dist/resolution/cooperative-yield.js +42 -0
  152. package/dist/resolution/cooperative-yield.js.map +1 -0
  153. package/dist/resolution/index.d.ts +11 -2
  154. package/dist/resolution/index.d.ts.map +1 -1
  155. package/dist/resolution/index.js +72 -4
  156. package/dist/resolution/index.js.map +1 -1
  157. package/dist/resolution/name-matcher.d.ts +22 -0
  158. package/dist/resolution/name-matcher.d.ts.map +1 -1
  159. package/dist/resolution/name-matcher.js +317 -20
  160. package/dist/resolution/name-matcher.js.map +1 -1
  161. package/dist/spec/config.d.ts +39 -0
  162. package/dist/spec/config.d.ts.map +1 -0
  163. package/dist/spec/config.js +304 -0
  164. package/dist/spec/config.js.map +1 -0
  165. package/dist/spec/db/commit-node.d.ts +23 -0
  166. package/dist/spec/db/commit-node.d.ts.map +1 -0
  167. package/dist/spec/db/commit-node.js +62 -0
  168. package/dist/spec/db/commit-node.js.map +1 -0
  169. package/dist/spec/db/fragment-node.d.ts +24 -0
  170. package/dist/spec/db/fragment-node.d.ts.map +1 -0
  171. package/dist/spec/db/fragment-node.js +128 -0
  172. package/dist/spec/db/fragment-node.js.map +1 -0
  173. package/dist/spec/db/fts.d.ts +74 -0
  174. package/dist/spec/db/fts.d.ts.map +1 -0
  175. package/dist/spec/db/fts.js +324 -0
  176. package/dist/spec/db/fts.js.map +1 -0
  177. package/dist/spec/db/index.d.ts +13 -0
  178. package/dist/spec/db/index.d.ts.map +1 -0
  179. package/dist/spec/db/index.js +50 -0
  180. package/dist/spec/db/index.js.map +1 -0
  181. package/dist/spec/db/relations.d.ts +55 -0
  182. package/dist/spec/db/relations.d.ts.map +1 -0
  183. package/dist/spec/db/relations.js +158 -0
  184. package/dist/spec/db/relations.js.map +1 -0
  185. package/dist/spec/db/schema.d.ts +33 -0
  186. package/dist/spec/db/schema.d.ts.map +1 -0
  187. package/dist/spec/db/schema.js +119 -0
  188. package/dist/spec/db/schema.js.map +1 -0
  189. package/dist/spec/db/schema.sql +117 -0
  190. package/dist/spec/db/spec-node.d.ts +41 -0
  191. package/dist/spec/db/spec-node.d.ts.map +1 -0
  192. package/dist/spec/db/spec-node.js +114 -0
  193. package/dist/spec/db/spec-node.js.map +1 -0
  194. package/dist/spec/evolve/impact-locator.d.ts +13 -0
  195. package/dist/spec/evolve/impact-locator.d.ts.map +1 -0
  196. package/dist/spec/evolve/impact-locator.js +25 -0
  197. package/dist/spec/evolve/impact-locator.js.map +1 -0
  198. package/dist/spec/evolve/llm-client.d.ts +50 -0
  199. package/dist/spec/evolve/llm-client.d.ts.map +1 -0
  200. package/dist/spec/evolve/llm-client.js +176 -0
  201. package/dist/spec/evolve/llm-client.js.map +1 -0
  202. package/dist/spec/evolve/logic-checker.d.ts +12 -0
  203. package/dist/spec/evolve/logic-checker.d.ts.map +1 -0
  204. package/dist/spec/evolve/logic-checker.js +24 -0
  205. package/dist/spec/evolve/logic-checker.js.map +1 -0
  206. package/dist/spec/evolve/pipeline.d.ts +42 -0
  207. package/dist/spec/evolve/pipeline.d.ts.map +1 -0
  208. package/dist/spec/evolve/pipeline.js +567 -0
  209. package/dist/spec/evolve/pipeline.js.map +1 -0
  210. package/dist/spec/evolve/spec-rewriter.d.ts +42 -0
  211. package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -0
  212. package/dist/spec/evolve/spec-rewriter.js +230 -0
  213. package/dist/spec/evolve/spec-rewriter.js.map +1 -0
  214. package/dist/spec/graph/queries.d.ts +155 -0
  215. package/dist/spec/graph/queries.d.ts.map +1 -0
  216. package/dist/spec/graph/queries.js +440 -0
  217. package/dist/spec/graph/queries.js.map +1 -0
  218. package/dist/spec/llm/client.d.ts +29 -0
  219. package/dist/spec/llm/client.d.ts.map +1 -0
  220. package/dist/spec/llm/client.js +123 -0
  221. package/dist/spec/llm/client.js.map +1 -0
  222. package/dist/spec/llm/index.d.ts +3 -0
  223. package/dist/spec/llm/index.d.ts.map +1 -0
  224. package/dist/spec/llm/index.js +11 -0
  225. package/dist/spec/llm/index.js.map +1 -0
  226. package/dist/spec/llm/prompts.d.ts +13 -0
  227. package/dist/spec/llm/prompts.d.ts.map +1 -0
  228. package/dist/spec/llm/prompts.js +75 -0
  229. package/dist/spec/llm/prompts.js.map +1 -0
  230. package/dist/spec/mining/diff-parser.d.ts +33 -0
  231. package/dist/spec/mining/diff-parser.d.ts.map +1 -0
  232. package/dist/spec/mining/diff-parser.js +166 -0
  233. package/dist/spec/mining/diff-parser.js.map +1 -0
  234. package/dist/spec/mining/git-scanner.d.ts +103 -0
  235. package/dist/spec/mining/git-scanner.d.ts.map +1 -0
  236. package/dist/spec/mining/git-scanner.js +307 -0
  237. package/dist/spec/mining/git-scanner.js.map +1 -0
  238. package/dist/spec/mining/pipeline.d.ts +53 -0
  239. package/dist/spec/mining/pipeline.d.ts.map +1 -0
  240. package/dist/spec/mining/pipeline.js +178 -0
  241. package/dist/spec/mining/pipeline.js.map +1 -0
  242. package/dist/spec/mining/scope-resolver.d.ts +45 -0
  243. package/dist/spec/mining/scope-resolver.d.ts.map +1 -0
  244. package/dist/spec/mining/scope-resolver.js +103 -0
  245. package/dist/spec/mining/scope-resolver.js.map +1 -0
  246. package/dist/spec/mining/spec-extractor.d.ts +69 -0
  247. package/dist/spec/mining/spec-extractor.d.ts.map +1 -0
  248. package/dist/spec/mining/spec-extractor.js +369 -0
  249. package/dist/spec/mining/spec-extractor.js.map +1 -0
  250. package/dist/spec/types.d.ts +149 -0
  251. package/dist/spec/types.d.ts.map +1 -0
  252. package/dist/spec/types.js +15 -0
  253. package/dist/spec/types.js.map +1 -0
  254. package/dist/spec/utils.d.ts +167 -0
  255. package/dist/spec/utils.d.ts.map +1 -0
  256. package/dist/spec/utils.js +463 -0
  257. package/dist/spec/utils.js.map +1 -0
  258. package/dist/sync/worktree.d.ts +9 -0
  259. package/dist/sync/worktree.d.ts.map +1 -1
  260. package/dist/sync/worktree.js +40 -0
  261. package/dist/sync/worktree.js.map +1 -1
  262. package/dist/types.d.ts +6 -1
  263. package/dist/types.d.ts.map +1 -1
  264. package/dist/ui/shimmer-progress.d.ts +2 -0
  265. package/dist/ui/shimmer-progress.d.ts.map +1 -1
  266. package/dist/ui/shimmer-progress.js +19 -2
  267. package/dist/ui/shimmer-progress.js.map +1 -1
  268. package/dist/upgrade/index.js +1 -1
  269. package/dist/upgrade/index.js.map +1 -1
  270. package/package.json +58 -57
  271. package/scripts/add-lang/bench.sh +60 -60
  272. package/scripts/add-lang/check-grammar.mjs +75 -75
  273. package/scripts/add-lang/dump-ast.mjs +103 -103
  274. package/scripts/add-lang/verify-extraction.mjs +70 -70
  275. package/scripts/agent-eval/ab-adoption.sh +91 -91
  276. package/scripts/agent-eval/ab-hook.sh +86 -86
  277. package/scripts/agent-eval/ab-impl.sh +78 -78
  278. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -102
  279. package/scripts/agent-eval/ab-sufficiency.sh +78 -78
  280. package/scripts/agent-eval/arms-F.sh +21 -21
  281. package/scripts/agent-eval/arms-matrix.sh +37 -37
  282. package/scripts/agent-eval/audit.sh +68 -68
  283. package/scripts/agent-eval/bench-readme.sh +28 -28
  284. package/scripts/agent-eval/bench-why-repo.sh +22 -22
  285. package/scripts/agent-eval/block-read-hook.sh +19 -19
  286. package/scripts/agent-eval/hook-settings.json +15 -15
  287. package/scripts/agent-eval/itrun.sh +120 -120
  288. package/scripts/agent-eval/offload-eval-3arm.sh +72 -72
  289. package/scripts/agent-eval/offload-eval-cost.mjs +133 -133
  290. package/scripts/agent-eval/offload-eval-effort.mjs +108 -108
  291. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -25
  292. package/scripts/agent-eval/offload-eval-frontload.sh +47 -47
  293. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -18
  294. package/scripts/agent-eval/offload-eval-hook.mjs +84 -84
  295. package/scripts/agent-eval/offload-eval-judge.mjs +103 -103
  296. package/scripts/agent-eval/offload-eval-matrix.sh +20 -20
  297. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -94
  298. package/scripts/agent-eval/offload-eval-refs1.sh +50 -50
  299. package/scripts/agent-eval/offload-eval-setup.sh +24 -24
  300. package/scripts/agent-eval/offload-eval-styles.sh +71 -71
  301. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -68
  302. package/scripts/agent-eval/offload-eval.md +76 -76
  303. package/scripts/agent-eval/parse-arms.mjs +116 -116
  304. package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
  305. package/scripts/agent-eval/parse-run.mjs +45 -45
  306. package/scripts/agent-eval/parse-session.mjs +93 -93
  307. package/scripts/agent-eval/probe-context.mjs +21 -21
  308. package/scripts/agent-eval/probe-explore.mjs +40 -40
  309. package/scripts/agent-eval/probe-node.mjs +20 -20
  310. package/scripts/agent-eval/probe-sweep.mjs +119 -119
  311. package/scripts/agent-eval/probe-trace.mjs +20 -20
  312. package/scripts/agent-eval/redirect-read-hook.sh +38 -38
  313. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  314. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  315. package/scripts/agent-eval/run-agent.sh +34 -34
  316. package/scripts/agent-eval/run-all.sh +69 -69
  317. package/scripts/agent-eval/run-arms.sh +56 -56
  318. package/scripts/agent-eval/seq-matrix.mjs +137 -137
  319. package/scripts/build-bundle.sh +118 -118
  320. package/scripts/exp_boundary_eval/README.md +247 -0
  321. package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
  322. package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
  323. package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
  324. package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
  325. package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
  326. package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
  327. package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -0
  328. package/scripts/exp_boundary_eval/_test_stdin.py +8 -0
  329. package/scripts/exp_boundary_eval/_utils.py +1116 -0
  330. package/scripts/exp_boundary_eval/analyze.py +1313 -0
  331. package/scripts/exp_boundary_eval/data/agents.json +109 -0
  332. package/scripts/exp_boundary_eval/data/experiments.json +140 -0
  333. package/scripts/exp_boundary_eval/deveco_arm.py +519 -0
  334. package/scripts/exp_boundary_eval/run_all.py +378 -0
  335. package/scripts/exp_boundary_eval/run_one.py +165 -0
  336. package/scripts/exp_boundary_eval/run_session.py +158 -0
  337. package/scripts/exp_boundary_eval/setup.py +120 -0
  338. package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -0
  339. package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -0
  340. package/scripts/exp_boundary_eval/win_node_launcher.py +24 -0
  341. package/scripts/extract-release-notes.mjs +130 -130
  342. package/scripts/local-install.sh +41 -41
  343. package/scripts/npm-sdk.js +75 -75
  344. package/scripts/npm-shim.js +268 -246
  345. package/scripts/ohos-sdk-publish.mjs +133 -0
  346. package/scripts/pack-npm.sh +119 -119
  347. package/scripts/prepare-release.mjs +270 -270
  348. package/scripts/qa_eval/README.md +407 -404
  349. package/scripts/qa_eval/_test_deveco_probe.py +41 -41
  350. package/scripts/qa_eval/agent_runner.py +526 -526
  351. package/scripts/qa_eval/data/.gitignore +4 -4
  352. package/scripts/qa_eval/data/test-set.jsonl +2 -22
  353. package/scripts/qa_eval/eval_metrics.py +274 -233
  354. package/scripts/qa_eval/external_agent.py +976 -671
  355. package/scripts/qa_eval/llm_config.py +92 -92
  356. package/scripts/qa_eval/memory_monitor.py +132 -132
  357. package/scripts/qa_eval/my_answer_accuracy.py +187 -187
  358. package/scripts/qa_eval/requirements.txt +2 -2
  359. package/scripts/qa_eval/run_pipeline.py +804 -711
  360. package/scripts/qa_eval/stats_efficiency.py +279 -279
  361. package/scripts/qa_eval/stats_scores.py +207 -207
@@ -1,120 +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 homegraph 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, homegraph 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
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 homegraph 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, homegraph 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
@@ -1,72 +1,72 @@
1
- #!/usr/bin/env bash
2
- # 3-arm offload eval for ONE indexed repo + ONE question, n reps each.
3
- # ARM offload : homegraph attached, managed offload ON (per-run AI usage log)
4
- # ARM raw : homegraph attached, HOMEGRAPH_OFFLOAD_DISABLE=1 (raw source)
5
- # ARM nocg : no homegraph (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/homegraph.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/.homegraph" ] || { 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/.homegraph/daemon.sock" 2>/dev/null; sleep 0.6
31
- env ${2:-} HOMEGRAPH_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]+"/.homegraph/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 homegraph-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":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","HOMEGRAPH_OFFLOAD_USAGE_LOG=%s","node","%s","serve","--mcp","--path","%s"]}}}' "$USAGE" "$BIN" "$TARGET" > "$CFG_OFF"
56
- printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","HOMEGRAPH_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" "HOMEGRAPH_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/.homegraph/daemon.sock" 2>/dev/null; sleep 1
67
- echo "== ARM raw =="; prewarm "$TARGET" "HOMEGRAPH_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/.homegraph/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"
1
+ #!/usr/bin/env bash
2
+ # 3-arm offload eval for ONE indexed repo + ONE question, n reps each.
3
+ # ARM offload : homegraph attached, managed offload ON (per-run AI usage log)
4
+ # ARM raw : homegraph attached, HOMEGRAPH_OFFLOAD_DISABLE=1 (raw source)
5
+ # ARM nocg : no homegraph (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/homegraph.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/.homegraph" ] || { 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/.homegraph/daemon.sock" 2>/dev/null; sleep 0.6
31
+ env ${2:-} HOMEGRAPH_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]+"/.homegraph/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 homegraph-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":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","HOMEGRAPH_OFFLOAD_USAGE_LOG=%s","node","%s","serve","--mcp","--path","%s"]}}}' "$USAGE" "$BIN" "$TARGET" > "$CFG_OFF"
56
+ printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","HOMEGRAPH_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" "HOMEGRAPH_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/.homegraph/daemon.sock" 2>/dev/null; sleep 1
67
+ echo "== ARM raw =="; prewarm "$TARGET" "HOMEGRAPH_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/.homegraph/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"