# Changelog

All notable changes to the rdbg Claude Code plugin.

## [Unreleased]

### Changed

- **`send_input` is on by default** — removed the `--allow-send-input`
  daemon flag. Driving the UI is one of the plugin's advertised
  features, so making it opt-in produced a confusing failure mode
  (`"send_input disabled (start daemon with --allow-send-input)"`)
  the first time an agent reached for it. The flag is now silently
  ignored if a user passes it; remove it from your `daemon_args`
  if you customised them.

### Added

- **First-time-user-path polish** (from real-user feedback):
  - `hello` response now includes a `daemons` object showing
    BOTH x64 and x86 daemons' status (`{running, port, version,
    daemon, target_arch, active_sessions}`) in a single call —
    previously only the connected bitness was visible.
  - New `bridge_config` MCP tool: pure introspection over the
    bridge's effective config — host, ports, daemon paths,
    auto_start state, current target arch, interactive session
    flag, live cross-bitness probe results, and LSP-side state
    (delphilsp_path, default_project, autogen_disabled, active
    projects, current project). Useful for debugging
    *"why didn't auto_start fire"* / *"which daemon is the
    bridge using"* without squinting at stderr.
  - `rdbgd64`/`rdbgd32` CLI now prints
    *"error: must specify --listen <addr:port> or --test-launch
    <exe>"* instead of the misleading *"unknown arguments"* when
    a recognised flag is supplied without a mode flag.

- **State-machine + honesty fixes**:
  - **Stale paused-event scrub**: bridge now scrubs queued
    `paused` events from its local event queue before sending
    `continue` / `step_over` / `step_into` / `run_to` /
    `set_rip` / `detach` / `kill_session`. Eliminates the
    `launch + continue + events → stale loader-BP paused event
    + next continue errors "target is running"` cycle.
  - `set_exception_filter` is now actually enforced. Previously
    the handler accepted the filter shape but always returned
    `warning: not yet enforced`. Now the filter is stored on the
    session; `OnException` consults `Allows(class, first_chance)`
    before emitting AND before pausing — filtered exceptions
    don't freeze the target.
  - `get_main_form` HWND-scan fallback. When the
    `Application` global symbol isn't in the .map / PDB (common
    on default Delphi 12 builds), the handler now scans the
    target's top-level VCL windows via `find_vcl_for_hwnd`'s
    primitives, picks the first visible top-level form, and
    surfaces every candidate as `candidates[]` so the agent
    can disambiguate.

- **Signal-to-noise improvements**:
  - `inspect_object` accepts new optional flags
    `include_methods` (default `true` for back-compat) and
    `methods_from_leaf_only` (default `false`). Setting
    `include_methods=false` drops the methods array entirely
    (~3KB saved on a typical exception class when the agent
    only wants fields/props).
  - Exception event `frames[]` now includes a `kind` field on
    every frame: `user` (target's main exe), `system` (Windows
    DLLs — kernelbase/ntdll/user32/etc.), `rtl` (Delphi runtime
    packages, `*.bpl`), or `unknown`. Agents can filter by
    `kind == 'user'` to find user-code frames instantly without
    re-implementing module-name heuristics.

- **`read_param` MCP tool** — read the calling-convention
  argument register for the paused thread without needing TD32
  debug info. `index=0` is first arg, etc. x64 maps RCX/RDX/R8/R9;
  x86 (Delphi register convention) maps EAX/EDX/ECX. Index ≥ N
  reads from the appropriate stack slot. Optional `kind`
  decodes the value as a Delphi string / raw memory through the
  same primitives `read` uses. Closes the user complaint
  *"can't inspect StrToInt's argument without TD32"* — now one
  call gets the bad input.

- **DelphiLSP code-navigation surface** — 10 new MCP tools backed
  by Embarcadero's DelphiLSP, alongside the existing runtime-debug
  surface in the same bridge process:
  - **Navigation**: `lsp_definition`, `lsp_declaration`,
    `lsp_implementation` (jumps from interface decl to body),
    `lsp_hover`, `lsp_references` (server-backed when advertised).
  - **Authoring**: `lsp_completion` (with trigger-char + kind
    metadata), `lsp_signature_help`.
  - **Outline**: `lsp_document_symbols` (hierarchical),
    `lsp_workspace_symbol` (server-backed when available; falls
    back to per-file `documentSymbol` aggregation with
    `precision: "approximate"`).
  - **Diagnostics**: `lsp_diagnostics` (pull-style snapshot of
    cached `publishDiagnostics`; per-URI wait-event lets callers
    block briefly for first diagnostics after didOpen).
  - **Project lifecycle**: `lsp_open_project` — bootstrap and
    set the active default project. Multi-project registry
    caches one DelphiLSP child per `.delphilsp.json`; idle
    channels reaped after 5 min.
  Capability-gated against DelphiLSP's
  `initialize.result.capabilities` so unsupported tools don't
  surface (e.g. `lsp_references` is hidden on Delphi 12 because
  `referencesProvider` isn't advertised there).
- **`.delphilsp.json` autogen from `.dproj`** — the bridge
  generates the LSP project config from any `.dproj` without
  needing the user to tick *Tools > Options > Code Insight >
  Generate LSP Config* in the IDE. Fires automatically when a
  `.dproj` is hinted or walked-up to and no fresh sibling
  `.delphilsp.json` exists. Opt out via
  `RDBG_LSP_NO_AUTOGEN=1`.
- **DelphiLSP discovery** via registry walk
  (`HKCU\Software\Embarcadero\BDS\<24.0|23.0|22.0>\RootDir`,
  most-recent-first, preferring `bin64\DelphiLSP.exe` over
  `bin\DelphiLSP.exe`). Override via `RDBG_DELPHILSP_PATH`.
- **License-error translation** — DelphiLSP's
  *"valid license was not found"* error (typically caused by
  spawning from a non-interactive session) is rewritten with an
  actionable bridge-level explanation pointing at the
  interactive-session requirement and `registry.slm`.
- New skill **`delphi-code-navigation`** — guides Claude on
  when to use LSP tools vs. grep, when LSP tools complement
  runtime debugging, and the project-resolution model.
- New user_config keys: `delphilsp_path`,
  `lsp_default_project`, `lsp_disable_autogen`. Env-var
  overrides: `RDBG_DELPHILSP_PATH`, `RDBG_LSP_PROJECT`,
  `RDBG_LSP_NO_AUTOGEN`, `RDBG_LSP_PLATFORM`, `RDBG_LSP_CONFIG`.

- `inspect_locals` MCP tool — returns parameter and stack-local
  information for the procedure containing the paused frame's RIP.
  Reads the EXE's `.debug` TD32/TDS section (Borland CodeView 4
  derivative; magic `FB09`); target must be built with `-V`
  ("Place debug information in EXE"). Auto-walks past
  kernel32/wil DLL frames at `DebugBreak()` to land on user code.
  Surfaces all four version-gating outcomes (`tdsOk` /
  `tdsNoDebugSection` / `tdsVersionMismatch` / `tdsCorrupt`) as
  structured wire errors with `version_warning` + `fallback_hint`
  + `diagnostic_command`. Skill updates in
  `delphi-debugging-workflow` and `delphi-rtti-inspection` teach
  the agent to use it; `delphi-bug-hunter` agent gains the tool.

## [0.1.0] — Unreleased

Initial release. Tracks `rdbg` 0.2.

### Added

- MCP server (`rdbg-mcp.exe`) wrapping the rdbg JSON-RPC wire protocol
  for use as a Claude Code subprocess. Stdio transport, ~33 tools
  spanning process control, breakpoints, stepping, RTTI inspection,
  VCL discovery, GUI capture, input injection, and exception
  filtering.
- Auto-spawn of `rdbgd64.exe` if not already running, with detached
  spawn so the daemon outlives Claude Code restarts. Session
  pre-check refuses to spawn from non-interactive contexts.
- Five skills:
  - `delphi-debugging-workflow` — primary debugging rhythm.
  - `exception-triage` — first-chance vs second-chance, frame walking.
  - `gui-bug-reproduction` — demo-and-record vs autonomous repro.
  - `delphi-rtti-inspection` — `inspect_object` + `read` walking.
  - `vcl-self-discovery` — bootstrap UI tree from RTTI, fuzz it.
- `delphi-bug-hunter` subagent for autonomous bug investigation.
- Slash commands: `/rdbg:status`, `/rdbg:start-daemon`,
  `/rdbg:install-help`.
- Wire commands added in this release (require rdbg 0.2+):
  `find_vcl_for_hwnd`, `get_main_form`, `enumerate_vcl_tree`,
  `set_text_field`, `screenshot_desktop`, `set_exception_filter`,
  and a `filter` parameter on the existing event push.

### Out of scope (v1)

- SSH-to-remote-Windows debugging.
- Cross-platform `rdbg-mcp` builds (darwin, linux).
- `inspect_locals`, expression evaluator, data watchpoints.
