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:
@@ -360,6 +360,14 @@ pub async fn handle_command<W: UiWriter>(
|
||||
Some(project) => {
|
||||
// Set project content in agent's system message
|
||||
if agent.set_project_content(Some(project.content.clone())) {
|
||||
// Set project path on UI writer for path shortening
|
||||
let project_name = project.path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.unwrap_or("project")
|
||||
.to_string();
|
||||
agent.ui_writer().set_project_path(project.path.clone(), project_name);
|
||||
|
||||
// Print loaded status
|
||||
print!(
|
||||
"{}Project loaded:{} {}\n",
|
||||
@@ -388,6 +396,7 @@ pub async fn handle_command<W: UiWriter>(
|
||||
"/unproject" => {
|
||||
if active_project.is_some() {
|
||||
agent.clear_project_content();
|
||||
agent.ui_writer().clear_project();
|
||||
*active_project = None;
|
||||
output.print("✅ Project unloaded. Context reset to original system message.");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user