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.
- package/LICENSE +21 -21
- package/README.md +268 -243
- package/dist/arkts/ohos-api-index.d.ts +15 -0
- package/dist/arkts/ohos-api-index.d.ts.map +1 -0
- package/dist/arkts/ohos-api-index.js +190 -0
- package/dist/arkts/ohos-api-index.js.map +1 -0
- package/dist/arkts/ohos-sdk-input.d.ts +36 -0
- package/dist/arkts/ohos-sdk-input.d.ts.map +1 -0
- package/dist/arkts/ohos-sdk-input.js +214 -0
- package/dist/arkts/ohos-sdk-input.js.map +1 -0
- package/dist/bin/command-supervision.d.ts +12 -0
- package/dist/bin/command-supervision.d.ts.map +1 -0
- package/dist/bin/command-supervision.js +86 -0
- package/dist/bin/command-supervision.js.map +1 -0
- package/dist/bin/homegraph.d.ts +1 -1
- package/dist/bin/homegraph.js +971 -71
- package/dist/bin/homegraph.js.map +1 -1
- package/dist/db/index.d.ts +20 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +39 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +58 -19
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +14 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +314 -143
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +172 -152
- package/dist/directory.d.ts +32 -0
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +88 -5
- package/dist/directory.js.map +1 -1
- package/dist/extraction/arkts-batch-worker.d.ts +2 -0
- package/dist/extraction/arkts-batch-worker.d.ts.map +1 -0
- package/dist/extraction/arkts-batch-worker.js +28 -0
- package/dist/extraction/arkts-batch-worker.js.map +1 -0
- package/dist/extraction/context.d.ts +11 -0
- package/dist/extraction/context.d.ts.map +1 -1
- package/dist/extraction/context.js +20 -0
- package/dist/extraction/context.js.map +1 -1
- package/dist/extraction/index.d.ts +16 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +619 -380
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/arkts-state-decorators.d.ts +13 -0
- package/dist/extraction/languages/arkts-state-decorators.d.ts.map +1 -0
- package/dist/extraction/languages/arkts-state-decorators.js +26 -0
- package/dist/extraction/languages/arkts-state-decorators.js.map +1 -0
- package/dist/extraction/languages/arkts-viewtree.d.ts +4 -2
- package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
- package/dist/extraction/languages/arkts-viewtree.js +21 -6
- package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
- package/dist/extraction/languages/arkts.d.ts +98 -2
- package/dist/extraction/languages/arkts.d.ts.map +1 -1
- package/dist/extraction/languages/arkts.js +1290 -61
- package/dist/extraction/languages/arkts.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts +56 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +198 -1
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/ohos-api-consumer.d.ts +34 -0
- package/dist/extraction/languages/ohos-api-consumer.d.ts.map +1 -0
- package/dist/extraction/languages/ohos-api-consumer.js +283 -0
- package/dist/extraction/languages/ohos-api-consumer.js.map +1 -0
- package/dist/extraction/parse-pool.d.ts +126 -0
- package/dist/extraction/parse-pool.d.ts.map +1 -0
- package/dist/extraction/parse-pool.js +319 -0
- package/dist/extraction/parse-pool.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +17 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +21 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +198 -27
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +76 -17
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -4
- package/dist/index.js.map +1 -1
- package/dist/installer/instructions-template.js +9 -9
- package/dist/installer/targets/shared.d.ts +5 -6
- package/dist/installer/targets/shared.d.ts.map +1 -1
- package/dist/installer/targets/shared.js +5 -6
- package/dist/installer/targets/shared.js.map +1 -1
- package/dist/mcp/daemon-paths.d.ts +30 -3
- package/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/dist/mcp/daemon-paths.js +50 -10
- package/dist/mcp/daemon-paths.js.map +1 -1
- package/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/dist/mcp/daemon-registry.js +7 -3
- package/dist/mcp/daemon-registry.js.map +1 -1
- package/dist/mcp/daemon.d.ts +48 -0
- package/dist/mcp/daemon.d.ts.map +1 -1
- package/dist/mcp/daemon.js +196 -32
- package/dist/mcp/daemon.js.map +1 -1
- package/dist/mcp/engine.d.ts +17 -0
- package/dist/mcp/engine.d.ts.map +1 -1
- package/dist/mcp/engine.js +73 -1
- package/dist/mcp/engine.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +25 -43
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/liveness-watchdog.js +16 -16
- package/dist/mcp/ppid-watchdog.d.ts +18 -0
- package/dist/mcp/ppid-watchdog.d.ts.map +1 -1
- package/dist/mcp/ppid-watchdog.js +37 -0
- package/dist/mcp/ppid-watchdog.js.map +1 -1
- package/dist/mcp/query-cache.d.ts +25 -0
- package/dist/mcp/query-cache.d.ts.map +1 -0
- package/dist/mcp/query-cache.js +191 -0
- package/dist/mcp/query-cache.js.map +1 -0
- package/dist/mcp/query-pool.d.ts +94 -0
- package/dist/mcp/query-pool.d.ts.map +1 -0
- package/dist/mcp/query-pool.js +297 -0
- package/dist/mcp/query-pool.js.map +1 -0
- package/dist/mcp/query-worker.d.ts +24 -0
- package/dist/mcp/query-worker.d.ts.map +1 -0
- package/dist/mcp/query-worker.js +87 -0
- package/dist/mcp/query-worker.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +5 -7
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +72 -74
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/tools.d.ts +94 -4
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +877 -71
- package/dist/mcp/tools.js.map +1 -1
- package/dist/project-config.d.ts +20 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +42 -2
- package/dist/project-config.js.map +1 -1
- package/dist/reasoning/login.js +1 -1
- package/dist/reasoning/login.js.map +1 -1
- package/dist/reasoning/reasoner.js +32 -32
- package/dist/resolution/c-fnptr-synthesizer.d.ts +0 -28
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.js +765 -79
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/dist/resolution/callback-synthesizer.d.ts +1 -1
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/dist/resolution/callback-synthesizer.js +72 -11
- package/dist/resolution/callback-synthesizer.js.map +1 -1
- package/dist/resolution/cooperative-yield.d.ts +32 -0
- package/dist/resolution/cooperative-yield.d.ts.map +1 -0
- package/dist/resolution/cooperative-yield.js +42 -0
- package/dist/resolution/cooperative-yield.js.map +1 -0
- package/dist/resolution/index.d.ts +11 -2
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +72 -4
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/name-matcher.d.ts +22 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +317 -20
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/spec/config.d.ts +39 -0
- package/dist/spec/config.d.ts.map +1 -0
- package/dist/spec/config.js +304 -0
- package/dist/spec/config.js.map +1 -0
- package/dist/spec/db/commit-node.d.ts +23 -0
- package/dist/spec/db/commit-node.d.ts.map +1 -0
- package/dist/spec/db/commit-node.js +62 -0
- package/dist/spec/db/commit-node.js.map +1 -0
- package/dist/spec/db/fragment-node.d.ts +24 -0
- package/dist/spec/db/fragment-node.d.ts.map +1 -0
- package/dist/spec/db/fragment-node.js +128 -0
- package/dist/spec/db/fragment-node.js.map +1 -0
- package/dist/spec/db/fts.d.ts +74 -0
- package/dist/spec/db/fts.d.ts.map +1 -0
- package/dist/spec/db/fts.js +324 -0
- package/dist/spec/db/fts.js.map +1 -0
- package/dist/spec/db/index.d.ts +13 -0
- package/dist/spec/db/index.d.ts.map +1 -0
- package/dist/spec/db/index.js +50 -0
- package/dist/spec/db/index.js.map +1 -0
- package/dist/spec/db/relations.d.ts +55 -0
- package/dist/spec/db/relations.d.ts.map +1 -0
- package/dist/spec/db/relations.js +158 -0
- package/dist/spec/db/relations.js.map +1 -0
- package/dist/spec/db/schema.d.ts +33 -0
- package/dist/spec/db/schema.d.ts.map +1 -0
- package/dist/spec/db/schema.js +119 -0
- package/dist/spec/db/schema.js.map +1 -0
- package/dist/spec/db/schema.sql +117 -0
- package/dist/spec/db/spec-node.d.ts +41 -0
- package/dist/spec/db/spec-node.d.ts.map +1 -0
- package/dist/spec/db/spec-node.js +114 -0
- package/dist/spec/db/spec-node.js.map +1 -0
- package/dist/spec/evolve/impact-locator.d.ts +13 -0
- package/dist/spec/evolve/impact-locator.d.ts.map +1 -0
- package/dist/spec/evolve/impact-locator.js +25 -0
- package/dist/spec/evolve/impact-locator.js.map +1 -0
- package/dist/spec/evolve/llm-client.d.ts +50 -0
- package/dist/spec/evolve/llm-client.d.ts.map +1 -0
- package/dist/spec/evolve/llm-client.js +176 -0
- package/dist/spec/evolve/llm-client.js.map +1 -0
- package/dist/spec/evolve/logic-checker.d.ts +12 -0
- package/dist/spec/evolve/logic-checker.d.ts.map +1 -0
- package/dist/spec/evolve/logic-checker.js +24 -0
- package/dist/spec/evolve/logic-checker.js.map +1 -0
- package/dist/spec/evolve/pipeline.d.ts +42 -0
- package/dist/spec/evolve/pipeline.d.ts.map +1 -0
- package/dist/spec/evolve/pipeline.js +567 -0
- package/dist/spec/evolve/pipeline.js.map +1 -0
- package/dist/spec/evolve/spec-rewriter.d.ts +42 -0
- package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -0
- package/dist/spec/evolve/spec-rewriter.js +230 -0
- package/dist/spec/evolve/spec-rewriter.js.map +1 -0
- package/dist/spec/graph/queries.d.ts +155 -0
- package/dist/spec/graph/queries.d.ts.map +1 -0
- package/dist/spec/graph/queries.js +440 -0
- package/dist/spec/graph/queries.js.map +1 -0
- package/dist/spec/llm/client.d.ts +29 -0
- package/dist/spec/llm/client.d.ts.map +1 -0
- package/dist/spec/llm/client.js +123 -0
- package/dist/spec/llm/client.js.map +1 -0
- package/dist/spec/llm/index.d.ts +3 -0
- package/dist/spec/llm/index.d.ts.map +1 -0
- package/dist/spec/llm/index.js +11 -0
- package/dist/spec/llm/index.js.map +1 -0
- package/dist/spec/llm/prompts.d.ts +13 -0
- package/dist/spec/llm/prompts.d.ts.map +1 -0
- package/dist/spec/llm/prompts.js +75 -0
- package/dist/spec/llm/prompts.js.map +1 -0
- package/dist/spec/mining/diff-parser.d.ts +33 -0
- package/dist/spec/mining/diff-parser.d.ts.map +1 -0
- package/dist/spec/mining/diff-parser.js +166 -0
- package/dist/spec/mining/diff-parser.js.map +1 -0
- package/dist/spec/mining/git-scanner.d.ts +103 -0
- package/dist/spec/mining/git-scanner.d.ts.map +1 -0
- package/dist/spec/mining/git-scanner.js +307 -0
- package/dist/spec/mining/git-scanner.js.map +1 -0
- package/dist/spec/mining/pipeline.d.ts +53 -0
- package/dist/spec/mining/pipeline.d.ts.map +1 -0
- package/dist/spec/mining/pipeline.js +178 -0
- package/dist/spec/mining/pipeline.js.map +1 -0
- package/dist/spec/mining/scope-resolver.d.ts +45 -0
- package/dist/spec/mining/scope-resolver.d.ts.map +1 -0
- package/dist/spec/mining/scope-resolver.js +103 -0
- package/dist/spec/mining/scope-resolver.js.map +1 -0
- package/dist/spec/mining/spec-extractor.d.ts +69 -0
- package/dist/spec/mining/spec-extractor.d.ts.map +1 -0
- package/dist/spec/mining/spec-extractor.js +369 -0
- package/dist/spec/mining/spec-extractor.js.map +1 -0
- package/dist/spec/types.d.ts +149 -0
- package/dist/spec/types.d.ts.map +1 -0
- package/dist/spec/types.js +15 -0
- package/dist/spec/types.js.map +1 -0
- package/dist/spec/utils.d.ts +167 -0
- package/dist/spec/utils.d.ts.map +1 -0
- package/dist/spec/utils.js +463 -0
- package/dist/spec/utils.js.map +1 -0
- package/dist/sync/worktree.d.ts +9 -0
- package/dist/sync/worktree.d.ts.map +1 -1
- package/dist/sync/worktree.js +40 -0
- package/dist/sync/worktree.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/shimmer-progress.d.ts +2 -0
- package/dist/ui/shimmer-progress.d.ts.map +1 -1
- package/dist/ui/shimmer-progress.js +19 -2
- package/dist/ui/shimmer-progress.js.map +1 -1
- package/dist/upgrade/index.js +1 -1
- package/dist/upgrade/index.js.map +1 -1
- package/package.json +58 -57
- package/scripts/add-lang/bench.sh +60 -60
- package/scripts/add-lang/check-grammar.mjs +75 -75
- package/scripts/add-lang/dump-ast.mjs +103 -103
- package/scripts/add-lang/verify-extraction.mjs +70 -70
- package/scripts/agent-eval/ab-adoption.sh +91 -91
- package/scripts/agent-eval/ab-hook.sh +86 -86
- package/scripts/agent-eval/ab-impl.sh +78 -78
- package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -102
- package/scripts/agent-eval/ab-sufficiency.sh +78 -78
- package/scripts/agent-eval/arms-F.sh +21 -21
- package/scripts/agent-eval/arms-matrix.sh +37 -37
- package/scripts/agent-eval/audit.sh +68 -68
- package/scripts/agent-eval/bench-readme.sh +28 -28
- package/scripts/agent-eval/bench-why-repo.sh +22 -22
- package/scripts/agent-eval/block-read-hook.sh +19 -19
- package/scripts/agent-eval/hook-settings.json +15 -15
- package/scripts/agent-eval/itrun.sh +120 -120
- package/scripts/agent-eval/offload-eval-3arm.sh +72 -72
- package/scripts/agent-eval/offload-eval-cost.mjs +133 -133
- package/scripts/agent-eval/offload-eval-effort.mjs +108 -108
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -25
- package/scripts/agent-eval/offload-eval-frontload.sh +47 -47
- package/scripts/agent-eval/offload-eval-ground-truth.json +18 -18
- package/scripts/agent-eval/offload-eval-hook.mjs +84 -84
- package/scripts/agent-eval/offload-eval-judge.mjs +103 -103
- package/scripts/agent-eval/offload-eval-matrix.sh +20 -20
- package/scripts/agent-eval/offload-eval-metrics.mjs +94 -94
- package/scripts/agent-eval/offload-eval-refs1.sh +50 -50
- package/scripts/agent-eval/offload-eval-setup.sh +24 -24
- package/scripts/agent-eval/offload-eval-styles.sh +71 -71
- package/scripts/agent-eval/offload-eval-summarize.mjs +68 -68
- package/scripts/agent-eval/offload-eval.md +76 -76
- package/scripts/agent-eval/parse-arms.mjs +116 -116
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
- package/scripts/agent-eval/parse-run.mjs +45 -45
- package/scripts/agent-eval/parse-session.mjs +93 -93
- package/scripts/agent-eval/probe-context.mjs +21 -21
- package/scripts/agent-eval/probe-explore.mjs +40 -40
- package/scripts/agent-eval/probe-node.mjs +20 -20
- package/scripts/agent-eval/probe-sweep.mjs +119 -119
- package/scripts/agent-eval/probe-trace.mjs +20 -20
- package/scripts/agent-eval/redirect-read-hook.sh +38 -38
- package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
- package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
- package/scripts/agent-eval/run-agent.sh +34 -34
- package/scripts/agent-eval/run-all.sh +69 -69
- package/scripts/agent-eval/run-arms.sh +56 -56
- package/scripts/agent-eval/seq-matrix.mjs +137 -137
- package/scripts/build-bundle.sh +118 -118
- package/scripts/exp_boundary_eval/README.md +247 -0
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -0
- package/scripts/exp_boundary_eval/_test_stdin.py +8 -0
- package/scripts/exp_boundary_eval/_utils.py +1116 -0
- package/scripts/exp_boundary_eval/analyze.py +1313 -0
- package/scripts/exp_boundary_eval/data/agents.json +109 -0
- package/scripts/exp_boundary_eval/data/experiments.json +140 -0
- package/scripts/exp_boundary_eval/deveco_arm.py +519 -0
- package/scripts/exp_boundary_eval/run_all.py +378 -0
- package/scripts/exp_boundary_eval/run_one.py +165 -0
- package/scripts/exp_boundary_eval/run_session.py +158 -0
- package/scripts/exp_boundary_eval/setup.py +120 -0
- package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -0
- package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -0
- package/scripts/exp_boundary_eval/win_node_launcher.py +24 -0
- package/scripts/extract-release-notes.mjs +130 -130
- package/scripts/local-install.sh +41 -41
- package/scripts/npm-sdk.js +75 -75
- package/scripts/npm-shim.js +268 -246
- package/scripts/ohos-sdk-publish.mjs +133 -0
- package/scripts/pack-npm.sh +119 -119
- package/scripts/prepare-release.mjs +270 -270
- package/scripts/qa_eval/README.md +407 -404
- package/scripts/qa_eval/_test_deveco_probe.py +41 -41
- package/scripts/qa_eval/agent_runner.py +526 -526
- package/scripts/qa_eval/data/.gitignore +4 -4
- package/scripts/qa_eval/data/test-set.jsonl +2 -22
- package/scripts/qa_eval/eval_metrics.py +274 -233
- package/scripts/qa_eval/external_agent.py +976 -671
- package/scripts/qa_eval/llm_config.py +92 -92
- package/scripts/qa_eval/memory_monitor.py +132 -132
- package/scripts/qa_eval/my_answer_accuracy.py +187 -187
- package/scripts/qa_eval/requirements.txt +2 -2
- package/scripts/qa_eval/run_pipeline.py +804 -711
- package/scripts/qa_eval/stats_efficiency.py +279 -279
- package/scripts/qa_eval/stats_scores.py +207 -207
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# A/B the PreToolUse(Read) REDIRECT hook (P1): does steering Read → homegraph_node
|
|
3
|
-
# file-view actually move the agent off Read during implementation? BOTH arms use
|
|
4
|
-
# the CURRENT build with homegraph attached and pre-warmed; the only difference is
|
|
5
|
-
# the hook. Isolates the hook's behavioral effect from the build/file-view change
|
|
6
|
-
# (use ab-new-vs-baseline.sh for the build A/B).
|
|
7
|
-
#
|
|
8
|
-
# arm [nohook] — homegraph on, no hook (does the better file-view get picked on its own?)
|
|
9
|
-
# arm [hook] — homegraph on, + redirect hook (does routing close it?)
|
|
10
|
-
#
|
|
11
|
-
# Reliable attach (works nested): each arm pre-warms a persistent daemon and skips
|
|
12
|
-
# the startup re-exec (HOMEGRAPH_WASM_RELAUNCHED=1), so claude connects before the
|
|
13
|
-
# agent's first turn. Judge by ACTUAL homegraph usage in parse-run.mjs's "by type",
|
|
14
|
-
# not claude's init snapshot (which can read pending even when it then connects).
|
|
15
|
-
#
|
|
16
|
-
# Usage: ab-hook.sh <indexed-repo> "<implementation task>" [runs-per-arm]
|
|
17
|
-
# <indexed-repo> a repo with a .homegraph index (copied per arm; never mutated)
|
|
18
|
-
# "<task>" a GENUINELY-NEW implementation task (verify it isn't already done)
|
|
19
|
-
# [runs-per-arm] default 2 (n=1 is noisy — the doctrine says >=2)
|
|
20
|
-
# Env: AGENT_EVAL_OUT (default: /tmp/ab-hook)
|
|
21
|
-
set -uo pipefail
|
|
22
|
-
|
|
23
|
-
TARGET="${1:?usage: ab-hook.sh <indexed-repo> \"<task>\" [runs-per-arm]}"
|
|
24
|
-
TASK="${2:?task required}"
|
|
25
|
-
RUNS="${3:-2}"
|
|
26
|
-
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
27
|
-
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
28
|
-
HOOK="$ENGINE/scripts/agent-eval/redirect-read-hook.sh"
|
|
29
|
-
OUT="${AGENT_EVAL_OUT:-/tmp/ab-hook}"
|
|
30
|
-
PARSE="$ENGINE/scripts/agent-eval/parse-run.mjs"
|
|
31
|
-
|
|
32
|
-
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
33
|
-
command -v jq >/dev/null || { echo "jq not on PATH (the hook needs it)"; exit 1; }
|
|
34
|
-
[ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
|
|
35
|
-
chmod +x "$HOOK"
|
|
36
|
-
|
|
37
|
-
cleanup() { pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null; }
|
|
38
|
-
trap cleanup EXIT
|
|
39
|
-
|
|
40
|
-
mkdir -p "$OUT"
|
|
41
|
-
echo "###### engine=$ENGINE"
|
|
42
|
-
echo "###### target=$TARGET runs/arm=$RUNS"
|
|
43
|
-
echo "###### task=$TASK"
|
|
44
|
-
echo
|
|
45
|
-
|
|
46
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
|
|
47
|
-
|
|
48
|
-
# A settings file carrying ONLY the PreToolUse(Read) redirect hook.
|
|
49
|
-
HOOK_SETTINGS="$OUT/hook-settings.json"
|
|
50
|
-
jq -n --arg cmd "bash $HOOK" \
|
|
51
|
-
'{hooks:{PreToolUse:[{matcher:"Read",hooks:[{type:"command",command:$cmd}]}]}}' > "$HOOK_SETTINGS"
|
|
52
|
-
|
|
53
|
-
prewarm() { # target — spawn a persistent daemon and wait for its socket
|
|
54
|
-
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
55
|
-
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
56
|
-
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" \
|
|
57
|
-
&& echo " daemon warm: $1" || echo " WARN: daemon never bound for $1"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
run_one() { # arm-label, run-index, use-hook(0|1)
|
|
61
|
-
local label="$1" idx="$2" hook="$3"
|
|
62
|
-
local tgt="$OUT/t-$label-$idx" c="$OUT/mcp-$label.json"
|
|
63
|
-
rm -rf "$tgt"
|
|
64
|
-
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$tgt/"
|
|
65
|
-
node "$BIN" init "$tgt" >/dev/null 2>&1
|
|
66
|
-
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
|
|
67
|
-
prewarm "$tgt"
|
|
68
|
-
local extra=()
|
|
69
|
-
[ "$hook" = "1" ] && extra=(--settings "$HOOK_SETTINGS")
|
|
70
|
-
echo "----- [$label] run $idx -----"
|
|
71
|
-
# ${extra[@]+...} guard: bash 3.2 (macOS) under `set -u` errors on an empty
|
|
72
|
-
# array expansion otherwise, which would skip the no-hook arm's claude run.
|
|
73
|
-
( cd "$tgt" && claude -p "$TASK" \
|
|
74
|
-
--output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
75
|
-
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" ${extra[@]+"${extra[@]}"} \
|
|
76
|
-
</dev/null > "$OUT/run-$label-$idx.jsonl" 2>"$OUT/run-$label-$idx.err" )
|
|
77
|
-
node "$PARSE" "$OUT/run-$label-$idx.jsonl" 2>&1 | grep -E "by type|Result" || echo " (parse failed — see $OUT/run-$label-$idx.jsonl)"
|
|
78
|
-
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
79
|
-
echo
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
for i in $(seq 1 "$RUNS"); do run_one nohook "$i" 0; done
|
|
83
|
-
for i in $(seq 1 "$RUNS"); do run_one hook "$i" 1; done
|
|
84
|
-
|
|
85
|
-
echo "###### DONE. Compare [nohook] vs [hook] 'by type' — Read should fall and"
|
|
86
|
-
echo "###### mcp__homegraph__homegraph_node should rise in the [hook] arm. Logs: $OUT"
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# A/B the PreToolUse(Read) REDIRECT hook (P1): does steering Read → homegraph_node
|
|
3
|
+
# file-view actually move the agent off Read during implementation? BOTH arms use
|
|
4
|
+
# the CURRENT build with homegraph attached and pre-warmed; the only difference is
|
|
5
|
+
# the hook. Isolates the hook's behavioral effect from the build/file-view change
|
|
6
|
+
# (use ab-new-vs-baseline.sh for the build A/B).
|
|
7
|
+
#
|
|
8
|
+
# arm [nohook] — homegraph on, no hook (does the better file-view get picked on its own?)
|
|
9
|
+
# arm [hook] — homegraph on, + redirect hook (does routing close it?)
|
|
10
|
+
#
|
|
11
|
+
# Reliable attach (works nested): each arm pre-warms a persistent daemon and skips
|
|
12
|
+
# the startup re-exec (HOMEGRAPH_WASM_RELAUNCHED=1), so claude connects before the
|
|
13
|
+
# agent's first turn. Judge by ACTUAL homegraph usage in parse-run.mjs's "by type",
|
|
14
|
+
# not claude's init snapshot (which can read pending even when it then connects).
|
|
15
|
+
#
|
|
16
|
+
# Usage: ab-hook.sh <indexed-repo> "<implementation task>" [runs-per-arm]
|
|
17
|
+
# <indexed-repo> a repo with a .homegraph index (copied per arm; never mutated)
|
|
18
|
+
# "<task>" a GENUINELY-NEW implementation task (verify it isn't already done)
|
|
19
|
+
# [runs-per-arm] default 2 (n=1 is noisy — the doctrine says >=2)
|
|
20
|
+
# Env: AGENT_EVAL_OUT (default: /tmp/ab-hook)
|
|
21
|
+
set -uo pipefail
|
|
22
|
+
|
|
23
|
+
TARGET="${1:?usage: ab-hook.sh <indexed-repo> \"<task>\" [runs-per-arm]}"
|
|
24
|
+
TASK="${2:?task required}"
|
|
25
|
+
RUNS="${3:-2}"
|
|
26
|
+
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
27
|
+
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
28
|
+
HOOK="$ENGINE/scripts/agent-eval/redirect-read-hook.sh"
|
|
29
|
+
OUT="${AGENT_EVAL_OUT:-/tmp/ab-hook}"
|
|
30
|
+
PARSE="$ENGINE/scripts/agent-eval/parse-run.mjs"
|
|
31
|
+
|
|
32
|
+
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
33
|
+
command -v jq >/dev/null || { echo "jq not on PATH (the hook needs it)"; exit 1; }
|
|
34
|
+
[ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
|
|
35
|
+
chmod +x "$HOOK"
|
|
36
|
+
|
|
37
|
+
cleanup() { pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null; }
|
|
38
|
+
trap cleanup EXIT
|
|
39
|
+
|
|
40
|
+
mkdir -p "$OUT"
|
|
41
|
+
echo "###### engine=$ENGINE"
|
|
42
|
+
echo "###### target=$TARGET runs/arm=$RUNS"
|
|
43
|
+
echo "###### task=$TASK"
|
|
44
|
+
echo
|
|
45
|
+
|
|
46
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
|
|
47
|
+
|
|
48
|
+
# A settings file carrying ONLY the PreToolUse(Read) redirect hook.
|
|
49
|
+
HOOK_SETTINGS="$OUT/hook-settings.json"
|
|
50
|
+
jq -n --arg cmd "bash $HOOK" \
|
|
51
|
+
'{hooks:{PreToolUse:[{matcher:"Read",hooks:[{type:"command",command:$cmd}]}]}}' > "$HOOK_SETTINGS"
|
|
52
|
+
|
|
53
|
+
prewarm() { # target — spawn a persistent daemon and wait for its socket
|
|
54
|
+
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
55
|
+
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
56
|
+
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" \
|
|
57
|
+
&& echo " daemon warm: $1" || echo " WARN: daemon never bound for $1"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
run_one() { # arm-label, run-index, use-hook(0|1)
|
|
61
|
+
local label="$1" idx="$2" hook="$3"
|
|
62
|
+
local tgt="$OUT/t-$label-$idx" c="$OUT/mcp-$label.json"
|
|
63
|
+
rm -rf "$tgt"
|
|
64
|
+
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$tgt/"
|
|
65
|
+
node "$BIN" init "$tgt" >/dev/null 2>&1
|
|
66
|
+
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
|
|
67
|
+
prewarm "$tgt"
|
|
68
|
+
local extra=()
|
|
69
|
+
[ "$hook" = "1" ] && extra=(--settings "$HOOK_SETTINGS")
|
|
70
|
+
echo "----- [$label] run $idx -----"
|
|
71
|
+
# ${extra[@]+...} guard: bash 3.2 (macOS) under `set -u` errors on an empty
|
|
72
|
+
# array expansion otherwise, which would skip the no-hook arm's claude run.
|
|
73
|
+
( cd "$tgt" && claude -p "$TASK" \
|
|
74
|
+
--output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
75
|
+
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" ${extra[@]+"${extra[@]}"} \
|
|
76
|
+
</dev/null > "$OUT/run-$label-$idx.jsonl" 2>"$OUT/run-$label-$idx.err" )
|
|
77
|
+
node "$PARSE" "$OUT/run-$label-$idx.jsonl" 2>&1 | grep -E "by type|Result" || echo " (parse failed — see $OUT/run-$label-$idx.jsonl)"
|
|
78
|
+
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
79
|
+
echo
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for i in $(seq 1 "$RUNS"); do run_one nohook "$i" 0; done
|
|
83
|
+
for i in $(seq 1 "$RUNS"); do run_one hook "$i" 1; done
|
|
84
|
+
|
|
85
|
+
echo "###### DONE. Compare [nohook] vs [hook] 'by type' — Read should fall and"
|
|
86
|
+
echo "###### mcp__homegraph__homegraph_node should rise in the [hook] arm. Logs: $OUT"
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Sufficiency A/B for an IMPLEMENTATION task (the agent edits): when it uses
|
|
3
|
-
# homegraph (explore/node) to understand before editing, does it still Read? Like
|
|
4
|
-
# ab-sufficiency.sh but copies+indexes a FRESH target per run (the agent mutates
|
|
5
|
-
# it), so runs don't see each other's edits.
|
|
6
|
-
#
|
|
7
|
-
# WITH homegraph (pre-warmed) vs WITHOUT (empty MCP), N runs each. Reports
|
|
8
|
-
# explore/node vs Read/Grep + the files Read, and whether the build still passes.
|
|
9
|
-
#
|
|
10
|
-
# Usage: ab-impl.sh <indexed-repo> "<task>" [runs] [build-cmd]
|
|
11
|
-
# Env: AGENT_EVAL_OUT (default: /tmp/ab-impl)
|
|
12
|
-
set -uo pipefail
|
|
13
|
-
REPO="${1:?usage: ab-impl.sh <indexed-repo> \"<task>\" [runs] [build-cmd]}"
|
|
14
|
-
Q="${2:?task required}"
|
|
15
|
-
RUNS="${3:-2}"
|
|
16
|
-
BUILD_CMD="${4:-}"
|
|
17
|
-
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
18
|
-
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
19
|
-
OUT="${AGENT_EVAL_OUT:-/tmp/ab-impl}"
|
|
20
|
-
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
21
|
-
[ -d "$REPO/.homegraph" ] || { echo "no .homegraph index at $REPO"; exit 1; }
|
|
22
|
-
cleanup(){ pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null; }
|
|
23
|
-
trap cleanup EXIT
|
|
24
|
-
mkdir -p "$OUT"
|
|
25
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built engine"
|
|
26
|
-
echo "###### repo=$REPO runs/arm=$RUNS"
|
|
27
|
-
echo "###### task=$Q"; echo
|
|
28
|
-
echo '{"mcpServers":{}}' > "$OUT/mcp-empty.json"
|
|
29
|
-
|
|
30
|
-
prewarm(){
|
|
31
|
-
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
32
|
-
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
33
|
-
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" >/dev/null 2>&1
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
analyze(){
|
|
37
|
-
node -e '
|
|
38
|
-
const fs=require("fs");
|
|
39
|
-
const L=fs.readFileSync(process.argv[1],"utf8").split("\n").filter(Boolean);
|
|
40
|
-
let ex=0,nf=0,ns=0,oc=0,gr=0,ed=0,exposed="?";const reads=[];
|
|
41
|
-
for(const l of L){try{const o=JSON.parse(l);
|
|
42
|
-
if(o.type==="system"&&o.subtype==="init")exposed=(o.tools||[]).filter(t=>/homegraph/.test(t)).length;
|
|
43
|
-
for(const b of (o.message?.content||[])){if(b.type!=="tool_use")continue;
|
|
44
|
-
if(b.name==="mcp__homegraph__homegraph_explore")ex++;
|
|
45
|
-
else if(b.name==="mcp__homegraph__homegraph_node"){if(b.input&&b.input.symbol)ns++;else nf++;}
|
|
46
|
-
else if(/mcp__homegraph__/.test(b.name))oc++;
|
|
47
|
-
else if(b.name==="Read")reads.push((b.input?.file_path||"").split("/").pop());
|
|
48
|
-
else if(b.name==="Grep")gr++;
|
|
49
|
-
else if(b.name==="Edit"||b.name==="Write")ed++;
|
|
50
|
-
}}catch{}}
|
|
51
|
-
console.log(` explore=${ex} node[sym]=${ns} node[file]=${nf} other_cg=${oc} | Read=${reads.length}${reads.length?" ("+reads.join(", ")+")":""} Grep=${gr} Edit=${ed} [cg exposed=${exposed}]`);
|
|
52
|
-
' "$1"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
run(){ # label, withCodegraph(0/1)
|
|
56
|
-
local label="$1" wcg="$2"
|
|
57
|
-
for i in $(seq 1 "$RUNS"); do
|
|
58
|
-
local tgt="$OUT/t-$label-$i" cfg="$OUT/mcp-$label.json"
|
|
59
|
-
rm -rf "$tgt"
|
|
60
|
-
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$REPO/" "$tgt/"
|
|
61
|
-
node "$BIN" init "$tgt" >/dev/null 2>&1
|
|
62
|
-
if [ "$wcg" = "1" ]; then
|
|
63
|
-
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$cfg"
|
|
64
|
-
prewarm "$tgt"
|
|
65
|
-
else cp "$OUT/mcp-empty.json" "$cfg"; fi
|
|
66
|
-
( cd "$tgt" && claude -p "$Q" --output-format stream-json --verbose \
|
|
67
|
-
--permission-mode bypassPermissions --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
|
|
68
|
-
--strict-mcp-config --mcp-config "$cfg" </dev/null > "$OUT/$label-$i.jsonl" 2>"$OUT/$label-$i.err" )
|
|
69
|
-
echo "[$label] run $i:"; analyze "$OUT/$label-$i.jsonl"
|
|
70
|
-
if [ -n "$BUILD_CMD" ]; then ( cd "$tgt" && eval "$BUILD_CMD" >/dev/null 2>&1 && echo " build: PASS" || echo " build: FAIL" ); fi
|
|
71
|
-
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
72
|
-
done
|
|
73
|
-
echo
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
echo "== WITH homegraph =="; run with 1
|
|
77
|
-
echo "== WITHOUT (Read/Grep only) =="; run without 0
|
|
78
|
-
echo "###### DONE: $OUT"
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Sufficiency A/B for an IMPLEMENTATION task (the agent edits): when it uses
|
|
3
|
+
# homegraph (explore/node) to understand before editing, does it still Read? Like
|
|
4
|
+
# ab-sufficiency.sh but copies+indexes a FRESH target per run (the agent mutates
|
|
5
|
+
# it), so runs don't see each other's edits.
|
|
6
|
+
#
|
|
7
|
+
# WITH homegraph (pre-warmed) vs WITHOUT (empty MCP), N runs each. Reports
|
|
8
|
+
# explore/node vs Read/Grep + the files Read, and whether the build still passes.
|
|
9
|
+
#
|
|
10
|
+
# Usage: ab-impl.sh <indexed-repo> "<task>" [runs] [build-cmd]
|
|
11
|
+
# Env: AGENT_EVAL_OUT (default: /tmp/ab-impl)
|
|
12
|
+
set -uo pipefail
|
|
13
|
+
REPO="${1:?usage: ab-impl.sh <indexed-repo> \"<task>\" [runs] [build-cmd]}"
|
|
14
|
+
Q="${2:?task required}"
|
|
15
|
+
RUNS="${3:-2}"
|
|
16
|
+
BUILD_CMD="${4:-}"
|
|
17
|
+
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
18
|
+
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
19
|
+
OUT="${AGENT_EVAL_OUT:-/tmp/ab-impl}"
|
|
20
|
+
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
21
|
+
[ -d "$REPO/.homegraph" ] || { echo "no .homegraph index at $REPO"; exit 1; }
|
|
22
|
+
cleanup(){ pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null; }
|
|
23
|
+
trap cleanup EXIT
|
|
24
|
+
mkdir -p "$OUT"
|
|
25
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built engine"
|
|
26
|
+
echo "###### repo=$REPO runs/arm=$RUNS"
|
|
27
|
+
echo "###### task=$Q"; echo
|
|
28
|
+
echo '{"mcpServers":{}}' > "$OUT/mcp-empty.json"
|
|
29
|
+
|
|
30
|
+
prewarm(){
|
|
31
|
+
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
32
|
+
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
33
|
+
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" >/dev/null 2>&1
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
analyze(){
|
|
37
|
+
node -e '
|
|
38
|
+
const fs=require("fs");
|
|
39
|
+
const L=fs.readFileSync(process.argv[1],"utf8").split("\n").filter(Boolean);
|
|
40
|
+
let ex=0,nf=0,ns=0,oc=0,gr=0,ed=0,exposed="?";const reads=[];
|
|
41
|
+
for(const l of L){try{const o=JSON.parse(l);
|
|
42
|
+
if(o.type==="system"&&o.subtype==="init")exposed=(o.tools||[]).filter(t=>/homegraph/.test(t)).length;
|
|
43
|
+
for(const b of (o.message?.content||[])){if(b.type!=="tool_use")continue;
|
|
44
|
+
if(b.name==="mcp__homegraph__homegraph_explore")ex++;
|
|
45
|
+
else if(b.name==="mcp__homegraph__homegraph_node"){if(b.input&&b.input.symbol)ns++;else nf++;}
|
|
46
|
+
else if(/mcp__homegraph__/.test(b.name))oc++;
|
|
47
|
+
else if(b.name==="Read")reads.push((b.input?.file_path||"").split("/").pop());
|
|
48
|
+
else if(b.name==="Grep")gr++;
|
|
49
|
+
else if(b.name==="Edit"||b.name==="Write")ed++;
|
|
50
|
+
}}catch{}}
|
|
51
|
+
console.log(` explore=${ex} node[sym]=${ns} node[file]=${nf} other_cg=${oc} | Read=${reads.length}${reads.length?" ("+reads.join(", ")+")":""} Grep=${gr} Edit=${ed} [cg exposed=${exposed}]`);
|
|
52
|
+
' "$1"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
run(){ # label, withCodegraph(0/1)
|
|
56
|
+
local label="$1" wcg="$2"
|
|
57
|
+
for i in $(seq 1 "$RUNS"); do
|
|
58
|
+
local tgt="$OUT/t-$label-$i" cfg="$OUT/mcp-$label.json"
|
|
59
|
+
rm -rf "$tgt"
|
|
60
|
+
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$REPO/" "$tgt/"
|
|
61
|
+
node "$BIN" init "$tgt" >/dev/null 2>&1
|
|
62
|
+
if [ "$wcg" = "1" ]; then
|
|
63
|
+
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$cfg"
|
|
64
|
+
prewarm "$tgt"
|
|
65
|
+
else cp "$OUT/mcp-empty.json" "$cfg"; fi
|
|
66
|
+
( cd "$tgt" && claude -p "$Q" --output-format stream-json --verbose \
|
|
67
|
+
--permission-mode bypassPermissions --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
|
|
68
|
+
--strict-mcp-config --mcp-config "$cfg" </dev/null > "$OUT/$label-$i.jsonl" 2>"$OUT/$label-$i.err" )
|
|
69
|
+
echo "[$label] run $i:"; analyze "$OUT/$label-$i.jsonl"
|
|
70
|
+
if [ -n "$BUILD_CMD" ]; then ( cd "$tgt" && eval "$BUILD_CMD" >/dev/null 2>&1 && echo " build: PASS" || echo " build: FAIL" ); fi
|
|
71
|
+
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
72
|
+
done
|
|
73
|
+
echo
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
echo "== WITH homegraph =="; run with 1
|
|
77
|
+
echo "== WITHOUT (Read/Grep only) =="; run without 0
|
|
78
|
+
echo "###### DONE: $OUT"
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# A/B a homegraph retrieval/steering change: the NEW build (current HEAD) vs a
|
|
3
|
-
# BASELINE build (a git ref) — BOTH with homegraph attached — on the same
|
|
4
|
-
# implementation task, measuring how many Read vs homegraph calls the agent
|
|
5
|
-
# makes. ISOLATES the change (unlike run-all.sh's with-vs-without). The agent
|
|
6
|
-
# works on a throwaway copy of the target, so your repos are never touched.
|
|
7
|
-
#
|
|
8
|
-
# Reliable attach (works even when this is itself run nested inside a Claude
|
|
9
|
-
# session): each arm PRE-WARMS a persistent homegraph daemon for its target so
|
|
10
|
-
# claude connects to an already-bound, index-loaded daemon instantly — before
|
|
11
|
-
# the agent's first turn — and SKIPS homegraph's startup re-exec via
|
|
12
|
-
# HOMEGRAPH_WASM_RELAUNCHED=1. Without this, on a multi-step task the agent
|
|
13
|
-
# dives into Read/grep before homegraph finishes its ~2-3s startup (worse under
|
|
14
|
-
# the CPU contention of a nested run) and runs with NO homegraph.
|
|
15
|
-
#
|
|
16
|
-
# Gotcha: claude's `system/init` snapshot can read status:"pending" / 0 tools
|
|
17
|
-
# even when the server then connects fine — judge by ACTUAL homegraph usage in
|
|
18
|
-
# parse-run.mjs's "by type", not the init line.
|
|
19
|
-
#
|
|
20
|
-
# Usage: ab-new-vs-baseline.sh <indexed-repo> "<task>" [baseline-ref]
|
|
21
|
-
# <indexed-repo> a repo with a .homegraph index (copied per arm)
|
|
22
|
-
# "<task>" an implementation task, e.g. "Add X to Y and wire it through"
|
|
23
|
-
# [baseline-ref] git ref for the BEFORE build (default: HEAD~1)
|
|
24
|
-
# Env: AGENT_EVAL_OUT (default: /tmp/ab-new-vs-baseline)
|
|
25
|
-
set -uo pipefail
|
|
26
|
-
|
|
27
|
-
TARGET="${1:?usage: ab-new-vs-baseline.sh <indexed-repo> \"<task>\" [baseline-ref]}"
|
|
28
|
-
TASK="${2:?task required}"
|
|
29
|
-
BASE_REF="${3:-HEAD~1}"
|
|
30
|
-
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
31
|
-
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
32
|
-
OUT="${AGENT_EVAL_OUT:-/tmp/ab-new-vs-baseline}"
|
|
33
|
-
PARSE="$ENGINE/scripts/agent-eval/parse-run.mjs"
|
|
34
|
-
|
|
35
|
-
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
36
|
-
[ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
|
|
37
|
-
if ! git -C "$ENGINE" diff --quiet || ! git -C "$ENGINE" diff --cached --quiet; then
|
|
38
|
-
echo "engine repo has uncommitted changes — commit or stash first (this script checks files out)"; exit 1
|
|
39
|
-
fi
|
|
40
|
-
CHANGED=$(git -C "$ENGINE" diff --name-only "$BASE_REF" HEAD -- src 2>/dev/null)
|
|
41
|
-
[ -n "$CHANGED" ] || { echo "no src/ changes between $BASE_REF and HEAD — nothing to A/B"; exit 1; }
|
|
42
|
-
|
|
43
|
-
# On exit: kill any eval daemons + restore the engine to HEAD.
|
|
44
|
-
cleanup() {
|
|
45
|
-
pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null
|
|
46
|
-
git -C "$ENGINE" checkout HEAD -- $CHANGED 2>/dev/null
|
|
47
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 )
|
|
48
|
-
}
|
|
49
|
-
trap cleanup EXIT
|
|
50
|
-
|
|
51
|
-
mkdir -p "$OUT"
|
|
52
|
-
echo "###### engine=$ENGINE baseline=$BASE_REF"
|
|
53
|
-
echo "###### changed: $(echo "$CHANGED" | tr '\n' ' ')"
|
|
54
|
-
echo "###### target=$TARGET"
|
|
55
|
-
echo "###### task=$TASK"
|
|
56
|
-
echo
|
|
57
|
-
|
|
58
|
-
# Two pristine copies so each arm starts clean (the agent edits its own copy).
|
|
59
|
-
rm -rf "$OUT/t-new" "$OUT/t-base"
|
|
60
|
-
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$OUT/t-new/"
|
|
61
|
-
cp -R "$OUT/t-new" "$OUT/t-base"
|
|
62
|
-
|
|
63
|
-
prewarm() { # target — spawn a persistent daemon (current $BIN) and wait for its socket
|
|
64
|
-
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
65
|
-
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
66
|
-
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" \
|
|
67
|
-
&& echo " daemon warm: $1" || echo " WARN: daemon never bound for $1 (arm may run without homegraph)"
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
run_arm() { # label, target-copy
|
|
71
|
-
local label="$1" tgt="$2" c="$OUT/mcp-$1.json"
|
|
72
|
-
# Connect to the pre-warmed daemon; skip the startup re-exec for a fast attach.
|
|
73
|
-
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
|
|
74
|
-
prewarm "$tgt"
|
|
75
|
-
echo "############## ARM [$label] ##############"
|
|
76
|
-
( cd "$tgt" && claude -p "$TASK" \
|
|
77
|
-
--output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
78
|
-
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" \
|
|
79
|
-
</dev/null > "$OUT/run-$label.jsonl" 2>"$OUT/run-$label.err" )
|
|
80
|
-
node "$PARSE" "$OUT/run-$label.jsonl" 2>&1 | grep -E "by type|Result" || echo " (parse failed — see $OUT/run-$label.jsonl)"
|
|
81
|
-
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
82
|
-
echo
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
echo "== NEW build (HEAD) =="
|
|
86
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo " built"
|
|
87
|
-
node "$BIN" init "$OUT/t-new" >/dev/null 2>&1 && echo " indexed t-new"
|
|
88
|
-
run_arm new "$OUT/t-new"
|
|
89
|
-
|
|
90
|
-
echo "== BASELINE build ($BASE_REF) =="
|
|
91
|
-
# Per-file: a file ADDED since baseline has no pathspec on the ref — and a
|
|
92
|
-
# single multi-file checkout with one bad pathspec checks out NOTHING, which
|
|
93
|
-
# silently ran the NEW build in the baseline arm. Absent-on-baseline → remove.
|
|
94
|
-
for f in $CHANGED; do
|
|
95
|
-
git -C "$ENGINE" checkout "$BASE_REF" -- "$f" 2>/dev/null || rm -f "$ENGINE/$f"
|
|
96
|
-
done
|
|
97
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo " built"
|
|
98
|
-
node "$BIN" init "$OUT/t-base" >/dev/null 2>&1 && echo " indexed t-base"
|
|
99
|
-
run_arm baseline "$OUT/t-base"
|
|
100
|
-
|
|
101
|
-
echo "###### DONE. Compare the [new] vs [baseline] 'by type' counts above"
|
|
102
|
-
echo "###### (especially Read vs mcp__homegraph__*). Full logs in: $OUT"
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# A/B a homegraph retrieval/steering change: the NEW build (current HEAD) vs a
|
|
3
|
+
# BASELINE build (a git ref) — BOTH with homegraph attached — on the same
|
|
4
|
+
# implementation task, measuring how many Read vs homegraph calls the agent
|
|
5
|
+
# makes. ISOLATES the change (unlike run-all.sh's with-vs-without). The agent
|
|
6
|
+
# works on a throwaway copy of the target, so your repos are never touched.
|
|
7
|
+
#
|
|
8
|
+
# Reliable attach (works even when this is itself run nested inside a Claude
|
|
9
|
+
# session): each arm PRE-WARMS a persistent homegraph daemon for its target so
|
|
10
|
+
# claude connects to an already-bound, index-loaded daemon instantly — before
|
|
11
|
+
# the agent's first turn — and SKIPS homegraph's startup re-exec via
|
|
12
|
+
# HOMEGRAPH_WASM_RELAUNCHED=1. Without this, on a multi-step task the agent
|
|
13
|
+
# dives into Read/grep before homegraph finishes its ~2-3s startup (worse under
|
|
14
|
+
# the CPU contention of a nested run) and runs with NO homegraph.
|
|
15
|
+
#
|
|
16
|
+
# Gotcha: claude's `system/init` snapshot can read status:"pending" / 0 tools
|
|
17
|
+
# even when the server then connects fine — judge by ACTUAL homegraph usage in
|
|
18
|
+
# parse-run.mjs's "by type", not the init line.
|
|
19
|
+
#
|
|
20
|
+
# Usage: ab-new-vs-baseline.sh <indexed-repo> "<task>" [baseline-ref]
|
|
21
|
+
# <indexed-repo> a repo with a .homegraph index (copied per arm)
|
|
22
|
+
# "<task>" an implementation task, e.g. "Add X to Y and wire it through"
|
|
23
|
+
# [baseline-ref] git ref for the BEFORE build (default: HEAD~1)
|
|
24
|
+
# Env: AGENT_EVAL_OUT (default: /tmp/ab-new-vs-baseline)
|
|
25
|
+
set -uo pipefail
|
|
26
|
+
|
|
27
|
+
TARGET="${1:?usage: ab-new-vs-baseline.sh <indexed-repo> \"<task>\" [baseline-ref]}"
|
|
28
|
+
TASK="${2:?task required}"
|
|
29
|
+
BASE_REF="${3:-HEAD~1}"
|
|
30
|
+
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
31
|
+
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
32
|
+
OUT="${AGENT_EVAL_OUT:-/tmp/ab-new-vs-baseline}"
|
|
33
|
+
PARSE="$ENGINE/scripts/agent-eval/parse-run.mjs"
|
|
34
|
+
|
|
35
|
+
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
36
|
+
[ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
|
|
37
|
+
if ! git -C "$ENGINE" diff --quiet || ! git -C "$ENGINE" diff --cached --quiet; then
|
|
38
|
+
echo "engine repo has uncommitted changes — commit or stash first (this script checks files out)"; exit 1
|
|
39
|
+
fi
|
|
40
|
+
CHANGED=$(git -C "$ENGINE" diff --name-only "$BASE_REF" HEAD -- src 2>/dev/null)
|
|
41
|
+
[ -n "$CHANGED" ] || { echo "no src/ changes between $BASE_REF and HEAD — nothing to A/B"; exit 1; }
|
|
42
|
+
|
|
43
|
+
# On exit: kill any eval daemons + restore the engine to HEAD.
|
|
44
|
+
cleanup() {
|
|
45
|
+
pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null
|
|
46
|
+
git -C "$ENGINE" checkout HEAD -- $CHANGED 2>/dev/null
|
|
47
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 )
|
|
48
|
+
}
|
|
49
|
+
trap cleanup EXIT
|
|
50
|
+
|
|
51
|
+
mkdir -p "$OUT"
|
|
52
|
+
echo "###### engine=$ENGINE baseline=$BASE_REF"
|
|
53
|
+
echo "###### changed: $(echo "$CHANGED" | tr '\n' ' ')"
|
|
54
|
+
echo "###### target=$TARGET"
|
|
55
|
+
echo "###### task=$TASK"
|
|
56
|
+
echo
|
|
57
|
+
|
|
58
|
+
# Two pristine copies so each arm starts clean (the agent edits its own copy).
|
|
59
|
+
rm -rf "$OUT/t-new" "$OUT/t-base"
|
|
60
|
+
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$OUT/t-new/"
|
|
61
|
+
cp -R "$OUT/t-new" "$OUT/t-base"
|
|
62
|
+
|
|
63
|
+
prewarm() { # target — spawn a persistent daemon (current $BIN) and wait for its socket
|
|
64
|
+
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
65
|
+
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
66
|
+
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" \
|
|
67
|
+
&& echo " daemon warm: $1" || echo " WARN: daemon never bound for $1 (arm may run without homegraph)"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
run_arm() { # label, target-copy
|
|
71
|
+
local label="$1" tgt="$2" c="$OUT/mcp-$1.json"
|
|
72
|
+
# Connect to the pre-warmed daemon; skip the startup re-exec for a fast attach.
|
|
73
|
+
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
|
|
74
|
+
prewarm "$tgt"
|
|
75
|
+
echo "############## ARM [$label] ##############"
|
|
76
|
+
( cd "$tgt" && claude -p "$TASK" \
|
|
77
|
+
--output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
78
|
+
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" \
|
|
79
|
+
</dev/null > "$OUT/run-$label.jsonl" 2>"$OUT/run-$label.err" )
|
|
80
|
+
node "$PARSE" "$OUT/run-$label.jsonl" 2>&1 | grep -E "by type|Result" || echo " (parse failed — see $OUT/run-$label.jsonl)"
|
|
81
|
+
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
82
|
+
echo
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
echo "== NEW build (HEAD) =="
|
|
86
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo " built"
|
|
87
|
+
node "$BIN" init "$OUT/t-new" >/dev/null 2>&1 && echo " indexed t-new"
|
|
88
|
+
run_arm new "$OUT/t-new"
|
|
89
|
+
|
|
90
|
+
echo "== BASELINE build ($BASE_REF) =="
|
|
91
|
+
# Per-file: a file ADDED since baseline has no pathspec on the ref — and a
|
|
92
|
+
# single multi-file checkout with one bad pathspec checks out NOTHING, which
|
|
93
|
+
# silently ran the NEW build in the baseline arm. Absent-on-baseline → remove.
|
|
94
|
+
for f in $CHANGED; do
|
|
95
|
+
git -C "$ENGINE" checkout "$BASE_REF" -- "$f" 2>/dev/null || rm -f "$ENGINE/$f"
|
|
96
|
+
done
|
|
97
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo " built"
|
|
98
|
+
node "$BIN" init "$OUT/t-base" >/dev/null 2>&1 && echo " indexed t-base"
|
|
99
|
+
run_arm baseline "$OUT/t-base"
|
|
100
|
+
|
|
101
|
+
echo "###### DONE. Compare the [new] vs [baseline] 'by type' counts above"
|
|
102
|
+
echo "###### (especially Read vs mcp__homegraph__*). Full logs in: $OUT"
|