rch_common/ui/mod.rs
1//! UI utilities for RCH terminal output.
2//!
3//! This module provides context-aware output utilities that automatically
4//! adapt to the current environment (interactive terminal, hook mode, piped, etc.).
5//!
6//! # Key Components
7//!
8//! - [`OutputContext`]: Detects and represents the current output context
9//! - [`Icons`]: Unicode icons with automatic ASCII fallbacks
10//! - [`RchTheme`]: Brand colors and semantic styles
11//!
12//! # Design Philosophy
13//!
14//! - **stdout** is for DATA (JSON, compilation output, etc.)
15//! - **stderr** is for DIAGNOSTICS (status, progress, errors)
16//!
17//! Rich output goes to stderr so that:
18//! 1. Agents can parse stdout reliably
19//! 2. Piping `rch status | jq` works correctly
20//! 3. Compilation output passthrough is unaffected
21//!
22//! # Example
23//!
24//! ```ignore
25//! use rch_common::ui::{Icons, OutputContext, RchTheme};
26//!
27//! let ctx = OutputContext::detect();
28//! eprintln!("{} Build successful", Icons::check(ctx));
29//!
30//! // With rich-ui feature enabled:
31//! let style = RchTheme::success();
32//! ```
33
34pub mod context;
35pub mod display;
36pub mod error;
37pub mod errors;
38pub mod icons;
39pub mod progress;
40pub mod theme;
41
42pub use context::OutputContext;
43pub use display::{
44 IntoErrorPanel, ResultExt, anyhow_to_json, anyhow_to_panel, display_anyhow_error,
45 display_error, display_error_with_code, error_to_json, error_to_panel,
46};
47pub use error::{ErrorContext, ErrorPanel, ErrorSeverity, show_error, show_info, show_warning};
48pub use errors::NetworkErrorDisplay;
49pub use icons::Icons;
50pub use progress::{
51 AnimatedSpinner, ArtifactSummary, BuildPhase, BuildProfile, CelebrationSummary,
52 CompilationProgress, CompletionCelebration, CrateInfo, PipelineProgress, PipelineStage,
53 ProgressContext, RateLimiter, SpinnerResult, SpinnerStyle, StageStatus, TransferDirection,
54 TransferProgress,
55};
56pub use theme::RchTheme;