Skip to content

Conversation

@chrisgleissner
Copy link
Owner

@chrisgleissner chrisgleissner commented Nov 2, 2025

Extend VICE support so that as many of the C64 Bridge tools as possible can leverage VICE instead of a real C64U device.

Copilot AI review requested due to automatic review settings November 2, 2025 00:05
@chrisgleissner chrisgleissner marked this pull request as draft November 2, 2025 00:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive VICE emulator support for the MCP server, adding:

  • A complete VICE Binary Monitor client with debugger capabilities (checkpoints, registers, stepping)
  • Process management and test infrastructure with mock server support
  • Platform-aware tool routing with supportedPlatforms metadata
  • Extensive test coverage using a mock BM server for CI environments

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/vice/viceClient.ts Core Binary Monitor protocol client with extended debugger ops
src/vice/mockServer.ts Lightweight BM stub for test environments
src/vice/process.ts VICE process lifecycle management with Xvfb support
src/vice/readiness.ts Helpers for polling BASIC READY and screen patterns
src/tools/debug.ts Debugger tool module (checkpoints, registers, stepping)
src/tools/vice.ts VICE-specific tools (display capture, resource access)
src/device.ts ViceBackend implementation with long-lived process support
test/* Comprehensive test coverage with platform-aware harness
scripts/run-tests.ts Test matrix runner supporting multiple platforms/targets
doc/* Updated documentation and rollout tracking

const bytes = Buffer.from(text, "ascii");
const body = Buffer.concat([Buffer.from([bytes.length & 0xff]), bytes]);
await this.send(0x72, body);
}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line before new method section. The checkpoint methods start immediately after keyboardFeed without separation, while earlier methods (e.g., before line 195) maintain consistent spacing between functional groups.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 17
async function resumeEmulation(bm: ViceClient): Promise<void> {
try {
await bm.exitMonitor();
} catch {
// Ignore errors while resuming; monitor may already be running.
}
}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name resumeEmulation is ambiguous. The comment says 'monitor may already be running,' but the function name suggests starting emulation. Consider renaming to exitMonitorIfNeeded or ensureEmulationRunning for clarity.

Copilot uses AI. Check for mistakes.
Comment on lines +62 to +64
0x0E,0x08,
0x0A,0x00,
0x99,
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed inline comments explaining BASIC program structure ($080E pointer, line 10, PRINT token). The original comments improved readability for this low-level byte sequence. Consider restoring them or adding a docstring to buildHelloProgramBody.

Copilot uses AI. Check for mistakes.
Comment on lines 48 to 57
function toolIsAvailable(ctx, toolName) {
if (typeof ctx.isToolSupported === "function") {
try {
return ctx.isToolSupported(toolName);
} catch {
return true;
}
}
return true;
}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function returns true on exception (line 53), which contradicts the function name toolIsAvailable. If isToolSupported throws, the tool support status is unknown, not confirmed as available. Consider returning false on exception or logging the error.

Copilot uses AI. Check for mistakes.
src/device.ts Outdated
constructor(config: ViceConfig) {
this.exe = config.exe || which("x64sc") || which("x64") || "x64sc";
const envBinary = configuredString(process.env.VICE_BINARY);
this.exe = configuredString(config.exe) ?? envBinary ?? which("x64sc") ?? which("x64") ?? "x64sc";
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment variable takes precedence over config file (envBinary is checked before config.exe), but the configuration documentation in README.md suggests config files should override env defaults. This ordering contradicts typical precedence (explicit config > env > defaults).

Suggested change
this.exe = configuredString(config.exe) ?? envBinary ?? which("x64sc") ?? which("x64") ?? "x64sc";
this.exe = config.exe !== undefined && config.exe !== null
? config.exe
: envBinary ?? which("x64sc") ?? which("x64") ?? "x64sc";

Copilot uses AI. Check for mistakes.
Comment on lines 106 to 110
const bunRuntime = (globalThis as { Bun?: any }).Bun;
if (!bunRuntime || typeof bunRuntime.spawn !== "function") {
throw new Error("[run-tests] Bun runtime is required to execute tests");
}
const child = bunRuntime.spawn({
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script requires Bun runtime (line 108 error message), but the documentation states 'stay on the npm variants if Bun is not installed.' This hard requirement contradicts the documented fallback behavior and will break npm test on Node-only installations.

Copilot uses AI. Check for mistakes.
@chrisgleissner
Copy link
Owner Author

@codex Fix the failing tests against VICE:

skip) poweroff succeeds with valid response
(skip) poweroff handles failure response
(skip) poweroff handles exception
(skip) menu_button succeeds with valid response
(skip) menu_button handles failure response
(skip) menu_button handles exception
32 tests failed:
(fail) music_generate builds timeline and triggers SID sequence [2.00ms]
(fail) music_generate defaults to triangle waveform and best-practice ADSR
(fail) music_generate expression preset uses varied durations and reports preset
(fail) music_generate survives playback error and logs [1.00ms]
(fail) music_compile_and_play compiles SIDWAVE to PRG and runs on C64
(fail) music_compile_and_play can emit SID and use attachment playback
(fail) sidplay_file delegates to C64 client and returns metadata [1.00ms]
(fail) modplay_file delegates to C64 client
(fail) music_compile_and_play handles C64 firmware failure for PRG
(fail) music_compile_and_play handles C64 firmware failure for SID
(fail) music_compile_and_play wraps unexpected errors [1.00ms]
(fail) music_compile_and_play validates sidwave input
(fail) music_compile_and_play respects dryRun flag
(fail) sid_volume clamps and normalizes address [1.00ms]
(fail) sid_volume reports firmware failure
(fail) sid_volume wraps unexpected errors
(fail) sid_reset soft and hard [1.00ms]
(fail) sid_note_on passes parameters and returns metadata
(fail) sid_note_on surfaces firmware failure
(fail) sid_note_off and silence_all
(fail) sid_silence_all verify reports silence metrics [1.00ms]
(fail) sid_silence_all verify fails when residual audio remains
(fail) analyze_audio returns guidance when no keywords detected
(fail) analyze_audio wraps backend errors when keywords present [1.00ms]
(fail) record_and_analyze_audio returns error when backend missing
(fail) music_generate validates pattern input
(fail) stream_start forwards parsed payload
(fail) stream_start surfaces firmware failure
(fail) stream_stop forwards parsed payload [1.00ms]
(fail) stream_stop surfaces firmware failure
(fail) poweroff is unsupported on vice
(fail) menu_button is unsupported on vice [1.00ms]
 425 pass
 21 skip
 32 fail
 2836 expect() calls
Ran 478 tests across 50 files. [4.93s]
Error: Process completed with exit code 1.

@chatgpt-codex-connector
Copy link

Summary

Testing

  • bun test test/audioModule.test.mjs --filter music_generate
  • bun test test/machineControl.test.mjs --filter poweroff

View task →

@chrisgleissner chrisgleissner marked this pull request as ready for review November 2, 2025 11:17
@chrisgleissner chrisgleissner changed the title Added VICE support Extend VICE support Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants