MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseFrontmatter

Function parseFrontmatter

sdk/src/skills/load-skills.ts:24–40  ·  view source on GitHub ↗

* Parses YAML frontmatter from a SKILL.md file using gray-matter. * Frontmatter is expected to be between --- markers at the start of the file.

(content: string)

Source from the content-addressed store, hash-verified

22 * Frontmatter is expected to be between --- markers at the start of the file.
23 */
24function parseFrontmatter(content: string): {
25 frontmatter: Record<string, unknown>
26 body: string
27} | null {
28 try {
29 const parsed = matter(content)
30 if (!parsed.data || Object.keys(parsed.data).length === 0) {
31 return null
32 }
33 return {
34 frontmatter: parsed.data as Record<string, unknown>,
35 body: parsed.content,
36 }
37 } catch {
38 return null
39 }
40}
41
42/**
43 * Loads a single skill from a SKILL.md file.

Callers 1

loadSkillFromFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected