SkillKit.Kit.Local.Parser (SkillKit v0.1.0)

Copy Markdown View Source

Internal parser for the Local provider.

Parses SKILL.md files into %SkillKit.Skill{} structs. This module is internal to the Local provider — callers outside the provider should not depend on it directly.

A SKILL.md file combines a YAML frontmatter section with a markdown prompt template body. The frontmatter must contain exactly the required fields; the body below the second --- delimiter becomes the prompt template stored in %Skill{body: ...}.

File Format

---
name: "namespace:skill_name"
description: "Human-readable description"
required_scope:
  - "namespace:permission"
---
Your prompt template goes here.

Use {{arg_name}} to reference arguments passed at execution time.

Required Fields

FieldTypeNotes
nameString.t()Must follow "namespace:skill_name" format
descriptionString.t()Non-empty description

Optional Fields

FieldTypeDefaultNotes

| required_scope | [String.t()] | String.t() | [] | Single string coerced to list |

Security Note

YAML is always parsed with atoms: false — skill files must not be able to exhaust the BEAM atom table. Map keys from YAML are always strings, never atoms.

Example

iex> SkillKit.Kit.Local.Parser.load_file("/path/to/skills/summarize/SKILL.md")
{:ok, %SkillKit.Skill{
  name: "files:summarize",
  namespace: "files",
  description: "Summarize a file's contents",
  required_scope: ["files:read"],
  body: "Please summarize: {{content}}",
  location: "/path/to/skills/summarize/SKILL.md"
}}

Summary

Functions

Loads a SKILL.md file from path and returns a parsed skill struct.

Functions

load_file(path)

@spec load_file(Path.t()) :: {:ok, SkillKit.Skill.t()} | {:error, term()}

Loads a SKILL.md file from path and returns a parsed skill struct.

Returns {:ok, %SkillKit.Skill{}} on success.

Returns {:error, reason} on failure:

  • {:error, :enoent} — file does not exist
  • {:error, :invalid_frontmatter} — file missing --- delimiters
  • {:error, %YamlElixir.ParsingError{}} — YAML could not be parsed
  • {:error, {:missing_field, field}} — required field absent or empty
  • {:error, {:invalid_field, field}} — field present but wrong type
  • {:error, :invalid_name_format} — name doesn't match "namespace:skill_name" format