@henols/vice-mcp 0.2.1 → 0.2.3

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 (108) hide show
  1. package/README.md +4 -3
  2. package/THIRD-PARTY-NOTICES.md +423 -25
  3. package/{r2000-acme-ident.ts → anno-acme-ident.ts} +13 -13
  4. package/anno-bank.ts +171 -0
  5. package/anno-cli.ts +3040 -0
  6. package/{r2000-confidence.ts → anno-confidence.ts} +22 -22
  7. package/anno-coverage.ts +2465 -0
  8. package/anno-derive.ts +590 -0
  9. package/anno-details.ts +169 -0
  10. package/anno-enum-gen.ts +919 -0
  11. package/anno-export-asm.ts +2396 -0
  12. package/anno-graphics.ts +338 -0
  13. package/anno-hazard-report.ts +1367 -0
  14. package/anno-import.ts +495 -0
  15. package/anno-index.ts +150 -0
  16. package/anno-join.ts +480 -0
  17. package/{r2000-memmap-render.ts → anno-memmap-render.ts} +236 -95
  18. package/anno-provenance-ledger.ts +472 -0
  19. package/{r2000-regbits-gen.ts → anno-regbits-gen.ts} +20 -15
  20. package/{r2000-regbits.json → anno-regbits.json} +2 -2
  21. package/anno-register.ts +399 -0
  22. package/anno-store-export.ts +661 -0
  23. package/anno-store.ts +4002 -0
  24. package/anno-symbols.ts +266 -0
  25. package/anno-tools.ts +3264 -0
  26. package/anno-types.ts +1909 -0
  27. package/backend-detect.mts +124 -312
  28. package/block-class.ts +201 -0
  29. package/build.ts +4 -2
  30. package/capture-predicate.ts +597 -0
  31. package/channel-lock.ts +349 -0
  32. package/disasm-decoder.ts +14 -14
  33. package/disasm-opcodes.ts +4 -4
  34. package/disasm-renderer.ts +2 -2
  35. package/evid-ingest.ts +217 -0
  36. package/evid-reconcile.ts +316 -0
  37. package/host-tool-client.ts +430 -0
  38. package/hostpath.ts +1 -1
  39. package/incident-record.ts +23 -12
  40. package/install-resources.ts +30 -14
  41. package/memmap-lookup.ts +285 -0
  42. package/package.json +48 -23
  43. package/prg-image.ts +118 -0
  44. package/repo-root.ts +107 -8
  45. package/resources/backend-detect.mjs +98 -236
  46. package/resources/broker-control.mjs +189 -16
  47. package/resources/broker-epoch.mjs +1 -1
  48. package/resources/broker-kill.mjs +8 -2
  49. package/resources/broker-launch.mjs +373 -214
  50. package/resources/broker-state.mjs +64 -18
  51. package/resources/container-guard.mjs +1 -1
  52. package/resources/ghidra-project.mjs +790 -0
  53. package/resources/host-tool.mjs +2561 -0
  54. package/resources/vice-broker.mjs +330 -184
  55. package/resources/vice-launcher.sh +130 -12
  56. package/stock-address.ts +6 -6
  57. package/stock-cia.ts +2 -2
  58. package/stock-condition.ts +8 -8
  59. package/stock-connect.ts +10 -6
  60. package/stock-derived.ts +29 -37
  61. package/stock-diagnose.ts +200 -36
  62. package/stock-dispatch.ts +200 -68
  63. package/stock-execution.ts +5 -3
  64. package/stock-handler.ts +1 -1
  65. package/stock-input.ts +9 -9
  66. package/stock-machine.ts +17 -6
  67. package/stock-paths.ts +18 -14
  68. package/stock-petscii.ts +1 -1
  69. package/stock-protocol.ts +17 -12
  70. package/stock-recycle.ts +83 -2
  71. package/stock-registers.ts +54 -29
  72. package/stock-reproducible-run.ts +811 -0
  73. package/stock-run-until.ts +100 -1
  74. package/stock-sprites.ts +3 -3
  75. package/stock-symbols.ts +13 -13
  76. package/stock-timing.ts +2 -2
  77. package/stock-vicii.ts +1 -1
  78. package/stop-oracle.ts +167 -0
  79. package/text-capability-probe.ts +660 -0
  80. package/text-connect.ts +157 -0
  81. package/text-protocol.ts +810 -0
  82. package/text-tools.ts +778 -0
  83. package/textmon-backtrace.ts +385 -0
  84. package/textmon-cpuhistory.ts +335 -0
  85. package/textmon-memmap.ts +494 -0
  86. package/textmon-profile.ts +458 -0
  87. package/textmon-registers.ts +748 -0
  88. package/tools-manifest.stock.json +864 -3
  89. package/version.ts +1 -1
  90. package/vice-broker-client.ts +189 -42
  91. package/vice-errors.ts +268 -0
  92. package/vice-proxy.ts +392 -2175
  93. package/vsf-slice.ts +640 -0
  94. package/capability-registry.ts +0 -388
  95. package/r2000-cli.ts +0 -1103
  96. package/r2000-d64.ts +0 -310
  97. package/r2000-enum-gen.ts +0 -574
  98. package/r2000-launch.ts +0 -357
  99. package/r2000-mcp-client.ts +0 -596
  100. package/r2000-project.ts +0 -190
  101. package/r2000-symbols.ts +0 -388
  102. package/r2000-tools.ts +0 -914
  103. package/r2000-verify.ts +0 -184
  104. package/refresh-manifest.ts +0 -124
  105. package/tools-manifest.json +0 -1223
  106. package/vice-probe.ts +0 -278
  107. package/vice-sync.ts +0 -336
  108. package/vice.ts +0 -772
@@ -1,388 +0,0 @@
1
- // capability-registry.ts
2
- //
3
- // WHY THIS FILE EXISTS (BACK-05): today, a tool name the ACTIVE backend does
4
- // not advertise falls straight through vice-proxy.ts's CallToolRequestSchema
5
- // override to its generic `Unknown tool: ${name}` fallback -- the exact same
6
- // message a genuine typo gets. That is indistinguishable and unhelpful: a
7
- // caller cannot tell "you misspelled this" from "this tool exists, but only
8
- // on the other backend, for this specific reason." This module is the ONE
9
- // authoritative place holding that per-backend capability data -- names,
10
- // reason categories, reason text, and which backend actually provides each
11
- // one -- so a future call site (the runtime refusal wired in plan 08-02, the
12
- // generated support table in plan 08-03, the skill-text lint in plan 08-04)
13
- // reads exactly one source rather than re-deriving or hand-copying it.
14
- //
15
- // WHAT NOT TO DO: do not hand-maintain a second copy of this data anywhere
16
- // else in the repo (D-E; see CLAUDE.md's "re-deriving a cross-cutting seam
17
- // locally" anti-pattern). If a consumer needs this data in a different
18
- // shape, import CAPABILITY_REGISTRY and reshape it there -- never re-type
19
- // the 26 entries or their reasons from memory.
20
- //
21
- // SECURITY POSTURE: this module is a READ-ONLY MESSAGE-TEXT LOOKUP and is
22
- // NEVER an authorization boundary. DENY_LIST (vice.ts) remains the only
23
- // refusal in this tree that is a security control; that check runs first, at
24
- // every call site, and this module never overrides or duplicates it. Every
25
- // string held here is already public: it names only information already
26
- // published in docs/stock-vice-parity.md and this public repository -- no
27
- // credential, no secret, no host, no port, no path, and no tool name that is
28
- // not already present in one of the two shipped manifests
29
- // (tools-manifest.json, tools-manifest.stock.json).
30
- //
31
- // This is the exact shape vice.ts's DENY_LIST / denyListRefusalMessage()
32
- // already established: one exported readonly array, one exported
33
- // message-rendering function, keyed by hazard/reason shape rather than one
34
- // wording reused for every entry -- because telling a caller the wrong
35
- // reason shape for what is otherwise the same permanent refusal invites a
36
- // pointless retry (that function's own doc comment makes the identical
37
- // point).
38
- //
39
- // EXCLUDED, DELIBERATELY (see docs/stock-vice-parity.md and
40
- // 08-RESEARCH.md's "Capability Delta Registry"):
41
- // - "vice_diagnose" and "vice_recycle" are NOT capability gaps: they are
42
- // synthetic, proxy-local tools registered on BOTH backends by
43
- // vice-proxy.ts's buildBackendAwareTool()/resolveAdvertisedToolDefinition()
44
- // synthetic-registration call sites, never listed in either raw manifest
45
- // JSON file. A naive set-difference over the two manifests misclassifies
46
- // them as a divergence; they are not one, and including them here would
47
- // be a factual error, not merely an omission.
48
- // - "initialize", "notifications_initialized", "tools_call", "tools_list"
49
- // are already refused by vice.ts's DENY_LIST, which runs strictly BEFORE
50
- // any capability-registry lookup and owns a different hazard shape
51
- // entirely (confused-deputy bypass, not a missing capability). They must
52
- // keep being owned there, not duplicated here.
53
- //
54
- // This module imports nothing at runtime -- the only import is a type-only
55
- // import of ViceBackend, which is erased by Node's type-stripping -- so it
56
- // has no transport, no filesystem, and no process dependency of its own.
57
- import type { ViceBackend } from "./backend-detect.mts";
58
-
59
- /**
60
- * Three reason categories, matching the distinctions the project's own docs
61
- * already draw (docs/stock-vice-parity.md SS A/B):
62
- * - "hardware": no 1:1 opcode can ever exist because of a hardware or
63
- * firmware property (a write-only register, per-read recomputation, no
64
- * monitor command for a physical line). Permanent; nothing to build.
65
- * - "descoped": theoretically buildable client-side (an opcode or
66
- * equivalent already exists) but cut from v0.2.0 scope because no
67
- * shipped skill calls it.
68
- * - "stock-only-gain": the reverse direction -- stock has a native opcode
69
- * the fork's custom HTTP API never exposed an equivalent RPC for.
70
- */
71
- export type CapabilityCategory = "hardware" | "descoped" | "stock-only-gain";
72
-
73
- /**
74
- * One row of capability data. `providedBy` names the backend that DOES have
75
- * the capability (never the backend refusing it). `reason` is one sentence
76
- * of user-facing prose ending in a full stop -- no planning identifier
77
- * (BACK-05, SKILL-01, DERIV-*, SHOT-*, GAIN-*, "Phase N") belongs in this
78
- * field; those are internal routing annotations, not something a caller
79
- * calling a tool by name should ever see. `alternative`, when present, names
80
- * a concrete route that exists on the OTHER backend today -- omit it rather
81
- * than inventing one where none exists.
82
- */
83
- export interface CapabilityEntry {
84
- name: string;
85
- category: CapabilityCategory;
86
- providedBy: ViceBackend;
87
- reason: string;
88
- alternative?: string;
89
- }
90
-
91
- const KEYBOARD_ALTERNATIVE =
92
- "vice_keyboard_type / vice_keyboard_petscii inject text through the KERNAL keyboard buffer, " +
93
- "and vice_joystick_set covers most in-game input -- but a program polling $DC00/$DC01 directly " +
94
- "will not see buffer injection.";
95
-
96
- /**
97
- * The 26-entry capability delta: every tool one backend advertises that the
98
- * other genuinely does not, after excluding registration artifacts
99
- * (vice_diagnose/vice_recycle) and DENY_LIST's own four meta-tools -- see
100
- * the header comment above and 08-RESEARCH.md's "Capability Delta Registry"
101
- * for the full accounting this array is derived from.
102
- */
103
- export const CAPABILITY_REGISTRY: readonly CapabilityEntry[] = [
104
- // --- hardware (6), providedBy: fork -------------------------------------
105
- {
106
- name: "vice_sid_get_state",
107
- category: "hardware",
108
- providedBy: "fork",
109
- reason:
110
- "SID's $D400-$D418 registers are write-only in hardware, and the binary monitor exposes " +
111
- "no SID read command.",
112
- },
113
- {
114
- name: "vice_keyboard_matrix",
115
- category: "hardware",
116
- providedBy: "fork",
117
- reason:
118
- "The binary monitor's KEYBOARD_FEED (0x72) only injects PETSCII buffer text; the emulator " +
119
- "recomputes CIA port B from its own keyboard array on every read, so there is no wire " +
120
- "command that can drive the raw matrix.",
121
- alternative: KEYBOARD_ALTERNATIVE,
122
- },
123
- {
124
- name: "vice_keyboard_restore",
125
- category: "hardware",
126
- providedBy: "fork",
127
- reason:
128
- "RESTORE pulses the NMI line directly; it is not part of the keyboard matrix, and " +
129
- "KEYBOARD_FEED has no way to produce it.",
130
- alternative: KEYBOARD_ALTERNATIVE,
131
- },
132
- {
133
- name: "vice_keyboard_chord",
134
- category: "hardware",
135
- providedBy: "fork",
136
- reason:
137
- "KEYBOARD_FEED injects a whole string at a time; it has no primitive for holding multiple " +
138
- "keys down together for a span of frames.",
139
- alternative: KEYBOARD_ALTERNATIVE,
140
- },
141
- {
142
- name: "vice_keyboard_key_press",
143
- category: "hardware",
144
- providedBy: "fork",
145
- reason:
146
- "KEYBOARD_FEED has no hold/release primitive -- it injects a complete string, not an " +
147
- "individual key-down event.",
148
- alternative: KEYBOARD_ALTERNATIVE,
149
- },
150
- {
151
- name: "vice_keyboard_key_release",
152
- category: "hardware",
153
- providedBy: "fork",
154
- reason:
155
- "KEYBOARD_FEED has no hold/release primitive -- it injects a complete string, not an " +
156
- "individual key-up event.",
157
- alternative: KEYBOARD_ALTERNATIVE,
158
- },
159
-
160
- // --- descoped (18), providedBy: fork -------------------------------------
161
- {
162
- name: "vice_disk_detach",
163
- category: "descoped",
164
- providedBy: "fork",
165
- reason:
166
- "No detach opcode exists on the stock binary monitor; attaching a different disk image " +
167
- "covers the same workflow.",
168
- },
169
- {
170
- name: "vice_disk_read_sector",
171
- category: "descoped",
172
- providedBy: "fork",
173
- reason:
174
- "Reading a sector would require parsing the .d64 file client-side rather than calling a " +
175
- "live-drive opcode, and no shipped skill calls it.",
176
- },
177
- {
178
- name: "vice_display_screenshot",
179
- category: "descoped",
180
- providedBy: "fork",
181
- reason:
182
- "The client-side PNG encoder for the INDEXED8 framebuffer DISPLAY_GET returns was descoped " +
183
- "because no shipped skill calls it.",
184
- },
185
- {
186
- name: "vice_display_get_dimensions",
187
- category: "descoped",
188
- providedBy: "fork",
189
- reason: "Descoped alongside vice_display_screenshot -- no shipped skill calls it.",
190
- },
191
- {
192
- name: "vice_backtrace",
193
- category: "descoped",
194
- providedBy: "fork",
195
- reason: "No shipped skill calls it.",
196
- },
197
- {
198
- name: "vice_checkpoint_group_add",
199
- category: "descoped",
200
- providedBy: "fork",
201
- reason: "No shipped skill calls any checkpoint-group tool.",
202
- },
203
- {
204
- name: "vice_checkpoint_group_create",
205
- category: "descoped",
206
- providedBy: "fork",
207
- reason: "No shipped skill calls any checkpoint-group tool.",
208
- },
209
- {
210
- name: "vice_checkpoint_group_list",
211
- category: "descoped",
212
- providedBy: "fork",
213
- reason: "No shipped skill calls any checkpoint-group tool.",
214
- },
215
- {
216
- name: "vice_checkpoint_group_toggle",
217
- category: "descoped",
218
- providedBy: "fork",
219
- reason: "No shipped skill calls any checkpoint-group tool.",
220
- },
221
- {
222
- name: "vice_checkpoint_set_ignore_count",
223
- category: "descoped",
224
- providedBy: "fork",
225
- reason:
226
- "No native wire ignore-count exists; the only implementation would require resuming the " +
227
- "machine on every ignored hit, which the no-unrequested-resume policy forbids. " +
228
- "CHECKPOINT_INFO's reply still reports an existing ignore count read-only.",
229
- },
230
- {
231
- name: "vice_cia_set_state",
232
- category: "descoped",
233
- providedBy: "fork",
234
- reason:
235
- "The write half of a tool whose read half already ships on stock; no shipped skill calls " +
236
- "the write half.",
237
- },
238
- {
239
- name: "vice_vicii_set_state",
240
- category: "descoped",
241
- providedBy: "fork",
242
- reason:
243
- "The write half of a tool whose read half already ships on stock; no shipped skill calls " +
244
- "the write half.",
245
- },
246
- {
247
- name: "vice_sprite_set",
248
- category: "descoped",
249
- providedBy: "fork",
250
- reason:
251
- "The write half of a tool whose read half already ships on stock; no shipped skill calls " +
252
- "the write half.",
253
- },
254
- {
255
- name: "vice_memory_fill",
256
- category: "descoped",
257
- providedBy: "fork",
258
- reason: "No shipped skill calls it.",
259
- },
260
- {
261
- name: "vice_sid_set_state",
262
- category: "descoped",
263
- providedBy: "fork",
264
- reason:
265
- "SID writes work fine over MEM_SET at $D400-$D418 -- this is not a hardware loss, only " +
266
- "reads are write-only in hardware. It is simply not implemented because no shipped skill " +
267
- "calls it.",
268
- },
269
- {
270
- name: "vice_machine_config_get",
271
- category: "descoped",
272
- providedBy: "fork",
273
- reason:
274
- "Full resource get/set access was descoped; the fork's tool is a hand-curated whitelist " +
275
- "subset that never shipped on stock.",
276
- },
277
- {
278
- name: "vice_machine_config_set",
279
- category: "descoped",
280
- providedBy: "fork",
281
- reason:
282
- "Full resource get/set access was descoped; the fork's tool is a hand-curated whitelist " +
283
- "subset that never shipped on stock.",
284
- },
285
- {
286
- name: "vice_joystick_tap",
287
- category: "descoped",
288
- providedBy: "fork",
289
- reason:
290
- "Requires running the machine for a measured hold-then-release interval, which depends on " +
291
- "timing infrastructure; not yet built, and no shipped skill calls it.",
292
- },
293
-
294
- // --- stock-only-gain (2), providedBy: stock ------------------------------
295
- {
296
- name: "vice_execution_until_return",
297
- category: "stock-only-gain",
298
- providedBy: "stock",
299
- reason: "The fork's custom HTTP API has no equivalent RPC; this is the native EXECUTE_UNTIL_RETURN opcode.",
300
- },
301
- {
302
- name: "vice_registers_available",
303
- category: "stock-only-gain",
304
- providedBy: "stock",
305
- reason: "The fork has no equivalent enumeration call; this is the native REGISTERS_AVAILABLE opcode.",
306
- },
307
- ];
308
-
309
- /**
310
- * Plain name-keyed lookup over CAPABILITY_REGISTRY. `name` is untrusted
311
- * `request.params.name` from the wire: it is used ONLY as an equality
312
- * comparison value below. Never interpolate it into a path, a command, or
313
- * anything executed.
314
- */
315
- export function capabilityEntryFor(name: string): CapabilityEntry | undefined {
316
- return CAPABILITY_REGISTRY.find((entry) => entry.name === name);
317
- }
318
-
319
- /**
320
- * Renders the BACK-05 refusal for `name` on `activeBackend`, or `undefined`
321
- * when there is nothing to refuse -- mirroring denyListRefusalMessage()'s
322
- * keyed-by-hazard-shape contract (vice.ts).
323
- *
324
- * Returns `undefined` when:
325
- * - no registry entry exists for `name` (a genuinely unknown tool name --
326
- * a typo -- must still fall through to the generic "Unknown tool"
327
- * message at the call site, not this function's wording); or
328
- * - `entry.providedBy === activeBackend` (defensive: the active backend
329
- * already advertises this tool, so a miss here is a genuine
330
- * unknown-tool case, not a capability gap, and must not be
331
- * misclassified as one).
332
- *
333
- * Otherwise renders one of three wordings, selected by `entry.category`:
334
- * - "hardware": names the tool, states it is unrecoverable on
335
- * `activeBackend`, gives `entry.reason`, then names `entry.providedBy`
336
- * with the actionable `Set VICE_BACKEND=...`, then `entry.alternative`
337
- * when present. No "wait for a later phase" framing -- none is coming
338
- * for a hardware loss, but a stock route may still exist and must be
339
- * named here, since this is where the caller actually reads it.
340
- * - "descoped": names the tool, states it is not implemented on
341
- * `activeBackend`, gives `entry.reason`, then `entry.providedBy` and
342
- * `Set VICE_BACKEND=...`, then `entry.alternative` when present. The
343
- * literal token "unrecoverable" must NEVER appear in this wording: a
344
- * reader told "not supported" for both a hardware loss and a merely
345
- * unbuilt tool cannot tell which one is worth filing an issue about.
346
- * - "stock-only-gain": names the tool, states it is not implemented on the
347
- * fork backend specifically, gives `entry.reason`, then
348
- * `Set VICE_BACKEND=stock`.
349
- */
350
- export function capabilityRefusalMessage(
351
- name: string,
352
- activeBackend: ViceBackend,
353
- ): string | undefined {
354
- const entry = capabilityEntryFor(name);
355
- if (!entry) return undefined;
356
- if (entry.providedBy === activeBackend) return undefined;
357
-
358
- // `alternative` is rendered in EVERY branch that has one. It used to be
359
- // read only inside the "descoped" branch, which made the field dead at
360
- // runtime: all five entries that carry an alternative are category
361
- // "hardware", and no "descoped" entry has one. The generated support
362
- // table, the skill playbooks and README all printed the stock route while
363
- // the runtime refusal -- the one surface BACK-05 exists for -- dropped it.
364
- // Do not re-scope this back into a single branch.
365
- const alt = entry.alternative ? ` ${entry.alternative}` : "";
366
-
367
- if (entry.category === "hardware") {
368
- return (
369
- `${entry.name} is unrecoverable on the ${activeBackend} backend: ${entry.reason} ` +
370
- `Use the ${entry.providedBy} backend instead (Set VICE_BACKEND=${entry.providedBy}).${alt}`
371
- );
372
- }
373
-
374
- if (entry.category === "descoped") {
375
- return (
376
- `${entry.name} is not implemented on the ${activeBackend} backend: ${entry.reason} ` +
377
- `Use the ${entry.providedBy} backend instead (Set VICE_BACKEND=${entry.providedBy}).${alt}`
378
- );
379
- }
380
-
381
- // category === "stock-only-gain": only reachable with activeBackend ===
382
- // "fork" and entry.providedBy === "stock", since the same-backend guard
383
- // above already excluded the activeBackend === "stock" case.
384
- return (
385
- `${entry.name} is not implemented on the fork backend: ${entry.reason} ` +
386
- `Use the stock backend instead (Set VICE_BACKEND=stock).${alt}`
387
- );
388
- }