Skip to main content

load_skill_body

Function load_skill_body 

Source
pub fn load_skill_body(
    skills_dir: &Path,
    name: &str,
    known: &[SkillMetadata],
) -> Result<String, SkillError>
Expand description

Lazily load one skill’s full Markdown body (the frontmatter stripped off).

Why: This is the “on invoke” half of progressive disclosure — the body is read from disk only when a caller (the use_skill tool, or a resolver’s resolve) actually needs it. What: Rejects any name not present in known (the cached catalog) up front — this doubles as the path-traversal guard, since the join’d path is only ever built from a name the catalog itself already discovered on disk. Reads <skills_dir>/<name>/SKILL.md and returns the body after the frontmatter fence, trimmed. Test: load_skill_body_returns_body_without_frontmatter, load_skill_body_rejects_unknown_name.