Spaces:
Sleeping
Sleeping
File size: 768 Bytes
609fcb1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /**
* Extracts files from AI generated content using the <file path="...">...</file> format.
*/
export function extractFilesFromAI(content: string): { path: string; content: string }[] {
const fileRegex = /<file path="([^"]+)">([\s\S]*?)<\/file>/g;
const files: { path: string; content: string }[] = [];
let match;
while ((match = fileRegex.exec(content)) !== null) {
const filePath = match[1];
const fileContent = match[2].trim();
files.push({ path: filePath, content: fileContent });
}
return files;
}
/**
* Sanitizes a string for use as a branch name.
*/
export function sanitizeBranchName(name: string): string {
return name
.toLowerCase()
.replace(/[^a-z0-9]/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '');
}
|