MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / stripFrontmatter

Function stripFrontmatter

ui/src/components/workspace/api.ts:159–167  ·  view source on GitHub ↗

* Strip a leading YAML frontmatter block (`---` ... `---`) so the rendered * README body doesn't show the metadata to the user. Conservative: only * strips when frontmatter is at column 0; anything else passes through.

(raw: string)

Source from the content-addressed store, hash-verified

157 * strips when frontmatter is at column 0; anything else passes through.
158 */
159function stripFrontmatter(raw: string): string {
160 const text = raw.replace(/^/, '');
161 if (!text.startsWith('---')) return text;
162 const closeMatch = /^---\s*$/m.exec(text.slice(3));
163 if (!closeMatch || closeMatch.index === undefined) return text;
164 // Skip past the closing fence and any trailing newline.
165 const tailStart = 3 + closeMatch.index + closeMatch[0].length;
166 return text.slice(tailStart).replace(/^\r?\n/, '');
167}
168
169export interface AgentCapabilities {
170 readonly parallelPerCwd: boolean;

Callers 1

fetchTemplateReadmeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected