fix: 0.2.0 system prompt修复 + patch89 + override状态机 + 提示词优化

- core.js: isKeepableUserOverride重排序, markOverrideCustomized不写hash(explicitSave), commitOverrideOnApply读盘, patch89 SYSTEM_FIELD_EXTRACT
- index.js: system_field_extracted状态字段(status/apply/override端点)
- default-prompt-inject.en.md: 优化英文版提示词
- default-prompt-inject.zh.md: 优化中文版提示词
- docs/修改文档.md: 完整修改文档+还原说明
- pi-ai anthropic-messages.js: system从顶层字段改为messages里role:system消息
This commit is contained in:
叫我小杨同学 committed 2026-10-13 16:36:15 +08:00
1 parent 6c1d638d1b
commit e1d8e59087
24 files changed
+3353 -1198

No files matched your search

+88 -37
View File
@@ -197,7 +197,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"status.pending": "待应用",
"status.unmatched": "没对上",
"status.skipped": "跳过",
"apply.hint": "点应用会打补丁并把当前默认提示词挂上,框里仍是插件旧默认时自动刷到加密槽,不必再点保存。只有你另写的稿才会按框落盘。待应用=原文还在。跳过=当前版本不需要或组件未安装。",
"apply.hint": "没改提示词框不用点保存,默认就是这份,启动和应用会写进 prompt-inject.md。只有自己改过再点保存才会覆盖。点应用打补丁。待应用=原文还在。跳过=当前版本不需要或组件未安装。",
"warn.noRoot": "未定位到当前宿主的 @deepseek-ai,清洗不会生效。请完全退出后再打开本宿主,在本页点「应用」。桌面端安装目录可以是任意盘符;目录名带 DeepseekHarness / DeepSeek Harness 均可。",
"warn.noRoot.desktop": "官方客户端的代码在 app.asar 里。点「应用」会解开并自动重启,不用另跑脚本。若一直显示还没定位,先完全退出客户端再开,再点「应用」。第三方 DSH Desktop 直接点「应用」。",
"unpack.restarting": "补丁已写入。点「重启」后客户端会自己重新打开。",
@@ -420,7 +420,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"patch.69": "deepseek-flash 保持官方 in-history",
"patch.72": "Messages 的 system 用当前系统提示",
"patch.73": "极简 bash 去掉误留的镜像说明",
"patch.74": "首发前先挂默认提示词",
"patch.74": "启动/应用把默认提示词写入 prompt-inject.md",
"patch.75": "回退把已完成任务收回成未开始",
"patch.76": "unrestricted 预设去掉身份句",
"patch.77": "回退标记到达时丢弃已发送消息",
@@ -429,6 +429,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"patch.82": "主进程兜底 DSH_PROFILE=desktop",
"patch.83": "host 信号杀时不报错不弹对话框",
"patch.84": "host code=0 正常退出不报错 (消除 stopped 对话框)",
"patch.85": "prompt() 的 steer 仍走插话,不压成 followup",
"patch.86": "队列插话走 steer;公共 steer() 保持下一步",
"patch.87": "首次 assemble 用 prepare 返回的当前模式 systemPrompt",
"patch.88": "去掉 renderPrompt 后的挂针,注入只走 assemble",
"status.unlocated": "未定位",
"status.na": "本端不需要",
"metric.unlocated": "还没定位到本机 Harness",
@@ -441,10 +445,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"rewind.busy": "回退中…",
"rewind.empty": "没有可回退的上一句",
"rewind.fail": "回退失败: {error}",
"rewind.once": "回退一次",
"rewind.once.hint": "把这一轮发出去的那句放回输入框,并清掉这一轮",
"rewind.once": "回退上一步",
"rewind.once.hint": "撤回最后一步已进行的对话,新会话接上之前的上下文;那句回到输入框再发送",
"rewind.round": "回退上一轮",
"rewind.round.hint": "把这一轮发出去的那句放回输入框;子代理也只撤这一轮",
"rewind.round.hint": "撤回上一整轮(含子代理)已进行的对话,新会话接上之前的上下文;那句回到输入框再发送",
"hooksDeny.title": "Hooks 拦截",
"hooksDeny.bypass": "放行 hooks 的 deny / ask(补丁 30 / 31 / 64 / 65)",
"hooksDeny.hint": "关掉后,用户自己的 PreToolUse / UserPromptSubmit / Stop hook 的 deny 会按官方逻辑生效。官方 ask 分支本身是空操作,关开关不会弹出审批框。改完后点「应用」并重启才写进宿主。",
@@ -537,7 +541,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"status.pending": "Pending",
"status.unmatched": "No match",
"status.skipped": "Skipped",
"apply.hint": "Apply writes patches and hangs the current default prompt. A stale plugin default in the box is refreshed from the sealed slot; a separate save is unnecessary. Only a prompt you wrote yourself is kept from the box. Pending = original text still present. Skipped = not needed for this version or the component is not installed.",
"apply.hint": "If you did not edit the prompt box, do not save. The default is already used and is written to prompt-inject.md on start/apply. Save only after you change it. Apply writes host patches. Pending = original text still present. Skipped = not needed for this version or the component is 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; folder names like DeepseekHarnessDesktop or DeepSeek Harness are fine.",
"warn.noRoot.desktop": "Official Harness keeps its code in app.asar. Apply unpacks it and restarts the app. If this page stays “not found”, fully quit the client, reopen it, then Apply again. Third-party DSH Desktop: just Apply.",
"unpack.restarting": "Patches are written. Click Restart and the client opens again by itself.",
@@ -760,7 +764,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"patch.69": "deepseek-flash keeps the official in-history flag",
"patch.72": "Messages system field uses the current system prompt",
"patch.73": "Minimal preset drops stray mirror sentence",
"patch.74": "Hang default prompt before first assemble",
"patch.74": "Start/apply writes the default prompt to prompt-inject.md",
"patch.75": "Rewind resets completed todos to pending",
"patch.76": "Unrestricted preset: strip identity sentence",
"patch.77": "Rewind marker drops already-sent messages",
@@ -769,6 +773,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"patch.82": "Fallback DSH_PROFILE=desktop in main process",
"patch.83": "Don't fail on signal kill (no crash dialog)",
"patch.84": "Don't fail on code=0 clean exit (no stopped dialog)",
"patch.85": "prompt() steer stays interrupt, not followup",
"patch.86": "Queue steer stays steer; public steer() stays next-step",
"patch.87": "First assemble uses the systemPrompt prepare returned",
"patch.88": "Drop the hang after renderPrompt; inject is assemble only",
"status.na": "Not for this host",
"metric.sealed": "Official client found. Apply to unpack",
"metric.sealed.count": "Sealed",
@@ -781,10 +789,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
"rewind.busy": "Undoing…",
"rewind.empty": "Nothing to undo",
"rewind.fail": "Undo failed: {error}",
"rewind.once": "Undo once",
"rewind.once.hint": "Put this round's message back in the box and drop only this round",
"rewind.round": "Undo last round",
"rewind.round.hint": "Put this round's message back in the box; subagents drop only this round",
"rewind.once": "Undo last step",
"rewind.once.hint": "Withdraw the last step into a new session that keeps earlier context; the line returns to the box",
"rewind.round": "Undo last turn",
"rewind.round.hint": "Withdraw the last turn (and its subagents) into a new session that keeps earlier context; the line returns to the box",
"hooksDeny.title": "Hook interception",
"hooksDeny.bypass": "Bypass hook deny / ask (patches 30 / 31 / 64 / 65)",
"hooksDeny.hint": "When off, your own PreToolUse / UserPromptSubmit / Stop hook deny runs as the official host wrote it. The official ask branch is a no-op; turning this off will not show an approval dialog. Click Apply and restart to write the host files.",
@@ -947,7 +955,7 @@ body[data-ds-dark-theme] .dshp-restart-card .dshp-btn-primary,body[data-ds-dark-
.dshp-dock[data-open="0"]{display:none}
.dshp-launch{position:fixed;right:16px;bottom:16px;z-index:10040;appearance:none;display:inline-flex;align-items:center;gap:6px;height:36px;padding:0 14px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 55%,transparent);border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1c1c) 72%,transparent);color:var(--dsw-alias-label-primary,#f2f2f2);cursor:pointer;font:13px/1 inherit;box-shadow:0 8px 22px color-mix(in srgb,#000 28%,transparent);pointer-events:auto}
.dshp-launch:hover{border-color:var(--dsw-alias-brand-primary,#6dbf8c);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 18%,transparent)}
.dshp-launch[data-open="1"]{display:none}
.dshp-launch[data-open="1"],.dshp-launch[data-hide="1"]{display:none}
.dshp-dock-head{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,var(--dshp-line,#555)) 55%,transparent);background:transparent;cursor:grab;user-select:none;touch-action:none;color:var(--dsw-alias-label-primary,var(--dshp-ink,#f2f2f2));border-radius:12px 12px 0 0}
.dshp-dock-head:active{cursor:grabbing}
.dshp-dock-head b{font-size:14px;font-weight:600;color:inherit;text-shadow:0 1px 0 color-mix(in srgb,#000 18%,transparent)}
@@ -1110,17 +1118,37 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
const rows = fromList
? fromList.map((p) => ({
id: Number(p.id),
ids: Array.isArray(p.ids) && p.ids.length ? p.ids.map(Number) : [Number(p.id)],
st: p.status || "missing_file",
layer: p.layer || "",
title: p.title || "",
}))
: Object.keys(state.patch_status || {}).map((id) => ({
id: Number(id),
ids: [Number(id)],
st: state.patch_status[id],
layer: "",
title: "",
}));
return rows.filter((r) => r.st && r.st !== "na" && Number.isFinite(r.id));
}
function patchIdLabel(r) {
const ids = Array.isArray(r.ids) && r.ids.length ? r.ids : [r.id];
return ids.map((id) => "#" + id).join("/");
}
function patchTitle(t, state, r) {
if (r && r.title) return r.title;
const id = r && typeof r === "object" ? r.id : r;
const key = "patch." + id;
const hit = t(key);
if (hit && hit !== key) return hit;
const names = state && state.patch_names;
const name = names && (names[id] || names[String(id)]);
return name || key;
}
function tallyPatches(rows) {
const out = { applied: 0, pending: 0, unmatched: 0, skipped: 0, total: 0 };
for (const row of rows || []) {
@@ -1170,9 +1198,9 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
h("th", null, t("table.patch")),
h("th", null, t("table.status")),
)),
h("tbody", null, rows.map((r) => h("tr", { key: r.id },
h("td", { className: "dshp-id" }, "#" + r.id),
h("td", null, t("patch." + r.id)),
h("tbody", null, rows.map((r) => h("tr", { key: r.ids ? r.ids.join("-") : r.id },
h("td", { className: "dshp-id" }, patchIdLabel(r)),
h("td", null, patchTitle(t, state, r)),
h("td", null, h(Pill, { value: r.st })),
))),
) : null,
@@ -1391,6 +1419,7 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
const overrideRef = useRef("");
const defaultOverrideRef = useRef("");
const promptSeededRef = useRef(false);
const promptDirtyRef = useRef(false);
const promptAreaRef = useRef(null);
overrideRef.current = override;
defaultOverrideRef.current = defaultOverride;
@@ -1572,7 +1601,7 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
const packed = typeof d.defaultContent === "string" ? d.defaultContent : "";
const shown = typeof d.content === "string" ? d.content : packed;
if (packed) setDefaultOverride(packed);
if (!promptSeededRef.current) {
if (!promptSeededRef.current || !promptDirtyRef.current) {
promptSeededRef.current = true;
setOverride(shown || packed);
}
@@ -1671,12 +1700,8 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
if (action === "apply") {
setNotice({ kind: "ok", text: tr("ok.done") });
loadAll();
if (d.restarting || d.needs_full_quit) {
suppressRestartAsk.current = false;
setAskRestart(true);
} else {
setAskRestart(false);
}
suppressRestartAsk.current = false;
setAskRestart(true);
return;
}
setNotice({ kind: "ok", text: tr("ok.done") });
@@ -1713,7 +1738,11 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
rejectNeedPrompt(tr);
return;
}
if (typeof d.content === "string") setOverride(d.content);
if (typeof d.content === "string") {
overrideRef.current = d.content;
setOverride(d.content);
}
promptDirtyRef.current = false;
setNotice({ kind: "ok", text: t("saved.override") });
})
.catch((e) => {
@@ -1757,6 +1786,7 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
overrideRef.current = d.content;
setOverride(d.content);
}
promptDirtyRef.current = false;
setNotice({ kind: "ok", text: tr("saved.restoreInject") });
})
.catch((e) => {
@@ -1995,6 +2025,7 @@ body:not([data-ds-dark-theme]) .dshp-auth-ops button.primary{background:var(--ds
ref: promptAreaRef,
value: override,
onChange: (e) => {
promptDirtyRef.current = true;
overrideRef.current = e.target.value;
setOverride(e.target.value);
},
@@ -3251,8 +3282,8 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); },
onClick: (e) => { e.preventDefault(); e.stopPropagation(); runRewind("once"); },
},
h("b", null, rewindText(t, "rewind.once", "回退一次")),
h("span", null, rewindText(t, "rewind.once.hint", "把这一轮发出去的那句放回输入框,并清掉这一轮")),
h("b", null, rewindText(t, "rewind.once", "回退上一步")),
h("span", null, rewindText(t, "rewind.once.hint", "撤回最后一步已进行的对话,新会话接上之前的上下文;那句回到输入框再发送")),
),
h("button", {
type: "button",
@@ -3261,7 +3292,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
onClick: (e) => { e.preventDefault(); e.stopPropagation(); runRewind("round"); },
},
h("b", null, rewindText(t, "rewind.round", "回退上一轮")),
h("span", null, rewindText(t, "rewind.round.hint", "把这一轮发出去的那句放回输入框;子代理也只撤这一轮")),
h("span", null, rewindText(t, "rewind.round.hint", "撤回上一整轮(含子代理)已进行的对话,新会话接上之前的上下文;那句回到输入框再发送")),
),
);
try {
@@ -8199,10 +8230,7 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
if (!shell || patched.has(shell)) return;
if (typeof shell.submit !== "function") return;
const origSubmit = shell.submit;
const origActionsSubmit = (shell.actions && typeof shell.actions.submit === "function")
? shell.actions.submit
: null;
patched.set(shell, { origSubmit, origActionsSubmit });
patched.set(shell, { origSubmit });
patchedShells.push(shell);
const bound = origSubmit.bind(shell);
shell.submit = function gatedSubmit(mode) {
@@ -8211,9 +8239,6 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
} catch { /* 门禁异常时不吞掉发送 */ }
return bound(mode);
};
if (shell.actions && typeof shell.actions === "object") {
shell.actions.submit = () => shell.submit("queue");
}
};
const tick = () => {
try {
@@ -8231,9 +8256,6 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
const info = patched.get(shell);
if (!info) continue;
try { shell.submit = info.origSubmit; } catch { /* ignore */ }
if (info.origActionsSubmit && shell.actions) {
try { shell.actions.submit = info.origActionsSubmit; } catch { /* ignore */ }
}
}
patchedShells.length = 0;
};
@@ -8539,13 +8561,42 @@ body[data-ds-dark-theme] .dshp-rewind-item span{color:var(--dsw-alias-label-tert
);
}
function hasInlinePurgeEntry() {
if (typeof document === "undefined") return false;
if (document.querySelector("[data-testid='dsh-purge-hero-chip'], [data-testid='dsh-purge-tab-chip']")) return true;
const nodes = document.querySelectorAll("button, [role='tab'], [role='button'], [class*='chip']");
for (let i = 0; i < nodes.length; i += 1) {
const el = nodes[i];
if (!el || el.classList.contains("dshp-launch")) continue;
if (el.closest && el.closest(".dshp-dock, .dshp-launch")) continue;
if (String(el.textContent || "").trim() === "dsh-purge") return true;
}
return false;
}
function PurgeLauncher() {
const t = useT();
const st = useDock();
const [hide, setHide] = useState(hasInlinePurgeEntry);
useEffect(() => {
const sync = () => setHide(hasInlinePurgeEntry());
sync();
const obs = typeof MutationObserver !== "undefined"
? new MutationObserver(sync)
: null;
if (obs && document.body) obs.observe(document.body, { childList: true, subtree: true });
const iv = setInterval(sync, 800);
return () => {
if (obs) obs.disconnect();
clearInterval(iv);
};
}, []);
if (st.open || hide) return null;
return h("button", {
type: "button",
className: "dshp-launch",
"data-open": st.open ? "1" : "0",
"data-open": "0",
"data-hide": "0",
"data-testid": "dsh-purge-launch",
title: t("dock.newSession"),
onClick: () => toggleDock(),