mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 12:10:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cdf5596cd |
No files matched your search
@@ -6,6 +6,11 @@ npm-debug.log*
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
# 本地草稿,不进仓库
|
||||||
|
scripts/tmp-*.mjs
|
||||||
|
scripts/test-*.mjs
|
||||||
|
dsh-redteam-mode-main/
|
||||||
|
|
||||||
# 外部参考,不是本插件
|
# 外部参考,不是本插件
|
||||||
choirboy-prompt/
|
choirboy-prompt/
|
||||||
/choirboy-prompt/
|
/choirboy-prompt/
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
||||||
|
|
||||||
<p align="center"><strong>Version 1.1.54</strong></p>
|
<p align="center"><strong>Version 1.1.55</strong></p>
|
||||||
|
|
||||||
<p align="center">
|
<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>
|
<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 |
|
| Official Harness 0.1.x | Not supported |
|
||||||
| Any other version | Unmatched patches stay pending or skipped; do not expect them to work |
|
| Any other version | Unmatched patches stay pending or skipped; do not expect them to work |
|
||||||
|
|
||||||
The plugin version is **1.1.54**. 1.1.45 is skipped; it has bugs.
|
The plugin version is **1.1.55**. 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">
|
<p align="center">
|
||||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 Open Hub page</strong></a>
|
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 Open Hub page</strong></a>
|
||||||
·
|
·
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&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.55&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>
|
</p>
|
||||||
|
|
||||||
🔗 **Raw protocol URL:**
|
🔗 **Raw protocol URL:**
|
||||||
|
|
||||||
```
|
```
|
||||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&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.55&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>
|
<details>
|
||||||
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
id: 'dsh-purge',
|
id: 'dsh-purge',
|
||||||
name: 'dsh-purge',
|
name: 'dsh-purge',
|
||||||
version: '1.1.54',
|
version: '1.1.55',
|
||||||
repo: 'YuJunZhiXue/dsh-purge',
|
repo: 'YuJunZhiXue/dsh-purge',
|
||||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||||
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
**HTML link:**
|
**HTML link:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&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.55&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
|
🚀 Install in desktop client
|
||||||
</a>
|
</a>
|
||||||
```
|
```
|
||||||
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| id | `dsh-purge` | Plugin id |
|
| id | `dsh-purge` | Plugin id |
|
||||||
| name | `dsh-purge` | Display name |
|
| name | `dsh-purge` | Display name |
|
||||||
| version | `1.1.54` | Semver |
|
| version | `1.1.55` | Semver |
|
||||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
|
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
|
||||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
|
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
|
||||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
|
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
|
||||||
|
|||||||
+7
-7
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
||||||
|
|
||||||
<p align="center"><strong>Version 1.1.54</strong></p>
|
<p align="center"><strong>Version 1.1.55</strong></p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
||||||
@@ -118,7 +118,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
|||||||
| 官方 Harness 0.1.x | 不支持 |
|
| 官方 Harness 0.1.x | 不支持 |
|
||||||
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
|
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
|
||||||
|
|
||||||
插件版本是 **1.1.54**。1.1.45 有问题,略过。
|
插件版本是 **1.1.55**。1.1.45 有问题,略过。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -220,13 +220,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 打开插件市场页</strong></a>
|
<a href="https://deepseek.stream/plugins/dsh-purge"><strong>🌐 打开插件市场页</strong></a>
|
||||||
·
|
·
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&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.55&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>
|
</p>
|
||||||
|
|
||||||
🔗 **原生协议链接:**
|
🔗 **原生协议链接:**
|
||||||
|
|
||||||
```
|
```
|
||||||
dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&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.55&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>
|
<details>
|
||||||
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
id: 'dsh-purge',
|
id: 'dsh-purge',
|
||||||
name: 'dsh-purge',
|
name: 'dsh-purge',
|
||||||
version: '1.1.54',
|
version: '1.1.55',
|
||||||
repo: 'YuJunZhiXue/dsh-purge',
|
repo: 'YuJunZhiXue/dsh-purge',
|
||||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||||
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
**HTML 静态链接方式:**
|
**HTML 静态链接方式:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&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.55&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>
|
</a>
|
||||||
```
|
```
|
||||||
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| id | `dsh-purge` | 插件唯一标识符 |
|
| id | `dsh-purge` | 插件唯一标识符 |
|
||||||
| name | `dsh-purge` | 插件展示名称 |
|
| name | `dsh-purge` | 插件展示名称 |
|
||||||
| version | `1.1.54` | 语义化版本号 |
|
| version | `1.1.55` | 语义化版本号 |
|
||||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
||||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
||||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
|
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
|
||||||
|
|||||||
@@ -1429,9 +1429,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (ticket !== actionTicket.current) return;
|
if (ticket !== actionTicket.current) return;
|
||||||
const posted = action === "apply" ? applyContent : override;
|
if (responseNeedsPrompt(d)) {
|
||||||
const applyEmptyBlocked = action === "apply" && promptBoxEmpty(posted) && (!d || d.injectSource !== "rule");
|
|
||||||
if (responseNeedsPrompt(d) || applyEmptyBlocked) {
|
|
||||||
rejectNeedPrompt(tr);
|
rejectNeedPrompt(tr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1480,7 +1478,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
loadAll();
|
loadAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (action === "apply" && (d.restart_after_apply || d.restarting || d.unpacked_asar || d.needs_full_quit)) {
|
if (action === "apply" && (d.restart_after_apply || d.restarting)) {
|
||||||
setNotice({
|
setNotice({
|
||||||
kind: "ok",
|
kind: "ok",
|
||||||
text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("update.restarting"),
|
text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("update.restarting"),
|
||||||
@@ -1490,6 +1488,14 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
restartDsh(setNotice, setPatchBusy, tr, surf);
|
restartDsh(setNotice, setPatchBusy, tr, surf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (action === "apply" && (d.needs_full_quit || d.unpacked_asar)) {
|
||||||
|
setNotice({
|
||||||
|
kind: "ok",
|
||||||
|
text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("ok.done"),
|
||||||
|
});
|
||||||
|
loadAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
setNotice({ kind: "ok", text: tr("ok.done") });
|
setNotice({ kind: "ok", text: tr("ok.done") });
|
||||||
loadAll();
|
loadAll();
|
||||||
})
|
})
|
||||||
@@ -1501,18 +1507,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
|
|||||||
if (ticket === actionTicket.current) setPatchBusy(false);
|
if (ticket === actionTicket.current) setPatchBusy(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (action !== "apply") {
|
run();
|
||||||
run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bothInjectEmpty(overrideRef.current, defaultOverrideRef.current).then((empty) => {
|
|
||||||
if (ticket !== actionTicket.current) return;
|
|
||||||
if (empty) {
|
|
||||||
rejectNeedPrompt(tr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
run();
|
|
||||||
});
|
|
||||||
}, [loadAll, rejectNeedPrompt]);
|
}, [loadAll, rejectNeedPrompt]);
|
||||||
|
|
||||||
const saveOverride = useCallback(() => {
|
const saveOverride = useCallback(() => {
|
||||||
|
|||||||
+63
-32
@@ -20,6 +20,7 @@ import * as uninstaller from "./uninstall.js";
|
|||||||
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
|
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
|
||||||
import * as refusalRecover from "./refusal-recover.js";
|
import * as refusalRecover from "./refusal-recover.js";
|
||||||
import {
|
import {
|
||||||
|
applyShouldRestart,
|
||||||
isInactiveContextError,
|
isInactiveContextError,
|
||||||
settleDelayMs,
|
settleDelayMs,
|
||||||
settleMayReapply,
|
settleMayReapply,
|
||||||
@@ -203,9 +204,17 @@ function rejectIfNeedPrompt(dshHome, boxText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function ensureRestartReady() {
|
async function ensureRestartReady() {
|
||||||
const inject = rules.resolveInjectText(core.findDshHome());
|
const home = core.findDshHome();
|
||||||
|
try { core.seedOverrideSync(home); } catch { /* 仍可读内置默认 */ }
|
||||||
|
const inject = rules.resolveInjectText(home);
|
||||||
if (!inject.text) return { ok: false, error: "没有可注入的提示词,已取消重启" };
|
if (!inject.text) return { ok: false, error: "没有可注入的提示词,已取消重启" };
|
||||||
return core.ensureHostClean();
|
const clean = await core.ensureHostClean();
|
||||||
|
if (clean.ok) return clean;
|
||||||
|
// 密封 asar 读的是旧包,清洗写在解包目录;允许换包重启,注入靠 assemble 包装。
|
||||||
|
try {
|
||||||
|
if (core.desktopAsarStillSealed()) return { ok: true, pending: clean.pending || [] };
|
||||||
|
} catch { /* 非桌面 */ }
|
||||||
|
return clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerPromptSections(ctx, config, _injectFile) {
|
export function registerPromptSections(ctx, config, _injectFile) {
|
||||||
@@ -215,7 +224,7 @@ export function registerPromptSections(ctx, config, _injectFile) {
|
|||||||
interpolate: false,
|
interpolate: false,
|
||||||
text: (context) => {
|
text: (context) => {
|
||||||
if (!injectAllowedNow(config)) return "";
|
if (!injectAllowedNow(config)) return "";
|
||||||
return rules.resolveModeInject(core.findDshHome(), isRedteamSession(context));
|
return readInjectFallback(context);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -249,7 +258,9 @@ export function registerPromptSections(ctx, config, _injectFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readInjectFallback(context) {
|
function readInjectFallback(context) {
|
||||||
return rules.resolveModeInject(core.findDshHome(), isRedteamSession(context));
|
const home = core.findDshHome();
|
||||||
|
try { core.seedOverrideSync(home); } catch { /* 落盘失败仍试读默认 */ }
|
||||||
|
return rules.resolveModeInject(home, isRedteamSession(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
function installMnemonMessageStrip(ctx, config = {}) {
|
function installMnemonMessageStrip(ctx, config = {}) {
|
||||||
@@ -360,33 +371,46 @@ function installRewindDeriveFilter(ctx) {
|
|||||||
function installIdentityOverride(ctx, config = {}) {
|
function installIdentityOverride(ctx, config = {}) {
|
||||||
if (typeof ctx.on !== "function") return;
|
if (typeof ctx.on !== "function") return;
|
||||||
installSubagentRoleCapture(ctx);
|
installSubagentRoleCapture(ctx);
|
||||||
if (ctx.__dshPurgeAssembleHook) return;
|
|
||||||
ctx.__dshPurgeAssembleHook = true;
|
|
||||||
const hook = async (_assembly, context, next) => {
|
|
||||||
const assembled = typeof next === "function" ? await next() : _assembly;
|
|
||||||
return rewriteLiveAssembly(config, assembled, context);
|
|
||||||
};
|
|
||||||
// 只挂一次。不改 contexts,不改 pre-step 白名单,梁神 phase-1 和其它插件的消息原样保留。
|
|
||||||
ctx.on("system-prompt/assemble", hook, { global: true, prepend: true });
|
|
||||||
// 0.1.5 起 complete:true 在 waterfall 之后用调用前的快照盖掉 sections。
|
|
||||||
// 换宿主版本时文件补丁还没写上,或换插件版本时旧钩子把 dsh-purge 段删掉,注入都会丢。
|
|
||||||
// 包住 assemble 的返回值,按 prompt-inject.md 再补回。
|
|
||||||
const wrapAssemble = () => {
|
const wrapAssemble = () => {
|
||||||
const prompt = ctx.systemPrompt;
|
try {
|
||||||
if (!prompt || typeof prompt.assemble !== "function" || prompt.__dshPurgeAssembleWrapped) return false;
|
const prompt = ctx.systemPrompt;
|
||||||
const orig = prompt.assemble;
|
if (!prompt || typeof prompt.assemble !== "function") return false;
|
||||||
prompt.assemble = async function (...args) {
|
if (prompt.assemble._dshPurgeWrapped) return true;
|
||||||
const assembled = await orig.apply(this, args);
|
const orig = prompt.assemble.bind(prompt);
|
||||||
return rewriteLiveAssembly(config, assembled, args[0]);
|
const wrapped = async function assembleWithPurge(...args) {
|
||||||
};
|
const assembled = await orig(...args);
|
||||||
prompt.__dshPurgeAssembleWrapped = true;
|
return rewriteLiveAssembly(config, assembled, args[0]);
|
||||||
return true;
|
};
|
||||||
|
wrapped._dshPurgeWrapped = true;
|
||||||
|
prompt.assemble = wrapped;
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (!wrapAssemble()) {
|
if (!ctx.__dshPurgeAssembleHook) {
|
||||||
queueMicrotask(wrapAssemble);
|
ctx.__dshPurgeAssembleHook = true;
|
||||||
setTimeout(wrapAssemble, 500);
|
ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
|
||||||
setTimeout(wrapAssemble, 2000);
|
const assembled = typeof next === "function" ? await next() : _assembly;
|
||||||
|
return rewriteLiveAssembly(config, assembled, context);
|
||||||
|
}, { global: true, prepend: true });
|
||||||
}
|
}
|
||||||
|
// complete:true 会在 waterfall 之后盖掉 sections;包住 assemble 返回值,每轮都补回注入。
|
||||||
|
wrapAssemble();
|
||||||
|
const started = Date.now();
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
wrapAssemble();
|
||||||
|
if (Date.now() - started > 20000) clearInterval(timer);
|
||||||
|
}, 400);
|
||||||
|
if (typeof timer.unref === "function") timer.unref();
|
||||||
|
try { ctx.effect(() => () => clearInterval(timer)); } catch { /* 无 effect 时靠 unref */ }
|
||||||
|
try { ctx.on("session/created", wrapAssemble); } catch { /* ignore */ }
|
||||||
|
try {
|
||||||
|
ctx.on("agent/pre-step", (payload, next) => {
|
||||||
|
wrapAssemble();
|
||||||
|
return typeof next === "function" ? next() : payload;
|
||||||
|
}, { global: true, prepend: true });
|
||||||
|
} catch { /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
function shimNeedsPatch(state) {
|
function shimNeedsPatch(state) {
|
||||||
@@ -1503,7 +1527,13 @@ function installWebServer(ctx, cfg) {
|
|||||||
const leaveTray = renamed || pendingQuit;
|
const leaveTray = renamed || pendingQuit;
|
||||||
if (complete) reapply.markPatchesApplied();
|
if (complete) reapply.markPatchesApplied();
|
||||||
if (leaveTray) bootFullQuit = true;
|
if (leaveTray) bootFullQuit = true;
|
||||||
const shouldRestart = complete;
|
const sealedNow = core.desktopAsarStillSealed();
|
||||||
|
const shouldRestart = applyShouldRestart({
|
||||||
|
complete,
|
||||||
|
sealed: sealedNow,
|
||||||
|
appliedCount: summary.applied,
|
||||||
|
});
|
||||||
|
if (shouldRestart) reapply.markSettleRestart();
|
||||||
sendJson(response, 200, {
|
sendJson(response, 200, {
|
||||||
ok: true,
|
ok: true,
|
||||||
complete,
|
complete,
|
||||||
@@ -1511,8 +1541,8 @@ function installWebServer(ctx, cfg) {
|
|||||||
restart_after_apply: shouldRestart,
|
restart_after_apply: shouldRestart,
|
||||||
unpacked_asar: leaveTray,
|
unpacked_asar: leaveTray,
|
||||||
needs_full_quit: leaveTray,
|
needs_full_quit: leaveTray,
|
||||||
asar_still_sealed: core.desktopAsarStillSealed(),
|
asar_still_sealed: sealedNow,
|
||||||
asar_swap_started: Boolean(shouldRestart && handoff && core.desktopAsarStillSealed()),
|
asar_swap_started: Boolean(shouldRestart && handoff && sealedNow),
|
||||||
applied: summary.applied,
|
applied: summary.applied,
|
||||||
already: summary.already,
|
already: summary.already,
|
||||||
failed: summary.failed.length,
|
failed: summary.failed.length,
|
||||||
@@ -1532,7 +1562,7 @@ function installWebServer(ctx, cfg) {
|
|||||||
cli_repair: cliRepair,
|
cli_repair: cliRepair,
|
||||||
cmd_flash: flash,
|
cmd_flash: flash,
|
||||||
});
|
});
|
||||||
if (shouldRestart && handoff && core.desktopAsarStillSealed()) {
|
if (shouldRestart && handoff && sealedNow) {
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
try {
|
try {
|
||||||
core.restartSealedDesktopIfNeeded();
|
core.restartSealedDesktopIfNeeded();
|
||||||
@@ -1606,6 +1636,7 @@ function installWebServer(ctx, cfg) {
|
|||||||
if (request.method === "GET") {
|
if (request.method === "GET") {
|
||||||
try {
|
try {
|
||||||
const home = core.findDshHome();
|
const home = core.findDshHome();
|
||||||
|
try { core.seedOverrideSync(home); } catch { /* 仍可读内置默认 */ }
|
||||||
const ui = await core.readOverrideForUi(home);
|
const ui = await core.readOverrideForUi(home);
|
||||||
sendJson(response, 200, { ok: true, ...ui, ...injectSnapshot(home) });
|
sendJson(response, 200, { ok: true, ...ui, ...injectSnapshot(home) });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -41,3 +41,17 @@ export function settleMayReapply({ surface, sealed = false } = {}) {
|
|||||||
if (surface === "desktop" && sealed) return false;
|
if (surface === "desktop" && sealed) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点「应用」后是否重启:密封 asar 还要换包就重启;否则只在这次真的写了宿主补丁时重启。
|
||||||
|
* 冷却不放在这里——否则第一次重启没换掉 asar,第二次应用会被当成取消。
|
||||||
|
*/
|
||||||
|
export function applyShouldRestart({
|
||||||
|
complete = false,
|
||||||
|
sealed = false,
|
||||||
|
appliedCount = 0,
|
||||||
|
} = {}) {
|
||||||
|
if (!complete) return false;
|
||||||
|
if (sealed) return true;
|
||||||
|
return Number(appliedCount) > 0;
|
||||||
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dsh-purge",
|
"name": "dsh-purge",
|
||||||
"version": "1.1.54",
|
"version": "1.1.55",
|
||||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
# 1.1.55
|
||||||
|
|
||||||
|
## 中文
|
||||||
|
|
||||||
|
- 版本升级到 1.1.55。
|
||||||
|
- 点「应用」并重启后,每一轮 assemble 都会把提示词补回最前;宿主换成新 assemble 也会再包一次,不会第二轮丢掉。
|
||||||
|
- 空框不再在前端误取消应用;重启前先落下默认提示词。密封 asar 不会因为当前进程还是旧包而取消重启。
|
||||||
|
- 第二次应用不会因为冷却把重启/注入当成取消;密封包在换掉之前每次应用都会重启一次,补丁写完后不再空转。
|
||||||
|
|
||||||
|
## English
|
||||||
|
|
||||||
|
- Version 1.1.55.
|
||||||
|
- After Apply + restart, every assemble turn puts the operator prompt back at the front. If the host replaces assemble, it is wrapped again so turn 2 does not drop the inject.
|
||||||
|
- An empty settings box no longer cancels Apply on the client; Restart seeds the default prompt first. A sealed asar no longer cancels restart just because the running process still has the old archive.
|
||||||
|
- A second Apply is not treated as a cancel because of settle cooldown. A sealed archive still restarts on each Apply until swapped; after patches are in, it does not loop.
|
||||||
|
|
||||||
# 1.1.54
|
# 1.1.54
|
||||||
|
|
||||||
## 中文
|
## 中文
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
import assert from "node:assert/strict";
|
|
||||||
import fs from "node:fs";
|
|
||||||
import os from "node:os";
|
|
||||||
import path from "node:path";
|
|
||||||
|
|
||||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-purge-stamp-"));
|
|
||||||
process.env.DSH_HOME = tmp;
|
|
||||||
|
|
||||||
const {
|
|
||||||
stampMatches,
|
|
||||||
resolveApplySha,
|
|
||||||
markPatchesApplied,
|
|
||||||
readAppliedStamp,
|
|
||||||
healEmptyAppliedStamp,
|
|
||||||
ensureInstalledRevSeed,
|
|
||||||
shouldSkipSettleRestart,
|
|
||||||
markSettleRestart,
|
|
||||||
canHealEmptyStamp,
|
|
||||||
} = await import("../lib/reapply.js");
|
|
||||||
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "" }, "1.1.52", "abc"), false);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "abc"), true);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", ""), true);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "apply:1.1.52" }, "1.1.52", "deadbeef"), true);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "def"), false);
|
|
||||||
assert.equal(stampMatches({ version: "1.1.51", sha: "abc" }, "1.1.52", "abc"), false);
|
|
||||||
|
|
||||||
// #56:空 sha 仍不能当对齐;#57:密封/缺标记不能就地补戳。
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: true, hasAiBase: true, markersPresent: true }), false);
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: false }), false);
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: true }), true);
|
|
||||||
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: false, markersPresent: false }), true);
|
|
||||||
|
|
||||||
assert.equal(resolveApplySha("deadbeef"), "deadbeef");
|
|
||||||
assert.match(resolveApplySha(""), /^(apply:|applied)/);
|
|
||||||
|
|
||||||
const sha = markPatchesApplied();
|
|
||||||
assert.ok(sha);
|
|
||||||
assert.ok(sha.length > 0);
|
|
||||||
const stamp = readAppliedStamp();
|
|
||||||
assert.equal(stamp.sha, sha);
|
|
||||||
assert.ok(stamp.sha);
|
|
||||||
const revFile = path.join(tmp, "dsh-purge", "installed-rev");
|
|
||||||
assert.equal(fs.readFileSync(revFile, "utf8").trim(), sha);
|
|
||||||
assert.equal(stampMatches(stamp, stamp.version, sha), true);
|
|
||||||
|
|
||||||
fs.writeFileSync(path.join(tmp, "dsh-purge", "applied.json"), `${JSON.stringify({
|
|
||||||
version: stamp.version,
|
|
||||||
sha: "",
|
|
||||||
at: new Date().toISOString(),
|
|
||||||
}, null, 2)}\n`);
|
|
||||||
assert.equal(healEmptyAppliedStamp(), true);
|
|
||||||
assert.ok(readAppliedStamp().sha);
|
|
||||||
|
|
||||||
// #60:缺 installed-rev 时种子
|
|
||||||
fs.rmSync(path.join(tmp, "dsh-purge", "installed-rev"), { force: true });
|
|
||||||
const seeded = ensureInstalledRevSeed();
|
|
||||||
assert.ok(seeded);
|
|
||||||
assert.equal(fs.readFileSync(path.join(tmp, "dsh-purge", "installed-rev"), "utf8").trim(), seeded);
|
|
||||||
|
|
||||||
assert.equal(shouldSkipSettleRestart(), false);
|
|
||||||
markSettleRestart();
|
|
||||||
assert.equal(shouldSkipSettleRestart(), true);
|
|
||||||
|
|
||||||
console.log("ok: reapply stamp / infinite-restart guards");
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
import assert from "node:assert/strict";
|
|
||||||
import {
|
|
||||||
DESKTOP_SETTLE_DELAY_MS,
|
|
||||||
isInactiveContextError,
|
|
||||||
settleDelayMs,
|
|
||||||
settleMayReapply,
|
|
||||||
settleMayRestart,
|
|
||||||
watchContextLife,
|
|
||||||
} from "../lib/settle-policy.js";
|
|
||||||
|
|
||||||
assert.equal(settleMayRestart({ surface: "desktop", sealed: false }), false);
|
|
||||||
assert.equal(settleMayRestart({ surface: "desktop", sealed: true }), false);
|
|
||||||
assert.equal(settleMayRestart({ surface: "web", sealed: true }), false);
|
|
||||||
assert.equal(settleMayRestart({ surface: "web", sealed: false }), true);
|
|
||||||
|
|
||||||
assert.equal(settleMayReapply({ surface: "desktop", sealed: true }), false);
|
|
||||||
assert.equal(settleMayReapply({ surface: "desktop", sealed: false }), true);
|
|
||||||
assert.equal(settleMayReapply({ surface: "web", sealed: false }), true);
|
|
||||||
|
|
||||||
assert.equal(settleDelayMs("desktop"), DESKTOP_SETTLE_DELAY_MS);
|
|
||||||
assert.equal(settleDelayMs("web"), 0);
|
|
||||||
assert.ok(DESKTOP_SETTLE_DELAY_MS >= 3000);
|
|
||||||
|
|
||||||
assert.equal(isInactiveContextError({ code: "INACTIVE_EFFECT" }), true);
|
|
||||||
assert.equal(isInactiveContextError(new Error("cannot create effect on inactive context")), true);
|
|
||||||
assert.equal(isInactiveContextError(new Error("ENOENT")), false);
|
|
||||||
|
|
||||||
const missing = watchContextLife(null);
|
|
||||||
assert.equal(missing.alive, true);
|
|
||||||
|
|
||||||
let disposed = null;
|
|
||||||
const active = watchContextLife({
|
|
||||||
effect(factory) {
|
|
||||||
disposed = factory();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
assert.equal(active.alive, true);
|
|
||||||
disposed();
|
|
||||||
assert.equal(active.alive, false);
|
|
||||||
|
|
||||||
const inactive = watchContextLife({
|
|
||||||
effect() {
|
|
||||||
const err = new Error("cannot create effect on inactive context");
|
|
||||||
err.code = "INACTIVE_EFFECT";
|
|
||||||
throw err;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
assert.equal(inactive.alive, false);
|
|
||||||
|
|
||||||
console.log("ok: settle policy / inactive-context guards");
|
|
||||||
Reference in new issue
Block a user