MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / parseFrontMatter

Function parseFrontMatter

src/lib/skill-parser.ts:48–75  ·  view source on GitHub ↗

* Parse SKILL.md front matter (YAML between --- delimiters)

(content: string)

Source from the content-addressed store, hash-verified

46 * Parse SKILL.md front matter (YAML between --- delimiters)
47 */
48function parseFrontMatter(content: string): { frontMatter: FrontMatter; body: string } {
49 const frontMatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/);
50
51 if (!frontMatterMatch) {
52 return { frontMatter: {}, body: content };
53 }
54
55 const yamlContent = frontMatterMatch[1];
56 const body = frontMatterMatch[2];
57
58 const frontMatter: FrontMatter = {};
59
60 const nameMatch = yamlContent.match(/^name:\s*(.+)$/m);
61 if (nameMatch) frontMatter.name = nameMatch[1].trim();
62
63 const descMatch = yamlContent.match(/^description:\s*(.+)$/m);
64 if (descMatch) frontMatter.description = descMatch[1].trim();
65
66 const homepageMatch = yamlContent.match(/^homepage:\s*(.+)$/m);
67 if (homepageMatch) frontMatter.homepage = homepageMatch[1].trim();
68
69 const emojiMatch = yamlContent.match(/"emoji":\s*"([^"]+)"/);
70 if (emojiMatch) {
71 frontMatter.metadata = { openclaw: { emoji: emojiMatch[1] } };
72 }
73
74 return { frontMatter, body };
75}
76
77/**
78 * Extract first paragraph as description if no front matter description

Callers 1

parseSkillFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected