Skip to content

parser

diapason.skills.parser

SkillParser — strict spec validation + tolerant field mapping.

The parser is the single chokepoint for converting raw frontmatter dicts into normalized SkillManifest instances. It runs two passes:

  1. Strict pass — validates required fields, length limits, naming rules.
  2. Tolerant pass — maps non-spec top-level fields to their canonical locations under metadata.diapason.* via FIELD_MAPPING.

The mapping table is data, not code paths. Adding support for a new vendor's fields means adding entries to FIELD_MAPPING — no logic changes.

SkillParseError

Bases: ValueError

Raised when a skill frontmatter cannot be parsed.

SkillParser

Parse SKILL.md frontmatter into a SkillManifest.

Two-pass design:

  • :meth:parse_frontmatter runs the strict pass + tolerant pass and returns a normalized :class:SkillManifest.

parse_frontmatter(frontmatter, *, markdown_content='')

Parse a frontmatter dict, returning a SkillManifest.

Runs strict validation first, then applies tolerant field mapping.