Skip to content

Add MCP automation tools for AI agents and a headless stdio server - #38

Merged
bubio merged 8 commits into
mainfrom
feat/mcp-automation
Nov 9, 2026
Merged

bubio merged 8 commits into
mainfrom
feat/mcp-automation

Conversation

@bubio

@bubio bubio commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • AI エージェントがエミュレータを操作・確認するための MCP ツールを、通信手段に依存しない Bubilator88Automation ライブラリとして追加(JSON-RPC ハンドラ、ツール定義、純 Swift の PNG エンコーダ)
  • headless の stdio サーバー bubilator88-mcp を追加
  • Windows 向けの入口として C ABI b88_mcp_handle を追加(追加のみ、public @_cdecl)
  • 開発用ツール:ブレークポイント、ステップ、逆アセンブル、入力の記録・再生、書き込み元追跡とウォッチ、シンボル単位の T-state プロファイル
  • 書き込み追跡は 1 書き込み 1 ロック、履歴は追跡中のみ保持。リセット・ステートロードで破棄
  • エミュレーション部の挙動は変更なし(デバッガ経路のみ)

App 側の利用は bubio/Bubilator88 の feat/mcp-automation。

Test plan

  • swift test(1102 件パス)
  • 回帰スイート scripts/regression_compare.py 20/20 PASS
  • API 互換チェック:破壊的変更なし
  • scripts/format_all.sh --check / scripts/lint.sh
  • headless ベンチマーク:デバッガ経路で書き込み追跡・ウォッチのオーバーヘッドを確認

🤖 Generated with Claude Code

bubio and others added 8 commits October 31, 2026 13:21
Bubilator88Automation implements the tools once against AutomationHost:
running frames, keys and typed text, the screen as PNG and text, disks,
save states, registers, memory, disassembly and breakpoints. MCPHandler
handles one JSON-RPC message at a time and knows no transport.

- bubilator88-mcp serves it over stdio with a headless machine whose
  time moves only with the tools, so runs repeat exactly.
- b88_mcp_handle / b88_mcp_reply expose it through the C ABI for the
  Windows shell.
- PC88.peekMemory (SPI) reads memory without charging wait states,
  loading the ALU latches or firing read breakpoints.
- PNGEncoder is pure Swift so it builds on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
write_memory, set_registers, load_bin, memory_map, trace, dump_memory
and tape, backed by new Debug SPI on PC88: pokeMemory, setRegisters,
physical memory regions and the main CPU's current memory map.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
record_start saves a .b88s, key/type_text/run_frames are recorded, and
record_stop adds them to the file as an AREC section. replay restores
the state and runs the same input on the same frames. Tools a replay
could not repeat are refused while recording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The debugger now keeps, while asked, the instruction that last wrote each
byte, by where the byte physically lives, and stops after an instruction
that writes into a watched range. Both ride the debugger's existing write
hook, so the plain execution path is unchanged. The MCP tools gain
write_tracking, last_writer and watch_add/list/remove.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Profiler attached to the machine adds each instruction's T-states, waits
and count to per-address tables from the debugger path's tick, keeping
halts and interrupt acknowledges apart and timing begin/end regions. The
tools load an assembler's symbol file, group the counts by label when they
report, and accept symbol names wherever an address is asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Clear the write history on a cold reset or state load even while the
  debugger is detached, and on resets made by scripts.
- Drop open profile regions when the T-state count jumps, so a region
  open across a reset or load no longer wraps to a huge time.
- Skip region timing on halted ticks, so a loop round a HALT is timed
  once per pass.
- Count an interrupt acknowledge's waits with the acknowledge instead
  of the next instruction.
- Work out a write's location outside the debugger lock, and only when
  it is tracked or may match a watch; read the watches through a copy
  kept out of observation.
- Report watches like breakpoints: the last hit in an instruction wins,
  and a hit during a single step still reports.
- Disassemble only the profile rows that are listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The review fixes took the debugger lock up to three times per memory
write and kept a weak reference in Machine so a detached debugger's
history could still be cleared. Instead:

- noteMemoryWrite takes the lock once; describe only reads the bus.
- watches are unobserved (no view shows them), with no mirror copy.
- Turning write tracking off forgets the writers, so the history only
  exists while a debugger is attached and Machine clears it through
  that debugger. last_writer refuses while tracking is off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bubio
bubio merged commit 76c4b54 into main Nov 9, 2026
3 checks passed
@bubio
bubio deleted the feat/mcp-automation branch November 9, 2026 01:36
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.

1 participant