188 lines
9.0 KiB
Markdown
Executable File
188 lines
9.0 KiB
Markdown
Executable File
# PROMPT.md — Body Snatcher
|
|
|
|
This is the one-prompt entry for the Agentic Labs One-Prompt Challenge.
|
|
Paste the section between the ===== lines into Pi as your first and only message.
|
|
|
|
The AGENTS.md file in this directory is part of your prompt (rules 2.2 and 3.1).
|
|
Do not delete or modify AGENTS.md.
|
|
|
|
## How to use this file
|
|
|
|
1. Copy everything between the ===== markers below
|
|
2. Open Pi in an empty directory containing ONLY AGENTS.md
|
|
3. Paste as your first message
|
|
4. Hands off. Let it run.
|
|
5. Save the session jsonl when done (rule 6.2)
|
|
|
|
=====================================================================
|
|
|
|
Read AGENTS.md. That is the full game spec for "Body Snatcher" — a browser-based possession roguelike. Read it entirely before doing anything.
|
|
|
|
Your task: Build the complete game as a single index.html file. Follow the spec exactly.
|
|
|
|
## ARCHITECTURE: You are building a self-orchestrating software factory.
|
|
|
|
Do NOT write the game directly in this conversation. Instead, write two scripts — `build.sh` and `verify.js` — then run `build.sh` and let it orchestrate the entire build using `pi -p` as the primitive. This gives you subagent isolation, mechanical verification gates, and retry loops.
|
|
|
|
## STEP 1: Write verify.js (do this first, before any game code)
|
|
|
|
`verify.js` is your automated test harness. It uses Node.js to:
|
|
1. Read `index.html`, extract the `<script>` content, and eval it in a sandboxed context with DOM mocks
|
|
2. Mock `document`, `window`, `canvas.getContext`, `AudioContext`, `localStorage`, and `requestAnimationFrame` as no-ops / simple stubs
|
|
3. Call `GAME.start()` to initialize
|
|
4. Simulate input sequences and assert on game state via `window.GAME`
|
|
|
|
It must run without external packages — only Node.js builtins (`fs`, `vm`, `path`).
|
|
|
|
`verify.js` takes a phase number as argument: `node verify.js 1` runs phase 1 checks.
|
|
|
|
### Phase 1 checks: Engine exists and runs
|
|
- index.html exists, contains `<canvas` and `<script`
|
|
- No external src= attributes or import statements
|
|
- GAME.start() runs without throwing
|
|
- GAME.state is one of the valid states
|
|
- Grid exists and has wall + floor tiles
|
|
- GAME.input('ArrowRight') moves the ghost without error
|
|
- Ghost cannot move into walls
|
|
|
|
### Phase 2 checks: Possession + first 3 enemies
|
|
- Spawn an enemy next to the player via GAME.spawn or debug setup
|
|
- GAME.input('Space') on adjacent enemy → state transitions to "possessed"
|
|
- Brute: HP 8, damage 3, slow movement
|
|
- Skitterer: HP 2, damage 1, fast movement
|
|
- Sentinel: HP 4, shoots projectiles, no melee
|
|
- Each enemy pathfinds toward the ghost when not possessed
|
|
- Killing a host ejects ghost with timer > 0
|
|
- Essence increases on kill
|
|
|
|
### Phase 3 checks: All 12 enemy types
|
|
- All 12 enemy types can be instantiated
|
|
- Each has distinct stats (no two share HP + damage + speed)
|
|
- Each special ability executes without error when triggered
|
|
- Pathfinder navigates around walls (not through them)
|
|
|
|
### Phase 4 checks: Procgen + shop + save/load
|
|
- Generate 3 dungeons, assert all 3 layouts differ (compare wall positions)
|
|
- Exit tile exists on each floor
|
|
- Shop appears on floor transition
|
|
- Purchasing an upgrade changes GAME.upgrades
|
|
- localStorage.setItem is called on save
|
|
- After mock save/load round-trip, floor + essence + upgrades persist
|
|
|
|
### Phase 5 checks: Polish + completeness
|
|
- GAME.state can reach 'won' (reach floor 10 exit)
|
|
- GAME.state can reach 'lost' (ghost timer hits 0)
|
|
- At least 3 achievements can trigger
|
|
- Audio context methods are called (sound system initialized)
|
|
- No JS errors during a 200-tick stress test (move, possess, attack, descend 3 floors)
|
|
|
|
**Run verify.js after EVERY build phase. Exit 0 = pass. Exit 1 = fail with specific assertion. This is your gate.**
|
|
|
|
## STEP 2: Write build.sh
|
|
|
|
`build.sh` orchestrates the entire build in phases using `pi -p` as the primitive. Each phase gets:
|
|
- Fresh pi context (reads AGENTS.md, no drift from previous phases)
|
|
- A specific scope (only the systems for that phase)
|
|
- A mechanical gate (`node verify.js N`)
|
|
- Retry on failure (max 3 attempts per phase)
|
|
|
|
Structure:
|
|
|
|
```bash
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
MAX_RETRIES=3
|
|
|
|
run_phase() {
|
|
local phase=$1
|
|
local prompt=$2
|
|
local attempt=1
|
|
while [ $attempt -le $MAX_RETRIES ]; do
|
|
echo "=== Phase $phase (attempt $attempt/$MAX_RETRIES) ==="
|
|
pi -p "$prompt" || true # pi may exit non-zero, that's fine
|
|
|
|
if node verify.js "$phase"; then
|
|
echo "=== Phase $phase PASSED ==="
|
|
return 0
|
|
else
|
|
echo "=== Phase $phase FAILED (attempt $attempt) ==="
|
|
if [ $attempt -eq $MAX_RETRIES ]; then
|
|
echo "=== Phase $phase exhausted retries ==="
|
|
# Feed failure details into a fix attempt
|
|
pi -p "Phase $phase of Body Snatcher failed verification. Read AGENTS.md and the current index.html. The verify.js output was: $(node verify.js "$phase" 2>&1). Fix ALL issues. Do not rewrite from scratch — fix the specific failures." || true
|
|
if node verify.js "$phase"; then
|
|
echo "=== Phase $phase PASSED after fix ==="
|
|
return 0
|
|
fi
|
|
fi
|
|
fi
|
|
attempt=$((attempt + 1))
|
|
done
|
|
echo "=== Phase $phase FAILED after all retries ==="
|
|
return 1
|
|
}
|
|
|
|
# Phase 1: Core engine
|
|
run_phase 1 "Read AGENTS.md. Implement Phase 1 ONLY: HTML5 Canvas skeleton, game loop, grid system, tile rendering, wall collision, ghost movement (WASD/arrows), fog of war, HUD, and a static test dungeon. Expose window.GAME with {state, player, grid, input(key), start(), tick(n)} as specified in the Testability section. Do NOT implement enemies, possession, or procgen yet. Run node verify.js 1 yourself and fix any failures before finishing."
|
|
|
|
# Phase 2: Possession + first 3 enemies
|
|
run_phase 2 "Read AGENTS.md. Implement Phase 2 ONLY: possession mechanic (SPACE on adjacent enemy), Brute/Skitterer/Sentinel with dual AI+player-kit, A* pathfinding, ghost timer, essence drops. Preserve everything from Phase 1. Run node verify.js 2 yourself and fix any failures before finishing."
|
|
|
|
# Phase 3: Remaining 9 enemies
|
|
run_phase 3 "Read AGENTS.md. Implement Phase 3 ONLY: the remaining 9 enemy types (Shielder, Bomber, Healer, Phaser, Turret, Charger, Siren, Mimic, Leech). Each needs full enemy AI + player kit. Preserve everything from previous phases. Run node verify.js 3 yourself and fix any failures before finishing."
|
|
|
|
# Phase 4: Procgen + progression + shop + save/load
|
|
run_phase 4 "Read AGENTS.md. Implement Phase 4 ONLY: procedural dungeon generation (random walk + room carving), 10 floors with escalating enemies, between-floor shop with 3 upgrade choices, all 11 upgrades across 3 trees, save/load via localStorage. Preserve everything. Run node verify.js 4 yourself and fix any failures before finishing."
|
|
|
|
# Phase 5: Polish + audio + achievements + win/lose
|
|
run_phase 5 "Read AGENTS.md. Implement Phase 5 ONLY: Web Audio API procedural sounds, screen shake, particles, hit flashes, movement interpolation, all 8 achievements, win state (floor 10 exit), lose state (ghost timer expires), pause menu (ESC). Preserve everything. Run node verify.js 5 yourself and fix any failures before finishing."
|
|
|
|
# Final adversarial review
|
|
echo "=== ADVERSARIAL REVIEW ==="
|
|
pi -p "You are a QA reviewer. Read AGENTS.md and the complete index.html. Find bugs, missing features, and spec violations. For each issue found, fix it directly. Focus on: crashes, enemies that don't work, save/load edge cases, missing achievements, fog of war bugs. Run node verify.js 5 after fixes." || true
|
|
|
|
# Final verification
|
|
echo "=== FINAL VERIFICATION ==="
|
|
node verify.js 5 && echo "ALL GATES PASSED" || echo "FINAL GATE FAILED"
|
|
|
|
echo "=== BUILD COMPLETE ==="
|
|
```
|
|
|
|
Adapt the phase prompts as needed for your environment, but keep this structure:
|
|
1. Fresh `pi -p` per phase (isolated context)
|
|
2. `node verify.js N` as mechanical gate after each
|
|
3. Max 3 retries, then a targeted fix attempt
|
|
4. Adversarial review pass at the end
|
|
5. Final gate check
|
|
|
|
## STEP 3: Run it
|
|
|
|
```bash
|
|
chmod +x build.sh
|
|
bash build.sh
|
|
```
|
|
|
|
Then sit back. The factory runs itself.
|
|
|
|
## Rules
|
|
|
|
- Single index.html. Zero external dependencies.
|
|
- verify.js uses only Node.js builtins — no npm packages.
|
|
- build.sh uses `pi -p` as the only LLM primitive.
|
|
- If something in the spec is ambiguous, make a reasonable choice. Don't stop to ask.
|
|
- Write less code, not more. Bloat is penalized.
|
|
- No stubs, no TODOs, no placeholders. Everything works.
|
|
- Do not stop until all verify.js gates pass and the adversarial review completes.
|
|
|
|
Now: write verify.js, then build.sh, then run build.sh.
|
|
|
|
=====================================================================
|
|
|
|
## Notes
|
|
|
|
- The directory should contain ONLY AGENTS.md when you start the Pi session
|
|
- AGENTS.md is allowed by rule 2.2 ("Human-authored instruction text is allowed")
|
|
- AGENTS.md must be disclosed in your submission repo (rule 3.1)
|
|
- The session jsonl proves it was one prompt — save it
|
|
- verify.js and build.sh are generated BY the agent during the run — they don't violate the "empty directory" rule because they're produced as output, not pre-staged
|