fix: 发布 1.1.67,#85/#84 + 启动种子 + 85 项清单一次性修复

- #85 continue 续跑加 failStreak 阈值;refundContinue 不清 lastContinueSeq,连错 3 次放弃
- #84 region gate denialStream 单批 text-chunks 带 .length,不再卡宿主 UI
- 启动即种子:$DSH_HOME/prompt-inject.md 为空/缺失自动写加密默认稿,用户改过的不动
- Windows 重启脚本:pid+random 命名 + 直接 wscript.exe //B,不再 /IM 杀全名
- 官方 CLI shim 原子写 + .dsh-purge.bak 可回退
- WScript clean 判定两 null 放行,首装不卡;探测缓存不缓存空结果
- scheduleAsarRenameWhenIdle 的 .rename-pending 锁时钟回拨/30min 失效自动清
- 三处 execFileSync 加 maxBuffer: 8MB,大结果不再 ENOBUFS 静默
- net-scope / identity / hooks-deny / extract-asar / client.js / core.js / update.js / skills.js / refusal-recover / rewind / rules / reapply 等共 85 项修复
This commit is contained in:
叫我小杨同学 committed 2026-10-09 11:52:39 +08:00
1 parent 3df4f489b1
commit d26e69a4fa
18 files changed
+1153 -403

No files matched your search

+27 -20
View File
@@ -85,12 +85,6 @@ const REVERSES = Object.freeze([
},
]);
const SENTINEL_RULE = Object.freeze({
id: "R0",
find: '"__dsh_purge_deny_disabled__"',
replace: '"deny"',
});
export function applyHookDenyReverses(text) {
let out = String(text || "");
const hits = [];
@@ -99,13 +93,6 @@ export function applyHookDenyReverses(text) {
out = out.split(rule.find).join(rule.replace);
hits.push(rule.id);
}
if (hits.length === 0 && out.includes(DISABLED_SENTINEL)) {
const next = out.split(SENTINEL_RULE.find).join(SENTINEL_RULE.replace);
if (next !== out) {
out = next;
hits.push("R0");
}
}
return { text: out, hits };
}
@@ -167,6 +154,8 @@ export async function annotateHookDenyStatus(status, settings, aiBase, io) {
for (const id of HOOK_DENY_PATCH_IDS) {
const prev = status[id];
if (prev === "na" || prev === "missing_file") continue;
// #M12:已经成功打上的补丁不要被覆写成 pending/skipped
if (prev === "applied") continue;
status[id] = dirty ? "pending" : "skipped";
}
return status;
@@ -192,21 +181,39 @@ export function loadHookDenySettings(dshHome, configValue) {
return { hooksDenyBypass: value === undefined ? true : value };
}
/**
* #M11:本地原子写(写 tmp → fsync → rename)。
* 本模块不 import core.js(循环依赖),所以在这里独立实现。
* libuv 在 Win32 用 MoveFileExW(MOVEFILE_REPLACE_EXISTING),rename 可直接覆盖已存在文件,
* 不需要先 unlink —— 原本的 "unlink + rename" 在 unlink 和 rename 之间有竞态窗口 fp 不存在。
*/
function atomicWriteFileSync(fp, content, encoding = "utf8") {
fs.mkdirSync(path.dirname(fp), { recursive: true });
const tmp = `${fp}.${process.pid}.${Date.now()}.tmp`;
const fd = fs.openSync(tmp, "w");
try {
fs.writeFileSync(fd, content, encoding);
try { fs.fsyncSync(fd); } catch { /* FS 不支持 fsync 时忽略 */ }
} finally {
fs.closeSync(fd);
}
try {
fs.renameSync(tmp, fp);
} catch (e) {
try { fs.unlinkSync(tmp); } catch { /* ignore */ }
throw e;
}
}
export function saveHookDenySettings(dshHome, patch) {
const fp = hookDenySettingsPath(dshHome);
fs.mkdirSync(path.dirname(fp), { recursive: true });
const current = loadHookDenySettings(dshHome);
const next = {
hooksDenyBypass: typeof patch?.hooksDenyBypass === "boolean"
? patch.hooksDenyBypass
: current.hooksDenyBypass,
};
const tmp = `${fp}.${process.pid}.tmp`;
fs.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`, "utf8");
try {
if (fs.existsSync(fp)) fs.unlinkSync(fp);
} catch { /* rename 覆盖 */ }
fs.renameSync(tmp, fp);
atomicWriteFileSync(fp, `${JSON.stringify(next, null, 2)}\n`);
return { ok: true, ...next, path: fp };
}