# 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`). ## Knowledge Engine (persistent memory) Optional but required by the agent rules: a PostgreSQL + pgvector database shared by the Foundry and every generated project, reached through the `Foundry.Knowledge` PowerShell module. Agents recall earlier facts, decisions and errors before a task and record verified discoveries after it. Needs Docker and an Ollama with `nomic-embed-text`. Setup, design, tuning and what was verified: [docs/knowledge-engine.md](docs/knowledge-engine.md). ```powershell pwsh -File scripts/Initialize-Foundry.ps1 # first time: .env, container, schema, health check pwsh -File tests/Knowledge.Tests.ps1 # 17 checks in a scratch database ``` ## Start an interview Open your coding agent in this folder and send: > Read AGENTS.md and run the Foundry interview. My idea: *<describe your C64 or C128 program in a sentence or a page>* 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/<slug>.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\) 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) | | `docker-compose.yml`, `infrastructure/`, `scripts/` | Knowledge Engine infrastructure: PostgreSQL + pgvector, migrations, start/stop/backup scripts | | `powershell/Foundry.Knowledge/` | The agent-facing knowledge module | | `skills/knowledge-management/` | Skill telling agents when and how to retrieve and store knowledge (copied into generated projects) |