Parse skill frontmatter with YAML

This commit is contained in:
Alex Schapiro
2026-08-07 01:34:02 +00:00
parent 1569c9ae50
commit 47835d6dd1
2 changed files with 49 additions and 48 deletions
+29 -1
View File
@@ -89,7 +89,7 @@ def test_available_skill_supports_colon_in_description(tmp_path: Path) -> None:
tmp_path,
"extra",
"widget",
"---\nname: widget\ndescription: Useful widget: handles YAML\n---\nwidget body",
'---\nname: widget\ndescription: "Useful widget: handles YAML"\n---\nwidget body',
)
register_skill_dir(tmp_path)
@@ -135,6 +135,34 @@ def test_available_skill_normalizes_multiline_descriptions(tmp_path: Path) -> No
}
def test_available_skill_supports_block_scalar_trailing_comment(tmp_path: Path) -> None:
_write_skill(
tmp_path,
"extra",
"commented",
"---\nname: commented\ndescription: | # paragraph\n"
" First line\n Second line\n---\ncommented body",
)
register_skill_dir(tmp_path)
assert get_available_skills()["extra"] == [
{"name": "commented", "description": "First line Second line"}
]
def test_malformed_frontmatter_keeps_skill_body(tmp_path: Path) -> None:
_write_skill(
tmp_path,
"extra",
"broken",
"---\nname: [broken\ndescription: should be empty\n---\nbroken body",
)
register_skill_dir(tmp_path)
assert get_available_skills()["extra"] == [{"name": "broken", "description": ""}]
assert load_skills(["extra/broken"]) == {"broken": "broken body"}
def test_system_prompt_renders_skill_descriptions() -> None:
prompt = render_system_prompt(scan_mode="quick", is_root=True)