MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / compact_path_array

Function compact_path_array

src/mcp/tools/render.rs:624–643  ·  view source on GitHub ↗
(arr: &[Value])

Source from the content-addressed store, hash-verified

622}
623
624fn compact_path_array(arr: &[Value]) -> Option<String> {
625 if arr.len() < 2 || !arr.iter().all(Value::is_string) {
626 return None;
627 }
628 let paths = arr.iter().filter_map(Value::as_str).collect::<Vec<_>>();
629 if !paths.iter().all(|path| looks_like_path(path)) {
630 return None;
631 }
632 let bullets = paths
633 .iter()
634 .map(|path| format!("- {path}"))
635 .collect::<Vec<_>>()
636 .join("\n");
637 let compact = format_compact_path_list(paths.iter().copied(), "- ", "");
638 if compact == bullets {
639 None
640 } else {
641 Some(compact)
642 }
643}
644
645fn looks_like_path(value: &str) -> bool {
646 let trimmed = value.trim();

Callers 1

render_arrayFunction · 0.85

Calls 2

looks_like_pathFunction · 0.85
format_compact_path_listFunction · 0.85

Tested by

no test coverage detected