Skip to content

Refactor (2/5): share protocol strings, tidy the Command layer - #41

Open
yuuu wants to merge 2 commits into
refactor/small-cleanupsfrom
refactor/command-layer
Open

yuuu wants to merge 2 commits into
refactor/small-cleanupsfrom
refactor/command-layer

Conversation

@yuuu

@yuuu yuuu commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Stacked on #40. No change to any command's output.

  • MRDebug::Protocol (mrblib/mrdebug/protocol.rb): the (mrdbg) prompt, Breakpoint /Watchpoint /Stop: banner prefixes, added at, Usage: , EVAL_ERROR, NO_BINDING. Producers (Command, stop banners) and host-side parsers (DeviceLink, DapBridge, Colorizer) plus LocalConsole/Console now share these instead of separate literals, so a wording change can't silently break DAP parsing or coloring. Added to OwnSource::FILES and CLAUDE.md.
  • Command.dispatch: resuming verbs go through .resume; every other verb maps to <verb>_cmd(session, arg) (replaces the 18-arm case).
  • Hand-rolled char_index/last_dot_index/last_colon_index/find_if_clause → core String#index/#rindex (core, so safe under mrbtest).
  • break's reply reuses the breakpoint's own #to_s instead of rebuilding the label.
  • Repeated messages are constants (NO_POSITION, NO_FILESYSTEM, INVALID_LINE); list/cat share source_lines.
  • Character-class helpers (digit?/lower?/upper?/space?/word_char?/digits?) live once in Command and back RubyHighlighter, Json::Parser and MRDebug.default_port (which had its own digits?).
  • MRDebug.error_text(e) replaces four copies of "#{e.class}: #{e.message}".

Tested: rake test:unit (OK 3015, KO 0, Crash 0 — same as before), rake test:smoke (0 failures).

🤖 Generated with Claude Code

https://claude.ai/code/session_01CpfQQRdc3R13RafigfCNVk

- New MRDebug::Protocol holds the prompt, stop-banner prefixes, the
  "added at" reply, "Usage: ", EVAL_ERROR and NO_BINDING. Command, the
  breakpoint banners, DeviceLink, DapBridge, Colorizer, LocalConsole and
  the on-device Console all use it instead of their own literals.
- Command.dispatch: resuming verbs go through .resume; every other verb
  maps to <verb>_cmd(session, arg), replacing the 18-arm case.
- Hand-rolled index loops replaced by core String#index/#rindex.
- break's reply reuses the breakpoint's own #to_s.
- Repeated messages (no position, no filesystem, invalid line) are
  constants; list/cat share source_lines.
- Character-class helpers (digit?/lower?/upper?/space?/word_char?/digits?)
  live in Command and back RubyHighlighter, Json and MRDebug.default_port.
- MRDebug.error_text replaces four copies of "#{e.class}: #{e.message}".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CpfQQRdc3R13RafigfCNVk
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