From e89a4e98636744ef0e0ca2f376b9d5d81427b872 Mon Sep 17 00:00:00 2001 From: Chindanai Jaiman Date: Fri, 12 Jun 2026 22:05:09 +0700 Subject: [PATCH] Add rule copy drift check (#3) --- README.md | 8 ++++++++ scripts/check-rule-copies.js | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 scripts/check-rule-copies.js diff --git a/README.md b/README.md index b08b496..ad7e84f 100644 --- a/README.md +++ b/README.md @@ -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?** diff --git a/scripts/check-rule-copies.js b/scripts/check-rule-copies.js new file mode 100644 index 0000000..0a9a836 --- /dev/null +++ b/scripts/check-rule-copies.js @@ -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.');