fix: 桌面可补共享预设,空提示词拦截统一走一处

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-20 11:32:16 +08:00
1 parent fedda6d338
commit ed08f0c431
2 files changed
+21 -11

No files matched your search

+2 -1
View File
@@ -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";
}
+19 -10
View File
@@ -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;
}