use std::path::{Path, PathBuf};
use crate::core::agents::Env;
use crate::core::discover::{Skill, parse_skill_md};
pub fn env_at(tmp: &tempfile::TempDir) -> Env {
let mut env = Env::new(tmp.path(), tmp.path().join("config"), tmp.path());
env.set_probe_system_dirs(false);
env.set_vars(std::collections::HashMap::new());
env
}
pub fn write_skill_md(root: &Path, rel_dir: &str, name: &str) -> PathBuf {
let dir = root.join(rel_dir);
std::fs::create_dir_all(&dir).expect("create skill dir");
let md = dir.join("SKILL.md");
std::fs::write(&md, skill_frontmatter(name)).expect("write SKILL.md");
md
}
pub fn skill_frontmatter(name: &str) -> String {
format!("---\nname: {name}\ndescription: does {name}\n---\n\n# {name}\n\nBody text.\n")
}
pub fn write_and_parse_skill(dir: &Path, name: &str) -> Skill {
std::fs::create_dir_all(dir).expect("create skill dir");
let md = dir.join("SKILL.md");
std::fs::write(&md, skill_frontmatter(name)).expect("write SKILL.md");
parse_skill_md(&md).expect("parse skill md")
}