fix: 发布 1.1.50,修 macOS 桌面重启/CLI(#53)与应用后默认提示词注入。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-02 22:29:28 +08:00
1 parent 94a7cf814e
commit 148d6218d8
7 files changed
+128 -47

No files matched your search

+37 -16
View File
@@ -364,14 +364,22 @@ function installIdentityOverride(ctx, config = {}) {
// 0.1.5 起 complete:true 在 waterfall 之后用调用前的快照盖掉 sections。
// 换宿主版本时文件补丁还没写上,或换插件版本时旧钩子把 dsh-purge 段删掉,注入都会丢。
// 包住 assemble 的返回值,按 prompt-inject.md 再补回。
const prompt = ctx.systemPrompt;
if (!prompt || typeof prompt.assemble !== "function" || prompt.__dshPurgeAssembleWrapped) return;
const orig = prompt.assemble;
prompt.assemble = async function (...args) {
const assembled = await orig.apply(this, args);
return rewriteLiveAssembly(config, assembled, args[0]);
const wrapAssemble = () => {
const prompt = ctx.systemPrompt;
if (!prompt || typeof prompt.assemble !== "function" || prompt.__dshPurgeAssembleWrapped) return false;
const orig = prompt.assemble;
prompt.assemble = async function (...args) {
const assembled = await orig.apply(this, args);
return rewriteLiveAssembly(config, assembled, args[0]);
};
prompt.__dshPurgeAssembleWrapped = true;
return true;
};
prompt.__dshPurgeAssembleWrapped = true;
if (!wrapAssemble()) {
queueMicrotask(wrapAssemble);
setTimeout(wrapAssemble, 500);
setTimeout(wrapAssemble, 2000);
}
}
function shimNeedsPatch(state) {
@@ -515,6 +523,10 @@ async function handlePurgeCommand(rawInput, config) {
await core.ensureOverrideContent(state.dsh_home, false);
const blocked = rejectIfNeedPrompt(state.dsh_home);
if (blocked) return { kind: "error", text: blocked.error };
await core.saveOverrideContent(
state.dsh_home,
core.resolveApplyOverrideText(state.dsh_home, ""),
);
await core.backupAll(state.ai_base);
const report = await core.applyPatches(state.ai_base);
const shimResult = await core.patchAllShims();
@@ -854,6 +866,10 @@ export function apply(ctx, config) {
} catch (e) {
console.warn("[dsh-purge] seed override error:", String(e));
}
// 与 1.1.30 前一致:启动就落盘默认提示词,不依赖用户先点保存。
core.installOverride(core.findDshHome(), false).catch((e) => {
console.warn("[dsh-purge] install override error:", String(e));
});
installIdentityOverride(ctx, cfg);
installRegionGate(ctx);
try {
@@ -985,6 +1001,10 @@ export function apply(ctx, config) {
await core.ensureOverrideContent(state.dsh_home, false);
const blocked = rejectIfNeedPrompt(state.dsh_home);
if (blocked) return { text: "ERROR: " + blocked.error };
await core.saveOverrideContent(
state.dsh_home,
core.resolveApplyOverrideText(state.dsh_home, ""),
);
await core.backupAll(state.ai_base);
const report = await core.applyPatches(state.ai_base);
await core.patchAllShims();
@@ -1341,9 +1361,11 @@ function installWebServer(ctx, cfg) {
await core.ensureOverrideContent(state.dsh_home, false);
const ui = await core.readOverrideForUi(state.dsh_home);
const incoming = typeof body?.content === "string" ? body.content : "";
const boxText = core.normalizeOverride(incoming)
? incoming
: (ui.content || ui.defaultContent || "");
// 框空时用内置默认,与 1.1.30 前「应用即带默认注入」一致,不必先点保存。
const boxText = core.resolveApplyOverrideText(state.dsh_home, incoming)
|| ui.content
|| ui.defaultContent
|| "";
const blocked = rejectIfNeedPrompt(state.dsh_home, boxText);
if (blocked) {
sendJson(response, 400, {
@@ -1355,9 +1377,7 @@ function installWebServer(ctx, cfg) {
});
return;
}
if (core.normalizeOverride(boxText)) {
await core.saveOverrideContent(state.dsh_home, boxText);
}
await core.saveOverrideContent(state.dsh_home, boxText);
await core.backupAll(state.ai_base);
const report = await core.applyPatches(state.ai_base);
const override = await core.readOverrideForUi(state.dsh_home);
@@ -1505,16 +1525,17 @@ function installWebServer(ctx, cfg) {
return;
}
const home = core.findDshHome();
const blocked = rejectIfNeedPrompt(home, content);
const resolved = core.resolveApplyOverrideText(home, content);
const blocked = rejectIfNeedPrompt(home, resolved);
if (blocked) {
sendJson(response, 400, {
ok: false,
content,
content: resolved,
...blocked,
});
return;
}
const saved = await core.saveOverrideContent(home, content);
const saved = await core.saveOverrideContent(home, resolved);
sendJson(response, 200, { ok: true, ...saved, ...injectSnapshot(home) });
} catch (e) {
sendJson(response, 500, { ok: false, error: String(e) });