pub fn extract_meaningful_path(path: &Path) -> StringExpand description
Extract meaningful path structure from a dependency path.
This function handles three cases:
- Relative paths with
../- strips all parent directory components - Absolute paths - resolves
..components and strips root/prefix - Clean relative paths - uses as-is with normalized separators
ยงExamples
use std::path::Path;
// Relative paths with parent navigation
assert_eq!(extract_meaningful_path(Path::new("../../snippets/dir/file.md")), "snippets/dir/file.md");
// Absolute paths (root stripped, .. resolved) - Unix-style path
#[cfg(unix)]
assert_eq!(extract_meaningful_path(Path::new("/tmp/foo/../bar/agent.md")), "tmp/bar/agent.md");
// Absolute paths (root stripped, .. resolved) - Windows-style path
#[cfg(windows)]
assert_eq!(extract_meaningful_path(Path::new("C:\\tmp\\foo\\..\\bar\\agent.md")), "tmp/bar/agent.md");
// Clean relative paths
assert_eq!(extract_meaningful_path(Path::new("agents/test.md")), "agents/test.md");