c64bridge 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +17 -5
  2. package/data/assembly/assembly-spec.md +24 -0
  3. package/data/assembly/examples/video/hello_world.asm +39 -0
  4. package/data/basic/basic-pitfalls.md +236 -0
  5. package/data/basic/basic-spec.md +507 -198
  6. package/data/video/petscii-style-guide.md +105 -0
  7. package/data/video/sprite-charset-best-practices.md +292 -0
  8. package/dist/c64Client.js +1 -0
  9. package/dist/prompts/registry.js +10 -2
  10. package/dist/rag/knowledgeIndex.js +111 -24
  11. package/dist/rag/retriever.js +110 -4
  12. package/dist/tools/audio.js +26 -13
  13. package/dist/tools/developer.js +34 -0
  14. package/dist/tools/graphics.js +6 -5
  15. package/dist/tools/memory.js +1 -1
  16. package/dist/tools/pollValidator.js +256 -0
  17. package/dist/tools/programRunners.js +352 -12
  18. package/dist/tools/rag.js +1 -7
  19. package/doc/MCP_SETUP.md +7 -1
  20. package/doc/bun/baseline-metrics.md +16 -0
  21. package/doc/bun/migration-checklist.md +55 -0
  22. package/doc/bun/migration.md +83 -0
  23. package/doc/developer.md +72 -10
  24. package/doc/improve-knowledge/notes.md +29 -0
  25. package/doc/improve-knowledge/plan.md +28 -3
  26. package/doc/improve-knowledge/rollout.md +39 -5
  27. package/doc/meta-tools/README.md +101 -0
  28. package/doc/meta-tools/analysis.md +255 -0
  29. package/doc/{meta-tools.md → meta-tools/catalog.md} +2 -2
  30. package/doc/meta-tools/notes.md +174 -0
  31. package/doc/meta-tools/rollout.md +343 -0
  32. package/mcp.json +1 -1
  33. package/package.json +17 -10
  34. package/scripts/c64-cli.mjs +42 -7
  35. package/scripts/c64-tool.sh +7 -1
  36. package/scripts/check-node-compat.mjs +107 -0
  37. package/scripts/invoke-bun.mjs +58 -0
  38. package/scripts/rag-rebuild.mjs +11 -13
  39. package/scripts/run-mcp-check.sh +10 -2
  40. package/scripts/run-tests.mjs +3 -3
  41. package/scripts/run-tests.ts +187 -0
  42. package/scripts/start.mjs +3 -26
  43. package/scripts/update-readme.ts +17 -1
  44. package/scripts/verify-package.mjs +0 -1
  45. package/data/assembly/examples/effects/sinewave.asm +0 -5
  46. package/doc/meta-tools-rollout.md +0 -211
  47. package/scripts/register-ts-node.mjs +0 -6
  48. /package/data/assembly/examples/{graphics/sprite/mover.asm → video/sprite_mover.asm} +0 -0
package/doc/developer.md CHANGED
@@ -33,14 +33,42 @@ Key documentation:
33
33
 
34
34
  ## Prerequisites
35
35
 
36
- - Node.js 18+ (20+ recommended); ESM TypeScript via `ts-node`.
37
- - npm for dependency management.
38
- - Optional: Ultimate 64 hardware (or compatible REST device) for real tests.
36
+ - Node.js 18+ (20+ recommended) or Bun 1.1+
37
+ - npm (for user installation) or Bun (for development)
38
+ - Optional: Ultimate 64 hardware (or compatible REST device) for real tests
39
+
40
+ ## Development Tooling
41
+
42
+ This project uses **Bun** for building and testing during development due to its significantly higher performance compared to npm/node. However, the published npm package remains **fully compatible with both Bun and npm/node**, ensuring that end users can install and run it using standard Node.js tooling.
43
+
44
+ For **release preparation**, npm/node is used to ensure everything works correctly on the target platform, as Node.js remains our primary deployment target.
45
+
46
+ ### Bun vs npm Command Reference
47
+
48
+ Common development commands are available for both toolchains:
49
+
50
+ | Task | Bun Command | npm Command |
51
+ |------|-------------|-------------|
52
+ | Install dependencies | `bun install` | `npm install` |
53
+ | Build project | `bun run build` | `npm run build` |
54
+ | Run tests | `bun test` or `npm test` | `npm test` |
55
+ | Run with coverage | `bun test --coverage` or `npm run coverage` | `npm run coverage` |
56
+ | Start MCP server | `npm start` | `npm start` |
57
+ | Run single script | `bun scripts/script-name.ts` | `node scripts/invoke-bun.mjs scripts/script-name.ts` |
58
+
59
+ **Notes:**
60
+ - Bun can execute TypeScript files directly without transpilation
61
+ - npm scripts internally use Bun where configured via `scripts/invoke-bun.mjs` wrapper
62
+ - Both toolchains produce identical `dist/` output for packaging
39
63
 
40
64
  ## Setup
41
65
 
42
66
  ```bash
67
+ # For end users (npm)
43
68
  npm install
69
+
70
+ # For contributors (Bun - faster)
71
+ bun install
44
72
  ```
45
73
 
46
74
  Configuration resolution (first match wins):
@@ -51,7 +79,39 @@ Configuration resolution (first match wins):
51
79
 
52
80
  `loadConfig()` normalises IPv6 literals, coerces legacy keys (`c64_host`, `c64_ip`), and caches the resolved structure for subsequent calls.
53
81
 
54
- ## Useful npm Scripts
82
+ ## Container (Docker)
83
+
84
+ For reproducible deployments, you can build and run C64 Bridge in a container:
85
+
86
+ 1. Build the container image
87
+
88
+ ```bash
89
+ docker build -t c64bridge:dev .
90
+ ```
91
+
92
+ 2. Run the container
93
+
94
+ ```bash
95
+ docker run --rm \
96
+ -e C64_HOST=192.168.1.64 \
97
+ -e C64_PORT=80 \
98
+ c64bridge:dev
99
+ ```
100
+
101
+ The container uses `ubuntu:24.04` as the base image with Node.js 20 (installed via `n` version manager) and Bun, runs as a non-root user (`c64bridge`), and starts the MCP server with `npm start`. Configure the C64 connection through environment variables (`C64_HOST`, `C64_PORT`, `C64_BACKEND`) as needed.
102
+
103
+ For development or testing, you can mount a volume to access logs or temporary files:
104
+
105
+ ```bash
106
+ docker run --rm \
107
+ -e C64_HOST=192.168.1.64 \
108
+ -v /tmp/c64bridge:/tmp \
109
+ c64bridge:dev
110
+ ```
111
+
112
+ ## npm Scripts Reference
113
+
114
+ All commands below work with both `npm run <script>` and `bun run <script>`. For consistency with user documentation, npm syntax is shown.
55
115
 
56
116
  **Core server flows**
57
117
 
@@ -63,7 +123,7 @@ Configuration resolution (first match wins):
63
123
  **Quality gates**
64
124
 
65
125
  - `npm test` drives `scripts/run-tests.mjs` against the mock C64 server; pass `-- --real [--base-url=http://host]` to exercise actual hardware.
66
- - `npm run check` executes `npm run build` followed by the mock test suite; `npm run coverage` wraps the same runner with c8.
126
+ - `npm run check` executes `npm run build` followed by the mock test suite; `npm run coverage` now invokes the Bun runner with `--coverage`, producing `coverage/lcov.info` for Codecov.
67
127
  - `npm run check:package` validates packaging metadata, while `npm run check:run-local` / `npm run check:run-npm` execute `scripts/run-mcp-check.sh` against local and packaged installs.
68
128
 
69
129
  **RAG workflows**
@@ -76,7 +136,7 @@ Configuration resolution (first match wins):
76
136
  - `npm run c64:tool` opens the interactive helper for PRG conversion and upload; `npm run api:generate` refreshes the generated REST client.
77
137
  - `npm run changelog:generate` distills Conventional Commit history, and `npm run release:prepare -- <semver>` orchestrates version bumps plus manifest regeneration.
78
138
 
79
- Invoke `node --import ./scripts/register-ts-node.mjs scripts/update-readme.ts` directly when you need to refresh documentation tables without a full rebuild.
139
+ Invoke `bun scripts/update-readme.ts` directly when you need to refresh documentation tables without a full rebuild.
80
140
 
81
141
  The test driver in `scripts/run-tests.mjs` accepts additional flags: `--mock` (default) to use `test/mockC64Server.mjs`, `--real` to target hardware (`C64_TEST_TARGET=real`), and `--base-url` to override the REST endpoint during real runs.
82
142
 
@@ -141,7 +201,7 @@ flowchart LR
141
201
  ## Testing Notes
142
202
 
143
203
  - Node’s built-in test runner (`node --test`) is wrapped by `scripts/run-tests.mjs`.
144
- - Use `npm run coverage` (c8) to capture coverage without double-running tests.
204
+ - Use `npm run coverage` (Bun runner) to capture coverage without double-running tests. The command emits `coverage/lcov.info`, which CI uploads to Codecov.
145
205
  - `test/basicConverter.test.mjs`: byte-level PRG output validation.
146
206
  - `test/c64Client.test.mjs`: REST client and mock-server integration; `--real` toggles hardware.
147
207
  - `test/suites/mcpServer*.mjs`: End-to-end MCP surface coverage (tools, resources, prompts).
@@ -155,6 +215,8 @@ flowchart LR
155
215
 
156
216
  ## Release Workflow
157
217
 
218
+ Releases are prepared using **npm/node** to ensure the published package works correctly on the target platform (Node.js 18+), even though development uses Bun for speed.
219
+
158
220
  1. Create a short-lived branch (for example `release/X.Y.Z`) from the target commit.
159
221
  2. Run `npm run release:prepare -- <semver>` to bump versions (`major`, `minor`, `patch`, or explicit like `0.2.0`). This updates `package.json`, `package-lock.json`, `mcp.json`, and prepends a new section to `CHANGELOG.md` from commit messages since the last tag.
160
222
  3. Review and commit the changes, then open a pull request.
@@ -303,9 +365,9 @@ For advanced options (depth semantics, throttling/limits, adaptive rate limiting
303
365
  - Advanced users can call the underlying CLI directly:
304
366
 
305
367
  ```bash
306
- node --import ./scripts/register-ts-node.mjs scripts/c64-cli.mjs convert-basic --input path/to/program.bas
307
- node --import ./scripts/register-ts-node.mjs scripts/c64-cli.mjs run-basic --input path/to/program.bas
308
- node --import ./scripts/register-ts-node.mjs scripts/c64-cli.mjs run-prg --input artifacts/program.prg
368
+ bun scripts/c64-cli.mjs convert-basic --input path/to/program.bas
369
+ bun scripts/c64-cli.mjs run-basic --input path/to/program.bas
370
+ bun scripts/c64-cli.mjs run-prg --input artifacts/program.prg
309
371
  ```
310
372
 
311
373
  Generated binaries are written to the `artifacts/` directory by default (ignored by git) so you can transfer them to real hardware or flash media. Make sure your `~/.c64bridge.json` (or `C64BRIDGE_CONFIG`) points at your c64 device before using the run options.
@@ -12,3 +12,32 @@
12
12
  - **Memory/IO resource exposure (K1)**: Memory maps and IO reference docs under `data/memory` and `data/io` must be published as MCP resources with appropriate metadata for retrieval and grounding.
13
13
  - **SID best-practices resource (K2)**: `data/audio/sid-programming-best-practices.md` must be surfaced as a first-class MCP resource to guide audio tools and prompts.
14
14
  - **Validation gates**: Each improvement requires incremental changes with companion tests or documentation updates, followed by a successful `npm run check` prior to marking tasks complete.
15
+
16
+ ## Additional Acceptance Criteria (New Tasks)
17
+
18
+ - **License info in RAG (S2)**: Structured RAG outputs expose `spdxId` only (replaces license name/URL), along with `uri`, `origin`, `snippet`, and `score`.
19
+ - **What changed summary (D1)**: README or resource index contains a concise, auto-updated summary of tool/resource changes with a link to platform status.
20
+ - **Prompt cross-links (D2)**: Prompts referencing SID/graphics/PETSCII include `relatedResources` pointing to best-practices and quickrefs.
21
+ - **BASIC pitfalls resource (K3)**: A brief, actionable quickref exists and is listed in the knowledge index; BASIC runners reference it.
22
+ - **PETSCII/charset quickrefs (K4)**: PETSCII char codes and glyph mapping are published as resources; retrieval returns URIs to them.
23
+ - **VIC-II quickref (K5)**: Register quickref is exposed as a resource and linked from graphics tools.
24
+ - **Sprite & Charset workflows doc (K6)**: New doc published and exposed; graphics tools and prompts link to it.
25
+ - **RAG URIs (R2)**: RAG results consistently include `c64://` resource URIs where applicable; `ReadResource` can open them.
26
+ - **Retrieval diversity (R3)**: Top-K results have basic de-duplication and domain diversity; tests cover presence of varied domains.
27
+ - **PETSCII presets docs (G5)**: Documented style presets exist; prompts mention how to select them.
28
+ - **Hires bitmap PRG generator (G6)**: A tool exists to render a static bitmap; a minimal example and test verify it runs and captures a screen.
29
+ - **Graphics tests (T4/T5)**: PETSCII generation and sprite preview PRG flows have e2e tests asserting key structured fields and behavior.
30
+ - **Container workflow (S1)**: ✅ Dockerfile updated to use `ubuntu:24.04` with Node.js 20 (via `n` version manager) and Bun, create a non-root `c64bridge` user at `/app`, run `npm ci` during build, copy the repo, and set `CMD ["npm","start"]`; doc/developer.md documents `docker build` / `docker run` usage and verification steps.
31
+
32
+ ## Container Build/Run Examples
33
+
34
+ ```bash
35
+ # Build the container
36
+ docker build -t c64bridge:dev .
37
+
38
+ # Run with environment configuration
39
+ docker run --rm \
40
+ -e C64_HOST=192.168.1.64 \
41
+ -e C64_PORT=80 \
42
+ c64bridge:dev
43
+ ```
@@ -33,6 +33,9 @@ The server exposes a rich, well-typed MCP surface with clear schemas, strong log
33
33
  | K1 | Add memory/IO maps and low-memory docs as MCP resources (critical grounding for ASM/memory tools). | Missing under `src/rag/knowledgeIndex.ts:55-299`; candidate docs: `data/memory/*.md`, `data/io/*.md` | S | 5 | Larger resource list; very high grounding value for LLMs. |
34
34
  | K2 | Expose SID best-practices as a resource (used by creative flows). | Not in knowledge index; exists at `data/audio/sid-programming-best-practices.md` | S | 5 | Aligns generation defaults with proven musical outcomes. |
35
35
  | K3 | Add a short “BASIC pitfalls” quickref (quoting, line length, tokenization) and link from runners. | Tokenizer: `src/basicConverter.ts`; hints exist but not resource-linked | M | 4 | Minor doc work; reduces BASIC generation errors. |
36
+ | K4 | Publish PETSCII/charset quickrefs as MCP resources; generate a Markdown table from the existing `data/video/character-set.csv` (retain CSV for programmatic access). Prefer dynamic generation to avoid duplicate sources of truth. | `data/video/character-set.csv`, `src/petscii.ts`, `src/petsciiArt.ts` | S | 5 | Improves PETSCII/charset fluency while avoiding duplication. |
37
+ | K5 | Publish VIC-II register quickref and addressing guide as MCP resource. | `data/video/vic-spec.md` | S | 5 | Essential grounding for sprites, colours, raster, screen control. |
38
+ | K6 | Add “Sprite & Charset workflows best-practices” doc and expose as resource. | New doc under `data/video/` referencing `src/tools/graphics.ts` capabilities | M | 4 | Guides consistent, high-quality sprite/charset pipelines for LLMs. |
36
39
 
37
40
  #### RAG & Retrieval
38
41
 
@@ -41,6 +44,7 @@ The server exposes a rich, well-typed MCP surface with clear schemas, strong log
41
44
  | R1 | Return structured refs from RAG: `[uri|origin, snippet, score]` instead of only text. Parse `<!-- Source: ... -->` and include score. | Text returned: `src/tools/rag.ts:82-128`; retriever: `src/rag/retriever.ts:37-80`; provenance comment injected: `src/rag/indexer.ts:769-772` | M | 5 | Requires minor client-side changes reading structured refs. |
42
45
  | R2 | Include bundle/resource URIs (e.g., `c64://specs/*`) in RAG results when matches originate from docs; enable quick “open resource.” | `src/rag/knowledgeIndex.ts:328-359` (index resource), doc chunking: `720-767` | S | 4 | Slight mapping logic; greatly improves provenance and navigation. |
43
46
  | R3 | Add diversity heuristic (basic+asm mixed fallback already exists) and simple duplicate suppression in top-K. | `src/rag/retriever.ts:70-76,78-80` | S | 3 | Keeps refs varied; minimal complexity. |
47
+ | R4 | Add domain weighting to retrieval (boost SID/graphics docs when relevant). | `src/rag/retriever.ts` scoring path; tool domain is known at call sites | M | 4 | More relevant grounding for PETSCII/sprites/SID prompts. |
44
48
 
45
49
  #### Generators & Creative Pipelines (BASIC/ASM/Graphics/SID)
46
50
 
@@ -50,6 +54,8 @@ The server exposes a rich, well-typed MCP surface with clear schemas, strong log
50
54
  | G2 | When `sid_note_on` is used without `system`, auto-detect or remind to check `$02A6` (PAL/NTSC) and reflect in response metadata. | Client freq calc + defaults: `src/c64Client.ts:371-407,773-778`; PAL/NTSC doc: `src/knowledge.ts:373-421` | S | 4 | Small change; better tuning accuracy. |
51
55
  | G3 | Include generated PRG metadata (addresses, bytes written) in program runners’ structured output to aid follow-up memory ops. | Runners return text only: `src/tools/programRunners.ts:129-140,176-180,231-236,276-281,320-324` | M | 4 | Minor tool API enhancement; improves post-run determinism. |
52
56
  | G4 | For PETSCII, surface chosen glyph/codes and a miniature preview in structured output (already present; ensure docs highlight usage). | Already included: `src/tools/graphics.ts:489-515` | S | 3 | Doc-only; improves downstream use. |
57
+ | G5 | Document PETSCII style presets (contrast, dithering, palette) and link from prompts. | `src/tools/graphics.ts` PETSCII args; `src/prompts/registry.ts` | S | 4 | Helps LLM pick good defaults for readable, artistic output. |
58
+ | G6 | Add hires bitmap PRG generator tool (render static bitmap with colour RAM). | New tool in `src/tools/graphics.ts`; preview via screen capture | M | 4 | Enables high-quality hires demonstrations and asset previews. |
53
59
 
54
60
  #### Validation, Testing & CI
55
61
 
@@ -58,6 +64,8 @@ The server exposes a rich, well-typed MCP surface with clear schemas, strong log
58
64
  | T1 | Add tests asserting `music_generate` new defaults (tri/ADSR) and pitch accuracy by PAL/NTSC. | Audio analysis tests exist: `test/audioAnalysis.test.mjs:56-141`; `hzToSidFrequency`: `src/c64Client.ts:773-778` | S | 4 | Keeps musical defaults from regressing. |
59
65
  | T2 | Add a small e2e test for `rag_retrieve_*` verifying structured refs and that URIs open via `ReadResource`. | `src/tools/rag.ts:82-128`, `src/mcp-server.ts:133-176` | M | 4 | Increases confidence in RAG interoperability. |
60
66
  | T3 | Quick test to ensure `read_screen` works without prior `upload_and_run_basic`. | `src/tools/memory.ts:81-99` | S | 3 | Guards against accidental pre-req regressions. |
67
+ | T4 | Add e2e test for PETSCII generation: verify preview fields and PRG runs. | `src/tools/graphics.ts`, `test/graphicsModule.test.mjs` | S | 4 | Prevents regressions in graphics outputs crucial for PETSCII art. |
68
+ | T5 | Add sprite preview PRG test: bytes copied, coords/colour applied, screen captured. | `src/tools/graphics.ts`, `test/graphicsModule.test.mjs` | S | 4 | Ensures sprite workflows stay reliable for asset iteration. |
61
69
 
62
70
  #### Developer Experience & Documentation
63
71
 
@@ -65,13 +73,14 @@ The server exposes a rich, well-typed MCP surface with clear schemas, strong log
65
73
  |----|----------------|-----------------------------|---------|-----------|------------------|
66
74
  | D1 | Add a “What changed” MCP summary to README or resource index after build (already partially auto-generated) and link platform status resource. | Auto-generated API in `README.md:346-589`; platform resource in `src/mcp-server.ts:371-432` | S | 3 | Keeps LLM and humans in sync with tool/resource changes. |
67
75
  | D2 | Cross-link prompts to resources (e.g., SID prompts to best-practices) for richer in-editor help. | Prompt registry references tools/resources: `src/prompts/registry.ts:369-547` | S | 3 | Small doc metadata lift; improves LLM contextual grounding. |
76
+ | D3 | Add PETSCII/sprite/hires quickstarts and example-driven guides; link from prompts. | New docs under `data/video/`, `src/prompts/registry.ts` | M | 4 | Streamlines creative workflows aligned to the core mission. |
68
77
 
69
78
  #### Security/Licensing & Reproducibility
70
79
 
71
80
  | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
72
81
  |----|----------------|-----------------------------|---------|-----------|------------------|
73
- | S1 | Provide a runnable, reproducible container (Node 20 LTS, non-root user, `npm ci`, `npm start`), not just apt base. | Current Dockerfile doesn’t copy/build/run: `Dockerfile:1-12` | M | 3 | Larger image and CI time; greatly simplifies reproducibility. |
74
- | S2 | Preserve and surface external source license info in RAG outputs (already recorded in index), include SPDX in structured refs. | License metadata recorded: `src/rag/indexer.ts:592-699` | S | 3 | Clarifies usage constraints; minimal change. |
82
+ | S1 | Provide a reproducible container workflow anchored on Node 20 LTS (bookworm-slim), create a non-root runtime user, run `npm ci` during build, and set `npm start` as the default command; document how to build/run it. | Current Dockerfile doesn’t copy/build/run: `Dockerfile:1-12` | M | 3 | Larger image and CI time; greatly simplifies reproducibility. |
83
+ | S2 | Replace license name and URL with SPDX identifier in structured RAG refs (map when possible; omit if unknown). | License metadata recorded: `src/rag/indexer.ts:592-699` | S | 3 | Normalizes licensing with a single standard field. |
75
84
 
76
85
  \* Effort: S (small), M (medium), L (large)
77
86
  \** Benefit: 1–5 (5 = highest impact)
@@ -87,7 +96,23 @@ The server exposes a rich, well-typed MCP surface with clear schemas, strong log
87
96
  | 5 | M2 | Standardize structured JSON outputs for runners | M | 4 | Improves determinism and follow-up automation. |
88
97
  | 6 | T1 | Tests for PAL/NTSC and new music defaults | S | 4 | Locks in audible quality and tuning accuracy. |
89
98
  | 7 | M1 | Remove `read_screen` pre-req coupling | S | 3 | Avoids confusing plans; reduces unnecessary steps. |
90
- | 8 | S1 | Ship a runnable container | M | 3 | Eases local/CI reproducibility and onboarding. |
99
+ | 8 | S1 | Ship a runnable container with the exact steps above (Dockerfile, README section, and reference in rollout notes). | M | 3 | Eases local/CI reproducibility and onboarding. |
100
+
101
+ ### 3b) Additional Prioritized Improvements (Next Phases)
102
+
103
+ | Rank | ID | Title | Effort | Benefit | One-line Justification |
104
+ |------|----|-------|--------|---------|------------------------|
105
+ | 9 | K4 | PETSCII/charset quickrefs (Markdown from CSV; keep CSV) | S | 5 | Avoids duplication; improves PETSCII/charset fluency. |
106
+ | 10 | K5 | VIC-II register quickref resource | S | 5 | Core for graphics, sprites, raster, and colours. |
107
+ | 11 | R2 | Resource URIs in RAG refs | S | 4 | Faster navigation from retrieval to action. |
108
+ | 12 | R3 | Retrieval diversity + de-dup | S | 3 | Improves variety and reduces redundancy. |
109
+ | 13 | G5 | PETSCII style presets docs | S | 4 | Better default art quality and readability. |
110
+ | 14 | T4 | PETSCII e2e generation test | S | 4 | Prevents regressions in critical graphics flow. |
111
+ | 15 | G2 | PAL/NTSC reminder in SID note-on | S | 4 | Reduces tuning errors automatically. |
112
+ | 16 | K6 | Sprite/charset workflows guide | M | 4 | Teaches robust workflows for assets. |
113
+ | 17 | G6 | Hires bitmap PRG generator | M | 4 | Enables hires demos and previews. |
114
+ | 18 | D3 | Creative quickstarts and guides | M | 4 | Guides LLMs and users to success paths. |
115
+ | 19 | S2 | SPDX id in RAG refs (replace name/URL) | S | 3 | Single normalized field; reduces duplication. |
91
116
 
92
117
  ### 4) Top Three Priorities
93
118
 
@@ -43,17 +43,51 @@ For every checklist item below, execute the following sub-steps in order (these
43
43
 
44
44
  ## Phase 2 — Creative Defaults & Validation
45
45
 
46
- - [ ] G1: Update `music_generate` defaults to triangle waveform with recommended ADSR profile; document the new “musical expression” preset (`src/tools/audio.ts`, `src/c64Client.ts`, best-practices doc). Preserve options to request legacy pulse behavior.
47
- - [ ] T1: Add automated tests verifying the new SID defaults (PAL/NTSC pitch accuracy and ADSR adherence) (`test/audioAnalysis.test.mjs` or adjacent suites).
46
+ - [x] G1: Update `music_generate` defaults to triangle waveform with recommended ADSR profile; document the new “musical expression” preset (`src/tools/audio.ts`, `src/c64Client.ts`, best-practices doc). Preserve options to request legacy pulse behavior.
47
+ - [x] T1: Add automated tests verifying the new SID defaults (PAL/NTSC pitch accuracy and ADSR adherence) (`test/audioAnalysis.test.mjs` or adjacent suites).
48
48
 
49
49
  ## Phase 3 — MCP Surface Improvements
50
50
 
51
- - [ ] M2: Standardize structured JSON outputs for all program runners, including entry addresses, artifacts, and URIs while retaining human-readable summaries (`src/tools/programRunners.ts`, `src/tools/types.ts`).
52
- - [ ] M1: Remove the artificial dependency between `upload_and_run_basic` and `read_screen`, ensuring documentation reflects independent usage (`src/tools/memory.ts`, related docs or schemas).
51
+ - [x] M2: Standardize structured JSON outputs for all program runners, including entry addresses, artifacts, and URIs while retaining human-readable summaries (`src/tools/programRunners.ts`, `src/tools/types.ts`).
52
+ - [x] M1: Remove the artificial dependency between `upload_and_run_basic` and `read_screen`, ensuring documentation reflects independent usage (`src/tools/memory.ts`, related docs or schemas).
53
53
 
54
54
  ## Phase 4 — Reproducibility & Packaging
55
55
 
56
- - [ ] S1: Produce a runnable, reproducible container path (Node 20 LTS, non-root user, `npm ci`, `npm start`) updating `Dockerfile` and associated docs.
56
+ > Implementation guardrails for S1
57
+ > • Base image must be `node:20-bookworm-slim` (or newer 20.x digest) to keep parity with local tooling.
58
+ > • Create a dedicated non-root user (e.g., `bridge`) with home `/app` and run the container as that user.
59
+ > • Copy `package.json`, `package-lock.json`, and `npm ci` during build before adding the rest of the repo to leverage caching.
60
+ > • Switch `WORKDIR` to `/app`, copy the code, and set `CMD ["npm","start"]`.
61
+ > • Ensure the container runs `npm start` without extra flags, reading configuration from env vars.
62
+ > • Update `README.md` (Containers section) and `doc/improve-knowledge/notes.md` with build/run examples (`docker build` / `docker run`).
63
+ > • Validate locally via `docker build` + `docker run --rm c64bridge:dev` before checking the box.
64
+
65
+ - [x] S1: Produce the reproducible container workflow described above, updating `Dockerfile`, README, and notes so future operators can rebuild and run the MCP server in that container.
66
+ - [x] S2: Replace license name and URL with SPDX identifier in structured RAG refs (ensure `origin`, `uri`, `spdxId` fields are present; map when possible) (`src/rag/indexer.ts`, `src/rag/retriever.ts`, `src/tools/rag.ts`).
67
+ - [x] D1: Add a concise “What changed” MCP summary to README/resource index after build; link the platform status resource (`README.md`, `src/mcp-server.ts`).
68
+ - [x] D2: Cross-link prompts to key resources (SID best-practices, VIC-II, PETSCII/charset quickrefs) for richer in-editor guidance (`src/prompts/registry.ts`).
69
+
70
+ ## Phase 5 — Knowledge Exposure & Retrieval Enhancements
71
+
72
+ - [x] K3: Add “BASIC pitfalls” quickref and publish as MCP resource; link from BASIC runners (`data/basic/basic-pitfalls.md`, `src/rag/knowledgeIndex.ts`, `src/tools/programRunners.ts`).
73
+ - [x] K4: Publish PETSCII/charset quickrefs (char codes, glyph map) as MCP resources; dynamically generate Markdown table from `data/video/character-set.csv` (build-time or runtime) to avoid duplicate sources (`src/rag/knowledgeIndex.ts`).
74
+ - [x] K5: Publish VIC-II register quickref as MCP resource and ensure graphics tools reference it (`data/video/vic-spec.md`, `src/tools/graphics.ts`).
75
+ - [x] R2: Include bundle/resource URIs in RAG results when matches originate from docs (`src/rag/retriever.ts`, `src/tools/rag.ts`).
76
+ - [x] R3: Add retrieval diversity and simple duplicate suppression in top-K (`src/rag/retriever.ts`).
77
+ - [x] M5: Add PAL/NTSC-sensitive tags to relevant tools (SID, graphics) to nudge system-awareness (`src/tools/audio.ts`, `src/tools/graphics.ts`).
78
+ - [x] M4: Audit remaining tools for validation messages and examples; bring to parity (`src/tools/*`).
79
+ - [x] T2: Add e2e test for `rag_retrieve_*` verifying structured refs open via `ReadResource` (`test/rag.test.mjs`).
80
+
81
+ ## Phase 6 — Creative Surface: Graphics & SID Workflows
82
+
83
+ - [x] G2: Auto-detect or remind PAL/NTSC context for `sid_note_on`; reflect in metadata (`src/c64Client.ts`, `src/tools/audio.ts`).
84
+ - [x] G3: Include PRG metadata (entry addresses, bytes) in program runners’ structured outputs (`src/tools/programRunners.ts`).
85
+ - [x] G4: Ensure PETSCII structured outputs and docs highlight selected glyphs/codes and miniature preview (`src/tools/graphics.ts`, docs).
86
+ - [x] G5: Document PETSCII style presets (contrast, dithering, palette) and link from prompts (`src/prompts/registry.ts`, docs under `data/video/`).
87
+ - [ ] G6: Add hires bitmap PRG generator tool and document a minimal usage flow (`src/tools/graphics.ts`, `test/graphicsModule.test.mjs`).
88
+ - [x] K6: Add “Sprite & Charset workflows best-practices” document and expose as resource (`data/video/sprite-charset-best-practices.md`, `src/rag/knowledgeIndex.ts`).
89
+ - [x] T4: Add PETSCII generation e2e test verifying preview fields and PRG execution (`test/graphicsModule.test.mjs`).
90
+ - [x] T5: Add sprite preview PRG test (bytes copied, coords/colour applied, screen captured) (`test/graphicsModule.test.mjs`).
57
91
 
58
92
  ## Done Definition (before ticking any item)
59
93
 
@@ -0,0 +1,101 @@
1
+ # Meta Tools Documentation
2
+
3
+ This folder contains documentation for c64bridge meta tools — high-level orchestration tools that compose multiple MCP operations into single, stateful workflows.
4
+
5
+ ## Documents
6
+
7
+ - **[catalog.md](catalog.md)** — Comprehensive catalog of all meta tools with detailed specifications, effort/benefit analysis, and dependency matrix
8
+ - **[rollout.md](rollout.md)** — Implementation checklist with phases, dependencies, and done criteria for executing the meta tools rollout
9
+ - **[analysis.md](analysis.md)** — Impact analysis and prioritization rationale; explains why tools are ordered as they are based on agent effectiveness
10
+ - **[notes.md](notes.md)** — Implementation notes, observations, lessons learned, and technical decisions
11
+
12
+ ## Quick Overview
13
+
14
+ ### What are Meta Tools?
15
+
16
+ Meta tools reduce round-trips between client and server by bundling multiple REST/MCP calls into single, stateful operations with agent-side state management (snapshots, buffers, registries, etc.).
17
+
18
+ ### Current Status
19
+
20
+ **Implemented (11 tools)**:
21
+ - Foundation tools (Phase 0): firmware health checks, screen polling, memory verification, background tasks
22
+ - Orchestration (Phase 1): program shuffle, batch assertions, artifact bundling, compile-run-verify cycles
23
+
24
+ **Not Implemented (~60 tools)**: See catalog.md for full list
25
+
26
+ ### Implementation Priority (New Reprioritization)
27
+
28
+ See [analysis.md](analysis.md) for detailed rationale.
29
+
30
+ **Phase 2a — Quick Wins** (~3.4 hours, high impact):
31
+ 1. `find_and_run_program_by_name` — Find and run programs in disk collections
32
+ 2. `silence_and_verify` — SID testing foundation
33
+ 3. `filesystem_stats_by_extension` — Understand file collections
34
+ 4. `music_compile_play_analyze` — Complete music workflow
35
+
36
+ **Phase 2b — Graphics & Extraction** (~3.3 hours):
37
+ - Extract sprites and character sets from RAM
38
+ - Reliable drive mounting
39
+
40
+ **Phase 2c — Advanced Features**: Classification, timelines, parameter sweeps, memory diffing
41
+
42
+ **Phase 3 — Container Management**: Classify PRG types, deduplication
43
+
44
+ **Phase 4 — Additional Orchestration**: Developer loops, RAG-coupled tools
45
+
46
+ **Phase 5 — Debug Streaming** (Post-GA, requires ~72 hours of infrastructure):
47
+ - Assembly verification, IRQ validation, bus tracing
48
+ - Deferred until UDP ingest pipeline is ready
49
+
50
+ ## Key Insights from Analysis
51
+
52
+ 1. **Filesystem navigation is critical** — Agents struggle to find programs in disk collections; `find_and_run_program_by_name` is the #1 priority
53
+ 2. **SID testing needs proper silence verification** — Quick win that unblocks music composition
54
+ 3. **Debug streaming is valuable but complex** — Requires UDP infrastructure; better to ship simpler high-value features first
55
+ 4. **Graphics extraction has broad appeal** — Sprite/charset extraction enables creative reuse
56
+
57
+ ## For Implementers
58
+
59
+ Start with [rollout.md](rollout.md) which provides:
60
+ - Required reading list
61
+ - Operator rules (process strictly in order, run tests after each change)
62
+ - Global implementation template
63
+ - Phase-by-phase checklists with dependencies
64
+
65
+ Each meta tool entry includes:
66
+ - Priority ranking
67
+ - Effort estimate (minutes)
68
+ - Benefit level (high/medium/low)
69
+ - Dependencies
70
+ - Implementation notes
71
+ - REST endpoints used
72
+
73
+ ## For Users
74
+
75
+ See [catalog.md](catalog.md) for:
76
+ - Tool purpose and use cases
77
+ - Agent-managed state
78
+ - Underlying REST/MCP operations
79
+ - Expected behavior
80
+
81
+ ## Architecture
82
+
83
+ Meta tools live in `src/tools/meta/` with submodules:
84
+ - `diagnostics.ts` — Health checks, firmware info
85
+ - `screen.ts` — Screen polling, text matching
86
+ - `memory.ts` — Memory dumps, verification, diffs
87
+ - `background.ts` — Background task scheduling
88
+ - `filesystem.ts` — File discovery, stats
89
+ - `config.ts` — Configuration snapshots
90
+ - `program.ts` — Program orchestration
91
+ - `artifacts.ts` — Artifact bundling
92
+ - `compilation.ts` — Build-test cycles
93
+
94
+ All meta tools are marked as experimental and exposed through the standard MCP tool registry.
95
+
96
+ ## Related Documentation
97
+
98
+ - `doc/agent-state-spec.md` — Background task registry specification
99
+ - `doc/developer.md` — Architecture overview and contribution guidelines
100
+ - `doc/improve-knowledge/` — Similar documentation structure pattern
101
+ - `src/tools/meta/` — Implementation source code