c64bridge 0.9.2 → 1.0.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 (58) hide show
  1. package/AGENTS.md +24 -3
  2. package/README.md +271 -161
  3. package/data/basic/rom-routines.md +269 -0
  4. package/data/context/bootstrap.md +1 -1
  5. package/data/io/cia-spec.md +2 -2
  6. package/data/{memory/kernal-memory-map.md → kernal/rom-routines.md} +3 -2
  7. package/data/memory/low-memory-map.md +1 -0
  8. package/data/memory/memory-map.md +13 -0
  9. package/dist/.tsbuildinfo +1 -1
  10. package/dist/c64Client.js +127 -12
  11. package/dist/config.js +34 -8
  12. package/dist/device.js +75 -45
  13. package/dist/mcp-server.js +28 -8
  14. package/dist/platform.js +13 -2
  15. package/dist/rag/knowledgeIndex.js +54 -9
  16. package/dist/rag/resourceUris.js +2 -0
  17. package/dist/tools/audio.js +1 -1
  18. package/dist/tools/developer.js +6 -6
  19. package/dist/tools/graphics.js +4 -4
  20. package/dist/tools/input.js +129 -12
  21. package/dist/tools/machineControl.js +85 -6
  22. package/dist/tools/memory.js +1 -1
  23. package/dist/tools/meta/index.js +1 -1
  24. package/dist/tools/programRunners.js +5 -5
  25. package/dist/tools/rag.js +1 -1
  26. package/dist/tools/registry/batch.js +1 -1
  27. package/dist/tools/registry/config.js +5 -5
  28. package/dist/tools/registry/disk.js +2 -2
  29. package/dist/tools/registry/drive.js +2 -2
  30. package/dist/tools/registry/graphics.js +2 -2
  31. package/dist/tools/registry/memory.js +2 -2
  32. package/dist/tools/registry/platform.js +7 -5
  33. package/dist/tools/registry/program.js +5 -5
  34. package/dist/tools/registry/rag.js +1 -1
  35. package/dist/tools/registry/sound.js +4 -4
  36. package/dist/tools/registry/system.js +13 -3
  37. package/dist/tools/storage.js +1 -1
  38. package/doc/c64u/c64-openapi.yaml +1130 -774
  39. package/doc/developer.md +3 -2
  40. package/doc/u2/u2-openapi.yaml +1192 -0
  41. package/generated/c64/index.js +142 -9
  42. package/generated/openapi/c64u/index.js +1117 -0
  43. package/generated/openapi/u2/index.js +929 -0
  44. package/mcp/resources.json +60 -7
  45. package/mcp/schemas/c64_graphics.schema.json +3 -3
  46. package/mcp/schemas/c64_input.schema.json +247 -6
  47. package/mcp/schemas/c64_memory.schema.json +3 -3
  48. package/mcp/schemas/c64_program.schema.json +3 -3
  49. package/mcp/schemas/c64_select_backend.schema.json +2 -0
  50. package/mcp/schemas/c64_system.schema.json +41 -1
  51. package/mcp/server.json +1 -1
  52. package/mcp/tools.json +382 -41
  53. package/mcp.json +21 -5
  54. package/package.json +14 -8
  55. package/scripts/mockC64Server.mjs +40 -0
  56. package/scripts/prepare-release.mjs +13 -2
  57. package/scripts/update-readme.ts +19 -30
  58. package/server.json +2 -2
@@ -668,7 +668,7 @@ export const programRunnersModule = defineToolModule({
668
668
  "Invoke right after you generate BASIC source so it runs on the C64 without extra user steps.",
669
669
  "Ensure the program includes line numbers and uppercase keywords before calling the tool.",
670
670
  ],
671
- supportedPlatforms: ["c64u", "vice"],
671
+ supportedPlatforms: ["c64u", "u2", "vice"],
672
672
  async execute(args, ctx) {
673
673
  return executeUploadRunBasic(args, ctx);
674
674
  },
@@ -693,7 +693,7 @@ export const programRunnersModule = defineToolModule({
693
693
  "Use when the user requests to run new 6502 code; surface any assembler diagnostics in your reply.",
694
694
  "Mention the entry routine or important addresses after execution so the user can continue debugging.",
695
695
  ],
696
- supportedPlatforms: ["c64u", "vice"],
696
+ supportedPlatforms: ["c64u", "u2", "vice"],
697
697
  async execute(args, ctx) {
698
698
  return executeUploadRunAsm(args, ctx);
699
699
  },
@@ -717,7 +717,7 @@ export const programRunnersModule = defineToolModule({
717
717
  "Stage PRG files without running when the user wants to inspect memory first.",
718
718
  "Confirm the Ultimate filesystem path (e.g. //USB0/demo.prg) is accessible before invoking.",
719
719
  ],
720
- supportedPlatforms: ["c64u"],
720
+ supportedPlatforms: ["c64u", "u2"],
721
721
  async execute(args, ctx) {
722
722
  return executeLoadPrg(args, ctx);
723
723
  },
@@ -733,7 +733,7 @@ export const programRunnersModule = defineToolModule({
733
733
  "Call when the user provides a PRG path and expects immediate execution without compiling.",
734
734
  "Mention that firmware issues a RUN so the user knows the machine state changed.",
735
735
  ],
736
- supportedPlatforms: ["c64u", "vice"],
736
+ supportedPlatforms: ["c64u", "u2", "vice"],
737
737
  prerequisites: ["drives_list"],
738
738
  examples: [
739
739
  {
@@ -765,7 +765,7 @@ export const programRunnersModule = defineToolModule({
765
765
  arguments: { path: "//USB0/game.crt" },
766
766
  },
767
767
  ],
768
- supportedPlatforms: ["c64u"],
768
+ supportedPlatforms: ["c64u", "u2"],
769
769
  async execute(args, ctx) {
770
770
  try {
771
771
  const parsed = crtFileArgsSchema.parse(args ?? {});
package/dist/tools/rag.js CHANGED
@@ -181,7 +181,7 @@ export const ragModule = defineToolModule({
181
181
  ],
182
182
  prompts: ["basic-program", "assembly-program"],
183
183
  defaultTags: ["rag", "search"],
184
- supportedPlatforms: ["c64u", "vice"],
184
+ supportedPlatforms: ["c64u", "u2", "vice"],
185
185
  workflowHints: [
186
186
  "Call RAG tools when the user needs references or examples before generating new code.",
187
187
  "Summarise the number of refs returned and suggest follow-up actions like reading specific docs.",
@@ -35,7 +35,7 @@ const executeBatchArgsSchema = objectSchema({
35
35
  export const batchModuleGroup = defineToolModule({
36
36
  domain: "batch",
37
37
  summary: "Execute multiple tool calls in a single MCP request for reduced round-trip overhead.",
38
- supportedPlatforms: ["c64u", "vice"],
38
+ supportedPlatforms: ["c64u", "u2", "vice"],
39
39
  resources: [],
40
40
  prompts: [],
41
41
  defaultTags: ["batch", "orchestration"],
@@ -154,7 +154,7 @@ export const configModuleGroup = defineToolModule({
154
154
  resources: ["c64://guide/bootstrap", "c64://guide/index"],
155
155
  prompts: ["memory-debug"],
156
156
  defaultTags: ["config", "diagnostics"],
157
- supportedPlatforms: ["c64u", "vice"],
157
+ supportedPlatforms: ["c64u", "u2", "vice"],
158
158
  workflowHints: [
159
159
  "List categories before changing values so users can confirm firmware-provided names.",
160
160
  "Mention when operations persist to flash or modify debug registers to highlight impacts.",
@@ -171,12 +171,12 @@ export const configModuleGroup = defineToolModule({
171
171
  }),
172
172
  tags: ["config", "diagnostics", "grouped"],
173
173
  operationPlatforms: {
174
- load_flash: ["c64u"],
175
- save_flash: ["c64u"],
176
- reset_defaults: ["c64u"],
174
+ load_flash: ["c64u", "u2"],
175
+ save_flash: ["c64u", "u2"],
176
+ reset_defaults: ["c64u", "u2"],
177
177
  read_debugreg: ["c64u"],
178
178
  write_debugreg: ["c64u"],
179
- shuffle: ["c64u"],
179
+ shuffle: ["c64u", "u2"],
180
180
  },
181
181
  operationToolNames: {
182
182
  load_flash: "config_load_from_flash",
@@ -251,7 +251,7 @@ const diskOperationHandlers = createOperationHandlers(diskOperations);
251
251
  export const diskModuleGroup = defineToolModule({
252
252
  domain: "storage",
253
253
  summary: "Grouped disk image management, mounting, and discovery tools.",
254
- supportedPlatforms: ["c64u", "vice"],
254
+ supportedPlatforms: ["c64u", "u2", "vice"],
255
255
  resources: ["c64://guide/bootstrap"],
256
256
  prompts: ["drive-management"],
257
257
  defaultTags: ["storage", "drive"],
@@ -269,7 +269,7 @@ export const diskModuleGroup = defineToolModule({
269
269
  variants: diskOperations.map((operation) => operation.schema),
270
270
  }),
271
271
  tags: ["storage", "drive", "grouped"],
272
- operationPlatforms: { file_info: ["c64u"], create_image: ["c64u"], find_and_run: ["c64u"] },
272
+ operationPlatforms: { file_info: ["c64u", "u2"], create_image: ["c64u", "u2"], find_and_run: ["c64u", "u2"] },
273
273
  operationToolNames: {
274
274
  file_info: "file_info",
275
275
  create_image: "create_image",
@@ -33,7 +33,7 @@ const driveOperationHandlers = createOperationHandlers(driveOperations);
33
33
  export const driveModuleGroup = defineToolModule({
34
34
  domain: "drive",
35
35
  summary: "Grouped drive power, reset, ROM, and mode helpers.",
36
- supportedPlatforms: ["c64u", "vice"],
36
+ supportedPlatforms: ["c64u", "u2", "vice"],
37
37
  resources: ["c64://guide/bootstrap"],
38
38
  defaultTags: ["drive", "hardware"],
39
39
  workflowHints: [
@@ -50,7 +50,7 @@ export const driveModuleGroup = defineToolModule({
50
50
  variants: driveOperations.map((operation) => operation.schema),
51
51
  }),
52
52
  tags: ["drive", "hardware", "grouped"],
53
- operationPlatforms: { load_rom: ["c64u"] },
53
+ operationPlatforms: { load_rom: ["c64u", "u2"] },
54
54
  operationToolNames: { load_rom: "drive_load_rom" },
55
55
  examples: [
56
56
  {
@@ -89,7 +89,7 @@ function parseVicState(d011, d016, d018, dd00, d020, d021) {
89
89
  };
90
90
  }
91
91
  const getDisplayStateArgsSchema = objectSchema({
92
- description: "Read VIC-II and CIA2 registers to determine the current graphics mode and memory layout. Works on C64U and VICE; both backends are read through shared memory primitives so the response shape is identical.",
92
+ description: "Read VIC-II and CIA2 registers to determine the current graphics mode and memory layout. The same shared-memory path is used on C64U/U64, U2-family hardware, and VICE, so the response shape is identical.",
93
93
  properties: {
94
94
  op: literalSchema("get_display_state"),
95
95
  },
@@ -212,7 +212,7 @@ export const graphicsModuleGroup = defineToolModule({
212
212
  "Use render helpers for PETSCII text, PETSCII art, sprites, and bitmaps; clarify whether PETSCII art executed or stayed a dry run.",
213
213
  "Mention sprite positions/colours so follow-up memory inspection stays grounded.",
214
214
  ],
215
- supportedPlatforms: ["c64u", "vice"],
215
+ supportedPlatforms: ["c64u", "u2", "vice"],
216
216
  tools: [
217
217
  {
218
218
  name: "c64_graphics",
@@ -27,7 +27,7 @@ const memoryOperations = [
27
27
  },
28
28
  {
29
29
  op: "disassemble",
30
- schema: extendSchemaWithOp("disassemble", disassembleArgsSchema.jsonSchema, { description: "Disassemble a memory region into annotated 6502/6510 instructions, including undocumented opcodes with canonical names. Symbol annotations from `.vs` files are applied when available. Works on both C64U and VICE." }),
30
+ schema: extendSchemaWithOp("disassemble", disassembleArgsSchema.jsonSchema, { description: "Disassemble a memory region into annotated 6502/6510 instructions, including undocumented opcodes with canonical names. Symbol annotations from `.vs` files are applied when available. Works on C64U/U64, U2-family hardware, and VICE." }),
31
31
  handler: groupedMemoryHandlers.disassemble,
32
32
  },
33
33
  {
@@ -60,7 +60,7 @@ const memoryOperationHandlers = createOperationHandlers(memoryOperations);
60
60
  export const memoryModuleGroup = defineToolModule({
61
61
  domain: "memory",
62
62
  summary: "Grouped memory, screen, and polling operations.",
63
- supportedPlatforms: ["c64u", "vice"],
63
+ supportedPlatforms: ["c64u", "u2", "vice"],
64
64
  resources: ["c64://guide/bootstrap", "c64://basic/spec", "c64://assembly/6510-spec"],
65
65
  prompts: ["memory-debug", "basic-program", "assembly-program"],
66
66
  defaultTags: ["memory", "debug"],
@@ -50,7 +50,7 @@ const selectBackendSchema = operationSchema("select", {
50
50
  properties: {
51
51
  backend: {
52
52
  type: "string",
53
- enum: ["c64u", "vice"],
53
+ enum: ["c64u", "u2", "vice"],
54
54
  description: "Backend to activate for subsequent tool calls.",
55
55
  },
56
56
  },
@@ -76,14 +76,16 @@ const platformOperationHandlers = {
76
76
  ctx.client.switchBackend(backend);
77
77
  ctx.setPlatform(backend);
78
78
  const { availableTools, unavailableTools } = describeTargetPlatform(backend);
79
- const switchBackTarget = backend === "c64u" ? "vice" : "c64u";
79
+ const switchBackTarget = availableBackends.find((candidate) => candidate !== backend);
80
80
  const data = {
81
81
  success: true,
82
82
  activeBackend: backend,
83
83
  configuredBackends: availableBackends,
84
84
  availableTools,
85
85
  unavailableTools,
86
- usageHint: `Use c64_select_backend again with backend: "${switchBackTarget}" to switch back.`,
86
+ usageHint: switchBackTarget
87
+ ? `Use c64_select_backend again with backend: "${switchBackTarget}" to switch back.`
88
+ : "No other backend is configured.",
87
89
  };
88
90
  return jsonResult(data, { success: true });
89
91
  },
@@ -91,7 +93,7 @@ const platformOperationHandlers = {
91
93
  export const platformModuleGroup = defineToolModule({
92
94
  domain: "platform",
93
95
  summary: "Runtime backend selection and platform-status coordination.",
94
- supportedPlatforms: ["c64u", "vice"],
96
+ supportedPlatforms: ["c64u", "u2", "vice"],
95
97
  resources: ["c64://platform/status", "c64://guide/bootstrap"],
96
98
  prompts: [],
97
99
  defaultTags: ["platform", "backend", "grouped"],
@@ -101,7 +103,7 @@ export const platformModuleGroup = defineToolModule({
101
103
  tools: [
102
104
  {
103
105
  name: "c64_select_backend",
104
- description: "Switch the active backend between C64U hardware and the VICE emulator at runtime.",
106
+ description: "Switch the active backend between C64U/U64 hardware, U2-family cartridges, and the VICE emulator at runtime.",
105
107
  summary: "Changes the active backend without restarting the MCP server and reports resulting tool availability.",
106
108
  inputSchema: discriminatedUnionSchema({
107
109
  description: "Runtime backend selection operations.",
@@ -12,7 +12,7 @@ const programOperations = [
12
12
  },
13
13
  {
14
14
  op: "run_prg",
15
- schema: extendSchemaWithOp("run_prg", ensureDescriptor(programDescriptorIndex, "run_prg").inputSchema, { description: "Load and execute a PRG from Ultimate-visible storage on c64u or a host-local path on VICE." }),
15
+ schema: extendSchemaWithOp("run_prg", ensureDescriptor(programDescriptorIndex, "run_prg").inputSchema, { description: "Load and execute a PRG from Ultimate-visible storage on C64U/U64 or U2-family hardware, or from a host-local path on VICE." }),
16
16
  handler: async (rawArgs, ctx) => invokeModuleTool(programRunnersModule, "run_prg", rawArgs, ctx),
17
17
  },
18
18
  {
@@ -55,10 +55,10 @@ export const programModule = defineToolModule({
55
55
  defaultTags: ["programs", "execution"],
56
56
  workflowHints: [
57
57
  "Choose BASIC or assembly uploaders based on the language you just generated for the user.",
58
- "Prefer PRG or CRT runners when the user supplies a file path instead of source text; PRG paths are host-local on VICE and Ultimate-visible on c64u.",
59
- "For a quick visible confirmation on VICE and/or C64U, prefer cross_platform_greeting instead of composing manual backend switches and BASIC upload steps.",
58
+ "Prefer PRG or CRT runners when the user supplies a file path instead of source text; PRG paths are host-local on VICE and Ultimate-visible on hardware.",
59
+ "For a quick visible confirmation on VICE, C64U/U64, or U2-family hardware, prefer cross_platform_greeting instead of composing manual backend switches and BASIC upload steps.",
60
60
  ],
61
- supportedPlatforms: ["c64u", "vice"],
61
+ supportedPlatforms: ["c64u", "u2", "vice"],
62
62
  tools: [
63
63
  {
64
64
  name: "c64_program",
@@ -69,7 +69,7 @@ export const programModule = defineToolModule({
69
69
  variants: programOperations.map((operation) => operation.schema),
70
70
  }),
71
71
  tags: ["programs", "execution", "grouped"],
72
- operationPlatforms: { load_prg: ["c64u"], run_crt: ["c64u"], bundle_run: ["c64u"] },
72
+ operationPlatforms: { load_prg: ["c64u", "u2"], run_crt: ["c64u", "u2"], bundle_run: ["c64u", "u2"] },
73
73
  operationToolNames: {
74
74
  load_prg: "load_prg",
75
75
  run_crt: "run_crt",
@@ -25,7 +25,7 @@ export const ragModuleGroup = defineToolModule({
25
25
  "Use BASIC retrieval before synthesising new BASIC code and mention primary resources in responses.",
26
26
  "For assembly, note registers or addresses surfaced so the user can inspect them further.",
27
27
  ],
28
- supportedPlatforms: ["c64u", "vice"],
28
+ supportedPlatforms: ["c64u", "u2", "vice"],
29
29
  tools: [
30
30
  {
31
31
  name: "c64_rag",
@@ -139,7 +139,7 @@ const soundOperationHandlers = createOperationHandlers(soundOperations);
139
139
  export const soundModuleGroup = defineToolModule({
140
140
  domain: "audio",
141
141
  summary: "Grouped SID control, playback, composition, and analysis operations.",
142
- supportedPlatforms: ["c64u", "vice"],
142
+ supportedPlatforms: ["c64u", "u2", "vice"],
143
143
  resources: ["c64://sound/sid/spec", "c64://sound/sidwave/spec", "c64://sound/sid/file-format"],
144
144
  prompts: ["sid-music"],
145
145
  defaultTags: ["sid", "audio"],
@@ -159,9 +159,9 @@ export const soundModuleGroup = defineToolModule({
159
159
  tags: ["sid", "audio", "grouped"],
160
160
  operationPlatforms: {
161
161
  capture_samples: ["c64u"],
162
- play_sid_file: ["c64u"],
163
- play_mod_file: ["c64u"],
164
- pipeline: ["c64u"],
162
+ play_sid_file: ["c64u", "u2"],
163
+ play_mod_file: ["c64u", "u2"],
164
+ pipeline: ["c64u", "u2"],
165
165
  analyze: ["c64u"],
166
166
  record_analyze: ["c64u"],
167
167
  },
@@ -30,11 +30,21 @@ const systemOperations = [
30
30
  schema: extendSchemaWithOp("poweroff", ensureDescriptor(machineDescriptorIndex, "poweroff").inputSchema, { description: "Request a controlled shutdown via the Ultimate firmware." }),
31
31
  handler: async (rawArgs, ctx) => invokeModuleTool(machineControlModule, "poweroff", rawArgs, ctx),
32
32
  },
33
+ {
34
+ op: "power_cycle",
35
+ schema: extendSchemaWithOp("power_cycle", ensureDescriptor(machineDescriptorIndex, "power_cycle").inputSchema, { description: "Return the active backend to a fresh state. C64U/U64 Tool Menu verification requires machine:menu_screen (a C64U firmware version that provides it, or U64 3.15+); U2-family reboots through REST." }),
36
+ handler: async (rawArgs, ctx) => invokeModuleTool(machineControlModule, "power_cycle", rawArgs, ctx),
37
+ },
33
38
  {
34
39
  op: "menu",
35
40
  schema: extendSchemaWithOp("menu", ensureDescriptor(machineDescriptorIndex, "menu_button").inputSchema, { description: "Toggle the Ultimate menu button for navigation." }),
36
41
  handler: async (rawArgs, ctx) => invokeModuleTool(machineControlModule, "menu_button", rawArgs, ctx),
37
42
  },
43
+ {
44
+ op: "read_menu_screen",
45
+ schema: extendSchemaWithOp("read_menu_screen", ensureDescriptor(machineDescriptorIndex, "read_menu_screen").inputSchema, { description: "Read the active Ultimate menu's raw character and colour matrix through machine:menu_screen (a C64U firmware version that provides it, or U64/U2 3.15+)." }),
46
+ handler: async (rawArgs, ctx) => invokeModuleTool(machineControlModule, "read_menu_screen", rawArgs, ctx),
47
+ },
38
48
  {
39
49
  op: "start_task",
40
50
  schema: extendSchemaWithOp("start_task", ensureDescriptor(metaDescriptorIndex, "start_background_task").inputSchema, { description: "Start a named background task that runs on an interval." }),
@@ -65,7 +75,7 @@ const systemOperationHandlers = createOperationHandlers(systemOperations);
65
75
  export const systemModuleGroup = defineToolModule({
66
76
  domain: "system",
67
77
  summary: "Grouped machine control and background task orchestration.",
68
- supportedPlatforms: ["c64u", "vice"],
78
+ supportedPlatforms: ["c64u", "u2", "vice"],
69
79
  resources: ["c64://guide/bootstrap"],
70
80
  prompts: ["memory-debug"],
71
81
  defaultTags: ["system", "control"],
@@ -83,8 +93,8 @@ export const systemModuleGroup = defineToolModule({
83
93
  variants: systemOperations.map((operation) => operation.schema),
84
94
  }),
85
95
  tags: ["system", "control", "grouped"],
86
- operationPlatforms: { pause: ["c64u"], resume: ["c64u"], menu: ["c64u"] },
87
- operationToolNames: { pause: "pause", resume: "resume", menu: "menu_button" },
96
+ operationPlatforms: { pause: ["c64u", "u2"], resume: ["c64u", "u2"], menu: ["c64u", "u2"], read_menu_screen: ["c64u", "u2"] },
97
+ operationToolNames: { pause: "pause", resume: "resume", menu: "menu_button", read_menu_screen: "read_menu_screen" },
88
98
  examples: [
89
99
  {
90
100
  name: "Soft reset",
@@ -143,7 +143,7 @@ const createDnpArgsSchema = objectSchema({
143
143
  export const storageModule = defineToolModule({
144
144
  domain: "storage",
145
145
  summary: "Drive management, disk image creation, and file inspection utilities.",
146
- supportedPlatforms: ["c64u", "vice"],
146
+ supportedPlatforms: ["c64u", "u2", "vice"],
147
147
  resources: ["c64://guide/bootstrap"],
148
148
  prompts: ["memory-debug"],
149
149
  defaultTags: ["drive", "storage"],