#!/usr/bin/env bash # Rerun the agent: Claude Code in headless mode, with the bino MCP server as its only tools. # # ./run.sh turn 1: send prompt.md, the agent builds the report # ./run.sh review 1 turn 2: resume the same session and send review-1.md # ./run.sh review 2 turn 3: resume again and send review-2.md # # Each turn writes its raw transcript to transcript/run-.jsonl and a Markdown # rendering of it to transcript/run-.md. The review files are a human review of # the PDF the recorded run produced; on your own rerun, read your PDF and edit them first. set -euo pipefail cd "$(dirname "$0")" MODEL="${MODEL:-claude-opus-5-5}" FLAGS=( --model "$MODEL" --mcp-config mcp.json --strict-mcp-config --tools "ListMcpResourcesTool,ReadMcpResourceTool" --allowedTools "mcp__bino,ListMcpResourcesTool,ReadMcpResourceTool" --setting-sources project --output-format stream-json --verbose ) mkdir -p transcript if [[ "${1:-}" == "review" ]]; then n="${2:?usage: ./run.sh review }" turn=$((n + 1)) claude -p "$(cat "review-$n.md")" --resume "$(cat transcript/session-id.txt)" "${FLAGS[@]}" \ < /dev/null | tee "transcript/run-$turn.jsonl" python3 scripts/transcript_to_md.py "transcript/run-$turn.jsonl" > "transcript/run-$turn.md" if [[ "$n" == "1" ]]; then cp dist/sales_2025_report.pdf report-second-pass.pdf else cp dist/sales_2025_report.pdf report.pdf fi else claude -p "$(cat prompt.md)" "${FLAGS[@]}" < /dev/null | tee transcript/run-1.jsonl python3 scripts/transcript_to_md.py transcript/run-1.jsonl > transcript/run-1.md python3 -c "import json,sys; print(json.loads(open(sys.argv[1]).readline())['session_id'])" \ transcript/run-1.jsonl > transcript/session-id.txt cp dist/sales_2025_report.pdf report-first-pass.pdf fi