From e776c9d901c0d11a5bdc4bd0a77e610cca2665e8 Mon Sep 17 00:00:00 2001 From: "joe.zhao" Date: Wed, 18 Mar 2026 20:40:21 +0800 Subject: [PATCH] fix: use yaml.safe_load to parse SKILL.md frontmatter Replace hand-rolled line-by-line parser with yaml.safe_load() to correctly handle YAML block scalars (| and >) in frontmatter fields like multi-line descriptions. --- agents/s05_skill_loading.py | 8 +++----- requirements.txt | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/agents/s05_skill_loading.py b/agents/s05_skill_loading.py index 07e580e82..17be20581 100644 --- a/agents/s05_skill_loading.py +++ b/agents/s05_skill_loading.py @@ -40,6 +40,8 @@ import subprocess from pathlib import Path +import yaml + from anthropic import Anthropic from dotenv import load_dotenv @@ -75,11 +77,7 @@ def _parse_frontmatter(self, text: str) -> tuple: 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() + meta = yaml.safe_load(match.group(1)) or {} return meta, match.group(2).strip() def get_descriptions(self) -> str: diff --git a/requirements.txt b/requirements.txt index 55f896d40..c27dfcc04 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ anthropic>=0.25.0 python-dotenv>=1.0.0 +pyyaml>=6.0 \ No newline at end of file