Compare commits

...
Author SHA1 Message Date
叫我小杨同学andCursor 11daeabb7c fix: 发布 1.1.51,修 skills 自导入删空、EnvAdapt op、同版本更新劫持与补丁锚点
Co-authored-by: Cursor <cursoragent@cursor.com>

#54 拒绝 skills 源与目标重叠;#55 补 platformEnvAdaptStatus/Skip;#56 无版本 installer 不再劫持重启并恢复 app;#52/#57 锚点跟上 0.1.7/0.2,导出 patches_ready。
2026-10-03 01:01:31 +08:00
叫我小杨同学andCursor 148d6218d8 fix: 发布 1.1.50,修 macOS 桌面重启/CLI(#53)与应用后默认提示词注入。
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-02 22:29:28 +08:00
12 changed files with 260 additions and 66 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.49-beta.1</strong></p>
<p align="center"><strong>Version 1.1.51</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>
@@ -118,7 +118,7 @@ This release supports **DeepSeek Harness 0.2** only (official desktop **0.2.0-rc
| Official Harness 0.1.x | Not supported |
| Any other version | Unmatched patches stay pending or skipped; do not expect them to work |
The plugin version is **1.1.49-beta.1**. 1.1.45 is skipped; it has bugs.
The plugin version is **1.1.51**. 1.1.45 is skipped; it has bugs.
---
@@ -220,13 +220,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
<p align="center">
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 Open Hub page</strong></a>
&nbsp;·&nbsp;
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.49-beta.1&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 Install in desktop client</strong></a>
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.51&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 Install in desktop client</strong></a>
</p>
🔗 **Raw protocol URL:**
```
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.49-beta.1&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.51&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
```
<details>
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
const params = new URLSearchParams({
id: 'dsh-purge',
name: 'dsh-purge',
version: '1.1.49-beta.1',
version: '1.1.51',
repo: 'YuJunZhiXue/dsh-purge',
permissions: '系统提示词注入, 本机补丁, 设置页',
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
**HTML link:**
```html
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.49-beta.1&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.51&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
🚀 Install in desktop client
</a>
```
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|---|---|---|
| id | `dsh-purge` | Plugin id |
| name | `dsh-purge` | Display name |
| version | `1.1.49-beta.1` | Semver |
| version | `1.1.51` | Semver |
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
+7 -7
View File
@@ -4,7 +4,7 @@
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
<p align="center"><strong>Version 1.1.49-beta.1</strong></p>
<p align="center"><strong>Version 1.1.51</strong></p>
<p align="center">
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
@@ -118,7 +118,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
| 官方 Harness 0.1.x | 不支持 |
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
插件版本是 **1.1.49-beta.1**。1.1.45 有问题,略过。
插件版本是 **1.1.51**。1.1.45 有问题,略过。
---
@@ -220,13 +220,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
<p align="center">
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 打开插件市场页</strong></a>
&nbsp;·&nbsp;
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.49-beta.1&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 唤起客户端一键安装</strong></a>
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.51&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz"><strong>🚀 唤起客户端一键安装</strong></a>
</p>
🔗 **原生协议链接:**
```
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.49-beta.1&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.51&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
```
<details>
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
const params = new URLSearchParams({
id: 'dsh-purge',
name: 'dsh-purge',
version: '1.1.49-beta.1',
version: '1.1.51',
repo: 'YuJunZhiXue/dsh-purge',
permissions: '系统提示词注入, 本机补丁, 设置页',
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
**HTML 静态链接方式:**
```html
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.49-beta.1&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.51&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz">
🚀 唤起客户端一键安装
</a>
```
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|---|---|---|
| id | `dsh-purge` | 插件唯一标识符 |
| name | `dsh-purge` | 插件展示名称 |
| version | `1.1.49-beta.1` | 语义化版本号 |
| version | `1.1.51` | 语义化版本号 |
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
+9 -6
View File
@@ -94,8 +94,9 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
return Boolean(active && active.size > 0);
}
async function bothInjectEmpty(overrideText) {
async function bothInjectEmpty(overrideText, defaultText) {
if (!promptBoxEmpty(overrideText)) return false;
if (!promptBoxEmpty(defaultText)) return false;
try {
return !activeRuleHasBody(await rulesApi("status"));
} catch {
@@ -195,6 +196,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"metric.purged.skip": "已就绪,其中 {n} 项本机不需要",
"metric.unlocated.count": "—",
"metric.shim": "shim",
"metric.shim.na": "本端不需要",
"metric.bak.yes": "有备份",
"metric.bak.no": "无备份",
"metric.bak.hint": "备份",
@@ -487,6 +489,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"metric.purged.skip": "Ready, {n} not needed here",
"metric.unlocated.count": "—",
"metric.shim": "shim",
"metric.shim.na": "Not needed here",
"metric.bak.yes": "Backup",
"metric.bak.no": "No backup",
"metric.bak.hint": "Backup",
@@ -1016,9 +1019,9 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
}
function shimKind(v) {
if (v === "patched") return "ok";
if (v === "patched" || v === "n/a") return "ok";
if (v === "original") return "wait";
if (v === "missing" || v === "n/a" || !v) return "miss";
if (v === "missing" || !v) return "miss";
return "bad";
}
@@ -1498,7 +1501,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
run();
return;
}
bothInjectEmpty(overrideRef.current).then((empty) => {
bothInjectEmpty(overrideRef.current, defaultOverrideRef.current).then((empty) => {
if (ticket !== actionTicket.current) return;
if (empty) {
rejectNeedPrompt(tr);
@@ -1538,7 +1541,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
if (ticket === actionTicket.current) setPatchBusy(false);
});
};
bothInjectEmpty(overrideRef.current).then((empty) => {
bothInjectEmpty(overrideRef.current, defaultOverrideRef.current).then((empty) => {
if (ticket !== actionTicket.current) return;
if (empty) {
rejectNeedPrompt(tr);
@@ -1714,7 +1717,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
" ",
h("span", { className: "dshp-pill is-" + shimKind(s.shim_bin || "missing") }, "unix"),
),
h("span", null, t("metric.shim")),
h("span", null, (s.shim_cmd === "n/a" && s.shim_ps1 === "n/a" && (s.shim_bin === "n/a" || !s.shim_bin)) ? t("metric.shim.na") : t("metric.shim")),
),
h("div", { className: "dshp-metric" },
h("b", null, s.has_backup ? t("metric.bak.yes") : t("metric.bak.no")),
+82 -15
View File
@@ -3497,6 +3497,8 @@ const NEW_TOOL_PATCHES = [
},
],
markers: ["Proceed with operator-requested paths."],
// 上游已删谨慎句时无残留 pattern,按软完成计(#48)。
softSettle: true,
},
{
id: 49,
@@ -3594,6 +3596,11 @@ const NEW_TOOL_PATCHES = [
pattern: "enabled: z.boolean().default(true).volatile(),",
replace: "enabled: z.boolean().default(false).volatile(), // [dsh-purge] session log upload off",
},
// 0.1.7-rc.2 / 0.2 起去掉 .volatile();限定在本补丁两个文件内各只命中一次。
{
pattern: "enabled: z.boolean().default(true),",
replace: "enabled: z.boolean().default(false), // [dsh-purge] session log upload off",
},
],
markers: ["[dsh-purge] session log upload off"],
},
@@ -4050,7 +4057,7 @@ const NEW_TOOL_PATCHES = [
layer: "代码",
layer_en: "Code",
desc: "deepseek.com 的系统提示词固定走 system,思维链不动 / keep deepseek.com instructions on system",
file: ["pi-ai-completions"],
file: ["pi-ai-completions", "pi-ai-responses-shared"],
optional: true,
skipIfMarked: true,
replacements: [
@@ -4058,6 +4065,16 @@ const NEW_TOOL_PATCHES = [
pattern: 'const instructionRole = model.reasoning && compat.supportsDeveloperRole ? "developer" : "system";',
replace: 'const instructionRole = model.reasoning && compat.supportsDeveloperRole && !String(model.baseUrl || "").toLowerCase().includes("deepseek.com") ? "developer" : "system"; // [dsh-purge] deepseek.com keeps system role',
},
// 0.1.7+ / 0.2:改写为 useDeveloperRole。
{
pattern: "const useDeveloperRole = model.reasoning && compat.supportsDeveloperRole;",
replace: 'const useDeveloperRole = model.reasoning && compat.supportsDeveloperRole && !String(model.baseUrl || "").toLowerCase().includes("deepseek.com"); // [dsh-purge] deepseek.com keeps system role',
},
// responses 通路(悬空键 pi-ai-responses-shared 接上)。
{
pattern: 'const role = model.reasoning && compat?.supportsDeveloperRole !== false ? "developer" : "system";',
replace: 'const role = model.reasoning && compat?.supportsDeveloperRole !== false && !String(model.baseUrl || "").toLowerCase().includes("deepseek.com") ? "developer" : "system"; // [dsh-purge] deepseek.com keeps system role',
},
],
markers: ["[dsh-purge] deepseek.com keeps system role"],
},
@@ -4990,7 +5007,7 @@ function isApprovalSentencePatch(patch) {
}
function isLayoutSoftPatch(patch) {
return isIdentityLayoutPatch(patch) || isApprovalSentencePatch(patch);
return isIdentityLayoutPatch(patch) || isApprovalSentencePatch(patch) || Boolean(patch?.softSettle);
}
function filePatchSettled(text, patch, fp = "") {
@@ -5762,7 +5779,10 @@ export async function readOverrideForUi(dshHome) {
}
}
const customized = await isUserCustomizedOverride(dshHome);
const show = normalizeOverride(disk) ? disk : defaultContent;
// 未改过:界面始终显示内置默认(1.1.30 前行为)。已改过:显示磁盘正文,空则回退默认。
const show = customized
? (normalizeOverride(disk) ? disk : defaultContent)
: defaultContent;
return {
path: fp,
exists,
@@ -5788,42 +5808,84 @@ export function seedOverrideSync(dshHome) {
const bundled = defaultOverrideText();
if (!normalizeOverride(bundled)) return fs.existsSync(fp) ? "empty" : "missing";
fs.writeFileSync(fp, bundled, "utf8");
try {
const state = readOverrideStateSync(dshHome);
if (state.customized !== true) {
fs.mkdirSync(path.dirname(overrideStatePath(dshHome)), { recursive: true });
fs.writeFileSync(
overrideStatePath(dshHome),
`${JSON.stringify({
customized: false,
hash: hashOverride(bundled),
seedHash: defaultOverrideHash(),
updatedAt: new Date().toISOString(),
}, null, 2)}\n`,
"utf8",
);
}
} catch {
// 状态写失败不挡注入文件
}
return "wrote";
}
/**
* 未自行改过时始终把内置默认写回磁盘(与 1.1.30 前一致)。
* 只点「应用」不点「保存」也要有可注入正文;空文件或仍是旧默认种子时都补齐。
*/
export async function installOverride(dshHome, force = false) {
const fp = findOverrideFile(dshHome);
await fsp.mkdir(dshHome, { recursive: true });
if (!force && await isUserCustomizedOverride(dshHome)) return "exists";
const bundled = defaultOverrideText();
if (!normalizeOverride(bundled)) return fs.existsSync(fp) ? "empty" : "missing";
let disk = "";
if (!force && fs.existsSync(fp)) {
let disk = "";
try {
disk = await loadText(fp);
} catch {
disk = "";
}
const bundled = defaultOverrideText();
if (normalizeOverride(disk) && normalizeOverride(disk) !== normalizeOverride(bundled)) {
await markOverrideCustomized(dshHome, true, disk);
return "exists";
}
}
const bundled = defaultOverrideText();
if (!normalizeOverride(bundled)) return fs.existsSync(fp) ? "empty" : "missing";
// 磁盘已是同一份默认则只刷新标记,避免无意义重写。
if (!force && normalizeOverride(disk) && normalizeOverride(disk) === normalizeOverride(bundled)) {
await markOverrideCustomized(dshHome, false, bundled);
return "exists";
}
await fsp.writeFile(fp, bundled, "utf8");
await markOverrideCustomized(dshHome, false, bundled);
return "wrote";
}
/** 应用/启动时解析最终要落盘并注入的正文:框里有就用框,否则内置默认。 */
export function resolveApplyOverrideText(dshHome, incoming) {
const bundled = defaultOverrideText();
if (normalizeOverride(incoming)) return String(incoming);
const disk = overrideFileTextSafe(dshHome);
if (normalizeOverride(disk)) return disk;
return bundled;
}
function overrideFileTextSafe(dshHome) {
const fp = findOverrideFile(dshHome);
try {
if (!fp || !fs.existsSync(fp)) return "";
return fs.readFileSync(fp, "utf8");
} catch {
return "";
}
}
export async function saveOverrideContent(dshHome, content) {
const bundled = defaultOverrideText();
const incoming = typeof content === "string" ? content : "";
const customized = normalizeOverride(incoming) !== normalizeOverride(bundled);
const resolved = normalizeOverride(incoming) ? incoming : bundled;
const customized = normalizeOverride(resolved) !== normalizeOverride(bundled);
const fp = findOverrideFile(dshHome);
await fsp.mkdir(dshHome, { recursive: true });
await fsp.writeFile(fp, incoming, "utf8");
await markOverrideCustomized(dshHome, customized, incoming);
return { path: fp, customized, content: incoming, defaultContent: bundled };
await fsp.writeFile(fp, resolved, "utf8");
await markOverrideCustomized(dshHome, customized, resolved);
return { path: fp, customized, content: resolved, defaultContent: bundled };
}
export async function ensureOverrideContent(dshHome, force = false) {
@@ -5893,6 +5955,11 @@ export async function gatherState() {
shim_cmd = shimFileStatus(path.join(shimDir, "dsh.cmd"));
shim_ps1 = shimFileStatus(path.join(shimDir, "dsh.ps1"));
shim_bin = shimFileStatus(path.join(shimDir, "dsh"));
} else if (adapterFor(detectSurface()) === "desktop") {
// 桌面宿主不 patch CLI shim;缺目录不是失败。
shim_cmd = "n/a";
shim_ps1 = "n/a";
shim_bin = "n/a";
}
return {
surface: detectSurface(),
+38 -16
View File
@@ -364,14 +364,22 @@ function installIdentityOverride(ctx, config = {}) {
// 0.1.5 起 complete:true 在 waterfall 之后用调用前的快照盖掉 sections。
// 换宿主版本时文件补丁还没写上,或换插件版本时旧钩子把 dsh-purge 段删掉,注入都会丢。
// 包住 assemble 的返回值,按 prompt-inject.md 再补回。
const prompt = ctx.systemPrompt;
if (!prompt || typeof prompt.assemble !== "function" || prompt.__dshPurgeAssembleWrapped) return;
const orig = prompt.assemble;
prompt.assemble = async function (...args) {
const assembled = await orig.apply(this, args);
return rewriteLiveAssembly(config, assembled, args[0]);
const wrapAssemble = () => {
const prompt = ctx.systemPrompt;
if (!prompt || typeof prompt.assemble !== "function" || prompt.__dshPurgeAssembleWrapped) return false;
const orig = prompt.assemble;
prompt.assemble = async function (...args) {
const assembled = await orig.apply(this, args);
return rewriteLiveAssembly(config, assembled, args[0]);
};
prompt.__dshPurgeAssembleWrapped = true;
return true;
};
prompt.__dshPurgeAssembleWrapped = true;
if (!wrapAssemble()) {
queueMicrotask(wrapAssemble);
setTimeout(wrapAssemble, 500);
setTimeout(wrapAssemble, 2000);
}
}
function shimNeedsPatch(state) {
@@ -515,6 +523,10 @@ async function handlePurgeCommand(rawInput, config) {
await core.ensureOverrideContent(state.dsh_home, false);
const blocked = rejectIfNeedPrompt(state.dsh_home);
if (blocked) return { kind: "error", text: blocked.error };
await core.saveOverrideContent(
state.dsh_home,
core.resolveApplyOverrideText(state.dsh_home, ""),
);
await core.backupAll(state.ai_base);
const report = await core.applyPatches(state.ai_base);
const shimResult = await core.patchAllShims();
@@ -854,6 +866,10 @@ export function apply(ctx, config) {
} catch (e) {
console.warn("[dsh-purge] seed override error:", String(e));
}
// 与 1.1.30 前一致:启动就落盘默认提示词,不依赖用户先点保存。
core.installOverride(core.findDshHome(), false).catch((e) => {
console.warn("[dsh-purge] install override error:", String(e));
});
installIdentityOverride(ctx, cfg);
installRegionGate(ctx);
try {
@@ -985,6 +1001,10 @@ export function apply(ctx, config) {
await core.ensureOverrideContent(state.dsh_home, false);
const blocked = rejectIfNeedPrompt(state.dsh_home);
if (blocked) return { text: "ERROR: " + blocked.error };
await core.saveOverrideContent(
state.dsh_home,
core.resolveApplyOverrideText(state.dsh_home, ""),
);
await core.backupAll(state.ai_base);
const report = await core.applyPatches(state.ai_base);
await core.patchAllShims();
@@ -1112,6 +1132,7 @@ function installWebServer(ctx, cfg) {
patches_applied: state.patches_applied,
patches_pending: state.patches_pending,
patches_skipped: state.patches_skipped || 0,
patches_ready: state.patches_ready || 0,
patches_na: state.patches_na || 0,
patches_total: state.patches_total || core.ALL_PATCHES.length,
patch_status: state.patch_status,
@@ -1341,9 +1362,11 @@ function installWebServer(ctx, cfg) {
await core.ensureOverrideContent(state.dsh_home, false);
const ui = await core.readOverrideForUi(state.dsh_home);
const incoming = typeof body?.content === "string" ? body.content : "";
const boxText = core.normalizeOverride(incoming)
? incoming
: (ui.content || ui.defaultContent || "");
// 框空时用内置默认,与 1.1.30 前「应用即带默认注入」一致,不必先点保存。
const boxText = core.resolveApplyOverrideText(state.dsh_home, incoming)
|| ui.content
|| ui.defaultContent
|| "";
const blocked = rejectIfNeedPrompt(state.dsh_home, boxText);
if (blocked) {
sendJson(response, 400, {
@@ -1355,9 +1378,7 @@ function installWebServer(ctx, cfg) {
});
return;
}
if (core.normalizeOverride(boxText)) {
await core.saveOverrideContent(state.dsh_home, boxText);
}
await core.saveOverrideContent(state.dsh_home, boxText);
await core.backupAll(state.ai_base);
const report = await core.applyPatches(state.ai_base);
const override = await core.readOverrideForUi(state.dsh_home);
@@ -1505,16 +1526,17 @@ function installWebServer(ctx, cfg) {
return;
}
const home = core.findDshHome();
const blocked = rejectIfNeedPrompt(home, content);
const resolved = core.resolveApplyOverrideText(home, content);
const blocked = rejectIfNeedPrompt(home, resolved);
if (blocked) {
sendJson(response, 400, {
ok: false,
content,
content: resolved,
...blocked,
});
return;
}
const saved = await core.saveOverrideContent(home, content);
const saved = await core.saveOverrideContent(home, resolved);
sendJson(response, 200, { ok: true, ...saved, ...injectSnapshot(home) });
} catch (e) {
sendJson(response, 500, { ok: false, error: String(e) });
+6 -2
View File
@@ -91,6 +91,7 @@ export function pendingOfficialUpdate(exe) {
const cache = updaterCacheDir();
let installer = path.join(cache, "installer.exe");
let fileName = "installer.exe";
let infoVersion = "";
try {
const info = JSON.parse(fs.readFileSync(path.join(cache, "pending", "update-info.json"), "utf8"));
const pendingName = String(info.fileName || "");
@@ -99,13 +100,16 @@ export function pendingOfficialUpdate(exe) {
installer = pending;
fileName = pendingName;
}
infoVersion = String(info.version || info.fileVersion || info.toVersion || "").trim();
} catch {
// 没有 update-info 时只认已经复制出来的 installer.exe。
}
if (!fs.existsSync(installer)) return null;
const version = versionFromInstallerName(fileName);
// installer.exe 无版本号时绝不能当「待更新」(#56:同版本缓存会劫持重启解包)。
const version = versionFromInstallerName(fileName) || (parseSemver(infoVersion) ? infoVersion : "");
if (!version || !parseSemver(version)) return null;
const installed = readInstalledVersion(exe);
if (version && installed && compareSemver(version, installed) <= 0) return null;
if (installed && compareSemver(version, installed) <= 0) return null;
if (!installed) {
try {
const exeTime = fs.statSync(exe).mtimeMs;
+8 -2
View File
@@ -67,8 +67,14 @@ if (!ok) {
if (copiedAsar && fso.FileExists(asar)) {
try { fso.DeleteFile(asar, true); log('rehid-asar'); } catch (hideErr) { log('rehid-asar ' + hideErr); }
}
if (movedApp && prev && fso.FolderExists(prev) && !fso.FolderExists(appDir)) {
try { fso.MoveFolder(prev, appDir); log('restored-app'); } catch (backErr) { log('restored-app ' + backErr); }
// 并发解包 helper 可能已重建 resources\app;更新失败时仍要把打过补丁的目录搬回来。
if (movedApp && prev && fso.FolderExists(prev)) {
if (fso.FolderExists(appDir)) {
try { fso.DeleteFolder(appDir, true); log('cleared-recreated-app'); } catch (clearErr) { log('cleared-recreated-app ' + clearErr); }
}
if (!fso.FolderExists(appDir)) {
try { fso.MoveFolder(prev, appDir); log('restored-app'); } catch (backErr) { log('restored-app ' + backErr); }
}
}
try { sh.Environment('PROCESS').Remove('ELECTRON_RUN_AS_NODE'); } catch (ignore) {}
sh.Run('"' + exe + '"', 1, false);
+3 -1
View File
@@ -46,7 +46,9 @@ function sameRev(a, b) {
/** 当前插件版本和已写入补丁的版本一致时,启动不必再还原重打。 */
export function stampMatches(stamp, version, rev) {
if (!stamp || !stamp.version || stamp.version !== version) return false;
if (rev && stamp.sha && !sameRev(rev, stamp.sha)) return false;
// sha 为空表示 stamp 不完整(曾误写空串),不能当作已对齐(#56)。
if (!stamp.sha) return false;
if (rev && !sameRev(rev, stamp.sha)) return false;
return true;
}
+8 -2
View File
@@ -22,7 +22,7 @@ import { dispatch, dispatchAsync } from './store-core.js'
import { checkSkill, summarizeSkills } from './skill-availability.js'
import { maxAgentsOf, maxAgentsSourceOf, saveMaxAgents, DEFAULT_MAX_AGENTS, MAX_AGENTS_LIMIT } from './settings.js'
import {
loadPlatformConfig, mergeConfigEnv, redteamRoot, envAdaptStatus,
loadPlatformConfig, mergeConfigEnv, redteamRoot, envAdaptStatus, markEnvAdaptSkip,
platformSummary, savePlatformConfig, assignToolkitFolder,
} from './platform-config.js'
@@ -155,10 +155,16 @@ function profileDirOf(ctx) {
*/
function handlePlatformOp(store, request) {
const op = request && request.op
if (op !== 'platformConfigGet' && op !== 'platformConfigSave' && op !== 'platformAssignToolkit') {
if (op !== 'platformConfigGet' && op !== 'platformConfigSave' && op !== 'platformAssignToolkit'
&& op !== 'platformEnvAdaptStatus' && op !== 'platformEnvAdaptSkip') {
return undefined
}
const root = (store && store.root) || redteamRoot()
// EnvAdaptSendGate 轮询就绪 / 「暂不配置」;缺分支时前端永远拿不到 ready。
if (op === 'platformEnvAdaptStatus') return Object.assign({ ok: true }, envAdaptStatus(root))
if (op === 'platformEnvAdaptSkip') {
return Object.assign({ ok: true }, markEnvAdaptSkip(root, request.skip === undefined ? true : !!request.skip))
}
if (op === 'platformConfigGet') return platformSummary(root)
if (op === 'platformConfigSave') {
savePlatformConfig(request.config || {}, root)
+59 -7
View File
@@ -67,6 +67,23 @@ function assertInside(root, target) {
}
}
/** 源与 $DSH_HOME/skills 重叠时先删后拷会把自己删空(#54)。 */
function pathsOverlap(a, b) {
const left = path.resolve(String(a || ""));
const right = path.resolve(String(b || ""));
if (!left || !right) return false;
if (left === right) return true;
const leftPrefix = left.endsWith(path.sep) ? left : left + path.sep;
const rightPrefix = right.endsWith(path.sep) ? right : right + path.sep;
return left.startsWith(rightPrefix) || right.startsWith(leftPrefix);
}
function assertImportSourceOutsideSkills(dshHome, srcPath) {
const root = skillsDir(dshHome);
if (!pathsOverlap(srcPath, root)) return;
throw new Error("不能从 $DSH_HOME/skills 自身(或其子目录)导入,请换一个源目录");
}
function yamlScalar(value) {
const text = String(value ?? "").trim();
if (!text) return '""';
@@ -483,7 +500,30 @@ export async function findSkillRoots(root) {
return { dirs, flats };
}
async function restoreSkillFromBackup(dshHome, id, backup) {
if (!backup) return;
const root = skillsDir(dshHome);
const bundleSrc = path.join(backup, id);
const flatSrc = path.join(backup, `${id}.md`);
try {
if (await pathExists(bundleSrc)) {
const dest = skillBundleDir(dshHome, id);
assertInside(root, dest);
await fsp.rm(dest, { recursive: true, force: true }).catch(() => {});
await copyDir(bundleSrc, dest);
}
if (await pathExists(flatSrc)) {
const dest = skillFlatFile(dshHome, id);
assertInside(root, dest);
await fsp.copyFile(flatSrc, dest);
}
} catch {
// 回滚失败时保留 backup 路径给调用方。
}
}
async function installBundleDir(dshHome, srcDir, fallbackId) {
assertImportSourceOutsideSkills(dshHome, srcDir);
const mdPath = path.join(srcDir, "SKILL.md");
const raw = await fsp.readFile(mdPath, "utf8");
const parsed = parseSkillDocument(raw);
@@ -491,19 +531,30 @@ async function installBundleDir(dshHome, srcDir, fallbackId) {
if (!validSkillName(id)) throw new Error("压缩包/文件夹里没有合法的 Skill 名称");
const dest = skillBundleDir(dshHome, id);
assertInside(skillsDir(dshHome), dest);
if (pathsOverlap(srcDir, dest)) {
throw new Error("不能从目标技能目录自身导入,请换一个源目录");
}
const backup = await backupExisting(dshHome, id);
await removeOfficialSkill(dshHome, id);
await copyDir(srcDir, dest);
const destMd = path.join(dest, "SKILL.md");
if (parsed.ok && parsed.name !== id) {
await fsp.writeFile(destMd, mergeSkillDocument(id, parsed.description, raw), "utf8");
} else if (!parsed.ok && !String(raw).replace(/^\uFEFF/, "").startsWith("---")) {
await fsp.writeFile(destMd, renderSkillDocument(id, id, raw), "utf8");
try {
await copyDir(srcDir, dest);
const destMd = path.join(dest, "SKILL.md");
if (!(await pathExists(destMd))) throw new Error("导入后缺少 SKILL.md");
if (parsed.ok && parsed.name !== id) {
await fsp.writeFile(destMd, mergeSkillDocument(id, parsed.description, raw), "utf8");
} else if (!parsed.ok && !String(raw).replace(/^\uFEFF/, "").startsWith("---")) {
await fsp.writeFile(destMd, renderSkillDocument(id, id, raw), "utf8");
}
return { id, path: destMd, backup, description: parsed.ok ? parsed.description : id };
} catch (err) {
await fsp.rm(dest, { recursive: true, force: true }).catch(() => {});
await restoreSkillFromBackup(dshHome, id, backup);
throw err;
}
return { id, path: destMd, backup, description: parsed.ok ? parsed.description : id };
}
async function installFlatFile(dshHome, srcFile, fallbackId) {
assertImportSourceOutsideSkills(dshHome, srcFile);
const raw = await fsp.readFile(srcFile, "utf8");
const parsed = parseSkillDocument(raw);
const id = parsed.ok ? parsed.name : kebabFromLabel(fallbackId || path.basename(srcFile, ".md"));
@@ -512,6 +563,7 @@ async function installFlatFile(dshHome, srcFile, fallbackId) {
}
async function installFoundSkills(dshHome, root, fallbackId) {
assertImportSourceOutsideSkills(dshHome, root);
const found = await findSkillRoots(root);
const imported = [];
for (const dir of found.dirs) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dsh-purge",
"version": "1.1.49-beta.1",
"version": "1.1.51",
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
"type": "module",
"main": "lib/index.js",
+32
View File
@@ -1,3 +1,35 @@
# 1.1.51
## 中文
- 版本升级到 1.1.51。
- 修复 `/skills import` 对 `$DSH_HOME/skills` 自身导入时先删后拷把技能删空(#54)。
- 补齐 `platformEnvAdaptStatus` / `platformEnvAdaptSkip`,发送门禁不再误报「环境还没配好」(#55)。
- 修复官方桌面:无版本/同版本 `installer.exe` 被当成待更新劫持重启;更新失败时恢复 `resources/app`;空 sha 的 applied stamp 不再跳过 reapply(#56,0.1.7/0.2 同路径)。
- 补丁 #52 兼容无 `.volatile()` 写法;#57 跟到 `useDeveloperRole` 并覆盖 responses 通路;#48 上游已删句按软完成;状态导出 `patches_ready`;桌面端 shim 显示「本端不需要」。
## English
- Version 1.1.51.
- Reject `/skills import` when source overlaps `$DSH_HOME/skills` so delete-then-copy cannot wipe skills (#54).
- Implement `platformEnvAdaptStatus` / `platformEnvAdaptSkip` so the send gate no longer false-blocks ready environments (#55).
- Official desktop: ignore unversioned/same-version `installer.exe` pending updates; restore `resources/app` if update handoff fails; empty applied stamp sha no longer skips reapply (#56, same path on 0.1.7 and 0.2).
- Patch #52 matches non-`.volatile()` defaults; #57 follows `useDeveloperRole` and covers responses; #48 soft-settles when upstream removed the caution text; export `patches_ready`; desktop shim shows not-needed-here.
# 1.1.50
## 中文
- 版本升级到 1.1.50。
- 修复 macOS 官方桌面:点「应用」假失败「失败: 正在重启。」、解包后 `dsh` CLI 失效、status 误标 ✗(#53)。
- 修复点「应用」重启后默认提示词不注入:未改过时自动落盘内置默认,不必先点保存。
## English
- Version 1.1.50.
- Fix macOS official desktop: Apply false "Failed: Restarting.", broken `dsh` CLI after asar unpack, and status ✗ false negatives (#53).
- Fix default prompt not injecting after Apply + restart; bundled default is written without requiring Save first.
# 1.1.49-beta.1
## 中文