Compare commits

...
2 Commits
Author SHA1 Message Date
叫我小杨同学 925f7d3f0f fix: 发布 1.1.40,适配 DSH 0.2.0 并应用后自动重启
Anthropic OAuth 去掉 Claude Code 首段;移除 0.2 无效的 patch 41;应用成功后自动重启宿主。
2026-09-30 01:07:24 +08:00
叫我小杨同学andCursor a049e3c7d5 fix: 发布 1.1.39,中文 Windows 官方桌面更新不再卡在准备重启
Fixes #47

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-29 20:10:51 +08:00
10 changed files with 190 additions and 82 deletions

No files matched your search

+7 -7
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.40</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>
@@ -15,7 +15,7 @@
<a href="https://github.com/YuJunZhiXue/dsh-purge/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-65a30d?style=flat" alt="MIT license"></a>
<a href="https://awesome-dsh-plugin.com"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="awesome · DSH plugin"></a>
<a href="https://deepseek.stream/plugins/dsh-purge"><img src="https://img.shields.io/badge/Hub-dsh--purge-1a73e8" alt="DeepSeek Harness Hub"></a>
<a href="https://www.deepseek.com/harness/"><img src="https://img.shields.io/badge/dsh-0.1.7--rc.2-blue" alt="DSH"></a>
<a href="https://www.deepseek.com/harness/"><img src="https://img.shields.io/badge/dsh-0.2.0--rc.2-blue" alt="DSH"></a>
<br>
<img src="https://img.shields.io/badge/Node.js-%3E%3D18-339933?logo=node.js&logoColor=fff" alt="Node.js">
<img src="https://img.shields.io/badge/JavaScript-F7DF1E?logo=javascript&logoColor=000" alt="JavaScript">
@@ -25,9 +25,9 @@
<a href="README.md">English</a> | <a href="README.zh-CN.md">中文</a>
</p>
> **After Apply, you must click Restart or the inject does not take effect.** Apply only writes the prompt and patches to disk. This process is still the old one. When the host has restarted, start a new chat — that is when the inject enters the session. Apply alone looks like nothing was injected.
> **Apply writes the prompt and patches, then restarts the host automatically.** After the host comes back, start a new chat — that is when the inject enters the session. If Apply fails (for example patches did not all apply), it does not restart.
> Current target is **dsh 0.1.7-rc.2**. The previous target, **0.1.7-rc.1** (including `0.1.7-rc.1.20260924.1`), still matches (Node.js **≥18**; Windows no-flash import hooks need **Node ≥22** `registerHooks`, older Node still gets file-level `windowsHide` patches). Patterns from older host builds that no longer exist are not applied. On other versions, unmatched originals stay pending or skipped. Nothing is rewritten blindly. Also accepts the 0.1.2 community `dsh-persona text` field and `dsh-mnemon` v0 session `summary`. After install you still need **Apply + restart**.
> Current target is **dsh 0.2.0-rc.2**; **0.1.7-rc.2** / **0.1.7-rc.1** still match (Node.js **≥18**; Windows no-flash import hooks need **Node ≥22** `registerHooks`, older Node still gets file-level `windowsHide` patches). Patterns from older host builds that no longer exist are not applied. On other versions, unmatched originals stay pending or skipped. Nothing is rewritten blindly. Also accepts the 0.1.2 community `dsh-persona text` field and `dsh-mnemon` v0 session `summary`. After install, click **Apply** once (a successful Apply restarts for you).
>
> Hub page is for reading only: [DeepSeek Harness Hub](https://deepseek.stream/plugins/dsh-purge). Do not install via `deepseek.stream/api/plugins/download?...`.
@@ -190,7 +190,7 @@ $env:DSH_DESKTOP_DEFAULT_PROFILE = "desktop"
### Official desktop EXE
If the **official DeepSeek Harness desktop client** is installed, use the command or the button (`dsh://`). Community DSH Desktop does **not** handle that protocol — use the previous section. Current patches target **0.1.7-rc.2**. The **0.1.7-rc.1** anchors are still there.
If the **official DeepSeek Harness desktop client** is installed, use the command or the button (`dsh://`). Community DSH Desktop does **not** handle that protocol — use the previous section. Current patches target **0.2.0-rc.2**. The **0.1.7-rc.2** / **0.1.7-rc.1** anchors are still there.
```sh
dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
@@ -260,7 +260,7 @@ export function installDshPurgeToDesktop() {
Then fully quit the official client, including the tray, and open it again.
On the official desktop, click **Apply**, then restart.
On the official desktop, click **Apply** (a successful Apply restarts automatically).
### How to tell it installed
@@ -677,7 +677,7 @@ dsh-purge --edit
purge_status purge_apply purge_revert
```
Patched packages load only after a restart. Apply does not restart by itself. Under the patch title is the stable release: you can see versions and switch. A rollback is pinned; click **Update** to return to the latest. The beta channel is gone.
After a successful Apply, the host restarts so patched packages load; you can also click **Restart** manually. Under the patch title is the stable release: you can see versions and switch. A rollback is pinned; click **Update** to return to the latest. The beta channel is gone.
The composer **Undo** button drops the last turn and puts the last user sentence back in the input. On the main agent you can rewind once or the whole last round (including subagents). After rewind, send only what is in the box now. `/rewind` does the same. The host cannot truncate a session in place, so rewind opens another session for the shortened transcript and removes the old one from the sidebar. Repeating undo does not leave a stack of branches in the list.
+8 -8
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.40</strong></p>
<p align="center">
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
@@ -15,7 +15,7 @@
<a href="https://github.com/YuJunZhiXue/dsh-purge/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-65a30d?style=flat" alt="MIT license"></a>
<a href="https://awesome-dsh-plugin.com"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="awesome · DSH plugin"></a>
<a href="https://deepseek.stream/plugins/dsh-purge"><img src="https://img.shields.io/badge/Hub-dsh--purge-1a73e8" alt="DeepSeek Harness Hub"></a>
<a href="https://www.deepseek.com/harness/"><img src="https://img.shields.io/badge/dsh-0.1.7--rc.2-blue" alt="DSH"></a>
<a href="https://www.deepseek.com/harness/"><img src="https://img.shields.io/badge/dsh-0.2.0--rc.2-blue" alt="DSH"></a>
<br>
<img src="https://img.shields.io/badge/Node.js-%3E%3D18-339933?logo=node.js&logoColor=fff" alt="Node.js">
<img src="https://img.shields.io/badge/JavaScript-F7DF1E?logo=javascript&logoColor=000" alt="JavaScript">
@@ -25,9 +25,9 @@
<a href="README.md">English</a> | <a href="README.zh-CN.md">中文</a>
</p>
> **点「应用」之后,必须再点「重启」,注入才会生效。** 「应用」只把提示词和补丁写进文件,当前这个进程还是旧的。重启完成、宿主重新打开后,新开一轮对话,注入才进当前会话。只点应用、不重启,看起来就像没注入。
> **点「应用」会写入提示词和补丁,并自动重启宿主。** 重启完成后新开一轮对话,注入才进当前会话。若应用失败(例如补丁未全部打上),不会自动重启。
> 当前对准 **dsh 0.1.7-rc.2**。上一档 **0.1.7-rc.1**(含 `0.1.7-rc.1.20260924.1`)仍认(Node.js **≥18**;Windows 无闪窗需要 **Node ≥22** 的 `registerHooks`,更低版本仍用文件级 `windowsHide`)。旧宿主里已经不存在的条文不再打。其它版本对不上的原文会显示待应用或跳过,不会乱改文件。兼容 0.1.2 社区预设的 `text` 字段,以及 `dsh-mnemon` 旧会话的 v0 `summary`。装完必须 **应用 + 重启**。
> 当前对准 **dsh 0.2.0-rc.2**;**0.1.7-rc.2** / **0.1.7-rc.1** 仍可用(Node.js **≥18**;Windows 无闪窗需要 **Node ≥22** 的 `registerHooks`,更低版本仍用文件级 `windowsHide`)。旧宿主里已经不存在的条文不再打。其它版本对不上的原文会显示待应用或跳过,不会乱改文件。兼容 0.1.2 社区预设的 `text` 字段,以及 `dsh-mnemon` 旧会话的 v0 `summary`。装完要点一次 **应用**(成功后会自动重启)。
>
> 插件市场只看介绍:[DeepSeek Harness Hub](https://deepseek.stream/plugins/dsh-purge)。不要用 `deepseek.stream/api/plugins/download?...` 安装。
@@ -190,7 +190,7 @@ $env:DSH_DESKTOP_DEFAULT_PROFILE = "desktop"
### 官方桌面 EXE
已经安装 **DeepSeek Harness 官方桌面客户端** 时,用下面的命令,或点按钮走 `dsh://`。社区 DSH Desktop **不认** 这个协议,请回到上一节。当前补丁对准 **0.1.7-rc.2**,**0.1.7-rc.1** 的旧锚点还留着。
已经安装 **DeepSeek Harness 官方桌面客户端** 时,用下面的命令,或点按钮走 `dsh://`。社区 DSH Desktop **不认** 这个协议,请回到上一节。当前补丁对准 **0.2.0-rc.2**,**0.1.7-rc.2** / **0.1.7-rc.1** 的旧锚点还留着。
```sh
dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz
@@ -260,7 +260,7 @@ export function installDshPurgeToDesktop() {
然后完全退出官方客户端(含托盘),再打开,点会话标题旁的 **dsh-purge**,在「清洗」里点「应用」。
**官方桌面点「应用」,然后重启即可。**
**官方桌面点「应用」即可(成功后会自动重启)。**
### 怎样算装上了
@@ -680,7 +680,7 @@ dsh-purge --edit
purge_status purge_apply purge_revert
```
设置页「应用」完成后需要重启才会加载已改的包文件。点「重启」才会重启,不会自动重启。补丁标题下是正式版:可以看版本和切换。回退后会固定在该版本,要回到最新再点「更新」。测试版通道已去掉。
设置页「应用」成功后会自动重启,以加载已改的包文件;也可手动点「重启」。补丁标题下是正式版:可以看版本和切换。回退后会固定在该版本,要回到最新再点「更新」。测试版通道已去掉。
输入框旁的「回退」会丢掉最近一轮对话,并把上一句填回输入框;聊天里 `/rewind` 同样可用。宿主不能在原会话里截断,所以回退会另开一条承载截断后的内容,并把原来那条从侧边栏移出。多退几次不会在列表里堆出一串分支。
@@ -756,7 +756,7 @@ flowchart LR
4. 嵌套 `@deepseek-ai/dsh/node_modules/@deepseek-ai`
5. 系统默认 `~/.dsh`
**桌面端:** 只改当前正在运行的桌面安装。官方客户端点「应用」,然后重启即可。社区端点「应用」,然后重启即可。
**桌面端:** 只改当前正在运行的桌面安装。官方客户端点「应用」即可(成功后会自动重启)。社区端点「应用」,然后重启即可。
找不到目标时提示设置 `DSH_BASE`,不改文件。
+7 -7
View File
@@ -1293,12 +1293,6 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3
setNotice({ kind: "error", text: tr("err.action", { action: label, error: d.error || "" }) });
return;
}
if (action === "apply" && (d.unpacked_asar || d.needs_full_quit)) {
setAskOfficialRestart(true);
setNotice({ kind: "ok", text: tr("restart.official.body") });
loadAll();
return;
}
if (action === "apply") {
if (typeof d.defaultContent === "string") setDefaultOverride(d.defaultContent);
if (typeof d.override_content === "string") {
@@ -1335,9 +1329,15 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3
loadAll();
return;
}
if (action === "apply" && (d.restart_after_apply || d.restarting || d.unpacked_asar || d.needs_full_quit)) {
setNotice({ kind: "ok", text: tr("update.restarting") });
loadAll();
const surf = hostSurfaceOf(state) || clientGuessSurface() || "web";
restartDsh(setNotice, setPatchBusy, tr, surf);
return;
}
setNotice({ kind: "ok", text: tr("ok.done") });
loadAll();
if (action === "apply") setAskRestart(true);
})
.catch((e) => {
if (ticket !== actionTicket.current) return;
+105 -48
View File
@@ -2889,49 +2889,6 @@ const NEW_TOOL_PATCHES = [
forbid: ["dsh-purge:committed"],
markers: ["dshPurgeInject"],
},
{
// 自定义 OpenAI 兼容接口不认 developer;推理模型默认会把 system 收成这个角色,直接 400。
id: 41, name: "DEVELOPER_ROLE_TO_SYSTEM", layer: "0.1.5 兼容", layer_en: "0.1.5",
desc: "developer 角色改回 system,兼容接口不再 400 / remap developer role to system",
file: ["pi-ai-completions", "pi-ai-responses-shared"],
optional: true,
skipIfMarked: true,
replacements: [
{
pattern:
" const useDeveloperRole = model.reasoning && compat.supportsDeveloperRole;\n" +
" const role = useDeveloperRole ? \"developer\" : \"system\";",
replace:
" const useDeveloperRole = false; // [dsh-purge] compatible APIs reject developer\n" +
" const role = useDeveloperRole ? \"developer\" : \"system\";",
},
{
pattern:
" lastRole = msg.role;\n" +
" }\n" +
" return params;\n" +
"}\n" +
"function convertTools(",
replace:
" lastRole = msg.role;\n" +
" }\n" +
" for (const message of params) {\n" +
" if (message && message.role === \"developer\") message.role = \"system\";\n" +
" } // [dsh-purge] compatible APIs reject developer\n" +
" return params;\n" +
"}\n" +
"function convertTools(",
},
{
pattern:
" const role = model.reasoning && compat?.supportsDeveloperRole !== false ? \"developer\" : \"system\";",
replace:
" const role = \"system\"; // [dsh-purge] compatible APIs reject developer",
},
],
markersAny: true,
markers: ["[dsh-purge] compatible APIs reject developer"],
},
{
id: 42, name: "SETTINGS_LEGACY_API", layer: "代码", layer_en: "Code",
desc: "设置服务补回 register/get,旧插件可继续用 / legacy settings API",
@@ -3136,6 +3093,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 +3121,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 +3141,99 @@ 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"],
},
{
id: 47,
name: "ANTHROPIC_OAUTH_NO_CLAUDE_IDENTITY",
layer: "0.2.0 兼容",
layer_en: "0.2.0",
desc: "Anthropic OAuth 不再强插 Claude Code 首段系统提示 / drop Claude Code OAuth system prefix",
file: ["pi-ai-anthropic-messages"],
optional: true,
skipIfMarked: true,
replacements: [
{
pattern:
" // For OAuth tokens, we MUST include Claude Code identity\n" +
" if (isOAuthToken) {\n" +
" params.system = [\n" +
" {\n" +
" type: \"text\",\n" +
" text: \"You are Claude Code, Anthropic's official CLI for Claude.\",\n" +
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
" },\n" +
" ];\n" +
" if (initialSystemText) {\n" +
" params.system.push({\n" +
" type: \"text\",\n" +
" text: sanitizeSurrogates(initialSystemText),\n" +
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
" });\n" +
" }\n" +
" }\n" +
" else if (initialSystemText) {\n" +
" // Add cache control to system prompt for non-OAuth tokens\n" +
" params.system = [\n" +
" {\n" +
" type: \"text\",\n" +
" text: sanitizeSurrogates(initialSystemText),\n" +
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
" },\n" +
" ];\n" +
" }",
replace:
" // [dsh-purge] OAuth no longer prepends Claude Code identity\n" +
" if (initialSystemText) {\n" +
" params.system = [\n" +
" {\n" +
" type: \"text\",\n" +
" text: sanitizeSurrogates(initialSystemText),\n" +
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
" },\n" +
" ];\n" +
" }",
},
],
markers: ["[dsh-purge] OAuth no longer prepends Claude Code identity"],
},
];
export const ALL_PATCHES = [...PATCHES, ...CODE_PATCHES, ...ENGINE_PATCHES, ...NEW_TOOL_PATCHES];
@@ -3553,6 +3609,7 @@ export function targetFiles(aiBase, dshHome = findDshHome()) {
]),
"pi-ai-completions": allExisting(listPiAiApiFiles(dshHome, aiBase, "openai-completions.js")),
"pi-ai-responses-shared": allExisting(listPiAiApiFiles(dshHome, aiBase, "openai-responses-shared.js")),
"pi-ai-anthropic-messages": allExisting(listPiAiApiFiles(dshHome, aiBase, "anthropic-messages.js")),
};
return filterTargetFiles(files);
}
+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,
+3 -1
View File
@@ -1248,10 +1248,12 @@ function installWebServer(ctx, cfg) {
const leaveTray = renamed || pendingQuit;
if (complete) reapply.markPatchesApplied();
if (leaveTray) bootFullQuit = true;
const shouldRestart = complete;
sendJson(response, 200, {
ok: true,
complete,
restarting: false,
restarting: shouldRestart,
restart_after_apply: shouldRestart,
unpacked_asar: leaveTray,
needs_full_quit: leaveTray,
applied: summary.applied,
+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.40",
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
"type": "module",
"main": "lib/index.js",
+30
View File
@@ -1,3 +1,33 @@
# 1.1.40
## 中文
- 版本升级到 1.1.40。
- 适配 **DSH 0.2.0-rc.2**:Anthropic OAuth 不再在系统提示最前面强插「You are Claude Code…」,自定义 `prompt-inject` 不会被压到后面。
- 去掉在 0.2 里已不存在的 **patch 41**(developer 角色改写),避免无效补丁占位。
- 设置页点 **应用** 成功后 **自动重启** 宿主,不必再打开插件点第二次重启。
## English
- Version 1.1.40.
- For **DSH 0.2.0-rc.2**, Anthropic OAuth no longer prepends “You are Claude Code…” ahead of your system prompt, so custom `prompt-inject` is not pushed behind a Claude identity block.
- Removed **patch 41** (developer-role remap) because those needles are gone in 0.2.
- After **Apply** in settings, the host **restarts automatically**; you no longer need to open the plugin again to confirm restart.
# 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
## 中文