fix: 发布 1.1.39,中文 Windows 官方桌面更新不再卡在准备重启

Fixes #47

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-29 20:10:51 +08:00
1 parent 701b4188cd
commit a049e3c7d5
8 files changed
+96 -18

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
<p align="center"><strong>Version 1.1.38</strong></p>
<p align="center"><strong>Version 1.1.39</strong></p>
<p align="center">
<em>Local official DeepSeek Harness cybersecurity red-team plugin. Clean host policy, and ship a built-in drill console. Swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
+1 -1
View File
@@ -4,7 +4,7 @@
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
<p align="center"><strong>Version 1.1.38</strong></p>
<p align="center"><strong>Version 1.1.39</strong></p>
<p align="center">
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
+50 -5
View File
@@ -3136,6 +3136,11 @@ const NEW_TOOL_PATCHES = [
{
pattern: "var DesktopUpdateCoordinator = class {",
replace:
"function dshPurgeWshLiteral(value) {\n" +
"\treturn JSON.stringify(String(value == null ? \"\" : value)).replace(/[^\\u0000-\\u007e]/g, function (ch) {\n" +
"\t\treturn \"\\\\u\" + (\"0000\" + ch.charCodeAt(0).toString(16)).slice(-4);\n" +
"\t});\n" +
"}\n" +
"function dshPurgeHandoffDesktopUpdate(owner) {\n" +
"\ttry {\n" +
"\t\tconst cache = join(process.env.LOCALAPPDATA || \"\", \"@deepseek-aidsh-desktop-updater\");\n" +
@@ -3159,11 +3164,12 @@ const NEW_TOOL_PATCHES = [
"\t\tconst installDir = dirname(exe);\n" +
"\t\tconst logPath = join(process.env.TEMP || \"\", \"dsh-purge-official-update.log\");\n" +
"\t\tconst body = readFileSync(templatePath, \"utf8\")\n" +
"\t\t\t.split(\"__EXE_JSON__\").join(JSON.stringify(exe))\n" +
"\t\t\t.split(\"__INSTALLER_JSON__\").join(JSON.stringify(installer))\n" +
"\t\t\t.split(\"__RESOURCES_JSON__\").join(JSON.stringify(resources))\n" +
"\t\t\t.split(\"__INSTALL_DIR_JSON__\").join(JSON.stringify(installDir))\n" +
"\t\t\t.split(\"__LOG_JSON__\").join(JSON.stringify(logPath));\n" +
"\t\t\t.split(\"__EXE_JSON__\").join(dshPurgeWshLiteral(exe))\n" +
"\t\t\t.split(\"__INSTALLER_JSON__\").join(dshPurgeWshLiteral(installer))\n" +
"\t\t\t.split(\"__RESOURCES_JSON__\").join(dshPurgeWshLiteral(resources))\n" +
"\t\t\t.split(\"__INSTALL_DIR_JSON__\").join(dshPurgeWshLiteral(installDir))\n" +
"\t\t\t.split(\"__LOG_JSON__\").join(dshPurgeWshLiteral(logPath));\n" +
"\t\tfor (var i = 0; i < body.length; i++) { if (body.charCodeAt(i) > 127) throw new Error(\"desktop update script is not ascii\"); }\n" +
"\t\tconst script = join(process.env.TEMP || \"\", \"dsh-purge-official-update.js\");\n" +
"\t\tconst launcher = join(process.env.TEMP || \"\", \"dsh-purge-official-update.cmd\");\n" +
"\t\twriteFileSync(script, body, \"utf8\");\n" +
@@ -3178,6 +3184,45 @@ const NEW_TOOL_PATCHES = [
],
markers: ["function dshPurgeHandoffDesktopUpdate", "dshPurgeHandoffDesktopUpdate(this)"],
},
{
id: 46, name: "OFFICIAL_DESKTOP_UPDATE_ASCII", layer: "代码", layer_en: "Code",
desc: "已接管的官方桌面更新改为 ASCII 脚本,中文 Windows 不再吞掉换行",
file: "desktop-shell",
optional: true,
skipIfMarked: true,
replacements: [
{
pattern: "function dshPurgeHandoffDesktopUpdate(owner) {",
replace:
"function dshPurgeWshLiteral(value) {\n" +
"\treturn JSON.stringify(String(value == null ? \"\" : value)).replace(/[^\\u0000-\\u007e]/g, function (ch) {\n" +
"\t\treturn \"\\\\u\" + (\"0000\" + ch.charCodeAt(0).toString(16)).slice(-4);\n" +
"\t});\n" +
"}\n" +
"function dshPurgeHandoffDesktopUpdate(owner) {",
},
{
pattern:
"\t\tconst body = readFileSync(templatePath, \"utf8\")\n" +
"\t\t\t.split(\"__EXE_JSON__\").join(JSON.stringify(exe))\n" +
"\t\t\t.split(\"__INSTALLER_JSON__\").join(JSON.stringify(installer))\n" +
"\t\t\t.split(\"__RESOURCES_JSON__\").join(JSON.stringify(resources))\n" +
"\t\t\t.split(\"__INSTALL_DIR_JSON__\").join(JSON.stringify(installDir))\n" +
"\t\t\t.split(\"__LOG_JSON__\").join(JSON.stringify(logPath));\n" +
"\t\tconst script = join(process.env.TEMP || \"\", \"dsh-purge-official-update.js\");\n",
replace:
"\t\tconst body = readFileSync(templatePath, \"utf8\")\n" +
"\t\t\t.split(\"__EXE_JSON__\").join(dshPurgeWshLiteral(exe))\n" +
"\t\t\t.split(\"__INSTALLER_JSON__\").join(dshPurgeWshLiteral(installer))\n" +
"\t\t\t.split(\"__RESOURCES_JSON__\").join(dshPurgeWshLiteral(resources))\n" +
"\t\t\t.split(\"__INSTALL_DIR_JSON__\").join(dshPurgeWshLiteral(installDir))\n" +
"\t\t\t.split(\"__LOG_JSON__\").join(dshPurgeWshLiteral(logPath));\n" +
"\t\tfor (var i = 0; i < body.length; i++) { if (body.charCodeAt(i) > 127) throw new Error(\"desktop update script is not ascii\"); }\n" +
"\t\tconst script = join(process.env.TEMP || \"\", \"dsh-purge-official-update.js\");\n",
},
],
markers: ["function dshPurgeWshLiteral"],
},
];
export const ALL_PATCHES = [...PATCHES, ...CODE_PATCHES, ...ENGINE_PATCHES, ...NEW_TOOL_PATCHES];
+5 -3
View File
@@ -2,7 +2,7 @@ import os from "node:os";
import path from "node:path";
import { execFileSync, spawn } from "node:child_process";
import { fileURLToPath } from "node:url";
import { launchOfficialDesktopUpdate, pendingOfficialUpdate } from "./official-update.js";
import { isWshAscii, launchOfficialDesktopUpdate, pendingOfficialUpdate, wshLiteral } from "./official-update.js";
import { hostFs } from "./extract-asar.js";
// 无归档时用 node:fs。app.asar 还在时不能把映射出来的 resources/app 当成已经解开。
@@ -826,7 +826,7 @@ export function scheduleRestart(request, ctx) {
}
function jsString(value) {
return JSON.stringify(String(value || ""));
return wshLiteral(value);
}
function officialRestartScript(exe, asar) {
@@ -873,7 +873,9 @@ export function restartOfficialHarness() {
const asar = appAsarPath(exe);
const script = path.join(os.tmpdir(), "dsh-purge-official-restart.js");
const launcher = path.join(os.tmpdir(), "dsh-purge-official-restart.cmd");
fs.writeFileSync(script, officialRestartScript(exe, asar), "utf8");
const restartBody = officialRestartScript(exe, asar);
if (!isWshAscii(restartBody)) return { restarting: false };
fs.writeFileSync(script, restartBody, "utf8");
fs.writeFileSync(launcher, `@echo off\r\nstart "" wscript.exe //nologo //B "${script}"\r\n`, "utf8");
const child = spawn("cmd.exe", ["/d", "/c", launcher], {
detached: true,
+23 -6
View File
@@ -149,16 +149,33 @@ function winPath(value) {
return path.win32.normalize(String(value || ""));
}
/** Windows Script Host 无 BOM 时按系统 ANSI 读文件。中文路径写成 \uXXXX,整份脚本保持 ASCII。 */
export function wshLiteral(value) {
return JSON.stringify(String(value ?? "")).replace(/[\u007f-\uffff]/g, (ch) => {
return "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0");
});
}
export function isWshAscii(source) {
const text = String(source || "");
for (let i = 0; i < text.length; i += 1) {
if (text.charCodeAt(i) > 0x7f) return false;
}
return true;
}
function renderUpdateScript(exe, installer) {
const installDir = winPath(path.dirname(exe));
const resources = winPath(path.join(installDir, "resources"));
const logPath = winPath(path.join(os.tmpdir(), "dsh-purge-official-update.log"));
return fs.readFileSync(TEMPLATE_PATH, "utf8")
.split("__EXE_JSON__").join(JSON.stringify(winPath(exe)))
.split("__INSTALLER_JSON__").join(JSON.stringify(winPath(installer)))
.split("__RESOURCES_JSON__").join(JSON.stringify(resources))
.split("__INSTALL_DIR_JSON__").join(JSON.stringify(installDir))
.split("__LOG_JSON__").join(JSON.stringify(logPath));
const body = fs.readFileSync(TEMPLATE_PATH, "utf8")
.split("__EXE_JSON__").join(wshLiteral(winPath(exe)))
.split("__INSTALLER_JSON__").join(wshLiteral(winPath(installer)))
.split("__RESOURCES_JSON__").join(wshLiteral(resources))
.split("__INSTALL_DIR_JSON__").join(wshLiteral(installDir))
.split("__LOG_JSON__").join(wshLiteral(logPath));
if (!isWshAscii(body)) throw new Error("official update script is not ASCII");
return body;
}
/** 退出官方客户端后运行已下载的安装包,再打开新版本。不把新的 app.asar 挪走。 */
+1 -1
View File
@@ -1,4 +1,4 @@
// 占位符由 official-update.js 填上。退出当前官方客户端,运行已下载的安装包,成功后再打开。
// Placeholders are filled by official-update.js. Quit the official client, run the downloaded installer, then reopen.
var exe = __EXE_JSON__;
var installer = __INSTALLER_JSON__;
var resources = __RESOURCES_JSON__;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dsh-purge",
"version": "1.1.38",
"version": "1.1.39",
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
"type": "module",
"main": "lib/index.js",
+14
View File
@@ -1,3 +1,17 @@
# 1.1.39
## 中文
- 版本升级到 1.1.39。
- 中文 Windows 上,官方桌面版点「安装并重启」不再停在「正在准备重启」。更新脚本首行改为纯 ASCII,路径里的中文写成 `\u` 转义,避免 Windows Script Host 按 GBK 把换行吞进注释。
- macOS 和 Linux 不走这条脚本,重启方式不变。
## English
- Version 1.1.39.
- On Chinese Windows, the official desktop install-and-restart no longer stays on preparing to restart. The update script starts with an ASCII comment, and non-ASCII paths are written as `\u` escapes, so Windows Script Host does not swallow the newline when it reads the file as GBK.
- macOS and Linux do not use this script. Their restart path is unchanged.
# 1.1.38
## 中文