Expand description
Machine-readable output renderer for SubX-CLI.
This module defines the versioned JSON envelope contract used by
--output json mode, the OutputMode enum surfaced as a top-level
CLI flag, and the OutputRenderer abstraction routed through the
command dispatcher. The text-mode renderer is a thin shim that
preserves today’s interactive UX; the JSON renderer owns stdout
exclusively and emits exactly one JSON document per invocation.
§Stdout / stderr discipline
- JSON mode (
--output json): stdout SHALL receive exactly oneserde_jsondocument terminated by a trailing\n. No other writes to stdout from any command, helper, or library code are permitted —print_success/print_warning/display_match_results/progress bars are silenced for the lifetime of the process. Stderr is also tightened: free-formeprintln!/println!chatter (matcher🔍 AI Analysis Results:block,Total matches:summaries,- file_<id>candidate lines,Warning: Skipping relocation/Warning: Conflict resolution prompt not implemented, etc.) is suppressed. Structuredtracing/logrecords (gated byRUST_LOG) are still allowed; ANSI styling and status symbols are stripped (seecrate::cli::ui). With--quiet, even those structured records are suppressed except for fatal errors emitted by the renderer itself. - Text mode (default): behavior is unchanged from prior releases.
§Schema versioning
SCHEMA_VERSION follows semver. Additive payload changes are
minor bumps; renames or removals are major bumps and require a new
OpenSpec change proposal.
Structs§
- Envelope
- Top-level JSON envelope written to stdout in JSON mode.
- Error
Envelope - Stable error payload carried in
Envelope::error. - Json
Renderer - JSON renderer — owns stdout exclusively in JSON mode.
- Text
Renderer - Text renderer — preserves today’s UX as a no-op for the envelope.
Enums§
- Output
Mode - Output mode selected by the user via
--outputorSUBX_OUTPUT.
Constants§
- SCHEMA_
VERSION - Schema version emitted in every JSON envelope.
Traits§
- Output
Renderer - Renderer trait routing success/error envelopes to the active output stream.
Functions§
- active_
mode - Returns the active output mode, defaulting to
OutputMode::Textwhen not yet installed. - emit_
argument_ parsing_ error - Emit a synthetic argument-parsing error envelope (clap failures).
- emit_
error - Emit an error envelope through the appropriate renderer.
- emit_
success - Emit a success envelope through the appropriate renderer.
- emit_
success_ with_ warnings - Emit a success envelope with optional non-fatal warnings attached.
- install_
active_ mode - Install the resolved output mode and quiet flag globally.
- is_
quiet - Returns whether
--quietis active. - strip_
ansi - Strip ANSI CSI escape sequences from a borrowed string.