Feature: let a host observe shell commands as they run - #95
Merged
Merged
Conversation
execute_command already produces everything a live display needs — the command, its working directory, each line of output as it arrives, and an exit code — and then throws all of it away except a one-line spinner activity string truncated to 80 characters. Add an optional ICommandOutputSink a host can attach to receive that lifecycle. Purely observational: it cannot gate or alter a command, and every callback is wrapped so a faulting display can never propagate into the command the agent is running. Deliberately teed OUTSIDE the 5000-character output cap. That cap protects the model's context window; a host display has its own scrollback, and inheriting the cap would hide the tail of exactly the long build output someone opened a panel to watch. Nothing changes for a caller that attaches no sink — the CLI passes none and behaves as before. The sink is handed to the plugin on every agent rebuild, so a host attaches once and keeps it across model switches and settings changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional hook that lets a host application watch the assistant's shell commands as they run — the command, its output line by line, and how it ended. Nothing uses it yet in the CLI; it exists so MandoCode Desktop can show the user a live view of commands instead of only reporting them afterward.
Why this matters
When the assistant runs a shell command today — a build, a test run,
git status— the user sees a single truncated status line while it works, then the finished output. Adotnet buildthat takes ninety seconds is ninety seconds of near-silence. There is no way for the host to show the work in progress, because the information needed to do that is discarded as it is produced.Everything a live display needs already exists inside the command runner. It is simply not offered to anyone. This makes it available.
What is new
cdis not reported. That case is intercepted and never starts a process, so announcing it would leave a command header on a display with nothing under it.Scope and risk
Low. One new optional parameter, defaulted to nothing, on two constructors. Callers that pass no sink — which is every caller today, including the CLI — take an identical path to before. No change to what the model receives, to timeouts, to output caps, or to how commands are launched or killed.
The one thing worth a reviewer's attention: output callbacks are raised on the command's output-reader threads, so an implementation must be thread-safe and fast, since each callback runs inline with reading the command's output. This is documented on the interface, and the accompanying Desktop change is expected to hand off to its UI thread immediately.
Verification
Full engine suite passes on both target frameworks — 733 of 733 on .NET 10 and .NET 8. Five new tests cover the lifecycle end to end: start/output/exit reporting, a non-zero exit reported as a failure rather than a kill, a bare
cdproducing no report, output surviving past the model's truncation cap, and a throwing sink leaving the command unaffected.Not covered: no test exercises a killed command's reporting path, since that requires waiting out the 30-second idle timeout. The code path is one line alongside the existing kill handling.
Dependency
Nothing depends on this landing first, but it is a prerequisite for the MandoCode Desktop change that adds a live agent output view. That work needs this merged and the Desktop submodule pin moved forward.