diff --git a/body-snatcher/build.sh b/body-snatcher/build.sh
new file mode 100755
index 0000000..3d34b91
--- /dev/null
+++ b/body-snatcher/build.sh
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+MAX_RETRIES=3
+
+run_phase() {
+ local phase=$1
+ local prompt=$2
+ local attempt=1
+ local output
+
+ while [ "$attempt" -le "$MAX_RETRIES" ]; do
+ echo "=== Phase $phase (attempt $attempt/$MAX_RETRIES) ==="
+ pi -p "$prompt" || true
+ if output=$(node verify.js "$phase" 2>&1); then
+ printf '%s\n' "$output"
+ echo "=== Phase $phase PASSED ==="
+ return 0
+ fi
+
+ printf '%s\n' "$output"
+ echo "=== Phase $phase FAILED (attempt $attempt) ==="
+ prompt="Phase $phase of Body Snatcher failed verification. Read AGENTS.md, verify.js, and the current index.html. Fix the current implementation in place; do not rewrite working systems or merely explain. The failing output is:
+
+$output
+
+Run node verify.js $phase yourself and keep fixing until it exits 0."
+ attempt=$((attempt + 1))
+ done
+
+ echo "=== Phase $phase exhausted retries; targeted fix ==="
+ pi -p "$prompt" || true
+ node verify.js "$phase"
+ echo "=== Phase $phase PASSED after targeted fix ==="
+}
+
+COMMON="Read AGENTS.md completely, then read verify.js and the current files. Body Snatcher must remain one dependency-free index.html with inline CSS/JavaScript. Directly edit files; do not only describe code. Preserve working prior phases. Keep window.GAME's test surface synchronized with live state. Canvas and AudioContext mocks must never crash. The page must wait for GAME.start() or a user key before starting."
+
+run_phase 1 "$COMMON
+Implement Phase 1 only: HTML5 Canvas skeleton; 25x18 tile grid plus HUD; title/start flow; game loop; ghost state and timer; WASD/arrow tile movement; wall collision; fog of war; HUD; static test dungeon. Expose GAME.state, player, enemies, grid, floor, essence, upgrades, log, start(), newRun(), input(key), and tick(n). Do not implement enemies, possession, or procedural generation yet. Run node verify.js 1 and fix every failure."
+
+run_phase 2 "$COMMON
+Implement Phase 2 only: possession with Space; Brute, Skitterer, and Sentinel as dual enemy/player kits; BFS or A* wall-aware enemy movement; host death/ejection; projectiles; combat; essence drops. Preserve Phase 1. Expose deterministic GAME.spawn(type,x,y), damageEnemy(enemy,amount), and findPath(sx,sy,tx,ty) used by verify.js. Enemy objects and possessed bodies must expose maxHp, damage, speed, and special/ability. Run node verify.js 2 and fix every failure."
+
+run_phase 3 "$COMMON
+Implement Phase 3 only: add Shielder, Bomber, Healer, Phaser, Turret, Charger, Siren, Mimic, and Leech with the complete enemy AI and possessed player kit from AGENTS.md. Preserve prior systems. All 12 types must instantiate, render with their required silhouettes, possess, fight, and execute specials without errors. Give every type a distinct maxHp/damage/speed tuple as verify.js requires while retaining the specified gameplay identity. Ensure findPath routes around walls on the current GAME.grid. Run node verify.js 3 and fix every failure."
+
+run_phase 4 "$COMMON
+Implement Phase 4 only: random-room-and-corridor procedural generation; different layouts each call; exits; chests; 10 escalating floors; between-floor shop with three choices; every prerequisite-gated upgrade in all three trees; gameplay effects; save/load/autosave using bodysnatcher_save; continue-run Y/N prompt. Preserve all combat. Expose generateFloor(floor), completeFloor(), shopChoices, buyUpgrade(index), save(), and load() exactly as verify.js exercises them. Run node verify.js 4 and fix every failure."
+
+run_phase 5 "$COMMON
+Implement Phase 5 and complete the full AGENTS.md spec: procedural Web Audio tones; screen shake; particles; hit flash; 150ms movement interpolation; all eight persistent achievements; floor-10 victory; ghost-timer loss with stats; pause and Save+Quit; all controls and game feel. Audit every completion criterion, not only the harness. Expose achievements, unlockAchievement(name), and sound(name). Make GAME.tick(n) deterministic enough for the 200-tick mock stress test. Run node verify.js 5 and fix every failure."
+
+echo "=== ADVERSARIAL REVIEW ==="
+pi -p "$COMMON
+Act as an adversarial QA reviewer and fixer. Read the complete AGENTS.md, verify.js, and index.html. Inspect the full game for crashes, missing completion criteria, broken enemy AI or possessed kits, procgen connectivity, save/load edge cases, achievement tracking, fog, audio mocks, shop prerequisites, controls, win/loss, and 5-minute play stability. Fix every issue directly with the smallest safe changes. Run node verify.js 5 until it passes." || true
+
+echo "=== FINAL VERIFICATION ==="
+if ! output=$(node verify.js 5 2>&1); then
+ printf '%s\n' "$output"
+ pi -p "$COMMON
+Final verification failed after QA. Fix only the concrete remaining failures in index.html and rerun node verify.js 5 until it exits 0. Failure output:
+
+$output" || true
+fi
+node verify.js 5
+echo "=== BUILD COMPLETE: ALL GATES PASSED ==="
diff --git a/body-snatcher/index.html b/body-snatcher/index.html
new file mode 100644
index 0000000..00b5937
--- /dev/null
+++ b/body-snatcher/index.html
@@ -0,0 +1,1088 @@
+
+
+
+
+
+Body Snatcher
+
+
+
+
+
+
+
diff --git a/body-snatcher/verify.js b/body-snatcher/verify.js
new file mode 100644
index 0000000..bf98004
--- /dev/null
+++ b/body-snatcher/verify.js
@@ -0,0 +1,292 @@
+#!/usr/bin/env node
+'use strict';
+
+const fs = require('fs');
+const path = require('path');
+const vm = require('vm');
+
+const phase = Number(process.argv[2] || 5);
+const checks = [];
+const ok = (condition, message) => {
+ if (!condition) throw new Error(message);
+ checks.push(message);
+};
+const value = (object, names, fallback) => {
+ for (const name of names) if (object && object[name] != null) return object[name];
+ return fallback;
+};
+const tileName = tile => String((tile && (tile.type ?? tile.kind ?? tile.tile)) ?? tile).toLowerCase();
+const isWall = tile => /wall|#/.test(tileName(tile)) || tile === 1;
+const isFloor = tile => !isWall(tile) && !/void|unknown/.test(tileName(tile));
+const keyFor = (dx, dy) => dx < 0 ? 'ArrowLeft' : dx > 0 ? 'ArrowRight' : dy < 0 ? 'ArrowUp' : 'ArrowDown';
+const gridRows = game => Array.isArray(game.grid?.[0]) ? game.grid : [];
+const setPlayerPosition = (game, x, y) => {
+ game.player.x = x; game.player.y = y;
+ if ('tx' in game.player) game.player.tx = x;
+ if ('ty' in game.player) game.player.ty = y;
+ if ('renderX' in game.player) game.player.renderX = x;
+ if ('renderY' in game.player) game.player.renderY = y;
+};
+const position = entity => [Number(value(entity, ['x', 'col'], 0)), Number(value(entity, ['y', 'row'], 0))];
+
+function mocks() {
+ const storage = new Map();
+ let storageWrites = 0;
+ let audioCalls = 0;
+ const noop = () => {};
+ const gradient = { addColorStop: noop };
+ const context2d = new Proxy({ canvas: null, measureText: text => ({ width: String(text).length * 8 }), createLinearGradient: () => gradient, createRadialGradient: () => gradient, createPattern: () => ({}), getImageData: () => ({ data: new Uint8ClampedArray(4) }) }, { get: (target, key) => key in target ? target[key] : noop, set: (target, key, val) => (target[key] = val, true) });
+ const listeners = {};
+ const element = tag => ({
+ tagName: String(tag).toUpperCase(), id: '', width: tag === 'canvas' ? 800 : 0, height: tag === 'canvas' ? 640 : 0,
+ style: {}, classList: { add: noop, remove: noop, toggle: noop, contains: () => false }, children: [],
+ appendChild(child) { this.children.push(child); return child; }, remove: noop, focus: noop,
+ addEventListener(type, fn) { (listeners[type] ||= []).push(fn); }, removeEventListener: noop,
+ getContext: () => context2d, getBoundingClientRect: () => ({ left: 0, top: 0, width: 800, height: 640 }),
+ setAttribute(name, val) { this[name] = val; }, getAttribute(name) { return this[name] ?? null; },
+ querySelector: () => null, querySelectorAll: () => []
+ });
+ const canvas = element('canvas');
+ canvas.id = 'game'; context2d.canvas = canvas;
+ const body = element('body'); body.appendChild(canvas);
+ const document = {
+ body, readyState: 'loading', hidden: false,
+ createElement: element,
+ getElementById: id => id === 'game' || id === 'canvas' ? canvas : null,
+ querySelector: selector => selector === 'canvas' || selector === '#game' || selector === '#canvas' ? canvas : null,
+ querySelectorAll: selector => selector === 'canvas' ? [canvas] : [],
+ addEventListener(type, fn) { (listeners[type] ||= []).push(fn); }, removeEventListener: noop,
+ dispatchEvent(event) { for (const fn of listeners[event.type] || []) fn(event); },
+ };
+ class AudioParam { setValueAtTime() { audioCalls++; } linearRampToValueAtTime() { audioCalls++; } exponentialRampToValueAtTime() { audioCalls++; } cancelScheduledValues() {} }
+ class AudioNode { constructor() { this.frequency = new AudioParam(); this.gain = new AudioParam(); this.type = 'sine'; } connect() { audioCalls++; return this; } disconnect() {} start() { audioCalls++; } stop() { audioCalls++; } }
+ class AudioContext { constructor() { audioCalls++; this.currentTime = 0; this.destination = new AudioNode(); this.state = 'running'; } createOscillator() { audioCalls++; return new AudioNode(); } createGain() { audioCalls++; return new AudioNode(); } createBiquadFilter() { return new AudioNode(); } resume() { audioCalls++; return Promise.resolve(); } close() { return Promise.resolve(); } }
+ const localStorage = { getItem: key => storage.has(key) ? storage.get(key) : null, setItem: (key, val) => { storageWrites++; storage.set(key, String(val)); }, removeItem: key => storage.delete(key), clear: () => storage.clear(), key: i => [...storage.keys()][i] ?? null, get length() { return storage.size; } };
+ let now = 1000;
+ const window = {
+ document, localStorage, AudioContext, webkitAudioContext: AudioContext, innerWidth: 800, innerHeight: 640, devicePixelRatio: 1,
+ performance: { now: () => (now += 16) }, navigator: { userAgent: 'verify.js' }, location: { reload: noop },
+ addEventListener(type, fn) { (listeners[type] ||= []).push(fn); }, removeEventListener: noop,
+ dispatchEvent(event) { for (const fn of listeners[event.type] || []) fn(event); },
+ requestAnimationFrame: fn => (window.__raf = fn, 1), cancelAnimationFrame: noop,
+ setTimeout: () => 1, clearTimeout: noop, setInterval: () => 1, clearInterval: noop,
+ confirm: () => false, alert: noop,
+ };
+ window.window = window; window.self = window; window.globalThis = window;
+ const sandbox = {
+ window, self: window, document, localStorage, AudioContext, webkitAudioContext: AudioContext,
+ requestAnimationFrame: window.requestAnimationFrame, cancelAnimationFrame: noop,
+ setTimeout: window.setTimeout, clearTimeout: noop, setInterval: window.setInterval, clearInterval: noop,
+ performance: window.performance, navigator: window.navigator, location: window.location,
+ console, Math, Date, JSON, Array, Object, String, Number, Boolean, Map, Set, WeakMap, Promise,
+ Uint8ClampedArray, Event: class Event { constructor(type, init = {}) { this.type = type; Object.assign(this, init); } },
+ KeyboardEvent: class KeyboardEvent { constructor(type, init = {}) { this.type = type; Object.assign(this, init); } },
+ };
+ sandbox.globalThis = sandbox;
+ return { sandbox, window, storage, metrics: { get storageWrites() { return storageWrites; }, get audioCalls() { return audioCalls; } } };
+}
+
+function boot() {
+ const file = path.join(__dirname, 'index.html');
+ ok(fs.existsSync(file), 'index.html exists');
+ const html = fs.readFileSync(file, 'utf8');
+ ok(/