homegraph 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +305 -305
- package/dist/bin/command-supervision.d.ts.map +1 -1
- package/dist/bin/command-supervision.js +7 -4
- package/dist/bin/command-supervision.js.map +1 -1
- package/dist/bin/homegraph.js +9 -9
- package/dist/db/index.js +36 -36
- package/dist/db/migrations.js +37 -37
- package/dist/db/queries.js +156 -156
- package/dist/db/schema.sql +203 -203
- package/dist/directory.js +5 -5
- package/dist/extraction/languages/arkts-viewtree.d.ts +2 -4
- package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
- package/dist/extraction/languages/arkts-viewtree.js +6 -21
- package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
- package/dist/extraction/languages/arkts.d.ts +16 -6
- package/dist/extraction/languages/arkts.d.ts.map +1 -1
- package/dist/extraction/languages/arkts.js +174 -21
- package/dist/extraction/languages/arkts.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/dist/installer/instructions-template.js +9 -9
- package/dist/mcp/liveness-watchdog.d.ts +18 -0
- package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/dist/mcp/liveness-watchdog.js +185 -73
- package/dist/mcp/liveness-watchdog.js.map +1 -1
- package/dist/mcp/server-instructions.js +47 -47
- package/dist/reasoning/reasoner.js +32 -32
- package/dist/spec/db/commit-node.js +4 -4
- package/dist/spec/db/fragment-node.js +10 -10
- package/dist/spec/db/fts.js +8 -8
- package/dist/spec/db/relations.js +88 -88
- package/dist/spec/db/schema.js +6 -6
- package/dist/spec/db/schema.sql +121 -121
- package/dist/spec/db/spec-node.js +4 -4
- package/dist/spec/llm/prompts.js +53 -53
- package/dist/spec/utils.d.ts +16 -4
- package/dist/spec/utils.d.ts.map +1 -1
- package/dist/spec/utils.js +58 -6
- package/dist/spec/utils.js.map +1 -1
- package/package.json +62 -62
- package/scripts/_tmp-cfwk-resolve.log +0 -0
- package/scripts/_tmp-cfwk-sig.log +0 -0
- package/scripts/_tmp-cfwk-vt.log +0 -0
- 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 -119
- package/scripts/agent-eval/repro-daemon-clients.mjs +125 -125
- package/scripts/agent-eval/run-agent.sh +34 -34
- package/scripts/agent-eval/run-all.sh +75 -75
- package/scripts/agent-eval/run-arms.sh +56 -56
- package/scripts/agent-eval/seq-matrix.mjs +137 -137
- package/scripts/bench-arkts-init-rss.log +0 -0
- package/scripts/build-bundle.sh +123 -123
- package/scripts/exp_boundary_eval/README.md +247 -247
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/win_mcp_launcher.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -78
- package/scripts/exp_boundary_eval/_test_stdin.py +8 -8
- package/scripts/exp_boundary_eval/_utils.py +1116 -1116
- package/scripts/exp_boundary_eval/analyze.py +1313 -1313
- package/scripts/exp_boundary_eval/deveco_arm.py +519 -519
- package/scripts/exp_boundary_eval/run_all.py +378 -378
- package/scripts/exp_boundary_eval/run_one.py +165 -165
- package/scripts/exp_boundary_eval/run_session.py +158 -158
- package/scripts/exp_boundary_eval/setup.py +120 -120
- package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -73
- package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -36
- package/scripts/exp_boundary_eval/win_node_launcher.py +24 -24
- 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 +275 -275
- package/scripts/ohos-sdk-publish.mjs +133 -133
- package/scripts/pack-npm.sh +119 -119
- package/scripts/prepare-release.mjs +270 -270
- package/scripts/probe-arkts-mem-why-run.log +0 -0
- package/scripts/probe-banner-livecard-ir.log +0 -0
- package/scripts/probe-cfwk-ast.stderr.log +0 -0
- package/scripts/probe-cfwk-ast.stdout.log +0 -0
- package/scripts/probe-cfwk-attr-shape.log +0 -0
- package/scripts/probe-cfwk-cfgdump.stderr.log +0 -0
- package/scripts/probe-cfwk-cfgdump.stdout.log +0 -0
- package/scripts/probe-cfwk-cvc.stderr.log +0 -0
- package/scripts/probe-cfwk-cvc.stdout.log +0 -0
- package/scripts/probe-cfwk-diag2.log +0 -0
- package/scripts/probe-cfwk-diag3.log +0 -0
- package/scripts/probe-cfwk-fedbg.stderr.log +0 -0
- package/scripts/probe-cfwk-fedbg.stdout.log +0 -0
- package/scripts/probe-cfwk-fileresult.log +0 -0
- package/scripts/probe-cfwk-fix.stderr.log +0 -0
- package/scripts/probe-cfwk-fix.stdout.log +0 -0
- package/scripts/probe-cfwk-fix2.stderr.log +0 -0
- package/scripts/probe-cfwk-fix2.stdout.log +0 -0
- package/scripts/probe-cfwk-fix3.stderr.log +0 -0
- package/scripts/probe-cfwk-fix3.stdout.log +0 -0
- package/scripts/probe-cfwk-foreach.log +0 -0
- package/scripts/probe-cfwk-getmethod-throw.log +0 -0
- package/scripts/probe-cfwk-hg-extract.log +0 -0
- package/scripts/probe-cfwk-pr1003-noprior.stderr.log +0 -0
- package/scripts/probe-cfwk-pr1003-noprior.stdout.log +0 -0
- package/scripts/probe-cfwk-pr1003.stderr.log +0 -0
- package/scripts/probe-cfwk-pr1003.stdout.log +0 -0
- package/scripts/probe-cfwk-preroot-noprior.stderr.log +0 -0
- package/scripts/probe-cfwk-preroot-noprior.stdout.log +0 -0
- package/scripts/probe-cfwk-preroot-prior.stderr.log +0 -0
- package/scripts/probe-cfwk-preroot-prior.stdout.log +0 -0
- package/scripts/probe-cfwk-preroot-skipstate.stderr.log +0 -0
- package/scripts/probe-cfwk-preroot-skipstate.stdout.log +0 -0
- package/scripts/probe-cfwk-resolve-sim.log +0 -0
- package/scripts/probe-cfwk-tree-shape.log +0 -0
- package/scripts/probe-cfwk-walk-abort.log +0 -0
- package/scripts/probe-cfwk.log +0 -0
- package/scripts/probe-force-index.log +0 -0
- package/scripts/probe-no-force-index.log +0 -0
- package/scripts/probe-samefile-ir.stderr.log +0 -0
- package/scripts/probe-samefile-ir.stdout.log +224 -0
- package/scripts/probe-sdk-vs-project.log +0 -0
- package/scripts/probe-viewtree-downgrade.log +0 -0
- package/dist/arkts/ohos-api-index.d.ts +0 -15
- package/dist/arkts/ohos-api-index.d.ts.map +0 -1
- package/dist/arkts/ohos-api-index.js +0 -190
- package/dist/arkts/ohos-api-index.js.map +0 -1
- package/dist/arkts/ohos-sdk-input.d.ts +0 -36
- package/dist/arkts/ohos-sdk-input.d.ts.map +0 -1
- package/dist/arkts/ohos-sdk-input.js +0 -214
- package/dist/arkts/ohos-sdk-input.js.map +0 -1
- package/dist/extraction/languages/arkts-state-decorators.d.ts +0 -13
- package/dist/extraction/languages/arkts-state-decorators.d.ts.map +0 -1
- package/dist/extraction/languages/arkts-state-decorators.js +0 -26
- package/dist/extraction/languages/arkts-state-decorators.js.map +0 -1
- package/dist/extraction/languages/ohos-api-consumer.d.ts +0 -34
- package/dist/extraction/languages/ohos-api-consumer.d.ts.map +0 -1
- package/dist/extraction/languages/ohos-api-consumer.js +0 -283
- package/dist/extraction/languages/ohos-api-consumer.js.map +0 -1
- package/dist/spec/build/git-scanner.d.ts +0 -93
- package/dist/spec/build/git-scanner.d.ts.map +0 -1
- package/dist/spec/build/git-scanner.js +0 -254
- package/dist/spec/build/git-scanner.js.map +0 -1
- package/dist/spec/git-utils.d.ts +0 -8
- package/dist/spec/git-utils.d.ts.map +0 -1
- package/dist/spec/git-utils.js +0 -14
- package/dist/spec/git-utils.js.map +0 -1
- package/dist/spec/mine/clusterer.d.ts +0 -63
- package/dist/spec/mine/clusterer.d.ts.map +0 -1
- package/dist/spec/mine/clusterer.js +0 -904
- package/dist/spec/mine/clusterer.js.map +0 -1
- package/dist/spec/mine/progress-handler.d.ts +0 -22
- package/dist/spec/mine/progress-handler.d.ts.map +0 -1
- package/dist/spec/mine/progress-handler.js +0 -108
- package/dist/spec/mine/progress-handler.js.map +0 -1
- package/dist/spec/mine/progress.d.ts +0 -23
- package/dist/spec/mine/progress.d.ts.map +0 -1
- package/dist/spec/mine/progress.js +0 -12
- package/dist/spec/mine/progress.js.map +0 -1
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Does the agent PICK homegraph_node to read a file, vs the built-in Read tool?
|
|
3
|
-
# Build A/B: NEW build (HEAD, homegraph_node has Read parity) vs BASELINE build
|
|
4
|
-
# (a ref where it doesn't), BOTH homegraph-attached + pre-warmed, same task. The
|
|
5
|
-
# metric is tool CHOICE: Read calls vs homegraph_node[file] calls per run.
|
|
6
|
-
#
|
|
7
|
-
# Usage: ab-adoption.sh <indexed-repo> "<task>" [runs-per-arm] [baseline-ref]
|
|
8
|
-
# Env: AGENT_EVAL_OUT (default: /tmp/ab-adoption)
|
|
9
|
-
set -uo pipefail
|
|
10
|
-
TARGET="${1:?usage: ab-adoption.sh <indexed-repo> \"<task>\" [runs] [baseline-ref]}"
|
|
11
|
-
TASK="${2:?task required}"
|
|
12
|
-
RUNS="${3:-2}"
|
|
13
|
-
BASE_REF="${4:-HEAD~1}"
|
|
14
|
-
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
15
|
-
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
16
|
-
OUT="${AGENT_EVAL_OUT:-/tmp/ab-adoption}"
|
|
17
|
-
|
|
18
|
-
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
19
|
-
[ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
|
|
20
|
-
git -C "$ENGINE" diff --quiet && git -C "$ENGINE" diff --cached --quiet || { echo "engine has uncommitted changes — commit/stash first"; exit 1; }
|
|
21
|
-
CHANGED=$(git -C "$ENGINE" diff --name-only "$BASE_REF" HEAD -- src 2>/dev/null)
|
|
22
|
-
[ -n "$CHANGED" ] || { echo "no src/ changes between $BASE_REF and HEAD"; exit 1; }
|
|
23
|
-
|
|
24
|
-
cleanup() {
|
|
25
|
-
pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null
|
|
26
|
-
git -C "$ENGINE" checkout HEAD -- $CHANGED 2>/dev/null
|
|
27
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 )
|
|
28
|
-
}
|
|
29
|
-
trap cleanup EXIT
|
|
30
|
-
mkdir -p "$OUT"
|
|
31
|
-
echo "###### target=$TARGET runs/arm=$RUNS baseline=$BASE_REF"
|
|
32
|
-
echo "###### changed: $(echo "$CHANGED" | tr '\n' ' ')"
|
|
33
|
-
echo "###### task=$TASK"; echo
|
|
34
|
-
|
|
35
|
-
prewarm() {
|
|
36
|
-
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
37
|
-
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
38
|
-
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
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
# Per-run tool-choice counts: Read vs homegraph_node[file] vs [symbol].
|
|
42
|
-
count() {
|
|
43
|
-
node -e '
|
|
44
|
-
const fs=require("fs");
|
|
45
|
-
const lines=fs.readFileSync(process.argv[1],"utf8").split("\n").filter(Boolean);
|
|
46
|
-
let read=0,cgFile=0,cgSym=0,cgOther=0,exposed="?";
|
|
47
|
-
for(const l of lines){try{const o=JSON.parse(l);
|
|
48
|
-
if(o.type==="system"&&o.subtype==="init"){exposed=(o.tools||[]).filter(t=>/homegraph/.test(t)).length;}
|
|
49
|
-
const blocks=o.message?.content||[];
|
|
50
|
-
for(const b of (Array.isArray(blocks)?blocks:[])){
|
|
51
|
-
if(b.type!=="tool_use")continue;
|
|
52
|
-
if(b.name==="Read")read++;
|
|
53
|
-
else if(b.name==="mcp__homegraph__homegraph_node"){ if(b.input&&b.input.symbol)cgSym++; else cgFile++; }
|
|
54
|
-
else if(/mcp__homegraph__/.test(b.name))cgOther++;
|
|
55
|
-
}
|
|
56
|
-
}catch{}}
|
|
57
|
-
console.log(` Read=${read} homegraph_node[file]=${cgFile} homegraph_node[symbol]=${cgSym} other_cg=${cgOther} (cg exposed=${exposed})`);
|
|
58
|
-
' "$1"
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
run_arm() { # label, N
|
|
62
|
-
local label="$1" n="$2"
|
|
63
|
-
local c="$OUT/mcp-$label.json"
|
|
64
|
-
for i in $(seq 1 "$n"); do
|
|
65
|
-
local tgt="$OUT/t-$label-$i"
|
|
66
|
-
rm -rf "$tgt"
|
|
67
|
-
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$tgt/"
|
|
68
|
-
node "$BIN" init "$tgt" >/dev/null 2>&1
|
|
69
|
-
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
|
|
70
|
-
prewarm "$tgt"
|
|
71
|
-
echo "----- [$label] run $i -----"
|
|
72
|
-
( cd "$tgt" && claude -p "$TASK" \
|
|
73
|
-
--output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
74
|
-
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" \
|
|
75
|
-
</dev/null > "$OUT/run-$label-$i.jsonl" 2>"$OUT/run-$label-$i.err" )
|
|
76
|
-
count "$OUT/run-$label-$i.jsonl"
|
|
77
|
-
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
78
|
-
done
|
|
79
|
-
echo
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
echo "== NEW build (HEAD: homegraph_node has Read parity) =="
|
|
83
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
|
|
84
|
-
run_arm new "$RUNS"
|
|
85
|
-
|
|
86
|
-
echo "== BASELINE build ($BASE_REF) =="
|
|
87
|
-
git -C "$ENGINE" checkout "$BASE_REF" -- $CHANGED
|
|
88
|
-
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
|
|
89
|
-
run_arm baseline "$RUNS"
|
|
90
|
-
|
|
91
|
-
echo "###### DONE — compare [new] vs [baseline]: does homegraph_node[file] rise / Read fall? Logs: $OUT"
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Does the agent PICK homegraph_node to read a file, vs the built-in Read tool?
|
|
3
|
+
# Build A/B: NEW build (HEAD, homegraph_node has Read parity) vs BASELINE build
|
|
4
|
+
# (a ref where it doesn't), BOTH homegraph-attached + pre-warmed, same task. The
|
|
5
|
+
# metric is tool CHOICE: Read calls vs homegraph_node[file] calls per run.
|
|
6
|
+
#
|
|
7
|
+
# Usage: ab-adoption.sh <indexed-repo> "<task>" [runs-per-arm] [baseline-ref]
|
|
8
|
+
# Env: AGENT_EVAL_OUT (default: /tmp/ab-adoption)
|
|
9
|
+
set -uo pipefail
|
|
10
|
+
TARGET="${1:?usage: ab-adoption.sh <indexed-repo> \"<task>\" [runs] [baseline-ref]}"
|
|
11
|
+
TASK="${2:?task required}"
|
|
12
|
+
RUNS="${3:-2}"
|
|
13
|
+
BASE_REF="${4:-HEAD~1}"
|
|
14
|
+
ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
15
|
+
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
16
|
+
OUT="${AGENT_EVAL_OUT:-/tmp/ab-adoption}"
|
|
17
|
+
|
|
18
|
+
command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
|
|
19
|
+
[ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
|
|
20
|
+
git -C "$ENGINE" diff --quiet && git -C "$ENGINE" diff --cached --quiet || { echo "engine has uncommitted changes — commit/stash first"; exit 1; }
|
|
21
|
+
CHANGED=$(git -C "$ENGINE" diff --name-only "$BASE_REF" HEAD -- src 2>/dev/null)
|
|
22
|
+
[ -n "$CHANGED" ] || { echo "no src/ changes between $BASE_REF and HEAD"; exit 1; }
|
|
23
|
+
|
|
24
|
+
cleanup() {
|
|
25
|
+
pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null
|
|
26
|
+
git -C "$ENGINE" checkout HEAD -- $CHANGED 2>/dev/null
|
|
27
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 )
|
|
28
|
+
}
|
|
29
|
+
trap cleanup EXIT
|
|
30
|
+
mkdir -p "$OUT"
|
|
31
|
+
echo "###### target=$TARGET runs/arm=$RUNS baseline=$BASE_REF"
|
|
32
|
+
echo "###### changed: $(echo "$CHANGED" | tr '\n' ' ')"
|
|
33
|
+
echo "###### task=$TASK"; echo
|
|
34
|
+
|
|
35
|
+
prewarm() {
|
|
36
|
+
pkill -9 -f "serve --mcp --path $1" 2>/dev/null
|
|
37
|
+
HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
38
|
+
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
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# Per-run tool-choice counts: Read vs homegraph_node[file] vs [symbol].
|
|
42
|
+
count() {
|
|
43
|
+
node -e '
|
|
44
|
+
const fs=require("fs");
|
|
45
|
+
const lines=fs.readFileSync(process.argv[1],"utf8").split("\n").filter(Boolean);
|
|
46
|
+
let read=0,cgFile=0,cgSym=0,cgOther=0,exposed="?";
|
|
47
|
+
for(const l of lines){try{const o=JSON.parse(l);
|
|
48
|
+
if(o.type==="system"&&o.subtype==="init"){exposed=(o.tools||[]).filter(t=>/homegraph/.test(t)).length;}
|
|
49
|
+
const blocks=o.message?.content||[];
|
|
50
|
+
for(const b of (Array.isArray(blocks)?blocks:[])){
|
|
51
|
+
if(b.type!=="tool_use")continue;
|
|
52
|
+
if(b.name==="Read")read++;
|
|
53
|
+
else if(b.name==="mcp__homegraph__homegraph_node"){ if(b.input&&b.input.symbol)cgSym++; else cgFile++; }
|
|
54
|
+
else if(/mcp__homegraph__/.test(b.name))cgOther++;
|
|
55
|
+
}
|
|
56
|
+
}catch{}}
|
|
57
|
+
console.log(` Read=${read} homegraph_node[file]=${cgFile} homegraph_node[symbol]=${cgSym} other_cg=${cgOther} (cg exposed=${exposed})`);
|
|
58
|
+
' "$1"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
run_arm() { # label, N
|
|
62
|
+
local label="$1" n="$2"
|
|
63
|
+
local c="$OUT/mcp-$label.json"
|
|
64
|
+
for i in $(seq 1 "$n"); do
|
|
65
|
+
local tgt="$OUT/t-$label-$i"
|
|
66
|
+
rm -rf "$tgt"
|
|
67
|
+
rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$tgt/"
|
|
68
|
+
node "$BIN" init "$tgt" >/dev/null 2>&1
|
|
69
|
+
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
|
|
70
|
+
prewarm "$tgt"
|
|
71
|
+
echo "----- [$label] run $i -----"
|
|
72
|
+
( cd "$tgt" && claude -p "$TASK" \
|
|
73
|
+
--output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
74
|
+
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" \
|
|
75
|
+
</dev/null > "$OUT/run-$label-$i.jsonl" 2>"$OUT/run-$label-$i.err" )
|
|
76
|
+
count "$OUT/run-$label-$i.jsonl"
|
|
77
|
+
pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
|
|
78
|
+
done
|
|
79
|
+
echo
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
echo "== NEW build (HEAD: homegraph_node has Read parity) =="
|
|
83
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
|
|
84
|
+
run_arm new "$RUNS"
|
|
85
|
+
|
|
86
|
+
echo "== BASELINE build ($BASE_REF) =="
|
|
87
|
+
git -C "$ENGINE" checkout "$BASE_REF" -- $CHANGED
|
|
88
|
+
( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
|
|
89
|
+
run_arm baseline "$RUNS"
|
|
90
|
+
|
|
91
|
+
echo "###### DONE — compare [new] vs [baseline]: does homegraph_node[file] rise / Read fall? Logs: $OUT"
|
|
@@ -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"
|