mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 05:00:22 +08:00
fix: 发布 1.1.58,打开即挂上默认提示词
重启或重新打开后不用再点保存。磁盘正文优先,其次规则集,再没有就用内置默认。应用成功仍先询问是否重启。前端模块只在页面发出前改写,避免输入框消失。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
75637c48b9
commit
131ef12ecb
8 files changed
+158
-37
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.57</strong></p>
|
||||
<p align="center"><strong>Version 1.1.58</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>
|
||||
@@ -126,7 +126,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.57**. 1.1.45 is skipped; it has bugs.
|
||||
The plugin version is **1.1.58**. 1.1.45 is skipped; it has bugs.
|
||||
|
||||
---
|
||||
|
||||
@@ -190,13 +190,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>
|
||||
·
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.57&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.58&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.57&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.58&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>
|
||||
@@ -212,7 +212,7 @@ export function installDshPurgeToDesktop() {
|
||||
const params = new URLSearchParams({
|
||||
id: 'dsh-purge',
|
||||
name: 'dsh-purge',
|
||||
version: '1.1.57',
|
||||
version: '1.1.58',
|
||||
repo: 'YuJunZhiXue/dsh-purge',
|
||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||
@@ -231,7 +231,7 @@ export function installDshPurgeToDesktop() {
|
||||
**HTML link:**
|
||||
|
||||
```html
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.57&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.58&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>
|
||||
```
|
||||
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
|
||||
|---|---|---|
|
||||
| id | `dsh-purge` | Plugin id |
|
||||
| name | `dsh-purge` | Display name |
|
||||
| version | `1.1.57` | Semver |
|
||||
| version | `1.1.58` | 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
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 align="center">⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)</h1>
|
||||
|
||||
<p align="center"><strong>Version 1.1.57</strong></p>
|
||||
<p align="center"><strong>Version 1.1.58</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<em>本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
|
||||
@@ -126,7 +126,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
|
||||
| 官方 Harness 0.1.x | 不支持 |
|
||||
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
|
||||
|
||||
插件版本是 **1.1.57**。1.1.45 有问题,略过。
|
||||
插件版本是 **1.1.58**。1.1.45 有问题,略过。
|
||||
|
||||
---
|
||||
|
||||
@@ -190,13 +190,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>
|
||||
·
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.57&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.58&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.57&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.58&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>
|
||||
@@ -212,7 +212,7 @@ export function installDshPurgeToDesktop() {
|
||||
const params = new URLSearchParams({
|
||||
id: 'dsh-purge',
|
||||
name: 'dsh-purge',
|
||||
version: '1.1.57',
|
||||
version: '1.1.58',
|
||||
repo: 'YuJunZhiXue/dsh-purge',
|
||||
permissions: '系统提示词注入, 本机补丁, 设置页',
|
||||
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
|
||||
@@ -231,7 +231,7 @@ export function installDshPurgeToDesktop() {
|
||||
**HTML 静态链接方式:**
|
||||
|
||||
```html
|
||||
<a href="dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.57&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.58&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>
|
||||
```
|
||||
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
|
||||
|---|---|---|
|
||||
| id | `dsh-purge` | 插件唯一标识符 |
|
||||
| name | `dsh-purge` | 插件展示名称 |
|
||||
| version | `1.1.57` | 语义化版本号 |
|
||||
| version | `1.1.58` | 语义化版本号 |
|
||||
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
|
||||
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
|
||||
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
|
||||
|
||||
@@ -1527,16 +1527,13 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
|
||||
text: tr("restart.incomplete", { detail: parts.join(";") }),
|
||||
});
|
||||
loadAll();
|
||||
return;
|
||||
}
|
||||
if (action === "apply" && (d.restarting || d.restart_after_apply)) {
|
||||
loadAll();
|
||||
restartDsh(setNotice, function () {}, tr, hostSurfaceOf(state));
|
||||
setAskRestart(true);
|
||||
return;
|
||||
}
|
||||
if (action === "apply") {
|
||||
setNotice({ kind: "ok", text: tr("ok.done") });
|
||||
loadAll();
|
||||
setAskRestart(true);
|
||||
return;
|
||||
}
|
||||
setNotice({ kind: "ok", text: tr("ok.done") });
|
||||
|
||||
+86
-5
@@ -2098,10 +2098,11 @@ function quotedConst(name, body) {
|
||||
const COMPLETE_PROMPT_WATERFALL_INJECT =
|
||||
"\t\tconst transformed = await this.ctx.waterfall(scopeTarget(this, scope), \"system-prompt/assemble\", assembly, context, () => Promise.resolve(assembly));\n" +
|
||||
"\t\tconst dshPurgeSections = (transformed.sections || []).filter((s) => String(s && s.name || \"\").startsWith(\"dsh-purge\") && String(s.text || \"\").length > 0);\n" +
|
||||
"\t\tif (completeSection === void 0 && !runtimeContextSuppressed) return transformed;\n" +
|
||||
"\t\tconst dshPurgeRest = (transformed.sections || []).filter((s) => !String(s && s.name || \"\").startsWith(\"dsh-purge\"));\n" +
|
||||
"\t\tif (completeSection === void 0 && !runtimeContextSuppressed) return { ...transformed, sections: [...dshPurgeSections, ...dshPurgeRest] }; // [dsh-purge] every mode keeps system inject\n" +
|
||||
"\t\treturn {\n" +
|
||||
"\t\t\t...transformed,\n" +
|
||||
"\t\t\tsections: completeSection === void 0 ? transformed.sections : (function (complete, purge) {\n" +
|
||||
"\t\t\tsections: completeSection === void 0 ? [...dshPurgeSections, ...dshPurgeRest] : (function (complete, purge) {\n" +
|
||||
"\t\t\t\tconst base = { ...complete };\n" +
|
||||
"\t\t\t\treturn [...purge, base]; // [dsh-purge] complete prompt keeps waterfall inject\n" +
|
||||
"\t\t\t})(completeSection, dshPurgeSections),\n" +
|
||||
@@ -3334,6 +3335,21 @@ const NEW_TOOL_PATCHES = [
|
||||
"\t\t};",
|
||||
replace: COMPLETE_PROMPT_WATERFALL_INJECT,
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
"\t\tconst transformed = await this.ctx.waterfall(scopeTarget(this, scope), \"system-prompt/assemble\", assembly, context, () => Promise.resolve(assembly));\n" +
|
||||
"\t\tconst dshPurgeSections = (transformed.sections || []).filter((s) => String(s && s.name || \"\").startsWith(\"dsh-purge\") && String(s.text || \"\").length > 0);\n" +
|
||||
"\t\tif (completeSection === void 0 && !runtimeContextSuppressed) return transformed;\n" +
|
||||
"\t\treturn {\n" +
|
||||
"\t\t\t...transformed,\n" +
|
||||
"\t\t\tsections: completeSection === void 0 ? transformed.sections : (function (complete, purge) {\n" +
|
||||
"\t\t\t\tconst base = { ...complete };\n" +
|
||||
"\t\t\t\treturn [...purge, base]; // [dsh-purge] complete prompt keeps waterfall inject\n" +
|
||||
"\t\t\t})(completeSection, dshPurgeSections),\n" +
|
||||
"\t\t\tcontexts: runtimeContextSuppressed ? [] : transformed.contexts\n" +
|
||||
"\t\t};",
|
||||
replace: COMPLETE_PROMPT_WATERFALL_INJECT,
|
||||
},
|
||||
],
|
||||
forbid: ["dsh-purge:committed"],
|
||||
markers: ["complete prompt keeps waterfall inject"],
|
||||
@@ -3911,6 +3927,30 @@ const NEW_TOOL_PATCHES = [
|
||||
],
|
||||
markers: ["[dsh-purge] system prompt replaces the first node"],
|
||||
},
|
||||
{
|
||||
id: 74,
|
||||
name: "ASSEMBLE_BEFORE_PRESTEP",
|
||||
layer: "代码",
|
||||
layer_en: "Code",
|
||||
desc: "每个模式的第一次发送前先挂上默认提示词 / hang the default prompt before the first assemble",
|
||||
file: ["agent-loop"],
|
||||
skipIfMarked: true,
|
||||
replacements: [
|
||||
{
|
||||
pattern:
|
||||
"\t\tconst claimed = this.inbox.claim(target, position.turn);\n" +
|
||||
"\t\tconst assembly = await this.loopCtx.systemPrompt.assemble(assembleContextFor(this, signal));",
|
||||
replace:
|
||||
"\t\tconst claimed = this.inbox.claim(target, position.turn);\n" +
|
||||
"\t\tconst dshPurgePrepare = globalThis.__dshPurgePrepareAssemble;\n" +
|
||||
"\t\tif (typeof dshPurgePrepare === \"function\") {\n" +
|
||||
"\t\t\ttry { dshPurgePrepare(this.loopCtx); } catch { /* [dsh-purge] prepare assemble before this step */ }\n" +
|
||||
"\t\t}\n" +
|
||||
"\t\tconst assembly = await this.loopCtx.systemPrompt.assemble(assembleContextFor(this, signal));",
|
||||
},
|
||||
],
|
||||
markers: ["[dsh-purge] prepare assemble before this step"],
|
||||
},
|
||||
{
|
||||
id: 66,
|
||||
name: "SYSTEM_PROMPT_RENDER_GUARD",
|
||||
@@ -4179,6 +4219,47 @@ const NEW_TOOL_PATCHES = [
|
||||
// 锚点还在时也别再 replaceAll。这个文件是前端模块,重复写会改 mtime。
|
||||
skipIfMarked: true,
|
||||
replacements: [
|
||||
{
|
||||
// 上一版只藏 surface 序号。界面气泡和「用时」挂在回合事件上,序号对不上就还留在聊天里。
|
||||
pattern:
|
||||
"\t\t\t\thidden.add(event.seq);\n" +
|
||||
"\t\t\t\tif (Array.isArray(event.sourceEventSeqs)) {\n" +
|
||||
"\t\t\t\t\tfor (const seq of event.sourceEventSeqs) hidden.add(seq);\n" +
|
||||
"\t\t\t\t}\n",
|
||||
replace:
|
||||
"\t\t\t\thidden.add(event.seq); // [dsh-purge] rewind hides the cut turn\n" +
|
||||
"\t\t\t\tconst op = event.surfaceOp;\n" +
|
||||
"\t\t\t\tif (op && typeof op.startSeq === \"number\" && typeof op.endSeq === \"number\" && op.endSeq >= op.startSeq && op.endSeq - op.startSeq < 100000) {\n" +
|
||||
"\t\t\t\t\tfor (let seq = op.startSeq; seq <= op.endSeq; seq += 1) hidden.add(seq);\n" +
|
||||
"\t\t\t\t}\n" +
|
||||
"\t\t\t\tconst raw = event.sourceEventSeqs;\n" +
|
||||
"\t\t\t\tif (Array.isArray(raw)) {\n" +
|
||||
"\t\t\t\t\tfor (const row of raw) {\n" +
|
||||
"\t\t\t\t\t\tif (typeof row === \"number\") hidden.add(row);\n" +
|
||||
"\t\t\t\t\t\telse if (Array.isArray(row) && row.length === 2 && typeof row[0] === \"number\" && typeof row[1] === \"number\" && row[1] >= row[0] && row[1] - row[0] < 100000) {\n" +
|
||||
"\t\t\t\t\t\t\tfor (let seq = row[0]; seq <= row[1]; seq += 1) hidden.add(seq);\n" +
|
||||
"\t\t\t\t\t\t}\n" +
|
||||
"\t\t\t\t\t}\n" +
|
||||
"\t\t\t\t}\n" +
|
||||
"\t\t\t\tconst cutEnd = op && typeof op.endSeq === \"number\" ? op.endSeq : event.seq;\n" +
|
||||
"\t\t\t\tlet turnStart = null;\n" +
|
||||
"\t\t\t\tlet turnEnd = null;\n" +
|
||||
"\t\t\t\tfor (const row of list) {\n" +
|
||||
"\t\t\t\t\tconst ev = row && row.event;\n" +
|
||||
"\t\t\t\t\tif (!ev || ev.seq >= event.seq) continue;\n" +
|
||||
"\t\t\t\t\tif (ev.type === \"turn/start\") turnStart = ev.seq;\n" +
|
||||
"\t\t\t\t\tif (ev.type === \"turn/end\" && ev.seq >= cutEnd && turnEnd === null) turnEnd = ev.seq;\n" +
|
||||
"\t\t\t\t}\n" +
|
||||
"\t\t\t\tif (turnStart !== null) {\n" +
|
||||
"\t\t\t\t\tconst last = turnEnd === null ? event.seq : turnEnd;\n" +
|
||||
"\t\t\t\t\tfor (const row of list) {\n" +
|
||||
"\t\t\t\t\t\tconst ev = row && row.event;\n" +
|
||||
"\t\t\t\t\t\tif (!ev || ev.seq < turnStart || ev.seq > last) continue;\n" +
|
||||
"\t\t\t\t\t\tif (ev.type === \"system/message\") continue;\n" +
|
||||
"\t\t\t\t\t\thidden.add(ev.seq);\n" +
|
||||
"\t\t\t\t\t}\n" +
|
||||
"\t\t\t\t}\n",
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
"\t\tfunction rewindVisibleEntries(entries) {\n" +
|
||||
@@ -4247,7 +4328,7 @@ const NEW_TOOL_PATCHES = [
|
||||
"\t\t\t\tconst event = entry && entry.event;\n" +
|
||||
"\t\t\t\treturn !!event && !hidden.has(event.seq);\n" +
|
||||
"\t\t\t});\n" +
|
||||
"\t\t} // [dsh-purge] rewind hides only the cut range",
|
||||
"\t\t} // [dsh-purge] rewind hides the cut turn",
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
@@ -4312,7 +4393,7 @@ const NEW_TOOL_PATCHES = [
|
||||
"\t\t\t\tconst event = entry && entry.event;\n" +
|
||||
"\t\t\t\treturn !!event && !hidden.has(event.seq);\n" +
|
||||
"\t\t\t});\n" +
|
||||
"\t\t} // [dsh-purge] rewind hides only the cut range\n" +
|
||||
"\t\t} // [dsh-purge] rewind hides the cut turn\n" +
|
||||
"\t\tvar ConversationNodeAssembler = class {",
|
||||
},
|
||||
{
|
||||
@@ -4325,7 +4406,7 @@ const NEW_TOOL_PATCHES = [
|
||||
"\t\t\t\tthis.contexts.clear();",
|
||||
},
|
||||
],
|
||||
markers: ["[dsh-purge] rewind hides only the cut range"],
|
||||
markers: ["[dsh-purge] rewind hides the cut turn"],
|
||||
},
|
||||
{
|
||||
id: 57,
|
||||
|
||||
+32
-5
@@ -176,9 +176,13 @@ function injectAllowedNow(config) {
|
||||
return config.enabled !== false;
|
||||
}
|
||||
|
||||
/** 有默认提示词用默认,没有才用当前规则集。两边都空则段上不挂正文。 */
|
||||
/** 有磁盘提示词用磁盘,没有才用规则集,再没有就用内置默认。打开就能挂上。 */
|
||||
function refreshHungOperator(dshHome = core.findDshHome()) {
|
||||
const resolved = rules.resolveInjectText(dshHome);
|
||||
const home = dshHome || core.findDshHome();
|
||||
if (home) {
|
||||
try { core.seedOverrideSync(home); } catch { /* 默认写不进去时,组装仍会用内存里的内置正文 */ }
|
||||
}
|
||||
const resolved = rules.resolveInjectText(home);
|
||||
core.hangOperatorPrompt(resolved.text);
|
||||
return resolved;
|
||||
}
|
||||
@@ -192,7 +196,7 @@ function injectSnapshot(dshHome = core.findDshHome()) {
|
||||
};
|
||||
}
|
||||
|
||||
/** 框里有字用框;空框才看规则集;都没有则要求先写提示词。不看内置默认。 */
|
||||
/** 框里有字用框;空框才看规则集;都没有就用内置默认,不要求先点保存。 */
|
||||
function injectSnapshotFromBox(dshHome, boxText) {
|
||||
const ruleId = rules.activeRuleId(dshHome);
|
||||
if (typeof boxText === "string" && core.normalizeOverride(boxText)) {
|
||||
@@ -201,6 +205,9 @@ function injectSnapshotFromBox(dshHome, boxText) {
|
||||
if (core.normalizeOverride(rules.activeRuleText(dshHome))) {
|
||||
return { injectSource: "rule", injectRuleId: ruleId, needPrompt: false };
|
||||
}
|
||||
if (core.normalizeOverride(core.defaultOverrideText())) {
|
||||
return { injectSource: "default", injectRuleId: null, needPrompt: false };
|
||||
}
|
||||
if (typeof boxText !== "string") return injectSnapshot(dshHome);
|
||||
return { injectSource: "none", injectRuleId: ruleId, needPrompt: true };
|
||||
}
|
||||
@@ -435,6 +442,21 @@ function installIdentityOverride(ctx, config = {}) {
|
||||
return rewriteLiveAssembly(config, assembled, context);
|
||||
}, { global: true, prepend: true });
|
||||
}
|
||||
// 切换预设会换掉 assemble。pre-step 瀑布在 assemble 之后才跑,第一次发送包不上。
|
||||
// 宿主在 assemble 之前调用这个函数,用的就是当前模式自己的 systemPrompt。
|
||||
const prepareAssemble = (loopCtx) => {
|
||||
try { rules.ensureOperatorBody(core.findDshHome()); } catch { /* 主目录还没有提示词 */ }
|
||||
const prompt = loopCtx && loopCtx.systemPrompt;
|
||||
if (prompt) {
|
||||
try {
|
||||
installAssembleGuard(prompt, (assembled, context) => (
|
||||
rewriteLiveAssembly(config, assembled, context)
|
||||
));
|
||||
} catch { /* 这一层代理包不上时,下面再包插件自己的 */ }
|
||||
}
|
||||
wrapAssemble();
|
||||
};
|
||||
globalThis.__dshPurgePrepareAssemble = prepareAssemble;
|
||||
// complete:true 会在 waterfall 之后盖掉 sections;包住 assemble 返回值,每轮都补回注入。
|
||||
wrapAssemble();
|
||||
const started = Date.now();
|
||||
@@ -1017,7 +1039,10 @@ export function apply(ctx, config) {
|
||||
} catch (e) {
|
||||
console.warn("[dsh-purge] client bundle boot patch:", String(e && e.message ? e.message : e));
|
||||
}
|
||||
try { refreshHungOperator(core.findDshHome()); } catch { /* 主目录还没有提示词时段上留空 */ }
|
||||
try {
|
||||
const home = core.pinDshHome() || core.findDshHome();
|
||||
refreshHungOperator(home);
|
||||
} catch { /* 主目录还没有提示词时,组装会再挂内置默认 */ }
|
||||
try {
|
||||
const scrubbed = core.sanitizeDesktopCommandRuntimes();
|
||||
if (scrubbed.length) log(cfg, "desktop runtime scrub on load:", JSON.stringify(scrubbed));
|
||||
@@ -1568,7 +1593,9 @@ function installWebServer(ctx, cfg) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (incoming !== null) await core.saveOverrideContent(state.dsh_home, incoming);
|
||||
if (incoming !== null && core.normalizeOverride(incoming)) {
|
||||
await core.saveOverrideContent(state.dsh_home, incoming);
|
||||
}
|
||||
refreshHungOperator(state.dsh_home);
|
||||
await core.backupAll(state.ai_base);
|
||||
const report = await core.applyPatches(state.ai_base, core.ALL_PATCHES, { preserveClientBundles: true });
|
||||
|
||||
+7
-7
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
import {
|
||||
findDshHome,
|
||||
findOverrideFile,
|
||||
defaultOverrideText,
|
||||
hangOperatorPrompt,
|
||||
hungOperatorPrompt,
|
||||
normalizeOverride,
|
||||
@@ -195,27 +196,26 @@ function diskPrompt(dshHome) {
|
||||
return normalizeOverride(overrideFileText(dshHome));
|
||||
}
|
||||
|
||||
/** 磁盘上的提示词优先;没有则用当前规则集;两边都没有则不注入。不回落内置默认。 */
|
||||
/** 磁盘上的提示词优先;没有则用当前规则集;两边都没有就用内置默认。不需要先点保存。 */
|
||||
export function resolveInjectText(dshHome) {
|
||||
const prompt = diskPrompt(dshHome);
|
||||
if (prompt) return { text: prompt, source: "prompt", ruleId: null };
|
||||
const ruleId = activeRuleId(dshHome);
|
||||
const rule = normalizeOverride(activeRuleText(dshHome));
|
||||
if (rule) return { text: rule, source: "rule", ruleId };
|
||||
const bundled = normalizeOverride(defaultOverrideText());
|
||||
if (bundled) return { text: bundled, source: "default", ruleId: null };
|
||||
return { text: "", source: "none", ruleId };
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装时用。内存里已经挂过就用那一份;还没挂(没点保存、也没在本次启动里挂上)
|
||||
* 就从磁盘提示词或当前规则集补上。空内存不能挡住磁盘上已有的正文。
|
||||
* 磁盘和规则集都没有时保持空,不回落内置默认。
|
||||
* 每次组装都按当前主目录重读。重启后的空内存不能挡住磁盘或内置默认。
|
||||
* 磁盘和规则集都没有时挂内置默认,打开、应用、重启都不用再点保存。
|
||||
*/
|
||||
export function ensureOperatorBody(dshHome) {
|
||||
const hung = normalizeOverride(hungOperatorPrompt());
|
||||
if (hung) return hung;
|
||||
const resolved = resolveInjectText(dshHome);
|
||||
if (resolved.text) hangOperatorPrompt(resolved.text);
|
||||
return resolved.text || "";
|
||||
return resolved.text || normalizeOverride(hungOperatorPrompt()) || "";
|
||||
}
|
||||
|
||||
/** 官方和红队同一顺序。红队再去掉 CTF。没有正文时不注入操作者段。 */
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.57",
|
||||
"version": "1.1.58",
|
||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# 1.1.58
|
||||
|
||||
## 中文
|
||||
|
||||
- 版本升级到 1.1.58。
|
||||
- 打开、应用、重启都会挂上提示词。磁盘上有正文就用磁盘,没有就用规则集,再没有就用内置默认,不用再点保存。
|
||||
- 启动不再在页面发出之后改写前端 client.js,避免输入框因模块版本号对不上而消失(#63)。
|
||||
- macOS / Linux 已解包桌面端点应用后会退出并重新打开;清洗标记两种写法都认(#64)。
|
||||
|
||||
## English
|
||||
|
||||
- Version 1.1.58.
|
||||
- Open, Apply, and restart all hang the prompt. A saved file wins, then the active rule set, then the built-in default. Save is not required.
|
||||
- Startup no longer rewrites frontend client.js after the page has taken a module revision, so the composer does not disappear (#63).
|
||||
- Unpacked macOS and Linux desktop builds quit and relaunch after Apply. Both inject markers count as clean (#64).
|
||||
|
||||
# 1.1.57
|
||||
|
||||
## 中文
|
||||
|
||||
Reference in new issue
Block a user