fix: parse multi-line YAML block scalars in frontmatter

_parse_frontmatter used manual line splitting which only handled
simple key: value pairs. Multi-line block scalars (|) returned
only '|' as the value, dropping all subsequent indented lines.

Replace with yaml.safe_load() to correctly parse all YAML syntax.
Add pyyaml>=6.0 to requirements.txt.
This commit is contained in:
Moon 2026-03-28 21:37:22 +08:00
parent a9c71002d2
commit 93ccf2a2ac
2 changed files with 6 additions and 5 deletions

View file

@ -38,6 +38,7 @@ Key insight: "Don't put everything in the system prompt. Load on demand."
import os
import re
import subprocess
import yaml
from pathlib import Path
from anthropic import Anthropic
@ -75,11 +76,10 @@ class SkillLoader:
match = re.match(r"^---\n(.*?)\n---\n(.*)", text, re.DOTALL)
if not match:
return {}, text
meta = {}
for line in match.group(1).strip().splitlines():
if ":" in line:
key, val = line.split(":", 1)
meta[key.strip()] = val.strip()
try:
meta = yaml.safe_load(match.group(1)) or {}
except yaml.YAMLError:
meta = {}
return meta, match.group(2).strip()
def get_descriptions(self) -> str:

View file

@ -1,2 +1,3 @@
anthropic>=0.25.0
python-dotenv>=1.0.0
pyyaml>=6.0