bench-why-repo.sh 1.6 KB

12345678910111213141516171819202122
  1. #!/usr/bin/env bash
  2. # One README repo, WITH-codegraph only, N runs. Each run appends a why-Read
  3. # diagnostic so the agent explains any Read/Grep. (The WITHOUT baseline is
  4. # codegraph-independent and already in the README — no point re-running it.)
  5. # Output -> /tmp/ab-why/<repo>/with<n>.jsonl
  6. # Usage: bench-why-repo.sh <repo-path> "<query>" [N]
  7. set -uo pipefail
  8. REPO="$1"; Q="$2"; N="${3:-4}"
  9. NAME="$(basename "$REPO")"
  10. CG="/Users/colby/Development/Personal/codegraph/dist/bin/codegraph.js"
  11. OUT="/tmp/ab-why/$NAME"; mkdir -p "$OUT"
  12. WHY=$'\n\nIMPORTANT — diagnostic: if you use the Read or Grep tool at ANY point, for EACH such call explain why codegraph_explore / codegraph_node did not already give you what you needed. End your entire answer with a section titled exactly "## Why I read" listing every Read and Grep you made and the precise reason codegraph fell short for it. If you used neither, write "## Why I read" then "none — codegraph was sufficient."'
  13. printf '{"mcpServers":{"codegraph":{"command":"%s","args":["serve","--mcp","--path","%s"]}}}' "$CG" "$REPO" > "$OUT/cg.json"
  14. for i in $(seq 1 "$N"); do
  15. pkill -f "serve --mcp" 2>/dev/null; sleep 1; rm -f "$REPO/.codegraph/daemon.sock"
  16. ( cd "$REPO" && claude -p "$Q$WHY" --output-format stream-json --verbose \
  17. --permission-mode bypassPermissions --model opus --effort "${EFFORT:-high}" --max-budget-usd 4 \
  18. --strict-mcp-config --mcp-config "$OUT/cg.json" > "$OUT/with$i.jsonl" 2>"$OUT/with$i.err" )
  19. echo "WITH run $i: exit $? ($(wc -l < "$OUT/with$i.jsonl" | tr -d ' ') lines)"
  20. done
  21. echo "DONE $NAME"