fix: 可选补丁/CMD钉入不再误挡他人 Apply,并标明 #20/#21/#28/#29 所属插件

梁神与 web-fetch 的 pattern_miss 改为软通过;bin 缺失或写失败不永久卡完成。设置页文案写明 dsh-web-fetch-http / dsh-liangshen,失败提示列出具体补丁号。
This commit is contained in:
yang committed 2026-09-02 23:26:56 +08:00
1 parent 8aa7afecd3
commit a204851989
3 files changed
+99 -30

No files matched your search

+47 -7
View File
@@ -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");
}