MCPcopy Create free account
hub / github.com/continuedev/continue / parseAgentFile

Function parseAgentFile

packages/config-yaml/src/markdown/agentFiles.ts:48–70  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

46 * Agent files must have frontmatter with at least a name
47 */
48export function parseAgentFile(content: string): AgentFile {
49 const { frontmatter, markdown } = parseMarkdownRule(content);
50
51 if (!frontmatter.name) {
52 throw new Error(
53 "Agent file must contain YAML frontmatter with a 'name' field",
54 );
55 }
56
57 const validationResult = agentFileFrontmatterSchema.safeParse(frontmatter);
58
59 if (!validationResult.success) {
60 const errorDetails = validationResult.error.issues
61 .map((issue) => `${issue.path.join(".")}: ${issue.message}`)
62 .join(", ");
63 throw new Error(`Invalid agent file frontmatter: ${errorDetails}`);
64 }
65
66 return {
67 ...validationResult.data,
68 prompt: markdown,
69 };
70}
71
72/**
73 * Serializes an Agent file back to markdown with YAML frontmatter

Callers 3

hubLoader.tsFile · 0.90
getAgentFileMethod · 0.90
agentFiles.test.tsFile · 0.85

Calls 1

parseMarkdownRuleFunction · 0.85

Tested by

no test coverage detected