export.mjs now removes hooks referencing npm packages not included in the Portable distribution (session-continuity-mcp). Eliminates MODULE_NOT_FOUND errors on Portable installations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
1.0 KiB
JavaScript
24 lines
1.0 KiB
JavaScript
#!/usr/bin/env node
|
||
// Fix: lastValidPrimary 未持久化到 route-state-current.json
|
||
// writeRouteState 只保存 6 个字段,lastValidPrimary 被丢弃
|
||
// 导致图片继承链在跨 hook 调用时永远无法回退到上一个有效路由
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const SENTINEL = '// LVP_PERSIST_FIX_v1';
|
||
const fp = path.join(__dirname, '..', 'route-state.js');
|
||
|
||
let code = fs.readFileSync(fp, 'utf8');
|
||
if (code.includes(SENTINEL)) { console.log('SKIP: already patched'); process.exit(0); }
|
||
|
||
const marker = 'domain: routing.domain || null,';
|
||
const idx = code.indexOf(marker);
|
||
if (idx === -1) { console.error('FAIL: cannot find domain field in writeRouteState'); process.exit(1); }
|
||
|
||
const insertPos = idx + marker.length;
|
||
const patch = `\n lastValidPrimary: routing.lastValidPrimary || null, ${SENTINEL}`;
|
||
|
||
fs.copyFileSync(fp, fp + '.bak');
|
||
code = code.slice(0, insertPos) + patch + code.slice(insertPos);
|
||
fs.writeFileSync(fp, code, 'utf8');
|
||
console.log('PATCHED: lastValidPrimary now persisted in route-state-current.json');
|