bookworm-smart-assistant/scripts/patches/patch-w1-disambig-count-88to89.js

25 lines
853 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
// patch-w1-disambig-count-88to89.js — 幂等补丁: CLAUDE.md 消歧规则计数 88→89
const fs = require('fs');
const path = require('path');
const SENTINEL = '完整 89 条见';
const target = path.join(__dirname, '..', '..', 'CLAUDE.md');
const content = fs.readFileSync(target, 'utf-8');
if (content.includes(SENTINEL)) {
console.log('[SKIP] CLAUDE.md 已包含 "完整 89 条",无需修改');
process.exit(0);
}
const updated = content.replace('完整 88 条见', SENTINEL);
if (updated === content) {
console.log('[SKIP] 未找到 "完整 88 条见",可能已修改');
process.exit(0);
}
const bak = target + '.bak.' + new Date().toISOString().slice(0,10);
fs.copyFileSync(target, bak);
fs.writeFileSync(target, updated, 'utf-8');
console.log('[DONE] CLAUDE.md 消歧规则计数 88→89备份:', bak);