Parse YAML frontmatter from SKILL.md. Returns (meta, body).
(text: str)
| 51 | |
| 52 | # s07: Skill catalog scan (used by build_system below) |
| 53 | def _parse_frontmatter(text: str) -> tuple[dict, str]: |
| 54 | """Parse YAML frontmatter from SKILL.md. Returns (meta, body).""" |
| 55 | if not text.startswith("---"): |
| 56 | return {}, text |
| 57 | parts = text.split("---", 2) |
| 58 | if len(parts) < 3: |
| 59 | return {}, text |
| 60 | try: |
| 61 | meta = yaml.safe_load(parts[1]) or {} |
| 62 | except yaml.YAMLError: |
| 63 | meta = {} |
| 64 | return meta, parts[2].strip() |
| 65 | |
| 66 | # Build skill registry at startup (used for safe lookup in load_skill) |
| 67 | SKILL_REGISTRY: dict[str, dict] = {} |