MCPcopy Create free account
hub / github.com/AI45Lab/Code / md_files

Function md_files

core/src/config/agent_dir.rs:188–204  ·  view source on GitHub ↗

Markdown files with a ` ` extension in `dir`, sorted by path. Returns an empty list when `dir` does not exist.

(dir: &Path, exts: &[&str])

Source from the content-addressed store, hash-verified

186/// Markdown files with a `<ext>` extension in `dir`, sorted by path. Returns an
187/// empty list when `dir` does not exist.
188fn md_files(dir: &Path, exts: &[&str]) -> Result<Vec<PathBuf>> {
189 if !dir.is_dir() {
190 return Ok(Vec::new());
191 }
192 let mut entries: Vec<PathBuf> = std::fs::read_dir(dir)
193 .map_err(|e| CodeError::Context(format!("read {}: {e}", dir.display())))?
194 .filter_map(|e| e.ok().map(|e| e.path()))
195 .filter(|p| {
196 p.extension()
197 .and_then(|s| s.to_str())
198 .map(|e| exts.contains(&e))
199 .unwrap_or(false)
200 })
201 .collect();
202 entries.sort();
203 Ok(entries)
204}
205
206fn load_schedules(dir: &Path) -> Result<Vec<ScheduleSpec>> {
207 let mut out = Vec::new();

Callers 2

load_schedulesFunction · 0.85
load_toolsFunction · 0.85

Calls 2

pathMethod · 0.80
containsMethod · 0.80

Tested by

no test coverage detected