#!/usr/bin/env bash # build.sh — self-orchestrating factory for Body Snatcher. # Drives the build in phases via `pi -p` (fresh isolated context each phase), # gated mechanically by `node verify.js `. Max 3 retries + targeted fix. set -uo pipefail cd "$(dirname "$0")" MAX_RETRIES=3 MODEL="--model openai/gpt-5.2 --thinking high" mkdir -p build LOG=build/build.log : > "$LOG" if [ ! -f verify.js ]; then echo "FATAL: verify.js missing" >&2; exit 1; fi # ---- shared contract + phase scopes written to build/_*.md ------------------ cat > build/_contract.md <<'EOF' You are building "Body Snatcher" — a single index.html browser possession roguelike. STEP 0: Read AGENTS.md in THIS directory COMPLETELY. It is the authoritative spec. Then, if index.html already exists, read ALL of the current index.html before editing. After phase 1, NEVER rewrite index.html from scratch — edit it incrementally and PRESERVE every working system from earlier phases. HARD CONSTRAINTS (every phase): - Single index.html. Zero external dependencies: no CDN, no npm, no ES `import`, no