fix: prevent cleanup from stripping copilot-instructions.md markers before generation
The cleanup() method was removing the BMAD marker section from copilot-instructions.md, leaving user content without markers. generateCopilotInstructions() then treated the markerless file as legacy, backed it up, and overwrote user content. Fix: remove the copilot-instructions.md block from cleanup() entirely. generateCopilotInstructions() already handles marker-based replacement in a single read-modify-write pass that correctly preserves user content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
88afcb5a88
commit
057864ca3d
|
|
@ -666,34 +666,11 @@ Type \`/bmad-\` in Copilot Chat to see all available BMAD workflows and agent ac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up BMAD section from copilot-instructions.md (preserve user content)
|
// Note: copilot-instructions.md is NOT cleaned up here.
|
||||||
const instructionsPath = path.join(projectDir, this.githubDir, 'copilot-instructions.md');
|
// generateCopilotInstructions() handles marker-based replacement in a single
|
||||||
if (await fs.pathExists(instructionsPath)) {
|
// read-modify-write pass, which correctly preserves user content outside the markers.
|
||||||
const existing = await fs.readFile(instructionsPath, 'utf8');
|
// Stripping markers here would cause generation to treat the file as legacy (no markers)
|
||||||
const markerStart = '<!-- BMAD:START -->';
|
// and overwrite user content.
|
||||||
const markerEnd = '<!-- BMAD:END -->';
|
|
||||||
const startIdx = existing.indexOf(markerStart);
|
|
||||||
const endIdx = existing.indexOf(markerEnd);
|
|
||||||
|
|
||||||
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
||||||
// Remove only the BMAD section between markers (inclusive)
|
|
||||||
const before = existing.slice(0, startIdx);
|
|
||||||
const after = existing.slice(endIdx + markerEnd.length);
|
|
||||||
const remaining = (before + after).trim();
|
|
||||||
|
|
||||||
if (remaining.length > 0) {
|
|
||||||
await fs.writeFile(instructionsPath, `${remaining}\n`);
|
|
||||||
console.log(chalk.dim(' Cleaned up BMAD section from copilot-instructions.md (user content preserved)'));
|
|
||||||
} else {
|
|
||||||
await fs.remove(instructionsPath);
|
|
||||||
console.log(chalk.dim(' Cleaned up copilot-instructions.md'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// No markers — file is either entirely BMAD-generated or entirely user content.
|
|
||||||
// Leave it alone during cleanup to avoid destroying user content.
|
|
||||||
console.log(chalk.dim(' Skipped copilot-instructions.md (no BMAD markers found, not modified)'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue