# AGENTS.md - implementation instructions for Stonehold 64 You are the implementation agent for **Stonehold 64**, a game for `c64`. This repository is self-contained: everything you need is in this folder. Do not look for the tool that generated it or the conversation that produced the spec. ## 1. Read first, in this order 1. `docs/spec.md` - approved requirements, scope boundaries, targets, assumptions, acceptance criteria. 2. `docs/toolchain.md` - language decision, tools and versions, exact commands, verification status. 3. `docs/milestones.md` - ordered tasks; each links to requirements and has a completion check. 4. `docs/manual-tests.md` - what the user does by hand to confirm each milestone, per target. 5. `docs/verification-status.md` - what has been checked so far, and what is still pending. 6. `project.json` - the approved brief in structured form, plus the `resolved` build configuration that `tools/*.ps1` read. The spec is the contract. If the code and the spec disagree, stop and ask the user; do not quietly change either one. ## 2. Project constraints - Language and toolchain: C (cc65) with ca65 assembly modules via Windows cross-development with cc65 (C, ca65 assembly or mixed) and VICE. Do not switch languages or tools without the user's approval (see section 6). - Build location: Windows cross-development. - Targets: `c64`. Every target listed in `docs/spec.md` must keep building and passing its checks after each task. - Tools: cl65, x64sc, PowerShell 7, git. Scripts find them via environment variables (`CC65_HOME`, `VICE_HOME`), `PATH`, or the usual install folders. Never hard-code a machine-specific path into source or scripts. - Paths may contain spaces (including this repository's own path). Quote paths in every command you write or document. - Keep the smoke hooks working: `tools/smoke.ps1` depends on them (see `docs/toolchain.md`). If you change the first screen, update `starter.smokeChecks` in `project.json` and the matching `resolved.targets[].smoke.checks` so the automated check still describes what the screen really shows. - Generated outputs go in `build/` (ignored by Git). Never commit build outputs, disk images or screenshots unless the spec asks for a fixture. - Fixtures in `fixtures/` are stored byte-for-byte. Do not let an editor change their line endings or encoding. ## 3. Start: build and verify the starter (milestone M0) Before writing any feature code: ```powershell pwsh -File tools/check-prereqs.ps1 pwsh -File tools/build.ps1 pwsh -File tools/smoke.ps1 ``` - `check-prereqs.ps1` exits 2 if a tool is missing and prints the exact tool, the first command to run, and what stays unverified. Report that to the user and stop. Don't work around a missing tool. - `smoke.ps1` exits 0 when every automated check passes. Results: `build/smoke/results.json`; screenshots: `build/smoke//`. - Then ask the user to perform M0 in `docs/manual-tests.md` and mark M0 manual verification **pending** in `docs/verification-status.md` until they confirm. ## 4. Milestone workflow Work through `docs/milestones.md` in order, **one reviewable task at a time**: 1. Pick the next task. Re-read its requirements and acceptance criteria in `docs/spec.md`. 2. Make the smallest change that delivers the task's buildable outcome. 3. Run the checks: `pwsh -File tools/build.ps1` and `pwsh -File tools/smoke.ps1` at minimum, plus any check the task names. Fix failures before you report. 4. Update `docs/verification-status.md`: automated result for the task, manual verification **pending**. 5. Report to the user using the template below, then stop and wait if the next task depends on their manual verification. ### Report template (after every task) ``` Task: (requirements: <R ids>) What changed: <files and behavior, in a few lines> Checks run: <command> -> <result> (one line each, with exit codes) Please verify manually: 1. <exact command to start, e.g. pwsh -File tools/run.ps1 -Target <id>> 2. <exact keys to press / actions> Expected: <exactly what should appear or happen> Manual verification: PENDING until you confirm. Next: <next task id>, or "waiting for your verification" if the next task depends on it. ``` ### Pausing rules - When a milestone ends, stop until the user confirms that milestone's manual tests. - Stop sooner if the next task builds on behavior that only the user can confirm (feel, timing, visuals, sound, real hardware). - When the user confirms, change the item from pending to `confirmed by user (<date>)` in `docs/verification-status.md`. If they report a problem, record it there, fix it as the next task, and re-request verification. - Never mark manual verification as confirmed yourself. ## 5. Verification rules - Never claim a check passed unless you ran it in this session and saw it pass. Quote the command and the result. - If a check cannot run (missing tool, no hardware), say so, and record it as `not run - <reason>`. - Real-hardware results are only recorded when the user reports them. - Keep `docs/manual-tests.md` accurate. When behavior changes, update the steps and expected observations in the same task. - Acceptance criteria are verified against the target(s) they name. Native 40-column and 80-column C128 behavior are separate targets and need separate checks. ## 6. Changes to requirements If the user asks for a change, or you find that a requirement cannot be met as written: 1. Describe the change and its impact: which requirements, milestones, tests and targets it touches. 2. Wait for approval. 3. In one task, update `docs/spec.md`, `docs/milestones.md`, `docs/manual-tests.md`, `docs/verification-status.md` and `project.json` together, and then the code. Requirements, implementation and verification must stay in sync. 4. A change of language or toolchain also updates `docs/toolchain.md` and the `resolved` section of `project.json`, and must be re-verified from M0. ## 7. Git - Work on `main` unless the user asks otherwise. Commit after each verified task with a message naming the task id, e.g. `M1.2: draw signal heads`. - Don't add remotes or push unless the user asks.