Add rule copy drift check (#3)

This commit is contained in:
Chindanai Jaiman
2026-06-12 17:05:09 +02:00
committed by GitHub
parent 2f2a0d33e0
commit e89a4e9863
2 changed files with 48 additions and 0 deletions
+8
View File
@@ -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?**
+40
View 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.');