feat(cli): shorten file paths in tool output display

Add three-level path shortening hierarchy for cleaner CLI output:
1. Project path -> <project_name>/... (when project loaded via /project)
2. Workspace path -> ./... (relative to current working directory)
3. Home path -> ~/... (fallback for paths under home directory)

Changes:
- Add shorten_path() and shorten_paths_in_command() functions in display.rs
- Add project_path/project_name fields to ConsoleUiWriter
- Add set_workspace_path(), set_project_path(), clear_project() to UiWriter trait
- Add ui_writer() getter to Agent struct
- Wire up project path setting in /project and /unproject commands
- Set workspace path when creating agents in all CLI modes

Before: ● read_file | /Users/dhanji/icloud/butler/projects/appa_estate/status.md
After:  ● read_file | appa_estate/status.md (with project loaded)
        ● read_file | ./src/main.rs (workspace-relative)
        ● read_file | ~/Documents/file.txt (home-relative)
This commit is contained in:
Dhanji R. Prasanna
2026-01-21 21:27:16 +05:30
parent 0f7961d3c6
commit 9325a43ff3
9 changed files with 264 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ use crate::coach_feedback;
use crate::metrics::{format_elapsed_time, generate_turn_histogram, TurnMetrics};
use crate::simple_output::SimpleOutput;
use crate::ui_writer_impl::ConsoleUiWriter;
use g3_core::ui_writer::UiWriter;
/// Run autonomous mode with coach-player feedback loop (console output).
pub async fn run_autonomous(
@@ -498,6 +499,7 @@ async fn execute_coach_turn(
crate::filter_json::reset_json_tool_state();
let ui_writer = ConsoleUiWriter::new();
ui_writer.set_workspace_path(project.workspace().to_path_buf());
let mut coach_agent =
match Agent::new_autonomous_with_readme_and_quiet(coach_config, ui_writer, None, quiet)
.await