Add rule copy drift check (#3)
This commit is contained in:
@@ -69,6 +69,14 @@ Cursor, Windsurf, Cline, Copilot, Aider, Kiro: copy the matching rules file from
|
||||
|
||||
Kiro: copy `.kiro/steering/ponytail.md` to `~/.kiro/steering/` (global) or `.kiro/steering/` in your project.
|
||||
|
||||
## Development
|
||||
|
||||
When changing the compact rule text, keep the agent copies aligned:
|
||||
|
||||
```bash
|
||||
node scripts/check-rule-copies.js
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
**Does it need a config file?**
|
||||
|
||||
@@ -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