fix: parse skill frontmatter as YAML (#25610)

This commit is contained in:
Michael Suchacz
2026-05-22 15:09:30 +02:00
committed by GitHub
parent 15ada66e14
commit bdf2698fcd
5 changed files with 223 additions and 87 deletions
+37
View File
@@ -26,6 +26,33 @@ func TestParsePersonalSkillMarkdown(t *testing.T) {
require.Equal(t, "Use this skill.", content.Body)
})
t.Run("ValidWithFoldedDescription", func(t *testing.T) {
t.Parallel()
content, err := skills.ParsePersonalSkillMarkdown([]byte(strings.Join([]string{
"---",
"name: brainstorming",
"description: >",
" Use before any creative work: features, components, functionality changes,",
" or behavior modifications. Turns ideas into approved designs through",
" collaborative dialog. Hard gate: no implementation action until the",
" design is presented and approved.",
"---",
"Use this skill.",
}, "\n")))
require.NoError(t, err)
require.Equal(t, "brainstorming", content.Name)
require.Equal(t, strings.Join([]string{
"Use before any creative work: features, components, functionality changes,",
"or behavior modifications. Turns ideas into approved designs through",
"collaborative dialog. Hard gate: no implementation action until the",
"design is presented and approved.",
}, " "), content.Description)
require.Equal(t, skills.SourcePersonal, content.Source)
require.Equal(t, "Use this skill.", content.Body)
})
t.Run("ValidWithoutDescription", func(t *testing.T) {
t.Parallel()
@@ -67,6 +94,16 @@ func TestParsePersonalSkillMarkdown(t *testing.T) {
require.ErrorContains(t, err, "frontmatter must contain a 'name' field")
})
t.Run("NonStringName", func(t *testing.T) {
t.Parallel()
_, err := skills.ParsePersonalSkillMarkdown([]byte(
"---\nname: null\n---\nBody.\n",
))
require.ErrorIs(t, err, skills.ErrInvalidSkillName)
})
t.Run("NonKebabCaseName", func(t *testing.T) {
t.Parallel()