Commit graph

30 commits

Author SHA1 Message Date
Simen Svale
d06d2ef71d Add DisplayGet packet debug test
Standalone test script to verify DisplayGet packet format matches
MCP client implementation. Useful for debugging protocol issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 04:58:30 +01:00
Simen Svale
c3547593f0 Add --version flag for debugging
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 04:36:08 +01:00
Simen Svale
a8bd8ab60a Bump version to 1.0.1, add startup version log
- Update package.json version from 0.1.0 to 1.0.1
- Update MCP server version to 1.0.1
- Log version to stderr on startup for debugging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 04:29:19 +01:00
Simen Svale
69e05806e1 Add integration test suites for protocol and MCP tool layers
- test/integration.ts: Protocol-level tests (Connect, RegistersGet, MemoryGet, MemorySet, DisplayGet)
- test/integration.test.ts: MCP tool-level tests (16 tools including semantic layer)

Both suites validate the VICE binary monitor protocol implementation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 04:24:26 +01:00
Simen Svale
c722e18496 Skip debug logging for large response bodies (>1KB)
DisplayGet returns ~150KB of pixel data which was being logged to stderr,
potentially causing crashes. Now shows just the size for large responses.

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-30 04:14:50 +01:00
Simen Svale
8541408504 Fix DisplayGet: add ensureStopped, response type, correct body parsing
- Add ensureStopped() before DisplayGet to ensure VICE is ready
- Add ResponseType.DisplayGet (0x84) to types
- Fix response parsing: FL(4)+DW(2)+DH(2)+XO(2)+YO(2)+IW(2)+IH(2)+BP(1)+BL(4)+BD
- Width/height are 16-bit not 32-bit per VICE docs

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-30 04:12:15 +01:00
Simen Svale
26b5b694c1 Fix DisplayGet API v2, writeMemory format, sprite address validation
- Change API_VERSION from 0x01 to 0x02 (required for DisplayGet, KeyboardFeed)
- Fix writeMemory body format: add end address and bankId per VICE docs
- Fix step() to use AdvanceInstructions (0x71) - no separate Step command
- Add validateSpriteDataAddress() with region/severity/warning
- Update readSprites to include address diagnostics in dataAddress field
- Prioritize address issues over visibility issues in hints

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-30 03:56:57 +01:00
Simen Svale
57c4c43b8a Fix step() to use AdvanceInstructions command
The Step command was removed in protocol cleanup, but step() still
referenced it. Using AdvanceInstructions (0x71) which is the correct
command for stepping.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:46:39 +01:00
Simen Svale
18b976adb8 Fix packet header: request ID is 4 bytes, not 1 byte
Command header: STX(1) + API(1) + Length(4) + ReqID(4) + Cmd(1) = 11 bytes
Response header: STX(1) + API(1) + Length(4) + Type(1) + Err(1) + ReqID(4) = 12 bytes

Async events use ReqID=0xffffffff (not 0xff).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:35:36 +01:00
Simen Svale
aacdf7bbb2 Add ensureStopped() before memory operations
VICE stops emulation on first command and sends async events, but may
not process the command itself until fully stopped. This adds an
ensureStopped() mechanism that sends RegistersGet first to confirm
VICE is in stopped state before memory read/write operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:28:27 +01:00
Simen Svale
a985c074a4 Comprehensive protocol fix from official VICE docs
Audited all codes against https://vice-emu.sourceforge.io/vice_13.html

Command code fixes:
- Added ExecuteUntilReturn (0x73)
- Fixed BanksAvailable (0x82, was 0x83)
- Added RegistersAvailable (0x83)
- Added ViceInfo (0x85)
- Added PaletteGet (0x91)
- Added JoyportSet (0xa2), UserportSet (0xb2)
- Use Exit (0xaa) for continue/resume

Response type fixes:
- Added JAM (0x61) async event
- Clarified which responses are command echoes vs async events

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:23:58 +01:00
Simen Svale
c00cd9e3da Fix command codes per official VICE manual
Our KB had wrong command codes. Fixed per VICE docs:
- RegistersGet = 0x31 (was 0x22)
- RegistersSet = 0x32 (was 0x23)
- Continue = 0x82 (was 0x31)
- Step = 0x81 (was 0x32)
- Exit = 0xaa (was 0x71)
- Reset = 0xcc (was 0x43)

Also reordered checkpoint commands (Get=0x11, Set=0x12).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:18:25 +01:00
Simen Svale
148ade15b9 Fix MemoryGet command format per official VICE docs
Official format: FX(1) + Start(2) + End(2) + Memspace(1) + BankID(2) = 8 bytes
Our code had: FX(1) + Start(2) + Memspace(1) + End(2) = 6 bytes (wrong order, missing bank)

This was causing error 0x81 "invalid parameter".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:14:03 +01:00
Simen Svale
40c2ecd1a5 Fix response types per official VICE manual
Our KB had wrong response type codes. Corrected per VICE docs:
- MemoryGet = 0x01 (was 0x31)
- RegisterInfo = 0x31 (was 0x62)
- Stopped = 0x62 (was 0x11)
- Resumed = 0x63 (was 0x12)

This should fix readMemory timeouts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:13:00 +01:00
Simen Svale
067ec7af24 Try removing async matching for MemoryGet
Testing if VICE sends MemoryGet responses with matched ReqID
instead of as async events (ReqID=0xff).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:11:49 +01:00
Simen Svale
caa3bc8e22 Fix async event handling for VICE API v1
VICE API v1 sends some responses (RegisterInfo, MemoryGet) as async
events with ReqID=0xff instead of matched responses. This caused
timeouts because we were waiting for responses with our request ID.

Fix: Match async responses (ReqID=0xff) to pending requests by
expected response type instead of request ID.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:01:54 +01:00
Simen Svale
995683a936 Fix VICE protocol: API v1, correct command codes, body length
Multiple fixes based on live testing:
- API version changed to 0x01 (VICE 3.x uses v1, not v2)
- Command codes updated per KB docs:
  - RegistersGet: 0x22 (was 0x31)
  - Continue: 0x31 (was 0x81)
  - Step: 0x32 (was 0x82)
- Body length field now excludes ReqID and Cmd (just command body)
- Response parsing: totalLength = 9 + bodyLength

Added test script for debugging protocol issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:55:10 +01:00
Simen Svale
0a6982ae40 Fix VICE protocol: 1-byte request ID, correct header sizes
Per KB docs, the actual protocol format is:
- Request: STX(1) + API(1) + Length(4) + ReqID(1) + Cmd(1) + Body (header = 8)
- Response: STX(1) + API(1) + Length(4) + Type(1) + Error(1) + ReqID(1) + Body (header = 9)

Previous fix incorrectly used 4-byte request IDs. Also added debug
logging to stderr to help diagnose protocol issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:47:49 +01:00
Simen Svale
3fece5cb1e Fix VICE binary protocol packet format
The request ID field is 4 bytes (not 1), and the packet structure was
incorrect:
- Request: STX(1) + API(1) + Length(4) + ReqID(4) + Cmd(1) + Body
- Response: STX(1) + API(1) + Length(4) + Type(1) + Error(1) + ReqID(4) + Body

This was causing all commands after connect() to timeout because response
matching was reading the wrong bytes for the request ID.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:44:27 +01:00
Simen Svale
0f5db6162f Add prepare script for npx GitHub install
When npx installs from GitHub, it runs the prepare script to build.
Without this, dist/ doesn't exist and the bin entry fails.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:36:49 +01:00
Simen Svale
67a38d3d32 Add Claude Code installation section to README
Quick-start instructions for Claude Code users with the
`claude mcp add` command and manual config file option.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:17:12 +01:00
Simen Svale
0e9efa89db Add comprehensive README
Covers installation (npm and GitHub), configuration, full tool reference,
example workflows, response format, architecture overview, and protocol
reference. Emphasizes semantic layer and agent-friendly design patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:12:24 +01:00
Simen Svale
8c74fb3484 Clarify deleteBreakpoint works for watchpoints too
Minor AX fix from owl's final review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:07:22 +01:00
Simen Svale
76a1069436 Add visual feedback tools
Protocol layer:
- Add DisplayGet command (0x84) for screen capture
- Add PaletteGet command (0x91) for color palette
- Implement getDisplay() and getPalette() client methods

New tools:
- screenshot: Capture display as indexed pixel data with palette
  - Returns base64-encoded pixel buffer for efficient transfer
  - Includes display dimensions and visible area bounds
  - Optionally includes RGB palette values
- renderScreen: ASCII art representation of current display
  - Converts pixel luminance to ASCII shading characters
  - Configurable output dimensions and character set
  - Useful for quick visual debugging in text-only contexts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:05:52 +01:00
Simen Svale
cebe6f4a14 Add advanced debugging tools
Protocol layer:
- Add watchpoint support (setWatchpoint, toggleCheckpoint, listWatchpoints)
- Add snapshot methods (saveSnapshot, loadSnapshot)
- Add autostart support
- Update command codes to match VICE binary monitor protocol
- Refactor BreakpointInfo to CheckpointInfo for unified handling

New tools:
- toggleBreakpoint: Enable/disable breakpoints without deleting
- setWatchpoint: Memory read/write watchpoints
- listWatchpoints: Show active watchpoints
- runTo: Run until specific address (temporary breakpoint)
- disassemble: 6502 disassembler with KERNAL/BASIC labels
- saveSnapshot/loadSnapshot: Machine state persistence
- loadProgram: Autostart PRG/D64/T64 files

Utilities:
- Add full 6502 disassembler with all addressing modes
- Include KERNAL/BASIC entry point labels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:04:23 +01:00
Simen Svale
56ea0984bb Add readScreen summary format and readVicState sprite visibility
- readScreen now supports format: "summary" | "full" option
  - summary: non-empty lines with trimming (agent-friendly)
  - full: all 25 lines (debugging use)
- readVicState now tracks sprite visibility:
  - visibleSprites array with sprite numbers
  - visibleCount for quick checking
  - Updated hint when sprites enabled but not visible

AX feedback from owl review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:59:13 +01:00
Simen Svale
37f53616ff Add semantic layer tools for interpreted C64 debugging
New tools:
- readScreen: Screen RAM as ASCII text with non-empty line summary
- readColorRam: Color RAM with color names and usage statistics
- readVicState: Full VIC-II state with interpreted values
  - Graphics mode detection
  - Memory bank/address calculation
  - Sprite enable summary
- readSprites: All 8 sprites with position, visibility, colors
  - Visibility checks with explanations
  - Data pointer address resolution
  - enabledOnly filtering option

Utilities (src/utils/c64.ts):
- PETSCII screen code to ASCII conversion
- C64 color palette names
- VIC bank and memory address calculation
- Graphics mode detection
- Sprite visibility range checks

AX patterns applied:
- Summary modes (readColorRam summary option)
- Filtering (readSprites enabledOnly option)
- Rich hints explaining issues (sprite visibility)
- Proactive issue detection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:56:03 +01:00
Simen Svale
84b10689d0 Address AX review feedback
- Fix status hint: clarify step() vs setBreakpoint+continue for pausing
- Add flag string to getRegisters: "NV-BDIZC" format (uppercase=set)
- Add listBreakpoints tool with local breakpoint tracking
- Track breakpoints in client for listing support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:53:16 +01:00
Simen Svale
32eb8f3c17 Add VICE binary protocol layer and core debugging tools
Protocol layer (src/protocol/):
- TCP socket client with connection management
- Binary packet encoding/decoding per VICE monitor protocol
- Async response handling and request ID tracking
- Proper error handling with actionable suggestions

MCP tools implemented:
- status: Connection and emulation state
- connect/disconnect: VICE session management
- readMemory/writeMemory: Memory access with hex dump formatting
- getRegisters: CPU state with decoded flags
- step/continue: Execution control
- reset: Machine reset (soft/hard)
- setBreakpoint/deleteBreakpoint: Breakpoint management

AX patterns integrated:
- _meta block in all responses (connection state context)
- Structured output (value + hex + hint where relevant)
- Rich tool descriptions with cross-references
- Actionable error messages with suggestions
- Memory region hints for common addresses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:50:27 +01:00
Simen Svale
db47d8ed10 Initial project setup with MCP SDK skeleton
- TypeScript project with tsup build
- MCP server with status, connect, disconnect tools (stubs)
- Uses zod for schema validation
- Builds and starts successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:47:16 +01:00