mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 03:40:22 +08:00
fix: 可选补丁/CMD钉入不再误挡他人 Apply,并标明 #20/#21/#28/#29 所属插件
梁神与 web-fetch 的 pattern_miss 改为软通过;bin 缺失或写失败不永久卡完成。设置页文案写明 dsh-web-fetch-http / dsh-liangshen,失败提示列出具体补丁号。
This commit is contained in:
1 parent
864e6b7a3b
commit
777b3a1d15
3 files changed
+99
-30
No files matched your search
@@ -76,7 +76,9 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"restart.timeout": "超时,请刷新",
|
||||
"restart.fail": "失败: {error}",
|
||||
"restart.confirm": "清洗已完成,重启后生效。",
|
||||
"restart.incomplete": "清洗未完成(失败 {failed} 项或 CMD 无感未钉入),请先处理完再重启。",
|
||||
"restart.incomplete": "清洗未完成:{detail}",
|
||||
"restart.incomplete.patches": "必需补丁失败 {failed} 项(#{ids})",
|
||||
"restart.incomplete.flash": "CMD 无感未钉入({entry})",
|
||||
"restart.later": "以后",
|
||||
"group.prompt": "提示词",
|
||||
"group.code": "代码",
|
||||
@@ -101,12 +103,16 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"patch.17": "观察策略读写放行",
|
||||
"patch.18": "重复调用守卫禁用",
|
||||
"patch.19": "工具结果修剪禁用",
|
||||
"patch.20": "web fetch 启用 + provider",
|
||||
"patch.21": "base 依赖 fetch-http",
|
||||
"patch.20": "dsh-web-fetch-http:启用 fetch + provider",
|
||||
"patch.21": "dsh-web-fetch-http:base 写入依赖",
|
||||
"patch.22": "bash 超时 60s → 10min",
|
||||
"patch.23": "read 上限放宽",
|
||||
"patch.24": "子代理深度 3 → 10",
|
||||
"patch.25": "preset fetch 启用",
|
||||
"patch.26": "Harness 身份剥离",
|
||||
"patch.27": "minimal 人设清洗",
|
||||
"patch.28": "dsh-liangshen(梁神):人设拒绝锁→可执行",
|
||||
"patch.29": "dsh-liangshen(梁神):phase-1 保留注入段",
|
||||
};
|
||||
|
||||
const en = {
|
||||
@@ -164,8 +170,10 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"restarting": "Restarting…",
|
||||
"restart.timeout": "Timed out; refresh",
|
||||
"restart.fail": "Failed: {error}",
|
||||
"restart.confirm": "Apply finished (incl. silent CMD). Restart to take effect.",
|
||||
"restart.incomplete": "Apply incomplete ({failed} failed or CMD silence not pinned). Fix first, then restart.",
|
||||
"restart.confirm": "Apply finished. Restart to take effect.",
|
||||
"restart.incomplete": "Apply incomplete: {detail}",
|
||||
"restart.incomplete.patches": "{failed} required patch(es) failed (#{ids})",
|
||||
"restart.incomplete.flash": "CMD silence not pinned ({entry})",
|
||||
"restart.later": "Later",
|
||||
"group.prompt": "Prompt",
|
||||
"group.code": "Code",
|
||||
@@ -190,12 +198,16 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
"patch.17": "Observation policy allow R/W",
|
||||
"patch.18": "Repeat-call guard off",
|
||||
"patch.19": "Tool-result pruner off",
|
||||
"patch.20": "Web fetch on + provider",
|
||||
"patch.21": "base depends on fetch-http",
|
||||
"patch.20": "dsh-web-fetch-http: enable fetch + provider",
|
||||
"patch.21": "dsh-web-fetch-http: pin base dependency",
|
||||
"patch.22": "bash timeout 60s → 10min",
|
||||
"patch.23": "read cap raised",
|
||||
"patch.24": "subagent depth 3 → 10",
|
||||
"patch.25": "preset fetch on",
|
||||
"patch.26": "Harness identity strip",
|
||||
"patch.27": "minimal persona purge",
|
||||
"patch.28": "dsh-liangshen: refusal lock → executable",
|
||||
"patch.29": "dsh-liangshen: keep inject in phase-1",
|
||||
};
|
||||
|
||||
const THEME_KEY = "dshp-theme";
|
||||
@@ -412,13 +424,30 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
setOverrideLoaded(true);
|
||||
}
|
||||
if (action === "apply" && d.complete === false) {
|
||||
const flashHint =
|
||||
d.cmd_flash && d.cmd_flash.ok === false
|
||||
? ` cmd-flash=${d.cmd_flash.entry || "fail"}`
|
||||
: "";
|
||||
const parts = [];
|
||||
if (d.failed > 0) {
|
||||
const ids = (d.failed_items || [])
|
||||
.map((x) => x.id)
|
||||
.filter((id) => id != null)
|
||||
.join(",");
|
||||
parts.push(
|
||||
tr("restart.incomplete.patches", {
|
||||
failed: String(d.failed || 0),
|
||||
ids: ids || "?",
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (d.cmd_flash && d.cmd_flash.ok === false) {
|
||||
parts.push(
|
||||
tr("restart.incomplete.flash", {
|
||||
entry: String(d.cmd_flash.entry || "fail"),
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (parts.length === 0) parts.push(tr("restart.incomplete.flash", { entry: "unknown" }));
|
||||
setNotice({
|
||||
kind: "error",
|
||||
text: tr("restart.incomplete", { failed: String(d.failed || 0) }) + flashHint,
|
||||
text: tr("restart.incomplete", { detail: parts.join(";") }),
|
||||
});
|
||||
loadAll();
|
||||
return;
|
||||
@@ -506,7 +535,6 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
h("div", { className: "dshp-sub" },
|
||||
h("h4", null, t("override.title")),
|
||||
h("div", { className: "dshp-row", style: { margin: 0 } },
|
||||
noticeNode(notice),
|
||||
h(Btn, { kind: "primary", tiny: true, disabled: busy || !overrideLoaded, onClick: saveOverride }, t("btn.saveInject")),
|
||||
),
|
||||
),
|
||||
|
||||
+47
-7
@@ -198,13 +198,15 @@ export function silenceCmdFlash(aiBase = findAiBase()) {
|
||||
const hide = ensureHiddenConsole(aiBase);
|
||||
const doctor = stubDoctorSupervisor();
|
||||
const mnemon = silenceMnemonGitFlash();
|
||||
// Hard gate: bin.js hide-console must pin. Mnemon is best-effort — different
|
||||
// plugin versions may miss the pattern without blocking Apply for everyone.
|
||||
// Hard gate only when we can write bin.js. missing_bin / write errors must not
|
||||
// block Apply forever on foreign installs (portable paths, no ACL, etc.).
|
||||
const ok =
|
||||
process.platform !== "win32" ||
|
||||
hide.entry === "injected" ||
|
||||
hide.entry === "already_injected" ||
|
||||
hide.entry === "skipped_not_win32";
|
||||
hide.entry === "skipped_not_win32" ||
|
||||
hide.entry === "missing_bin" ||
|
||||
(typeof hide.entry === "string" && hide.entry.startsWith("error:"));
|
||||
return { ...hide, doctor, mnemon, ok };
|
||||
}
|
||||
|
||||
@@ -1185,7 +1187,8 @@ const NEW_TOOL_PATCHES = [
|
||||
},
|
||||
{
|
||||
id: 20, name: "WEB_FETCH_ENABLED", layer: "代码", layer_en: "Code",
|
||||
desc: "fetch 工具启用 + provider 挂载 / web fetch enabled",
|
||||
desc: "插件 dsh-web-fetch-http:启用 fetch + provider(可选) / @deepseek-ai/dsh-web-fetch-http",
|
||||
optional: true, // package/layout varies by install — never block Apply
|
||||
file: "base",
|
||||
rel: ["cordis.patch.yml"],
|
||||
replacements: [
|
||||
@@ -1228,11 +1231,13 @@ const NEW_TOOL_PATCHES = [
|
||||
},
|
||||
],
|
||||
markers: ["id: web-fetch-http", "fetchProvider: http", "fetch: true\n searchTimeoutMs"],
|
||||
optional: true, // package/layout varies — never block Apply for everyone
|
||||
},
|
||||
{
|
||||
id: 21, name: "WEB_FETCH_BASE_DEPENDENCY", layer: "代码", layer_en: "Code",
|
||||
desc: "base bundle 依赖 fetch-http / web fetch dependency",
|
||||
desc: "插件 dsh-web-fetch-http:base 写入依赖(可选) / @deepseek-ai/dsh-web-fetch-http",
|
||||
file: "base-package",
|
||||
optional: true,
|
||||
rel: ["package.json"],
|
||||
replacements: [
|
||||
{
|
||||
@@ -1426,8 +1431,9 @@ const NEW_TOOL_PATCHES = [
|
||||
// 梁神 phase-1 only surfaces the one-line persona (filters inject).
|
||||
// Rewrite refusal/engineer lock into allow/exec — no fixed operator role.
|
||||
id: 28, name: "LIANGSHEN_PERSONA_PURGE", layer: "提示词", layer_en: "Prompt",
|
||||
desc: "梁神预设:拒绝锁→可执行(若已安装) / purge liangshen refusal lock",
|
||||
desc: "插件 dsh-liangshen(梁神):拒绝锁→可执行(可选) / @linxin666/dsh-liangshen",
|
||||
file: ["preset-liangshen", "preset-liangshen-pkg"],
|
||||
optional: true, // only when liangshen is installed; text drifts by version
|
||||
replacements: [
|
||||
{
|
||||
pattern: "text: You are a helpful software engineer assistant.",
|
||||
@@ -1448,8 +1454,9 @@ const NEW_TOOL_PATCHES = [
|
||||
{
|
||||
// Liangshen phase-1 keeps only persona sections — allow dsh-purge inject through.
|
||||
id: 29, name: "LIANGSHEN_PHASE1_KEEP_INJECT", layer: "提示词", layer_en: "Prompt",
|
||||
desc: "梁神 phase-1 保留 dsh-purge 注入段 / keep purge sections in phase-1",
|
||||
desc: "插件 dsh-liangshen(梁神):phase-1 保留注入段(可选) / @linxin666/dsh-liangshen",
|
||||
file: ["liangshen-tool-bootstrap"],
|
||||
optional: true, // liangshen-only; bootstrap source changes across releases
|
||||
replacements: [
|
||||
{
|
||||
pattern: "const PERSONA_SECTION_NAMES = new Set(['deployment:persona', 'persona'])",
|
||||
@@ -1707,6 +1714,39 @@ function rollupPatchStatus({ applied, already, missing, notFound, lastError, key
|
||||
return "pattern_not_found";
|
||||
}
|
||||
|
||||
/** Statuses that never block Apply completion. */
|
||||
const ALWAYS_SOFT_STATUSES = new Set(["applied", "already", "missing_file", "skipped"]);
|
||||
|
||||
/**
|
||||
* Optional patches (liangshen / web-fetch / …) may pattern-miss on other
|
||||
* installs — treat mismatch as soft so strangers can still finish Apply.
|
||||
*/
|
||||
export function isPatchResultSoftOk(row, patch = null) {
|
||||
if (!row) return false;
|
||||
if (ALWAYS_SOFT_STATUSES.has(row.status)) return true;
|
||||
const p = patch || ALL_PATCHES.find((x) => x.id === row.patch_id || x.id === row.id);
|
||||
if (p?.optional && row.status === "pattern_not_found") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Split apply report into hard failures vs soft/ok rows. */
|
||||
export function summarizeApplyReport(report, patches = ALL_PATCHES) {
|
||||
const byId = new Map(patches.map((p) => [p.id, p]));
|
||||
const failed = [];
|
||||
const soft = [];
|
||||
for (const row of report) {
|
||||
const patch = byId.get(row.patch_id) || byId.get(row.id);
|
||||
if (isPatchResultSoftOk(row, patch)) soft.push(row);
|
||||
else failed.push(row);
|
||||
}
|
||||
return {
|
||||
failed,
|
||||
soft,
|
||||
applied: report.filter((r) => r.status === "applied").length,
|
||||
already: report.filter((r) => r.status === "already").length,
|
||||
};
|
||||
}
|
||||
|
||||
async function loadText(p) {
|
||||
return fsp.readFile(p, "utf8");
|
||||
}
|
||||
|
||||
+11
-10
@@ -683,19 +683,20 @@ function installWebServer(ctx, cfg) {
|
||||
const shim = await core.patchAllShims();
|
||||
// Apply must finish the no-flash pass before offering restart.
|
||||
const flash = core.silenceCmdFlash(state.ai_base);
|
||||
const applied = report.filter((r) => r.status === "applied").length;
|
||||
const already = report.filter((r) => r.status === "already").length;
|
||||
// missing_file = optional target not installed (liangshen / web-fetch / …) — not a hard fail.
|
||||
const softOk = new Set(["applied", "already", "missing_file"]);
|
||||
const failed = report.filter((r) => !softOk.has(r.status));
|
||||
// Restart only when required patches finished AND (on win32) bin.js hide-console pinned.
|
||||
const complete = failed.length === 0 && flash.ok === true;
|
||||
const summary = core.summarizeApplyReport(report);
|
||||
// Restart when required patches are soft-ok AND (on win32) bin pin is ok/soft.
|
||||
const complete = summary.failed.length === 0 && flash.ok === true;
|
||||
sendJson(response, 200, {
|
||||
ok: true,
|
||||
complete,
|
||||
applied,
|
||||
already,
|
||||
failed: failed.length,
|
||||
applied: summary.applied,
|
||||
already: summary.already,
|
||||
failed: summary.failed.length,
|
||||
failed_items: summary.failed.map((r) => ({
|
||||
id: r.patch_id,
|
||||
name: r.name,
|
||||
status: r.status,
|
||||
})),
|
||||
report: report.map((r) => ({ id: r.patch_id, name: r.name, status: r.status })),
|
||||
override_content: override.content,
|
||||
override_path: override.path,
|
||||
|
||||
Reference in new issue
Block a user