Add rule copy drift check (#3)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const root = path.join(__dirname, '..');
|
||||
|
||||
function read(relPath) {
|
||||
return fs.readFileSync(path.join(root, relPath), 'utf8').replace(/\r\n/g, '\n').trim();
|
||||
}
|
||||
|
||||
function stripCursorFrontmatter(text) {
|
||||
return text.replace(/^---\n[\s\S]*?\n---\n*/, '').trim();
|
||||
}
|
||||
|
||||
const agents = read('AGENTS.md');
|
||||
const canonical = agents.replace(/\n\n\(Yes, this file also applies[\s\S]*?\)$/, '').trim();
|
||||
|
||||
const copies = [
|
||||
['.cursor/rules/ponytail.mdc', stripCursorFrontmatter],
|
||||
['.windsurf/rules/ponytail.md', text => text.trim()],
|
||||
['.clinerules/ponytail.md', text => text.trim()],
|
||||
['.github/copilot-instructions.md', text => text.trim()],
|
||||
];
|
||||
|
||||
let failed = false;
|
||||
|
||||
for (const [relPath, normalize] of copies) {
|
||||
const actual = normalize(read(relPath));
|
||||
if (actual !== canonical) {
|
||||
console.error(`${relPath} drifted from AGENTS.md`);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
console.error('Update the copied rule text or AGENTS.md so the shared body matches.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('Rule copies match AGENTS.md shared body.');
|
||||
Reference in New Issue
Block a user