Skip to content

Commit 994ec72

Browse files
committed
Fix parsing of SKILL.md file frontmatter - regex
1 parent b77a403 commit 994ec72

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/skills/loader.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"path/filepath"
1010
"regexp"
1111
"strings"
12+
13+
"github.com/sipeed/picoclaw/pkg/logger"
1214
)
1315

1416
var namePattern = regexp.MustCompile(`^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`)
@@ -251,6 +253,11 @@ func (sl *SkillsLoader) BuildSkillsSummary() string {
251253
func (sl *SkillsLoader) getSkillMetadata(skillPath string) *SkillMetadata {
252254
content, err := os.ReadFile(skillPath)
253255
if err != nil {
256+
logger.WarnCF("skills", "Failed to read skill metadata",
257+
map[string]interface{}{
258+
"skill_path": skillPath,
259+
"error": err.Error(),
260+
})
254261
return nil
255262
}
256263

@@ -306,9 +313,9 @@ func (sl *SkillsLoader) parseSimpleYAML(content string) map[string]string {
306313
}
307314

308315
func (sl *SkillsLoader) extractFrontmatter(content string) string {
309-
// (?s) enables DOTALL mode so . matches newlines
310-
// Match first ---, capture everything until next --- on its own line
311-
re := regexp.MustCompile(`(?s)^---\n(.*)\n---`)
316+
// Support both Unix (\n) and Windows (\r\n) line endings for frontmatter blocks
317+
// (?s) enables DOTALL so . matches newlines; ^--- at start, then ... --- at start of line
318+
re := regexp.MustCompile(`(?s)^---\r?\n(.*?)\r?\n---`)
312319
match := re.FindStringSubmatch(content)
313320
if len(match) > 1 {
314321
return match[1]

0 commit comments

Comments
 (0)