Files
agentic-labs-challenge/body-snatcher/build.sh
T
2026-08-15 19:23:11 +02:00

69 lines
6.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
MAX_RETRIES=3
run_phase() {
local phase="$1"
local prompt="$2"
local attempt=1
local failure=""
while [ "$attempt" -le "$MAX_RETRIES" ]; do
echo "=== Phase $phase (attempt $attempt/$MAX_RETRIES) ==="
pi -p "$prompt${failure:+
Previous gate failure to fix in this attempt:
$failure}" || true
if node verify.js "$phase"; then
echo "=== Phase $phase PASSED ==="
return 0
fi
failure="$(node verify.js "$phase" 2>&1 || true)"
echo "=== Phase $phase FAILED (attempt $attempt) ==="
attempt=$((attempt + 1))
done
echo "=== Phase $phase exhausted retries; targeted fix ==="
pi -p "Phase $phase of Body Snatcher failed verification. Read AGENTS.md, verify.js, and the current index.html completely. The exact output is below. Fix ALL reported issues in index.html. Do not rewrite from scratch and do not weaken verify.js.
$failure" || true
if node verify.js "$phase"; then
echo "=== Phase $phase PASSED after targeted fix ==="
return 0
fi
echo "=== Phase $phase FAILED after all retries ==="
return 1
}
run_phase 1 "Read AGENTS.md and verify.js completely. Implement Phase 1 ONLY in a new single index.html: HTML5 Canvas skeleton, polished title/HUD panels, game loop, 25x18 grid, intricate layered/shaded stone tile rendering, wall collision, snappy ghost movement (WASD/arrows with ~85ms visual interpolation and hold repeat), deterministic tick(n), 15-second ghost timer, radial fog of war, and a static test dungeon. The title must visibly explain WASD/arrows, SPACE, Q/E, ENTER, ESC and expose a readable L-key enemy legend containing all 12 enemy names plus enemy behavior and possessed kit. HUD shows contextual SPACE. Expose the live window.GAME API required by AGENTS.md and verify.js. start() must initialize title and never auto-start play. Use only inline HTML/CSS/JS, no dependencies. Make canvas and audio mocks safe. Run node verify.js 1 and fix failures before finishing."
run_phase 2 "Read AGENTS.md, verify.js, and the complete current index.html. Implement Phase 2 ONLY while preserving Phase 1: possession by SPACE, voluntary abandon by X (host survives, 2-turn pacify/repossess lockout, timer resumes), and Brute/Skitterer/Sentinel as dual AI/player-kit data objects with the exact observable stats in verify.js. Add BFS/A* pathfinding, essence drops, host death ejection, attacks/projectiles, and detailed layered canvas-vector sprites. CRITICAL calm pacing: enemies start docile; aggro only within about 6 tiles with line of sight; most move every 2 turns; no enemy attack/projectile can damage another enemy. Sentinel uses a 3-shot burst then a visible 3-turn overheat with no firing. Keep deterministic tick(n), contextual controls, and the live GAME API. Run node verify.js 2 and fix all failures before finishing."
run_phase 3 "Read AGENTS.md, verify.js, and the complete current index.html. Implement Phase 3 ONLY while preserving prior phases: Shielder, Bomber, Healer, Phaser, Turret, Charger, Siren, Mimic, and Leech, each with full distinct enemy AI, possessed player kit, observable distinct HP+damage+speed tuple, and intricate layered/shaded animated canvas-vector silhouette matching AGENTS.md. Implement directional facing and specials. No friendly fire: enemy Bomber explosions, Charger charges, Turret shots, melee, AoE, and projectiles damage only the player; possessed-player attacks still damage enemies. Turret fires 3 shots one per 2 turns then has forced 3-turn overheat and full vulnerability. Preserve docile/LOS aggro and slow exploration pacing. Run node verify.js 3 and fix all failures before finishing."
run_phase 4 "Read AGENTS.md, verify.js, and the complete current index.html. Implement Phase 4 ONLY while preserving everything: random-walk plus 5-8 carved rooms and L corridors, varying fresh layouts, exit in farthest room, spawn safety, chests, 10 floors with escalating 4+floor enemy populations, and between-floor shop with 3 random choices. Implement all 11 prerequisite upgrades across Ghost/Body/Meta trees with gameplay effects and prices/discounts. Implement localStorage bodysnatcher_save auto-save plus GAME.save/load round-trip of floor, essence, upgrades, player, enemies, and current grid; page load offers Continue Y/N without auto-start. Keep GAME properties live and settable enough for the harness. Run node verify.js 4 repeatedly and fix every failure before finishing."
run_phase 5 "Read AGENTS.md, verify.js, and the complete current index.html. Implement Phase 5 ONLY while preserving everything: procedural Web Audio tones guarded for mocks, screen shake, particles, hit flashes/numbers, possession/ejection dissolve, aura, idle bob/breathing, ~85ms sub-pixel movement interpolation, held-key repeat, and ~600ms live cadence without tying deterministic state to wall time. Polish every tile/entity and title/HUD/shop/pause/legend/win/lose overlay with layered gradients, bevels, highlights, shadows, accents, and contextual controls; no bare text or flat placeholders. Implement all 8 achievements, pause/resume and Save+Quit, title and pause bestiary, floor-10 exit victory, 15-second timer loss. Run node verify.js 5 and fix all failures before finishing."
echo "=== ADVERSARIAL REVIEW ==="
pi -p "You are the final QA owner. Read AGENTS.md, verify.js, and the complete index.html. Audit every completion criterion and fix all concrete issues directly in index.html without weakening tests or rewriting working systems. Prioritize crashes, mock compatibility, all 12 dual enemy kits, save/load refresh, achievements, fog, title/legend/controls, base 15-second timer, calm pacing, spawn safety, no friendly fire, LOS aggro, Sentinel/Turret forced overheat, X-abandon lockout, snappy movement, and intricate layered canvas-vector visual polish. Run node verify.js 5 repeatedly until it passes. Leave no TODOs/placeholders/external assets." || true
for attempt in 1 2 3; do
echo "=== FINAL VERIFICATION ($attempt/3) ==="
if node verify.js 5; then
echo "ALL GATES PASSED"
echo "=== BUILD COMPLETE ==="
exit 0
fi
failure="$(node verify.js 5 2>&1 || true)"
pi -p "Final Body Snatcher verification failed. Read AGENTS.md, verify.js, and index.html. Fix only the root causes in index.html; preserve working features and do not edit verify.js. Run node verify.js 5 until it passes. Failure:
$failure" || true
done
echo "FINAL GATE FAILED"
exit 1