SkillKit.Frontmatter (SkillKit v0.1.0)

Copy Markdown View Source

Shared frontmatter parsing for SKILL.md and AGENT.md files.

Splits a markdown file with YAML frontmatter into its parts and parses the YAML. Used by both the skill parser and the agent definition parser.

YAML is always parsed with atoms: false to prevent atom table exhaustion from untrusted files.

Summary

Functions

Parses a string containing YAML frontmatter and a markdown body.

Splits content into frontmatter string and body string.

Functions

parse(content)

@spec parse(String.t()) :: {:ok, map(), String.t()} | {:error, term()}

Parses a string containing YAML frontmatter and a markdown body.

Returns {:ok, yaml_map, body} or {:error, reason}.

split(content)

@spec split(String.t()) ::
  {:ok, String.t(), String.t()} | {:error, :invalid_frontmatter}

Splits content into frontmatter string and body string.

Returns {:ok, frontmatter, body} or {:error, :invalid_frontmatter}.