loadSkillFromMarkdown function

Skill loadSkillFromMarkdown(
  1. String markdown, {
  2. Resources? resources,
})

Loads a Skill from the text of a SKILL.md file.

The skill name is not compared with a directory name, since there is none. Parses YAML frontmatter between --- lines and validates it with Frontmatter.fromMap, attaching resources when provided.

Implementation

Skill loadSkillFromMarkdown(String markdown, {Resources? resources}) {
  final _ParsedSkillMd parsed = _parseSkillMdContent(markdown);
  return Skill(
    frontmatter: Frontmatter.fromMap(parsed.frontmatter),
    instructions: parsed.body,
    resources: resources ?? Resources(),
  );
}