Centralize g3 status message formatting

Extract a new g3_status module in g3-cli that provides consistent formatting
for all 'g3:' prefixed system status messages.

Key changes:
- Add G3Status struct with methods for progress, done, failed, error, etc.
- Add Status enum with Done, Failed, Error, Resolved, Insufficient, NoChanges
- Add ThinResult struct in g3-core for semantic thinning data
- Update UiWriter trait with print_thin_result() method
- Refactor context thinning to return ThinResult instead of formatted strings
- Update all callers to use the new centralized formatting
- Session resume/decline messages now use G3Status
- Compaction status messages now use G3Status

This maintains clean separation of concerns: g3-core emits semantic data,
g3-cli handles all terminal formatting and colors.
This commit is contained in:
Dhanji R. Prasanna
2026-01-20 09:50:55 +05:30
parent 7bd72a4a51
commit 182f5f98fe
15 changed files with 512 additions and 182 deletions

View File

@@ -27,8 +27,11 @@ pub trait UiWriter: Send + Sync {
/// - "g3:" should be bold green, "failed"/"error" status should be red
fn print_g3_status(&self, message: &str, status: &str);
/// Print a context thinning success message with highlight and animation
fn print_context_thinning(&self, message: &str);
/// Print a context thinning result
fn print_thin_result(&self, result: &crate::ThinResult);
/// Print a context thinning message (legacy - for pre-formatted messages)
fn print_context_thinning(&self, _message: &str) {}
/// Print a tool execution header
fn print_tool_header(&self, tool_name: &str, tool_args: Option<&serde_json::Value>);
@@ -136,7 +139,7 @@ impl UiWriter for NullUiWriter {
fn print_context_status(&self, _message: &str) {}
fn print_g3_progress(&self, _message: &str) {}
fn print_g3_status(&self, _message: &str, _status: &str) {}
fn print_context_thinning(&self, _message: &str) {}
fn print_thin_result(&self, _result: &crate::ThinResult) {}
fn print_tool_header(&self, _tool_name: &str, _tool_args: Option<&serde_json::Value>) {}
fn print_tool_arg(&self, _key: &str, _value: &str) {}
fn print_tool_output_header(&self) {}