c64bridge 1.0.6 → 1.1.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 (136) hide show
  1. package/.github/skills/assembly-program/SKILL.md +37 -0
  2. package/.github/skills/basic-program/SKILL.md +40 -0
  3. package/.github/skills/cross-platform-demo/SKILL.md +32 -0
  4. package/.github/skills/drive-manager/SKILL.md +33 -0
  5. package/.github/skills/graphics-demo/SKILL.md +30 -0
  6. package/.github/skills/hello-world/SKILL.md +36 -0
  7. package/.github/skills/memory-debug/SKILL.md +32 -0
  8. package/.github/skills/pr-converge/SKILL.md +33 -0
  9. package/.github/skills/printer-job/SKILL.md +30 -0
  10. package/.github/skills/sid-music/SKILL.md +35 -0
  11. package/.github/skills/software-launch/SKILL.md +31 -0
  12. package/.github/skills/stream-control/SKILL.md +29 -0
  13. package/.github/skills/system-control/SKILL.md +32 -0
  14. package/AGENTS.md +28 -7
  15. package/README.md +70 -15
  16. package/data/assembly/assembly-spec.md +2 -0
  17. package/dist/c64Client.js +238 -60
  18. package/dist/chargen.js +0 -4
  19. package/dist/config.js +53 -28
  20. package/dist/device.js +92 -37
  21. package/dist/diagnostics.js +66 -5
  22. package/dist/hostPaths.js +128 -0
  23. package/dist/logger.js +3 -2
  24. package/dist/loggingHttpClient.js +71 -2
  25. package/dist/mcp-server.js +416 -291
  26. package/dist/numericArg.js +55 -0
  27. package/dist/petscii.js +13 -6
  28. package/dist/platform.js +12 -3
  29. package/dist/prompts/registry.js +6 -1
  30. package/dist/redact.js +166 -0
  31. package/dist/tools/access.js +66 -0
  32. package/dist/tools/debug.js +6 -0
  33. package/dist/tools/developer.js +77 -36
  34. package/dist/tools/errors.js +54 -3
  35. package/dist/tools/input.js +25 -8
  36. package/dist/tools/machineControl.js +113 -21
  37. package/dist/tools/memory.js +135 -30
  38. package/dist/tools/meta/artifacts.js +5 -5
  39. package/dist/tools/meta/background.js +216 -54
  40. package/dist/tools/meta/compilation.js +6 -5
  41. package/dist/tools/meta/config.js +20 -10
  42. package/dist/tools/meta/configInventory.js +25 -2
  43. package/dist/tools/meta/diagnostics.js +2 -1
  44. package/dist/tools/meta/filesystem.js +16 -14
  45. package/dist/tools/meta/graphics.js +48 -20
  46. package/dist/tools/meta/memory.js +45 -19
  47. package/dist/tools/meta/program.js +10 -7
  48. package/dist/tools/meta/screen.js +116 -25
  49. package/dist/tools/pauseGuard.js +23 -0
  50. package/dist/tools/pollValidator.js +53 -8
  51. package/dist/tools/programRunners.js +62 -18
  52. package/dist/tools/registry/batch.js +17 -11
  53. package/dist/tools/registry/config.js +9 -2
  54. package/dist/tools/registry/disk.js +12 -2
  55. package/dist/tools/registry/drive.js +3 -0
  56. package/dist/tools/registry/extract.js +3 -0
  57. package/dist/tools/registry/graphics.js +59 -6
  58. package/dist/tools/registry/index.js +17 -1
  59. package/dist/tools/registry/memory.js +11 -1
  60. package/dist/tools/registry/platform.js +4 -1
  61. package/dist/tools/registry/printer.js +2 -1
  62. package/dist/tools/registry/program.js +5 -1
  63. package/dist/tools/registry/rag.js +1 -0
  64. package/dist/tools/registry/sound.js +12 -1
  65. package/dist/tools/registry/stream.js +2 -1
  66. package/dist/tools/registry/system.js +8 -1
  67. package/dist/tools/schema.js +7 -7
  68. package/dist/tools/streaming.js +34 -4
  69. package/dist/tools/translation/assembler.js +247 -24
  70. package/dist/tools/translation/basicDetokenizer.js +80 -0
  71. package/dist/tools/translation/basicTokenizer.js +8 -3
  72. package/dist/tools/translation/disassembler.js +14 -0
  73. package/dist/tools/types.js +258 -7
  74. package/dist/tools/vice.js +5 -16
  75. package/dist/vicBitmap.js +1 -1
  76. package/dist/vice/mockServer.js +3 -0
  77. package/dist/vice/process.js +19 -0
  78. package/dist/vice/resourcePolicy.js +36 -0
  79. package/dist/vice/viceClient.js +22 -5
  80. package/doc/vice/support-matrix.md +17 -11
  81. package/mcp/schemas/c64_batch.schema.json +2 -1
  82. package/mcp/schemas/c64_config.schema.json +33 -466
  83. package/mcp/schemas/c64_debug.schema.json +3 -602
  84. package/mcp/schemas/c64_disk.schema.json +17 -344
  85. package/mcp/schemas/c64_drive.schema.json +2 -157
  86. package/mcp/schemas/c64_extract.schema.json +10 -364
  87. package/mcp/schemas/c64_graphics.schema.json +19 -426
  88. package/mcp/schemas/c64_input.schema.json +5 -318
  89. package/mcp/schemas/c64_memory.schema.json +23 -491
  90. package/mcp/schemas/c64_printer.schema.json +3 -258
  91. package/mcp/schemas/c64_program.schema.json +16 -491
  92. package/mcp/schemas/c64_rag.schema.json +1 -81
  93. package/mcp/schemas/c64_select_backend.schema.json +2 -36
  94. package/mcp/schemas/c64_sound.schema.json +20 -822
  95. package/mcp/schemas/c64_stream.schema.json +4 -75
  96. package/mcp/schemas/c64_system.schema.json +28 -348
  97. package/mcp/schemas/c64_vice.schema.json +2 -71
  98. package/mcp/server.json +1 -1
  99. package/mcp/tools.json +1990 -6900
  100. package/mcp.json +21 -1
  101. package/package.json +19 -8
  102. package/scripts/mockC64Server.mjs +44 -0
  103. package/scripts/run-coverage.mjs +27 -1
  104. package/scripts/smoke-run.sh +3 -2
  105. package/scripts/start.mjs +23 -1
  106. package/server.json +53 -3
  107. package/dist/.tsbuildinfo +0 -1
  108. package/doc/agent-state-spec.md +0 -243
  109. package/doc/plans/bun/baseline-metrics.md +0 -16
  110. package/doc/plans/bun/migration-checklist.md +0 -55
  111. package/doc/plans/bun/migration.md +0 -83
  112. package/doc/plans/improve-knowledge/notes.md +0 -43
  113. package/doc/plans/improve-knowledge/plan.md +0 -121
  114. package/doc/plans/improve-knowledge/rollout.md +0 -110
  115. package/doc/plans/meta-tools/README.md +0 -110
  116. package/doc/plans/meta-tools/analysis.md +0 -272
  117. package/doc/plans/meta-tools/catalog.md +0 -435
  118. package/doc/plans/meta-tools/notes.md +0 -192
  119. package/doc/plans/meta-tools/rollout.md +0 -368
  120. package/doc/plans/prompts/README.md +0 -96
  121. package/doc/plans/prompts/user-prompt-ideas.md +0 -147
  122. package/doc/plans/tool-consolidation/notes.md +0 -28
  123. package/doc/plans/tool-consolidation/plan.md +0 -169
  124. package/doc/plans/tool-consolidation/rollout.md +0 -104
  125. package/doc/plans/vice-backend-switch/plan.md +0 -486
  126. package/doc/plans/vice-backend-switch-2/plan.md +0 -48
  127. package/doc/plans/vice-support/notes.md +0 -63
  128. package/doc/plans/vice-support/plan.md +0 -88
  129. package/doc/plans/vice-support/rollout.md +0 -99
  130. package/doc/reviews/audit.md +0 -143
  131. package/doc/reviews/hardening/01-fable/prompt-handover.md +0 -125
  132. package/doc/reviews/hardening/01-fable/prompt.md +0 -98
  133. package/doc/reviews/hardening/01-fable/review-prompt.md +0 -468
  134. package/doc/reviews/hardening/01-fable/review.md +0 -1234
  135. package/doc/reviews/vice-support-review.md +0 -185
  136. package/scripts/compare-rest/rest-compare-2025-11-01T00-25-21-830Z.json +0 -2513
@@ -1,243 +0,0 @@
1
- # c64bridge — Agent State Specification
2
-
3
- This specification defines how the **c64bridge** agent stores and manages its persistent **task** and **session** state.
4
-
5
- A **task** is the fundamental unit of work executed by the agent. There are two task types:
6
-
7
- - **Foreground tasks** — short-lived, single-execution operations (e.g., extract sprites from RAM).
8
- - **Background tasks** — long-running, periodic operations (e.g., sample memory every second).
9
-
10
- ---
11
-
12
- ## 1. Directory Layout
13
-
14
- All state is stored under the user’s home directory (`~/.c64bridge/`).
15
-
16
- ```text
17
- ~/.c64bridge/
18
- ├─ tasks.json # global registry of all tasks (foreground + background)
19
- └─ tasks/
20
- ├─ background/ # background (recurring) tasks
21
- │ └─ <taskId>/ # e.g. 0001_read
22
- │ ├─ task.json
23
- │ ├─ result.json
24
- │ └─ log.txt
25
- └─ <taskId>/ # foreground (one-shot) tasks
26
- ├─ task.json
27
- ├─ result.json
28
- ├─ artifacts/ # optional outputs (e.g., sprites, dumps)
29
- └─ log.txt
30
- ```
31
-
32
- ### Task ID Convention
33
-
34
- Each task folder name equals its **`task.id`**, constructed as:
35
-
36
- ```text
37
- <4-digit counter>_<task.name>
38
- ```
39
-
40
- Example:
41
-
42
- ```text
43
- 0001_extract_sprites
44
- 0002_extract_sprites
45
- 0003_extract_ram
46
- ```
47
-
48
- Counters increment per new task creation (shared across both task types).
49
- All background tasks are placed under `tasks/background/`, all foreground tasks under `tasks/`.
50
-
51
- ---
52
-
53
- ## 2. Task Types
54
-
55
- ### Foreground Tasks
56
-
57
- - Short-lived, synchronous operations that run once and complete quickly.
58
- - Used for “extract” or “analyze” style commands where the user requests data immediately.
59
-
60
- Examples:
61
-
62
- - **Extract all sprites from RAM**
63
- → Reads sprite data from `$2000`–`$3FFF`, decodes shapes, saves PNGs and binary blobs to
64
- `~/.c64bridge/tasks/0001_extract_sprites/artifacts/sprites/`.
65
- - **Extract RAM region to file**
66
- → Dumps a range of memory into a `.bin` or `.hex` file for later inspection.
67
-
68
- A foreground task executes once and then transitions from `running → completed` or `running → error`.
69
- No repetition or scheduling logic applies.
70
-
71
- ---
72
-
73
- ### Background Tasks
74
-
75
- - Long-running, recurring operations that execute periodically.
76
- - Used for sampling, monitoring, or repeated execution of a fixed operation.
77
-
78
- Examples:
79
-
80
- - Read C64 memory every second for 1 minute.
81
- - Poll the C64 screen until specific text appears.
82
- - Periodically capture state for regression detection.
83
-
84
- Background tasks have an interval and optional maximum iteration count.
85
-
86
- ---
87
-
88
- ## 3. tasks.json — Global Task Registry
89
-
90
- This file tracks all tasks, regardless of type.
91
- It is updated atomically after each task start, update, or completion.
92
-
93
- ```json
94
- {
95
- "tasks": [
96
- {
97
- "id": "0001_extract_sprites",
98
- "name": "extract_sprites",
99
- "type": "foreground",
100
- "operation": "extract_sprites_from_ram",
101
- "args": { "persistArtifacts": true },
102
- "status": "completed",
103
- "startedAt": "2025-10-27T11-42-03Z",
104
- "updatedAt": "2025-10-27T11-42-05Z",
105
- "stoppedAt": "2025-10-27T11-42-05Z",
106
- "lastError": null,
107
- "folder": "tasks/0001_extract_sprites"
108
- },
109
- {
110
- "id": "0002_read",
111
- "name": "read",
112
- "type": "background",
113
- "operation": "read",
114
- "args": { "address": "$0400", "length": 256 },
115
- "intervalMs": 1000,
116
- "maxIterations": 60,
117
- "iterations": 60,
118
- "status": "completed",
119
- "startedAt": "2025-10-27T11-45-00Z",
120
- "updatedAt": "2025-10-27T11-46-00Z",
121
- "stoppedAt": "2025-10-27T11-46-00Z",
122
- "lastError": null,
123
- "folder": "tasks/background/0002_read"
124
- }
125
- ]
126
- }
127
- ```
128
-
129
- ### Field meanings
130
-
131
- | Field | Type | Description |
132
- |--------|------|-------------|
133
- | `id` | string | Unique folder name (`0001_extract_sprites`). |
134
- | `name` | string | Logical name (user-assigned). |
135
- | `type` | string | `"foreground"` or `"background"`. |
136
- | `operation` | string | Operation performed (`read`, `write`, `extract_sprites_from_ram`, etc.). |
137
- | `args` | object | Operation-specific arguments. |
138
- | `intervalMs` | number \| undefined | Interval between runs (background only). |
139
- | `maxIterations` | number \| undefined | Total iterations before stop (background only). |
140
- | `iterations` | number \| undefined | Iterations completed (background only). |
141
- | `status` | string | `"running"` \| `"completed"` \| `"stopped"` \| `"error"`. |
142
- | `startedAt` | string | Timestamp (`YYYY-MM-DDTHH-mm-ssZ`) of first run start. |
143
- | `updatedAt` | string | Timestamp of last state change. |
144
- | `stoppedAt` | string \| null | Timestamp when finished or stopped. |
145
- | `lastError` | string \| null | Error message if failed. |
146
- | `folder` | string | Path of the task folder relative to `~/.c64bridge/`. |
147
-
148
- ---
149
-
150
- ## 4. task.json — Individual Task State
151
-
152
- Each task’s folder contains a standalone `task.json`, mirroring its registry entry plus any additional metadata.
153
-
154
- ```json
155
- {
156
- "id": "0001_extract_sprites",
157
- "name": "extract_sprites",
158
- "type": "foreground",
159
- "operation": "extract_sprites_from_ram",
160
- "args": { "persistArtifacts": true },
161
- "status": "completed",
162
- "startedAt": "2025-10-27T11-42-03Z",
163
- "updatedAt": "2025-10-27T11-42-05Z",
164
- "stoppedAt": "2025-10-27T11-42-05Z",
165
- "resultPath": "tasks/0001_extract_sprites/result.json"
166
- }
167
- ```
168
-
169
- ---
170
-
171
- ## 5. result.json — Structured Task Output
172
-
173
- Optional file describing high-level output of a task.
174
-
175
- Example for **foreground** sprite extraction:
176
-
177
- ```json
178
- {
179
- "id": "0001_extract_sprites",
180
- "type": "task",
181
- "name": "extract_sprites_from_ram",
182
- "created": "2025-10-27T11-42-03Z",
183
- "completed": "2025-10-27T11-42-05Z",
184
- "status": "completed",
185
- "summary": {
186
- "spriteCount": 8,
187
- "spriteAddresses": ["0x2000", "0x2080"]
188
- },
189
- "artifacts": {
190
- "spritesDir": "artifacts/sprites/"
191
- }
192
- }
193
- ```
194
-
195
- ---
196
-
197
- ## 6. session.json — Session Summary (optional)
198
-
199
- Sessions are logical groupings of tasks run in the same time window.
200
- This file is optional and only created if session tracking is enabled.
201
-
202
- ```json
203
- {
204
- "sessionId": "2025-10-27T11-42-00Z",
205
- "created": "2025-10-27T11-42-00Z",
206
- "ended": null,
207
- "status": "active",
208
- "tasks": [
209
- { "id": "0001_extract_sprites", "type": "foreground" },
210
- { "id": "0002_read", "type": "background" }
211
- ]
212
- }
213
- ```
214
-
215
- ---
216
-
217
- ## 7. Update & Persistence Model
218
-
219
- - **In-memory source of truth:** `TASKS: Map<string, Task>`
220
- - **On-disk persistence:** `~/.c64bridge/tasks.json`
221
- - On startup:
222
- - `ensureTasksLoaded()` loads `tasks.json`.
223
- - If missing, an empty file is created.
224
- - On every task state change:
225
- - Update `tasks.json` (atomic rewrite).
226
- - Write or update the per-task `task.json` and optional `result.json`.
227
- - **Timestamps:** All stored as UTC strings in `YYYY-MM-DDTHH-mm-ssZ` format.
228
-
229
- ---
230
-
231
- ## 8. Summary
232
-
233
- | Concept | Description | Example |
234
- |----------|--------------|----------|
235
- | **Foreground Task** | One-shot, short operation returning immediate data (e.g., extract sprites, read memory once). | `0001_extract_sprites` |
236
- | **Background Task** | Recurring scheduled operation (e.g., read memory every second). | `0002_read` |
237
- | **Task Folder** | Directory under `tasks/` (foreground) or `tasks/background/` containing JSON state and logs. | `~/.c64bridge/tasks/0001_extract_sprites/` |
238
- | **Registry File** | Global view of all tasks. | `~/.c64bridge/tasks.json` |
239
- | **Session Summary** | Optional grouping of related tasks run during a session. | `~/.c64bridge/sessions/<id>/session.json` |
240
-
241
- ---
242
-
243
- **This specification is authoritative for all task persistence and state tracking in c64bridge.**
@@ -1,16 +0,0 @@
1
- # Bun Migration Baseline (Node.js)
2
-
3
- Captured before introducing Bun tooling. All commands executed on the `bun-migration` branch using Node.js 18 (system default).
4
-
5
- | Command | Notes | Duration |
6
- |---------|-------|----------|
7
- | `npm run build` | TypeScript compile + postbuild + README update | **10.44 s** |
8
- | `npm test` | Full TAP suite via `scripts/run-tests.mjs` | **47.61 s** |
9
-
10
- Additional context:
11
-
12
- - Dependencies installed with `npm install` (fresh, no cache) before measuring.
13
- - No Bun tooling in use; these timings represent our current Node-only baseline.
14
- - Results recorded on 2025-10-29 to anchor future comparisons.
15
-
16
- Next step: use these numbers to evaluate improvements once Bun drives install/build/test tasks.
@@ -1,55 +0,0 @@
1
- # Bun Migration Checklist
2
-
3
- > Track the incremental migration from Node.js/npm tooling to Bun.
4
- > Update each item as it is completed and keep a short note/date beside the checkbox.
5
- > Before doing any work, ensure you understand the [Bun Migration Strategy](./migration.md).
6
- > Keep notes of any deviations or important observations in the checklist itself.
7
-
8
- ## 1. Foundations
9
-
10
- - [x] **1.1** Capture baseline metrics (install/build/test timings, coverage reports) for comparison. *(doc/bun/baseline-metrics.md, 2025-10-29)*
11
- - [x] **1.2** Introduce Bun toolchain alongside existing Node workflow (lockfile, `packageManager`, basic `bun install` smoke test).
12
-
13
- ## 2. Package & Tooling
14
-
15
- - [x] **2.1** Update `package.json` scripts to use Bun equivalents while keeping Node fallbacks where required. *(added Bun packageManager + `check:node-compat`)*
16
- - [x] **2.2** Ensure `bun run build` reproduces the existing `dist/` layout (compare key artifacts). *(verified 2025-10-29)*
17
- - [x] **2.3** Add an automated check that validates the published package still runs under `npm install` + `node`. *(npm script + compatibility harness)*
18
-
19
- ## 3. Test Suite
20
-
21
- - [x] **3.1** Migrate test runner to `bun test`, converting assertion helpers and harness utilities. *(bun harness + timeout guardrails, 2025-10-29)*
22
- - [x] **3.2** Ensure `bun test` runs the full suite with the same semantics (mock servers, fixtures, CLI tools). *(`bun scripts/run-tests.ts --mock`, 2025-10-29)*
23
- - [x] **3.3** Provide an explicit npm/node compatibility test (e.g., `npm test` wrapper or integration smoke test). *(`npm run test:node`, 2025-10-29)*
24
-
25
- ## 4. Coverage & Reporting
26
-
27
- - [x] **4.1** Replace `c8` with Bun’s coverage tooling and export lcov output. *(bun coverage emits `coverage/lcov.info`, 2025-10-29)*
28
- - [x] **4.2** Verify Codecov integration with the new coverage artifacts. *(workflow uploads Bun lcov, 2025-10-29)*
29
-
30
- ## 5. Scripts & Utilities
31
-
32
- - [x] **5.1** Port repository scripts (`scripts/*.mjs`) from Node-specific loaders/`ts-node` to Bun-native execution. *(start, rag, CLI now Bun-aware; Node fallbacks use dist, 2025-10-29)*
33
- - [x] **5.2** Replace `register-ts-node` usage with Bun-compatible module loading. *(ts-node loader inlined; helper removed, 2025-10-29)*
34
- - [x] **5.3** Update shell helpers (e.g., `run-mcp-check.sh`, `c64-tool.sh`) to call Bun commands by default. *(preferred Bun paths with Node fallback, 2025-10-29)*
35
-
36
- ## 6. Automation & CI
37
-
38
- - [x] **6.1** Update GitHub Actions to install Bun (`oven-sh/setup-bun`) and run build/test/coverage using Bun. *(added setup-bun, switched to `bun run build`, ensured LCOV output for Codecov, 2025-10-30)*
39
- - [x] **6.2** Ensure Docker-based checks (if any) consume the new Bun workflow without regressions. *(builder image now includes Bun; CI jobs use container and run Bun successfully, 2025-10-30)*
40
-
41
- ## 7. Docker & Runtime
42
-
43
- - [x] **7.1** Rebuild the Dockerfile using an official Bun base image; retain runtime parity and entrypoints. *(deviation: kept `ubuntu:24.04` base but installed Bun system-wide; image provides both Node and Bun for CI parity, 2025-10-30)*
44
- - [x] **7.2** Confirm resulting image passes existing smoke tests and compatibility checks. *(Docker workflow builds `mcp-builder` and downstream package smoke tests pass, 2025-10-30)*
45
-
46
- ## 8. Documentation
47
-
48
- - [x] **8.1** Refresh README, developer docs, and setup guides to reference Bun (with a note about Node compatibility). *(README Build & Test updated to include Bun; dev docs already referenced Bun, 2025-10-30)*
49
- - [x] **8.2** Document the npm/node compatibility verification process for external consumers. *(`npm run check:node-compat` documented in dev docs; retained, 2025-10-30)*
50
-
51
- ## 9. Final Verification
52
-
53
- - [x] **9.1** Run full validation suite: `bun install`, `bun run build`, `bun test --coverage`, npm compatibility smoke test. *(wired in CI; local scripts use Bun runner; coverage emits LCOV, 2025-10-30)*
54
- - [x] **9.2** Compare final artifacts and confirm no API/package layout changes. *(build parity verified earlier; CI keeps packaging check, 2025-10-30)*
55
- - [x] **9.3** Remove obsolete Node-only tooling and close out migration notes. *(no remaining Node-only paths required for CI; kept Node paths for consumer compatibility, 2025-10-30)*
@@ -1,83 +0,0 @@
1
- # Bun Migration Strategy
2
-
3
- Our goal is to adopt Bun everywhere it improves speed (local dev, CI, container builds) **without sacrificing Node compatibility** for downstream consumers.
4
-
5
- ---
6
-
7
- ## Approach Overview
8
-
9
- 1. **Track incremental work via the checklist** (`doc/bun/migration-checklist.md`).
10
- 2. **Introduce Bun tooling in parallel** with Node/npm. Validate parity before turning off Node paths.
11
- 3. **Port the build/test pipeline** to Bun (`bun install`, `bun run build`, `bun test --coverage`) and keep comparing against Node outputs (especially `dist/` packaging).
12
- 4. **Update automation and docs** once Bun passes all checks.
13
- 5. **Retain Node smoke tests** to ensure published artifacts remain consumable by Node users.
14
-
15
- ### Current Status (2025-10-29)
16
-
17
- - Baseline Node metrics captured (`npm run build` ~10.44 s, `npm test` ~47.61 s) in `doc/bun/baseline-metrics.md`.
18
- - Bun toolchain bootstrapped alongside Node (`bun.lock`, `packageManager`, smoke `bun install`).
19
- - Added `npm run check:node-compat` (packs the module, installs via npm, and imports key ESM modules with Node) to guard compatibility as we iterate.
20
- - `bun run build` verified to produce the same `dist/` output as the Node workflow.
21
-
22
- ---
23
-
24
- ## Guardrails
25
-
26
- ### 1. Build & Runtime Rules
27
-
28
- - Sources remain TypeScript, emitting standard ESM/CJS modules compatible with Node.
29
- - Published code may not depend on Bun-only APIs (no `Bun.file`, `Bun.serve`, etc.).
30
- - The compiled `dist/` must execute under both **Bun ≥1.1** and **Node ≥24**.
31
- - `package.json` stays valid for npm clients (no Bun-only metadata).
32
-
33
- ### 2. CI Strategy (Asymmetric Validation)
34
-
35
- - **Primary path (PRs, default CI):**
36
-
37
- ```bash
38
- bun install
39
- bun run build
40
- bun test --coverage
41
- ```
42
-
43
- - **Release/nightly Node validation (reuse `dist/`):**
44
-
45
- ```bash
46
- npm ci --omit=dev
47
- node dist/index.js --version
48
- npm test -- --smoke
49
- ```
50
-
51
- ### 3. Docker Strategy
52
-
53
- Build with Bun, run with Node:
54
-
55
- ```dockerfile
56
- FROM oven/bun:latest AS build
57
- WORKDIR /app
58
- COPY . .
59
- RUN bun install && bun run build
60
-
61
- FROM node:24-slim
62
- WORKDIR /app
63
- COPY --from=build /app/dist ./dist
64
- COPY package.json .
65
- CMD ["node", "dist/index.js"]
66
- ```
67
-
68
- ### 4. Validation Matrix
69
-
70
- - **Bun:** install/build/test/coverage on every PR.
71
- - **Node:** smoke tests on main branch, releases, or nightly jobs.
72
- - **Rule:** only build once; reuse Bun artifacts for Node checks.
73
-
74
- ### 5. Documentation Messaging
75
- >
76
- > Built and tested with **Bun** ⚡
77
- > Fully compatible with **Node.js 24+** 🟩
78
-
79
- ---
80
-
81
- ## Next Steps
82
-
83
- Use this document together with the checklist to plan each migration phase. Update both as milestones are completed and ensure the guardrails stay enforced.
@@ -1,43 +0,0 @@
1
- # Knowledge Improvement Rollout Working Notes
2
-
3
- ## Required Reading Confirmation
4
-
5
- - `doc/improve-knowledge/plan.md` — Reviewed priorities and scoped improvements.
6
- - `doc/developer.md` — Reviewed contribution workflow, testing gates (`npm run check`), and documentation update expectations.
7
- - `README.md` (API and MCP surface sections) — Reconfirmed autogenerated tool/resource tables and need to update documentation alongside code changes.
8
-
9
- ## Key Acceptance Criteria from the Improvement Plan
10
-
11
- - **Structured RAG outputs (R1)**: Responses must include structured fields (`uri`, `origin`, `snippet`, `score`) so `ReadResource` consumers can follow references without parsing prose.
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
- - **SID best-practices resource (K2)**: `data/sound/sid-programming-best-practices.md` must be surfaced as a first-class MCP resource to guide audio tools and prompts.
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
- ```
@@ -1,121 +0,0 @@
1
- # Knowledge Improvement Plan
2
-
3
- This plan aims to identify and prioritize improvements to the C64 Bridge MCP server.
4
-
5
- The main goal is to enhance the server's effectiveness when used with LLMs for code generation, music creation, graphics, and general C64 programming tasks.
6
-
7
- The focus is on improving the MCP surface, knowledge base, RAG capabilities, generator defaults, and overall developer experience.
8
-
9
- ### 1) Executive Summary
10
-
11
- The server exposes a rich, well-typed MCP surface with clear schemas, strong logging, a deterministic local RAG, and extensive tests. The biggest gaps affecting LLM effectiveness are:
12
-
13
- - (1) RAG results are returned as raw text rather than structured, referenceable snippets;
14
- - (2) key domain docs (memory/IO maps, SID best-practices) are not exposed as MCP resources;
15
- - (3) creative defaults (e.g., SID waveform/ADSR) aren’t aligned with the repo’s own musical best-practices. Addressing these will materially improve determinism, provenance, and the quality of BASIC/ASM/graphics/SID outputs.
16
-
17
- ### 2) Recommendations (Grouped by Topic)
18
-
19
- #### MCP Surface & Tooling
20
-
21
- | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
22
- |----|----------------|-----------------------------|---------|-----------|------------------|
23
- | M1 | Remove `upload_run_basic` as a prerequisite for `read_screen` to avoid misleading LLM plans (screen read works independently). | `src/tools/memory.ts:81-99`, `88-89` | S | 3 | Slightly changes listed workflow hints; no runtime impact. |
24
- | M2 | Standardize structured JSON outputs for runner tools (include entry addresses, artifacts, URIs) similar to graphics/audio tools using `structuredContent`. | `src/tools/types.ts:64-72, 90-106`; program runners return only `textResult` in `src/tools/programRunners.ts:129-140,176-180,231-236,276-281,320-324` | M | 4 | Minor API output change; keep text message for backward compatibility. |
25
- | M3 | Add a lightweight tool to set platform at runtime (uses existing `setPlatform`) and surface platform resource in resources index for LLM clarity. | `src/platform.ts:29-46,58-91`; resource exists: `src/mcp-server.ts:371-432` | S | 3 | Requires documenting when platform switch affects tool availability. |
26
- | M4 | Ensure all tools include concise validation messages and examples (many already do); audit remaining modules for parity. | e.g., `src/tools/audio.ts:190-224,517-583,747-756` | S | 3 | Small doc/schema edits; keeps LLM prompts aligned with schemas. |
27
- | M5 | Add explicit tool tags and related resources for PAL/NTSC-sensitive tools (SID, graphics) to nudge LLM to check system differences. | `src/tools/audio.ts:94-101`, `src/knowledge.ts:368-438` | S | 3 | Slight metadata churn; improves prompt-tool alignment. |
28
-
29
- #### Knowledge Base & Resources
30
-
31
- | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
32
- |----|----------------|-----------------------------|---------|-----------|------------------|
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
- | K2 | Expose SID best-practices as a resource (used by creative flows). | Not in knowledge index; exists at `data/sound/sid-programming-best-practices.md` | S | 5 | Aligns generation defaults with proven musical outcomes. |
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/graphics/character-set.csv` (retain CSV for programmatic access). Prefer dynamic generation to avoid duplicate sources of truth. | `data/graphics/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/graphics/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/graphics/` referencing `src/tools/graphics.ts` capabilities | M | 4 | Guides consistent, high-quality sprite/charset pipelines for LLMs. |
39
-
40
- #### RAG & Retrieval
41
-
42
- | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
43
- |----|----------------|-----------------------------|---------|-----------|------------------|
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. |
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. |
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. |
48
-
49
- #### Generators & Creative Pipelines (BASIC/ASM/Graphics/SID)
50
-
51
- | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
52
- |----|----------------|-----------------------------|---------|-----------|------------------|
53
- | G1 | Change `music_generate` defaults to triangle waveform and best-practice ADSR; optionally expose a “musical expression” preset. | Current defaults pulse+ADSR: `src/tools/audio.ts:747-756,783-801`; PAL/NTSC in client: `src/c64Client.ts:773-786`; best-practices doc: `data/sound/sid-programming-best-practices.md` | S | 5 | Slight change to expected timbre; add arg to opt back to pulse. |
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. |
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. |
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. |
59
-
60
- #### Validation, Testing & CI
61
-
62
- | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
63
- |----|----------------|-----------------------------|---------|-----------|------------------|
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. |
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. |
66
- | T3 | Quick test to ensure `read_screen` works without prior `upload_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. |
69
-
70
- #### Developer Experience & Documentation
71
-
72
- | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
73
- |----|----------------|-----------------------------|---------|-----------|------------------|
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. |
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/graphics/`, `src/prompts/registry.ts` | M | 4 | Streamlines creative workflows aligned to the core mission. |
77
-
78
- #### Security/Licensing & Reproducibility
79
-
80
- | ID | Recommendation | Evidence (paths/lines/refs) | Effort* | Benefit** | Risks/Trade-offs |
81
- |----|----------------|-----------------------------|---------|-----------|------------------|
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. |
84
-
85
- \* Effort: S (small), M (medium), L (large)
86
- \** Benefit: 1–5 (5 = highest impact)
87
-
88
- ### 3) Ranked Shortlist (Cross-Topic)
89
-
90
- | Rank | ID | Title | Effort | Benefit | One-line Justification |
91
- |------|----|-------|--------|---------|------------------------|
92
- | 1 | R1 | Structured RAG refs with URIs and scores | M | 5 | Makes retrieval actionable and referenceable for LLMs. |
93
- | 2 | K1 | Add memory/IO docs as MCP resources | S | 5 | Critical grounding for reliable ASM/memory operations. |
94
- | 3 | G1 | Align music defaults to best-practices (tri/ADSR) | S | 5 | Immediate quality uplift for SID output. |
95
- | 4 | K2 | Expose SID best-practices as resource | S | 5 | Guides LLM toward proven musical results. |
96
- | 5 | M2 | Standardize structured JSON outputs for runners | M | 4 | Improves determinism and follow-up automation. |
97
- | 6 | T1 | Tests for PAL/NTSC and new music defaults | S | 4 | Locks in audible quality and tuning accuracy. |
98
- | 7 | M1 | Remove `read_screen` pre-req coupling | S | 3 | Avoids confusing plans; reduces unnecessary steps. |
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. |
116
-
117
- ### 4) Top Three Priorities
118
-
119
- - Implement structured RAG results (URIs, origin, score) and wire `ReadResource` for direct follow-ups.
120
- - Add memory/IO maps and SID best-practices to the exposed MCP resources to improve grounding.
121
- - Switch `music_generate` defaults to triangle + recommended ADSR, and add tests for PAL/NTSC tuning.