release: 1.1.70

Hub/残装不再空等 pluginPackages;清洗页合并升级链展示,Apply 仍全打。合并 #97/#98/#99。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-11 18:01:05 +08:00
1 parent 17bbeb12cc
commit 199329bd5a
17 files changed
+774 -471

No files matched your search

+42 -43
View File
@@ -17,6 +17,7 @@ import {
installAssembleGuard,
modePromptText,
peelChatmlEnvelope,
escapeDshInterpolation,
rewritePromptAssembly,
} from "./identity.js";
import { capabilityProtocolText, CAPABILITY_SECTION } from "./capability-protocol.js";
@@ -37,13 +38,15 @@ import {
export const name = "dsh-purge";
// 不要把 pluginPackages 写进 inject:Cordis 会对 map 里每一个 key 空等。
// 便携拷贝 / Hub 残装经常没有这项服务,一写进去就是 pending → 宿主退出码 1。
export const inject = ["systemPrompt", "tools"];
let bootFullQuit = false;
const DEFAULTS = {
enabled: true,
autoApplyOnStart: true,
autoApplyOnStart: false,
autoUpdateOnStart: false,
autoRevertOnMissing: false,
injectOnce: false,
@@ -141,11 +144,18 @@ function renderStatus(state) {
out.push(line("app.asar", "还在。补丁写在解开目录,当前进程读不到", false));
}
out.push("");
out.push(`补丁 / patches: ${state.patches_applied}/${state.patches_total || 0} applied, ${state.patches_pending} pending`);
for (const p of core.ALL_PATCHES) {
const s = state.patch_status[p.id] || "n/a";
const displayRows = Array.isArray(state.display_patches)
? state.display_patches
: core.groupPatchesForDisplay(core.ALL_PATCHES, state.patch_status || {});
const displayTally = core.tallyDisplayPatches(displayRows);
out.push(`补丁 / patches: ${displayTally.applied}/${displayTally.total || 0} applied, ${displayTally.pending} pending`);
for (const row of displayRows) {
const s = row.status || "n/a";
const mark = s === "applied" ? "✓" : s === "pending" ? "✗" : "·";
out.push(` ${mark} [#${String(p.id).padEnd(2)}] ${p.name.padEnd(30)} ${p.layer}/${p.layer_en} — ${s}`);
const patch = core.ALL_PATCHES.find((item) => item.id === row.id);
const label = patch ? patch.name : `patch-${row.id}`;
const layer = patch ? `${patch.layer}/${patch.layer_en}` : row.layer || "";
out.push(` ${mark} [#${String(row.id).padEnd(2)}] ${label.padEnd(30)} ${layer} — ${s}`);
}
out.push("");
out.push(`shim: dsh.cmd=${state.shim_cmd} dsh.ps1=${state.shim_ps1} dsh=${state.shim_bin}`);
@@ -184,7 +194,7 @@ function refreshHungOperator(dshHome = core.findDshHome()) {
const resolved = rules.resolveInjectText(home);
// 兜底顺序:resolved.text > 加密默认 > 永不空串(避免二轮 fallbackInject 为空走 purge[] 残留)。
const fallback = core.normalizeOverride(core.defaultOverrideText()) || "";
// 框里、磁盘、加密槽是什么样就挂什么样,不剥 ChatML / project_instructions。
// 框、磁盘、加密槽保持原样。发给模型只整理 ChatML 单独成行,并补上缺失的闭合标签。
const text = resolved.text || fallback;
if (text) {
core.hangOperatorPrompt(text);
@@ -208,7 +218,7 @@ function installHungPromptGlobal() {
// 3) readPromptInjectFileSync — 直读磁盘 prompt-inject.md,绕过 sync/resolve
// 4) defaultOverrideText — 加密槽解包,除非插件安装残缺否则非空
const fn = () => {
const norm = (s) => peelChatmlEnvelope(String(s || "").replace(/\r\n/g, "\n").trim());
const norm = (s) => peelChatmlEnvelope(String(s || "").replace(/\r\n/g, "\n"));
let home = "";
try { home = core.findDshHome(); } catch { home = ""; }
try {
@@ -374,7 +384,9 @@ export function registerPromptSections(ctx, config) {
text: (context) => {
if (!injectAllowedNow(config)) return "";
// 标准、极简都注入同一份正文。极简只改工具句,不决定注不注入。
return adaptInjectForMinimalPreset(readInjectFallback(context), context);
return escapeDshInterpolation(
peelChatmlEnvelope(adaptInjectForMinimalPreset(readInjectFallback(context), context)),
);
},
});
@@ -884,6 +896,18 @@ async function settleInstalledPatches(config, ctx, life) {
log(config, "heal applied stamp failed:", String(e && e.message ? e.message : e));
}
if (config.autoApplyOnStart !== true) {
try {
if (await reapply.patchesMatchInstallStrict() || await reapply.hostCleanEnoughToKeep()) {
reapply.markPatchesApplied();
log(config, "boot: host files left untouched; stamp kept");
return "boot:host-untouched";
}
} catch { /* 没戳也没关系,等用户点应用 */ }
log(config, "boot: skip host writes (Apply once)");
return "skip:boot-no-host-write";
}
const scope = currentSettleScope();
if (!(await reapply.patchesMatchInstallStrict())) {
if (!settleMayReapply(scope)) {
@@ -1464,44 +1488,18 @@ export function apply(ctx, config) {
}
refreshHungOperator(home);
} catch { /* 主目录还没有时,组装会再挂内置默认 */ }
try {
const restored = core.restoreMissingOriginalsAllHosts();
if (restored.length) log(cfg, "restored missing overlay from bak:", restored.join(","));
} catch (e) {
console.warn("[dsh-purge] restore bak:", String(e && e.message ? e.message : e));
}
// 启动不写宿主包。补丁 / bak / client.js / runtime 只在点「应用」时写一次。
const life = watchContextLife(ctx);
if (!life.alive) {
console.warn("[dsh-purge] skip apply: inactive context");
return;
}
log(cfg, "plugin enabled");
try {
const hide = core.ensureHiddenConsole();
log(cfg, "hide-console:", JSON.stringify(hide));
} catch (e) {
console.warn("[dsh-purge] hide-console error:", String(e));
}
core.applyRuntimeEnv();
// 页面打开前写前端 client.js。settle 在数秒之后,那时再写会让已发出的 rev 404(#63)。
try {
const written = core.patchWatchedClientBundlesSync();
publishClientBundleRevs(ctx, written);
if (written.length) log(cfg, "client bundles patched before page:", written.join(","));
} catch (e) {
console.warn("[dsh-purge] client bundle boot patch:", String(e && e.message ? e.message : e));
}
try {
const home = core.pinDshHome() || core.findDshHome();
refreshHungOperator(home);
} catch { /* 主目录还没有时,组装会再挂内置默认 */ }
try {
const scrubbed = core.sanitizeDesktopCommandRuntimes();
if (scrubbed.length) log(cfg, "desktop runtime scrub on load:", JSON.stringify(scrubbed));
} catch (e) {
console.warn("[dsh-purge] desktop runtime scrub error:", String(e));
}
const settleTimer = setTimeout(() => {
if (!life.alive) {
@@ -1794,19 +1792,20 @@ function installWebServer(ctx, cfg) {
desktop_exe: state.desktop_exe || "",
asar_still_sealed: state.asar_still_sealed || false,
missing_ai_base: state.ai_base ? "" : core.missingAiBaseMessage(),
patches_applied: state.patches_applied,
patches_pending: state.patches_pending,
patches_skipped: state.patches_skipped || 0,
patches_ready: state.patches_ready || 0,
patches_applied: state.ai_base ? (state.display_applied ?? state.patches_applied) : 0,
patches_pending: state.display_pending ?? state.patches_pending,
patches_skipped: state.display_skipped ?? state.patches_skipped ?? 0,
patches_ready: (state.display_ready ?? state.patches_ready) || 0,
patches_na: state.patches_na || 0,
patches_total: state.ai_base ? (state.patches_total || 0) : 0,
patches_total: state.ai_base ? (state.display_total ?? state.patches_total || 0) : 0,
patches_lost: reapply.patchesLostAfterHostReset(),
patch_status: state.patch_status,
patches: core.ALL_PATCHES.map((p) => ({
patches: (state.display_patches || []).map((p) => ({
id: p.id,
ids: p.ids,
layer: p.layer || "",
status: state.patch_status[p.id] || (state.ai_base ? "missing_file" : "unlocated"),
})).filter((p) => p.status !== "na"),
status: p.status,
})),
patch_names,
shim_cmd: state.shim_cmd,
shim_ps1: state.shim_ps1,