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

Function parseFrontMatter

scripts/tmux/tmux-viewer/session-loader.ts:67–87  ·  view source on GitHub ↗

* Parse YAML front-matter from a capture file

(content: string)

Source from the content-addressed store, hash-verified

65 * Parse YAML front-matter from a capture file
66 */
67function parseFrontMatter(content: string): { frontMatter: CaptureFrontMatter; body: string } {
68 const frontMatterRegex = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/
69 const match = content.match(frontMatterRegex)
70
71 if (!match) {
72 // No front-matter, return defaults
73 return {
74 frontMatter: {
75 sequence: 0,
76 label: null,
77 timestamp: new Date().toISOString(),
78 after_command: null,
79 dimensions: { width: 'unknown', height: 'unknown' },
80 },
81 body: content,
82 }
83 }
84
85 const frontMatter = yaml.load(match[1]) as CaptureFrontMatter
86 return { frontMatter, body: match[2] }
87}
88
89/**
90 * Check if a filename matches capture file patterns:

Callers 1

loadCapturesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected