Remove ANSI formatting codes from g3-core
Move terminal formatting responsibility to g3-cli layer: - format_str_replace_summary(): Remove ANSI codes, add colorize_str_replace_summary() helper in CLI to apply green/red colors for insertions/deletions - format_timing_footer(): Remove dimming ANSI codes (now plain text) - str_replace tool result: Remove ANSI codes from success message Remaining acceptable ANSI usage in g3-core: - iTerm2 inline image protocol (terminal-specific escape sequence) - Image metadata dimming (direct print, would need larger refactor) - Terminal beep for stale TODO warning (audio, not visual) - ANSI stripping utility in research.rs (not output) This continues the separation of concerns: g3-core handles logic, g3-cli handles all terminal formatting.
This commit is contained in:
@@ -142,11 +142,11 @@ pub fn format_timing_footer(
|
||||
// Add token usage info if available (dimmed)
|
||||
if let Some(tokens) = turn_tokens {
|
||||
format!(
|
||||
"{} \x1b[2m{} ◉ | {:.0}%\x1b[0m",
|
||||
"{} {} ◉ | {:.0}%",
|
||||
timing, tokens, context_percentage
|
||||
)
|
||||
} else {
|
||||
format!("{} \x1b[2m{:.0}%\x1b[0m", timing, context_percentage)
|
||||
format!("{} {:.0}%", timing, context_percentage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,11 +326,11 @@ pub fn format_write_file_result(tool_result: &str) -> String {
|
||||
/// Format a str_replace result summary.
|
||||
pub fn format_str_replace_summary(insertions: i32, deletions: i32) -> String {
|
||||
if insertions > 0 && deletions > 0 {
|
||||
format!("\x1b[32m+{}\x1b[0m \x1b[2m|\x1b[0m \x1b[31m-{}\x1b[0m", insertions, deletions)
|
||||
format!("+{} | -{}", insertions, deletions)
|
||||
} else if insertions > 0 {
|
||||
format!("\x1b[32m+{}\x1b[0m", insertions)
|
||||
format!("+{}", insertions)
|
||||
} else {
|
||||
format!("\x1b[31m-{}\x1b[0m", deletions)
|
||||
format!("-{}", deletions)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -582,7 +582,7 @@ pub async fn execute_str_replace<W: UiWriter>(
|
||||
|
||||
// Write the result back to the file
|
||||
match std::fs::write(&file_path, &result) {
|
||||
Ok(()) => Ok(format!("✅ \x1b[32m+{} insertions\x1b[0m | \x1b[31m-{} deletions\x1b[0m", insertions, deletions)),
|
||||
Ok(()) => Ok(format!("✅ +{} insertions | -{} deletions", insertions, deletions)),
|
||||
Err(e) => Ok(format!("❌ Failed to write to file '{}': {}", file_path, e)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user