- VERSION file as authoritative version source - export.mjs reads VERSION with package.json fallback - bw-ota.ps1 DryRun mode for safe testing - auto-setup.ps1 bumped to v3.2.0 (Phase 8 OTA)
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* patch-r4-claudemd-doc.js · 2026-04-26
|
|
*
|
|
* R4: CLAUDE.md §上下文管理 追加外部压力信号说明, 同时升级 60% 规则
|
|
*
|
|
* 幂等: sentinel "外部压力信号"
|
|
*/
|
|
'use strict';
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const TARGET = path.join(__dirname, '..', '..', 'CLAUDE.md');
|
|
const SENTINEL = '外部压力信号';
|
|
|
|
const OLD = '- Compact at 60% context usage, do not wait until critical';
|
|
const NEW = '- Compact at 60% context usage, do not wait until critical (R4 **外部压力信号** 已自动播报: INFO 50% / WARN 70% / CRITICAL 85%, 收到信号时按建议动作执行, 不再凭自我感觉判断)';
|
|
|
|
function main() {
|
|
const src = fs.readFileSync(TARGET, 'utf8');
|
|
if (src.includes(SENTINEL)) {
|
|
console.log('[r4-doc] already applied, skip');
|
|
return;
|
|
}
|
|
if (!src.includes(OLD)) {
|
|
console.error('[r4-doc] anchor not found, manual review needed');
|
|
process.exit(1);
|
|
}
|
|
const next = src.replace(OLD, NEW);
|
|
const bak = TARGET + '.bak.r4doc.' + Date.now();
|
|
fs.copyFileSync(TARGET, bak);
|
|
const tmp = TARGET + '.tmp.' + process.pid;
|
|
fs.writeFileSync(tmp, next, 'utf8');
|
|
fs.renameSync(tmp, TARGET);
|
|
console.log('[r4-doc] OK, bak:', path.basename(bak));
|
|
}
|
|
|
|
main();
|