From 278eabbc076c51a3c0d25f30664246cd309b229a Mon Sep 17 00:00:00 2001 From: Musan-34 <279201993+Musan-34@users.noreply.github.com> Date: Wed, 23 Sep 2026 13:04:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#22=20=E8=B6=85=E6=97=B6=E8=A1=A5?= =?UTF-8?q?=E4=B8=81=E9=9D=9E=E5=B9=82=E7=AD=89=20+=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=AD=A3=E5=88=99=20pattern=20+=20=E8=A1=A5=20bundle=20persona?= =?UTF-8?q?=20marker=20(#31)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ① #22 BASH_TIMEOUT_RAISED 非幂等:pattern 以 `timeoutMs: 60000` 结尾,替换产物 `600000` 仍包含它,markers 子串判断恒真 → autoApplyOnStart 每次启动再补一个 0。 实测宿主已涨到 600000000000000(n 次开机 = 60s × 10ⁿ)。 改为锚定 bash-sandbox 行内、`[^\n]*` 吃到行尾的正则,产物收敛不动。 ② applyReplacementsToText 支持正则 pattern;并修掉 `out.replace(re, () => …)` 回调形态导致 `$1` 不展开(会把字面量 `$1` 写进宿主文件)的问题。 补 matchesPattern() 供 patchHasRemainingWork 复用,避免带正则的补丁反复写盘。 ③ #4 / #26 markers 补 bundle 布局:web-app / headless 的 persona 挂在 `persona:` 键上,清掉后是 `persona: ""`,现有 markers 命中不了 → 已完成的清洗在面板上永远报"待应用"。 ④ client.js 跳过态文案:0.1.5 里 #39 这类未应用的真实原因是"本版不需要", 原文案"没装或官方已改写"会误导。 连跑两遍 applyPatches → 0 files written(不动点);42 项 CLOSED 35 / N-A 5 / UNTOUCHED 2,non-optional unresolved 为空。 --- client.js | 4 ++-- lib/core.js | 52 ++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/client.js b/client.js index 1c6cf2e..f6ce2f3 100644 --- a/client.js +++ b/client.js @@ -153,7 +153,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => { "status.applied": "已应用", "status.pending": "待应用", "status.skipped": "跳过", - "apply.hint": "待应用=原文还在。跳过=没装或官方已改写,再点也不会变。", + "apply.hint": "待应用=原文还在。跳过=当前版本不需要或组件未安装,再点也不会变。", "warn.noRoot": "未定位到当前宿主的 @deepseek-ai,清洗不会生效。请完全退出后再打开本宿主,在本页点「应用」。桌面端安装目录可以是任意盘符,不要用官方 dsh 去清桌面端。", "warn.noRoot.desktop": "未定位到当前桌面应用里的 @deepseek-ai。请退出托盘后重新打开 DSH Desktop.exe,再在桌面端设置页点「应用」。安装目录不限盘符。", "warn.noInject": "提示词优先;为空则注入当前启用的规则集。两边都空会提示必须添加。Skill 不顶替提示词。", @@ -363,7 +363,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => { "status.applied": "Applied", "status.pending": "Pending", "status.skipped": "Skipped", - "apply.hint": "Pending = original text still present. Skipped = missing or already rewritten.", + "apply.hint": "Pending = original text still present. Skipped = not needed for this version or component not installed.", "warn.noRoot": "Could not find this host’s @deepseek-ai tree, so Apply will not patch anything. Fully quit and reopen this host, then Apply here. Desktop may live on any drive; do not use official dsh to purge Desktop.", "warn.noRoot.desktop": "Could not find @deepseek-ai inside this desktop app. Quit the tray, reopen DSH Desktop.exe, then Apply on the desktop Settings page. The install folder can be on any drive.", "warn.noInject": "The prompt box wins. If it is empty, the enabled rule set is injected. If both are empty you will be asked to add a prompt. Skills do not replace the prompt.", diff --git a/lib/core.js b/lib/core.js index 79bd548..bf22fd6 100644 --- a/lib/core.js +++ b/lib/core.js @@ -1744,6 +1744,11 @@ const PATCHES = [ 'personaPrefix: ""', 'prefix: ""', 'text: ""', + // bundle 布局 (0.1.5):web-app / headless 的 persona 是 `persona:` 键, + // 上面三条都命中不了,会让已完成的清洗在 UI 上报待应用。见下方 markersAny。 + 'persona: ""', + // 1.3.x cordis preset:身份段删除后留下的 purge 注记同样是完成态。 + '[dsh-purge] identity stripped', ], }, { @@ -2237,21 +2242,16 @@ const NEW_TOOL_PATCHES = [ rel: ["cordis.patch.yml"], replacements: [ { - pattern: - ' - id: bash-sandbox\n' + - " name: '@deepseek-ai/dsh-bash-sandbox'\n" + - " disabled: !!js process.platform === 'win32'\n" + - ' config:\n' + - ' timeoutMs: 60000', - replace: - ' - id: bash-sandbox\n' + - " name: '@deepseek-ai/dsh-bash-sandbox'\n" + - " disabled: !!js process.platform === 'win32'\n" + - ' config:\n' + - ' timeoutMs: 600000', + // 幂等性:原 pattern 以 `timeoutMs: 60000` 结尾,替换产物 `600000` 仍然 + // 包含它,于是每次 autoApplyOnStart 都会再拼一个 0(实测已涨到 + // 600000000000000)。 + // 现在的做法:锚在 bash-sandbox 行内,`[^\n]*` 必须吃到行尾 —— 这样上一次 + // 追加的注记会被整体重写而不是再叠一层,数值也不再有可再匹配的"前缀"。 + pattern: /(name: '@deepseek-ai\/dsh-bash-sandbox'[\s\S]*?\n {8}timeoutMs: )6[0-9]+[^\n]*/g, + replace: "$1600000 // [dsh-purge] bash timeout raised", }, ], - markers: ["timeoutMs: 600000"], + markers: ["timeoutMs: 600000 // [dsh-purge] bash timeout raised"], }, { id: 23, name: "READ_CAPS_RAISED", layer: "代码", layer_en: "Code", @@ -2439,6 +2439,9 @@ const NEW_TOOL_PATCHES = [ markers: [ "[dsh-purge] identity stripped", 'prefix: ""', + // bundle 布局:web-app / headless 的官方 persona 挂在 `persona:` 键上, + // 清掉后是 `persona: ""` —— 既无 purge 注记也无 prefix 键。 + 'persona: ""', ], }, { @@ -2956,6 +2959,7 @@ const NEW_TOOL_PATCHES = [ id: 39, name: "PERSONA_TEXT_PREFIX_ALIAS", layer: "代码", layer_en: "Code", desc: "dsh-persona:兼容 0.1.2 text 字段,否则梁神会话起不来 / accept legacy text as prefix", file: "persona", + optional: true, // 仅旧版 0.1.2 persona 使用;新版 prefix 结构无需改写 replacements: [ { pattern: @@ -3591,6 +3595,15 @@ function patchApplied(text, patch) { return false; } +function matchesPattern(hay, pattern) { + if (pattern instanceof RegExp) { + const re = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags); + re.lastIndex = 0; + return re.test(hay); + } + return hay.includes(asLf(pattern)); +} + function patchHasRemainingWork(text, patch, fp = "") { const hay = asLf(text); const yaml = isYamlPath(fp); @@ -3598,7 +3611,7 @@ function patchHasRemainingWork(text, patch, fp = "") { if (!pattern || typeof replace !== "string") continue; // 与 apply 一致:YAML 里无缩进 identity 不能 replaceAll,不算待做。 if (yaml && isBareIdentityNeedle(pattern)) continue; - if (hay.includes(asLf(pattern))) return true; + if (matchesPattern(hay, pattern)) return true; } return false; } @@ -3658,6 +3671,17 @@ function applyReplacementsToText(text, patch, fp = "") { if (!pattern || typeof replace !== "string") continue; // YAML 块标量行首有缩进;无缩进 identity+\n\n 会留下 6 空格,再和下一段拼成 12 空格。 if (yaml && isBareIdentityNeedle(pattern)) continue; + // 正则 pattern:用于自匹配型替换(产物包含原 pattern,如 timeoutMs 追加 0)。 + if (pattern instanceof RegExp) { + const re = pattern.global ? pattern : new RegExp(pattern.source, pattern.flags + "g"); + if (!re.test(out)) continue; + // 用字符串形态调用:保留 $1..$9 展开语义(回调形态会把 "$1" 当字面量写进文件)。 + const next = out.replace(re, asLf(replace)); + if (next === out) continue; + out = next; + changed = true; + continue; + } const needle = asLf(pattern); if (!out.includes(needle)) continue; out = out.split(needle).join(asLf(replace));