MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / read_directory_preview

Method read_directory_preview

crates/opencode-session/src/prompt.rs:697–718  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

695 }
696
697 async fn read_directory_preview(path: &Path) -> String {
698 let mut entries = match tokio::fs::read_dir(path).await {
699 Ok(entries) => entries,
700 Err(err) => return format!("Failed to list directory {}: {}", path.display(), err),
701 };
702
703 let mut names = Vec::new();
704 while let Ok(Some(entry)) = entries.next_entry().await {
705 names.push(entry.file_name().to_string_lossy().to_string());
706 if names.len() >= 200 {
707 names.push("... (truncated)".to_string());
708 break;
709 }
710 }
711
712 if names.is_empty() {
713 return format!("Directory is empty: {}", path.display());
714 }
715
716 names.sort();
717 names.join("\n")
718 }
719
720 async fn start(&self, session_id: &str) -> Option<CancellationToken> {
721 let state = self.state.lock().await;

Callers

nothing calls this directly

Calls 2

newFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected