(dir: &Path)
| 204 | } |
| 205 | |
| 206 | fn load_schedules(dir: &Path) -> Result<Vec<ScheduleSpec>> { |
| 207 | let mut out = Vec::new(); |
| 208 | for path in md_files(dir, &["md"])? { |
| 209 | let content = std::fs::read_to_string(&path) |
| 210 | .map_err(|e| CodeError::Context(format!("read {}: {e}", path.display())))?; |
| 211 | let (front, body) = split_frontmatter(&content); |
| 212 | let front = front.ok_or_else(|| { |
| 213 | CodeError::Context(format!( |
| 214 | "schedule {} has no YAML frontmatter (need `cron:`)", |
| 215 | path.display() |
| 216 | )) |
| 217 | })?; |
| 218 | let meta: ScheduleFront = serde_yaml::from_str(&front).map_err(|e| { |
| 219 | CodeError::Context(format!("schedule {} frontmatter: {e}", path.display())) |
| 220 | })?; |
| 221 | out.push(ScheduleSpec { |
| 222 | name: meta.name.unwrap_or_else(|| file_stem(&path)), |
| 223 | cron: meta.cron, |
| 224 | prompt: body.trim().to_string(), |
| 225 | enabled: meta.enabled.unwrap_or(true), |
| 226 | }); |
| 227 | } |
| 228 | Ok(out) |
| 229 | } |
| 230 | |
| 231 | /// Upper bounds for a `kind = "script"` tool's sandbox limits. A `tools/` file is |
| 232 | /// semi-trusted (the whole point of the guardrail), so an author cannot set an |
no test coverage detected