Clean up tool output formatting

- Shell: " Command executed successfully" → "️ ran successfully"
- Write file: Remove ✏️ emoji, use plain "wrote N lines | M chars"
This commit is contained in:
Dhanji R. Prasanna
2026-01-14 19:42:54 +05:30
parent 9ef064a041
commit 38828c7757
5 changed files with 48 additions and 10 deletions

View File

@@ -303,20 +303,20 @@ pub fn format_write_file_summary(line_count: usize, char_count: usize) -> String
} else { } else {
format!("{}", char_count) format!("{}", char_count)
}; };
format!("✏️ {} lines ({} chars)", line_count, char_display) format!("wrote {} lines | {} chars", line_count, char_display)
} }
/// Format a write_file result for compact display. /// Format a write_file result for compact display.
/// Parses the tool result which is in format: "wrote N lines | M chars" /// Parses the tool result which is in format: "wrote N lines | M chars"
/// Returns a compact summary like "✏️ N lines (M chars)" /// Returns a compact summary like "wrote N lines | M chars"
pub fn format_write_file_result(tool_result: &str) -> String { pub fn format_write_file_result(tool_result: &str) -> String {
// Parse "wrote N lines | M chars" or "wrote N lines | M.Mk chars" // Parse "wrote N lines | M chars" or "wrote N lines | M.Mk chars"
if let Some(rest) = tool_result.strip_prefix("wrote ") { if let Some(rest) = tool_result.strip_prefix("wrote ") {
// rest is "N lines | M chars" or "N lines | M.Mk chars" // rest is "N lines | M chars" or "N lines | M.Mk chars"
if let Some((lines_part, chars_part)) = rest.split_once(" | ") { if let Some((lines_part, chars_part)) = rest.split_once(" | ") {
let lines = lines_part.trim_end_matches(" lines"); let lines = lines_part.trim_end_matches(" lines");
let chars = chars_part.trim_end_matches(" chars"); let chars = chars_part.trim_end_matches(" chars");
return format!("✏️ {} lines ({} chars)", lines, chars); return format!("wrote {} lines | {} chars", lines, chars);
} }
} }
// Fallback: return the original result if parsing fails // Fallback: return the original result if parsing fails

View File

@@ -343,7 +343,7 @@ pub async fn execute_write_file<W: UiWriter>(
format!("{}", char_count) format!("{}", char_count)
}; };
Ok(format!( Ok(format!(
"wrote {} lines | {} chars", "wrote {} lines | {} chars",
line_count, char_display line_count, char_display
)) ))
} }

View File

@@ -56,7 +56,7 @@ pub async fn execute_shell<W: UiWriter>(tool_call: &ToolCall, ctx: &ToolContext<
Ok(result) => { Ok(result) => {
if result.success { if result.success {
Ok(if result.stdout.is_empty() { Ok(if result.stdout.is_empty() {
"✅ Command executed successfully".to_string() "⚡️ ran successfully".to_string()
} else { } else {
result.stdout.trim().to_string() result.stdout.trim().to_string()
}) })

View File

@@ -337,7 +337,7 @@ mod tool_output_formatting {
/// Test write_file result parsing /// Test write_file result parsing
#[test] #[test]
fn test_write_file_result() { fn test_write_file_result() {
let result = format_write_file_result("wrote 42 lines | 1500 chars"); let result = format_write_file_result("wrote 42 lines | 1500 chars");
assert!(result.contains("42"), "Should contain line count: {}", result); assert!(result.contains("42"), "Should contain line count: {}", result);
assert!(result.contains("1500"), "Should contain char count: {}", result); assert!(result.contains("1500"), "Should contain char count: {}", result);
} }
@@ -345,7 +345,7 @@ mod tool_output_formatting {
/// Test write_file result with k notation /// Test write_file result with k notation
#[test] #[test]
fn test_write_file_result_k_notation() { fn test_write_file_result_k_notation() {
let result = format_write_file_result("wrote 100 lines | 2.5k chars"); let result = format_write_file_result("wrote 100 lines | 2.5k chars");
assert!(result.contains("100")); assert!(result.contains("100"));
assert!(result.contains("2.5k")); assert!(result.contains("2.5k"));
} }

38
scripts/install.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Build and install g3 and studio to ~/.local/bin
set -e
cd "$(dirname "$0")/.."
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
echo "Building g3 and studio (release)..."
cargo build --release
echo "Installing to $INSTALL_DIR..."
cp target/release/g3 "$INSTALL_DIR/"
cp target/release/studio "$INSTALL_DIR/g3-studio"
cp target/release/libVisionBridge.dylib "$INSTALL_DIR/"
# Create symlink to override Android Studio's 'studio' command
# Remove existing symlink if present, but don't remove if it's a different file
if [ -L "$INSTALL_DIR/studio" ]; then
rm "$INSTALL_DIR/studio"
fi
ln -s "$INSTALL_DIR/g3-studio" "$INSTALL_DIR/studio"
echo "Done! Installed:"
echo " $INSTALL_DIR/g3"
echo " $INSTALL_DIR/g3-studio"
echo " $INSTALL_DIR/studio -> g3-studio"
echo " $INSTALL_DIR/libVisionBridge.dylib"
# Check if ~/.local/bin is in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
echo "⚠️ $INSTALL_DIR is not in your PATH"
echo " Add this to your shell rc file:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi