Shorten a file path for exploration summaries. Prefers project-relative paths: `/Users/lee/Projects/hello-world/src/index.ts` → `src/index.ts`
(full_path: &str)
| 502 | /// |
| 503 | /// Prefers project-relative paths: `/Users/lee/Projects/hello-world/src/index.ts` → `src/index.ts` |
| 504 | fn shorten_explore_path(full_path: &str) -> String { |
| 505 | let full_path = full_path.trim().trim_matches('"').trim_matches('\''); |
| 506 | if full_path == "." || full_path == "./" { |
| 507 | return "project root".to_string(); |
| 508 | } |
| 509 | |
| 510 | let parts: Vec<&str> = full_path.split('/').filter(|s| !s.is_empty()).collect(); |
| 511 | if parts.len() <= 2 { |
| 512 | return parts.join("/"); |
| 513 | } |
| 514 | |
| 515 | // Look for common project markers to find the project-relative path |
| 516 | let markers = ["src", "lib", "app", "test", "tests", "dist", "pkg", "cmd"]; |
| 517 | for (i, part) in parts.iter().enumerate() { |
| 518 | if markers.contains(&part.to_lowercase().as_str()) { |
| 519 | return parts[i..].join("/"); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | // Fall back to last 2 segments |
| 524 | parts[parts.len() - 2..].join("/") |
| 525 | } |
| 526 | |
| 527 | fn summarize_commitment(tool_name: &str, tool_input: Option<&serde_json::Value>) -> String { |
| 528 | let path = tool_input |