Skip to content

ripple v0.12.0

Choose a tag to compare

@github-actions github-actions released this 23 Apr 12:31
· 64 commits to master since this release

Two themes drive this release. (1) pwsh output fidelity — encoded_scriptblock multi-line delivery (faster than tempfile, no disk I/O, same dot-source scope semantics) is now the default, unlocked by a fix to the VT interpreter feed that had the baseline grid drifting one chunk past the OSC C boundary. Non-terminating errors now surface as ⚠ Completed with errors + Errors: N on the status line so Write-Error / cmdlet failures can't hide behind a green ✓ just because the process exited 0. Stale $LASTEXITCODE no longer leaks from a preceding native-exe pipeline into the next pure-PS pipeline's reported exit code. (2) Output rendering hardening at the MCP boundary — OSC 8 hyperlinks are preserved as <URI> cells instead of dropped, dangling SGR on either side of the output block is cleaned up (leading no-op reset stripped, trailing reset added when output ends mid-colour), stale SGR no longer bleeds onto cells that are overwritten with different characters, and ripple-exec tempfile paths are stripped from PowerShell ConciseView error summaries so ripple's implementation detail stops leaking into AI error traces.

Separately: a new list_shells MCP tool replaces startup stderr noise with a queryable discovery endpoint (startup stderr is now two-tier — silent modes only surface user-actionable load issues); AI-initiated cd is no longer misattributed as user drift (replaced the cwd-snapshot heuristic with a provenance counter); PTY width tracks the visible ConHost width instead of flooring at 200 so \r-based self-repainting Write-Progress bars work; a safety-net try/finally guarantees HandleExecuteAsync releases the user-input hold gate on every exception path.

Acknowledgments

  • @doraemonkeys — PR #7 (\xNN → \uNNNN in send_input docs) and PR #8 (surface send_input in the busy-timeout hint). Both landed as in-repo doc fixes that close discoverability gaps the AI consumer would otherwise hit exactly when it needed to rescue a stuck console.

Added

  • Errors: N counter on the status line for PowerShell commands. PowerShell maintains an automatic per-runspace $Error ArrayList that accumulates every cmdlet non-terminating error, Write-Error invocation, and thrown exception. ShellIntegration/integration.ps1 snapshots $Error.Count at PreCommandLookupAction and emits the post-command delta as a new OSC 633;E;{N} marker; the worker carries the value through CompletedCommandSnapshot.ErrorCount, the proxy reads it from the response, and FormatStatusLine (and BuildStatusLine for cached drains) prepend | Errors: N when N > 0. Zero is silent so the happy path keeps the existing line shape. Other shells emit no OSC E and stay at zero — no analogous always-on counter exists for Write-Warning / Write-Information (cmdlets bypass any user-defined proxy via $PSCmdlet.WriteWarning, so they can't be reliably counted from inside the integration script), so warnings and info are intentionally not tracked. Three regression asserts in OscParserTests cover OSC E parsing (positive count, zero, malformed payload defaults to 0).

  • OSC 8 hyperlinks preserved as <URI> in the MCP response. Modern terminals (xterm, Windows Terminal, iTerm2, VS Code) accept \e]8;;<URI>\a link-text \e]8;;\a to make link-text clickable. Build tools (dotnet, some linters), Write-Information, and IDE integrations emit these around file paths and documentation URLs. Previously ripple dropped them with every other OSC, losing the destination — the AI saw only the link-text and couldn't reference the URI back to the user. Now CommandOutputRenderer detects OSC 8 (open and close variants, both BEL- and ST-terminated) and injects the captured URI into the grid as <URI> cells right after the link-text, e.g. "click here<https://example.com/>". All other OSCs still drop silently. Six asserts added to CommandOutputFinalizerTests covering BEL/ST terminators, params segment (id=foo between the semicolons), unclosed opens, stray closes, and mix with surrounding OSC 0/7 traffic.

  • MCP tool hint when large output spills to disk. When a command's output exceeds the 15 KB threshold and gets written to a spill file, the preview now surfaces ripple's own search_files / read_file MCP tools as the recommended way to drill into the spill file — instead of leaving the AI to reach for shell grep / cat (which round-trips through the same PTY the command just ran in). The hint uses bare tool names so it stays valid no matter which MCP client prefix wraps ripple (ripple / ripple-stable / ripple-dev all resolve via the client's tool list).

  • encoded_scriptblock multi-line delivery mode for the pwsh adapter. New multiline_delivery schema value. Base64-encodes the multi-line body and sends a single-line . ([ScriptBlock]::Create([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String(<b64>)))) invocation. Dot-sourcing preserves caller scope the same as the tempfile path but avoids disk I/O and history-filter bookkeeping entirely. Shares the body builder (BuildMultiLineTempfileBody) with the tempfile path so both deliveries produce identical echo + OSC-C semantics — only the delivery wrapper differs. Roughly 0.3–0.5s faster than tempfile on the warm path for the common multi-line case.

  • ⚠ Completed with errors status badge. Post-command status splits into three outcomes instead of two: exit != 0 → ✗ Failed, exit == 0, errors > 0 → ⚠ Completed with errors, exit == 0, errors == 0 → ✓ Completed. pwsh commands that hit a Write-Error or non-terminating cmdlet failure exit 0 but bump $Error — a plain green ✓ understated what the AI needed to look at. The ⚠ badge pairs with the existing Errors: N tag so one status line carries both outcome category and error count without a second round trip. Applied consistently at both the Tools surface and ConsoleWorker's own rendering so the two sites can't drift.

  • list_shells MCP tool. Discovery endpoint for what values the current ripple build accepts as the shell argument to execute_command / start_console. Returns a JSON object with a shells array — one entry per registered adapter carrying name, aliases, description, family (shell / repl / debugger), source (embedded / external), and the executable start_console would actually launch (or null + executable_note when the name / override is not on PATH). The tool description also documents that any absolute path can be passed as shell to launch an unregistered REPL — with the caveat that without a matching adapter ripple runs it in a minimal mode (no prompt-boundary detection, no exit code, no cwd tracking), so a YAML in ~/.ripple/adapters/ is the right move for anything used regularly. A load_issues object on the response carries every parse error / collision / override detected at startup with a user_actionable flag.

Changed

  • Startup stderr goes two-tier. CLI modes (--test, --list-adapters, --adapter-tests, etc.) still print the full [ripple adapters info] / WARNING summary — a human is reading the terminal. Silent modes (MCP stdio server, ConPTY worker via --console) now suppress the info-level roll-up entirely and print only the subset of issues a user can act on: parse errors and collisions involving an external YAML the user dropped in ~/.ripple/adapters/. Embedded-only failures are ripple bugs the user can't fix, and firing them at every prompt was noise without a path to resolution. AI consumers needing the full picture call list_shells. Supporting helpers on the registry: AdapterLoader.ParseError is now a record carrying Embedded / External source; AdapterRegistry.LoadReport gains Collision (with IsUserActionable), HasUserActionableIssues, and UserActionableSummary; the load report is persisted alongside Default via SetDefault(registry, report) so list_shells surfaces startup issues without re-running the load. --list-adapters output is updated for the typed report (parse errors show [source] prefix, collisions show (user-actionable) suffix).

  • pwsh multi-line delivery default flipped to encoded_scriptblock. Now that the baseline-bleed race that previously tripped encoded delivery is fixed upstream (see the OSC-aligned _vtState feed under Fixed), adapters/pwsh.yaml defaults to encoded_scriptblock. 20+ consecutive burn-in runs of the original bleed repro (if ($true) { "a"; "b"; 1..3 | ForEach-Object { "iter $_" } }) produce clean output on the new default. tempfile remains selectable for bodies whose decoded length would exceed PSReadLine's input line cap.

  • execute_command busy-timeout hint now mentions send_input. When a command times out, the response header previously pointed only at wait_for_completion, which never returns when the command is actually stuck on an interactive prompt (pager, Read-Host, y/n confirmation). The hint now surfaces send_input as a peer tool with a role label (wait_for_completion (retrieve result), send_input (if stuck on interactive prompt / pager)) so the rescue path is discoverable at the moment it's needed. Contributed by @doraemonkeys in PR #8.

  • send_input documentation recommends JSON-native \uNNNN escapes. Both the tool and input parameter [Description] strings previously advised C-style \xNN hex escapes (e.g. \x03 for Ctrl+C, \x1b[A for arrow-up). JSON does not accept \xNN, so strict parsers rejected callers and lenient parsers passed through four literal characters — either way the advertised "send Ctrl+C" behavior did not reach the PTY, and agents following the docs verbatim got stuck rescuing pager-blocked consoles. The docs now recommend \u0003 / \u001b[A and include an explicit note that JSON does not accept \xNN. Runtime behavior is unchanged: ConsoleWorker.UnescapeInput still recognises the old \xNN form and is covered by existing tests; the new \uNNNN form is decoded by the JSON layer into real control bytes and passes through UnescapeInput untouched. Contributed by @doraemonkeys in PR #7.

  • GHA workflow actions bumped to v5. actions/{checkout,setup-dotnet,setup-node,upload-artifact,download-artifact} move from @v4 to @v5 ahead of GitHub's forced Node.js 24 switch on 2026-06-02 and Node 20 removal on 2026-09-16. No API changes needed. azure/login@v2 is already on Node 24 and stays.

Fixed

  • Dangling SGR at output boundaries is now cleaned up. Two symmetric boundary cases previously leaked visible noise or bled colour into consumer state: (a) a LEADING \e[m / \e[0m reset that serves no purpose at the MCP boundary (the consumer hasn't applied any SGR yet), e.g. Write-Progress cleanup dropping a reset at the bar's column which then attached as the SgrPrefix of the first non-bar character and showed up as [mafter garbage; (b) a MISSING trailing reset when the output ends mid-colour — observed when Write-Error or a coloured diagnostic's final byte is the message text, with no \e[0m to close, leaving the consumer's next prompt stuck red. CommandOutputFinalizer.CleanString now strips leading reset-only SGR sequences AND appends \e[0m when the cumulative SGR state at end-of-output is non-default (determined by scanning the last SGR sequence: parameters empty or all-zero = reset, anything else = setter). Eight regression asserts in CommandOutputFinalizerTests cover single / chained leading resets, preserved leading setters, missing / existing / bare-form trailing resets, plain text with no SGR, and the combined case.

  • Tempfile path no longer leaks into multi-line AI command error output. Multi-line AI commands are wrapped into a .ripple-exec-<pid>-<guid>.ps1 (or .cmd / .sh) file and dot-sourced, which is invisible for the happy path but PowerShell's ConciseView error renderer prefixes the summary with {Cmdlet}: {TempfilePath}:{Line}, exposing ripple's implementation detail. AI consumers had no way to know that path was a wrapper they didn't write — it just looked like an unrelated file in their error trace. CommandOutputFinalizer.CleanString now strips any line containing a ripple-exec-<pid>-<hex>.{ps1,cmd,sh} reference (Windows or POSIX flavor); the Line | N | <source> block below — which carries the actual diagnostic — is preserved untouched. Single-line AI commands never wrap, so they never produced this leakage and stay unaffected. Five regression asserts in CommandOutputFinalizerTests cover pwsh ConciseView output, bash on POSIX, cmd.exe .cmd paths, mid-line occurrences, and a negative case verifying that unrelated .ps1 paths are untouched.

  • Stale SGR no longer bleeds into text that overwrites previous cells. CommandOutputRenderer.WriteChar used prefix ?? existing.SgrPrefix on every cell overwrite, which inherited the old cell's SGR prefix whenever no new SGR was pending. That's correct for ConPTY repaint idempotence (same char redrawn should keep its color), but wrong for genuine content changes: PowerShell's Write-Progress Minimal view leaves reverse-video \e[7m cells on the row it used for the bar, and the cleanup path doesn't reset the SGR attribute on those cells before normal text later writes over them. Observed: Write-Progress ... ; "after" produced [mafter [7mprogress (garbled — reverse video leaked into random words). Fixed by splitting the overwrite decision: (a) new SGR pending → use it; (b) same char, no new SGR → keep existing (repaint); (c) different char, no new SGR → drop existing SGR — the previous character and its SGR belonged together. Three regression asserts added to CommandOutputFinalizerTests: overwrite-diff drops stale SGR, repaint-same-char preserves it, partial overwrite drops on touched cells while leaving the tail untouched.

  • Stale $LASTEXITCODE no longer bleeds into subsequent pure-PowerShell pipelines. ShellIntegration/integration.ps1's prompt fn previously read $global:LASTEXITCODE verbatim as the OSC D exit code. $LASTEXITCODE is only updated by native executables, so after e.g. cmd /c "exit 7" the value stayed at 7 and every subsequent innocent PS pipeline (1..3 | ForEach-Object {...}, Get-Date) was reported as Failed (exit 7). Fixed by: (1) capturing $? as the first statement of the prompt fn — it's PowerShell's canonical pipeline-success indicator and is updated by cmdlets, natives, and statements alike; (2) snapshotting $LASTEXITCODE at PreCommandLookupAction so the prompt fn can tell whether the value was updated BY this pipeline or inherited; (3) resolving the exit code in priority order: $? true → 0; $? false and $LASTEXITCODE changed non-zero → use it; $? false otherwise → generic failure 1. Multi-line AI pipelines (run via . 'tempfile.ps1'; Remove-Item '...') would otherwise see $? reflect Remove-Item, so BuildMultiLineTempfileBody now stashes $? and $LASTEXITCODE into globals inside the tempfile's scope that the prompt fn reads with priority. Two regression tests added to adapters/pwsh.yaml: cmdlet_error_surfaces_exit_1 (cmdlet error → exit 1, not stale 0) and lastexitcode_does_not_leak_after_native (setup native exit 7, eval pure PS → must be exit 0).

  • AI's own cd is no longer misattributed as a user-initiated drift. Drift detection previously compared the source console's LastAiCwd against the current OSC 633;P;Cwd= snapshot; if the two diverged for any reason — including internal state lag such as standby-rotation ordering or a race between RecordShellCwd and the next get_status — the proxy concluded the human had moved the shell and emitted a spurious source #N was moved by user to '...'; ran in #M at your last known cwd '...' routing notice while silently reverting the AI to a stale cwd. Replaced with a provenance counter (CommandTracker.UserCmdsSinceLastAi) that increments exactly once per user-typed command at OSC A (closing a user-busy cycle) and resets to 0 on every RegisterCommand. The worker now exposes the counter as a userCmdsSinceLastAi field on get_status, and ConsoleManager.PlanExecutionAsync reads it instead of comparing cwd snapshots. AI-initiated cd → counter stays 0 → no drift; user-initiated command (cd or otherwise) → counter increments → drift handled correctly. Removes the old IsCwdDrifted helper and its unit tests; adds 13 new provenance-counter asserts to CommandTrackerTests covering pwsh (B→C→D→A), bash/zsh (C→D→A), bare-OSC-A repeats, startup-OSC-B gating, and the interleaved AI-cd / user-cmd / AI-cmd scenario that reproduces the original bug in unit form.

  • Explicit LineFeed clears a stale soft-wrap flag on baseline rows. An explicit LineFeed means the destination row is a new logical line, not a soft-wrap continuation. Baseline rows that were wrap continuations of pre-command content (e.g. a long input echo that has since been erased) previously kept their ContinuedFromAbove flag, causing the render-time join logic to chain command-emitted rows onto predecessors and produce collapsed output like abiter 1\niter 2 instead of a\nb\niter 1\niter 2. Clearing the flag when LineFeed targets a row within the baseline range lets each command-written line stand on its own at render time.

  • PTY width tracks the visible console width instead of flooring at 200. The old floor-at-200 policy was meant to dodge mid-word soft-wraps in AI output but broke self-repainting lines. pwsh's Write-Progress pads its bar to the declared PTY width; when that exceeded the visible ConHost width the bar wrapped physically and the trailing \r returned only to the wrapped row, leaving each progress update stacked vertically instead of overwriting in place. Matching the visible width makes \r-based in-place repainting behave correctly. Mid-word splits on very narrow terminals remain a theoretical edge case the AI can still read around (and they match what the user is looking at anyway). Same change in the spawn-time path and in ResizeMonitorLoop — they stayed in sync with the old policy and stay in sync with the new one.

  • _vtState fed in OSC-aligned slices so baseline reflects the OSC C boundary. ConsoleWorker.ReadOutputLoop used to advance the live VT interpreter with an entire PTY chunk before the OSC event loop ran, so the snapshot handed to CommandOutputRenderer at CommandExecuted reflected end-of-chunk state rather than the screen at the OSC C byte. When a single PTY read straddled OSC C and downstream command-output bytes — the common case on encoded_scriptblock multi-line delivery — the baseline grid carried cells from the command output the renderer was about to replay and the cursor landed past the row the AI expected first output to reach. The renderer then wrote "a" onto a row whose stale tail was "ter 3", producing "ater 3" (or dropped the line entirely when the cursor ended up on an already-written row). Feed the VT interpreter in slices aligned to OSC event offsets instead. Snapshot at CommandExecuted now reflects state as of the OSC C byte exactly. Cleaned text (OSC 633 stripped) is equivalent to raw for VT interpretation — OSC is dropped by ApplyOsc, DSR queries are stripped upstream — so no state semantics change. CommandOutputRendererTests now documents the renderer's baseline sensitivity and the slice-by-offset happy-path assertion.

  • _holdUserInput gate and _heldUserInput queue are now guaranteed to release on every exit path. The hold-gate + queue mechanism (held user keystrokes replay after the AI command finishes so partial typed input isn't lost) previously leaked on any unhandled exception path — WriteToPty failures, Task.WhenAny surfacing an unexpected exception type, snapshotTaskLocal throwing non-TimeoutException / non-InvalidOperationException. The flag would stay true, user keystrokes kept piling into a queue nobody would drain, and the next execute_command would start with an already-poisoned shell. HandleExecuteAsync now wraps the body from _holdUserInput = true onwards in try/finally and calls ReleaseHeldUserInput() from the finally. Explicit releases on the happy path, timeout branch, and finalize-failed branch are preserved so the shell still gets the "head start" semantics (release before JSON serialization, keystrokes replay while the proxy formats the response). ReleaseHeldUserInput is idempotent (flag assignment + TryDequeue loop empty-exit + flush try/catch) so the duplicate call on normal paths is a no-op.