瀏覽代碼

Add C64/C128 Dev Foundry v1

Interview workflow (AGENTS.md), structured brief with schema and validator
(draft/resume, conflicts, overrides), toolchain catalog and selection guide,
templates, and a deterministic PowerShell generator that stages, initializes
Git and publishes self-contained project repos with VICE smoke tests.
Includes two example briefs (Traffic Control 64, C128 80-column text viewer),
test briefs, an automated suite (108 checks) and verification docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main
Daniel Covington 1 周之前
當前提交
d9ed9f7c00
共有 74 個文件被更改,包括 7858 次插入 和 0 次删除
  1. +5
    -0
      .gitattributes
  2. +12
    -0
      .gitignore
  3. +122
    -0
      AGENTS.md
  4. +3
    -0
      CLAUDE.md
  5. +115
    -0
      README.md
  6. +265
    -0
      catalog/recipes.json
  7. +148
    -0
      docs/brief-format.md
  8. +81
    -0
      docs/manual-verification.md
  9. +134
    -0
      docs/toolchain-guide.md
  10. +75
    -0
      docs/verification-log.md
  11. +0
    -0
      drafts/.gitkeep
  12. +256
    -0
      examples/c128-text-viewer/brief.json
  13. +5
    -0
      examples/c128-text-viewer/files/fixtures/crlf-sample.txt
  14. +5
    -0
      examples/c128-text-viewer/files/fixtures/lf-sample.txt
  15. +100
    -0
      examples/c128-text-viewer/files/fixtures/sample.txt
  16. +79
    -0
      examples/c128-text-viewer/files/src/main.c
  17. +247
    -0
      examples/traffic-control-64/brief.json
  18. +136
    -0
      examples/traffic-control-64/files/src/main.c
  19. +256
    -0
      schema/project-brief.schema.json
  20. +37
    -0
      templates/brief/draft.json
  21. +19
    -0
      templates/interview/handoff-report.md
  22. +46
    -0
      templates/interview/question-bank.md
  23. +32
    -0
      templates/interview/spec-review.md
  24. +10
    -0
      templates/repo/.gitattributes
  25. +21
    -0
      templates/repo/.gitignore
  26. +96
    -0
      templates/repo/AGENTS.md.tmpl
  27. +3
    -0
      templates/repo/CLAUDE.md
  28. +74
    -0
      templates/repo/README.md.tmpl
  29. +12
    -0
      templates/repo/docs/manual-tests.md.tmpl
  30. +6
    -0
      templates/repo/docs/milestones.md.tmpl
  31. +66
    -0
      templates/repo/docs/spec.md.tmpl
  32. +60
    -0
      templates/repo/docs/toolchain.md.tmpl
  33. +13
    -0
      templates/repo/docs/verification-status.md.tmpl
  34. +31
    -0
      templates/repo/tools/build.ps1
  35. +48
    -0
      templates/repo/tools/check-prereqs.ps1
  36. +51
    -0
      templates/repo/tools/from-commodore.ps1
  37. +248
    -0
      templates/repo/tools/lib.ps1
  38. +42
    -0
      templates/repo/tools/run.ps1
  39. +158
    -0
      templates/repo/tools/smoke.ps1
  40. +58
    -0
      templates/repo/tools/to-commodore.ps1
  41. +25
    -0
      templates/starters/asm-onboard/src/STARTER.TXT.tmpl
  42. +7
    -0
      templates/starters/basic-7/src/main.bas.tmpl
  43. +7
    -0
      templates/starters/basic-v2/src/main.bas.tmpl
  44. +31
    -0
      templates/starters/cc65-asm/src/main.s.tmpl
  45. +27
    -0
      templates/starters/cc65-c/src/main.c.tmpl
  46. +1
    -0
      templates/starters/cc65-c/starter.json
  47. +48
    -0
      templates/starters/cc65-common/src/smoke.c
  48. +17
    -0
      templates/starters/cc65-common/src/smoke.h
  49. +5
    -0
      templates/starters/cc65-mixed/src/frame.h
  50. +18
    -0
      templates/starters/cc65-mixed/src/frame.s
  51. +35
    -0
      templates/starters/cc65-mixed/src/main.c.tmpl
  52. +1
    -0
      templates/starters/cc65-mixed/starter.json
  53. +433
    -0
      tests/Run-FoundryTests.ps1
  54. +182
    -0
      tests/briefs/c128-40-asm.json
  55. +182
    -0
      tests/briefs/c128-40-basic7.json
  56. +182
    -0
      tests/briefs/c128-80-basic7.json
  57. +182
    -0
      tests/briefs/conflict-80col-on-c64.json
  58. +186
    -0
      tests/briefs/conflict-basic7-on-c64.json
  59. +185
    -0
      tests/briefs/conflict-build-location.json
  60. +188
    -0
      tests/briefs/conflict-override-capability.json
  61. +64
    -0
      tests/briefs/draft-paused.json
  62. +191
    -0
      tests/briefs/dual-c64mode-c.json
  63. +192
    -0
      tests/briefs/dual-c64mode.json
  64. +191
    -0
      tests/briefs/dual-native.json
  65. +191
    -0
      tests/briefs/multi-display-c.json
  66. +186
    -0
      tests/briefs/on-commodore-basic.json
  67. +187
    -0
      tests/briefs/on-commodore-basic7.json
  68. +187
    -0
      tests/briefs/override-asm.json
  69. +185
    -0
      tests/briefs/unverified-onboard-asm.json
  70. +1005
    -0
      tools/Foundry.psm1
  71. +40
    -0
      tools/New-FoundryDraft.ps1
  72. +57
    -0
      tools/New-FoundryProject.ps1
  73. +22
    -0
      tools/Show-FoundrySpec.ps1
  74. +43
    -0
      tools/Test-FoundryBrief.ps1

+ 5
- 0
.gitattributes 查看文件

@@ -0,0 +1,5 @@
* text=auto
*.ps1 text eol=crlf
*.psm1 text eol=crlf
# Example fixtures must keep their exact bytes (line-ending tests depend on them)
examples/**/fixtures/** -text

+ 12
- 0
.gitignore 查看文件

@@ -0,0 +1,12 @@
# Interview drafts are personal work in progress
drafts/*
!drafts/.gitkeep

# Test output
tests/results/

# Editor / OS
.vscode/
.idea/
Thumbs.db
.DS_Store

+ 122
- 0
AGENTS.md 查看文件

@@ -0,0 +1,122 @@
# AGENTS.md - C64/C128 Dev Foundry

You are the coding agent running the Foundry. You turn a plain-English idea for a Commodore 64
or Commodore 128 program into a new, self-contained Git repository. A fresh agent can build the
program from that repository alone. You do the reasoning and writing; the PowerShell tools in
`tools/` do validation, file creation and Git deterministically.

Work in this order: **interview -> toolchain decision -> spec review -> generation -> handoff.**
Never generate a project the user has not approved.

## Files you use

| Path | Use |
|---|---|
| `docs/brief-format.md` | Every brief field, its meaning and its rules. Read before writing a brief. |
| `schema/project-brief.schema.json` | Structural schema (checked by the validator). |
| `docs/toolchain-guide.md` | How to choose language, recipe and emulator settings. Read before step 3. |
| `catalog/recipes.json` | Verified starter configurations, tools, versions, capabilities, sources. |
| `templates/interview/` | Question bank, spec-review layout and handoff report layout. |
| `templates/brief/draft.json` | Empty draft. |
| `examples/*/brief.json` | Two complete approved briefs, with project files in `files/`. |
| `drafts/` | Saved interview drafts (not committed). |

Tools (PowerShell 7, run from the Foundry root):

| Command | Purpose |
|---|---|
| `pwsh -File tools/New-FoundryDraft.ps1 -Name "<name>" -Idea "<idea>"` | Create `drafts/<slug>.json` |
| `pwsh -File tools/Test-FoundryBrief.ps1 drafts/<slug>.json` | Show what is missing, conflicts, and where to resume |
| `pwsh -File tools/Show-FoundrySpec.ps1 drafts/<slug>.json` | Render the spec for the user to review |
| `pwsh -File tools/New-FoundryProject.ps1 drafts/<slug>.json` | Generate the repo (approved briefs only) |

## 1. Accept the idea

- Take whatever the user gives you: one line or a page. Reuse every fact they already supplied. Never ask for something they have already said.
- Reply with (a) a short summary of the program as you understand it, and (b) the **smallest version that would already be useful or playable**. Propose it concretely: "one intersection, cars from four sides, three crashes ends the shift".
- Create the draft immediately: `tools/New-FoundryDraft.ps1`. Fill `project.summary`, `project.kind` and `project.smallestUsefulVersion`, and save.
- If the idea is a recreation of a specific existing commercial game (its name, characters, art, levels or look), say you will help build an original game in that genre instead, and carry on with the original design.

## 2. Interview

Ask **a few focused questions at a time** (2-4), in this stage order. Stop drilling once you can write observable acceptance criteria. Use `templates/interview/question-bank.md` for wording and defaults.

1. **Target** - machine and display (C64 / C128 native 40-column / C128 native 80-column / both); PAL, NTSC or both; real hardware or VICE only. For both machines, ask: one C64 program run in C64 mode on the C128, or a native C128 build too? Native 40-column and 80-column are separate targets.
2. **First release** - what it must do, what is out, and how we will *see* that it works (observable success criteria).
3. **Details that affect the design** - only where relevant: controls, visuals, sound, persistence, file formats, peripherals (drive, joystick port, printer), hardware budgets (frame time, memory).
4. **Toolchain preference** - offer the user the chance to name a language or tool; otherwise you decide (step 3).
5. **Destination** - the folder for the new repository. Default: `../Foundry Projects/<slug>` (relative paths resolve against the Foundry root). It must not be inside the Foundry.

Rules:

- **Label practical defaults.** When the user has no preference, propose one and record it with `"source": "default"`. Record the user's own choices as `"user"`, topics that do not apply as `"n/a"`, and undecided ones as `"open"` with an `openDecisions` entry that states the default used meanwhile.
- **Unresolved decisions stay visible.** Put them in `openDecisions` and mention them in the spec review. Don't silently pick.
- **Save after every round.** Update the draft JSON (`interview.stage`, `interview.openQuestions`, `interview.notes`, and the answered fields) and run `tools/Test-FoundryBrief.ps1` on it.
- **Resuming.** If the user returns to a draft (or a new session starts), run `pwsh -File tools/Test-FoundryBrief.ps1 drafts/<slug>.json`. It prints the stage to resume at and the next questions, including the saved `interview.openQuestions`. Summarize what is already decided in two or three lines, then continue from that stage.

## 3. Choose the language and toolchain

Follow `docs/toolchain-guide.md`. In short:

- Choose the **simplest language that meets the brief**. Weigh CPU timing, memory and code size, display and sound needs, disk I/O, portability between targets, and maintainability. Consider mixed C + assembly only when a specific subsystem needs it, and name the subsystem.
- Pick a recipe and combination from `catalog/recipes.json`. Prefer combinations with `"status": "verified"`. An unverified one is allowed, but tell the user, because the generated docs carry a validation plan instead of an automated smoke test.
- Record in the brief: `toolchain.recommended`, `toolchain.reasons` (plain English), `toolchain.alternatives` (with why not), `toolchain.assumptionsToVerify`, and `capabilities` (catalog names, also per requirement).
- Explain the decision to the user in plain English in 3-5 sentences.
- **User override.** If the user asks for a different language, record `toolchain.override` (`requestedLanguage`, `reason`) and set `toolchain.language` to it. The approved override takes precedence over your recommendation. Then validate:
- If the validator reports a **CONFLICT** (exit code 4), quote the specific conflict to the user. Typical ones: BASIC 7.0 on a C64; 80 columns on a C64; BASIC for frame-locked animation; an on-Commodore build with a cross-compiler. **Ask the user which constraint to change**: the override, or the target/requirement it conflicts with. Do not resolve it yourself.
- If it validates, the override is compatible: keep it, and say so.

## 4. Show the spec and get approval

When `Test-FoundryBrief.ps1` reports only `review` items missing:

1. Run `pwsh -File tools/Show-FoundrySpec.ps1 drafts/<slug>.json` and show the user the result (or a faithful condensed version using `templates/interview/spec-review.md`). It must include the scope, assumptions, target and toolchain, the first milestone, the acceptance checks and the destination folder.
2. Ask for approval.
3. **Revision before generation:** apply the change to the draft, keep `status: "draft"`, re-validate, and show the updated spec again. Repeat until approved.
4. On approval, set `status: "approved"` and `approval.approvedBy` / `approval.approvedOn` (YYYY-MM-DD). Then run `pwsh -File tools/Test-FoundryBrief.ps1 drafts/<slug>.json -Mode Approved`.

## 5. Write the project-specific starter files

The recipe provides a generic starter. For a better first milestone, write project-specific
files in a folder next to the brief (for example `drafts/<slug>-files/src/main.c`), set
`starter.filesDir` to that folder (relative to the brief), and make `starter.smokeChecks` describe
rows and text the starter really draws. Rules:

- Keep the smoke hooks: cc65 C calls `smoke_capture(); smoke_ready();` after the first screen is drawn (`src/smoke.c` comes from the template). ca65 programs need the `smoke_ready` label. BASIC programs need `POKE 679,1` (V2) or `POKE 3071,1` (7.0).
- Put sample inputs in `<filesDir>/fixtures/` and list them in the target's `disk.files` when the program reads them from disk.
- Files ending in `.tmpl` are rendered with `{{PLACEHOLDERS}}` (see `docs/brief-format.md`). Others are copied as-is.
- Use `examples/` as the model.

## 6. Generate

```powershell
pwsh -File tools/New-FoundryProject.ps1 drafts/<slug>.json
```

The generator:

1. Validates the brief and the destination. An existing non-empty folder or project repo is refused untouched.
2. Builds the repo in a temporary sibling folder.
3. Checks that no placeholder is left.
4. Runs `git init` on `main` and commits if a Git identity is configured.
5. Moves the result into place.
6. Runs the new repo's `tools/smoke.ps1`.

If it refuses, report the exact reason and ask the user how to proceed. Never delete or rename the user's folders to make room.

## 7. Hand off

Report, using `templates/interview/handoff-report.md`:

- the output path;
- Git status (committed, or staged with the command to commit);
- starter verification status per target (passed / failed / not run: missing tool, with the tool and first command / manual only), and what remains unverified;
- the exact message for a **fresh** implementation session in that folder (the generator prints it);
- what the user should do to verify the project themselves (README "First run").

## Rules

- Every fact in the brief comes from the user or is a labelled default. Don't invent requirements.
- Keep the user's words for the idea (`project.idea`) verbatim.
- Use verified documentation (`catalog/recipes.json` sources and `docs/toolchain-guide.md`) for commands and emulator options. If you need a tool or option that is not in the catalog, check its primary documentation first. Record it as an assumption to verify, and propose a catalog update with its source.
- Don't change `catalog/`, `templates/` or `tools/` while running an interview. Those are Foundry maintenance. When you do change them, run `pwsh -File tests/Run-FoundryTests.ps1` afterwards.

+ 3
- 0
CLAUDE.md 查看文件

@@ -0,0 +1,3 @@
# Claude Code

Read and follow [AGENTS.md](AGENTS.md). It contains the complete Foundry workflow (interview, review, generation, handoff).

+ 115
- 0
README.md 查看文件

@@ -0,0 +1,115 @@
# C64 / C128 Dev Foundry

Turn a plain-English idea for a Commodore 64 or Commodore 128 program into a new, self-contained
local Git repository. The repository holds an approved spec, a toolchain decision, milestones, a
manual test plan and a starter program that builds and runs in VICE. Any fresh coding agent can
open it, read `AGENTS.md`, and build the program without this Foundry or the original
conversation.

Version 1 runs inside a coding agent you already use (Claude Code, Codex, or similar). The agent
holds the interview and writes the project content, following [AGENTS.md](AGENTS.md).
Validation, file creation and Git are done by small deterministic PowerShell tools. No AI API
key is needed.

## What it supports

| Dimension | Supported |
|---|---|
| Runtime target | C64; C128 native 40-column; C128 native 80-column; dual C64/C128 (same C64 program in C64 mode, or a native build per machine); C128 40+80-column |
| Build location | Windows cross-development (default); on-Commodore authoring for BASIC (verified) and native assemblers (validation plan) |
| Testing | VICE by default (automated headless smoke test); real-hardware steps when requested |
| Language | BASIC V2, BASIC 7.0, C (cc65), 6502 assembly (ca65), mixed C + assembly |

Details: [docs/toolchain-guide.md](docs/toolchain-guide.md).

## Prerequisites

| Tool | Needed for | Install |
|---|---|---|
| PowerShell 7+ (`pwsh`) | The Foundry tools and generated-repo scripts | `winget install --id Microsoft.PowerShell -e` |
| Git | Initializing generated repos | `winget install --id Git.Git -e`; set `git config --global user.name` / `user.email` to get an initial commit |
| VICE 3.10 (x64sc, x128, c1541, petcat) | Running and smoke-testing starters, BASIC tokenizing, disk images | `winget install --id VICE-Team.VICE.GTK3 -e`, or [download](https://vice-emu.sourceforge.io/index.html#download) and set `VICE_HOME` |
| cc65 (cl65) | C / assembly projects | [cc65 snapshot for Windows](https://sourceforge.net/projects/cc65/files/cc65-snapshot-win64.zip): unzip, then set `CC65_HOME` or add `bin` to `PATH` |

Only PowerShell and Git are needed to run interviews and generate repos. VICE and cc65 are
needed to verify starters. When a tool is missing, the generator still produces the repo and
reports exactly which tool is missing and what is still unverified. Tools are found through
`VICE_HOME` / `CC65_HOME`, then `PATH`, then the usual install folders (for example
`C:\Program Files\GTK3VICE-3.10-win64\bin`).

## Start an interview

Open your coding agent in this folder and send:

> Read AGENTS.md and run the Foundry interview. My idea: *&lt;describe your C64 or C128 program in a sentence or a page&gt;*

The agent summarizes the idea, proposes the smallest useful version, and asks a few questions at a
time. It saves a draft in `drafts/` after each round. To continue later, in a new session:

> Read AGENTS.md and resume the Foundry interview from drafts/&lt;slug&gt;.json

Before anything is created, the agent shows the complete proposed spec: scope, assumptions,
target and toolchain, first milestone, acceptance checks and destination folder. Generation
happens only after you approve it.

## Commands

```powershell
# Interview helpers (the agent runs these)
pwsh -File tools/New-FoundryDraft.ps1 -Name "Moon Miner" -Idea "A small mining game ..."
pwsh -File tools/Test-FoundryBrief.ps1 drafts/moon-miner.json # missing items, conflicts, resume stage
pwsh -File tools/Show-FoundrySpec.ps1 drafts/moon-miner.json # spec to approve

# Generate from an approved brief
pwsh -File tools/New-FoundryProject.ps1 drafts/moon-miner.json
pwsh -File tools/New-FoundryProject.ps1 drafts/moon-miner.json -Destination "D:\Retro Projects\Moon Miner"

# Regenerate the two examples (destination: ..\Foundry Projects\<slug>)
pwsh -File tools/New-FoundryProject.ps1 examples/traffic-control-64/brief.json
pwsh -File tools/New-FoundryProject.ps1 examples/c128-text-viewer/brief.json

# Automated checks (about 4 minutes with VICE and cc65 installed)
pwsh -File tests/Run-FoundryTests.ps1
pwsh -File tests/Run-FoundryTests.ps1 -Group validation,safety # fast subset, no emulator
```

The generator refuses to write into an existing non-empty folder or project repository. It
builds in a temporary sibling folder and moves the result into place only when everything
succeeded, so an interrupted run leaves nothing half-written and can simply be retried.

## Examples

| Example | Brief | Generated repo |
|---|---|---|
| Traffic Control 64: original C64 traffic game, manual signals, C + ca65 | [examples/traffic-control-64](examples/traffic-control-64/brief.json) | `..\Foundry Projects\traffic-control-64` |
| C128 Text Viewer: native 80-column SEQ file pager, C (cc65), sample files on D64 | [examples/c128-text-viewer](examples/c128-text-viewer/brief.json) | `..\Foundry Projects\c128-text-viewer` |

## Verifying a generated project (fresh agent session)

1. `cd` into the generated folder and run `pwsh -File tools/check-prereqs.ps1`, then `pwsh -File tools/smoke.ps1`. Expect `[PASS]` for every target.
2. `pwsh -File tools/run.ps1` shows the starter screen described in the README.
3. Open a **new** coding-agent session in that folder and send the message printed by the generator (also in the generated README):

> Read AGENTS.md and follow it. Build and verify the starter (milestone M0) first, then implement the next milestone one task at a time, reporting after each task what changed, which checks ran, and exactly how I should verify it.

Full checklist: [docs/manual-verification.md](docs/manual-verification.md).

## Repository layout

| Path | Contents |
|---|---|
| `AGENTS.md` | Interview, review, generation and handoff workflow for the coding agent |
| `docs/brief-format.md` | The structured project brief, field by field |
| `docs/toolchain-guide.md` | Language/toolchain selection, verified starter catalog, emulator options, sources |
| `docs/manual-verification.md` | Manual verification guide for the Foundry |
| `docs/verification-log.md` | Commands run to verify this version, and their outcomes; pending items |
| `schema/project-brief.schema.json` | JSON Schema for briefs |
| `catalog/recipes.json` | Machine-readable toolchain catalog (tools, versions, combinations, status, sources) |
| `templates/repo/` | Generated-repo documents and scripts |
| `templates/starters/` | Default starter source per recipe and language |
| `templates/interview/` | Question bank, spec-review and handoff-report layouts |
| `templates/brief/draft.json` | Empty draft |
| `tools/` | `Foundry.psm1` plus the command scripts |
| `examples/` | Two complete approved briefs with project-specific starter files |
| `tests/` | `Run-FoundryTests.ps1` and test briefs (C128 40-column, dual-target, on-Commodore, override, conflicts, draft) |
| `drafts/` | Your interview drafts (ignored by Git) |

+ 265
- 0
catalog/recipes.json 查看文件

@@ -0,0 +1,265 @@
{
"catalogVersion": "1.0",
"verifiedOn": "2026-11-26",
"verifiedWith": {
"cc65": "cl65 V2.19 - Git cc3c40c (Windows x64 snapshot)",
"vice": "VICE 3.10 GTK3 win64 (x64sc, x128, c1541, petcat)",
"powershell": "PowerShell 7.6.7",
"git": "git 2.53.0.windows.1",
"os": "Windows 11 Pro 10.0.26200"
},
"tools": {
"cl65": {
"package": "cc65",
"executable": "cl65",
"purpose": "cc65 compile/assemble/link driver (C and ca65 assembly)",
"verifiedVersion": "cl65 V2.19 - Git cc3c40c",
"versionArgs": ["--version"],
"envVar": "CC65_HOME",
"searchPaths": ["C:\\cc65\\bin", "C:\\Program Files\\cc65\\bin"],
"install": {
"source": "https://cc65.github.io/getting-started.html",
"download": "https://sourceforge.net/projects/cc65/files/cc65-snapshot-win64.zip",
"firstCommand": "Download https://sourceforge.net/projects/cc65/files/cc65-snapshot-win64.zip, unzip it (for example to C:\\cc65), then run: [Environment]::SetEnvironmentVariable('CC65_HOME','C:\\cc65','User') and open a new terminal."
},
"docs": ["https://cc65.github.io/doc/cl65.html", "https://cc65.github.io/doc/ca65.html"]
},
"x64sc": {
"package": "vice",
"executable": "x64sc",
"purpose": "VICE cycle-exact Commodore 64 emulator",
"verifiedVersion": "VICE 3.10",
"versionArgs": [],
"envVar": "VICE_HOME",
"searchPaths": ["C:\\Program Files\\GTK3VICE-*\\bin", "C:\\Program Files\\SDL2VICE-*", "%LOCALAPPDATA%\\Microsoft\\WinGet\\Packages\\VICE-Team.VICE.GTK3*\\*\\bin"],
"install": {
"source": "https://vice-emu.sourceforge.io/index.html#download",
"download": "https://sourceforge.net/projects/vice-emu/files/releases/binaries/windows/GTK3VICE-3.10-win64.zip/download",
"firstCommand": "winget install --id VICE-Team.VICE.GTK3 -e (or unzip GTK3VICE-3.10-win64.zip and set VICE_HOME to the unzipped folder)"
},
"docs": ["https://vice-emu.sourceforge.io/vice_2.html#SEC50", "https://vice-emu.sourceforge.io/vice_6.html", "https://vice-emu.sourceforge.io/vice_12.html"]
},
"x128": {
"package": "vice",
"executable": "x128",
"purpose": "VICE Commodore 128 emulator (VIC-II 40-column and VDC 80-column)",
"verifiedVersion": "VICE 3.10",
"versionArgs": [],
"envVar": "VICE_HOME",
"searchPaths": ["C:\\Program Files\\GTK3VICE-*\\bin", "C:\\Program Files\\SDL2VICE-*", "%LOCALAPPDATA%\\Microsoft\\WinGet\\Packages\\VICE-Team.VICE.GTK3*\\*\\bin"],
"install": {
"source": "https://vice-emu.sourceforge.io/index.html#download",
"download": "https://sourceforge.net/projects/vice-emu/files/releases/binaries/windows/GTK3VICE-3.10-win64.zip/download",
"firstCommand": "winget install --id VICE-Team.VICE.GTK3 -e (or unzip GTK3VICE-3.10-win64.zip and set VICE_HOME to the unzipped folder)"
},
"docs": ["https://vice-emu.sourceforge.io/vice_7.html#SEC194", "https://vice-emu.sourceforge.io/vice_2.html#SEC50"]
},
"c1541": {
"package": "vice",
"executable": "c1541",
"purpose": "VICE disk image tool (create D64/D71/D81, copy PRG and SEQ files in and out)",
"verifiedVersion": "c1541 (VICE 3.10)",
"versionArgs": ["-version"],
"envVar": "VICE_HOME",
"searchPaths": ["C:\\Program Files\\GTK3VICE-*\\bin", "C:\\Program Files\\SDL2VICE-*", "%LOCALAPPDATA%\\Microsoft\\WinGet\\Packages\\VICE-Team.VICE.GTK3*\\*\\bin"],
"install": {
"source": "https://vice-emu.sourceforge.io/index.html#download",
"download": "https://sourceforge.net/projects/vice-emu/files/releases/binaries/windows/GTK3VICE-3.10-win64.zip/download",
"firstCommand": "winget install --id VICE-Team.VICE.GTK3 -e (c1541 ships with VICE)"
},
"docs": ["https://vice-emu.sourceforge.io/vice_14.html"]
},
"petcat": {
"package": "vice",
"executable": "petcat",
"purpose": "VICE BASIC tokenizer/detokenizer (text listing <-> PRG)",
"verifiedVersion": "petcat (VICE 3.10)",
"versionArgs": ["-version"],
"envVar": "VICE_HOME",
"searchPaths": ["C:\\Program Files\\GTK3VICE-*\\bin", "C:\\Program Files\\SDL2VICE-*", "%LOCALAPPDATA%\\Microsoft\\WinGet\\Packages\\VICE-Team.VICE.GTK3*\\*\\bin"],
"install": {
"source": "https://vice-emu.sourceforge.io/index.html#download",
"download": "https://sourceforge.net/projects/vice-emu/files/releases/binaries/windows/GTK3VICE-3.10-win64.zip/download",
"firstCommand": "winget install --id VICE-Team.VICE.GTK3 -e (petcat ships with VICE)"
},
"docs": ["https://vice-emu.sourceforge.io/vice_16.html"]
}
},
"capabilities": {
"text-ui": "Text screens, menus and status lines (PRINT / conio / KERNAL CHROUT).",
"keyboard-input": "Reading keys from the keyboard.",
"joystick-input": "Reading a joystick in control port 1 or 2.",
"disk-seq-io": "Opening and reading or writing sequential (SEQ) or program files on a disk drive.",
"sprites": "VIC-II hardware sprites.",
"custom-charset": "Redefined character sets.",
"sid-sound": "Sound effects or music through the SID.",
"smooth-animation": "Several objects updated every frame or every few frames in a steady frame-locked loop.",
"raster-interrupts": "Cycle-sensitive raster interrupts, raster splits or stable raster timing.",
"vdc-80col": "Native C128 80-column output through the VDC (8563/8568)."
},
"platforms": {
"c64": { "title": "Commodore 64", "displays": ["vicii-40"] },
"c128-native": { "title": "Commodore 128 in native C128 mode", "displays": ["vicii-40", "vdc-80"] },
"c128-c64mode": { "title": "Commodore 128 running in C64 mode", "displays": ["vicii-40"] }
},
"displays": {
"vicii-40": "VIC-II 40x25 text/graphics screen (C64, or C128 40-column)",
"vdc-80": "VDC 80x25 text screen (C128 native 80-column, RGBI monitor)"
},
"languages": {
"basic-v2": {
"title": "Commodore BASIC V2 (C64 ROM BASIC)",
"platforms": ["c64", "c128-c64mode"],
"capabilities": ["text-ui", "keyboard-input", "joystick-input", "disk-seq-io", "sprites", "custom-charset", "sid-sound"],
"screenEncoding": "screen-upper",
"strengths": "No compiler needed; editable on the machine itself; quickest to change.",
"limits": "Interpreted: roughly hundreds of simple statements per second, so many moving objects or frame-locked logic are out of reach. No 80-column output."
},
"basic-7": {
"title": "Commodore BASIC 7.0 (C128 ROM BASIC)",
"platforms": ["c128-native"],
"capabilities": ["text-ui", "keyboard-input", "joystick-input", "disk-seq-io", "sprites", "custom-charset", "sid-sound", "vdc-80col"],
"screenEncoding": "screen-upper",
"strengths": "Structured loops, SPRITE/SOUND/PLAY/GRAPHIC commands, 80-column text with no extra code; editable on the C128.",
"limits": "Interpreted and slow for real-time games; C128 native mode only."
},
"c": {
"title": "C (cc65)",
"platforms": ["c64", "c128-native", "c128-c64mode"],
"capabilities": ["text-ui", "keyboard-input", "joystick-input", "disk-seq-io", "sprites", "custom-charset", "sid-sound", "smooth-animation", "vdc-80col"],
"screenEncoding": "screen-mixed",
"strengths": "Readable, portable between C64 and C128 with #ifdef, conio/cbm file I/O library, much faster than BASIC.",
"limits": "Larger and slower code than hand-written assembly; not suitable for cycle-exact raster work without assembly help."
},
"asm-ca65": {
"title": "6502 assembly (ca65)",
"platforms": ["c64", "c128-native", "c128-c64mode"],
"capabilities": ["text-ui", "keyboard-input", "joystick-input", "disk-seq-io", "sprites", "custom-charset", "sid-sound", "smooth-animation", "raster-interrupts", "vdc-80col"],
"screenEncoding": "screen-upper",
"strengths": "Full control of timing and memory; smallest and fastest code.",
"limits": "Most effort to write, review and change."
},
"mixed-c-asm": {
"title": "C (cc65) with ca65 assembly modules",
"platforms": ["c64", "c128-native", "c128-c64mode"],
"capabilities": ["text-ui", "keyboard-input", "joystick-input", "disk-seq-io", "sprites", "custom-charset", "sid-sound", "smooth-animation", "raster-interrupts", "vdc-80col"],
"screenEncoding": "screen-mixed",
"strengths": "Game/app logic in C, timing-critical subsystems (frame sync, raster IRQs, inner loops) in assembly.",
"limits": "Two languages and the cc65 calling convention to keep straight."
},
"asm-onboard": {
"title": "6502 assembly written and assembled on the Commodore (native assembler)",
"platforms": ["c64", "c128-native"],
"capabilities": ["text-ui", "keyboard-input", "joystick-input", "disk-seq-io", "sprites", "custom-charset", "sid-sound", "smooth-animation", "raster-interrupts", "vdc-80col"],
"screenEncoding": "screen-upper",
"strengths": "Authentic on-machine workflow.",
"limits": "Depends on a user-supplied native assembler; source lives in the assembler's own file format."
}
},
"recipes": {
"cc65": {
"title": "Windows cross-development with cc65 (C, ca65 assembly or mixed) and VICE",
"buildLocations": ["windows-cross"],
"buildKind": "cc65",
"languages": ["c", "asm-ca65", "mixed-c-asm"],
"tools": ["cl65"],
"starters": { "c": "cc65-c", "mixed-c-asm": "cc65-mixed", "asm-ca65": "cc65-asm" },
"combos": [
{ "platform": "c64", "display": "vicii-40", "languages": ["c", "mixed-c-asm", "asm-ca65"], "cc65Target": "c64", "emulator": "x64sc", "emulatorArgs": [], "status": "verified" },
{ "platform": "c128-native", "display": "vicii-40", "languages": ["c", "mixed-c-asm", "asm-ca65"], "cc65Target": "c128", "emulator": "x128", "emulatorArgs": ["-40col"], "status": "verified" },
{ "platform": "c128-native", "display": "vdc-80", "languages": ["c", "mixed-c-asm"], "cc65Target": "c128", "emulator": "x128", "emulatorArgs": ["-80col"], "status": "verified" },
{ "platform": "c128-native", "display": "vdc-80", "languages": ["asm-ca65"], "cc65Target": "c128", "emulator": "x128", "emulatorArgs": ["-80col"], "status": "unverified",
"validationPlan": ["Write the starter screen through the KERNAL (CHROUT) after the 80-column editor is active, or drive the VDC through $D600/$D601.", "Add a VDC read-back probe like the C starter's src/smoke.c and dump it in tools/smoke.ps1.", "Run tools/smoke.ps1 and inspect build/smoke/<target>/screen.png."] },
{ "platform": "c128-c64mode", "display": "vicii-40", "languages": ["c", "mixed-c-asm", "asm-ca65"], "cc65Target": "c64", "emulator": "x128", "emulatorArgs": ["-go64"], "status": "verified" }
],
"commands": {
"c": "cl65 -t <c64|c128> -g -O -I src -o build/<name>.prg -Ln build/<name>.lbl -m build/<name>.map src/*.c src/*.s",
"asm-ca65": "cl65 -t <c64|c128> -C <c64|c128>-asm.cfg -u __EXEHDR__ -g -o build/<name>.prg -Ln build/<name>.lbl -m build/<name>.map src/*.s"
},
"sources": [
"https://cc65.github.io/doc/cl65.html",
"https://cc65.github.io/doc/c64.html#toc4.2",
"https://cc65.github.io/doc/c128.html",
"https://cc65.github.io/doc/ca65.html",
"https://vice-emu.sourceforge.io/vice_2.html#SEC50",
"https://vice-emu.sourceforge.io/vice_7.html#SEC194",
"https://vice-emu.sourceforge.io/vice_12.html"
]
},
"basic-petcat": {
"title": "BASIC written on Windows as a text listing, tokenized with petcat, run in VICE",
"buildLocations": ["windows-cross"],
"buildKind": "petcat",
"languages": ["basic-v2", "basic-7"],
"tools": ["petcat"],
"starters": { "basic-v2": "basic-v2", "basic-7": "basic-7" },
"combos": [
{ "platform": "c64", "display": "vicii-40", "languages": ["basic-v2"], "dialect": "2", "emulator": "x64sc", "emulatorArgs": [], "status": "verified" },
{ "platform": "c128-c64mode", "display": "vicii-40", "languages": ["basic-v2"], "dialect": "2", "emulator": "x128", "emulatorArgs": ["-go64"], "status": "verified" },
{ "platform": "c128-native", "display": "vicii-40", "languages": ["basic-7"], "dialect": "70", "emulator": "x128", "emulatorArgs": ["-40col"], "status": "verified" },
{ "platform": "c128-native", "display": "vdc-80", "languages": ["basic-7"], "dialect": "70", "emulator": "x128", "emulatorArgs": ["-80col"], "status": "verified" }
],
"commands": {
"basic-v2": "petcat -w2 -f -o build/<name>.prg -- src/main.bas",
"basic-7": "petcat -w70 -f -o build/<name>.prg -- src/main.bas"
},
"sources": [
"https://vice-emu.sourceforge.io/vice_16.html",
"https://vice-emu.sourceforge.io/vice_2.html#SEC50",
"https://vice-emu.sourceforge.io/vice_12.html"
]
},
"basic-onboard": {
"title": "BASIC authored on the Commodore (or in VICE) with the repo kept on the Windows host; transfer by disk image",
"buildLocations": ["on-commodore"],
"buildKind": "petcat",
"languages": ["basic-v2", "basic-7"],
"tools": ["petcat", "c1541"],
"starters": { "basic-v2": "basic-v2", "basic-7": "basic-7" },
"onCommodore": {
"targetTool": "The built-in BASIC screen editor (BASIC V2 on the C64, BASIC 7.0 on the C128)",
"diskFormat": "d64",
"hostToTarget": "tools/to-commodore.ps1 tokenizes src/main.bas with petcat and writes it to build/transfer/<slug>.d64 with c1541. Attach that image in VICE (or copy it to a real disk) and LOAD\"<name>\",8 then RUN.",
"targetToHost": "On the Commodore: SAVE\"@0:<name>\",8 onto the transfer disk. On the host: tools/from-commodore.ps1 reads the PRG back with c1541 and detokenizes it with petcat into src/main.bas, then review the diff and commit."
},
"combos": [
{ "platform": "c64", "display": "vicii-40", "languages": ["basic-v2"], "dialect": "2", "emulator": "x64sc", "emulatorArgs": [], "status": "verified" },
{ "platform": "c128-native", "display": "vicii-40", "languages": ["basic-7"], "dialect": "70", "emulator": "x128", "emulatorArgs": ["-40col"], "status": "verified" },
{ "platform": "c128-native", "display": "vdc-80", "languages": ["basic-7"], "dialect": "70", "emulator": "x128", "emulatorArgs": ["-80col"], "status": "verified" }
],
"commands": {
"to-commodore": "petcat -w2 -f -o build/transfer/<name>.prg -- src/main.bas ; c1541 -format \"<name>,fd\" d64 build/transfer/<slug>.d64 -write build/transfer/<name>.prg <name>",
"from-commodore": "c1541 -attach build/transfer/<slug>.d64 -read <name> build/transfer/<name>.prg ; petcat -nh -2 -f -o src/main.bas -- build/transfer/<name>.prg"
},
"sources": [
"https://vice-emu.sourceforge.io/vice_14.html",
"https://vice-emu.sourceforge.io/vice_16.html",
"https://vice-emu.sourceforge.io/vice_2.html#SEC50"
]
},
"asm-onboard": {
"title": "Assembly written and assembled on the Commodore with a user-supplied native assembler",
"buildLocations": ["on-commodore"],
"buildKind": "none",
"languages": ["asm-onboard"],
"tools": ["c1541"],
"starters": { "asm-onboard": "asm-onboard" },
"onCommodore": {
"targetTool": "A native assembler supplied by the user (for example Turbo Macro Pro on the C64); not bundled or verified by the Foundry",
"diskFormat": "d64",
"hostToTarget": "tools/to-commodore.ps1 copies the repo's transfer files into build/transfer/<slug>.d64 with c1541; attach the image in VICE or write it to a real disk.",
"targetToHost": "Save source and the assembled PRG to the transfer disk on the Commodore, then run tools/from-commodore.ps1 to copy them back into src/ and build/."
},
"combos": [
{ "platform": "c64", "display": "vicii-40", "languages": ["asm-onboard"], "emulator": "x64sc", "emulatorArgs": [], "status": "unverified",
"validationPlan": ["Record the assembler name, version and where the user obtains it in docs/toolchain.md.", "Load the assembler in VICE with the transfer disk attached on drive 8.", "Type or load src/STARTER.TXT, assemble to a PRG named in docs/spec.md, save it to the transfer disk.", "Run tools/from-commodore.ps1, then load and run the PRG in VICE and compare with docs/manual-tests.md M0.", "Once it works, change the recipe status to verified in the Foundry catalog with the date and versions."] },
{ "platform": "c128-native", "display": "vicii-40", "languages": ["asm-onboard"], "emulator": "x128", "emulatorArgs": ["-40col"], "status": "unverified",
"validationPlan": ["Same as the C64 plan, using a C128-native assembler or the C128 MONITOR."] },
{ "platform": "c128-native", "display": "vdc-80", "languages": ["asm-onboard"], "emulator": "x128", "emulatorArgs": ["-80col"], "status": "unverified",
"validationPlan": ["Same as the C64 plan, using a C128-native assembler or the C128 MONITOR, in 80-column mode."] }
],
"commands": {},
"sources": ["https://vice-emu.sourceforge.io/vice_14.html"]
}
}
}

+ 148
- 0
docs/brief-format.md 查看文件

@@ -0,0 +1,148 @@
# Project brief format (schema 1.0)

A brief is one JSON file. During the interview it is a **draft** (`drafts/<slug>.json`). After
the user approves the spec it is **approved**, and the generator copies it into the new
repository as `project.json` with a generated `resolved` section added.

- Structure: [schema/project-brief.schema.json](../schema/project-brief.schema.json) (JSON Schema 2020-12, checked first by the validator).
- Rules and cross-checks: `tools/Test-FoundryBrief.ps1` (module function `Test-FoundryBrief`).
- Complete examples: [examples/traffic-control-64/brief.json](../examples/traffic-control-64/brief.json), [examples/c128-text-viewer/brief.json](../examples/c128-text-viewer/brief.json). Smaller ones: [tests/briefs/](../tests/briefs/).

## Draft, validate, resume

```powershell
pwsh -File tools/New-FoundryDraft.ps1 -Name "Moon Miner" -Idea "..." # creates drafts/moon-miner.json
pwsh -File tools/Test-FoundryBrief.ps1 drafts/moon-miner.json # draft mode: what's missing, where to resume
pwsh -File tools/Show-FoundrySpec.ps1 drafts/moon-miner.json # spec for the user to approve
pwsh -File tools/Test-FoundryBrief.ps1 drafts/moon-miner.json -Mode Approved
```

Validator exit codes: `0` valid for the mode, `1` invalid or incomplete, `4` conflicts (constraints the user must choose between).

Validator output kinds:

| Kind | Meaning | Blocks generation |
|---|---|---|
| `MISSING [stage]` | A field the interview still has to fill; grouped by stage | yes (allowed in a draft) |
| `ERROR [path]` | Malformed value or broken reference | yes |
| `CONFLICT [path]` | Two constraints cannot both hold; the message says what to ask the user | yes |
| `WARNING [path]` | Allowed, but tell the user (for example an unverified starter configuration) | no |

The **resume stage** is the first interview stage with missing fields. If nothing is missing, it is the first stage with errors or conflicts. Order: `idea`, `target`, `first-release`, `details`, `toolchain`, `plan`, `destination`, `review`. The validator prints the questions for that stage, after any saved `interview.openQuestions`.

## Fields

### Top level

| Field | Required | Notes |
|---|---|---|
| `schemaVersion` | yes | `"1.0"` |
| `status` | yes | `draft` or `approved`. Only approved briefs can be generated. |
| `approval` | approved | `{ approvedBy, approvedOn: "YYYY-MM-DD", notes? }` |
| `interview` | no | `{ startedOn, stage, openQuestions[], notes[] }`. Used to resume. |
| `destination` | yes | Folder for the new repo. Relative paths resolve against the Foundry root. It must not be inside the Foundry, must not end in a dot or space, and must not use `< > " \| ? *` or reserved names. Spaces are fine. |

### `project`

| Field | Notes |
|---|---|
| `name` | Display name, up to 60 characters |
| `slug` | 3-50 characters, `a-z 0-9 -`; used for file names |
| `idea` | The user's original words, verbatim |
| `summary` | 2-4 sentences, as you understand it |
| `kind` | `game`, `utility`, `demo`, `tool`, `education`, `other` |
| `smallestUsefulVersion` | The smallest useful or playable version you proposed and the user accepted |

### `targets[]` (one per machine/display combination that is verified separately)

| Field | Notes |
|---|---|
| `id` | Short id used in commands (`tools/run.ps1 -Target <id>`), `a-z 0-9 -` |
| `name` | Optional display name |
| `platform` | `c64`, `c128-native` (C128 mode), `c128-c64mode` (C128 running C64 mode) |
| `display` | `vicii-40` (VIC-II 40 columns) or `vdc-80` (C128 VDC 80 columns, `c128-native` only). Native 40- and 80-column operation are **separate targets**. |
| `video` | `pal`, `ntsc` or `pal-ntsc` (smoke test uses PAL unless `ntsc`) |
| `expectedBehavior` | What this target does that can be observed (the artifact behavior for this target) |
| `artifact` | Optional; default `build/<slug>.prg` (or `build/<slug>-<id>.prg` for several native builds) |
| `disk` | Optional disk image: `{ name: "diskname,id", format: d64/d71/d81, image?, files: [{ source, name, type: prg/seq, convert?: "ascii-to-petscii", lineEndings?: "cr"/"keep" }] }`. Use `"$artifact"` as `source` for the program itself. |
| `autostart` | `prg` (default: inject the program) or `disk` (load from the disk image like a user would) |
| `smokeLimitCycles` | Optional VICE cycle budget for the smoke run (default 30 M for `prg`, 80 M for `disk`) |

### `dualTarget` (required when there is more than one target)

| `strategy` | Meaning | Required targets |
|---|---|---|
| `c64-mode-on-both` | One C64 program; the C128 runs it in C64 mode | a `c64` and a `c128-c64mode` target |
| `native-per-target` | Separate C64 and native C128 builds from shared source | a `c64` and a `c128-native` target |
| `multi-display` | One native C128 program verified on 40 and 80 columns | only `c128-native` targets |

`notes` must say what is shared and what differs.

### Build and testing

| Field | Notes |
|---|---|
| `buildLocation` | `windows-cross` (default) or `on-commodore` |
| `onCommodore` | Required for `on-commodore`: `{ targetTool, transfer, diskFormat: d64/d71/d81, programName? (max 16) }` |
| `testing.emulator` | `vice` |
| `testing.realHardware` | `{ requested: bool, reason }`. The reason names the requirement that needs hardware. |

### Scope and requirements

| Field | Notes |
|---|---|
| `scope.firstRelease` | One paragraph |
| `scope.inScope[]`, `scope.outOfScope[]` | Both non-empty |
| `requirements[]` | `{ id: R1.., title, priority: must/should/could, text, acceptance[] (observable), capabilities[] }` |
| `capabilities[]` | Union of what the project needs; names from `catalog/recipes.json` (`text-ui`, `keyboard-input`, `joystick-input`, `disk-seq-io`, `sprites`, `custom-charset`, `sid-sound`, `smooth-animation`, `raster-interrupts`, `vdc-80col`). The validator checks them against the language and display. |

### `design`

Required topics: `controls`, `visuals`, `sound`, `persistence`, `fileFormats`, `peripherals`, `budgets`. Optional: `other[]` with `topic`. Each topic is `{ value, source }`, where `source` is one of:

- `user` - the user decided.
- `default` - the Foundry proposed it and the user accepted. It shows as "practical default".
- `n/a` - does not apply; the value says why.
- `open` - undecided. An `openDecisions` entry with the same `topic` is required.

### `assumptions[]`, `openDecisions[]`

- `assumptions[]`: `{ id, text, status: default/unverified/confirmed }`
- `openDecisions[]`: `{ id, topic, question, default (used until decided), status: open/resolved }`

### `toolchain`

| Field | Notes |
|---|---|
| `recipe` | `cc65`, `basic-petcat`, `basic-onboard`, `asm-onboard` (see the catalog) |
| `language` | `c`, `mixed-c-asm`, `asm-ca65`, `basic-v2`, `basic-7`, `asm-onboard` |
| `recommended` | `{ recipe, language }`: the Foundry's default recommendation |
| `reasons[]` | Plain-English reasons |
| `alternatives[]` | `{ option, whyNot }` |
| `override` | `null` or `{ requestedLanguage, requestedBy, reason, accepted }`. When present, `language` must equal `requestedLanguage` (the override takes precedence). If `language` differs from `recommended` with no override, that is an error. |
| `assumptionsToVerify[]` | Tool or timing assumptions the implementation must check |

### `starter`

| Field | Notes |
|---|---|
| `screenTitle` | Text on row 0, 1-38 characters of `A-Z 0-9` and simple punctuation (no quotes) |
| `expectedScreen` | What the starter shows; copied into the README and manual tests |
| `smokeChecks[]` | Optional `{ row, col, text, description?, targets?[] }`. Default: the title on row 0 and `STARTER OK` on row 2. On `vdc-80` targets, rows 0-3 can be checked. |
| `filesDir` | Optional folder (relative to the brief) with project-specific files that overlay the recipe starter: `src/`, `fixtures/`, anything else. `*.tmpl` files are rendered. |
| `requirements[]` | Requirements the starter (M0) already satisfies |

### `milestones[]`

`{ id: M1.., title, goal, tasks[], manualTests[] }`. M0 ("Starter builds and runs") is added by the generator.

- `tasks[]`: `{ id, text, requirements[] (must exist), outcome (buildable result), check (how completion is verified) }`. Every requirement must be linked from a task or from `starter.requirements`.
- `manualTests[]`: `{ id, title, target (target id, all or real-hardware), setup, steps[], expected[], requirements[] }`

## Template placeholders (`*.tmpl` files)

`{{PROJECT_NAME}}`, `{{PROJECT_NAME_LOWER}}`, `{{PROJECT_SLUG}}`, `{{SCREEN_TITLE}}`, `{{SCREEN_TITLE_LOWER}}`, plus the document blocks used by `templates/repo/` (see `New-DocVariables` in `tools/Foundry.psm1`). Unknown placeholders stop generation. After rendering, any `{{...}}` left in a generated text file also stops generation.

## The `resolved` section of `project.json` (generated)

The generator adds `resolved`: tools (with install sources and detection hints), and per target the exact `build` (cc65 target, defines, label file; or petcat dialect), `disk`, `emulator` (binary, arguments, autostart mode) and `smoke` configuration (ready point, memory dumps, checks, cycle limit), plus `onCommodore` transfer settings. The generated `tools/*.ps1` scripts read only this section, so a generated repo does not need the Foundry.

+ 81
- 0
docs/manual-verification.md 查看文件

@@ -0,0 +1,81 @@
# Manual verification guide

Use this guide to check the Foundry by hand after changing it, or to accept it on a new machine.
The automated suite (`pwsh -File tests/Run-FoundryTests.ps1`) covers the mechanics. These steps
cover what needs human judgment: the interview, the screens, and the handoff to a fresh agent.

Mark each item pass or fail, and note the date and the VICE/cc65 versions used.

## A. Environment

1. `pwsh -v` reports 7.x. `git --version` works.
2. Run `pwsh -File tests/Run-FoundryTests.ps1`. Expect `Summary: N passed, 0 failed, 0 skipped` and a fresh `tests/results/latest.md`.
- If VICE or cc65 is missing, the toolchain checks show `SKIP` with the missing tool. Install it (README, Prerequisites) and run again.

## B. Interview (in your coding agent, from the Foundry root)

1. Send: *Read AGENTS.md and run the Foundry interview. My idea: a C64 game where you herd sheep into a pen with a dog.*
- The agent summarizes the idea and proposes a smallest playable version.
- It asks 2-4 questions about the target first (machine, PAL/NTSC, real hardware).
- `drafts/<slug>.json` exists after the first round.
2. Answer one round, then close the session. Start a new session: *Read AGENTS.md and resume the Foundry interview from drafts/<slug>.json.*
- The agent states what was already decided and continues at the stage printed by `tools/Test-FoundryBrief.ps1`. It does not re-ask answered questions.
3. Say you have no preference on controls. The spec marks controls as a practical default.
4. Ask for BASIC V2 when the design needs smooth animation of many sprites.
- The agent quotes the conflict and asks which constraint to change. It does not pick one itself.
5. Ask instead for 6502 assembly.
- The agent accepts it as a compatible override and records it.
6. Ask for a change after the spec is shown.
- The agent updates the draft and shows the revised spec. Nothing is generated.
7. Approve the spec.
- The spec you saw included scope, assumptions, target and toolchain, the first milestone, acceptance checks and the destination.
- The agent generates the project and reports the path, Git status, starter verification per target, and the exact message for a fresh session.

## C. Generated example: Traffic Control 64

Folder: `..\Foundry Projects\traffic-control-64`

1. `pwsh -File tools/check-prereqs.ps1` lists cl65 and x64sc as found.
2. `pwsh -File tools/smoke.ps1` prints `[PASS] c64` with six ok lines.
3. `pwsh -File tools/run.ps1`: within about 5 seconds VICE shows the intersection screen.
- Title on row 0, score line on row 1, and a frame counter `Fnnn` that changes continuously.
- Green grass, a grey crossroads and white crosswalk stripes.
- North-east signal head with the bottom (green) lamp lit; south-west head with the left (red) lamp lit.
- Row 23: `N-S: GREEN E-W: RED WALK: OFF`.
4. Press a key: VICE returns to the BASIC screen with `READY.`
5. `pwsh -File tools/run.ps1 -Video ntsc`: row 1 shows `NTSC`.

## D. Generated example: C128 Text Viewer

Folder: `..\Foundry Projects\c128-text-viewer`

1. `pwsh -File tools/smoke.ps1` prints `[PASS] c128-80` with the title, `SAMPLE OPENED OK: 6423 BYTES`, `DRIVE STATUS: 00, ok,00,00` and the `$D7 = $80` check.
2. `pwsh -File tools/run.ps1`: x128 starts, loads VIEWER from the disk image, and the **80-column (VDC) window** shows those four lines. Disk loading at normal speed takes several seconds.
3. `c1541 -attach build\c128-text-viewer-c128-80.d64 -list` lists VIEWER (prg), SAMPLE, LFSAMPLE and CRLFSAMPLE (seq).
4. `docs/milestones.md` M1.3 and M2.3 contain the automated page-view checks to be added during implementation.
5. `docs/manual-tests.md` MT1.2 and MT1.3 describe what the sample file must look like on the 80-column screen.

## E. Handoff from a fresh agent session

1. Open a new coding-agent session in a generated folder (not in the Foundry), with no other context.
2. Send the message from the generated README ("Start the implementation agent").
3. Expect the following:
- The agent reads the docs in the order AGENTS.md lists.
- It runs check-prereqs, build and smoke first.
- It implements one task, then reports what changed, the checks it ran with their results, and numbered manual steps with the expected result.
- It marks manual verification as PENDING and waits at the end of the milestone.
4. Confirm the task works. The agent records `confirmed by user (<date>)` in `docs/verification-status.md`.

## F. Safety (spot check)

1. Run the generator twice with the same destination. The second run fails with `already contains a Git repository`, and the folder is unchanged.
2. Interrupt a generation with Ctrl+C while it runs.
- No destination folder appears, and no `.<name>.foundry-staging-*` folder is left. A stale one from a hard kill is removed by the next run.
- Re-running succeeds.

## Real hardware (pending until done)

Neither example requires real hardware. To check one anyway, follow the "Real hardware" section
of the generated `docs/manual-tests.md`. For example, copy `build\c128-text-viewer-c128-80.d64`
to an SD2IEC card, use a C128 with the 40/80 key down and an 80-column monitor, and run
`LOAD"*",8` then `RUN`. Record the result in that project's `docs/verification-status.md`.

+ 134
- 0
docs/toolchain-guide.md 查看文件

@@ -0,0 +1,134 @@
# Toolchain selection guide

How the Foundry chooses a language, toolchain and emulator configuration, and what each verified
starter configuration contains. The machine-readable version is [catalog/recipes.json](../catalog/recipes.json).

## 1. Decide the target first

| Need | Platform / display |
|---|---|
| Runs on a C64 | `c64` / `vicii-40` |
| Native C128 mode, 40 columns (VIC-II, composite/RF) | `c128-native` / `vicii-40` |
| Native C128 mode, 80 columns (VDC, RGBI) | `c128-native` / `vdc-80` |
| The same C64 program on a C128 | add `c128-c64mode` / `vicii-40` with `dualTarget.strategy = c64-mode-on-both` |
| C64 build and a native C128 build | `c64` + `c128-native` with `native-per-target` |

80-column output exists only in native C128 mode. A C64 (or a C128 in C64 mode) cannot use the VDC.

## 2. Choose the simplest language that meets the brief

Work down this list and stop at the first language that meets every requirement:

1. **BASIC** (V2 on C64, 7.0 on C128): text menus, quizzes, turn-based games, small utilities where a response of about a second is fine. It can be edited on the machine.
2. **C (cc65)**: anything that needs speed, more structure, file processing, or several objects moving every few frames. It also covers C64 and C128 builds from one source.
3. **C + ca65 assembly (mixed)**: as C, plus a named subsystem that needs exact timing or maximum speed (raster-synchronised frame loop, raster interrupts, SID driver, a hot inner loop).
4. **ca65 assembly only**: demos and effects that are mostly timing-critical, or when the user wants assembly.

Check each criterion that applies:

| Criterion | BASIC V2 / 7.0 | C (cc65) | C + asm | ca65 asm |
|---|---|---|---|---|
| CPU timing (frame-locked updates, many movers) | poor | fair-good | good | best |
| Raster interrupts / cycle-exact effects | no | no | yes (asm part) | yes |
| Memory and code size | compact source, slow; about 38 KB free (C64) | larger code; runtime about 2-4 KB | as C | smallest |
| Display: 40-col text, sprites, charset | yes (POKEs) | yes | yes | yes |
| Display: 80-col VDC | BASIC 7.0 prints directly | conio `videomode()` | yes | manual VDC access |
| Sound (SID) | POKE / BASIC 7 `SOUND`/`PLAY` | yes | yes | yes |
| Disk I/O (SEQ/PRG) | `OPEN`/`GET#`/`INPUT#` (slow byte loops) | `cbm_open`/`cbm_read`, stdio | yes | KERNAL calls |
| C64/C128 portability | separate dialects | one source, `-t c64` / `-t c128` | yes | per-target code |
| Maintainability | easy to read, hard to structure | good | good, if the asm stays small | hardest |
| On-machine editing | yes | no | no | only with a native assembler |

The capability names in the brief (`smooth-animation`, `raster-interrupts`, `vdc-80col`, ...)
are checked against these limits by the validator. A user override that breaks one is reported
as a **conflict**, and the user decides which constraint to change.

## 3. Verified starter configurations

All configurations marked **verified** were built, run headless in VICE and checked automatically
by `tests/Run-FoundryTests.ps1` on 2026-11-26 with:

- cc65 `cl65 V2.19 - Git cc3c40c` (Windows x64 snapshot)
- VICE 3.10 GTK3 win64 (`x64sc`, `x128`, `c1541`, `petcat`)
- PowerShell 7.6.7 and git 2.53.0 on Windows 11 Pro 10.0.26200

| Recipe | Language | Platform / display | Emulator | Status | Exercised by (test brief) |
|---|---|---|---|---|---|
| `cc65` | C | c64 / vicii-40 | `x64sc` | verified | dual-native (c64) |
| `cc65` | C + ca65 | c64 / vicii-40 | `x64sc` | verified | examples/traffic-control-64 |
| `cc65` | ca65 | c64 / vicii-40 | `x64sc` | verified | override-asm |
| `cc65` | C | c128-native / vicii-40 | `x128 -40col` | verified | multi-display-c (c128-40) |
| `cc65` | ca65 | c128-native / vicii-40 | `x128 -40col` | verified | c128-40-asm |
| `cc65` | C | c128-native / vdc-80 | `x128 -80col` | verified | examples/c128-text-viewer (disk autostart), dual-native, multi-display-c |
| `cc65` | C | c128-c64mode / vicii-40 | `x128 -go64` | verified | dual-c64mode-c |
| `cc65` | ca65 | c128-native / vdc-80 | `x128 -80col` | **unverified** | validation plan in the catalog |
| `basic-petcat` | BASIC V2 | c64 / vicii-40 | `x64sc` | verified | dual-c64mode (c64) |
| `basic-petcat` | BASIC V2 | c128-c64mode / vicii-40 | `x128 -go64` | verified | dual-c64mode (c128-in-c64-mode) |
| `basic-petcat` | BASIC 7.0 | c128-native / vicii-40 | `x128 -40col` | verified | c128-40-basic7 |
| `basic-petcat` | BASIC 7.0 | c128-native / vdc-80 | `x128 -80col` | verified | c128-80-basic7 (mode flag automated; text by screenshot) |
| `basic-onboard` | BASIC V2 | c64 / vicii-40 | `x64sc` (disk load-and-run) | verified | on-commodore-basic + transfer round trip |
| `basic-onboard` | BASIC 7.0 | c128-native / vdc-80 | `x128 -80col` (disk load-and-run) | verified | on-commodore-basic7 |
| `basic-onboard` | BASIC 7.0 | c128-native / vicii-40 | `x128 -40col` | verified | same scripts as the 80-column row and c128-40-basic7 |
| `asm-onboard` | native assembler | c64, c128-native | `x64sc` / `x128` | **unverified** | unverified-onboard-asm (generation and manual-only path) |

Combinations of mixed C + ca65 on the C128 use the same build command as the C and ca65 rows above.
`docs/verification-log.md` lists exactly what ran and its results.

### Commands per recipe

| Recipe | Build | Run (VICE) |
|---|---|---|
| `cc65` C / mixed | `cl65 -t c64\|c128 -g -O -I src -o build/x.prg -Ln build/x.lbl -m build/x.map src/*.c src/*.s` | `x64sc -autostart build/x.prg` or `x128 -40col\|-80col -autostart build/x.prg` |
| `cc65` asm only | `cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ -g -o build/x.prg -Ln build/x.lbl src/*.s` (c128: `c128-asm.cfg`) | same |
| `basic-petcat` | `petcat -w2 -f -o build/x.prg -- src/main.bas` (7.0: `-w70`) | same |
| disk image | `c1541 -format "name,id" d64 build/x.d64 -write build/x.prg x -write sample.petscii "sample,s"` | `x128 -80col -autostart build/x.d64` |
| on-Commodore BASIC | to target: `tools/to-commodore.ps1` (petcat + c1541); back: `tools/from-commodore.ps1` (`c1541 -read`, `petcat -nh -2 -f -o src/main.bas -- x.prg`) | `LOAD"X",8` then `RUN` |

C128 note: cc65 c128 programs load at `$1C01`. `videomode(VIDEOMODE_80COL)` switches conio to the VDC. A C64 started with `x128 -go64` reports the C64 KERNAL reset vector `$FCE2`, which the smoke test checks.

## 4. Emulator options used (VICE 3.10)

| Option | Used for | Source |
|---|---|---|
| `-autostart <file>` | Load and run a PRG or disk image | [VICE manual 2.1](https://vice-emu.sourceforge.io/vice_2.html#SEC50) |
| `-autostartprgmode 1` | Inject the PRG into RAM (fast, no drive) | [VICE manual 6.3.2](https://vice-emu.sourceforge.io/vice_6.html#SEC89) |
| `-8 <image>` | Attach a disk image to drive 8 | VICE `-help` |
| `-40col` / `-80col` / `-go64` | x128 display key / C64 mode | [VICE manual 7.2.4.2](https://vice-emu.sourceforge.io/vice_7.html#SEC194) |
| `-pal` / `-ntsc` | Video standard | VICE `-help` |
| `-limitcycles <n>` | Exit after n cycles (smoke runs end this way) | [VICE manual 2.1](https://vice-emu.sourceforge.io/vice_2.html#SEC50) |
| `-exitscreenshot` / `-exitscreenshotvicii` | Screenshot on exit (x128: VDC / VIC-II window) | [VICE manual 2.1](https://vice-emu.sourceforge.io/vice_2.html#SEC50) |
| `-moncommands <file>` | Monitor commands at start (tracepoints) | [VICE manual 6.17.2](https://vice-emu.sourceforge.io/vice_6.html#SEC139) |
| monitor `trace exec\|store <addr>`, `command <n> "..."`, `bsave` | Save memory when the program reaches its ready point, without stopping | [VICE manual 12.7-12.8](https://vice-emu.sourceforge.io/vice_12.html#SEC339) |
| `-config <file> -default -warp -minimized -sounddev dummy` | Isolated, fast, quiet smoke runs | [VICE manual 2.1, 6.4.2, 6.9.2, 8.1.1](https://vice-emu.sourceforge.io/vice_toc.html) |

Observed in VICE 3.10 (not stated in the manual): `c1541 -write <file> "<name>,s"` writes a SEQ
file; `petcat -w...` needs `-f` to overwrite an existing output; the x128 `-exitscreenshot`
captures the VDC window when started with `-80col`. When VICE quits through `-limitcycles`, its exit
code is 1; smoke scripts ignore it and judge only the saved memory.

## 5. On-Commodore workflows

The Git repository always stays on the Windows host.

- **BASIC (`basic-onboard`)**, verified: `tools/to-commodore.ps1` tokenizes `src/main.bas` and writes a D64 transfer image. The user attaches it in VICE (or copies it to an SD2IEC / 1541 Ultimate / real floppy), types `LOAD"NAME",8`, `RUN`, edits, and `SAVE"@0:NAME",8`. `tools/from-commodore.ps1` reads the PRG back and detokenizes it into `src/main.bas` for review and commit. The round trip is byte-identical (tested). Disk format: D64. Target-side tool: the ROM BASIC screen editor.
- **Native assembler (`asm-onboard`)**, unverified: same transfer mechanics; the target-side tool is supplied by the user (for example Turbo Macro Pro). No smoke automation; `docs/toolchain.md` in the generated repo carries the validation plan. Mark the combination verified in the catalog once the plan has been carried out, with date and versions.

## 6. Configurations without a verified starter

When a brief needs a combination marked `unverified` (or one missing from the catalog):

1. Tell the user during the toolchain step.
2. Generate anyway if they agree. The generated `docs/toolchain.md` shows status **unverified** and the validation plan. `tools/smoke.ps1` reports `MANUAL` (exit 3) for that target.
3. To promote it, carry out the plan, add an automated check (a test brief in `tests/briefs/`), run `tests/Run-FoundryTests.ps1`, and set `"status": "verified"` in the catalog.

## 7. Real hardware

VICE is the default reference. Real hardware is recorded in the brief (`testing.realHardware`)
when the user asks for it or a requirement depends on it (exact timing, a specific drive, REU,
RGBI monitor). Every generated `docs/manual-tests.md` includes transfer and load steps for real
machines. Results are recorded only when the user reports them.

## Sources

- cc65: <https://cc65.github.io/doc/cl65.html>, <https://cc65.github.io/doc/c64.html#toc4.2>, <https://cc65.github.io/doc/c128.html>, <https://cc65.github.io/doc/ca65.html>, install <https://cc65.github.io/getting-started.html>
- VICE: manual <https://vice-emu.sourceforge.io/vice_toc.html>, c1541 <https://vice-emu.sourceforge.io/vice_14.html>, petcat <https://vice-emu.sourceforge.io/vice_16.html>, monitor <https://vice-emu.sourceforge.io/vice_12.html>, download <https://vice-emu.sourceforge.io/index.html#download> (winget id `VICE-Team.VICE.GTK3`)

+ 75
- 0
docs/verification-log.md 查看文件

@@ -0,0 +1,75 @@
# Verification log - Foundry 1.0

Date: 2026-11-26. Machine: Windows 11 Pro 10.0.26200, PowerShell 7.6.7, git 2.53.0.
Tools: cc65 `cl65 V2.19 - Git cc3c40c` (in `C:\Development\Commodore\cc65-snapshot-win64 (1)\bin`, found on PATH);
VICE 3.10 GTK3 win64 (in `C:\Program Files\GTK3VICE-3.10-win64\bin`, **not** on PATH, found through the install-folder search).
Both install paths contain spaces, and cc65's contains parentheses.

Each run writes a full per-check table and the exact command list to `tests/results/latest.md` (not committed).

## 1. Automated suite

```powershell
pwsh -File tests/Run-FoundryTests.ps1
```

Outcome: **108 passed, 0 failed, 0 skipped** (about 4 minutes). Generated test repos went to
`%TEMP%\Foundry Tests\run <timestamp>\My C64 Projects\<name with spaces>`.

| Area | What was checked | Result |
|---|---|---|
| Brief validation | Both examples and 11 valid test briefs pass approved-mode validation | pass |
| Schema | 19 brief files match `schema/project-brief.schema.json`; an invalid platform is rejected | pass |
| Conflicting constraints | BASIC 7.0 override on a C64, 80 columns on a C64, BASIC override vs. `smooth-animation`, on-Commodore build with cc65: each exits 4 with a CONFLICT that asks the user which constraint to change, and the generator refuses (nothing created) | pass |
| Override rules | Compatible override (ca65 instead of recommended C) generates and is documented; language differing from the recommendation without an override is an error; an override that is not applied is an error | pass |
| Dual-target rules | Strategy/target mismatch is a conflict; missing strategy is reported | pass |
| Traceability | Unknown requirement reference and unlinked requirement are errors | pass |
| Drafts | A paused draft resumes at `first-release` and repeats its saved open question; `New-FoundryDraft.ps1` creates a draft and refuses to overwrite one; drafts fail approved-mode validation; an unapproved brief is refused by the generator | pass |
| Generation (normal entry point `tools/New-FoundryProject.ps1`) | 13 briefs (both examples, C128 40-col BASIC 7.0, C128 40-col ca65, C128 40+80 C, BASIC 7.0 80-col, dual native C, dual C64-mode BASIC, dual C64-mode C, on-Commodore BASIC V2, on-Commodore BASIC 7.0 80-col, ca65 override, unverified native assembler) | pass |
| Generated files | README, AGENTS, CLAUDE, docs (spec, toolchain, milestones, manual tests, verification status), project.json with resolved config, .gitignore, .gitattributes, src, tools; every requirement in the spec, every target in spec and M0 manual tests; on-Commodore scripts only where relevant | pass |
| Template completeness | No `{{...}}` left in any generated text file; unknown placeholder stops generation | pass |
| Git | Branch `main`, one commit, clean tree, no remote. Without a Git identity (`GIT_CONFIG_GLOBAL` = empty file), files are staged and not committed, and the message says how to commit | pass |
| Paths with spaces | Every generated repo and every tool path contains spaces | pass |
| Existing destinations | Non-empty folder, existing Git repo and existing file refused, with content hashes unchanged; empty folder accepted; destination inside the Foundry refused; `bad\|name`, `trailing dot.` and `CON` refused | pass |
| Interruption and retry | Simulated failure after the templates, files and git steps: no destination, no staging left, retry succeeds; an existing empty folder is restored; a stale staging folder from a killed run is removed on the next run | pass |
| Toolchain: build + VICE smoke | `check-prereqs.ps1`, `build.ps1`, `smoke.ps1` in each generated repo: 16 targets PASS, unverified native-assembler target reports MANUAL (exit 3) as designed | pass |
| Interactive run | `tools/run.ps1` starts x64sc (Traffic Control 64) and x128 (Text Viewer), and the processes stay running | pass |
| On-Commodore workflow | `to-commodore.ps1` -> D64 -> `from-commodore.ps1` round trip leaves `src/main.bas` identical; a change saved to the transfer disk (simulated with petcat + c1541) arrives in `src/main.bas` | pass |
| Missing tool | With the x128 entry pointing to a non-existent executable, `check-prereqs.ps1` and `smoke.ps1` exit 2, naming the tool, the first command (`winget install --id VICE-Team.VICE.GTK3 -e`) and what stays unverified | pass |

## 2. Example repositories (generated through the normal entry point)

```powershell
pwsh -File tools/New-FoundryProject.ps1 examples/traffic-control-64/brief.json
pwsh -File tools/New-FoundryProject.ps1 examples/c128-text-viewer/brief.json
```

| Repo | Result |
|---|---|
| `C:\Development\Commodore\Foundry Projects\traffic-control-64` | Generated, initial commit on `main`. Smoke **PASS** in x64sc (PAL): title, score line, `N-S: GREEN`, `E-W: RED`, `WALK: OFF` on the expected rows, C64 KERNAL reset vector. The screenshot `build/smoke/c64/screen.png` was inspected: crossroads, crosswalks, green N-S lamp, red E-W lamp. |
| `C:\Development\Commodore\Foundry Projects\c128-text-viewer` | Generated, initial commit on `main`. The D64 holds VIEWER, SAMPLE, LFSAMPLE and CRLFSAMPLE. Smoke **PASS** in x128 -80col, autostarted from disk: the VDC read-back shows the title, `SAMPLE OPENED OK: 6423 BYTES` and `DRIVE STATUS: 00, ok,00,00`, and `$D7 = $80`. The screenshot `build/smoke/c128-80/screen.png` (VDC window) was inspected. |

## 3. Experiments that shaped the design

| Command / experiment | Outcome |
|---|---|
| `x64sc -moncommands` with `break` + `command ... bsave` | Memory saved, but the monitor stays open and VICE never exits. Rejected. |
| Same with `trace exec <addr>` (non-stopping) + `-limitcycles` + `-exitscreenshot` | Memory saved, VICE exits by itself (exit code 1 from limitcycles), screenshot written. Adopted. |
| `x128 -80col -exitscreenshot` | Captures the VDC window. `-exitscreenshotvicii` captures the VIC-II window. |
| VDC text check | VDC RAM is not CPU-visible, so the C starter copies VDC rows 0-3 into `smoke_probe[]` (registers 18/19/31) before the tracepoint. The screen codes match the upper/lower-case encoding. |
| `c1541 -write file "name,s"` | Writes a SEQ file (not stated in the manual; observed). |
| `petcat -w2` then `petcat -nh -2` | Byte-identical round trip; `-f` is needed to overwrite. |
| `cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ -g -Ln` | Local ca65 labels such as `smoke_ready` appear in the VICE label file. |
| Bugs found by these checks and fixed | Windows strips a trailing dot from paths (destination check now uses the raw name); `run.ps1` joined `-pal` and `-autostart` into one argument (fixed; covered by the interactive-run test); the drive reports `ok` in lower case in the upper/lower-case set (expectation corrected); signal lamp order and contrast in Traffic Control 64 (fixed after viewing the screenshot). |

## 4. Still pending

| Item | Why pending | How to finish |
|---|---|---|
| Real hardware (C64, C128 + 80-column monitor) | No hardware in this environment; not required by either example brief | Follow "Real hardware" in each generated `docs/manual-tests.md`; record results in its `docs/verification-status.md` |
| Fresh-session handoff with a different agent | Needs a new interactive session | `docs/manual-verification.md` section E |
| Interactive interview end to end | Needs a person answering questions | `docs/manual-verification.md` section B |
| `asm-onboard` recipe (native assembler on the C64/C128) | The assembler is user-supplied and not available here | Carry out the validation plan in the generated `docs/toolchain.md`, then mark the combination verified in `catalog/recipes.json` |
| ca65-only programs on the C128 80-column screen | No starter writes to the VDC from assembly yet | Validation plan in `catalog/recipes.json` (`cc65` combo `c128-native`/`vdc-80`/`asm-ca65`) |
| `winget install VICE-Team.VICE.GTK3` install location | VICE was installed from the zip on this machine. The winget install folder is searched (`%LOCALAPPDATA%\Microsoft\WinGet\Packages\VICE-Team.VICE.GTK3*\*\bin`) but not observed | Install with winget on a clean machine and run `tools/check-prereqs.ps1`; if VICE is not found, set `VICE_HOME` and update `searchPaths` in the catalog |
| NTSC smoke run | Smoke tests use PAL; NTSC is selectable (`-Video ntsc` in run.ps1) but not automated | Traffic Control 64 MT2.6 covers it during implementation |

+ 0
- 0
drafts/.gitkeep 查看文件


+ 256
- 0
examples/c128-text-viewer/brief.json 查看文件

@@ -0,0 +1,256 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": { "approvedBy": "example user (Foundry demo)", "approvedOn": "2026-11-26", "notes": "Demo brief produced with the normal interview workflow." },
"interview": {
"startedOn": "2026-11-26",
"stage": "review",
"openQuestions": [],
"notes": [
"The user wants a native 80-column utility. The Foundry confirmed it must run in C128 native mode with the 40/80 key down (VDC). A C64-mode or 40-column fallback is out of scope.",
"File type and encoding were left to the Foundry. Proposed default: SEQ files in PETSCII with CR line endings, tolerant of LF and CR LF so text copied from a PC also reads correctly."
]
},
"project": {
"name": "C128 Text Viewer",
"slug": "c128-text-viewer",
"idea": "A native 80-column C128 utility that opens a sample text file from disk and shows it in a paged view.",
"summary": "A small Commodore 128 utility for the 80-column (VDC) screen. It loads a sequential text file from drive 8 into memory and shows it a page at a time. The header shows the file name and page number, and a status line lists the keys. Long lines wrap. Missing files produce a clear message instead of a hang or crash.",
"kind": "utility",
"smallestUsefulVersion": "Loads the SEQ file SAMPLE from drive 8 and shows it in pages of 23 rows on the 80-column screen. SPACE goes to the next page, B to the previous page, and Q quits. A missing file shows 'FILE NOT FOUND' with the drive status."
},
"destination": "../Foundry Projects/c128-text-viewer",
"targets": [
{
"id": "c128-80",
"name": "Commodore 128, native mode, 80-column VDC screen (PAL primary)",
"platform": "c128-native",
"display": "vdc-80",
"video": "pal-ntsc",
"expectedBehavior": "Autostarts from the disk image in C128 mode, switches to (or stays on) the 80-column VDC screen and shows the viewer. Starter: title, file line, 'SAMPLE OPENED OK: 6423 BYTES' and drive status '00, ok,00,00' (the drive sends unshifted PETSCII, which the upper/lower-case character set shows in lower case).",
"autostart": "disk",
"disk": {
"name": "textviewer,tv",
"format": "d64",
"files": [
{ "source": "$artifact", "name": "viewer", "type": "prg" },
{ "source": "fixtures/sample.txt", "name": "sample", "type": "seq", "convert": "ascii-to-petscii", "lineEndings": "cr" },
{ "source": "fixtures/lf-sample.txt", "name": "lfsample", "type": "seq", "convert": "ascii-to-petscii", "lineEndings": "keep" },
{ "source": "fixtures/crlf-sample.txt", "name": "crlfsample", "type": "seq", "convert": "ascii-to-petscii", "lineEndings": "keep" }
]
}
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": { "requested": false, "reason": "" }
},
"scope": {
"firstRelease": "View SEQ text files from drive 8 on the 80-column screen with paging, wrapping, tolerant line-ending handling and clear error messages.",
"inScope": [
"SEQ files on drive 8 (1541/1571/1581 or compatible), PETSCII text",
"Default file SAMPLE; prompt for another file name",
"Paged view of 23 text rows with header and status line on the VDC 80x25 screen",
"Next/previous/first/last page and one-line scrolling",
"Wrapping of lines longer than 80 characters",
"Clear messages for a missing file, a missing drive and files too large to load fully"
],
"outOfScope": [
"Editing or saving text",
"ASCII-to-PETSCII conversion on the C128 (files must be PETSCII; the host build converts fixtures)",
"PRG, USR and REL files, and directories",
"40-column mode and C64 mode",
"Search, bookmarks, printing"
]
},
"requirements": [
{
"id": "R1",
"title": "Native 80-column display",
"priority": "must",
"text": "The program runs in C128 native mode and uses the VDC 80x25 text screen. Row 0 is the header (reverse video): program name, file name, and 'PAGE p/n'. Rows 1-23 hold text. Row 24 is the status line with key help.",
"acceptance": [
"With VICE x128 -80col, the program appears in the VDC window with 80 usable columns",
"Memory location $D7 (MODE) is $80 while the program runs (checked by tools/smoke.ps1)",
"The header shows 'PAGE 1/5' for SAMPLE"
],
"capabilities": ["vdc-80col", "text-ui"]
},
{
"id": "R2",
"title": "File type and loading",
"priority": "must",
"text": "The viewer opens a SEQ file by name on drive 8 (open string '<name>,s,r') and loads it into memory, up to 24,000 bytes. Larger files load the first 24,000 bytes and show 'TRUNCATED' in the header. After loading, it reads the drive error channel; any status other than 00 is treated as an error (R7).",
"acceptance": [
"SAMPLE (6,423 bytes) loads completely; the starter reports 'SAMPLE OPENED OK: 6423 BYTES'",
"A file over 24,000 bytes shows its first 24,000 bytes and 'TRUNCATED' in the header"
],
"capabilities": ["disk-seq-io"]
},
{
"id": "R3",
"title": "Encoding",
"priority": "must",
"text": "Files are PETSCII and are shown with the upper/lower-case character set. Printable bytes ($20-$7F, $A0-$FF) are shown as PETSCII. Other control bytes, except the line endings in R4, are shown as a reverse-video '?'. Byte $09 (tab) expands to spaces up to the next multiple of 8 columns.",
"acceptance": [
"SAMPLE line 1 shows 'C128 TEXT VIEWER SAMPLE FILE' in capitals and line 2 shows mixed case exactly as in fixtures/sample.txt",
"No colour, cursor or clear-screen control codes take effect while viewing"
],
"capabilities": ["text-ui"]
},
{
"id": "R4",
"title": "Line endings",
"priority": "must",
"text": "CR ($0D) ends a line. LF ($0A) alone also ends a line, and CR followed by LF counts as one line ending. A final line without a line ending is still shown.",
"acceptance": [
"SAMPLE (CR), LFSAMPLE (LF) and CRLFSAMPLE (CR LF) each show their lines with no blank rows between them",
"LFSAMPLE and CRLFSAMPLE both show exactly 5 lines"
],
"capabilities": ["text-ui"]
},
{
"id": "R5",
"title": "Long lines",
"priority": "must",
"text": "A line longer than 80 characters wraps onto further screen rows at column 80, with no hyphenation or marker. A line of exactly 80 characters uses exactly one row. Pages are counted in screen rows (23 per page), so a wrapped line may continue on the next page.",
"acceptance": [
"SAMPLE line 010 (200 characters) occupies 3 rows (80 + 80 + 40) and ends with '<END OF LINE 010>'",
"SAMPLE line 015 (exactly 80 characters, ending in '|') occupies one row, and line 016 follows directly on the next row",
"SAMPLE has 102 screen rows = 5 pages; page 2 starts with 'Line 022:'"
],
"capabilities": ["text-ui"]
},
{
"id": "R6",
"title": "Navigation",
"priority": "must",
"text": "SPACE or F1: next page. B or F3: previous page. HOME: first page. E: last page. CRSR DOWN / CRSR UP: scroll one screen row. Q or RUN/STOP: quit to BASIC with the screen cleared. Keys that would move past the first or last page do nothing.",
"acceptance": [
"From page 1, SPACE x4 reaches 'PAGE 5/5', whose last text row is 'Line 100: END OF SAMPLE FILE'; a fifth SPACE changes nothing",
"B returns one page; HOME returns to 'PAGE 1/5'; E goes to 'PAGE 5/5'",
"CRSR DOWN on page 1 makes 'Stored as ASCII...' (line 2) the first text row",
"Q returns to the BASIC READY prompt in 80-column mode"
],
"capabilities": ["keyboard-input"]
},
{
"id": "R7",
"title": "Missing file and drive errors",
"priority": "must",
"text": "If the file does not exist, the viewer shows 'FILE NOT FOUND: <name>' and the drive status line (for example '62, FILE NOT FOUND,00,00'), then 'PRESS ANY KEY'. Any key returns to the file prompt. If drive 8 does not respond, it shows 'DRIVE 8 NOT RESPONDING'. The program never hangs and never shows a partial page as if it were the file.",
"acceptance": [
"Entering the name NOSUCHFILE shows 'FILE NOT FOUND: NOSUCHFILE' and a status starting with '62'",
"With no disk attached in VICE, opening SAMPLE shows an error message within 5 seconds instead of hanging"
],
"capabilities": ["disk-seq-io"]
},
{
"id": "R8",
"title": "Choosing a file",
"priority": "should",
"text": "At start the viewer prompts 'FILE NAME (RETURN = SAMPLE):'. The user can type a name of up to 16 characters. RETURN on an empty line opens SAMPLE.",
"acceptance": [
"RETURN on its own opens SAMPLE; typing LFSAMPLE opens that file"
],
"capabilities": ["keyboard-input"]
}
],
"design": {
"controls": { "value": "Keyboard only: SPACE/F1 next, B/F3 previous, HOME first, E last, CRSR UP/DOWN scroll a row, Q or RUN/STOP quit, RETURN accepts the file name.", "source": "default" },
"visuals": { "value": "VDC 80x25 text. Header row in reverse video, text rows in the default colour, status row in reverse video. Upper/lower-case character set.", "source": "default" },
"sound": { "value": "None.", "source": "n/a" },
"persistence": { "value": "Read-only; nothing is saved.", "source": "n/a" },
"fileFormats": { "value": "Input: Commodore SEQ file, PETSCII, CR line endings (LF and CR LF tolerated), any length up to 24,000 bytes loaded. Fixtures are kept as ASCII in fixtures/ and converted to PETSCII when tools/build.ps1 writes the D64 image.", "source": "default" },
"peripherals": { "value": "Disk drive 8 (1541, 1571 or 1581 compatible). Test disk: build/c128-text-viewer-c128-80.d64 holding VIEWER, SAMPLE, LFSAMPLE and CRLFSAMPLE. 80-column RGBI monitor (VICE: VDC window).", "source": "default" },
"budgets": { "value": "24,000-byte text buffer in bank 0, plus a line index of 2 bytes per screen row (max 1,200 rows). Page redraw under 0.5 s; no frame-rate requirement. Program under 12 KB.", "source": "default" }
},
"capabilities": ["vdc-80col", "text-ui", "keyboard-input", "disk-seq-io"],
"assumptions": [
{ "id": "A1", "text": "cc65's c128 conio writes to the VDC screen after videomode(VIDEOMODE_80COL) and handles the upper/lower-case character set.", "status": "confirmed" },
{ "id": "A2", "text": "Users have PETSCII files. ASCII files from a PC show with swapped letter case; this is acceptable for the first release.", "status": "default" },
{ "id": "A3", "text": "The VDC has at least 16 KB of RAM (all C128 models). Only the standard text screen and attribute memory are used.", "status": "default" },
{ "id": "A4", "text": "VICE x128 with true drive emulation (default) behaves like a real 1541 for the error channel and SEQ reads.", "status": "unverified" }
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "c",
"recommended": { "recipe": "cc65", "language": "c" },
"reasons": [
"C with cc65 targets C128 native mode directly (cl65 -t c128). Its conio library supports the 80-column VDC screen through videomode(), and the cbm_open/cbm_read library gives SEQ file I/O and the drive error channel.",
"A pager has no tight timing: C is fast enough to redraw a page well under half a second, and is much easier to read and change than assembly.",
"BASIC 7.0 could print to the 80-column screen. But loading 24 KB with GET# and indexing wrapped lines would be very slow, and paging backwards would need the whole file in memory with string handling."
],
"alternatives": [
{ "option": "BASIC 7.0", "whyNot": "Byte-by-byte loading and line wrapping in interpreted BASIC would take minutes for a 24 KB file." },
{ "option": "6502 assembly (ca65)", "whyNot": "Not needed for speed. It would add effort, and VDC access would have to be written by hand." },
{ "option": "C + assembly", "whyNot": "No subsystem needs assembly. A fast VDC block-copy routine can be added later if page redraw proves slow." }
],
"override": null,
"assumptionsToVerify": [
"A4: Compare the missing-file status and SEQ reading in VICE with a real C128 + 1571 if hardware becomes available.",
"Page redraw time with conio on the VDC stays under 0.5 s (measure in M1)."
]
},
"starter": {
"screenTitle": "C128 TEXT VIEWER - 80 COLUMNS",
"expectedScreen": "On the 80-column (VDC) screen. Row 0: 'C128 TEXT VIEWER - 80 COLUMNS'. Row 1: 'FILE: SAMPLE (SEQ, PETSCII, CR LINE ENDINGS, DRIVE 8)'. Row 2: 'SAMPLE OPENED OK: 6423 BYTES'. Row 3: 'DRIVE STATUS: 00, ok,00,00' (lower-case 'ok' is how the upper/lower-case set shows the drive's reply). Row 5: the starter key help.",
"smokeChecks": [
{ "row": 0, "col": 0, "text": "C128 TEXT VIEWER - 80 COLUMNS", "description": "Title on VDC row 0" },
{ "row": 2, "col": 0, "text": "SAMPLE OPENED OK: 6423 BYTES", "description": "SAMPLE loaded from disk, full size (VDC row 2)" },
{ "row": 3, "col": 0, "text": "DRIVE STATUS: 00, ok,00,00", "description": "Drive reports no error (VDC row 3)" }
],
"filesDir": "files",
"requirements": ["R2"]
},
"milestones": [
{
"id": "M1",
"title": "Load SAMPLE and show the first pages",
"goal": "SAMPLE is loaded into memory and shown page by page, with correct encoding, line endings and wrapping, and an automated check confirms page 1 on the 80-column screen.",
"tasks": [
{ "id": "M1.1", "text": "Load the named SEQ file into a 24,000-byte buffer, read the error channel, and keep the byte count and truncation flag.", "requirements": ["R2"], "outcome": "VIEWER loads SAMPLE into memory (starter screen shows the same byte count)", "check": "tools/smoke.ps1 passes; MT1.1" },
{ "id": "M1.2", "text": "Build a screen-row index: handle CR/LF/CR LF line endings and wrap at 80 columns. Render a page of 23 rows with the R3 control-code rules.", "requirements": ["R3", "R4", "R5"], "outcome": "VIEWER draws page 1 of SAMPLE", "check": "MT1.2 and MT1.3" },
{ "id": "M1.3", "text": "Header (file, PAGE p/n, TRUNCATED) and status line. Update starter.smokeChecks and the c128-80 smoke checks in project.json so the automated test verifies page 1: header row 0 contains 'PAGE 1/5' and text row 1 is 'C128 TEXT VIEWER SAMPLE FILE'.", "requirements": ["R1", "R3"], "outcome": "VIEWER shows the full page layout; the smoke test checks the loaded page on the VDC", "check": "tools/smoke.ps1 passes with the new checks; MT1.2" }
],
"manualTests": [
{ "id": "MT1.1", "title": "Load SAMPLE", "target": "c128-80", "setup": "pwsh -File tools/build.ps1 (creates the D64 with VIEWER, SAMPLE, LFSAMPLE, CRLFSAMPLE).", "steps": ["pwsh -File tools/run.ps1 -Target c128-80", "Look at the VDC (80-column) window."], "expected": ["Within about 5 seconds of autostart the viewer appears in the VDC window, not the VIC-II window", "No error message; the header names SAMPLE"], "requirements": ["R1", "R2"] },
{ "id": "MT1.2", "title": "Page 1 content and layout", "target": "c128-80", "setup": "Viewer showing SAMPLE page 1.", "steps": ["Read the header, the first three text rows and the status line.", "Find line 010 and line 015."], "expected": ["Header: file SAMPLE, 'PAGE 1/5'", "Text row 1: 'C128 TEXT VIEWER SAMPLE FILE'; row 2: 'Stored as ASCII in the repo; ...' in mixed case; row 3 blank", "Line 010 fills two full rows and part of a third, ending '<END OF LINE 010>'", "Line 015 fills exactly one row ending in '|', followed directly by 'Line 016:'"], "requirements": ["R1", "R3", "R5"] },
{ "id": "MT1.3", "title": "Line-ending tolerance", "target": "c128-80", "setup": "Temporarily change the default file to LFSAMPLE, then CRLFSAMPLE (or use the prompt once R8 is done).", "steps": ["View LFSAMPLE.", "View CRLFSAMPLE."], "expected": ["Each shows exactly 5 lines, 'LINE ENDING TEST' to 'Line 5: END', with no blank rows between them"], "requirements": ["R4"] }
]
},
{
"id": "M2",
"title": "Navigation",
"goal": "All navigation keys work, with correct limits at the first and last page.",
"tasks": [
{ "id": "M2.1", "text": "Next/previous/first/last page and quit keys.", "requirements": ["R6"], "outcome": "VIEWER pages through SAMPLE", "check": "MT2.1" },
{ "id": "M2.2", "text": "One-row scrolling with CRSR UP/DOWN.", "requirements": ["R6"], "outcome": "VIEWER scrolls by one row", "check": "MT2.2" },
{ "id": "M2.3", "text": "Automated navigation check: extend tools/smoke.ps1 with an optional per-target key sequence (VICE -keybuf) and a second ready point after the keys are handled, then check that page 2 starts with 'Line 022:'.", "requirements": ["R5", "R6"], "outcome": "tools/smoke.ps1 verifies paging without a person", "check": "tools/smoke.ps1 passes, including the page-2 check" }
],
"manualTests": [
{ "id": "MT2.1", "title": "Paging", "target": "c128-80", "setup": "Viewer showing SAMPLE page 1.", "steps": ["Press SPACE four times.", "Press SPACE once more.", "Press B, then HOME, then E.", "Press Q."], "expected": ["After 4 x SPACE: 'PAGE 5/5', last text row 'Line 100: END OF SAMPLE FILE'", "The extra SPACE changes nothing", "B -> PAGE 4/5, HOME -> PAGE 1/5, E -> PAGE 5/5", "Q: screen clears to the BASIC READY prompt, still in 80 columns"], "requirements": ["R6"] },
{ "id": "MT2.2", "title": "Scrolling", "target": "c128-80", "setup": "Viewer on page 1.", "steps": ["Press CRSR DOWN once.", "Press CRSR UP once."], "expected": ["First text row becomes 'Stored as ASCII in the repo; ...'", "Back to 'C128 TEXT VIEWER SAMPLE FILE'"], "requirements": ["R6"] }
]
},
{
"id": "M3",
"title": "File prompt and errors",
"goal": "Choose a file by name and get clear, non-hanging errors.",
"tasks": [
{ "id": "M3.1", "text": "File-name prompt with SAMPLE as the default.", "requirements": ["R8"], "outcome": "VIEWER asks for a file name", "check": "MT3.1" },
{ "id": "M3.2", "text": "Missing-file and missing-drive handling, returning to the prompt. Add a test fixture over 24,000 bytes and show TRUNCATED.", "requirements": ["R7", "R2"], "outcome": "VIEWER reports errors and truncation", "check": "MT3.2, MT3.3 and MT3.4" }
],
"manualTests": [
{ "id": "MT3.1", "title": "Choose a file", "target": "c128-80", "setup": "Viewer at the file prompt.", "steps": ["Press RETURN.", "Quit, run again, type LFSAMPLE and press RETURN."], "expected": ["RETURN opens SAMPLE", "LFSAMPLE opens and shows 5 lines"], "requirements": ["R8"] },
{ "id": "MT3.2", "title": "Missing file", "target": "c128-80", "setup": "Viewer at the file prompt.", "steps": ["Type NOSUCHFILE and press RETURN.", "Press any key."], "expected": ["'FILE NOT FOUND: NOSUCHFILE' with a drive status starting '62'", "Back at the file prompt; no hang"], "requirements": ["R7"] },
{ "id": "MT3.3", "title": "No disk", "target": "c128-80", "setup": "In VICE, start the viewer, then detach the disk (File > Detach disk image > Drive 8).", "steps": ["Open SAMPLE."], "expected": ["An error message within 5 seconds; no hang"], "requirements": ["R7"] },
{ "id": "MT3.4", "title": "Large file", "target": "c128-80", "setup": "Disk image with the large fixture added in M3.2.", "steps": ["Open the large file."], "expected": ["Header shows TRUNCATED; paging works up to the end of the first 24,000 bytes"], "requirements": ["R2"] }
]
}
]
}

+ 5
- 0
examples/c128-text-viewer/files/fixtures/crlf-sample.txt 查看文件

@@ -0,0 +1,5 @@
LINE ENDING TEST
Line 2: this file uses CR LF (0x0D 0x0A) line endings.
Line 3: no blank rows should appear between lines.
Line 4: tabs are not used.
Line 5: END

+ 5
- 0
examples/c128-text-viewer/files/fixtures/lf-sample.txt 查看文件

@@ -0,0 +1,5 @@
LINE ENDING TEST
Line 2: this file uses LF (0x0A) line endings.
Line 3: no blank rows should appear between lines.
Line 4: tabs are not used.
Line 5: END

+ 100
- 0
examples/c128-text-viewer/files/fixtures/sample.txt 查看文件

@@ -0,0 +1,100 @@
C128 TEXT VIEWER SAMPLE FILE
Stored as ASCII in the repo; the build converts it to PETSCII with CR line ends.

Line 004: The quick brown fox jumps over the lazy dog.
Line 005: Paging test: every line starts with its number.
Line 006: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 007: RETURN, SPACE and the cursor keys move through the file.
Line 008: The quick brown fox jumps over the lazy dog.
Line 009: Paging test: every line starts with its number.
Line 010: LONG LINE, 200 CHARACTERS, WRAPS ONTO 3 SCREEN ROWS. abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij<END OF LINE 010>
Line 011: RETURN, SPACE and the cursor keys move through the file.
Line 012: The quick brown fox jumps over the lazy dog.
Line 013: Paging test: every line starts with its number.
Line 014: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 015: EXACTLY 80 CHARACTERS, MUST USE ONE ROW, NO BLANK ROW AFTER IT.......|
Line 016: The quick brown fox jumps over the lazy dog.
Line 017: Paging test: every line starts with its number.
Line 018: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 019: RETURN, SPACE and the cursor keys move through the file.
Line 020: The quick brown fox jumps over the lazy dog.
Line 021: Paging test: every line starts with its number.
Line 022: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 023: RETURN, SPACE and the cursor keys move through the file.
Line 024: The quick brown fox jumps over the lazy dog.
Line 025: Paging test: every line starts with its number.
Line 026: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 027: RETURN, SPACE and the cursor keys move through the file.
Line 028: The quick brown fox jumps over the lazy dog.
Line 029: Paging test: every line starts with its number.
Line 030: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 031: RETURN, SPACE and the cursor keys move through the file.
Line 032: The quick brown fox jumps over the lazy dog.
Line 033: Paging test: every line starts with its number.
Line 034: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 035: RETURN, SPACE and the cursor keys move through the file.
Line 036: The quick brown fox jumps over the lazy dog.
Line 037: Paging test: every line starts with its number.
Line 038: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 039: RETURN, SPACE and the cursor keys move through the file.
Line 040: The quick brown fox jumps over the lazy dog.
Line 041: Paging test: every line starts with its number.
Line 042: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 043: RETURN, SPACE and the cursor keys move through the file.
Line 044: The quick brown fox jumps over the lazy dog.
Line 045: Paging test: every line starts with its number.
Line 046: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 047: RETURN, SPACE and the cursor keys move through the file.
Line 048: The quick brown fox jumps over the lazy dog.
Line 049: Paging test: every line starts with its number.
Line 050: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 051: RETURN, SPACE and the cursor keys move through the file.
Line 052: The quick brown fox jumps over the lazy dog.
Line 053: Paging test: every line starts with its number.
Line 054: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 055: RETURN, SPACE and the cursor keys move through the file.
Line 056: The quick brown fox jumps over the lazy dog.
Line 057: Paging test: every line starts with its number.
Line 058: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 059: RETURN, SPACE and the cursor keys move through the file.
Line 060: The quick brown fox jumps over the lazy dog.
Line 061: Paging test: every line starts with its number.
Line 062: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 063: RETURN, SPACE and the cursor keys move through the file.
Line 064: The quick brown fox jumps over the lazy dog.
Line 065: Paging test: every line starts with its number.
Line 066: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 067: RETURN, SPACE and the cursor keys move through the file.
Line 068: The quick brown fox jumps over the lazy dog.
Line 069: Paging test: every line starts with its number.
Line 070: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 071: RETURN, SPACE and the cursor keys move through the file.
Line 072: The quick brown fox jumps over the lazy dog.
Line 073: Paging test: every line starts with its number.
Line 074: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 075: RETURN, SPACE and the cursor keys move through the file.
Line 076: The quick brown fox jumps over the lazy dog.
Line 077: Paging test: every line starts with its number.
Line 078: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 079: RETURN, SPACE and the cursor keys move through the file.
Line 080: The quick brown fox jumps over the lazy dog.
Line 081: Paging test: every line starts with its number.
Line 082: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 083: RETURN, SPACE and the cursor keys move through the file.
Line 084: The quick brown fox jumps over the lazy dog.
Line 085: Paging test: every line starts with its number.
Line 086: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 087: RETURN, SPACE and the cursor keys move through the file.
Line 088: The quick brown fox jumps over the lazy dog.
Line 089: Paging test: every line starts with its number.
Line 090: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 091: RETURN, SPACE and the cursor keys move through the file.
Line 092: The quick brown fox jumps over the lazy dog.
Line 093: Paging test: every line starts with its number.
Line 094: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 095: RETURN, SPACE and the cursor keys move through the file.
Line 096: The quick brown fox jumps over the lazy dog.
Line 097: Paging test: every line starts with its number.
Line 098: Mixed Case, digits 0123456789 and punctuation: .,;:!?()+-*/=#%&<>
Line 099: RETURN, SPACE and the cursor keys move through the file.
Line 100: END OF SAMPLE FILE

+ 79
- 0
examples/c128-text-viewer/files/src/main.c 查看文件

@@ -0,0 +1,79 @@
/* C128 Text Viewer - starter (milestone M0).
**
** Switches to the native 80-column (VDC) screen, opens the SEQ file SAMPLE on drive 8,
** counts its bytes, reads the drive status, and reports the result. The paged view itself
** is milestone M1 (docs/milestones.md).
**
** Screen rows used by the starter (VDC 80x25):
** 0 title
** 1 file name and expected format
** 2 load result: "SAMPLE OPENED OK: nnnn BYTES" or "FILE NOT FOUND: SAMPLE"
** 3 drive status as reported by the drive, e.g. "DRIVE STATUS: 00, OK,00,00"
** 5 key help
*/
#include <conio.h>
#include <cbm.h>
#include <c128.h>
#include <string.h>
#include "smoke.h"

#define DRIVE 8
#define LFN_FILE 2
#define LFN_CMD 15

static unsigned char buf[256];
static char status[41];

/* Read the drive's error channel into status[] (for example "00, OK,00,00"). */
static void read_drive_status(void)
{
int n;
status[0] = '\0';
if (cbm_open(LFN_CMD, DRIVE, 15, "") != 0) {
strcpy(status, "NO RESPONSE FROM DRIVE");
return;
}
n = cbm_read(LFN_CMD, status, sizeof status - 1);
cbm_close(LFN_CMD);
if (n < 0) { n = 0; }
status[n] = '\0';
/* The drive ends its status with CR; drop it. */
while (n > 0 && (status[n - 1] == '\r' || status[n - 1] == '\n')) { status[--n] = '\0'; }
}

int main(void)
{
unsigned long total = 0;
int n;
unsigned char ok;

videomode(VIDEOMODE_80COL);
clrscr();
cputsxy(0, 0, "C128 TEXT VIEWER - 80 COLUMNS");
cputsxy(0, 1, "FILE: SAMPLE (SEQ, PETSCII, CR LINE ENDINGS, DRIVE 8)");

if (cbm_open(LFN_FILE, DRIVE, 2, "sample,s,r") == 0) {
while ((n = cbm_read(LFN_FILE, buf, sizeof buf)) > 0) {
total += (unsigned)n;
}
cbm_close(LFN_FILE);
}
read_drive_status();
ok = (status[0] == '0' && status[1] == '0');

gotoxy(0, 2);
if (ok && total > 0) {
cprintf("SAMPLE OPENED OK: %lu BYTES", total);
} else {
cputs("FILE NOT FOUND: SAMPLE");
}
gotoxy(0, 3);
cprintf("DRIVE STATUS: %s", status);
cputsxy(0, 5, "STARTER: PAGED VIEW ARRIVES IN M1. PRESS ANY KEY TO RETURN TO BASIC.");

smoke_capture();
smoke_ready();
cgetc();
clrscr();
return 0;
}

+ 247
- 0
examples/traffic-control-64/brief.json 查看文件

@@ -0,0 +1,247 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": { "approvedBy": "example user (Foundry demo)", "approvedOn": "2026-11-26", "notes": "Demo brief produced with the normal interview workflow; the defaults below were accepted as proposed." },
"interview": {
"startedOn": "2026-11-26",
"stage": "review",
"openQuestions": [],
"notes": [
"User idea was short; the Foundry proposed the smallest playable loop (one intersection, fixed spawn pattern, three crashes ends the shift) and the user accepted it.",
"User asked for fully manual signals: no automatic timers and no interlock that prevents conflicting greens. Unsafe choices must be possible and must have visible consequences."
]
},
"project": {
"name": "Traffic Control 64",
"slug": "traffic-control-64",
"idea": "An original hybrid arcade and simulation game for the C64. You run one intersection at a time, with cars and pedestrians, and you control the signals completely by hand. Unsafe choices can cause collisions.",
"summary": "A top-down, single-screen traffic game for the Commodore 64. Cars arrive from four directions and pedestrians wait at the crosswalks. The player switches the north-south and east-west signals and the pedestrian WALK signal by hand. Good timing clears traffic and earns points. Conflicting signals let vehicles or pedestrians collide, which ends the shift after three crashes.",
"kind": "game",
"smallestUsefulVersion": "One intersection on one screen. Cars enter from all four sides and pedestrians from the corners. Three player-controlled signals: N-S, E-W and WALK. Cars stop on red and go on green. Collisions are detected and shown. A CLEARED counter and a CRASHES counter. The shift ends at 3 crashes, and a key restarts."
},
"destination": "../Foundry Projects/traffic-control-64",
"targets": [
{
"id": "c64",
"name": "Commodore 64 (PAL primary, NTSC supported)",
"platform": "c64",
"display": "vicii-40",
"video": "pal-ntsc",
"expectedBehavior": "Autostarts to the intersection screen: title on row 0, score line on row 1, green grass with a grey crossroads, white crosswalk stripes, two signal heads, phase line 'N-S: GREEN E-W: RED WALK: OFF' on row 23. A frame counter on row 1 advances once per video frame."
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": { "requested": false, "reason": "" }
},
"scope": {
"firstRelease": "A playable single-intersection shift with manual signals, moving cars and pedestrians, and visible safe and unsafe outcomes. Scoring, game over and restart are included.",
"inScope": [
"One four-way intersection on a single 40x25 text screen",
"Cars from four approaches (one lane each way), pedestrians on four crosswalks",
"Manual control of the N-S signal, the E-W signal and the pedestrian WALK signal",
"Collision detection between cars on crossing paths and between cars and pedestrians in a crosswalk",
"CLEARED and CRASHES counters, game over at 3 crashes, restart",
"Simple SID sound effects for signal change, crash and car cleared",
"PAL and NTSC timing that is identical in game seconds"
],
"outOfScope": [
"Multiple intersections or scrolling maps",
"Turning traffic, emergency vehicles, buses",
"Automatic or timed signal programs",
"High-score saving to disk",
"Music",
"C128 native mode (it runs on a C128 only in C64 mode, untested)"
]
},
"requirements": [
{
"id": "R1",
"title": "Intersection display",
"priority": "must",
"text": "The playfield shows one intersection: grass, a N-S road (columns 16-23) and an E-W road (rows 8-15), crosswalk stripes on all four approaches, and two signal heads.",
"acceptance": [
"After autostart the intersection screen appears within 5 seconds in VICE (x64sc, PAL)",
"Row 0 reads 'TRAFFIC CONTROL 64'",
"Rows 2-21 show green grass, a grey cross of roads and white crosswalk stripes"
],
"capabilities": ["text-ui"]
},
{
"id": "R2",
"title": "Visible signal phases",
"priority": "must",
"text": "Each signal has phases RED, YELLOW and GREEN (WALK is ON or OFF). The current phases are always shown as text on row 23 and as lit lamps on the signal heads. Neither display depends on colour alone.",
"acceptance": [
"Row 23 shows 'N-S: <phase>', 'E-W: <phase>' and 'WALK: <ON|OFF>' matching the current state",
"The lit lamp on each signal head matches the text phase (top/left red, middle yellow, bottom/right green)",
"A phase change is visible within one frame of the key press"
],
"capabilities": ["text-ui"]
},
{
"id": "R3",
"title": "Fully manual signal control",
"priority": "must",
"text": "Keyboard: N cycles the N-S signal RED->GREEN->YELLOW->RED, E cycles the E-W signal the same way, W toggles WALK. Joystick in port 2: up/down cycles N-S, left/right cycles E-W, fire toggles WALK. There are no automatic timers or interlocks: the player can set conflicting phases.",
"acceptance": [
"Pressing N three times from RED goes GREEN, YELLOW, RED",
"Setting N-S GREEN and E-W GREEN at the same time is possible and is shown",
"Joystick port 2 performs the same actions as the keys"
],
"capabilities": ["keyboard-input", "joystick-input"]
},
{
"id": "R4",
"title": "Traffic and pedestrian movement",
"priority": "must",
"text": "Cars spawn at the screen edges on all four approaches and move one character cell at a time toward the far side. A car stops at its stop line on RED. It also stops on YELLOW if it has not reached the stop line. It proceeds on GREEN. Pedestrians wait at the corners and cross only when WALK is ON. Movement is frame-locked: cars advance every 8 frames on PAL and every 10 on NTSC, which is 6.25 cells per second on both. Pedestrians move at half that speed.",
"acceptance": [
"With N-S GREEN, N-S cars pass through the intersection and leave the screen; E-W cars queue at their stop lines on RED",
"A car takes the same time (within 5%) to cross the screen on PAL and NTSC",
"Pedestrians stay on the corner while WALK is OFF and cross while it is ON"
],
"capabilities": ["smooth-animation"]
},
{
"id": "R5",
"title": "Safe and unsafe outcomes",
"priority": "must",
"text": "A car that leaves the screen adds 1 to CLEARED. A pedestrian who reaches the far corner adds 1 to CLEARED. A collision happens when two cars on crossing approaches occupy the same cell, or when a car enters a crosswalk cell that holds a pedestrian. It flashes the involved cells, plays the crash sound, adds 1 to CRASHES and removes the involved movers.",
"acceptance": [
"Safe play (only one direction green at a time, WALK only while both roads are red) for 60 seconds produces CLEARED > 0 and CRASHES 0",
"Setting both roads GREEN with traffic present produces a visible crash and CRASHES increments within 10 seconds",
"WALK ON while the crossing road is GREEN with traffic produces a pedestrian collision"
],
"capabilities": ["text-ui"]
},
{
"id": "R6",
"title": "Game over and restart",
"priority": "must",
"text": "At 3 crashes the shift ends. Movement stops and 'SHIFT OVER - CLEARED nnn' is shown with 'PRESS FIRE OR SPACE'. Fire or SPACE starts a new shift with counters reset.",
"acceptance": [
"The third crash shows the game-over message and freezes movement",
"SPACE or fire restarts with CLEARED 000 and CRASHES 0/3"
],
"capabilities": ["keyboard-input", "joystick-input"]
},
{
"id": "R7",
"title": "Sound effects",
"priority": "should",
"text": "SID voice 1: a short click on each signal change. Voice 2: a noise burst on a crash. Voice 3: a short rising tone when a car or pedestrian is cleared.",
"acceptance": [
"Each of the three events produces its distinct sound in VICE with sound enabled"
],
"capabilities": ["sid-sound"]
}
],
"design": {
"controls": { "value": "Keyboard N / E / W for N-S, E-W and WALK; joystick port 2 up/down = N-S, left/right = E-W, fire = WALK; SPACE or fire restarts after game over.", "source": "default" },
"visuals": { "value": "Character-mode playfield using reverse-space blocks for grass (green), road (dark grey) and crosswalks (white). Cars are coloured solid PETSCII blocks with one colour per approach. Pedestrians are a light-colour figure character. No sprites in the first release, so collision cells are exact character cells.", "source": "default" },
"sound": { "value": "Three SID effects (signal click, crash noise, cleared tone); no music.", "source": "default" },
"persistence": { "value": "None. Scores are not saved.", "source": "n/a" },
"fileFormats": { "value": "None. A single PRG.", "source": "n/a" },
"peripherals": { "value": "Joystick in control port 2 (optional; keyboard works alone). No disk access after loading.", "source": "default" },
"budgets": { "value": "Logic, drawing and input in under 50% of a frame (about 9,800 of 19,656 PAL cycles), so all updates fit in one frame. At most 16 cars and 8 pedestrians active. Program under 16 KB. PAL 50 Hz primary; NTSC 60 Hz uses scaled movement intervals so game speed matches.", "source": "default" },
"other": [
{ "topic": "Difficulty", "value": "Spawn interval starts at 3 seconds per approach and shortens by 10% every 30 cleared movers (minimum 1 second).", "source": "default" }
]
},
"capabilities": ["text-ui", "keyboard-input", "joystick-input", "smooth-animation", "sid-sound"],
"assumptions": [
{ "id": "A1", "text": "Character-cell movement at 6.25 cells per second reads as smooth enough for this game. Sprite movement is not needed in the first release.", "status": "default" },
{ "id": "A2", "text": "Video standard is detected at start with get_tv(), which reads the KERNAL PAL/NTSC flag. Movement intervals are 8 frames on PAL and 10 on NTSC.", "status": "default" },
{ "id": "A3", "text": "The frame loop is synchronised to raster line 251 (wait_frame in frame.s). This line exists on PAL and NTSC.", "status": "unverified" },
{ "id": "A4", "text": "VICE x64sc with default C64 model settings is a faithful reference for timing.", "status": "default" }
],
"openDecisions": [
{ "id": "D1", "topic": "difficulty", "question": "Should difficulty ramp by time or by cleared count?", "default": "By cleared count (every 30 cleared movers).", "status": "open" }
],
"toolchain": {
"recipe": "cc65",
"language": "mixed-c-asm",
"recommended": { "recipe": "cc65", "language": "mixed-c-asm" },
"reasons": [
"BASIC V2 is too slow: updating up to 24 movers, checking collisions and polling input every frame is far beyond what interpreted BASIC can do in 20 ms.",
"C (cc65) is fast enough for character-cell game logic at this scale and keeps the game rules readable and easy to change.",
"A small ca65 module provides the raster-synchronised frame wait (and later the SID effect driver), which are the timing-sensitive parts. The rest stays in C.",
"Everything builds on Windows with one cc65 install and runs in VICE x64sc."
],
"alternatives": [
{ "option": "BASIC V2", "whyNot": "Too slow for frame-locked movement of many objects with collision checks." },
{ "option": "C only (cc65)", "whyNot": "Workable, but a busy-wait on the raster in C is fragile and the SID driver is easier in assembly. Mixed keeps those parts small and exact." },
{ "option": "6502 assembly only (ca65)", "whyNot": "Fastest, but the game rules (phases, queues, collisions, scoring) would take much longer to write and review. The speed is not needed." }
],
"override": null,
"assumptionsToVerify": [
"A3: wait_frame() keeps one update per frame on both PAL and NTSC (check the frame counter rate in VICE with -pal and -ntsc).",
"Frame budget: measure the worst-case update time (16 cars, 8 pedestrians) with a border-colour timing bar before M3 is complete."
]
},
"starter": {
"screenTitle": "TRAFFIC CONTROL 64",
"expectedScreen": "The intersection screen. Row 0: 'TRAFFIC CONTROL 64'. Row 1: 'CLEARED 000 CRASHES 0/3 PAL' and a frame counter 'Fnnn' that keeps changing. Rows 2-21: green grass, grey crossroads, white crosswalk stripes. North-east signal head with the bottom (green) lamp lit, south-west head with the left (red) lamp lit. Row 23: 'N-S: GREEN E-W: RED WALK: OFF'. Row 24: 'STARTER: SIGNALS FIXED. ANY KEY EXITS'.",
"smokeChecks": [
{ "row": 0, "col": 0, "text": "TRAFFIC CONTROL 64", "description": "Title on row 0" },
{ "row": 1, "col": 0, "text": "CLEARED 000 CRASHES 0/3", "description": "Score line on row 1" },
{ "row": 23, "col": 0, "text": "N-S: GREEN", "description": "N-S phase shown on row 23" },
{ "row": 23, "col": 13, "text": "E-W: RED", "description": "E-W phase shown on row 23" },
{ "row": 23, "col": 26, "text": "WALK: OFF", "description": "WALK state shown on row 23" }
],
"filesDir": "files",
"requirements": ["R1"]
},
"milestones": [
{
"id": "M1",
"title": "Manual signals",
"goal": "The player controls all three signals and sees every phase change immediately.",
"tasks": [
{ "id": "M1.1", "text": "Keyboard input: N, E and W change the signal state as specified in R3. Redraw the phase line and the signal heads on change.", "requirements": ["R2", "R3"], "outcome": "PRG in which N/E/W change row 23 and the lamps", "check": "Manual test MT1.1; smoke test still passes with the initial phases" },
{ "id": "M1.2", "text": "Joystick port 2 mapping (edge-triggered so that holding the stick changes the phase only once).", "requirements": ["R3"], "outcome": "PRG controllable by joystick", "check": "Manual test MT1.2" },
{ "id": "M1.3", "text": "Signal-change click on SID voice 1 (assembly sound module).", "requirements": ["R7"], "outcome": "PRG with an audible click on each change", "check": "Manual test MT1.1 step 4" }
],
"manualTests": [
{ "id": "MT1.1", "title": "Cycle signals by keyboard", "target": "c64", "setup": "VICE x64sc, PAL, sound on.", "steps": ["Wait for the intersection screen.", "Press N three times, watching row 23 and the north-east signal head.", "Press E once, then W once.", "Listen for a click on each key press."], "expected": ["After N: N-S shows YELLOW, then RED, then GREEN (it started GREEN), and the lit lamp moves to match each time", "After E: 'E-W: GREEN'. Both roads now show GREEN; this is allowed", "After W: 'WALK: ON'", "One click per change"], "requirements": ["R2", "R3", "R7"] },
{ "id": "MT1.2", "title": "Cycle signals by joystick", "target": "c64", "setup": "VICE: a joystick or keyset mapped to port 2.", "steps": ["Push up once and release.", "Push left once and release.", "Press fire once."], "expected": ["Each action changes exactly one signal by one step, exactly as the keys do"], "requirements": ["R3"] }
]
},
{
"id": "M2",
"title": "First playable loop",
"goal": "Cars and pedestrians move, obey the signals, and produce observable safe and unsafe outcomes.",
"tasks": [
{ "id": "M2.1", "text": "Car movers: spawn on each approach, frame-locked movement with PAL/NTSC intervals, stop-line behaviour on RED/YELLOW, queueing behind stopped cars.", "requirements": ["R4"], "outcome": "PRG with cars that obey the N-S/E-W signals", "check": "Manual test MT2.1" },
{ "id": "M2.2", "text": "Pedestrian movers: wait at corners, cross on WALK, add to CLEARED on arrival.", "requirements": ["R4", "R5"], "outcome": "PRG with pedestrians that obey WALK", "check": "Manual test MT2.2" },
{ "id": "M2.3", "text": "Collision detection and crash feedback (flash, noise, CRASHES +1, remove movers). Cleared counting for cars.", "requirements": ["R5", "R7"], "outcome": "PRG where unsafe phases cause visible crashes", "check": "Manual tests MT2.3 and MT2.4" },
{ "id": "M2.4", "text": "Game over at 3 crashes, and restart.", "requirements": ["R6"], "outcome": "PRG with a complete shift loop", "check": "Manual test MT2.5" }
],
"manualTests": [
{ "id": "MT2.1", "title": "Cars obey signals", "target": "c64", "setup": "Fresh start (N-S GREEN, E-W RED).", "steps": ["Watch for 15 seconds without pressing keys."], "expected": ["N-S cars drive through and leave the screen; CLEARED increases", "E-W cars stop at the stop line just before the crosswalk and queue"], "requirements": ["R4"] },
{ "id": "MT2.2", "title": "Pedestrians obey WALK", "target": "c64", "setup": "Fresh start.", "steps": ["Press N until N-S is RED (E-W is already RED).", "Press W (WALK ON) and watch for 10 seconds."], "expected": ["Pedestrians do not leave the corners before WALK is ON", "With WALK ON they cross, and CLEARED increases as each one arrives", "No crash occurs"], "requirements": ["R4", "R5"] },
{ "id": "MT2.3", "title": "Unsafe: both roads green", "target": "c64", "setup": "Fresh start.", "steps": ["Press E once so E-W is GREEN while N-S is still GREEN.", "Wait up to 10 seconds."], "expected": ["Cars from crossing directions meet in the intersection", "The crash cells flash, a noise burst plays, and CRASHES shows 1/3"], "requirements": ["R5"] },
{ "id": "MT2.4", "title": "Safe play for one minute", "target": "c64", "setup": "Fresh start; a stopwatch.", "steps": ["For 60 seconds, alternate: N-S GREEN with E-W RED, then N-S RED (via YELLOW) and E-W GREEN, about every 8 seconds; only use WALK while both are RED."], "expected": ["CLEARED is greater than 0", "CRASHES stays 0/3"], "requirements": ["R5"] },
{ "id": "MT2.5", "title": "Game over and restart", "target": "c64", "setup": "Fresh start.", "steps": ["Cause three crashes as in MT2.3.", "Press SPACE."], "expected": ["After the third crash: 'SHIFT OVER - CLEARED nnn' and 'PRESS FIRE OR SPACE', with movement frozen", "After SPACE: CLEARED 000 and CRASHES 0/3, and traffic starts again"], "requirements": ["R6"] },
{ "id": "MT2.6", "title": "PAL/NTSC speed match", "target": "c64", "setup": "pwsh -File tools/run.ps1 -Target c64 -Video ntsc, then the same with -Video pal.", "steps": ["Time one N-S car from entering at the top edge to leaving at the bottom, on each standard."], "expected": ["Row 1 shows NTSC or PAL to match", "The two times differ by no more than 5%"], "requirements": ["R4"] }
]
},
{
"id": "M3",
"title": "Polish within budget",
"goal": "Remaining sound effects and difficulty ramp, with the frame budget confirmed.",
"tasks": [
{ "id": "M3.1", "text": "Cleared tone (voice 3), and the difficulty ramp as decided in D1.", "requirements": ["R7", "R4"], "outcome": "PRG with all three effects and the spawn ramp", "check": "Manual test MT3.1" },
{ "id": "M3.2", "text": "Worst-case frame-budget check with a border-colour timing bar behind a debug key. Document the result in docs/toolchain.md.", "requirements": ["R4"], "outcome": "Measured worst-case frame time recorded", "check": "Manual test MT3.2" }
],
"manualTests": [
{ "id": "MT3.1", "title": "Sounds and ramp", "target": "c64", "setup": "Sound on.", "steps": ["Play safely for 2 minutes."], "expected": ["Distinct sounds for signal change, crash and cleared", "Cars arrive noticeably more often after about 30 cleared movers"], "requirements": ["R7", "R4"] },
{ "id": "MT3.2", "title": "Frame budget", "target": "c64", "setup": "Debug timing bar enabled (key documented by the agent).", "steps": ["Let traffic build to the maximum (both roads RED for 20 seconds)."], "expected": ["The border timing bar never reaches the bottom of the screen area, so every update fits in one frame"], "requirements": ["R4"] }
]
}
]
}

+ 136
- 0
examples/traffic-control-64/files/src/main.c 查看文件

@@ -0,0 +1,136 @@
/* Traffic Control 64 - starter (milestone M0).
**
** Draws the single intersection, both signal heads and the status lines, then runs the
** frame-locked main loop (wait_frame() from frame.s) with a visible frame counter.
** Signals are fixed (N-S GREEN, E-W RED) until milestone M1 makes them player-controlled.
**
** Screen layout (40x25 text, VIC-II):
** row 0 title
** row 1 score line (CLEARED / CRASHES) and video standard + frame counter
** rows 2-21 playfield: grass, N-S road (columns 16-23), E-W road (rows 8-15)
** row 23 signal phases (the authoritative, colour-blind-safe display)
** row 24 key help
*/
#include <conio.h>
#include <cbm.h>
#include <c64.h>
#include "smoke.h"
#include "frame.h"

#define FIELD_TOP 2
#define FIELD_BOTTOM 21
#define ROAD_L 16
#define ROAD_R 23
#define ROAD_T 8
#define ROAD_B 15

enum phase { PHASE_RED, PHASE_YELLOW, PHASE_GREEN };

static const char *const phase_name[] = { "RED", "YELLOW", "GREEN" };
static const unsigned char phase_color[] = { COLOR_RED, COLOR_YELLOW, COLOR_GREEN };

static unsigned char ns_phase = PHASE_GREEN;
static unsigned char ew_phase = PHASE_RED;
static unsigned char walk_on = 0;

/* Fill a rectangle with solid colour (reverse-video spaces). */
static void fill(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char color)
{
unsigned char x, y;
textcolor(color);
revers(1);
for (y = y0; y <= y1; ++y) {
gotoxy(x0, y);
for (x = x0; x <= x1; ++x) {
cputc(' ');
}
}
revers(0);
}

/* One signal head: three lamps; only the active phase is lit. */
static void draw_head(unsigned char x, unsigned char y, unsigned char vertical, unsigned char phase)
{
unsigned char i;
/* Black housing one cell larger than the lamps, so a lit green lamp stands out from the grass. */
if (vertical) {
fill((unsigned char)(x - 1), (unsigned char)(y - 1), (unsigned char)(x + 1), (unsigned char)(y + 3), COLOR_BLACK);
} else {
fill((unsigned char)(x - 1), (unsigned char)(y - 1), (unsigned char)(x + 3), (unsigned char)(y + 1), COLOR_BLACK);
}
revers(1);
for (i = 0; i < 3; ++i) { /* lamp i: 0 = red (top/left), 1 = yellow, 2 = green */
textcolor(i == phase ? phase_color[i] : COLOR_GRAY1);
if (vertical) {
cputcxy(x, (unsigned char)(y + i), ' ');
} else {
cputcxy((unsigned char)(x + i), y, ' ');
}
}
revers(0);
}

static void draw_status(void)
{
textcolor(COLOR_GRAY3);
gotoxy(0, 23);
cprintf("N-S: %-6s E-W: %-6s WALK: %-4s", phase_name[ns_phase], phase_name[ew_phase], walk_on ? "ON" : "OFF");
draw_head(ROAD_R + 2, ROAD_T - 4, 1, ns_phase); /* north-east corner, faces N-S traffic */
draw_head(ROAD_L - 5, ROAD_B + 2, 0, ew_phase); /* south-west corner, faces E-W traffic */
}

static void draw_intersection(void)
{
unsigned char x;
fill(0, FIELD_TOP, 39, FIELD_BOTTOM, COLOR_GREEN); /* grass */
fill(ROAD_L, FIELD_TOP, ROAD_R, FIELD_BOTTOM, COLOR_GRAY1); /* N-S road */
fill(0, ROAD_T, 39, ROAD_B, COLOR_GRAY1); /* E-W road */
/* Crosswalk stripes on all four approaches. */
revers(1);
textcolor(COLOR_WHITE);
for (x = ROAD_L; x <= ROAD_R; x += 2) {
cputcxy(x, ROAD_T - 1, ' ');
cputcxy(x, ROAD_B + 1, ' ');
}
for (x = ROAD_T; x <= ROAD_B; x += 2) {
cputcxy(ROAD_L - 1, x, ' ');
cputcxy(ROAD_R + 1, x, ' ');
}
revers(0);
}

int main(void)
{
unsigned char frames = 0;
const char *video = get_tv() == TV_NTSC ? "NTSC" : "PAL";

bordercolor(COLOR_BLACK);
bgcolor(COLOR_BLACK);
clrscr();
textcolor(COLOR_WHITE);
cputsxy(0, 0, "TRAFFIC CONTROL 64");
textcolor(COLOR_GRAY3);
gotoxy(0, 1);
cprintf("CLEARED 000 CRASHES 0/3 %-4s", video);
draw_intersection();
draw_status();
textcolor(COLOR_GRAY2);
cputsxy(0, 24, "STARTER: SIGNALS FIXED. ANY KEY EXITS");

smoke_capture();
smoke_ready();

textcolor(COLOR_GRAY3);
while (!kbhit()) {
wait_frame();
++frames;
gotoxy(32, 1);
cprintf("F%03u", (unsigned)frames);
}
cgetc();
bordercolor(COLOR_LIGHTBLUE);
bgcolor(COLOR_BLUE);
textcolor(COLOR_LIGHTBLUE);
clrscr();
return 0;
}

+ 256
- 0
schema/project-brief.schema.json 查看文件

@@ -0,0 +1,256 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.invalid/c64-c128-foundry/project-brief-1.0.schema.json",
"title": "C64/C128 Dev Foundry project brief",
"description": "Structural schema for briefs (drafts and approved). Semantic rules (conflicts, cross-references, approval) are enforced by tools/Test-FoundryBrief.ps1; see docs/brief-format.md.",
"type": "object",
"required": ["schemaVersion", "status", "project"],
"properties": {
"schemaVersion": { "const": "1.0" },
"status": { "enum": ["draft", "approved"] },
"approval": {
"type": ["object", "null"],
"properties": {
"approvedBy": { "type": "string" },
"approvedOn": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
"notes": { "type": "string" }
}
},
"interview": {
"type": ["object", "null"],
"properties": {
"startedOn": { "type": "string" },
"stage": { "enum": ["idea", "target", "first-release", "details", "toolchain", "plan", "destination", "review"] },
"openQuestions": { "type": "array", "items": { "type": "string" } },
"notes": { "type": "array", "items": { "type": "string" } }
}
},
"project": {
"type": "object",
"properties": {
"name": { "type": "string", "maxLength": 60 },
"slug": { "type": "string" },
"idea": { "type": "string" },
"summary": { "type": "string" },
"kind": { "enum": ["", "game", "utility", "demo", "tool", "education", "other"] },
"smallestUsefulVersion": { "type": "string" }
}
},
"destination": { "type": "string" },
"targets": { "type": "array", "items": { "$ref": "#/$defs/target" } },
"dualTarget": {
"type": ["object", "null"],
"properties": {
"strategy": { "enum": ["c64-mode-on-both", "native-per-target", "multi-display"] },
"notes": { "type": "string" }
}
},
"buildLocation": { "enum": ["windows-cross", "on-commodore"] },
"onCommodore": {
"type": ["object", "null"],
"properties": {
"targetTool": { "type": "string" },
"transfer": { "type": "string" },
"diskFormat": { "enum": ["d64", "d71", "d81"] },
"programName": { "type": "string", "maxLength": 16 }
}
},
"testing": {
"type": "object",
"properties": {
"emulator": { "const": "vice" },
"realHardware": {
"type": "object",
"properties": { "requested": { "type": "boolean" }, "reason": { "type": "string" } }
}
}
},
"scope": {
"type": "object",
"properties": {
"firstRelease": { "type": "string" },
"inScope": { "type": "array", "items": { "type": "string" } },
"outOfScope": { "type": "array", "items": { "type": "string" } }
}
},
"requirements": {
"type": "array",
"items": {
"type": "object",
"required": ["id"],
"properties": {
"id": { "type": "string", "pattern": "^R\\d+$" },
"title": { "type": "string" },
"priority": { "enum": ["must", "should", "could"] },
"text": { "type": "string" },
"acceptance": { "type": "array", "items": { "type": "string" } },
"capabilities": { "type": "array", "items": { "$ref": "#/$defs/capability" } }
}
}
},
"design": {
"type": "object",
"properties": {
"controls": { "$ref": "#/$defs/decision" },
"visuals": { "$ref": "#/$defs/decision" },
"sound": { "$ref": "#/$defs/decision" },
"persistence": { "$ref": "#/$defs/decision" },
"fileFormats": { "$ref": "#/$defs/decision" },
"peripherals": { "$ref": "#/$defs/decision" },
"budgets": { "$ref": "#/$defs/decision" },
"other": { "type": "array", "items": { "allOf": [{ "$ref": "#/$defs/decision" }, { "required": ["topic"] }] } }
}
},
"capabilities": { "type": "array", "items": { "$ref": "#/$defs/capability" } },
"assumptions": {
"type": "array",
"items": {
"type": "object",
"properties": { "id": { "type": "string" }, "text": { "type": "string" }, "status": { "enum": ["default", "unverified", "confirmed"] } }
}
},
"openDecisions": {
"type": "array",
"items": {
"type": "object",
"properties": { "id": { "type": "string" }, "topic": { "type": "string" }, "question": { "type": "string" }, "default": { "type": "string" }, "status": { "enum": ["open", "resolved"] } }
}
},
"toolchain": {
"type": ["object", "null"],
"properties": {
"recipe": { "enum": ["cc65", "basic-petcat", "basic-onboard", "asm-onboard"] },
"language": { "$ref": "#/$defs/language" },
"recommended": {
"type": "object",
"properties": { "recipe": { "type": "string" }, "language": { "$ref": "#/$defs/language" } }
},
"reasons": { "type": "array", "items": { "type": "string" } },
"alternatives": {
"type": "array",
"items": { "type": "object", "properties": { "option": { "type": "string" }, "whyNot": { "type": "string" } } }
},
"override": {
"type": ["object", "null"],
"properties": {
"requestedLanguage": { "$ref": "#/$defs/language" },
"requestedBy": { "type": "string" },
"reason": { "type": "string" },
"accepted": { "type": "boolean" }
}
},
"assumptionsToVerify": { "type": "array", "items": { "type": "string" } }
}
},
"starter": {
"type": ["object", "null"],
"properties": {
"screenTitle": { "type": "string", "maxLength": 38 },
"expectedScreen": { "type": "string" },
"filesDir": { "type": "string" },
"requirements": { "type": "array", "items": { "type": "string" } },
"smokeChecks": {
"type": "array",
"items": {
"type": "object",
"required": ["row", "col", "text"],
"properties": {
"row": { "type": "integer", "minimum": 0, "maximum": 24 },
"col": { "type": "integer", "minimum": 0, "maximum": 79 },
"text": { "type": "string" },
"description": { "type": "string" },
"targets": { "type": "array", "items": { "type": "string" } }
}
}
}
}
},
"milestones": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string", "pattern": "^M[1-9]\\d*$" },
"title": { "type": "string" },
"goal": { "type": "string" },
"tasks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"text": { "type": "string" },
"requirements": { "type": "array", "items": { "type": "string" } },
"outcome": { "type": "string" },
"check": { "type": "string" }
}
}
},
"manualTests": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"title": { "type": "string" },
"target": { "type": "string" },
"setup": { "type": "string" },
"steps": { "type": "array", "items": { "type": "string" } },
"expected": { "type": "array", "items": { "type": "string" } },
"requirements": { "type": "array", "items": { "type": "string" } }
}
}
}
}
}
}
},
"$defs": {
"capability": { "enum": ["text-ui", "keyboard-input", "joystick-input", "disk-seq-io", "sprites", "custom-charset", "sid-sound", "smooth-animation", "raster-interrupts", "vdc-80col"] },
"language": { "enum": ["basic-v2", "basic-7", "c", "asm-ca65", "mixed-c-asm", "asm-onboard"] },
"decision": {
"type": "object",
"properties": {
"topic": { "type": "string" },
"value": { "type": "string" },
"source": { "enum": ["user", "default", "n/a", "open"] }
}
},
"target": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"platform": { "enum": ["c64", "c128-native", "c128-c64mode"] },
"display": { "enum": ["vicii-40", "vdc-80"] },
"video": { "enum": ["pal", "ntsc", "pal-ntsc"] },
"artifact": { "type": "string" },
"expectedBehavior": { "type": "string" },
"autostart": { "enum": ["prg", "disk"] },
"smokeLimitCycles": { "type": "integer", "minimum": 1000000 },
"disk": {
"type": ["object", "null"],
"properties": {
"name": { "type": "string" },
"format": { "enum": ["d64", "d71", "d81"] },
"image": { "type": "string" },
"files": {
"type": "array",
"items": {
"type": "object",
"required": ["source", "name"],
"properties": {
"source": { "type": "string" },
"name": { "type": "string", "maxLength": 16 },
"type": { "enum": ["prg", "seq"] },
"convert": { "enum": [null, "ascii-to-petscii"] },
"lineEndings": { "enum": ["cr", "keep"] }
}
}
}
}
}
}
}
}
}

+ 37
- 0
templates/brief/draft.json 查看文件

@@ -0,0 +1,37 @@
{
"schemaVersion": "1.0",
"status": "draft",
"interview": {
"startedOn": "",
"stage": "idea",
"openQuestions": [],
"notes": []
},
"project": {
"name": "",
"slug": "",
"idea": "",
"summary": "",
"kind": "",
"smallestUsefulVersion": ""
},
"targets": [],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": { "requested": false, "reason": "" }
},
"scope": { "firstRelease": "", "inScope": [], "outOfScope": [] },
"requirements": [],
"design": {},
"capabilities": [],
"assumptions": [],
"openDecisions": [],
"toolchain": null,
"starter": null,
"milestones": [],
"destination": "",
"approval": null
}

+ 19
- 0
templates/interview/handoff-report.md 查看文件

@@ -0,0 +1,19 @@
# Handoff report layout (interview step 7)

```
Project generated: <absolute path>
Git: branch main, <initial commit created | files staged - run: git -C "<path>" commit -m "Initial handoff">

Starter verification (tools/smoke.ps1 at generation time):
- <target>: <PASSED | FAILED (<reason>) | NOT RUN - missing <tool>; first step: <command> | MANUAL ONLY - follow the validation plan in docs/toolchain.md>
Still unverified: <real hardware / manual tests / validation plan items>

To verify it yourself:
cd "<path>"
pwsh -File tools/check-prereqs.ps1
pwsh -File tools/smoke.ps1
pwsh -File tools/run.ps1 -Target <first target> (expected: <expected screen>)

To start implementation, open a fresh coding-agent session in "<path>" and send:
Read AGENTS.md and follow it. Build and verify the starter (milestone M0) first, then implement the next milestone one task at a time, reporting after each task what changed, which checks ran, and exactly how I should verify it.
```

+ 46
- 0
templates/interview/question-bank.md 查看文件

@@ -0,0 +1,46 @@
# Interview question bank

Ask 2-4 questions per round, in stage order, and skip anything the user already answered.
Each question has a **default** to propose when the user has no preference. Record accepted
defaults with `"source": "default"`.

## Stage: target

| Ask | Default to propose | Brief fields |
|---|---|---|
| Which machine should it run on: C64, C128 (40 or 80 columns), or both? | C64 for games and demos; C128 native 80-column for text tools that need width | `targets[].platform`, `targets[].display` |
| For both: one C64 program that the C128 runs in C64 mode, or a native C128 version too? | One C64 program (`c64-mode-on-both`) unless the user wants C128 features (80 columns, 2 MHz, BASIC 7) | `dualTarget.strategy`, `dualTarget.notes` |
| PAL, NTSC or both? | Both, with PAL as the reference (`pal-ntsc`) | `targets[].video` |
| VICE only, or real hardware too? Which requirement depends on hardware? | VICE only; real-hardware steps are still documented as optional | `testing.realHardware` |

## Stage: first-release

| Ask | Default to propose | Brief fields |
|---|---|---|
| What must the first release do? What can wait? | The smallest useful or playable version from step 1 | `scope.*` |
| How will we see it works? | Observable criteria: what appears on screen, what a key does, a counter changes | `requirements[].acceptance` |

## Stage: details (only where they affect the design)

| Topic | Ask | Typical default |
|---|---|---|
| Controls | Keyboard, joystick (port 2), or both? Which keys? | Joystick port 2 plus keyboard equivalents for games; keyboard for utilities |
| Visuals | Text/PETSCII, custom characters, sprites, bitmap? Colours? | PETSCII text mode first; sprites only if movement needs pixel precision |
| Sound | Effects, music, none? | A few SID effects for games, none for utilities |
| Persistence | Save anything (scores, settings, documents)? Where? | Nothing saved in the first release |
| File formats | Which files are read or written; type (PRG/SEQ/REL), encoding, line endings? | SEQ, PETSCII, CR line endings |
| Peripherals | Disk drive model, joystick, printer, REU, mouse? | Drive 8 (1541-compatible) only if files are needed |
| Budgets | Frame rate / response time, memory limits, load time? | One update per frame for action games; under 0.5 s response for tools |

## Stage: toolchain

| Ask | Default |
|---|---|
| Do you want a particular language or tool? | No preference: the Foundry chooses (docs/toolchain-guide.md) and explains why |
| Build on the PC (cross-development) or write/compile on the Commodore itself? | PC cross-development (`windows-cross`) |

## Stage: destination

| Ask | Default |
|---|---|
| Where should the new project folder go? | `../Foundry Projects/<slug>` next to the Foundry |

+ 32
- 0
templates/interview/spec-review.md 查看文件

@@ -0,0 +1,32 @@
# Spec review layout (interview step 4)

Generate the full text with `pwsh -File tools/Show-FoundrySpec.ps1 drafts/<slug>.json`. If you
condense it for the chat, keep every section below and every acceptance check.

```
## Proposed spec: <name>

<summary - 2-3 sentences>
Smallest useful version: <...>

Scope: first release <...>; in scope <...>; out of scope <...>

Target and toolchain
- Targets: <id: machine/mode, display, video, artifact, expected behavior> (one line each)
- Dual-target strategy: <strategy and what differs>
- Language: <language> via <recipe> - <one-sentence reason>; override: <none | requested X, compatible>
- Starter configuration: <verified | unverified - validation plan included>
- Testing: VICE <+ real hardware because ...>

Design decisions: <topic: value (user | default | n/a | OPEN)>
Assumptions: <id: text (status)>
Unresolved decisions: <id: question - default meanwhile>

Acceptance checks: <R#: criteria>

First milestone: M0 starter (smoke test + expected screen), then M1 <title>: <tasks>

Destination: <absolute path> (absent | empty folder)

Approve to generate, or tell me what to change.
```

+ 10
- 0
templates/repo/.gitattributes 查看文件

@@ -0,0 +1,10 @@
* text=auto
*.ps1 text eol=crlf
*.prg binary
*.d64 binary
*.d71 binary
*.d81 binary
*.bin binary
*.png binary
# Fixtures are test inputs: keep their bytes (line endings, encoding) exactly as committed.
fixtures/** -text

+ 21
- 0
templates/repo/.gitignore 查看文件

@@ -0,0 +1,21 @@
# Build outputs (tools/build.ps1, tools/smoke.ps1, tools/to-commodore.ps1)
build/
*.o
*.prg
*.lbl
*.map
*.d64
*.d71
*.d81
!fixtures/**

# Editor and machine-local settings
.vscode/
.idea/
*.swp
*~
.DS_Store
Thumbs.db
vicerc
vice.ini
sdl-vicerc

+ 96
- 0
templates/repo/AGENTS.md.tmpl 查看文件

@@ -0,0 +1,96 @@
# AGENTS.md - implementation instructions for {{PROJECT_NAME}}

You are the implementation agent for **{{PROJECT_NAME}}**, a {{PROJECT_KIND}} for {{TARGET_LIST}}.
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: {{LANGUAGE_TITLE}} via {{RECIPE_TITLE}}. Do not switch languages or tools without the user's approval (see section 6).
- Build location: {{BUILD_LOCATION}}.
- Targets: {{TARGET_LIST}}. Every target listed in `docs/spec.md` must keep building and passing its checks after each task.
- Tools: {{TOOL_LIST}}. 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.
{{ON_COMMODORE_AGENTS}}

## 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/<target>/`.
- 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: <id> <title> (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.

+ 3
- 0
templates/repo/CLAUDE.md 查看文件

@@ -0,0 +1,3 @@
# Claude Code

Read and follow [AGENTS.md](AGENTS.md). It is the complete set of instructions for this repository.

+ 74
- 0
templates/repo/README.md.tmpl 查看文件

@@ -0,0 +1,74 @@
# {{PROJECT_NAME}}

{{PROJECT_SUMMARY}}

- Targets: {{TARGET_LIST}} (details in [docs/spec.md](docs/spec.md))
- Language/toolchain: {{LANGUAGE_TITLE}} - {{RECIPE_TITLE}} ([docs/toolchain.md](docs/toolchain.md))
- Status: starter only (milestone M0). Next milestone: {{NEXT_MILESTONE}}.

## First run

All commands run from this folder in PowerShell 7 (`pwsh`). Paths with spaces are fine.

### 1. Check prerequisites

```powershell
pwsh -File tools/check-prereqs.ps1
```

You need {{TOOL_LIST}}. For any missing tool the script prints the first command to run.
If a tool is installed somewhere unusual, set `VICE_HOME` or `CC65_HOME` to its folder.

### 2. Build

```powershell
pwsh -File tools/build.ps1
```

Outputs go to `build/`. Per-target artifacts and commands: [docs/toolchain.md](docs/toolchain.md).

### 3. Automated smoke test

```powershell
pwsh -File tools/smoke.ps1
```

Expected output: one `[PASS] <target>` line per target, with the checks listed under it, and exit code 0.
VICE runs minimized for a few seconds per target with its own temporary settings; your VICE
configuration is not touched. Screenshots are saved to `build/smoke/<target>/`.

### 4. Run it yourself

```powershell
pwsh -File tools/run.ps1 -Target {{FIRST_TARGET}}
```

Expected screen: {{EXPECTED_SCREEN}}
{{ON_COMMODORE_README}}

## Start the implementation agent

Open a **fresh** coding-agent session in this folder and send:

> {{HANDOFF_MESSAGE}}

The agent's instructions are in [AGENTS.md](AGENTS.md). It reports after every task, with
exact steps for you to verify by hand, and treats your verification as pending until you confirm.

## Layout

| Path | Contents |
|---|---|
| `AGENTS.md` | Implementation instructions for the coding agent |
| `docs/spec.md` | Approved requirements and acceptance criteria |
| `docs/toolchain.md` | Language decision, tools, commands, verification status |
| `docs/milestones.md` | Ordered tasks with completion checks |
| `docs/manual-tests.md` | Manual test steps and expected results per milestone and target |
| `docs/verification-status.md` | What has been verified, and what is pending |
| `project.json` | Approved structured brief and resolved build configuration |
| `src/` | Program source |
| `fixtures/` | Sample inputs (stored byte-for-byte) |
| `tools/` | Build, run, smoke-test and prerequisite scripts |
| `build/` | Generated outputs (not committed) |

Generated by the C64/C128 Dev Foundry on {{GENERATED_ON}} from a spec approved by {{APPROVED_BY}} on {{APPROVED_ON}}.

+ 12
- 0
templates/repo/docs/manual-tests.md.tmpl 查看文件

@@ -0,0 +1,12 @@
# {{PROJECT_NAME}} - Manual tests

Exact setup, actions and expected observations for each milestone and target. The agent asks
you to run the relevant section after each task; record results in docs/verification-status.md.

General setup for every test: run commands from the repository folder in PowerShell 7. VICE
keyboard mapping: letters, digits and Return map directly; RUN/STOP is Esc, RESTORE is
Page Up and the Commodore key is Left Ctrl. Reset from the VICE menu (Machine > Reset). To use a
joystick, assign a PC joystick or keyset to the port in VICE (Preferences > Settings > Input
devices > Joystick) before the test.

{{MANUAL_TESTS}}

+ 6
- 0
templates/repo/docs/milestones.md.tmpl 查看文件

@@ -0,0 +1,6 @@
# {{PROJECT_NAME}} - Milestones

Work top to bottom, one task at a time (AGENTS.md section 4). Every task must leave all targets
building. Requirement IDs refer to docs/spec.md.

{{MILESTONES}}

+ 66
- 0
templates/repo/docs/spec.md.tmpl 查看文件

@@ -0,0 +1,66 @@
# {{PROJECT_NAME}} - Specification

Approved by {{APPROVED_BY}} on {{APPROVED_ON}}. Changes to this file follow AGENTS.md section 6.

## Summary

{{PROJECT_SUMMARY}}

Original idea, as given:

> {{PROJECT_IDEA}}

Smallest useful version: {{SMALLEST_VERSION}}

## First release

{{FIRST_RELEASE}}

### In scope

{{IN_SCOPE}}

### Out of scope

{{OUT_OF_SCOPE}}

## Targets

{{TARGETS_TABLE}}

### Dual-target and mode notes

{{DUAL_TARGET}}

### Display notes

{{DISPLAY_NOTES}}

### Testing environment

- Reference emulator: VICE (exact options in docs/toolchain.md).
- Real hardware: {{REAL_HARDWARE}}

## Requirements and acceptance criteria

Each criterion is observable. Criteria IDs (for example R1.2) are referenced by milestones and manual tests.

{{REQUIREMENTS}}

## Design decisions

"Practical default" means the Foundry proposed it and the user accepted it without a specific preference. It can be changed later through AGENTS.md section 6.

{{DESIGN_TABLE}}

## Required capabilities

{{CAPABILITIES}}

## Assumptions

{{ASSUMPTIONS}}

## Unresolved decisions

{{OPEN_DECISIONS}}

+ 60
- 0
templates/repo/docs/toolchain.md.tmpl 查看文件

@@ -0,0 +1,60 @@
# {{PROJECT_NAME}} - Toolchain

## Decision

- Language: **{{LANGUAGE_TITLE}}**
- Recipe: **{{RECIPE_TITLE}}** (`{{RECIPE_ID}}`)
- Build location: {{BUILD_LOCATION}}
- Foundry recommendation: {{TOOLCHAIN_RECOMMENDED}}

{{TOOLCHAIN_OVERRIDE}}

### Why this language

{{TOOLCHAIN_REASONS}}

### Alternatives considered

{{TOOLCHAIN_ALTERNATIVES}}

## Tools

{{TOOLS_TABLE}}

Check them with `pwsh -File tools/check-prereqs.ps1`. Lookup order for each tool: its environment variable (folder or folder\bin), then `PATH`, then common install folders.

## Commands

| Purpose | Command |
|---|---|
| Check prerequisites | `pwsh -File tools/check-prereqs.ps1` |
| Build all targets | `pwsh -File tools/build.ps1` |
| Build one target | `pwsh -File tools/build.ps1 -Target <id>` |
| Run in VICE | `pwsh -File tools/run.ps1 -Target <id>` (add `-Video ntsc` to try NTSC) |
| Automated smoke test | `pwsh -File tools/smoke.ps1` (exit 0 pass, 1 fail, 2 missing tool, 3 manual only) |

## Target settings and verification status

{{CATALOG_VERIFIED}}

{{TARGET_COMMANDS}}

### How the smoke test works

`tools/smoke.ps1` starts VICE with `-config <temp file> -default -warp -minimized -sounddev dummy`, so your own VICE settings are never read or changed. It gives the monitor a command file (`-moncommands`) that sets non-stopping tracepoints on the program's ready point. When the program reaches it, VICE saves memory with `bsave` into `build/smoke/<target>/`. VICE exits after `-limitcycles` cycles and writes `-exitscreenshot`; that is the normal way the run ends, so VICE's own exit code is ignored. The script then compares the saved memory with the expected screen text (as VIC-II/VDC screen codes) and mode bytes.

Smoke hooks in the source:

- cc65 C programs: `smoke_capture()` and `smoke_ready()` in `src/smoke.c`. 80-column builds copy the first VDC rows into `smoke_probe[]`, because VDC memory is not visible to the CPU.
- ca65 programs: the `smoke_ready` label.
- BASIC programs: `POKE 679,1` (BASIC V2) or `POKE 3071,1` (BASIC 7.0) after the first screen is drawn.

## Assumptions still to verify

{{TOOLCHAIN_VERIFY}}

{{ON_COMMODORE}}

## Sources

{{SOURCES}}

+ 13
- 0
templates/repo/docs/verification-status.md.tmpl 查看文件

@@ -0,0 +1,13 @@
# {{PROJECT_NAME}} - Verification status

The implementation agent updates this file after every task (AGENTS.md section 4).
Manual verification stays **pending** until the user confirms it. Only the user can confirm.

Values: automated = `passed (<date>, <command>)`, `failed (...)`, `not run - <reason>`;
manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <note>`.

{{VERIFICATION_TABLE}}

## Notes

- Generated {{GENERATED_ON}}. Starter verification at generation time is reported by the Foundry; re-run `pwsh -File tools/smoke.ps1` on your machine and record the result in row M0.1.

+ 31
- 0
templates/repo/tools/build.ps1 查看文件

@@ -0,0 +1,31 @@
<#
.SYNOPSIS
Build every target (or one target) listed in project.json.

.DESCRIPTION
Reads resolved.targets from project.json. cc65 targets compile every .c and .s file in the
target's source folders; BASIC targets tokenize the listing with petcat. Targets with a disk
section also get a disk image built with c1541. Outputs go to build/ (ignored by Git).

Exit codes: 0 = built, 1 = build error, 2 = a required tool is missing.

.EXAMPLE
pwsh -File tools/build.ps1
pwsh -File tools/build.ps1 -Target c64
#>
[CmdletBinding()]
param([string]$Target)
. (Join-Path $PSScriptRoot 'lib.ps1')

try {
$project = Get-ProjectConfig
$done = @{}
foreach ($t in Get-ProjectTargets $project $Target) { Invoke-TargetBuild $project $t $done }
Write-Host "Build complete."
} catch [MissingToolException] {
Write-Host $_.Exception.Message -ForegroundColor Yellow
exit 2
} catch {
Write-Host "BUILD FAILED: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

+ 48
- 0
templates/repo/tools/check-prereqs.ps1 查看文件

@@ -0,0 +1,48 @@
<#
.SYNOPSIS
Check that every tool this project needs is installed, and say exactly what to do if not.

.DESCRIPTION
Looks for each tool in resolved.tools (project.json) in this order: the tool's environment
variable (for example VICE_HOME or CC65_HOME, pointing at the install folder or its bin
folder), then PATH, then common install folders. Prints the path and version found, or the
first command to run and what stays unverified until the tool is installed.

Exit codes: 0 = everything found, 2 = something is missing.
#>
[CmdletBinding()]
param()
. (Join-Path $PSScriptRoot 'lib.ps1')

$project = Get-ProjectConfig
$missing = 0
Write-Host "Prerequisites for $($project.project.name)"
Write-Host ""
$ps = $PSVersionTable.PSVersion
if ($ps.Major -ge 7) { Write-Host (" [ok] PowerShell {0}" -f $ps) -ForegroundColor Green }
else { Write-Host " [MISSING] PowerShell 7+ (running $ps). First step: winget install --id Microsoft.PowerShell -e" -ForegroundColor Yellow; $missing++ }

$git = Get-Command git -ErrorAction SilentlyContinue
if ($git) { Write-Host (" [ok] {0}" -f ((& git --version) -join '')) -ForegroundColor Green }
else { Write-Host " [MISSING] git. First step: winget install --id Git.Git -e" -ForegroundColor Yellow; $missing++ }

foreach ($tool in @($project.resolved.tools)) {
$path = Find-ToolPath $tool
if ($path) {
$ver = Get-ToolVersion $tool $path
Write-Host (" [ok] {0,-7} {1}" -f $tool.executable, $ver) -ForegroundColor Green
Write-Host (" {0}" -f $path)
Write-Host (" verified with: {0}" -f $tool.verifiedVersion)
} else {
$missing++
Write-Host (" [MISSING] {0} - {1}" -f $tool.executable, $tool.purpose) -ForegroundColor Yellow
Write-Host (" First step : {0}" -f $tool.install.firstCommand)
Write-Host (" Source : {0}" -f $tool.install.source)
Write-Host (" Or set {0} to the install folder." -f $tool.envVar)
Write-Host (" Unverified until installed: {0}" -f (@($tool.requiredFor) -join '; '))
}
}
Write-Host ""
if ($missing) { Write-Host "$missing prerequisite(s) missing." -ForegroundColor Yellow; exit 2 }
Write-Host "All prerequisites found. Next: pwsh -File tools/smoke.ps1"
exit 0

+ 51
- 0
templates/repo/tools/from-commodore.ps1 查看文件

@@ -0,0 +1,51 @@
<#
.SYNOPSIS
Copy work saved on the Commodore back into the repository (on-Commodore workflow).

.DESCRIPTION
After you SAVE the program onto the transfer disk image (or a real disk imaged back to a
.d64), this script reads it with c1541:
- BASIC projects: reads the PRG and detokenizes it with petcat into src/main.bas.
- Other projects: copies the files in resolved.onCommodore.returnFiles into the repo.
Review the change with "git diff" before committing.

.EXAMPLE
pwsh -File tools/from-commodore.ps1
pwsh -File tools/from-commodore.ps1 -Image "D:\disks\my work.d64"
#>
[CmdletBinding()]
param([string]$Image)
. (Join-Path $PSScriptRoot 'lib.ps1')

try {
$project = Get-ProjectConfig
$oc = $project.resolved.onCommodore
if (-not $oc) { throw 'This project does not use the on-Commodore workflow.' }
$c1541 = Get-ToolPath $project 'c1541'
$img = if ($Image) { (Resolve-Path -LiteralPath $Image).ProviderPath } else { Get-RepoPath $oc.image }
if (-not (Test-Path -LiteralPath $img)) { throw "Disk image not found: $img (run tools/to-commodore.ps1 first, then SAVE your work onto it)." }
$stage = Get-RepoPath 'build/transfer/returned'
New-Item -ItemType Directory -Force -Path $stage | Out-Null
if ($oc.kind -eq 'basic') {
$petcat = Get-ToolPath $project 'petcat'
$prg = Join-Path $stage "$($oc.programName).prg"
if (Test-Path -LiteralPath $prg) { Remove-Item -LiteralPath $prg }
Invoke-Tool $c1541 @('-attach', $img, '-read', $oc.programName, $prg)
if (-not (Test-Path -LiteralPath $prg)) { throw "c1541 did not find '$($oc.programName)' on $img." }
Invoke-Tool $petcat @('-nh', "-$($oc.dialect)", '-f', '-o', (Get-RepoPath $oc.source), '--', $prg)
Write-Host "Updated $($oc.source) from the Commodore."
}
foreach ($f in @($oc.returnFiles)) {
if (-not $f) { continue }
$name = if ($f.type -eq 'seq') { "$($f.name),s" } else { $f.name }
Invoke-Tool $c1541 @('-attach', $img, '-read', $name, (Get-RepoPath $f.dest))
Write-Host "Copied $name -> $($f.dest)"
}
Write-Host 'Review with: git diff'
} catch [MissingToolException] {
Write-Host $_.Exception.Message -ForegroundColor Yellow
exit 2
} catch {
Write-Host "FAILED: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

+ 248
- 0
templates/repo/tools/lib.ps1 查看文件

@@ -0,0 +1,248 @@
# Shared helpers for tools/*.ps1. Generated by the C64/C128 Dev Foundry.
# Everything project-specific comes from project.json ("resolved" section), so these
# scripts do not need editing when sources are added. Requires PowerShell 7+.
Set-StrictMode -Version 1.0
$ErrorActionPreference = 'Stop'

$script:RepoRoot = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..')).Path

class MissingToolException : System.Exception {
[string]$ToolId
MissingToolException([string]$toolId, [string]$message) : base($message) { $this.ToolId = $toolId }
}

function Get-RepoRoot { $script:RepoRoot }

function Get-RepoPath([string]$Relative) {
if ([IO.Path]::IsPathRooted($Relative)) { return $Relative }
Join-Path $script:RepoRoot ($Relative -replace '[\\/]', [IO.Path]::DirectorySeparatorChar)
}

function Get-ProjectConfig {
$path = Join-Path $script:RepoRoot 'project.json'
Get-Content -LiteralPath $path -Raw | ConvertFrom-Json -AsHashtable -Depth 64
}

function Get-ProjectTargets([hashtable]$Project, [string]$TargetId) {
$targets = @($Project.resolved.targets)
if ($TargetId) {
$targets = @($targets | Where-Object { $_.id -eq $TargetId })
if ($targets.Count -eq 0) {
$known = ($Project.resolved.targets | ForEach-Object { $_.id }) -join ', '
throw "Unknown target '$TargetId'. Known targets: $known"
}
}
$targets
}

function Get-ToolEntry([hashtable]$Project, [string]$ToolId) {
$entry = $Project.resolved.tools | Where-Object { $_.id -eq $ToolId } | Select-Object -First 1
if (-not $entry) { throw "project.json does not list tool '$ToolId' under resolved.tools." }
$entry
}

function Find-ToolPath([hashtable]$Tool) {
$exe = $Tool.executable
$names = if ($IsWindows) { @("$exe.exe", $exe) } else { @($exe) }
# 1. Explicit environment variable (folder or folder\bin)
if ($Tool.envVar) {
$base = [Environment]::GetEnvironmentVariable($Tool.envVar)
if ($base) {
foreach ($dir in @($base, (Join-Path $base 'bin'))) {
foreach ($n in $names) {
$p = Join-Path $dir $n
if (Test-Path -LiteralPath $p -PathType Leaf) { return $p }
}
}
}
}
# 2. PATH
$cmd = Get-Command $exe -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
if ($cmd) { return $cmd.Source }
# 3. Well-known install folders (newest first)
foreach ($pattern in @($Tool.searchPaths)) {
if (-not $pattern) { continue }
$expanded = [Environment]::ExpandEnvironmentVariables($pattern)
$dirs = @(Resolve-Path -Path $expanded -ErrorAction SilentlyContinue | ForEach-Object { $_.ProviderPath } | Sort-Object -Descending)
foreach ($dir in $dirs) {
foreach ($n in $names) {
$p = Join-Path $dir $n
if (Test-Path -LiteralPath $p -PathType Leaf) { return $p }
}
}
}
$null
}

function Get-ToolPath([hashtable]$Project, [string]$ToolId) {
$tool = Get-ToolEntry $Project $ToolId
$path = Find-ToolPath $tool
if (-not $path) {
$msg = @"
MISSING TOOL: $($tool.executable) ($($tool.purpose))
First step : $($tool.install.firstCommand)
Source : $($tool.install.source)
Detection : set $($tool.envVar) to the install folder, or put $($tool.executable) on PATH.
Unverified until installed: $(@($tool.requiredFor) -join '; ')
"@
throw [MissingToolException]::new($ToolId, $msg)
}
$path
}

function Get-ToolVersion([hashtable]$Tool, [string]$Path) {
if (-not $Tool.versionArgs -or @($Tool.versionArgs).Count -eq 0) {
# VICE emulators have no quiet version switch; report the install folder name instead.
return "(version from folder) " + (Split-Path (Split-Path $Path -Parent) -Leaf)
}
try {
$out = & $Path @($Tool.versionArgs) 2>&1 | ForEach-Object { "$_" } | Where-Object { $_ -match '\d+\.\d+' } | Select-Object -First 1
if ($out) { return $out.Trim() }
} catch { }
'(version unknown)'
}

function Invoke-Tool([string]$Path, [string[]]$Arguments, [string]$WorkingDirectory = $script:RepoRoot) {
Write-Host (" > {0} {1}" -f (Split-Path $Path -Leaf), (($Arguments | ForEach-Object { if ($_ -match '\s') { '"' + $_ + '"' } else { $_ } }) -join ' '))
Push-Location -LiteralPath $WorkingDirectory
try {
$output = & $Path @Arguments 2>&1 | ForEach-Object { "$_" }
$code = $LASTEXITCODE
} finally { Pop-Location }
foreach ($line in $output) { if ($line.Trim()) { Write-Host " $line" } }
if ($code -ne 0) { throw "$(Split-Path $Path -Leaf) failed with exit code $code." }
}

# ---------------------------------------------------------------------------
# Text conversion
# ---------------------------------------------------------------------------

# Plain ASCII text -> PETSCII bytes for the upper/lower-case character set.
# ASCII lower case -> PETSCII $41-$5A, ASCII upper case -> PETSCII $C1-$DA.
# LineEndings: 'cr' converts LF and CRLF to CR ($0D); 'keep' leaves them alone.
function ConvertTo-Petscii([byte[]]$Bytes, [string]$LineEndings = 'cr') {
$out = [System.Collections.Generic.List[byte]]::new()
for ($i = 0; $i -lt $Bytes.Length; $i++) {
$b = $Bytes[$i]
if ($LineEndings -eq 'cr') {
if ($b -eq 0x0D) { $out.Add(0x0D); if ($i + 1 -lt $Bytes.Length -and $Bytes[$i + 1] -eq 0x0A) { $i++ }; continue }
if ($b -eq 0x0A) { $out.Add(0x0D); continue }
}
if ($b -ge 0x61 -and $b -le 0x7A) { $out.Add([byte]($b - 0x20)); continue }
if ($b -ge 0x41 -and $b -le 0x5A) { $out.Add([byte]($b + 0x80)); continue }
$out.Add($b)
}
, $out.ToArray()
}

# Expected text -> VIC-II/VDC screen codes.
# screen-upper: upper-case/graphics set (BASIC and KERNAL default): letters -> 1..26
# screen-mixed: lower/upper-case set (cc65 C programs): a-z -> 1..26, A-Z -> $41..$5A
function ConvertTo-ScreenCodes([string]$Text, [string]$Encoding) {
$codes = foreach ($ch in $Text.ToCharArray()) {
$c = [int]$ch
if ($c -ge 0x61 -and $c -le 0x7A) { $c - 0x60 }
elseif ($c -ge 0x41 -and $c -le 0x5A) { if ($Encoding -eq 'screen-mixed') { $c } else { $c - 0x40 } }
elseif ($c -eq 0x40) { 0 }
elseif ($c -ge 0x5B -and $c -le 0x5F) { $c - 0x40 }
else { $c }
}
, [byte[]]$codes
}

function Format-Hex([byte[]]$Bytes) { ($Bytes | ForEach-Object { '{0:X2}' -f $_ }) -join ' ' }

# ---------------------------------------------------------------------------
# Build
# ---------------------------------------------------------------------------

function Get-SourceFiles([hashtable]$Build) {
$files = foreach ($dir in @($Build.sourceDirs)) {
$full = Get-RepoPath $dir
if (Test-Path -LiteralPath $full) {
Get-ChildItem -LiteralPath $full -File | Where-Object { $_.Extension -in '.c', '.s' } | Sort-Object Name
}
}
@($files | ForEach-Object { $_.FullName })
}

function Invoke-TargetBuild([hashtable]$Project, [hashtable]$Target, [hashtable]$Done) {
$build = $Target.build
$key = "$($build.kind)|$($Target.artifact)"
if ($Done.ContainsKey($key)) {
Write-Host "[$($Target.id)] artifact $($Target.artifact) already built for target $($Done[$key])"
} else {
Write-Host "[$($Target.id)] building $($Target.artifact)"
$artifact = Get-RepoPath $Target.artifact
New-Item -ItemType Directory -Force -Path (Split-Path $artifact -Parent) | Out-Null
switch ($build.kind) {
'cc65' {
$cl65 = Get-ToolPath $Project 'cl65'
$sources = Get-SourceFiles $build
if ($sources.Count -eq 0) { throw "No .c or .s files found in $(@($build.sourceDirs) -join ', ')." }
$toolArgs = @('-t', $build.cc65Target, '-g')
if ($build.config) { $toolArgs += @('-C', $build.config, '-u', '__EXEHDR__') } else { $toolArgs += '-O' }
foreach ($d in @($build.defines)) { if ($d) { $toolArgs += @('-D', $d) } }
foreach ($dir in @($build.sourceDirs)) { $toolArgs += @('-I', (Get-RepoPath $dir)) }
$toolArgs += @('-o', $artifact, '-Ln', (Get-RepoPath $build.labels), '-m', (Get-RepoPath $build.map))
$toolArgs += $sources
Invoke-Tool $cl65 $toolArgs
# cl65 leaves object files next to sources; keep the source tree clean.
foreach ($s in $sources) { $o = [IO.Path]::ChangeExtension($s, '.o'); if (Test-Path -LiteralPath $o) { Remove-Item -LiteralPath $o } }
}
'petcat' {
$petcat = Get-ToolPath $Project 'petcat'
Invoke-Tool $petcat @("-w$($build.dialect)", '-f', '-o', $artifact, '--', (Get-RepoPath $build.source))
}
'none' {
Write-Host " This target is built on the Commodore (see docs/toolchain.md). Nothing to build on the host."
return
}
default { throw "Unknown build kind '$($build.kind)'." }
}
if (-not (Test-Path -LiteralPath $artifact)) { throw "Build reported success but $($Target.artifact) was not created." }
Write-Host (" ok: {0} ({1} bytes)" -f $Target.artifact, (Get-Item -LiteralPath $artifact).Length)
$Done[$key] = $Target.id
}
if ($Target.disk) { New-TargetDisk $Project $Target $Done }
}

function New-TargetDisk([hashtable]$Project, [hashtable]$Target, [hashtable]$Done) {
$disk = $Target.disk
$key = "disk|$($disk.image)"
if ($Done.ContainsKey($key)) { return }
$c1541 = Get-ToolPath $Project 'c1541'
$image = Get-RepoPath $disk.image
$stage = Join-Path (Split-Path $image -Parent) 'disk-files'
New-Item -ItemType Directory -Force -Path $stage | Out-Null
if (Test-Path -LiteralPath $image) { Remove-Item -LiteralPath $image }
$toolArgs = @('-format', $disk.name, $disk.format, $image)
foreach ($f in @($disk.files)) {
$src = Get-RepoPath $f.source
if (-not (Test-Path -LiteralPath $src)) { throw "Disk file source not found: $($f.source)" }
if ($f.convert -eq 'ascii-to-petscii') {
$converted = Join-Path $stage ($f.name + '.petscii')
[IO.File]::WriteAllBytes($converted, (ConvertTo-Petscii ([IO.File]::ReadAllBytes($src)) $f.lineEndings))
$src = $converted
}
$dest = if ($f.type -eq 'seq') { "$($f.name),s" } else { $f.name }
$toolArgs += @('-write', $src, $dest)
}
$toolArgs += '-list'
Write-Host "[$($Target.id)] writing disk image $($disk.image)"
Invoke-Tool $c1541 $toolArgs
$Done[$key] = $Target.id
}

# ---------------------------------------------------------------------------
# Emulator
# ---------------------------------------------------------------------------

function Get-AutostartFile([hashtable]$Target) {
if ($Target.emulator.autostart -eq 'disk') { return Get-RepoPath $Target.disk.image }
Get-RepoPath $Target.artifact
}

function Get-VideoArgs([hashtable]$Target) {
switch ($Target.video) { 'ntsc' { @('-ntsc') } default { @('-pal') } }
}

+ 42
- 0
templates/repo/tools/run.ps1 查看文件

@@ -0,0 +1,42 @@
<#
.SYNOPSIS
Build a target and start it in VICE for interactive testing.

.DESCRIPTION
Starts the emulator listed for the target in project.json with the target's display and
video options, attaches the disk image when there is one, and autostarts the program.
VICE uses your normal VICE settings here (unlike tools/smoke.ps1).

.EXAMPLE
pwsh -File tools/run.ps1
pwsh -File tools/run.ps1 -Target c128-80
#>
[CmdletBinding()]
param(
[string]$Target,
[switch]$NoBuild,
[ValidateSet('pal', 'ntsc')][string]$Video
)
. (Join-Path $PSScriptRoot 'lib.ps1')

try {
$project = Get-ProjectConfig
$t = if ($Target) { Get-ProjectTargets $project $Target } else { @($project.resolved.targets)[0] }
if (-not $NoBuild) { Invoke-TargetBuild $project $t @{} }
if ($t.build.kind -eq 'none' -and -not $t.disk) { throw "Target $($t.id) is built on the Commodore; follow docs/toolchain.md to load it." }
$emu = Get-ToolPath $project $t.emulator.binary
if ($Video) { $t.video = $Video }
$vargs = @(Get-VideoArgs $t) + @($t.emulator.args)
if ($t.emulator.autostart -ne 'disk' -and $t.disk) { $vargs += @('-8', (Get-RepoPath $t.disk.image)) }
$vargs += @('-autostart', (Get-AutostartFile $t))
$quoted = $vargs | ForEach-Object { if ($_ -match '\s') { '"' + $_ + '"' } else { $_ } }
Write-Host "[$($t.id)] starting $($t.emulator.binary) $($quoted -join ' ')"
Start-Process -FilePath $emu -ArgumentList $quoted | Out-Null
Write-Host "Expected: $($t.expectedBehavior)"
} catch [MissingToolException] {
Write-Host $_.Exception.Message -ForegroundColor Yellow
exit 2
} catch {
Write-Host "RUN FAILED: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

+ 158
- 0
templates/repo/tools/smoke.ps1 查看文件

@@ -0,0 +1,158 @@
<#
.SYNOPSIS
Build each target, run it headless in VICE, and check that the expected screen appears.

.DESCRIPTION
For every target in project.json (resolved.targets) that has a "smoke" section:
1. builds the artifact (and disk image, if any);
2. starts VICE minimized, in warp mode, with sound off and a private config file,
so your own VICE settings are never read or changed;
3. sets non-stopping monitor tracepoints on the program's "ready" point. When the
program reaches it, VICE saves the listed memory ranges (screen RAM, a VDC probe,
mode flags) to build/smoke/<target>/*.bin;
4. lets VICE quit after a fixed number of cycles (-limitcycles) and saves a screenshot;
5. compares the saved memory with the expected text and bytes.

Exit codes: 0 = all automated checks passed, 1 = a check failed, 2 = a tool is missing,
3 = nothing automated to run (manual verification only).

.EXAMPLE
pwsh -File tools/smoke.ps1
pwsh -File tools/smoke.ps1 -Target c64
#>
[CmdletBinding()]
param(
[string]$Target,
[switch]$NoBuild,
[int]$TimeoutSeconds = 180
)
. (Join-Path $PSScriptRoot 'lib.ps1')

function Resolve-SmokeAddress([hashtable]$Target, [string]$Symbol, [string]$Address) {
if ($Address) { return [Convert]::ToInt32($Address, 16) }
$labels = Get-RepoPath $Target.build.labels
if (-not (Test-Path -LiteralPath $labels)) { throw "Label file $($Target.build.labels) not found; cannot resolve symbol '$Symbol'." }
foreach ($line in Get-Content -LiteralPath $labels) {
$parts = $line -split '\s+'
if ($parts.Count -ge 3 -and $parts[2].TrimStart('.') -eq $Symbol.TrimStart('.')) { return [Convert]::ToInt32($parts[1], 16) }
}
throw "Symbol '$Symbol' not found in $($Target.build.labels). Keep the smoke hook in the source (see AGENTS.md)."
}

function ConvertFrom-ScreenCodes([byte[]]$Codes, [string]$Encoding) {
$chars = foreach ($b in $Codes) {
$c = $b -band 0x7F
if ($c -eq 0) { '@' }
elseif ($c -ge 1 -and $c -le 26) { if ($Encoding -eq 'screen-mixed') { [char](0x60 + $c) } else { [char](0x40 + $c) } }
elseif ($c -ge 0x1B -and $c -le 0x1F) { [char](0x40 + $c) }
elseif ($c -ge 0x20 -and $c -le 0x3F) { [char]$c }
elseif ($c -ge 0x41 -and $c -le 0x5A -and $Encoding -eq 'screen-mixed') { [char]$c }
else { '.' }
}
-join $chars
}

function Invoke-TargetSmoke([hashtable]$Project, [hashtable]$Target) {
$smoke = $Target.smoke
$dir = Get-RepoPath "build/smoke/$($Target.id)"
if (Test-Path -LiteralPath $dir) { Remove-Item -LiteralPath $dir -Recurse -Force }
New-Item -ItemType Directory -Force -Path $dir | Out-Null

$readyAddr = Resolve-SmokeAddress $Target $smoke.ready.symbol $smoke.ready.address
$mon = [System.Collections.Generic.List[string]]::new()
$n = 0
foreach ($d in @($smoke.dumps)) {
$n++
$start = Resolve-SmokeAddress $Target $d.symbol $d.address
$end = $start + [int]$d.length - 1
$mon.Add(('trace {0} ${1:x4}' -f $smoke.ready.kind, $readyAddr))
$mon.Add(('command {0} "bsave \"{1}.bin\" 0 {2:x4} {3:x4}"' -f $n, $d.name, $start, $end))
}
Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $mon
Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value ''

$emu = Get-ToolPath $Project $Target.emulator.binary
$vargs = @('-config', 'vicerc', '-default', '-sounddev', 'dummy', '-warp', '-minimized') + (Get-VideoArgs $Target) + @($Target.emulator.args)
$vargs += @('-limitcycles', [string]$smoke.limitCycles, '-exitscreenshot', 'screen.png')
if ($Target.emulator.binary -eq 'x128') { $vargs += @('-exitscreenshotvicii', 'vicii.png') }
$vargs += @('-moncommands', 'monitor.txt')
if ($Target.emulator.autostart -eq 'disk') {
$vargs += @('-autostart', (Get-AutostartFile $Target))
} else {
if ($Target.disk) { $vargs += @('-8', (Get-RepoPath $Target.disk.image)) }
$vargs += @('-autostartprgmode', '1', '-autostart', (Get-AutostartFile $Target))
}
$quoted = $vargs | ForEach-Object { if ($_ -match '[\s"]') { '"' + ($_ -replace '"', '\"') + '"' } else { $_ } }
Set-Content -LiteralPath (Join-Path $dir 'command.txt') -Value ("`"$emu`" " + ($quoted -join ' '))
Write-Host "[$($Target.id)] running $($Target.emulator.binary) headless (limit $($smoke.limitCycles) cycles)"
$sw = [Diagnostics.Stopwatch]::StartNew()
$p = Start-Process -FilePath $emu -ArgumentList $quoted -WorkingDirectory $dir -PassThru `
-RedirectStandardOutput (Join-Path $dir 'vice.log') -RedirectStandardError (Join-Path $dir 'vice.err')
if (-not $p.WaitForExit($TimeoutSeconds * 1000)) {
$p.Kill($true)
return @{ target = $Target.id; status = 'FAIL'; seconds = [int]$sw.Elapsed.TotalSeconds; checks = @(); message = "VICE did not exit within $TimeoutSeconds s (killed)." }
}

$checks = @()
$reached = @($smoke.dumps | Where-Object { Test-Path -LiteralPath (Join-Path $dir "$($_.name).bin") }).Count -gt 0
if (-not $reached) {
$where = if ($smoke.ready.symbol) { "symbol $($smoke.ready.symbol)" } else { "store to `$$($smoke.ready.address)" }
return @{ target = $Target.id; status = 'FAIL'; seconds = [int]$sw.Elapsed.TotalSeconds; checks = @(); message = "Program never reached its ready point ($where) within $($smoke.limitCycles) cycles. See build/smoke/$($Target.id)/vice.log and screen.png." }
}
foreach ($c in @($smoke.checks)) {
$file = Join-Path $dir "$($c.dump).bin"
$result = @{ description = $c.description; pass = $false; detail = '' }
if (-not (Test-Path -LiteralPath $file)) { $result.detail = "dump '$($c.dump)' missing"; $checks += $result; continue }
$data = [IO.File]::ReadAllBytes($file)
$expected = if ($null -ne $c.text) { ConvertTo-ScreenCodes $c.text $c.encoding } else { [byte[]]($c.bytes -split '\s+' | Where-Object { $_ } | ForEach-Object { [Convert]::ToByte($_, 16) }) }
$offset = [int]$c.offset
if ($offset + $expected.Length -gt $data.Length) { $result.detail = "dump '$($c.dump)' too short"; $checks += $result; continue }
$actual = [byte[]]$data[$offset..($offset + $expected.Length - 1)]
$result.pass = ((Format-Hex $actual) -eq (Format-Hex $expected))
if ($null -ne $c.text) {
$result.detail = "expected '$($c.text)', found '$(ConvertFrom-ScreenCodes $actual $c.encoding)'"
} else {
$result.detail = "expected $(Format-Hex $expected), found $(Format-Hex $actual)"
}
$checks += $result
}
$status = if (@($checks | Where-Object { -not $_.pass }).Count -eq 0) { 'PASS' } else { 'FAIL' }
$shots = @('screen.png', 'vicii.png') | Where-Object { Test-Path -LiteralPath (Join-Path $dir $_) } | ForEach-Object { "build/smoke/$($Target.id)/$_" }
@{ target = $Target.id; status = $status; seconds = [int]$sw.Elapsed.TotalSeconds; checks = $checks; screenshots = @($shots); message = $smoke.expectedScreen }
}

$exitCode = 0
try {
$project = Get-ProjectConfig
$targets = Get-ProjectTargets $project $Target
$done = @{}
$results = @()
foreach ($t in $targets) {
if (-not $NoBuild) { Invoke-TargetBuild $project $t $done }
if (-not $t.smoke) {
$results += @{ target = $t.id; status = 'MANUAL'; checks = @(); message = 'No automated smoke check for this target; follow docs/manual-tests.md (M0).' }
continue
}
$results += Invoke-TargetSmoke $project $t
}
} catch [MissingToolException] {
Write-Host ""
Write-Host $_.Exception.Message -ForegroundColor Yellow
exit 2
}

Write-Host ""
Write-Host "Smoke results"
foreach ($r in $results) {
$color = switch ($r.status) { 'PASS' { 'Green' } 'FAIL' { 'Red' } default { 'Yellow' } }
Write-Host (" [{0}] {1}" -f $r.status, $r.target) -ForegroundColor $color
foreach ($c in @($r.checks)) { Write-Host (" {0} {1}: {2}" -f ($(if ($c.pass) { 'ok ' } else { 'FAIL' })), $c.description, $c.detail) }
if ($r.ContainsKey('screenshots') -and $r.screenshots) { Write-Host (" screenshot: {0}" -f ($r.screenshots -join ', ')) }
if ($r.message) { Write-Host " $($r.message)" }
}
New-Item -ItemType Directory -Force -Path (Get-RepoPath 'build/smoke') | Out-Null
$results | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Get-RepoPath 'build/smoke/results.json')

if (@($results | Where-Object { $_.status -eq 'FAIL' }).Count -gt 0) { $exitCode = 1 }
elseif (@($results | Where-Object { $_.status -eq 'PASS' }).Count -eq 0) { $exitCode = 3 }
exit $exitCode

+ 58
- 0
templates/repo/tools/to-commodore.ps1 查看文件

@@ -0,0 +1,58 @@
<#
.SYNOPSIS
Put the current source on a transfer disk image for the Commodore (on-Commodore workflow).

.DESCRIPTION
The Git repository stays on this Windows host. This script prepares the disk image you
attach in VICE (File > Attach disk image > drive 8) or copy to a real disk/SD card:
- BASIC projects: tokenizes src/main.bas with petcat and writes the PRG to the image.
- Other projects: copies the files listed in project.json (resolved.onCommodore.files).
Then, on the Commodore: LOAD"<name>",8 and RUN (or load it into your native tool).

.EXAMPLE
pwsh -File tools/to-commodore.ps1
#>
[CmdletBinding()]
param()
. (Join-Path $PSScriptRoot 'lib.ps1')

try {
$project = Get-ProjectConfig
$oc = $project.resolved.onCommodore
if (-not $oc) { throw 'This project does not use the on-Commodore workflow.' }
$c1541 = Get-ToolPath $project 'c1541'
$image = Get-RepoPath $oc.image
$stage = Split-Path $image -Parent
New-Item -ItemType Directory -Force -Path $stage | Out-Null
$files = @()
if ($oc.kind -eq 'basic') {
$petcat = Get-ToolPath $project 'petcat'
$prg = Join-Path $stage "$($oc.programName).prg"
Invoke-Tool $petcat @("-w$($oc.dialect)", '-f', '-o', $prg, '--', (Get-RepoPath $oc.source))
$files += @{ path = $prg; dest = $oc.programName }
}
foreach ($f in @($oc.files)) {
if (-not $f) { continue }
$src = Get-RepoPath $f.source
if ($f.convert -eq 'ascii-to-petscii') {
$conv = Join-Path $stage ($f.name + '.petscii')
[IO.File]::WriteAllBytes($conv, (ConvertTo-Petscii ([IO.File]::ReadAllBytes($src)) $f.lineEndings))
$src = $conv
}
$files += @{ path = $src; dest = $(if ($f.type -eq 'seq') { "$($f.name),s" } else { $f.name }) }
}
if (Test-Path -LiteralPath $image) { Remove-Item -LiteralPath $image }
$toolArgs = @('-format', $oc.diskName, $oc.diskFormat, $image)
foreach ($f in $files) { $toolArgs += @('-write', $f.path, $f.dest) }
$toolArgs += '-list'
Invoke-Tool $c1541 $toolArgs
Write-Host ""
Write-Host "Transfer disk ready: $($oc.image)"
Write-Host "On the Commodore (or VICE with the image on drive 8): $($oc.loadCommand)"
} catch [MissingToolException] {
Write-Host $_.Exception.Message -ForegroundColor Yellow
exit 2
} catch {
Write-Host "FAILED: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

+ 25
- 0
templates/starters/asm-onboard/src/STARTER.TXT.tmpl 查看文件

@@ -0,0 +1,25 @@
; {{PROJECT_NAME}} - starter for a native (on-Commodore) assembler.
; Type or load this into your assembler on the Commodore. Syntax follows common
; C64 native assemblers (Turbo Macro Pro style); adjust to your assembler and record
; the changes in docs/toolchain.md. Assemble to $C000 and start with SYS 49152.

*= $c000
chrout = $ffd2
getin = $ffe4

start lda #$93
jsr chrout
ldx #0
loop lda msg,x
beq wait
jsr chrout
inx
bne loop
wait jsr getin
beq wait
rts

msg .text "{{SCREEN_TITLE_LOWER}}"
.byte 13,13
.text "starter ok"
.byte 0

+ 7
- 0
templates/starters/basic-7/src/main.bas.tmpl 查看文件

@@ -0,0 +1,7 @@
10 rem {{PROJECT_NAME_LOWER}} - starter (basic 7.0)
20 print chr$(147);"{{SCREEN_TITLE_LOWER}}":print
30 print "starter ok":print
40 print "press any key to return to basic"
50 poke 3071,1:rem smoke-test marker, keep after the screen is drawn
60 getkey k$
70 end

+ 7
- 0
templates/starters/basic-v2/src/main.bas.tmpl 查看文件

@@ -0,0 +1,7 @@
10 rem {{PROJECT_NAME_LOWER}} - starter (basic v2)
20 print chr$(147);"{{SCREEN_TITLE_LOWER}}":print
30 print "starter ok":print
40 print "press any key to return to basic"
50 poke 679,1:rem smoke-test marker, keep after the screen is drawn
60 get k$:if k$="" then 60
70 end

+ 31
- 0
templates/starters/cc65-asm/src/main.s.tmpl 查看文件

@@ -0,0 +1,31 @@
; {{PROJECT_NAME}} - starter program generated by the C64/C128 Dev Foundry (ca65).
; Built with: cl65 -t <target> -C <target>-asm.cfg -u __EXEHDR__ (BASIC SYS line included).
; Milestone M0 only: prints the title through the KERNAL and waits for a key.
; smoke_ready is the VICE tracepoint used by tools/smoke.ps1: keep it after the screen is drawn.

.export smoke_ready

CHROUT = $FFD2
GETIN = $FFE4

.segment "CODE"
start: lda #$93 ; PETSCII clear screen
jsr CHROUT
ldx #0
@print: lda message,x
beq smoke_ready
jsr CHROUT
inx
bne @print
smoke_ready:
nop
@wait: jsr GETIN
beq @wait
rts

.segment "RODATA"
; ca65 with -t c64/c128 turns lower-case ASCII into PETSCII that shows as upper case.
message:
.byte "{{SCREEN_TITLE_LOWER}}", $0D, $0D
.byte "starter ok", $0D, $0D
.byte "press any key to return to basic", $00

+ 27
- 0
templates/starters/cc65-c/src/main.c.tmpl 查看文件

@@ -0,0 +1,27 @@
/* {{PROJECT_NAME}} - starter program generated by the C64/C128 Dev Foundry.
** Milestone M0 only: proves the toolchain, the target display and the smoke test.
** Replace the body of main() as the milestones in docs/milestones.md are implemented.
*/
#include <conio.h>
#if defined(__C128__)
#include <c128.h>
#endif
#include "smoke.h"

int main(void)
{
#if defined(__C128__) && defined(FOUNDRY_VDC80)
videomode(VIDEOMODE_80COL);
#elif defined(__C128__)
videomode(VIDEOMODE_40COL);
#endif
clrscr();
cputsxy(0, 0, "{{SCREEN_TITLE}}");
cputsxy(0, 2, "STARTER OK");
cputsxy(0, 4, "PRESS ANY KEY TO RETURN TO BASIC");
smoke_capture();
smoke_ready();
cgetc();
clrscr();
return 0;
}

+ 1
- 0
templates/starters/cc65-c/starter.json 查看文件

@@ -0,0 +1 @@
{ "include": ["cc65-common"] }

+ 48
- 0
templates/starters/cc65-common/src/smoke.c 查看文件

@@ -0,0 +1,48 @@
/* Smoke-test hooks. See smoke.h. */
#include "smoke.h"

#if defined(__C128__) && defined(FOUNDRY_VDC80)
#include <c128.h>

unsigned char smoke_probe[SMOKE_PROBE_ROWS * 80];

static unsigned char vdc_read(unsigned char reg)
{
VDC.ctrl = reg;
while ((VDC.ctrl & 0x80) == 0) { }
return VDC.data;
}

static void vdc_write(unsigned char reg, unsigned char value)
{
VDC.ctrl = reg;
while ((VDC.ctrl & 0x80) == 0) { }
VDC.data = value;
}

void smoke_capture(void)
{
/* VDC registers 12/13 hold the screen start; register 31 reads VDC RAM and
** auto-increments the update address in registers 18/19. */
unsigned char hi = vdc_read(12);
unsigned char lo = vdc_read(13);
unsigned i;
vdc_write(18, hi);
vdc_write(19, lo);
for (i = 0; i < sizeof smoke_probe; ++i) {
smoke_probe[i] = vdc_read(31);
}
}
#else
unsigned char smoke_probe[1];

void smoke_capture(void)
{
/* 40-column builds: tools/smoke.ps1 reads screen RAM at $0400 directly. */
}
#endif

void smoke_ready(void)
{
/* Intentionally empty: VICE tracepoint target. */
}

+ 17
- 0
templates/starters/cc65-common/src/smoke.h 查看文件

@@ -0,0 +1,17 @@
/* Smoke-test hooks used by tools/smoke.ps1. Keep these in the program.
**
** smoke_capture() copies what is on the VDC 80-column screen into smoke_probe[]
** (80-column builds only), because VICE can only save CPU-visible memory.
** smoke_ready() is an empty function: tools/smoke.ps1 sets a VICE tracepoint on it
** and saves screen memory when it runs. Call both once the first screen is drawn.
*/
#ifndef SMOKE_H
#define SMOKE_H

#define SMOKE_PROBE_ROWS 4

extern unsigned char smoke_probe[];
void smoke_capture(void);
void smoke_ready(void);

#endif

+ 5
- 0
templates/starters/cc65-mixed/src/frame.h 查看文件

@@ -0,0 +1,5 @@
#ifndef FRAME_H
#define FRAME_H
/* Wait until the raster beam reaches the bottom border once (one video frame). */
void __fastcall__ wait_frame(void);
#endif

+ 18
- 0
templates/starters/cc65-mixed/src/frame.s 查看文件

@@ -0,0 +1,18 @@
; wait_frame: block until the VIC-II raster reaches line 251 (bottom border), once per frame.
; Works on PAL and NTSC because line 251 exists on both.
.export _wait_frame

VIC_RASTER = $D012
VIC_CTRL1 = $D011

.segment "CODE"
_wait_frame:
@leave: lda VIC_RASTER ; first make sure we are not already on line 251
cmp #251
beq @leave
@wait: lda VIC_CTRL1 ; bit 7 = raster bit 8; we want line < 256
bmi @wait
lda VIC_RASTER
cmp #251
bne @wait
rts

+ 35
- 0
templates/starters/cc65-mixed/src/main.c.tmpl 查看文件

@@ -0,0 +1,35 @@
/* {{PROJECT_NAME}} - starter program generated by the C64/C128 Dev Foundry.
** Mixed C + ca65: frame.s provides wait_frame(), a raster-synchronised frame wait.
** Milestone M0 only: proves the toolchain, the display, the frame loop and the smoke test.
*/
#include <conio.h>
#if defined(__C128__)
#include <c128.h>
#endif
#include "smoke.h"
#include "frame.h"

int main(void)
{
unsigned char frames = 0;
#if defined(__C128__) && defined(FOUNDRY_VDC80)
videomode(VIDEOMODE_80COL);
#elif defined(__C128__)
videomode(VIDEOMODE_40COL);
#endif
clrscr();
cputsxy(0, 0, "{{SCREEN_TITLE}}");
cputsxy(0, 2, "STARTER OK");
cputsxy(0, 4, "PRESS ANY KEY TO RETURN TO BASIC");
cputsxy(0, 6, "FRAME:");
smoke_capture();
smoke_ready();
while (!kbhit()) {
wait_frame();
gotoxy(7, 6);
cprintf("%3u", (unsigned)frames++);
}
cgetc();
clrscr();
return 0;
}

+ 1
- 0
templates/starters/cc65-mixed/starter.json 查看文件

@@ -0,0 +1 @@
{ "include": ["cc65-common"] }

+ 433
- 0
tests/Run-FoundryTests.ps1 查看文件

@@ -0,0 +1,433 @@
<#
.SYNOPSIS
Automated checks for the C64/C128 Dev Foundry.

.DESCRIPTION
Groups (all run by default):
validation - example and test briefs, conflicts, drafts and resume, override rules
generation - every valid brief through tools/New-FoundryProject.ps1 into a folder whose
path contains spaces; generated files, template completeness, project.json,
Git (branch main, commit, clean tree), no-identity behavior
safety - existing destinations (non-empty, Git repo, file, empty), destinations inside
the Foundry, invalid names, interrupted generation and retry, stale staging
toolchain - for each generated project: tools/check-prereqs.ps1, tools/build.ps1,
tools/smoke.ps1 (VICE headless); on-Commodore round trip; simulated missing tool.
Skipped with a reason when cc65/VICE are not installed.

Results are printed and written to tests/results/latest.md (commands and outcomes).
Exit code 0 = no failures.

.EXAMPLE
pwsh -File tests/Run-FoundryTests.ps1
pwsh -File tests/Run-FoundryTests.ps1 -Group validation,safety
pwsh -File tests/Run-FoundryTests.ps1 -KeepOutput
#>
[CmdletBinding()]
param(
[string[]]$Group = @('validation', 'generation', 'safety', 'toolchain'),
[string]$OutputRoot,
[switch]$KeepOutput
)
$ErrorActionPreference = 'Stop'
$Group = @($Group | ForEach-Object { $_ -split ',' } | ForEach-Object { $_.Trim() } | Where-Object { $_ })
foreach ($g in $Group) { if ($g -notin 'validation', 'generation', 'safety', 'toolchain') { throw "Unknown group '$g'. Use validation, generation, safety, toolchain." } }
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
Import-Module (Join-Path $root 'tools/Foundry.psm1') -Force
$gen = Join-Path $root 'tools/New-FoundryProject.ps1'
$val = Join-Path $root 'tools/Test-FoundryBrief.ps1'
if (-not $OutputRoot) { $OutputRoot = Join-Path ([IO.Path]::GetTempPath()) ("Foundry Tests\run " + (Get-Date -Format 'yyyyMMdd-HHmmss')) }
$projects = Join-Path $OutputRoot 'My C64 Projects' # deliberately contains spaces
New-Item -ItemType Directory -Force -Path $projects | Out-Null

$script:Results = [System.Collections.Generic.List[object]]::new()
$script:Log = [System.Collections.Generic.List[string]]::new()
function Invoke-Check([string]$Name, [scriptblock]$Body) {
$sw = [Diagnostics.Stopwatch]::StartNew()
try {
$detail = & $Body
$status = if ($detail -is [string] -and $detail.StartsWith('SKIP:')) { 'SKIP' } else { 'PASS' }
$script:Results.Add([pscustomobject]@{ Name = $Name; Status = $status; Detail = "$detail"; Seconds = [math]::Round($sw.Elapsed.TotalSeconds, 1) })
} catch {
$script:Results.Add([pscustomobject]@{ Name = $Name; Status = 'FAIL'; Detail = $_.Exception.Message; Seconds = [math]::Round($sw.Elapsed.TotalSeconds, 1) })
}
$r = $script:Results[-1]
$color = @{ PASS = 'Green'; FAIL = 'Red'; SKIP = 'Yellow' }[$r.Status]
Write-Host ("[{0}] {1}{2}" -f $r.Status, $Name, $(if ($r.Detail) { " - $($r.Detail)" } else { '' })) -ForegroundColor $color
}
function Assert([bool]$Condition, [string]$Message) { if (-not $Condition) { throw $Message } }
function Invoke-Pwsh([string]$Script, [string[]]$Arguments, [hashtable]$Env = @{}) {
$saved = @{}
foreach ($k in $Env.Keys) { $saved[$k] = [Environment]::GetEnvironmentVariable($k); [Environment]::SetEnvironmentVariable($k, $Env[$k]) }
try {
$out = & pwsh -NoProfile -File $Script @Arguments 2>&1 | ForEach-Object { "$_" }
$code = $LASTEXITCODE
} finally { foreach ($k in $saved.Keys) { [Environment]::SetEnvironmentVariable($k, $saved[$k]) } }
$quoted = ($Arguments | ForEach-Object { if ($_ -match '\s') { "`"$_`"" } else { $_ } }) -join ' '
$rel = $Script.Replace($root + [IO.Path]::DirectorySeparatorChar, '')
$script:Log.Add("pwsh -File $rel $quoted -> exit $code")
[pscustomobject]@{ Code = $code; Output = @($out); Text = ($out -join "`n") }
}
function Get-Hash([string]$Dir) {
(Get-ChildItem -LiteralPath $Dir -Recurse -File -Force | Sort-Object FullName | ForEach-Object { "$($_.FullName.Substring($Dir.Length))|$((Get-FileHash -LiteralPath $_.FullName).Hash)" }) -join "`n"
}

$examples = @(
@{ Name = 'traffic-control-64'; Brief = Join-Path $root 'examples/traffic-control-64/brief.json'; Expect = 0 },
@{ Name = 'c128-text-viewer'; Brief = Join-Path $root 'examples/c128-text-viewer/brief.json'; Expect = 0 }
)
$valid = @(
@{ Name = 'c128-40-basic7'; Expect = 0 }, @{ Name = 'dual-native'; Expect = 0 }, @{ Name = 'dual-c64mode'; Expect = 0 },
@{ Name = 'on-commodore-basic'; Expect = 0 }, @{ Name = 'override-asm'; Expect = 0 }, @{ Name = 'unverified-onboard-asm'; Expect = 3 },
@{ Name = 'multi-display-c'; Expect = 0 }, @{ Name = 'c128-40-asm'; Expect = 0 }, @{ Name = 'dual-c64mode-c'; Expect = 0 }, @{ Name = 'c128-80-basic7'; Expect = 0 }, @{ Name = 'on-commodore-basic7'; Expect = 0 }
) | ForEach-Object { $_.Brief = Join-Path $root "tests/briefs/$($_.Name).json"; $_ }
$conflicts = 'conflict-basic7-on-c64', 'conflict-80col-on-c64', 'conflict-override-capability', 'conflict-build-location'
$all = @($examples) + @($valid)

# ---------------------------------------------------------------------------
if ('validation' -in $Group) {
foreach ($b in $all) {
Invoke-Check "validation: $($b.Name) is a valid approved brief" {
$r = Invoke-Pwsh $val @($b.Brief, '-Mode', 'Approved')
Assert ($r.Code -eq 0) "exit $($r.Code): $($r.Text)"
}
}
foreach ($c in $conflicts) {
Invoke-Check "validation: $c is reported as a conflict and refused" {
$path = Join-Path $root "tests/briefs/$c.json"
$r = Invoke-Pwsh $val @($path, '-Mode', 'Approved')
Assert ($r.Code -eq 4) "expected exit 4 (conflict), got $($r.Code)"
Assert ($r.Text -match 'CONFLICT') 'no CONFLICT line'
Assert ($r.Text -match 'Ask the user which constraint to change') 'conflict does not ask the user which constraint to change'
$g = Invoke-Pwsh $gen @($path, '-Destination', (Join-Path $projects "should-not-exist $c"), '-SkipVerify')
Assert ($g.Code -eq 1) 'generator did not refuse'
Assert (-not (Test-Path -LiteralPath (Join-Path $projects "should-not-exist $c"))) 'destination was created'
($r.Output | Where-Object { $_ -match 'CONFLICT' } | Select-Object -First 1).Trim().Substring(0, 90) + '...'
}
}
Invoke-Check 'validation: user override conflict names the override and the recommended language' {
$r = Invoke-Pwsh $val @((Join-Path $root 'tests/briefs/conflict-override-capability.json'))
Assert ($r.Text -match "user override") 'override not mentioned'
Assert ($r.Text -match "recommended 'c'") 'recommended language not offered'
}
Invoke-Check 'validation: language different from recommendation without an override is an error' {
$b = Read-FoundryJson (Join-Path $root 'tests/briefs/override-asm.json')
$b.toolchain.override = $null
$res = Test-FoundryBrief -Brief $b -Mode Approved
Assert (-not $res.Valid) 'accepted'
Assert (@($res.Errors | Where-Object { $_.Message -match 'no override is recorded' }).Count -eq 1) 'missing error'
}
Invoke-Check 'validation: override requested but not applied is an error' {
$b = Read-FoundryJson (Join-Path $root 'tests/briefs/override-asm.json')
$b.toolchain.language = 'c'
$res = Test-FoundryBrief -Brief $b -Mode Approved
Assert (@($res.Errors | Where-Object { $_.Message -match 'takes precedence' }).Count -eq 1) 'missing precedence error'
}
Invoke-Check 'validation: dual-target strategy must match the targets' {
$b = Read-FoundryJson (Join-Path $root 'tests/briefs/dual-native.json')
$b.dualTarget.strategy = 'c64-mode-on-both'
$res = Test-FoundryBrief -Brief $b -Mode Approved
Assert ($res.Conflicts.Count -ge 1) 'no conflict for native target under c64-mode-on-both'
$b.dualTarget = $null
$res = Test-FoundryBrief -Brief $b -Mode Approved
Assert (@($res.Missing | Where-Object { $_.Path -eq 'dualTarget.strategy' }).Count -eq 1) 'missing strategy not reported'
}
Invoke-Check 'validation: unlinked requirement and unknown requirement reference are errors' {
$b = Read-FoundryJson (Join-Path $root 'tests/briefs/c128-40-basic7.json')
$b.milestones[0].tasks[0].requirements = @('R9')
$res = Test-FoundryBrief -Brief $b -Mode Approved
Assert (@($res.Errors | Where-Object { $_.Message -match "unknown requirement 'R9'" }).Count -eq 1) 'unknown ref not reported'
Assert (@($res.Errors | Where-Object { $_.Message -match 'R2 is not linked' }).Count -eq 1) 'unlinked requirement not reported'
}
Invoke-Check 'validation: unapproved brief is refused by the generator' {
$tmp = Join-Path $OutputRoot 'unapproved.json'
$b = Read-FoundryJson (Join-Path $root 'tests/briefs/c128-40-basic7.json')
$b.status = 'draft'
[IO.File]::WriteAllText($tmp, ($b | ConvertTo-Json -Depth 32))
$g = Invoke-Pwsh $gen @($tmp, '-Destination', (Join-Path $projects 'unapproved'), '-SkipVerify')
Assert ($g.Code -eq 1 -and $g.Text -match "status must be 'approved'") "exit $($g.Code)"
}
Invoke-Check 'draft: paused draft reports the stage and questions to resume with' {
$r = Invoke-Pwsh $val @((Join-Path $root 'tests/briefs/draft-paused.json'))
Assert ($r.Code -eq 0) "draft mode should accept an incomplete draft (exit $($r.Code))"
Assert ($r.Text -match 'Resume interview at stage: first-release') 'wrong resume stage'
Assert ($r.Text -match 'Should the first release include sound\?') 'saved open question not repeated'
$a = Invoke-Pwsh $val @((Join-Path $root 'tests/briefs/draft-paused.json'), '-Mode', 'Approved')
Assert ($a.Code -eq 1) 'incomplete draft passed approved-mode validation'
'resume stage: first-release'
}
Invoke-Check 'draft: New-FoundryDraft creates a draft that resumes at the first stage with gaps' {
$slug = 'zz-test-draft-' + [Guid]::NewGuid().ToString('N').Substring(0, 6)
$r = Invoke-Pwsh (Join-Path $root 'tools/New-FoundryDraft.ps1') @('-Name', 'Test Draft', '-Idea', 'A tiny test idea.', '-Slug', $slug)
$path = Join-Path $root "drafts/$slug.json"
try {
Assert (Test-Path -LiteralPath $path) 'draft file not created'
Assert ($r.Text -match 'Resume interview at stage: idea') "unexpected stage: $($r.Text)"
$again = Invoke-Pwsh (Join-Path $root 'tools/New-FoundryDraft.ps1') @('-Name', 'Test Draft', '-Idea', 'x', '-Slug', $slug)
Assert ($again.Code -eq 1) 'existing draft was overwritten'
} finally { Remove-Item -LiteralPath $path -ErrorAction SilentlyContinue }
}
Invoke-Check 'schema: every example, test brief and the draft template match schema/project-brief.schema.json' {
$schema = Join-Path $root 'schema/project-brief.schema.json'
$files = @(Get-ChildItem (Join-Path $root 'examples') -Recurse -Filter brief.json) + @(Get-ChildItem (Join-Path $root 'tests/briefs') -Filter *.json) + @(Get-Item (Join-Path $root 'templates/brief/draft.json'))
foreach ($f in $files) { Assert (Test-Json -Path $f.FullName -SchemaFile $schema -ErrorAction SilentlyContinue) "$($f.Name) does not match the schema" }
$bad = Join-Path $OutputRoot 'bad-schema.json'
$b = Read-FoundryJson (Join-Path $root 'tests/briefs/c128-40-basic7.json'); $b.targets[0].platform = 'vic20'
[IO.File]::WriteAllText($bad, ($b | ConvertTo-Json -Depth 32))
$r = Invoke-Pwsh $val @($bad)
Assert ($r.Code -ne 0 -and $r.Text -match 'SCHEMA') 'schema violation not reported'
"$($files.Count) files conform; invalid platform rejected"
}
Invoke-Check 'templates: unknown placeholder is rejected' {
$threw = $false
try { Expand-FoundryTemplate 'Hello {{NOT_A_VAR}}' @{} 'unit' | Out-Null } catch { $threw = $_.Exception.Message -match 'NOT_A_VAR' }
Assert $threw 'no error for unknown placeholder'
}
}

# ---------------------------------------------------------------------------
$generated = @{}
if ('generation' -in $Group -or 'toolchain' -in $Group) {
foreach ($b in $all) {
Invoke-Check "generation: $($b.Name) through tools/New-FoundryProject.ps1" {
$dest = Join-Path $projects $b.Name.Replace('-', ' ')
$r = Invoke-Pwsh $gen @($b.Brief, '-Destination', $dest, '-SkipVerify', '-Json')
Assert ($r.Code -eq 0) "generator exit $($r.Code): $($r.Text)"
$json = ($r.Output | Where-Object { $_ -notmatch '^\s*$' }) -join "`n"
$res = $json.Substring($json.IndexOf('{')) | ConvertFrom-Json
$generated[$b.Name] = $dest
$res.Destination
}
}
}
if ('generation' -in $Group) {
foreach ($b in $all) {
$dest = $generated[$b.Name]
if (-not $dest) { continue }
Invoke-Check "generated files: $($b.Name)" {
$required = 'README.md', 'AGENTS.md', 'CLAUDE.md', '.gitignore', '.gitattributes', 'project.json', 'docs/spec.md', 'docs/toolchain.md', 'docs/milestones.md', 'docs/manual-tests.md', 'docs/verification-status.md', 'tools/lib.ps1', 'tools/build.ps1', 'tools/run.ps1', 'tools/smoke.ps1', 'tools/check-prereqs.ps1'
foreach ($f in $required) { Assert (Test-Path -LiteralPath (Join-Path $dest $f)) "missing $f" }
Assert (@(Get-ChildItem -LiteralPath (Join-Path $dest 'src') -File).Count -ge 1) 'no source files'
$p = Get-Content -LiteralPath (Join-Path $dest 'project.json') -Raw | ConvertFrom-Json -AsHashtable
Assert ($p.status -eq 'approved' -and $p.resolved -and @($p.resolved.targets).Count -ge 1) 'project.json incomplete'
Assert ($p.toolchain.language -and $p.buildLocation -and @($p.targets).Count -eq @($p.resolved.targets).Count) 'project.json missing target/language/build location'
$spec = Get-Content -LiteralPath (Join-Path $dest 'docs/spec.md') -Raw
foreach ($req in $p.requirements) { Assert ($spec -match [regex]::Escape("### $($req.id) ")) "spec lacks $($req.id)" }
foreach ($t in $p.targets) { Assert ($spec -match [regex]::Escape("``$($t.id)``")) "spec lacks target $($t.id)" }
$ms = Get-Content -LiteralPath (Join-Path $dest 'docs/milestones.md') -Raw
Assert ($ms -match '## M0 - Starter builds and runs') 'milestones lack M0'
foreach ($m in $p.milestones) { Assert ($ms -match "## $($m.id) ") "milestones lack $($m.id)" }
$mt = Get-Content -LiteralPath (Join-Path $dest 'docs/manual-tests.md') -Raw
foreach ($t in $p.targets) { Assert ($mt -match "MT0-$($t.id)") "manual tests lack M0 for $($t.id)" }
$agents = Get-Content -LiteralPath (Join-Path $dest 'AGENTS.md') -Raw
Assert ($agents -match 'PENDING until you confirm' -and $agents -match 'docs/spec.md') 'AGENTS.md incomplete'
$oc = Test-Path -LiteralPath (Join-Path $dest 'tools/to-commodore.ps1')
Assert ($oc -eq ($p.buildLocation -eq 'on-commodore')) 'on-Commodore scripts present/absent incorrectly'
if ($p.toolchain.override) { Assert ((Get-Content -LiteralPath (Join-Path $dest 'docs/toolchain.md') -Raw) -match 'User override \(approved\)') 'override not documented' }
"$(@(Get-ChildItem -LiteralPath $dest -Recurse -File -Force | Where-Object FullName -notmatch '\\.git\\').Count) files"
}
Invoke-Check "template completeness: $($b.Name) has no unresolved placeholders" {
$u = @(Find-UnresolvedPlaceholders $dest)
Assert ($u.Count -eq 0) (($u | ForEach-Object { "$($_.File):$($_.Line)" }) -join ', ')
}
Invoke-Check "git: $($b.Name) is on main with a clean initial commit" {
$branch = (& git -C $dest symbolic-ref --short HEAD) -join ''
Assert ($branch -eq 'main') "branch is '$branch'"
$count = (& git -C $dest rev-list --count HEAD 2>$null) -join ''
Assert ($count -eq '1') "expected 1 commit, found '$count'"
$status = (& git -C $dest status --porcelain) -join "`n"
Assert (-not $status) "working tree not clean: $status"
$remotes = (& git -C $dest remote) -join ''
Assert (-not $remotes) 'a remote was configured'
}
}
Invoke-Check 'git: without a Git identity the files are staged, not committed' {
$empty = Join-Path $OutputRoot 'empty-gitconfig'
Set-Content -LiteralPath $empty -Value ''
$dest = Join-Path $projects 'no identity'
$r = Invoke-Pwsh $gen @((Join-Path $root 'tests/briefs/c128-40-basic7.json'), '-Destination', $dest, '-SkipVerify') @{ GIT_CONFIG_GLOBAL = $empty; GIT_CONFIG_NOSYSTEM = '1'; GIT_AUTHOR_NAME = $null; GIT_AUTHOR_EMAIL = $null; GIT_COMMITTER_NAME = $null; GIT_COMMITTER_EMAIL = $null }
Assert ($r.Code -eq 0) "exit $($r.Code): $($r.Text)"
Assert ($r.Text -match 'no Git identity configured') 'no-identity message missing'
& git -C $dest rev-parse --verify HEAD 2>$null | Out-Null
Assert ($LASTEXITCODE -ne 0) 'a commit exists'
$staged = @(& git -C $dest diff --cached --name-only)
Assert ($staged.Count -gt 10) "only $($staged.Count) files staged"
"$($staged.Count) files staged"
}
}

# ---------------------------------------------------------------------------
if ('safety' -in $Group) {
$brief = Join-Path $root 'tests/briefs/c128-40-basic7.json'
Invoke-Check 'safety: existing non-empty folder is refused and left untouched' {
$dest = Join-Path $projects 'existing work'
New-Item -ItemType Directory -Force -Path (Join-Path $dest 'notes') | Out-Null
Set-Content -LiteralPath (Join-Path $dest 'notes/todo.txt') -Value 'my work'
$before = Get-Hash $dest
$r = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify')
Assert ($r.Code -eq 1 -and $r.Text -match 'not empty') "exit $($r.Code)"
Assert ((Get-Hash $dest) -eq $before) 'existing folder changed'
Assert (@(Get-ChildItem -LiteralPath $projects -Force -Filter '.existing work.foundry-staging-*').Count -eq 0) 'staging folder left behind'
}
Invoke-Check 'safety: existing project repository is refused and left untouched' {
$dest = Join-Path $projects 'existing repo'
New-Item -ItemType Directory -Force -Path $dest | Out-Null
& git -C $dest init -q -b main
Set-Content -LiteralPath (Join-Path $dest 'README.md') -Value 'existing project'
$before = Get-Hash $dest
$r = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify')
Assert ($r.Code -eq 1 -and $r.Text -match 'already contains a Git repository') "exit $($r.Code): $($r.Text)"
Assert ((Get-Hash $dest) -eq $before) 'existing repo changed'
}
Invoke-Check 'safety: destination that is a file is refused' {
$dest = Join-Path $projects 'a file'
Set-Content -LiteralPath $dest -Value 'x'
$r = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify')
Assert ($r.Code -eq 1 -and (Get-Content -LiteralPath $dest) -eq 'x') "exit $($r.Code)"
}
Invoke-Check 'safety: existing empty folder is accepted' {
$dest = Join-Path $projects 'empty folder'
New-Item -ItemType Directory -Force -Path $dest | Out-Null
$r = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify')
Assert ($r.Code -eq 0 -and (Test-Path -LiteralPath (Join-Path $dest 'AGENTS.md'))) "exit $($r.Code): $($r.Text)"
}
Invoke-Check 'safety: destination inside the Foundry repository is refused' {
$r = Invoke-Pwsh $gen @($brief, '-Destination', (Join-Path $root 'output/inside'), '-SkipVerify')
Assert ($r.Code -eq 1 -and $r.Text -match 'inside the Foundry') "exit $($r.Code)"
Assert (-not (Test-Path -LiteralPath (Join-Path $root 'output/inside'))) 'folder created inside Foundry'
}
Invoke-Check 'safety: invalid destination names are refused' {
foreach ($bad in @((Join-Path $projects 'bad|name'), (Join-Path $projects 'trailing dot.'), (Join-Path $projects 'CON'))) {
$r = Invoke-Pwsh $gen @($brief, '-Destination', $bad, '-SkipVerify')
Assert ($r.Code -eq 1) "accepted '$bad'"
}
}
foreach ($stepName in 'templates', 'files', 'git') {
Invoke-Check "safety: interruption after '$stepName' leaves nothing behind, and a retry succeeds" {
$dest = Join-Path $projects "interrupted $stepName"
$r = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify', '-FailAfterStep', $stepName)
Assert ($r.Code -eq 1 -and $r.Text -match 'Simulated interruption') "exit $($r.Code)"
Assert (-not (Test-Path -LiteralPath $dest)) 'destination created by failed run'
Assert (@(Get-ChildItem -LiteralPath $projects -Force -Filter ".interrupted $stepName.foundry-staging-*").Count -eq 0) 'staging left behind'
$retry = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify')
Assert ($retry.Code -eq 0 -and (Test-Path -LiteralPath (Join-Path $dest 'project.json'))) "retry failed: $($retry.Text)"
}
}
Invoke-Check 'safety: interruption into an existing empty folder keeps the folder' {
$dest = Join-Path $projects 'empty kept'
New-Item -ItemType Directory -Force -Path $dest | Out-Null
$r = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify', '-FailAfterStep', 'git')
Assert ($r.Code -eq 1) 'did not fail'
Assert ((Test-Path -LiteralPath $dest -PathType Container) -and @(Get-ChildItem -LiteralPath $dest -Force).Count -eq 0) 'empty folder not restored'
}
Invoke-Check 'safety: leftover staging folder from a killed run is cleaned on retry' {
$dest = Join-Path $projects 'after crash'
$stale = Join-Path $projects '.after crash.foundry-staging-20000101000000-dead00'
New-Item -ItemType Directory -Force -Path (Join-Path $stale 'docs') | Out-Null
Set-Content -LiteralPath (Join-Path $stale 'docs/partial.md') -Value 'partial'
$r = Invoke-Pwsh $gen @($brief, '-Destination', $dest, '-SkipVerify')
Assert ($r.Code -eq 0 -and $r.Text -match 'leftover staging') "exit $($r.Code): $($r.Text)"
Assert (-not (Test-Path -LiteralPath $stale)) 'stale staging still there'
}
}

# ---------------------------------------------------------------------------
if ('toolchain' -in $Group) {
$probe = $generated['traffic-control-64']
$pre = if ($probe) { Invoke-Pwsh (Join-Path $probe 'tools/check-prereqs.ps1') @() } else { $null }
$toolsOk = $pre -and $pre.Code -eq 0
foreach ($b in $all) {
$dest = $generated[$b.Name]
if (-not $dest) { continue }
Invoke-Check "toolchain: $($b.Name) check-prereqs, build and smoke test (expect exit $($b.Expect))" {
if (-not $toolsOk) { return "SKIP: prerequisites missing ($(($pre.Output | Where-Object { $_ -match 'MISSING' }) -join '; '))" }
$p = Invoke-Pwsh (Join-Path $dest 'tools/check-prereqs.ps1') @()
Assert ($p.Code -eq 0) "check-prereqs exit $($p.Code)"
$bld = Invoke-Pwsh (Join-Path $dest 'tools/build.ps1') @()
Assert ($bld.Code -eq 0) "build exit $($bld.Code): $($bld.Text)"
$s = Invoke-Pwsh (Join-Path $dest 'tools/smoke.ps1') @()
Assert ($s.Code -eq $b.Expect) "smoke exit $($s.Code), expected $($b.Expect):`n$($s.Text)"
$lines = @($s.Output | Where-Object { $_ -match '^\s+\[(PASS|FAIL|MANUAL)\]' } | ForEach-Object { $_.Trim() })
foreach ($l in $s.Output | Where-Object { $_ -match '^\s+(ok|FAIL)\s' }) { $script:Log.Add(" $($l.Trim())") }
$lines -join ', '
}
}
Invoke-Check 'toolchain: tools/run.ps1 starts VICE with the program (interactive launch)' {
if (-not $toolsOk) { return 'SKIP: prerequisites missing' }
$results = @()
foreach ($name in 'traffic-control-64', 'c128-text-viewer') {
$dest = $generated[$name]
$p = Get-Content -LiteralPath (Join-Path $dest 'project.json') -Raw | ConvertFrom-Json -AsHashtable
$exe = $p.resolved.targets[0].emulator.binary
$before = @(Get-Process $exe -ErrorAction SilentlyContinue | ForEach-Object Id)
$r = Invoke-Pwsh (Join-Path $dest 'tools/run.ps1') @('-NoBuild')
Assert ($r.Code -eq 0) "run.ps1 exit $($r.Code): $($r.Text)"
Start-Sleep -Seconds 6
$new = @(Get-Process $exe -ErrorAction SilentlyContinue | Where-Object { $_.Id -notin $before })
Assert ($new.Count -ge 1) "$exe exited or did not start (check the emulator arguments): $($r.Text)"
$new | Stop-Process -Force
$results += "$name -> $exe running"
}
$results -join '; '
}
Invoke-Check 'toolchain: on-Commodore round trip (host -> transfer disk -> host) is lossless' {
if (-not $toolsOk) { return 'SKIP: prerequisites missing' }
$dest = $generated['on-commodore-basic']
$to = Invoke-Pwsh (Join-Path $dest 'tools/to-commodore.ps1') @()
Assert ($to.Code -eq 0 -and (Test-Path -LiteralPath (Join-Path $dest 'build/transfer/spelling-bee.d64'))) "to-commodore exit $($to.Code): $($to.Text)"
$from = Invoke-Pwsh (Join-Path $dest 'tools/from-commodore.ps1') @()
Assert ($from.Code -eq 0) "from-commodore exit $($from.Code): $($from.Text)"
$orig = (& git -C $dest show HEAD:src/main.bas) -join "`n"
$back = (Get-Content -LiteralPath (Join-Path $dest 'src/main.bas')) -join "`n"
$norm = { param($t) ($t -split "`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ }) -join "`n" }
Assert ((& $norm $orig) -eq (& $norm $back)) "listing changed:`n$back"
& git -C $dest checkout -q -- src/main.bas
'listing identical after detokenizing'
}
Invoke-Check 'toolchain: on-Commodore change made on the target comes back to the host' {
if (-not $toolsOk) { return 'SKIP: prerequisites missing' }
$dest = $generated['on-commodore-basic']
# Simulate editing on the Commodore: a new line saved to the transfer disk.
$p = Get-Content -LiteralPath (Join-Path $dest 'project.json') -Raw | ConvertFrom-Json -AsHashtable
$tool = { param($id) $t = $p.resolved.tools | Where-Object { $_.id -eq $id }; . (Join-Path $dest 'tools/lib.ps1'); Find-ToolPath $t }
$petcat = & $tool 'petcat'; $c1541 = & $tool 'c1541'
$edited = Join-Path $OutputRoot 'edited.bas'
(Get-Content -LiteralPath (Join-Path $dest 'src/main.bas')) + '80 rem edited on the c64' | Set-Content -LiteralPath $edited
& $petcat -w2 -f -o (Join-Path $OutputRoot 'edited.prg') -- $edited | Out-Null
& $c1541 -attach (Join-Path $dest 'build/transfer/spelling-bee.d64') -delete spellingbee -write (Join-Path $OutputRoot 'edited.prg') spellingbee 2>&1 | Out-Null
$from = Invoke-Pwsh (Join-Path $dest 'tools/from-commodore.ps1') @()
Assert ($from.Code -eq 0) "from-commodore exit $($from.Code)"
Assert ((Get-Content -LiteralPath (Join-Path $dest 'src/main.bas') -Raw) -match '80 rem edited on the c64') 'edit not returned'
& git -C $dest checkout -q -- src/main.bas
'line 80 arrived in src/main.bas'
}
Invoke-Check 'toolchain: a missing tool is reported with the first command and what stays unverified' {
$src = $generated['c128-40-basic7']
$dest = Join-Path $projects 'missing tool copy'
Copy-Item -LiteralPath $src -Destination $dest -Recurse
$pj = Join-Path $dest 'project.json'
$p = Get-Content -LiteralPath $pj -Raw | ConvertFrom-Json -AsHashtable
($p.resolved.tools | Where-Object { $_.id -eq 'x128' }).executable = 'x128-not-installed'
[IO.File]::WriteAllText($pj, ($p | ConvertTo-Json -Depth 64))
$c = Invoke-Pwsh (Join-Path $dest 'tools/check-prereqs.ps1') @()
Assert ($c.Code -eq 2) "check-prereqs exit $($c.Code)"
Assert ($c.Text -match 'MISSING\] x128-not-installed' -and $c.Text -match 'First step : winget install' -and $c.Text -match 'Unverified until installed: run and smoke test of target c128-40') "message incomplete:`n$($c.Text)"
$s = Invoke-Pwsh (Join-Path $dest 'tools/smoke.ps1') @()
Assert ($s.Code -eq 2 -and $s.Text -match 'MISSING TOOL') "smoke exit $($s.Code)"
'exit 2 with install command'
}
}

# ---------------------------------------------------------------------------
$pass = @($Results | Where-Object Status -eq 'PASS').Count
$fail = @($Results | Where-Object Status -eq 'FAIL').Count
$skip = @($Results | Where-Object Status -eq 'SKIP').Count
Write-Host ""
Write-Host "Summary: $pass passed, $fail failed, $skip skipped. Output: $OutputRoot"
$md = @("# Foundry test run $(Get-Date -Format 'yyyy-MM-dd HH:mm')", '', "Groups: $($Group -join ', '). Output folder: ``$OutputRoot``", '', "Result: **$pass passed, $fail failed, $skip skipped**", '', '| Status | Check | Detail | s |', '|---|---|---|---|')
$md += $Results | ForEach-Object { "| $($_.Status) | $($_.Name) | $(($_.Detail -replace '\|', '/' -replace '\r?\n', ' ').Substring(0, [Math]::Min(300, $_.Detail.Length))) | $($_.Seconds) |" }
$md += ''; $md += '## Commands run'; $md += ''; $md += '```'; $md += $Log; $md += '```'
$resultsDir = Join-Path $root 'tests/results'
New-Item -ItemType Directory -Force -Path $resultsDir | Out-Null
[IO.File]::WriteAllText((Join-Path $resultsDir 'latest.md'), ($md -join "`n"), [Text.UTF8Encoding]::new($false))
if (-not $KeepOutput -and $fail -eq 0) { Remove-Item -LiteralPath $OutputRoot -Recurse -Force -ErrorAction SilentlyContinue }
exit $(if ($fail) { 1 } else { 0 })

+ 182
- 0
tests/briefs/c128-40-asm.json 查看文件

@@ -0,0 +1,182 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Raster Clock",
"slug": "raster-clock",
"idea": "Test idea for Raster Clock.",
"summary": "Test project: Raster Clock.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/raster-clock",
"targets": [
{
"id": "c128-40",
"platform": "c128-native",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Native C128 40-column; prints the title."
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'RASTER CLOCK'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"raster-interrupts"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "asm-ca65",
"recommended": {
"recipe": "cc65",
"language": "asm-ca65"
},
"reasons": [
"Raster interrupts need cycle-level control; ca65 assembly gives it."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "RASTER CLOCK",
"expectedScreen": "'RASTER CLOCK' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 182
- 0
tests/briefs/c128-40-basic7.json 查看文件

@@ -0,0 +1,182 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "C128 Quiz Card",
"slug": "c128-quiz-card",
"idea": "Test idea for C128 Quiz Card.",
"summary": "Test project: C128 Quiz Card.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/c128-quiz-card",
"targets": [
{
"id": "c128-40",
"platform": "c128-native",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "C128 native mode, 40-column VIC-II screen with the title and STARTER OK."
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'C128 QUIZ CARD'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"sid-sound"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "basic-petcat",
"language": "basic-7",
"recommended": {
"recipe": "basic-petcat",
"language": "basic-7"
},
"reasons": [
"BASIC 7.0 is built into the C128, has structured loops and SOUND, and is fast enough for a quiz."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "C128 QUIZ CARD",
"expectedScreen": "'C128 QUIZ CARD' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 182
- 0
tests/briefs/c128-80-basic7.json 查看文件

@@ -0,0 +1,182 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Wide Notes",
"slug": "wide-notes",
"idea": "Test idea for Wide Notes.",
"summary": "Test project: Wide Notes.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/wide-notes",
"targets": [
{
"id": "c128-80",
"platform": "c128-native",
"display": "vdc-80",
"video": "pal",
"expectedBehavior": "BASIC 7.0 program on the 80-column screen."
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'WIDE NOTES'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"vdc-80col"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "basic-petcat",
"language": "basic-7",
"recommended": {
"recipe": "basic-petcat",
"language": "basic-7"
},
"reasons": [
"BASIC 7.0 prints directly to the 80-column screen; no compiler needed for a notes screen."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "WIDE NOTES",
"expectedScreen": "'WIDE NOTES' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 182
- 0
tests/briefs/conflict-80col-on-c64.json 查看文件

@@ -0,0 +1,182 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Conflict 80col on C64",
"slug": "conflict-80col-c64",
"idea": "Test idea for Conflict 80col on C64.",
"summary": "Test project: Conflict 80col on C64.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/conflict-80col-c64",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vdc-80",
"video": "pal",
"expectedBehavior": "n/a"
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'CONFLICT'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"vdc-80col"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "c",
"recommended": {
"recipe": "cc65",
"language": "c"
},
"reasons": [
"Simplest language that meets every requirement and target."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "CONFLICT",
"expectedScreen": "'CONFLICT' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 186
- 0
tests/briefs/conflict-basic7-on-c64.json 查看文件

@@ -0,0 +1,186 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Conflict BASIC7 on C64",
"slug": "conflict-basic7-c64",
"idea": "Test idea for Conflict BASIC7 on C64.",
"summary": "Test project: Conflict BASIC7 on C64.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/conflict-basic7-c64",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "n/a"
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'CONFLICT'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "basic-petcat",
"language": "basic-7",
"recommended": {
"recipe": "basic-petcat",
"language": "basic-v2"
},
"reasons": [
"User override."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": {
"requestedLanguage": "basic-7",
"requestedBy": "user",
"reason": "I like the BASIC 7 commands.",
"accepted": true
},
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "CONFLICT",
"expectedScreen": "'CONFLICT' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 185
- 0
tests/briefs/conflict-build-location.json 查看文件

@@ -0,0 +1,185 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Conflict build location",
"slug": "conflict-build-location",
"idea": "Test idea for Conflict build location.",
"summary": "Test project: Conflict build location.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/conflict-build-location",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "n/a"
}
],
"dualTarget": null,
"buildLocation": "on-commodore",
"onCommodore": {
"targetTool": "n/a",
"transfer": "D64",
"diskFormat": "d64"
},
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'CONFLICT'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "c",
"recommended": {
"recipe": "cc65",
"language": "c"
},
"reasons": [
"Simplest language that meets every requirement and target."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "CONFLICT",
"expectedScreen": "'CONFLICT' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 188
- 0
tests/briefs/conflict-override-capability.json 查看文件

@@ -0,0 +1,188 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Conflict BASIC arcade",
"slug": "conflict-basic-arcade",
"idea": "Test idea for Conflict BASIC arcade.",
"summary": "Test project: Conflict BASIC arcade.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/conflict-basic-arcade",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "n/a"
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'CONFLICT'"
],
"capabilities": [
"text-ui",
"smooth-animation"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"smooth-animation"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "basic-petcat",
"language": "basic-v2",
"recommended": {
"recipe": "cc65",
"language": "c"
},
"reasons": [
"User override."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": {
"requestedLanguage": "basic-v2",
"requestedBy": "user",
"reason": "I only know BASIC.",
"accepted": true
},
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "CONFLICT",
"expectedScreen": "'CONFLICT' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 64
- 0
tests/briefs/draft-paused.json 查看文件

@@ -0,0 +1,64 @@
{
"schemaVersion": "1.0",
"status": "draft",
"approval": null,
"interview": {
"stage": "first-release",
"openQuestions": [
"Should the first release include sound?"
],
"notes": [
"Paused after target questions."
]
},
"project": {
"name": "Paused Draft",
"slug": "paused-draft",
"idea": "Test idea for Paused Draft.",
"summary": "Test project: Paused Draft.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/paused-draft",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Title screen."
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "",
"inScope": [],
"outOfScope": []
},
"requirements": [],
"design": {},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": null,
"starter": null,
"milestones": []
}

+ 191
- 0
tests/briefs/dual-c64mode-c.json 查看文件

@@ -0,0 +1,191 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Pocket Planner",
"slug": "pocket-planner",
"idea": "Test idea for Pocket Planner.",
"summary": "Test project: Pocket Planner.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/pocket-planner",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Runs on a C64."
},
{
"id": "c128-in-c64-mode",
"platform": "c128-c64mode",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Same PRG on a C128 in C64 mode."
}
],
"dualTarget": {
"strategy": "c64-mode-on-both",
"notes": "One cc65 C64 build; no native C128 build."
},
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'POCKET PLANNER'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "c",
"recommended": {
"recipe": "cc65",
"language": "c"
},
"reasons": [
"C gives structured data handling at good speed."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "POCKET PLANNER",
"expectedScreen": "'POCKET PLANNER' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 192
- 0
tests/briefs/dual-c64mode.json 查看文件

@@ -0,0 +1,192 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Morse Trainer",
"slug": "morse-trainer",
"idea": "Test idea for Morse Trainer.",
"summary": "Test project: Morse Trainer.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/morse-trainer",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Runs on a C64."
},
{
"id": "c128-in-c64-mode",
"platform": "c128-c64mode",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "The same PRG runs on a C128 after GO 64."
}
],
"dualTarget": {
"strategy": "c64-mode-on-both",
"notes": "One BASIC V2 program. On a C128 the user enters C64 mode first; no native C128 build."
},
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'MORSE TRAINER'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"sid-sound"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "basic-petcat",
"language": "basic-v2",
"recommended": {
"recipe": "basic-petcat",
"language": "basic-v2"
},
"reasons": [
"A Morse trainer needs only text, keys and SID tones; BASIC V2 is enough and runs on both machines in C64 mode."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "MORSE TRAINER",
"expectedScreen": "'MORSE TRAINER' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 191
- 0
tests/briefs/dual-native.json 查看文件

@@ -0,0 +1,191 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Dice Duel",
"slug": "dice-duel",
"idea": "Test idea for Dice Duel.",
"summary": "Test project: Dice Duel.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/dice-duel",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "C64 build: 40-column title screen."
},
{
"id": "c128-80",
"platform": "c128-native",
"display": "vdc-80",
"video": "pal",
"expectedBehavior": "Native C128 build: same title on the 80-column VDC screen."
}
],
"dualTarget": {
"strategy": "native-per-target",
"notes": "Shared C source; cc65 builds a C64 PRG and a native C128 PRG. The C128 build uses the 80-column screen; layout code reads the screen width from screensize()."
},
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'DICE DUEL'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "c",
"recommended": {
"recipe": "cc65",
"language": "c"
},
"reasons": [
"C compiles from one source for both machines with cc65 (-t c64 and -t c128)."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "DICE DUEL",
"expectedScreen": "'DICE DUEL' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 191
- 0
tests/briefs/multi-display-c.json 查看文件

@@ -0,0 +1,191 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Unit Converter",
"slug": "unit-converter",
"idea": "Test idea for Unit Converter.",
"summary": "Test project: Unit Converter.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/unit-converter",
"targets": [
{
"id": "c128-40",
"platform": "c128-native",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Native C128, 40-column screen."
},
{
"id": "c128-80",
"platform": "c128-native",
"display": "vdc-80",
"video": "pal",
"expectedBehavior": "Same program, 80-column screen."
}
],
"dualTarget": {
"strategy": "multi-display",
"notes": "One native C128 program. The 40-column target is built with the VIC-II screen, the 80-column one with the VDC (FOUNDRY_VDC80); both are verified separately."
},
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'UNIT CONVERTER'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "c",
"recommended": {
"recipe": "cc65",
"language": "c"
},
"reasons": [
"C is fast and portable across both C128 displays."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "UNIT CONVERTER",
"expectedScreen": "'UNIT CONVERTER' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 186
- 0
tests/briefs/on-commodore-basic.json 查看文件

@@ -0,0 +1,186 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Spelling Bee",
"slug": "spelling-bee",
"idea": "Test idea for Spelling Bee.",
"summary": "Test project: Spelling Bee.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/spelling-bee",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal-ntsc",
"expectedBehavior": "Loaded from the transfer disk with LOAD and RUN; shows the title."
}
],
"dualTarget": null,
"buildLocation": "on-commodore",
"onCommodore": {
"targetTool": "C64 BASIC V2 screen editor",
"transfer": "D64 transfer image attached in VICE (or written to an SD2IEC card for real hardware)",
"diskFormat": "d64",
"programName": "spellingbee"
},
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'SPELLING BEE'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "basic-onboard",
"language": "basic-v2",
"recommended": {
"recipe": "basic-onboard",
"language": "basic-v2"
},
"reasons": [
"The user wants to type and edit the program on the C64 itself; BASIC V2 is built in."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "SPELLING BEE",
"expectedScreen": "'SPELLING BEE' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 187
- 0
tests/briefs/on-commodore-basic7.json 查看文件

@@ -0,0 +1,187 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "C128 Typing Drill",
"slug": "typing-drill",
"idea": "Test idea for C128 Typing Drill.",
"summary": "Test project: C128 Typing Drill.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/typing-drill",
"targets": [
{
"id": "c128-80",
"platform": "c128-native",
"display": "vdc-80",
"video": "pal",
"expectedBehavior": "Loaded from the transfer disk in C128 mode on the 80-column screen."
}
],
"dualTarget": null,
"buildLocation": "on-commodore",
"onCommodore": {
"targetTool": "C128 BASIC 7.0 screen editor",
"transfer": "D64 transfer image",
"diskFormat": "d64",
"programName": "typingdrill"
},
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'TYPING DRILL'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"vdc-80col"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "basic-onboard",
"language": "basic-7",
"recommended": {
"recipe": "basic-onboard",
"language": "basic-7"
},
"reasons": [
"The user wants to edit on the C128 itself in 80 columns."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "TYPING DRILL",
"expectedScreen": "'TYPING DRILL' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 187
- 0
tests/briefs/override-asm.json 查看文件

@@ -0,0 +1,187 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Starfield",
"slug": "starfield",
"idea": "Test idea for Starfield.",
"summary": "Test project: Starfield.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/starfield",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Title, then a scrolling starfield."
}
],
"dualTarget": null,
"buildLocation": "windows-cross",
"onCommodore": null,
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'STARFIELD'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input",
"smooth-animation"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "cc65",
"language": "asm-ca65",
"recommended": {
"recipe": "cc65",
"language": "c"
},
"reasons": [
"Recommended C (cc65); the user asked for 6502 assembly to learn it. Assembly supports every target and capability, so the override is accepted."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": {
"requestedLanguage": "asm-ca65",
"requestedBy": "user",
"reason": "I want to learn 6502 assembly with this project.",
"accepted": true
},
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "STARFIELD",
"expectedScreen": "'STARFIELD' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 185
- 0
tests/briefs/unverified-onboard-asm.json 查看文件

@@ -0,0 +1,185 @@
{
"schemaVersion": "1.0",
"status": "approved",
"approval": {
"approvedBy": "automated test",
"approvedOn": "2026-11-26"
},
"interview": {
"stage": "review",
"openQuestions": [],
"notes": [
"Test fixture brief for the Foundry automated checks."
]
},
"project": {
"name": "Border Flash",
"slug": "border-flash",
"idea": "Test idea for Border Flash.",
"summary": "Test project: Border Flash.",
"kind": "other",
"smallestUsefulVersion": "Shows its title screen and waits for a key."
},
"destination": "../Foundry Test Output/border-flash",
"targets": [
{
"id": "c64",
"platform": "c64",
"display": "vicii-40",
"video": "pal",
"expectedBehavior": "Assembled on the C64; SYS 49152 prints the title."
}
],
"dualTarget": null,
"buildLocation": "on-commodore",
"onCommodore": {
"targetTool": "Turbo Macro Pro (user supplied)",
"transfer": "D64 transfer image",
"diskFormat": "d64"
},
"testing": {
"emulator": "vice",
"realHardware": {
"requested": false,
"reason": ""
}
},
"scope": {
"firstRelease": "Title screen and one interaction.",
"inScope": [
"Title screen"
],
"outOfScope": [
"Everything else"
]
},
"requirements": [
{
"id": "R1",
"title": "Title screen",
"priority": "must",
"text": "Shows the title and waits for a key.",
"acceptance": [
"Row 0 shows 'BORDER FLASH'"
],
"capabilities": [
"text-ui"
]
},
{
"id": "R2",
"title": "Key response",
"priority": "must",
"text": "A key press returns to BASIC.",
"acceptance": [
"Any key returns to the READY prompt"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
"controls": {
"value": "Any key.",
"source": "default"
},
"visuals": {
"value": "Text only.",
"source": "default"
},
"sound": {
"value": "None.",
"source": "n/a"
},
"persistence": {
"value": "None.",
"source": "n/a"
},
"fileFormats": {
"value": "None.",
"source": "n/a"
},
"peripherals": {
"value": "None.",
"source": "n/a"
},
"budgets": {
"value": "No constraints beyond fitting in memory.",
"source": "default"
}
},
"capabilities": [
"text-ui",
"keyboard-input"
],
"assumptions": [
{
"id": "A1",
"text": "VICE defaults are representative.",
"status": "default"
}
],
"openDecisions": [],
"toolchain": {
"recipe": "asm-onboard",
"language": "asm-onboard",
"recommended": {
"recipe": "asm-onboard",
"language": "asm-onboard"
},
"reasons": [
"The user wants to write assembly on the machine with their own native assembler."
],
"alternatives": [
{
"option": "Assembly",
"whyNot": "More effort than this needs."
}
],
"override": null,
"assumptionsToVerify": []
},
"starter": {
"screenTitle": "BORDER FLASH",
"expectedScreen": "'BORDER FLASH' on row 0 and 'STARTER OK' on row 2.",
"requirements": [
"R1"
]
},
"milestones": [
{
"id": "M1",
"title": "Key handling",
"goal": "Return to BASIC on a key press.",
"tasks": [
{
"id": "M1.1",
"text": "Return to BASIC on any key.",
"requirements": [
"R2"
],
"outcome": "PRG that exits on a key",
"check": "MT1.1"
}
],
"manualTests": [
{
"id": "MT1.1",
"title": "Exit",
"target": "all",
"setup": "Program running.",
"steps": [
"Press SPACE."
],
"expected": [
"READY prompt appears."
],
"requirements": [
"R2"
]
}
]
}
]
}

+ 1005
- 0
tools/Foundry.psm1
文件差異過大導致無法顯示
查看文件


+ 40
- 0
tools/New-FoundryDraft.ps1 查看文件

@@ -0,0 +1,40 @@
<#
.SYNOPSIS
Start a new interview draft from the user's idea, or show where an existing draft stands.

.DESCRIPTION
Creates drafts/<slug>.json from templates/brief/draft.json with the project name, slug and
idea filled in and status "draft". The coding agent fills in the rest during the interview
and saves the file after each round of answers. To resume later, run
Test-FoundryBrief.ps1 on the draft: it prints the stage and questions to continue with.

.EXAMPLE
pwsh -File tools/New-FoundryDraft.ps1 -Name "Moon Miner" -Idea "A small mining game..."
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$Name,
[Parameter(Mandatory)][string]$Idea,
[string]$Slug,
[switch]$Force
)
Import-Module (Join-Path $PSScriptRoot 'Foundry.psm1') -Force
$root = Get-FoundryRoot
if (-not $Slug) { $Slug = (($Name.ToLowerInvariant() -replace '[^a-z0-9]+', '-').Trim('-')) }
if ($Slug.Length -lt 3) { $Slug = "project-$Slug".Trim('-') }
$path = Join-Path $root "drafts/$Slug.json"
if ((Test-Path -LiteralPath $path) -and -not $Force) {
Write-Host "Draft already exists: $path" -ForegroundColor Yellow
Write-Host "Resume it with: pwsh -File tools/Test-FoundryBrief.ps1 `"$path`""
exit 1
}
$draft = Read-FoundryJson (Join-Path $root 'templates/brief/draft.json')
$draft.project.name = $Name
$draft.project.slug = $Slug
$draft.project.idea = $Idea
$draft.interview.startedOn = (Get-Date -Format 'yyyy-MM-dd')
New-Item -ItemType Directory -Force -Path (Split-Path $path) | Out-Null
[IO.File]::WriteAllText($path, ($draft | ConvertTo-Json -Depth 32), [Text.UTF8Encoding]::new($false))
Write-Host "Draft created: $path"
& (Join-Path $PSScriptRoot 'Test-FoundryBrief.ps1') $path -Mode Draft
exit 0

+ 57
- 0
tools/New-FoundryProject.ps1 查看文件

@@ -0,0 +1,57 @@
<#
.SYNOPSIS
Generate a self-contained C64/C128 project repository from an approved brief.

.DESCRIPTION
1. Validates the brief (status must be "approved", no missing fields, no conflicts).
2. Validates the destination. An existing non-empty folder or Git repository is never
touched; an empty folder is allowed.
3. Builds the repository in a temporary sibling folder (".<name>.foundry-staging-*"):
templates, starter source, project-specific files (starter.filesDir), project.json.
4. Fails if any {{PLACEHOLDER}} is left unresolved.
5. Runs git init on branch main and commits if a Git identity is configured; otherwise
the files are staged and ready to commit.
6. Moves the folder to the destination in one rename. If anything fails before this, the
staging folder is removed and the destination is left as it was. Leftovers from an
interrupted earlier attempt are removed on the next run.
7. Runs the generated repo's tools/smoke.ps1 (unless -SkipVerify) and reports the result.

Exit codes: 0 = generated (see verification status), 1 = nothing generated.

.EXAMPLE
pwsh -File tools/New-FoundryProject.ps1 examples/traffic-control-64/brief.json
pwsh -File tools/New-FoundryProject.ps1 drafts/my-game.json -Destination "D:\Retro Projects\my-game"
#>
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)][string]$BriefPath,
[string]$Destination,
[switch]$SkipVerify,
[switch]$Json,
[string]$FailAfterStep
)
Import-Module (Join-Path $PSScriptRoot 'Foundry.psm1') -Force
try {
$r = New-FoundryProject -BriefPath $BriefPath -Destination $Destination -SkipVerify:$SkipVerify -FailAfterStep $FailAfterStep
} catch {
Write-Host "NOT GENERATED: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
if ($Json) { $r | ConvertTo-Json -Depth 6; exit 0 }

Write-Host ""
Write-Host "Project generated" -ForegroundColor Green
Write-Host " Path : $($r.Destination)"
Write-Host " Git : branch main, $(if ($r.Committed) { 'initial commit created' } else { 'files staged; no Git identity configured. Set one (git config --global user.name / user.email), then run: git commit -m "Initial handoff"' })"
foreach ($t in $r.Targets) { Write-Host " Target : $($t.Id) -> $($t.Artifact) (starter configuration: $($t.Status))" }
foreach ($w in $r.Warnings) { Write-Host " Warning : $w" -ForegroundColor Yellow }
if ($r.StaleRemoved.Count) { Write-Host " Cleaned : removed $($r.StaleRemoved.Count) leftover staging folder(s) from an interrupted run" }
Write-Host " Starter verification: $($r.Verification.status)"
if ($r.Verification.output) {
$r.Verification.output | Where-Object { $_ -match '^\s*(\[|MISSING| First| Unverified|ok |FAIL)|^\s+(ok|FAIL)\s' } | ForEach-Object { Write-Host " $_" }
}
Write-Host ""
Write-Host "Next: open a fresh coding-agent session in the folder above and send:"
Write-Host ""
Write-Host " $($r.HandoffMessage)"
exit 0

+ 22
- 0
tools/Show-FoundrySpec.ps1 查看文件

@@ -0,0 +1,22 @@
<#
.SYNOPSIS
Print the proposed spec (Markdown) for the user to approve before generation.

.DESCRIPTION
Interview step 4. Works on a draft once every stage except "review" is complete. Shows
scope, assumptions, target and toolchain, the first milestone, acceptance checks and the
destination folder (and whether it is free). Exit 1 if the brief is not complete enough.

.EXAMPLE
pwsh -File tools/Show-FoundrySpec.ps1 drafts/my-game.json
#>
[CmdletBinding()]
param([Parameter(Mandatory, Position = 0)][string]$Path)
Import-Module (Join-Path $PSScriptRoot 'Foundry.psm1') -Force
try {
$full = (Resolve-Path -LiteralPath $Path).ProviderPath
Format-FoundrySpecPreview -Brief (Read-FoundryJson $full) -BriefPath $full
} catch {
Write-Host $_.Exception.Message -ForegroundColor Yellow
exit 1
}

+ 43
- 0
tools/Test-FoundryBrief.ps1 查看文件

@@ -0,0 +1,43 @@
<#
.SYNOPSIS
Validate a project brief (draft or approved) and say where to resume the interview.

.DESCRIPTION
-Mode Draft (default for briefs whose status is "draft"): lists what is still missing,
grouped by interview stage, plus any errors or conflicts, and prints the stage and questions
to resume with.
-Mode Approved: everything must be complete, approved and free of conflicts; this is the
same check the generator runs before writing anything.

Exit codes: 0 = valid for the chosen mode, 1 = not valid, 4 = conflicts present
(constraints the user must choose between).

.EXAMPLE
pwsh -File tools/Test-FoundryBrief.ps1 drafts/my-game.json
pwsh -File tools/Test-FoundryBrief.ps1 examples/traffic-control-64/brief.json -Mode Approved
#>
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)][string]$Path,
[ValidateSet('Draft', 'Approved', 'Auto')][string]$Mode = 'Auto',
[switch]$Json
)
Import-Module (Join-Path $PSScriptRoot 'Foundry.psm1') -Force
try {
$full = (Resolve-Path -LiteralPath $Path).ProviderPath
$brief = Read-FoundryJson $full
} catch {
Write-Host "ERROR: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
$schema = Join-Path $PSScriptRoot '../schema/project-brief.schema.json'
$schemaOk = Test-Json -Path $full -SchemaFile $schema -ErrorAction SilentlyContinue
if (-not $schemaOk) {
Write-Host "SCHEMA: $Path does not match schema/project-brief.schema.json (wrong type or an unknown enum value). Details from the rule checks follow." -ForegroundColor Red
}
if ($Mode -eq 'Auto') { $Mode = if ($brief.status -eq 'approved') { 'Approved' } else { 'Draft' } }
$result = Test-FoundryBrief -Brief $brief -Mode $Mode -BriefPath $full
if ($Json) { $result | ConvertTo-Json -Depth 6 } else { Format-FoundryValidation $result | Write-Host }
if ($result.Conflicts.Count) { exit 4 }
if (-not $result.Valid -or -not $schemaOk) { exit 1 }
exit 0

Loading…
取消
儲存

Powered by TurnKey Linux.