strip out code fences (fix gemini occasional mis-format)

This commit is contained in:
Will Chen
2025-04-14 16:12:25 -07:00
parent f093a65940
commit 3ceb3e23c6
2 changed files with 42 additions and 2 deletions

View File

@@ -15,7 +15,14 @@ export function getDyadWriteTags(fullResponse: string): {
let match;
const tags: { path: string; content: string }[] = [];
while ((match = dyadWriteRegex.exec(fullResponse)) !== null) {
tags.push({ path: match[1], content: match[2] });
const content = match[2].trim().split("\n");
if (content[0].startsWith("```")) {
content.shift();
}
if (content[content.length - 1].startsWith("```")) {
content.pop();
}
tags.push({ path: match[1], content: content.join("\n") });
}
return tags;
}