MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / shorten_explore_path

Function shorten_explore_path

atomic-agent/src/provenance/classify.rs:504–525  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

502///
503/// Prefers project-relative paths: `/Users/lee/Projects/hello-world/src/index.ts` → `src/index.ts`
504fn 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
527fn summarize_commitment(tool_name: &str, tool_input: Option<&serde_json::Value>) -> String {
528 let path = tool_input

Callers 1

summarize_explorationFunction · 0.85

Calls 5

is_emptyMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected