From ed08f0c4314b9f08c3c8ae1625228a0d1d64c566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AB=E6=88=91=E5=B0=8F=E6=9D=A8=E5=90=8C=E5=AD=A6?= <188421097+HunYiSage@users.noreply.github.com> Date: Sun, 20 Sep 2026 11:32:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A1=8C=E9=9D=A2=E5=8F=AF=E8=A1=A5?= =?UTF-8?q?=E5=85=B1=E4=BA=AB=E9=A2=84=E8=AE=BE=EF=BC=8C=E7=A9=BA=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=8D=E6=8B=A6=E6=88=AA=E7=BB=9F=E4=B8=80=E8=B5=B0?= =?UTF-8?q?=E4=B8=80=E5=A4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- lib/core.js | 3 ++- lib/index.js | 29 +++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/core.js b/lib/core.js index 77e8ac1..1bbf350 100644 --- a/lib/core.js +++ b/lib/core.js @@ -734,7 +734,8 @@ export function pathZone(fp) { export function allowTargetPath(fp, surface = detectSurface()) { const zone = pathZone(fp); if (adapterFor(surface) === "desktop") { - return zone === "desktop-install" || zone === "desktop-profile"; + // 桌面只动本机桌面树 + 共享的 $DSH_HOME/.agent-presets,不碰 Web / npm-global。 + return zone === "desktop-install" || zone === "desktop-profile" || zone === "shared"; } return zone !== "desktop-install" && zone !== "desktop-profile"; } diff --git a/lib/index.js b/lib/index.js index ead4f33..3d38719 100644 --- a/lib/index.js +++ b/lib/index.js @@ -162,6 +162,14 @@ function injectSnapshotFromBox(dshHome, boxText) { return { injectSource: "none", injectRuleId: ruleId, needPrompt: true }; } +const NEED_PROMPT_ERROR = "提示词和规则集都是空的,必须先添加提示词"; + +function rejectIfNeedPrompt(dshHome, boxText) { + const snap = injectSnapshotFromBox(dshHome, boxText); + if (!snap.needPrompt) return null; + return { ...snap, error: NEED_PROMPT_ERROR }; +} + export function registerPromptSections(ctx, config, _injectFile) { ctx.systemPrompt.section({ name: "dsh-purge", @@ -302,9 +310,10 @@ async function handlePurgeCommand(rawInput, config) { if (!state.ai_base) { return { kind: "error", text: core.missingAiBaseMessage() }; } + const blocked = rejectIfNeedPrompt(state.dsh_home); + if (blocked) return { kind: "error", text: blocked.error }; await core.backupAll(state.ai_base); const report = await core.applyPatches(state.ai_base); - await core.installOverride(state.dsh_home, false); const shimResult = await core.patchAllShims(); const flash = core.silenceCmdFlash(state.ai_base); const lines = report.map((r) => { @@ -646,9 +655,10 @@ export function apply(ctx, config) { const scrubbed = core.sanitizeDesktopCommandRuntimes(); const state = await core.gatherState(); if (!state.ai_base) return { text: "ERROR: " + core.missingAiBaseMessage() }; + const blocked = rejectIfNeedPrompt(state.dsh_home); + if (blocked) return { text: "ERROR: " + blocked.error }; await core.backupAll(state.ai_base); const report = await core.applyPatches(state.ai_base); - await core.installOverride(state.dsh_home, false); await core.patchAllShims(); const flash = core.silenceCmdFlash(state.ai_base); const applied = report.filter((r) => r.status === "applied").length; @@ -691,6 +701,7 @@ export function apply(ctx, config) { } function installWebServer(ctx, cfg) { + // 桌面端内嵌 @deepseek-ai/dsh-web-app,设置页同样走 webServer(常见 43120),不是只给官方 dsh web。 watchWebTreeReady(ctx); ctx.inject(["webServer"], (host) => { host.effect(() => { @@ -930,15 +941,14 @@ function installWebServer(ctx, cfg) { const body = await readJsonBody(request); const ui = await core.readOverrideForUi(state.dsh_home); const boxText = typeof body?.content === "string" ? body.content : ui.content; - const snap = injectSnapshotFromBox(state.dsh_home, boxText); - if (snap.needPrompt) { + const blocked = rejectIfNeedPrompt(state.dsh_home, boxText); + if (blocked) { sendJson(response, 400, { ok: false, needPrompt: true, - error: "提示词和规则集都是空的,必须先添加提示词", override_content: boxText, defaultContent: ui.defaultContent, - ...snap, + ...blocked, }); return; } @@ -1051,13 +1061,12 @@ function installWebServer(ctx, cfg) { return; } const home = core.findDshHome(); - const snap = injectSnapshotFromBox(home, content); - if (snap.needPrompt) { + const blocked = rejectIfNeedPrompt(home, content); + if (blocked) { sendJson(response, 400, { ok: false, - error: "提示词和规则集都是空的,必须先添加提示词", content, - ...snap, + ...blocked, }); return; }