From c743a64d13d3c50f239c80c70e2e5eb9cd3849ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AB=E6=88=91=E5=B0=8F=E6=9D=A8=E5=90=8C=E5=AD=A6?= <188421097+HunYiSage@users.noreply.github.com> Date: Mon, 21 Sep 2026 10:34:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.1.11=20=E7=B3=BB=E7=BB=9F=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=8D=E5=8F=AA=E6=B3=A8=E5=85=A5=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E7=BB=AD=E4=B8=8D=E5=86=8D=E6=AF=8F=E6=AD=A5?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- README.md | 18 ++++++++++-------- README.zh-CN.md | 16 +++++++++------- lib/core.js | 2 ++ lib/identity.js | 42 ++++++++++++++++++++++++++++++++++++++---- lib/index.js | 3 ++- 5 files changed, 61 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c6d58cb..b978aeb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)

-

Version 1.1.10

+

Version 1.1.11

Local official DeepSeek Harness cybersecurity red-team plugin: evaluate and harden host safety policy in a controlled local install; swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐ @@ -244,13 +244,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv

🌐 Open Hub page  ·  - 🚀 Install in desktop client + 🚀 Install in desktop client

🔗 **Raw protocol URL:** ``` -dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.10&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.11&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 ``` **Web trigger example:** @@ -263,7 +263,7 @@ export function installDshPurgeToDesktop() { const params = new URLSearchParams({ id: 'dsh-purge', name: 'dsh-purge', - version: '1.1.10', + version: '1.1.11', repo: 'YuJunZhiXue/dsh-purge', permissions: '系统提示词注入, 本机补丁, 设置页', downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz', @@ -282,7 +282,7 @@ export function installDshPurgeToDesktop() { **HTML link:** ```html - + 🚀 Install in desktop client ``` @@ -293,7 +293,7 @@ export function installDshPurgeToDesktop() { |---|---|---| | id | `dsh-purge` | Plugin id | | name | `dsh-purge` | Display name | -| version | `1.1.10` | Semver | +| version | `1.1.11` | 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 | @@ -747,8 +747,10 @@ If nothing is found, set `DSH_BASE` / `DSH_DESKTOP_INSTALL`. No files are change ### 1.1.11 -- Settings splits Stable / Beta into two columns so you can switch and roll back; 1.1.10 can reach this by Check update -- Skill import is not in this release (it stays on the beta channel) +- Settings splits Stable / Beta into two columns, each with its own list, switch, and rollback. 1.1.10 can reach this by Check update. +- **No Skill import.** Skill stays on beta 1.1.12. +- **Inject the system prompt once per conversation.** The first turn writes the full `prompt-inject`; later steps pin that committed prompt and do not fold it again. +- **Stop a new「系统提示词」card on every step.** With 0.1.5 in-history, a changed assemble appends another `system/message`, so the transcript repeats system prompt → think → tools. Refolding inject every step made later official sections look like a new prompt; emptying inject did the same. After the inject is already in history, this release pins that committed system prompt and does not append a second copy. ### 1.1.10 diff --git a/README.zh-CN.md b/README.zh-CN.md index b24fce7..65e4ebd 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -4,7 +4,7 @@

⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)

-

Version 1.1.10

+

Version 1.1.11

本机官方 DeepSeek Harness 网络安全红队评测插件:在受控本机环境评测并加固宿主安全策略,不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐ @@ -241,13 +241,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv

🌐 打开插件市场页  ·  - 🚀 唤起客户端一键安装 + 🚀 唤起客户端一键安装

🔗 **原生协议链接:** ``` -dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.10&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.11&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 ``` **网页端(前端)触发代码示例:** @@ -279,7 +279,7 @@ export function installDshPurgeToDesktop() { **HTML 静态链接方式:** ```html - + 🚀 唤起客户端一键安装 ``` @@ -290,7 +290,7 @@ export function installDshPurgeToDesktop() { |---|---|---| | id | `dsh-purge` | 插件唯一标识符 | | name | `dsh-purge` | 插件展示名称 | -| version | `1.1.10` | 语义化版本号 | +| version | `1.1.11` | 语义化版本号 | | repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 | | permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 | | downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 | @@ -734,8 +734,10 @@ prompt-inject.md 有内容? ──是──> 原样写入 dsh-purge systemPrompt ### 1.1.11 -- 设置页正式版 / 测试版左右分栏,可切换并回退;1.1.10 点检测更新即可升到此版本 -- 不含 Skill 导入(该能力仍在测试通道) +- 设置页把正式版和测试版左右分开,各自选版本、各自切换和回退。还在 1.1.10 的点「检测更新」就能升到这一版。 +- **没有 Skill 导入。** Skill 只在测试版 1.1.12。 +- **系统提示词每个会话只注入一次。** 第一轮把 `prompt-inject` 完整写进系统提示;之后钉住已经提交的那一份,不再每步重折。 +- **修了聊天里每步都冒出「系统提示词」。** 0.1.5 in-history 只要本步组装结果和上一条不一样,就会再追加一条 `system/message`,时间线就会「思考 → 工具 → 系统提示词」循环。以前每步都把注入重新折进 persona,官方后半段稍有变化就会追加;把注入掏空也不行,渲染少了同样会被当成变化再追加。这一版历史里已经有完整注入后,就钉住那条已提交的系统提示,后续步骤不再追加第二份。 ### 1.1.10 diff --git a/lib/core.js b/lib/core.js index 1bbf350..6f1720c 100644 --- a/lib/core.js +++ b/lib/core.js @@ -2976,6 +2976,8 @@ const NEW_TOOL_PATCHES = [ "\t\t\t...transformed,\n" + "\t\t\tsections: completeSection === void 0 ? transformed.sections : (function (complete, assembled) {\n" + "\t\t\t\tconst sections = assembled.sections || [];\n" + + "\t\t\t\tconst committed = sections.find((s) => s && s.name === \"dsh-purge:committed\");\n" + + "\t\t\t\tif (committed && String(committed.text || \"\").trim()) return [{ ...complete, name: complete.name, text: committed.text }];\n" + "\t\t\t\tconst inject = sections.filter((s) => String(s && s.name || \"\").startsWith(\"dsh-purge\")).map((s) => String(s.text || \"\")).filter((t) => t.length > 0).join(\"\\n\\n\");\n" + "\t\t\t\tconst folded = sections.find((s) => s && s.name === complete.name);\n" + "\t\t\t\tconst base = folded && typeof folded.text === \"string\" ? { ...complete, text: folded.text } : { ...complete };\n" + diff --git a/lib/identity.js b/lib/identity.js index c7ed2d6..81fae39 100644 --- a/lib/identity.js +++ b/lib/identity.js @@ -175,10 +175,26 @@ export function promptAlreadyInjected(existing, injectText) { return String(existing || "").includes(inject); } -export function shouldInjectPrompt(_context, _injectOnce = true, _injectText = "") { - // 0.1.5 in-history:渲染少了注入就会再追加一条 system/message。 - // 用「最后一条是否含注入」决定本步掏空注入,会 A/B 死循环。每步都必须留下完整注入。 - return true; +export function lastInjectedSystemPrompt(context, injectText) { + const inject = String(injectText || "").trim(); + if (!inject) return ""; + const events = eventList(context?.agent?.session || context?.session); + let last = ""; + for (const event of events) { + if (event?.type !== "system/message") continue; + const text = messageText(event.data?.message || event.data).trim(); + if (text && promptAlreadyInjected(text, inject)) last = text; + } + return last; +} + +export function shouldInjectPrompt(context, _injectOnce = true, injectText = "") { + const inject = String(injectText || "").trim(); + if (!inject) return false; + // 历史里已经有完整注入就不要再折一份。0.1.5 in-history 只要渲染结果和上一条 + // system/message 不同就会再追加,聊天里就会每步都冒出「系统提示词」。 + // 掏空注入也不行:渲染少了注入同样会被当成变化再追加,形成 A/B。 + return !lastInjectedSystemPrompt(context, inject); } export function isMnemonPluginMessage(message) { @@ -198,15 +214,26 @@ function normalizeRewriteOptions(fallbackInject, options) { fallbackInject: typeof fallbackInject.fallbackInject === "string" ? fallbackInject.fallbackInject : "", dropMnemon: fallbackInject.dropMnemon !== false, dropPurgeAfterFold: fallbackInject.dropPurgeAfterFold !== false, + context: fallbackInject.context, }; } return { fallbackInject: typeof fallbackInject === "string" ? fallbackInject : "", dropMnemon: options?.dropMnemon !== false, dropPurgeAfterFold: options?.dropPurgeAfterFold !== false, + context: options?.context, }; } +function pinCommittedSystemPrompt(sections, committed) { + const names = sections.map((section) => String(section?.name || "")); + const hasPrefix = names.some((name) => PERSONA_PREFIX_NAMES.has(name)); + const target = hasPrefix + ? names.find((name) => PERSONA_PREFIX_NAMES.has(name)) + : names.find((name) => PERSONA_LEGACY_NAMES.has(name)); + return [{ name: target || "dsh-purge:committed", text: committed }]; +} + // 0.1.5 优先写入 persona-prefix;无 prefix 时写入 legacy persona。 function foldInjectIntoPersona(sections, injectText) { const inject = typeof injectText === "string" ? injectText : ""; @@ -250,6 +277,13 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options = } const injectText = collectInjectText(purge, opts.fallbackInject); + if (!shouldInjectPrompt(opts.context, true, injectText)) { + const committed = lastInjectedSystemPrompt(opts.context, injectText); + if (committed) { + assembled.sections = pinCommittedSystemPrompt([...rest, ...purge], committed); + return assembled; + } + } const folded = foldInjectIntoPersona(rest, injectText); const extras = opts.dropPurgeAfterFold ? purge.filter((section) => section.name !== "dsh-purge") diff --git a/lib/index.js b/lib/index.js index ef760d8..48c6d7c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -222,7 +222,7 @@ function installIdentityOverride(ctx, config = {}) { if (typeof ctx.on !== "function") return; if (ctx.__dshPurgeAssembleHook) return; ctx.__dshPurgeAssembleHook = true; - const hook = async (_assembly, _context, next) => { + const hook = async (_assembly, context, next) => { const assembled = typeof next === "function" ? await next() : _assembly; const enabled = config.enabled !== false; const inject = enabled ? readInjectFallback() : ""; @@ -230,6 +230,7 @@ function installIdentityOverride(ctx, config = {}) { fallbackInject: inject, dropMnemon: config.stripMnemon !== false, dropPurgeAfterFold: true, + context, }); }; // 只挂一次:挂多次会让同一轮 assemble 折两遍,UI 也会显示两次注入。