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,435 +0,0 @@
1
- ## Meta Tools Catalog for c64bridge (Research Draft)
2
-
3
- Purpose: Reduce round-trips and keep richer agent-side state by bundling multiple REST calls into single, stateful meta tools. Each entry lists its intent, agent-managed state, and the underlying Ultimate 64 REST endpoints it composes.
4
-
5
- Conventions:
6
-
7
- - Endpoint notation: METHOD /v1/<route>[:<command>] (see `doc/c64u/c64-rest-api.md`).
8
- - When a meta tool composes MCP tools, these map onto the same REST calls via the `C64Client` facade.
9
- - Agent-managed state includes timers, queues, background tasks, rolling buffers, snapshots, and derived artifacts written to the agent filesystem.
10
-
11
- ### Memory inspection, capture, and disassembly
12
-
13
- - "memory_dump_to_file"
14
- - Capture a large RAM range in chunks and write to a local file (hex or binary), with optional pause/resume for stability.
15
- - Agent state: chunking progress, retries, output file path, checksum.
16
- - REST: GET /v1/machine:readmem, PUT /v1/machine:pause, PUT /v1/machine:resume
17
-
18
- - "memory_snapshot_and_diff"
19
- - Take two or more snapshots of one or multiple address ranges and produce a diff report (hex and structured JSON with offsets and values).
20
- - Agent state: named snapshots, diff histories.
21
- - REST: GET /v1/machine:readmem, PUT /v1/machine:pause, PUT /v1/machine:resume
22
-
23
- - "verify_and_write_memory"
24
- - Pause, read current bytes, verify expected pattern, write bytes, read back to confirm, then resume. Fails fast on mismatch.
25
- - Agent state: expected vs actual buffers, verification report.
26
- - REST: PUT /v1/machine:pause, GET /v1/machine:readmem, PUT|POST /v1/machine:writemem, PUT /v1/machine:resume
27
-
28
- - "watch_memory_until_condition"
29
- - Poll a region until a predicate matches (e.g., value equals, non-zero, bitmask set), with timeout and sampling period; optional callback tool.
30
- - Agent state: poll scheduler, condition function, elapsed time.
31
- - REST: GET /v1/machine:readmem
32
-
33
- - "disassemble_ram_region"
34
- - Pause, read region, disassemble 6502 bytes (agent-side disassembler), write labeled listing to disk with optional symbol hints; resume.
35
- - Agent state: symbol map, disassembly options, output files.
36
- - REST: PUT /v1/machine:pause, GET /v1/machine:readmem, PUT /v1/machine:resume
37
-
38
- - "trace_code_flow_by_checksums"
39
- - Periodically hash code ranges, detect self-modifying changes, and log a time series; optional dump on change.
40
- - Agent state: rolling hashes, change log, thresholds.
41
- - REST: GET /v1/machine:readmem
42
-
43
- ### Graphics, sprites, and screen workflows
44
-
45
- - "extract_sprites_from_ram"
46
- - Scan RAM (configured ranges and stride) for likely 63-byte sprite patterns; decode and save each as `.spr`/hex/base64 with coordinates if discoverable.
47
- - Agent state: candidate heuristics, sprite index mapping, output folder.
48
- - REST: GET /v1/machine:readmem, optional PUT /v1/machine:pause|resume
49
-
50
- - "rip_charset_from_ram"
51
- - Locate 2 KB character sets (8x8 tiles × 256) by entropy/structure checks; export as binary and preview PNG.
52
- - Agent state: range scan plan, preview images, output paths.
53
- - REST: GET /v1/machine:readmem, optional PUT /v1/machine:pause|resume
54
-
55
- - "screen_capture_timeline"
56
- - Capture PETSCII text screen at fixed intervals, producing a time-stamped log and optional GIF assembled from frames (agent-side).
57
- - Agent state: timer, frame store, export settings.
58
- - REST: GET /v1/machine:readmem (via screen helper), or use MCP read_screen; optional PUT /v1/machine:pause|resume
59
-
60
- - "sprite_preview_prg_batch"
61
- - For many sprite binaries, generate and run preview PRGs back-to-back; snapshot screen between runs.
62
- - Agent state: job queue, per-item results, failures.
63
- - REST: POST /v1/runners:run_prg, GET /v1/machine:readmem (screen), PUT /v1/machine:reset
64
-
65
- ### Program execution and orchestration
66
-
67
- - "program_shuffle"
68
- - Discover PRG/CRT under a root path, run each for a configurable duration, capture screen, then soft reset and continue.
69
- - Agent state: iterator cursor, per-program artifacts, time budgets, failure handling.
70
- - REST: PUT /v1/runners:run_prg, PUT /v1/runners:run_crt, PUT /v1/machine:reset, GET /v1/machine:readmem, GET /v1/files/{path}:info
71
-
72
- - "batch_run_with_assertions"
73
- - Run a list of programs with post-conditions (screen contains text, memory byte equals value, SID silent); abort on first failure or continue-on-error.
74
- - Agent state: assertions, pass/fail log, junit-like report.
75
- - REST: PUT /v1/runners:run_prg or :run_crt, GET /v1/machine:readmem, GET /v1/machine:debugreg, optional PUT /v1/machine:pause|resume|reset
76
-
77
- - "compile_run_verify_cycle"
78
- - Assemble/compile source (BASIC/ASM/SIDWAVE), run, then verify via screen and/or audio analysis; archive artifacts.
79
- - Agent state: build outputs, verification records.
80
- - REST: POST /v1/runners:run_prg (uploaded PRG), GET /v1/machine:readmem; SID path uses POST /v1/runners:sidplay
81
-
82
- - "cold_boot_and_run"
83
- - Firmware reboot, then run target; used to validate cold-start behavior.
84
- - Agent state: boot timing, outcomes.
85
- - REST: PUT /v1/machine:reboot, PUT /v1/runners:run_prg or :run_crt
86
-
87
- ### Background scheduling and automation
88
-
89
- - "start_background_task"
90
- - Start a named background task that invokes a tool (e.g., `c64_memory` `read`, `read_screen`, `sid_note_on`) at a fixed interval for N iterations or indefinitely.
91
- - Agent state: task registry (id, name, schedule, next-run, last error), persistent across session.
92
- - REST: Depends on scheduled tool; common: GET /v1/machine:readmem, PUT|POST /v1/machine:writemem, PUT /v1/runners:run_prg, etc.
93
-
94
- - "stop_background_task"
95
- - Stop a task by name/id; supports graceful drain.
96
- - Agent state: registry update.
97
- - REST: none (meta only)
98
-
99
- - "list_background_tasks"
100
- - List active and recent tasks with status and next fire time.
101
- - Agent state: registry enumeration.
102
- - REST: none (meta only)
103
-
104
- - "stop_all_background_tasks"
105
- - Cancel all active tasks.
106
- - Agent state: registry update.
107
- - REST: none (meta only)
108
-
109
- ### Storage, drives, and filesystem recipes
110
-
111
- - "drive_mount_and_verify"
112
- - Mount an image, power-on if needed, reset drive, and verify state via drive list.
113
- - Agent state: retries, final mode, verification snapshot.
114
- - REST: PUT /v1/drives/{drive}:on, PUT /v1/drives/{drive}:mount, PUT /v1/drives/{drive}:reset, GET /v1/drives
115
-
116
- - "create_and_mount_blank_d64"
117
- - Create a blank D64 at path, mount it, and optionally run a BASIC program to write a directory header.
118
- - Agent state: created image metadata.
119
- - REST: PUT /v1/files/{path}:create_d64, PUT /v1/drives/{drive}:mount
120
-
121
- - "batch_on_assets_apply_tools"
122
- - For all PRG/CRT/D64 under a root path (wildcards), apply a named sequence of tools with templated args.
123
- - Agent state: recipe registry, per-asset logs, concurrency window.
124
- - REST: GET /v1/files/{path}:info (wildcards), PUT /v1/runners:run_prg|:run_crt, PUT /v1/drives/{drive}:mount
125
-
126
- - "drive_mode_profile_switch"
127
- - Set drive to 1541/1571/1581, reset, and verify; optional ROM load before switching.
128
- - Agent state: selected profile, last mode.
129
- - REST: PUT /v1/drives/{drive}:load_rom, PUT /v1/drives/{drive}:set_mode, PUT /v1/drives/{drive}:reset
130
-
131
- - "eject_and_poweroff_drive"
132
- - Remove image and power off selected drive slot.
133
- - Agent state: last known image, slot state.
134
- - REST: PUT /v1/drives/{drive}:remove, PUT /v1/drives/{drive}:off
135
-
136
- ### Filesystem discovery and deduplication
137
-
138
- Container-aware traversal: All tools in this group recurse into disk/tape containers (`.d64/.d71/.d81/.dnp/.t64`) and operate on their internal directory entries, not just the host filesystem. When container introspection is not available via REST, tools fall back to mounting the image and scraping the CBM directory via BASIC.
139
-
140
- - "find_and_run_program_by_name"
141
- - Search under a root (including inside `.d64/.d71/.d81/.t64`) for the first program whose filename contains a substring; run it. Supports PRG and CRT, case sensitivity toggle, and optional sort (path order vs. alphabetical).
142
- - Agent state: recent searches (root, pattern, extensions), last run path.
143
- - REST: Container-aware GET /v1/files/{root}/**/*:info (wildcards) to discover; if target is inside a container, mount via PUT /v1/drives/{drive}:mount and run via a tiny BASIC loader (`c64_program`, op `upload_run_basic`) or menu automation; direct PUT /v1/runners:run_prg|:run_crt when file is on the host filesystem.
144
-
145
- - "filesystem_stats_by_extension"
146
- - Walk all files beneath a root—including files inside disk/tape images—and compute counts and size statistics (total, min, max, mean) per extension, with convenience rollups for PRG vs non‑PRG and per‑folder (and per‑container) summaries.
147
- - Agent state: cached directory index, prior stats snapshots for trend comparisons.
148
- - REST: Container-aware GET /v1/files/{root}/**/*:info (wildcards); fallback: mount images and scrape directory via BASIC.
149
-
150
- - "find_paths_by_name"
151
- - Return fully qualified device paths for files whose names contain a substring; optional extension filter and max results. Returns host paths and logical paths inside containers (`<container>#<cbm-path>`).
152
- - Agent state: result caches with TTL and last search parameters.
153
- - REST: Container-aware GET /v1/files/{root}/**/*{substring}*{.{ext}}:info (wildcards)
154
-
155
- - "run_copy_move_delete_by_path"
156
- - Execute a batch of file operations addressed by fully qualified paths. Operations: run (PRG/CRT), copy, move, delete. Supports dry‑run planning and per‑op guards.
157
- - Agent state: audit log of planned/applied ops, allowlist/denylist of roots, optional quarantine path for deletes.
158
- - REST: Run → PUT /v1/runners:run_prg|:run_crt; Copy/Move/Delete → not exposed in current API (host‑side or future firmware endpoints). When unavailable, tool returns a plan and no‑ops unless host mapping is configured.
159
-
160
- - "container_aware_walk_and_classify"
161
- - Recursively walk host paths and container contents; classify each entry as `BASIC`, `PRG-MC`, `SEQ`, `USR`, `REL`, or `UNKNOWN`.
162
- - Agent state: classification cache keyed by content hash and CBM directory entry, per-container manifests.
163
- - REST: Container-aware GET /v1/files/{root}/**/*:info; for BASIC vs PRG‑MC, either (a) read PRG header bytes if `/files:read` is available, or (b) use PUT /v1/runners:load_prg followed by GET /v1/machine:readmem at the file’s load address to inspect tokens; cleanup via PUT /v1/machine:reset.
164
-
165
- - "classify_prg_basic_or_mc"
166
- - For a given PRG path (host or inside a container), determine if it is tokenized BASIC or machine code/data using load address and token checks.
167
- - Agent state: last probe result, token scanner configuration (PAL/NTSC irrelevant here).
168
- - REST: PUT /v1/runners:load_prg (does not run), GET /v1/machine:readmem (few hundred bytes from load address), optional PUT /v1/machine:reset.
169
-
170
- File-Type Determination (CBM directory and PRG content):
171
-
172
- - Step 1: Fetch metadata/listing for host files; detect container types (`.d64/.d71/.d81/.t64`).
173
- - Step 2: For containers, parse directory entries: CBM file type byte at offset $02 (0x02 = SEQ, 0x82 = PRG, etc.) to classify `SEQ/PRG/USR/REL/UNKNOWN`.
174
- - Step 3: If type is `PRG`, inspect first bytes of file data: load address, plausible next-line pointer, and presence of BASIC tokens (≥ $80) before `00 00` (end-of-program marker) → classify as `BASIC`; else `PRG-MC` (machine code).
175
- - Practical note: When byte reads are not supported by firmware for host files, use `load_prg` (non-running) + `readmem` to examine the loaded header without executing.
176
-
177
- - "dedup_scan"
178
- - Discover duplicate files under a root using a tiered strategy: (1) group by size and extension; (2) optional filename normalization; (3) optional content fingerprint when available. Produces groups of candidate duplicates.
179
- - Agent state: size→paths index, optional fingerprint cache, serialized scan manifests.
180
- - REST: GET /v1/files/{root}/**/*:info (wildcards). Note: content hashing requires a future `/files:read` capability; when absent, tool limits to size/name heuristics.
181
-
182
- - "dedup_plan_and_apply"
183
- - From a dedup scan, create a reversible plan that keeps one canonical file per group and quarantines the rest. Apply step moves duplicates into a timestamped quarantine directory; final deletion is an explicit, separate step.
184
- - Agent state: quarantine root, manifest of moved paths, rollback map, retention policy.
185
- - REST: No direct delete/move endpoints today; this tool defaults to dry‑run and plan output. Apply is disabled unless host‑side filesystem integration or future endpoints are configured.
186
- - Safety guards: dry‑run by default; explicit `apply=true` and `confirm_phrase` required; path allowlist; maximum deletions threshold; quarantine with rollback window; never touches outside allowed roots.
187
-
188
- ### SID, music, and audio analysis
189
-
190
- - "sid_param_sweep"
191
- - Sweep ADSR/waveform/pulse width across ranges; schedule notes, capture audio, and score results by analysis.
192
- - Agent state: sweep matrix, top-N results, audio artifacts.
193
- - REST: PUT|POST /v1/machine:writemem (via SID registers), POST /v1/runners:sidplay (for sid attachments), optional streams
194
-
195
- - "music_compile_play_analyze"
196
- - Compile SIDWAVE→PRG or SID, play, then record-and-analyze; export analysis JSON and summary.
197
- - Agent state: compilation cache, expected score, analysis logs.
198
- - REST: POST /v1/runners:run_prg or POST /v1/runners:sidplay
199
-
200
- - "silence_and_verify"
201
- - Silence all voices, then verify via short audio capture that output drops below a threshold.
202
- - Agent state: threshold, capture window.
203
- - REST: PUT|POST /v1/machine:writemem (SID reset), optional streams
204
-
205
- ### Streaming and monitoring
206
-
207
- - "stream_video_for_duration"
208
- - Start video stream to host:port for a fixed duration; stop and record timing.
209
- - Agent state: timer, destination, failure logs.
210
- - REST: PUT /v1/streams/video:start, PUT /v1/streams/video:stop
211
-
212
- - "stream_audio_and_record"
213
- - Start audio stream, run program, keep stream for N seconds, then stop; optionally run analysis afterward.
214
- - Agent state: chained schedule (start→run→stop), record path.
215
- - REST: PUT /v1/streams/audio:start, PUT /v1/streams/audio:stop, PUT /v1/runners:run_prg|:sidplay
216
-
217
- - "debug_stream_watch"
218
- - Start debug stream, collect diagnostic packets, and summarize rates; auto-stop on idle.
219
- - Agent state: packet counters, idle detection.
220
- - REST: PUT /v1/streams/debug:start, PUT /v1/streams/debug:stop
221
-
222
- #### Debug stream–based feedback loops
223
-
224
- - "debug_loop_run_and_capture"
225
- - Pause → start debug stream → resume → perform action (tool callback) → wait window or until condition → pause → stop stream → parse and summarize packets.
226
- - Agent state: host:port, selected mode (6510/VIC/1541), rolling buffer, filters (address ranges, R/W, device), last summary.
227
- - REST: PUT /v1/machine:pause, PUT /v1/streams/debug:start, PUT /v1/machine:resume, [action tool], PUT /v1/machine:pause, PUT /v1/streams/debug:stop
228
- - Safety: refuse when video stream is active; enforce max duration; auto-stop on packet loss; configurable throttling.
229
-
230
- - "debug_trace_until_cpu_write"
231
- - Run until a CPU write to an address (or set) is observed; then immediately pause and return a short trace window around the event.
232
- - Agent state: address watch set, pre/post window sizes, event metadata.
233
- - REST: PUT /v1/machine:pause, PUT /v1/streams/debug:start, PUT /v1/machine:resume, PUT /v1/machine:pause, PUT /v1/streams/debug:stop
234
-
235
- - "verify_irq_jitter"
236
- - Measure IRQ handler periodicity by detecting writes to $D019 (IRQ ack) or reads/writes around vector/$0314; compute intervals and jitter vs. threshold.
237
- - Agent state: target addresses, acceptable jitter, histogram of deltas.
238
- - REST: PUT /v1/machine:pause|resume, PUT /v1/streams/debug:start|stop
239
-
240
- - "verify_raster_irq_line"
241
- - Verify raster IRQ is programmed to a specific line by correlating writes to $D012/$D011 and ensuing IRQ acks; report mismatches.
242
- - Agent state: expected lines, tolerance for off-by-one conditions.
243
- - REST: PUT /v1/machine:pause|resume, PUT /v1/streams/debug:start|stop
244
-
245
- - "iec_bus_handshake_probe"
246
- - Use 1541 debug mode to capture ATN/CLOCK/DATA activity during a load/save; verify protocol phases and timings.
247
- - Agent state: phase detector, timing thresholds, pass/fail report.
248
- - REST: PUT /v1/machine:pause|resume, PUT /v1/streams/debug:start|stop (1541 mode), optional PUT /v1/runners:load_prg|:run_prg
249
-
250
- - "sid_register_write_profile"
251
- - Capture and summarize writes to $D400–$D418 (SID) to verify gates, ADSR and waveform updates; report per-voice rates and anomalies.
252
- - Agent state: address filters, per-register counters, time-bucketed stats.
253
- - REST: PUT /v1/machine:pause|resume, PUT /v1/streams/debug:start|stop
254
-
255
- - "action_latency_measure"
256
- - Measure cycles between issuing an action (e.g., menu_button, `c64_memory` `write`) and the first observed matching bus event; return cycle/µs estimate.
257
- - Agent state: action timestamp, first-match timestamp, CPU clock assumption (PAL/NTSC option).
258
- - REST: PUT /v1/machine:pause|resume, PUT /v1/streams/debug:start|stop, PUT /v1/machine:menu_button|:writemem|runners
259
-
260
- - "time_bounded_trace_around_event"
261
- - Maintain a circular buffer of debug entries and freeze it when a predicate matches (address, R/W, data mask); export the pre/post window.
262
- - Agent state: predicate, buffer size, captured window.
263
- - REST: PUT /v1/machine:pause|resume, PUT /v1/streams/debug:start|stop
264
-
265
- Notes:
266
-
267
- - Debug stream consumes significant bandwidth and cannot run concurrently with video; tools enforce mutual exclusion and strict time limits.
268
- - Modes supported: 6510, VIC, 6510&VIC, 1541, 6510&1541. Tools select minimal necessary mode for the predicate to reduce load.
269
-
270
- ### Configuration and diagnostics bundles
271
-
272
- - "config_snapshot_and_restore"
273
- - Read all categories, persist a JSON snapshot; restore later via batch update.
274
- - Agent state: snapshot store (versioned), diff reports.
275
- - REST: GET /v1/configs, GET /v1/configs/{category}, POST /v1/configs (batch), PUT /v1/configs:save_to_flash|:load_from_flash
276
-
277
- - "firmware_info_and_healthcheck"
278
- - Fetch version and info, run zero-page read probe, and produce a readiness report.
279
- - Agent state: probe outcomes, latency metrics.
280
- - REST: GET /v1/version, GET /v1/info, GET /v1/machine:readmem
281
-
282
- - "safe_reset_sequence"
283
- - Pause, snapshot select RAM ranges, soft reset, verify ranges known to persist (or not), and resume.
284
- - Agent state: before/after snapshots, persistence metrics.
285
- - REST: PUT /v1/machine:pause, GET /v1/machine:readmem, PUT /v1/machine:reset, PUT /v1/machine:resume
286
-
287
- ### High-level screen and UI assertions
288
-
289
- - "wait_for_screen_text"
290
- - Poll screen until a regex/text appears or timeout; return matched region and timestamp.
291
- - Agent state: screen sampling schedule, regex cache.
292
- - REST: GET /v1/machine:readmem (screen RAM)
293
-
294
- - "menu_navigation_script"
295
- - Send menu button toggles with delays, capturing screens between steps; export a chronicle.
296
- - Agent state: scripted steps, captures.
297
- - REST: PUT /v1/machine:menu_button, GET /v1/machine:readmem
298
-
299
- ### Developer loops and QA harnesses
300
-
301
- - "red_green_refactor_loop"
302
- - Run program → capture screen → apply `c64_memory` `write` fixups → rerun and compare; stop when assertion passes.
303
- - Agent state: assertion, iteration counter, diffs.
304
- - REST: PUT /v1/runners:run_prg, GET /v1/machine:readmem, PUT|POST /v1/machine:writemem, PUT /v1/machine:reset
305
-
306
- - "multi_range_guardrails"
307
- - Enforce invariant constraints across several memory regions (e.g., IRQ vector unchanged); if violated, auto-restore from snapshot.
308
- - Agent state: invariant set, restore buffers.
309
- - REST: GET /v1/machine:readmem, PUT|POST /v1/machine:writemem
310
-
311
- - "drive_recovery_sequence"
312
- - Detect drive error, then reset, power cycle, remount last image, and verify.
313
- - Agent state: last-known drive config, retries, backoff.
314
- - REST: PUT /v1/drives/{drive}:reset, PUT /v1/drives/{drive}:off, PUT /v1/drives/{drive}:on, PUT /v1/drives/{drive}:mount, GET /v1/drives
315
-
316
- ### RAG-coupled meta tools (knowledge + action)
317
-
318
- - "ask_and_apply_memory_fix"
319
- - Retrieve assembly guidance (RAG), compute targeted writes, then apply verify_and_write_memory.
320
- - Agent state: retrieved refs, decision trace, applied edits.
321
- - REST: GET /v1/machine:readmem, PUT|POST /v1/machine:writemem
322
-
323
- - "sprite_program_from_prompt"
324
- - Generate PETSCII/sprite from text prompt, upload preview PRG, and capture screen for report.
325
- - Agent state: prompt, generated assets, screen capture.
326
- - REST: POST /v1/runners:run_prg, GET /v1/machine:readmem
327
-
328
- ### Artifact pipelines (exports and reports)
329
-
330
- - "export_directory_listing_via_basic"
331
- - Run a tiny BASIC that prints disk directory; scrape screen pages into a single directory listing, write to disk.
332
- - Agent state: pagination state, parsed entries.
333
- - REST: PUT /v1/runners:run_prg, GET /v1/machine:readmem
334
-
335
- - "bundle_run_artifacts"
336
- - For any run, collect screen capture, memory snapshot, debugreg, and tool logs into a single folder/tarball.
337
- - Agent state: run session id, paths.
338
- - REST: GET /v1/machine:readmem, GET /v1/machine:debugreg
339
-
340
- ---
341
-
342
- ## Additional ideas (brief)
343
-
344
- - "memory_heatmap_over_time": periodical reads of ranges, visualize write frequency (GET /v1/machine:readmem).
345
- - "irq_latency_probe": run tiny PRG that toggles debug/colour and sample with debug stream; compute jitter (streams + run_prg).
346
- - "sid_voice_stuck_guard": watchdog that issues sid_note_off for lingering gates (writemem to SID regs).
347
- - "auto_benchmark_suite": run set of PRGs with timing reads from zero-page timers (run_prg + readmem).
348
- - "firmware_compat_matrix": try features and record which endpoints function on current hardware (GET/PUT variety).
349
- - "ultimate_config_migrate": snapshot on device A and batch apply to device B (GET /v1/configs, POST /v1/configs).
350
-
351
- ---
352
-
353
- ## Notes on composition with existing MCP tools
354
-
355
- These meta tools build atop existing MCP tools which already wrap the REST surface:
356
-
357
- - Memory: `c64_memory` (operations: `read`, `write`, `read_screen`, `wait_for_text`)
358
- - Programs: `c64_program` (operations: `upload_run_basic`, `upload_run_asm`, `run_prg`, `load_prg`, `run_crt`, `batch_run`, `bundle_run`)
359
- - Machine control: `c64_system` (operations: `pause`, `resume`, `reset`, `reboot`, `poweroff`, `menu`, `start_task`, `stop_task`, `stop_all_tasks`, `list_tasks`)
360
- - Storage: `c64_disk` (operations: `list_drives`, `mount`, `unmount`, `file_info`, `create_image`, `find_and_run`) and `c64_drive` (operations: `reset`, `power_on`, `power_off`, `set_mode`, `load_rom`)
361
- - Audio/SID: `c64_sound` (ops `set_volume`, `reset`, `note_on`, `note_off`, `silence_all`, `play_sid_file`, `play_mod_file`, `generate`, `compile_play`, `pipeline`, `record_analyze`, `analyze`)
362
- - Streaming: `c64_stream` (ops `start`, `stop`)
363
- - Developer/Config: `c64_config` (ops `list`, `get`, `set`, `batch_update`, `load_flash`, `save_flash`, `reset_defaults`, `read_debugreg`, `write_debugreg`, `info`, `version`, `snapshot`, `restore`, `diff`, `shuffle`)
364
-
365
- By bundling these into single, parameterized meta tools with agent-side scheduling and state, the agent can execute complex workflows with one invocation, reducing latency and improving determinism.
366
-
367
- ---
368
-
369
- ### Effort/Benefit/Dependencies Matrix
370
-
371
- | Tool | Effort (min) | Benefit | Dependencies |
372
- |---|---:|---|---|
373
- | memory_dump_to_file | 45 | medium | none |
374
- | memory_snapshot_and_diff | 50 | high | memory_dump_to_file |
375
- | verify_and_write_memory | 35 | high | none |
376
- | watch_memory_until_condition | 40 | medium | none |
377
- | disassemble_ram_region | 60 | medium | none |
378
- | trace_code_flow_by_checksums | 75 | medium | memory_snapshot_and_diff |
379
- | extract_sprites_from_ram | 80 | medium | memory_dump_to_file |
380
- | rip_charset_from_ram | 75 | medium | memory_dump_to_file |
381
- | screen_capture_timeline | 50 | medium | wait_for_screen_text |
382
- | sprite_preview_prg_batch | 60 | medium | program_shuffle |
383
- | program_shuffle | 45 | medium | wait_for_screen_text |
384
- | batch_run_with_assertions | 60 | high | wait_for_screen_text |
385
- | compile_run_verify_cycle | 90 | high | batch_run_with_assertions, bundle_run_artifacts |
386
- | cold_boot_and_run | 40 | medium | firmware_info_and_healthcheck |
387
- | start_background_task | 50 | high | none |
388
- | stop_background_task | 15 | high | start_background_task |
389
- | list_background_tasks | 20 | medium | start_background_task |
390
- | stop_all_background_tasks | 15 | medium | start_background_task |
391
- | drive_mount_and_verify | 45 | medium | firmware_info_and_healthcheck |
392
- | create_and_mount_blank_d64 | 35 | medium | drive_mount_and_verify |
393
- | batch_on_assets_apply_tools | 70 | medium | find_paths_by_name |
394
- | drive_mode_profile_switch | 40 | low | drive_mount_and_verify |
395
- | eject_and_poweroff_drive | 25 | low | drive_mount_and_verify |
396
- | find_and_run_program_by_name | 45 | high | find_paths_by_name |
397
- | filesystem_stats_by_extension | 35 | medium | none |
398
- | find_paths_by_name | 40 | high | none |
399
- | run_copy_move_delete_by_path | 50 | medium | find_paths_by_name |
400
- | container_aware_walk_and_classify | 60 | medium | find_paths_by_name |
401
- | classify_prg_basic_or_mc | 45 | medium | container_aware_walk_and_classify |
402
- | dedup_scan | 60 | medium | filesystem_stats_by_extension |
403
- | dedup_plan_and_apply | 75 | medium | dedup_scan |
404
- | sid_param_sweep | 90 | medium | silence_and_verify |
405
- | music_compile_play_analyze | 90 | high | silence_and_verify |
406
- | silence_and_verify | 35 | high | none |
407
- | stream_video_for_duration | 40 | medium | none |
408
- | stream_audio_and_record | 50 | medium | none |
409
- | debug_stream_watch | 55 | medium | none |
410
- | debug_loop_run_and_capture | 80 | high | debug_stream_watch |
411
- | debug_trace_until_cpu_write | 70 | high | debug_loop_run_and_capture |
412
- | verify_irq_jitter | 70 | medium | debug_loop_run_and_capture |
413
- | verify_raster_irq_line | 70 | high | debug_loop_run_and_capture |
414
- | iec_bus_handshake_probe | 85 | medium | debug_loop_run_and_capture |
415
- | sid_register_write_profile | 70 | medium | debug_loop_run_and_capture |
416
- | action_latency_measure | 75 | medium | debug_loop_run_and_capture |
417
- | time_bounded_trace_around_event | 70 | medium | debug_loop_run_and_capture |
418
- | config_snapshot_and_restore | 60 | medium | none |
419
- | firmware_info_and_healthcheck | 30 | high | none |
420
- | safe_reset_sequence | 45 | medium | firmware_info_and_healthcheck |
421
- | wait_for_screen_text | 35 | high | none |
422
- | menu_navigation_script | 45 | medium | wait_for_screen_text |
423
- | red_green_refactor_loop | 70 | high | verify_and_write_memory, wait_for_screen_text |
424
- | multi_range_guardrails | 80 | medium | verify_and_write_memory, memory_snapshot_and_diff |
425
- | drive_recovery_sequence | 60 | medium | drive_mount_and_verify |
426
- | ask_and_apply_memory_fix | 65 | high | verify_and_write_memory |
427
- | sprite_program_from_prompt | 75 | medium | sprite_preview_prg_batch |
428
- | export_directory_listing_via_basic | 45 | medium | wait_for_screen_text |
429
- | bundle_run_artifacts | 50 | high | memory_snapshot_and_diff, wait_for_screen_text |
430
- | memory_heatmap_over_time | 60 | medium | watch_memory_until_condition |
431
- | irq_latency_probe | 70 | medium | debug_stream_watch |
432
- | sid_voice_stuck_guard | 45 | medium | silence_and_verify |
433
- | auto_benchmark_suite | 80 | medium | program_shuffle, batch_run_with_assertions |
434
- | firmware_compat_matrix | 60 | medium | firmware_info_and_healthcheck |
435
- | ultimate_config_migrate | 75 | medium | config_snapshot_and_restore |
@@ -1,192 +0,0 @@
1
- # Meta Tools Implementation Notes
2
-
3
- This document tracks observations, decisions, and learnings from the meta tools rollout.
4
-
5
- ## Overview
6
-
7
- Meta tools are high-level orchestration tools that compose multiple MCP operations into single, stateful workflows. They reduce round-trips between client and server and enable complex agent behaviors.
8
-
9
- ## Current State (as of 2025-10-30)
10
-
11
- ### Implemented Tools (12)
12
-
13
- - Phase 0 foundations: firmware_info_and_healthcheck, wait_for_screen_text, verify_and_write_memory, background task suite, find_paths_by_name, memory_dump_to_file, config_snapshot_and_restore
14
- - Phase 1 orchestration: program_shuffle, batch_run_with_assertions, bundle_run_artifacts, compile_run_verify_cycle
15
- - Phase 2 quick wins: find_and_run_program_by_name, silence_and_verify, filesystem_stats_by_extension
16
-
17
- ### File Organization
18
-
19
- - Source: `src/tools/meta/` with submodules by domain (diagnostics, screen, memory, background, filesystem, config, program, artifacts, compilation)
20
- - Tests: Integrated into existing test suites, no dedicated meta/ test folder yet
21
- - Docs: **Reorganized into `doc/meta-tools/`** (matching improve-knowledge pattern)
22
-
23
- ## Documentation Structure
24
-
25
- Following the improve-knowledge precedent:
26
-
27
- ```text
28
- doc/meta-tools/
29
- ├── catalog.md (formerly meta-tools.md — comprehensive tool definitions)
30
- ├── rollout.md (formerly meta-tools-rollout.md — implementation checklist)
31
- ├── analysis.md (NEW — impact analysis and prioritization)
32
- └── notes.md (this file — observations and decisions)
33
- ```
34
-
35
- Benefits:
36
-
37
- - Cleaner doc/ root folder
38
- - Related documents grouped together
39
- - Easier to find meta tools documentation
40
- - Consistent with improve-knowledge structure
41
-
42
- ## Prioritization Rationale
43
-
44
- ### Why Reprioritize?
45
-
46
- Original rollout followed dependency order and implementation phases. However, based on actual agent usage patterns, some unimplemented tools would provide much higher value:
47
-
48
- 1. **Filesystem discovery** — Agents frequently struggle to find programs in disk collections
49
- 2. **SID testing** — Current music workflows lack proper silence verification
50
- 3. **Graphics extraction** — Users want to analyze and reuse sprites/charsets from programs
51
- 4. **Debug streaming** — Highly valuable but requires significant infrastructure
52
-
53
- ### Decision: High-Impact, Low-Effort First
54
-
55
- New approach prioritizes:
56
-
57
- - Quick wins (35-45 minute tools with high impact)
58
- - Foundation tools that enable agent creativity (find programs, compose music)
59
- - Tools with clear, testable outcomes
60
- - Deferring infrastructure-heavy work (debug streaming)
61
-
62
- See `analysis.md` for detailed impact breakdown.
63
-
64
- ## Implementation Patterns
65
-
66
- ### Meta Tool Anatomy
67
-
68
- Each meta tool typically:
69
-
70
- 1. **Composes** existing MCP tools (no direct REST calls when possible)
71
- 2. **Maintains state** agent-side (snapshots, buffers, registries)
72
- 3. **Provides retry logic** and error recovery
73
- 4. **Returns structured results** with metadata and URIs
74
- 5. **Respects hardware safeguards** (pause/resume, timeouts, mutual exclusion)
75
-
76
- ### Testing Strategy
77
-
78
- - Unit tests for tool logic (parameter validation, error handling)
79
- - Integration tests with mock C64Client
80
- - No hardware required for CI/CD
81
- - Real hardware testing manual (for now)
82
-
83
- ### Documentation Requirements
84
-
85
- For each implemented tool:
86
-
87
- - [ ] Entry in `catalog.md` with full specification
88
- - [ ] Checkbox in `rollout.md` marked complete
89
- - [ ] Tests covering happy path and one failure case
90
- - [ ] Usage examples in tool description
91
- - [ ] Dependencies clearly documented
92
-
93
- ## Technical Decisions
94
-
95
- ### Background Tasks Registry
96
-
97
- **Decision**: In-memory registry with optional persistence to disk
98
-
99
- **Rationale**: Simplicity for MVP; disk persistence can be added later if needed
100
-
101
- **Trade-offs**: Tasks lost on restart, but acceptable for experimental features
102
-
103
- ### Container-Aware Filesystem Tools
104
-
105
- **Decision**: Implement discovery that recurses into D64/D71/D81/T64 containers
106
-
107
- **Rationale**: C64 programs are often stored in disk images, not loose files
108
-
109
- **Implementation**: Use wildcards when firmware supports them; fall back to mount+BASIC scraping when necessary
110
-
111
- ### Debug Streaming Infrastructure
112
-
113
- **Decision**: Defer all debug streaming tools to Post-GA
114
-
115
- **Rationale**: Requires UDP ingest, backpressure handling, performance validation (~72 hours of infrastructure work)
116
-
117
- **Alternative considered**: Implement basic version with TCP — rejected because packet loss handling is essential
118
-
119
- **Next steps**: Plan dedicated infrastructure sprint before tackling Phase 5 debug tools
120
-
121
- ### Meta Tool File Layout
122
-
123
- **Decision**: Keep meta tools in `src/tools/meta/` submodule structure
124
-
125
- **Rationale**:
126
-
127
- - Clear separation from core tools
128
- - Easy to mark as experimental/beta
129
- - Modular structure by domain (diagnostics, screen, memory, etc.)
130
- - No impact on MCP tool registration (all tools exposed equally)
131
-
132
- **Trade-offs**: Slightly deeper import paths, but better organization
133
-
134
- ## Lessons Learned
135
-
136
- ### From Phase 0-1 Implementation
137
-
138
- 1. **Background tasks are versatile** — Can schedule any tool, not just specific operations
139
- 2. **Verification patterns reusable** — verify_and_write_memory pattern applies to many tools
140
- 3. **Screen polling essential** — wait_for_screen_text foundation for many workflows
141
- 4. **Artifacts bundling popular** — bundle_run_artifacts frequently requested by users
142
-
143
- ### From Impact Analysis
144
-
145
- 1. **Filesystem navigation is critical** — Most common agent failure: "I can't find that program"
146
- 2. **SID testing needs improvement** — Silence verification missing causes flaky tests
147
- 3. **Debug streaming is desirable but complex** — High demand, but infrastructure not ready
148
- 4. **Graphics tools have broad appeal** — Sprite/charset extraction enables creative reuse
149
-
150
- ## Future Considerations
151
-
152
- ### Potential Improvements
153
-
154
- 1. **Meta tool composition** — Allow meta tools to call other meta tools
155
- 2. **Persistent background tasks** — Survive server restarts
156
- 3. **Progress callbacks** — Report progress during long-running operations
157
- 4. **Cancellation** — Abort in-progress meta tools gracefully
158
- 5. **Dry-run mode** — Preview actions without executing (especially for destructive ops)
159
-
160
- ### Infrastructure Needs
161
-
162
- For debug streaming (Phase 5):
163
-
164
- - UDP packet receiver with reassembly
165
- - Backpressure and flow control
166
- - Circular buffer for trace windows
167
- - Packet loss detection and reporting
168
- - Performance benchmarks and load tests
169
- - Observability (metrics, logging, tracing)
170
-
171
- ### Documentation Gaps
172
-
173
- - No architecture diagram for meta tool system
174
- - Limited examples of meta tool composition patterns
175
- - No performance guidelines (when to avoid meta tools)
176
- - Testing best practices not documented
177
-
178
- ## Open Questions
179
-
180
- 1. **Should meta tools be separately versioned?** Currently experimental, but what's the graduation criteria?
181
- 2. **How to handle breaking changes?** Meta tools compose other tools — cascade impacts?
182
- 3. **Rate limiting?** Some meta tools could issue many requests — need throttling?
183
- 4. **Observability?** How to monitor meta tool usage and performance in production?
184
-
185
- ## References
186
-
187
- - `catalog.md` — Full meta tool definitions with effort/benefit matrix
188
- - `rollout.md` — Implementation checklist with dependencies
189
- - `analysis.md` — Impact analysis and prioritization rationale
190
- - `doc/improve-knowledge/` — Similar documentation structure pattern
191
- - `doc/agent-state-spec.md` — Background task registry specification
192
- - `src/tools/meta/` — Implementation source code