|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +/** |
| 4 | + * Repository consistency checker. |
| 5 | + * |
| 6 | + * Verifies: |
| 7 | + * - markdownlint config exists |
| 8 | + * - AGENTS.md references canonical MD060 style |
| 9 | + * - SKILL.md references canonical MD060 style |
| 10 | + * - README.md references canonical MD060 style |
| 11 | + */ |
| 12 | + |
| 13 | +const fs = require('fs'); |
| 14 | +const path = require('path'); |
| 15 | + |
| 16 | +const ROOT = path.join(__dirname, '..'); |
| 17 | +const CONFIG = path.join(ROOT, 'skills', 'markdown-lint', 'references', '.markdownlint.json'); |
| 18 | +const AGENTS = path.join(ROOT, 'AGENTS.md'); |
| 19 | +const README = path.join(ROOT, 'README.md'); |
| 20 | +const SKILL = path.join(ROOT, 'skills', 'markdown-lint', 'SKILL.md'); |
| 21 | + |
| 22 | +function fail(message) { |
| 23 | + console.error(`CONSISTENCY ERROR: ${message}`); |
| 24 | + process.exit(1); |
| 25 | +} |
| 26 | + |
| 27 | +function read(file) { |
| 28 | + if (!fs.existsSync(file)) { |
| 29 | + fail(`Missing file: ${file}`); |
| 30 | + } |
| 31 | + return fs.readFileSync(file, 'utf8'); |
| 32 | +} |
| 33 | + |
| 34 | +const config = JSON.parse(read(CONFIG)); |
| 35 | +const md060 = config.MD060?.style; |
| 36 | + |
| 37 | +if (md060 !== 'aligned') { |
| 38 | + fail(`Expected MD060 style 'aligned', found '${md060}'`); |
| 39 | +} |
| 40 | + |
| 41 | +const checks = [ |
| 42 | + [AGENTS, 'MD060', '`aligned`'], |
| 43 | + [README, 'aligned separators'], |
| 44 | + [SKILL, 'table-column-style', '`aligned`'], |
| 45 | +]; |
| 46 | + |
| 47 | +for (const [file, ...needles] of checks) { |
| 48 | + const content = read(file); |
| 49 | + for (const needle of needles) { |
| 50 | + if (!content.includes(needle)) { |
| 51 | + fail(`${path.basename(file)} missing expected text: ${needle}`); |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +console.log('Repository consistency checks passed.'); |
0 commit comments