Add --status-after flag to mutation subcommands#12262
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a global --status-after flag to the but CLI (legacy) to append workspace status output after mutation subcommands, including a JSON-mode wrapper that combines mutation output and status into a single JSON object for agents.
Changes:
- Introduces JSON buffering in
OutputChannelto capture mutation JSON before emitting combined{ result, status }output. - Adds
--status-afterarg parsing and wires post-mutation status emission intorub,commit,stage,amend, andabsorb. - Updates CLI help snapshots and agent skill docs/examples to demonstrate
--json --status-afterusage.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/but/src/utils/output_channel.rs |
Adds a JSON buffer and helpers to capture JSON output for later combination with status output. |
crates/but/src/lib.rs |
Hooks --status-after into mutation subcommands and implements maybe_run_status_after / run_status_after helpers. |
crates/but/src/args/mod.rs |
Adds the global --status-after CLI flag and help text. |
crates/but/tests/but/command/snapshots/help/rub-short-help.stdout.term.svg |
Updates help snapshot to include the new flag. |
crates/but/tests/but/command/snapshots/help/rub-long-help.stdout.term.svg |
Updates long help snapshot to document the new flag. |
crates/but/skill/references/reference.md |
Documents --status-after in reference examples and flag list. |
crates/but/skill/references/examples.md |
Updates agent-oriented examples to use --json --status-after. |
crates/but/skill/SKILL.md |
Updates guidance to recommend --status-after for agents to save a separate but status call. |
4b39e99 to
26ed86e
Compare
26ed86e to
f693afd
Compare
f8bfdb0 to
eb84974
Compare
98ca798 to
81eea08
Compare
81eea08 to
898f821
Compare
898f821 to
9815def
Compare
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
--status-afterflag to thebutCLI that appends workspace status output after mutation commands (rub,commit,stage,amend,absorb,squash,move,uncommit) completebut status){"result": ..., "status": ...}object — agents save a round-trip by not needing a separatebut statuscall"status_error"field instead); on mutation failure,OutputChannel::dropflushes any buffered structured error JSON (e.g. illegal move details)display_absorption_planreturns plan data instead of writing directly when in non-dry-run mode, allowingabsorb_assignmentsto combine plan + result into a singlewrite_valuecallnew_commit_id,squashed_count)--json --status-afterin all agent-facing examplesImplementation
OutputChannelgains JSON buffering (start_json_buffering,begin_status_after,take_json_buffer) to capture mutation JSON before combining with status JSONmaybe_run_status_after/run_status_afterhelpers handle the two-phase protocol across all mutation match arms, including the implicit rub path (no subcommand, two positional args)OutputChannel::dropsafety net flushes any non-null buffered JSON to stdoutdisplay_absorption_plantakes awrite_jsonparameter:true(dry-run) writes JSON directly,false(non-dry-run) returnsOption<JsonAbsorbOutput>for the caller to merge with operation resultsTest plan
cargo fmt -p but --checkpassescargo clippy -p but --lib --binscleancargo test -p but— all 160 tests pass (2 new)--status-afterin help outputstatus_after_json_wraps_mutation_and_status— verifies{"result": {"ok": true}, "status": {"stacks": ..., "unassignedChanges": ...}}shapestatus_after_json_with_status_error_has_status_error_field— verifiesstatus_errorabsent on success