MCPcopy Create free account
hub / github.com/MigoXLab/coderio / extractFiles

Function extractFiles

src/utils/parser.ts:81–98  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

79 * ```
80 */
81export function extractFiles(content: string): FileInfo[] {
82 const files: FileInfo[] = [];
83
84 // Match file sections: ## filename\n```language\ncode\n```
85 // Allow optional whitespace around newlines for flexibility
86 const fileRegex = /##\s+([^\n]+)\s*\n\s*```(?:\w+)?\s*\n([\s\S]*?)\n\s*```/g;
87 let match;
88
89 while ((match = fileRegex.exec(content)) !== null) {
90 if (match[1] && match[2]) {
91 const filename = match[1].trim();
92 const code = match[2].trim();
93 files.push({ filename, content: code });
94 }
95 }
96
97 return files;
98}

Callers 2

saveGeneratedCodeFunction · 0.90
parser.test.tsFile · 0.90

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected