INNER CODE UNIT · Rust

load_skills

ShurikenTrade/shuriken-skills · src/lib.rs:29

fn load_skills() -> Vec<Skill> {
    let mut out = Vec::new();
    for entry in SKILLS_DIR.dirs() {
        // include_dir returns paths relative to the embedded root; look up SKILL.md inside each skill directory.
        let skill_md_path = format!("{}/SKILL.md", entry.path().display());
        let skill_md = match SKILLS_DIR.get_file(&skill_md_path) {
            Some(f) => f,
            None => continue, // directories without SKILL.md are ignored
        };

        let raw = skill_md
            .contents_utf8()
            .expect("SKILL.md must be valid UTF-8");

        let parsed = frontmatter::parse(raw)
            .unwrap_or_else(|e| panic!("invalid frontmatter in {}: {e}", skill_md.path().display()));

        // Leak the strings so the Skill struct can hold &'static str.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…