fix: 发布 1.1.58,打开即挂上默认提示词

重启或重新打开后不用再点保存。磁盘正文优先,其次规则集,再没有就用内置默认。应用成功仍先询问是否重启。前端模块只在页面发出前改写,避免输入框消失。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-05 01:06:55 +08:00
1 parent 75637c48b9
commit 131ef12ecb
8 files changed
+158 -37

No files matched your search

+86 -5
View File
@@ -2098,10 +2098,11 @@ function quotedConst(name, body) {
const COMPLETE_PROMPT_WATERFALL_INJECT =
"\t\tconst transformed = await this.ctx.waterfall(scopeTarget(this, scope), \"system-prompt/assemble\", assembly, context, () => Promise.resolve(assembly));\n" +
"\t\tconst dshPurgeSections = (transformed.sections || []).filter((s) => String(s && s.name || \"\").startsWith(\"dsh-purge\") && String(s.text || \"\").length > 0);\n" +
"\t\tif (completeSection === void 0 && !runtimeContextSuppressed) return transformed;\n" +
"\t\tconst dshPurgeRest = (transformed.sections || []).filter((s) => !String(s && s.name || \"\").startsWith(\"dsh-purge\"));\n" +
"\t\tif (completeSection === void 0 && !runtimeContextSuppressed) return { ...transformed, sections: [...dshPurgeSections, ...dshPurgeRest] }; // [dsh-purge] every mode keeps system inject\n" +
"\t\treturn {\n" +
"\t\t\t...transformed,\n" +
"\t\t\tsections: completeSection === void 0 ? transformed.sections : (function (complete, purge) {\n" +
"\t\t\tsections: completeSection === void 0 ? [...dshPurgeSections, ...dshPurgeRest] : (function (complete, purge) {\n" +
"\t\t\t\tconst base = { ...complete };\n" +
"\t\t\t\treturn [...purge, base]; // [dsh-purge] complete prompt keeps waterfall inject\n" +
"\t\t\t})(completeSection, dshPurgeSections),\n" +
@@ -3334,6 +3335,21 @@ const NEW_TOOL_PATCHES = [
"\t\t};",
replace: COMPLETE_PROMPT_WATERFALL_INJECT,
},
{
pattern:
"\t\tconst transformed = await this.ctx.waterfall(scopeTarget(this, scope), \"system-prompt/assemble\", assembly, context, () => Promise.resolve(assembly));\n" +
"\t\tconst dshPurgeSections = (transformed.sections || []).filter((s) => String(s && s.name || \"\").startsWith(\"dsh-purge\") && String(s.text || \"\").length > 0);\n" +
"\t\tif (completeSection === void 0 && !runtimeContextSuppressed) return transformed;\n" +
"\t\treturn {\n" +
"\t\t\t...transformed,\n" +
"\t\t\tsections: completeSection === void 0 ? transformed.sections : (function (complete, purge) {\n" +
"\t\t\t\tconst base = { ...complete };\n" +
"\t\t\t\treturn [...purge, base]; // [dsh-purge] complete prompt keeps waterfall inject\n" +
"\t\t\t})(completeSection, dshPurgeSections),\n" +
"\t\t\tcontexts: runtimeContextSuppressed ? [] : transformed.contexts\n" +
"\t\t};",
replace: COMPLETE_PROMPT_WATERFALL_INJECT,
},
],
forbid: ["dsh-purge:committed"],
markers: ["complete prompt keeps waterfall inject"],
@@ -3911,6 +3927,30 @@ const NEW_TOOL_PATCHES = [
],
markers: ["[dsh-purge] system prompt replaces the first node"],
},
{
id: 74,
name: "ASSEMBLE_BEFORE_PRESTEP",
layer: "代码",
layer_en: "Code",
desc: "每个模式的第一次发送前先挂上默认提示词 / hang the default prompt before the first assemble",
file: ["agent-loop"],
skipIfMarked: true,
replacements: [
{
pattern:
"\t\tconst claimed = this.inbox.claim(target, position.turn);\n" +
"\t\tconst assembly = await this.loopCtx.systemPrompt.assemble(assembleContextFor(this, signal));",
replace:
"\t\tconst claimed = this.inbox.claim(target, position.turn);\n" +
"\t\tconst dshPurgePrepare = globalThis.__dshPurgePrepareAssemble;\n" +
"\t\tif (typeof dshPurgePrepare === \"function\") {\n" +
"\t\t\ttry { dshPurgePrepare(this.loopCtx); } catch { /* [dsh-purge] prepare assemble before this step */ }\n" +
"\t\t}\n" +
"\t\tconst assembly = await this.loopCtx.systemPrompt.assemble(assembleContextFor(this, signal));",
},
],
markers: ["[dsh-purge] prepare assemble before this step"],
},
{
id: 66,
name: "SYSTEM_PROMPT_RENDER_GUARD",
@@ -4179,6 +4219,47 @@ const NEW_TOOL_PATCHES = [
// 锚点还在时也别再 replaceAll。这个文件是前端模块,重复写会改 mtime。
skipIfMarked: true,
replacements: [
{
// 上一版只藏 surface 序号。界面气泡和「用时」挂在回合事件上,序号对不上就还留在聊天里。
pattern:
"\t\t\t\thidden.add(event.seq);\n" +
"\t\t\t\tif (Array.isArray(event.sourceEventSeqs)) {\n" +
"\t\t\t\t\tfor (const seq of event.sourceEventSeqs) hidden.add(seq);\n" +
"\t\t\t\t}\n",
replace:
"\t\t\t\thidden.add(event.seq); // [dsh-purge] rewind hides the cut turn\n" +
"\t\t\t\tconst op = event.surfaceOp;\n" +
"\t\t\t\tif (op && typeof op.startSeq === \"number\" && typeof op.endSeq === \"number\" && op.endSeq >= op.startSeq && op.endSeq - op.startSeq < 100000) {\n" +
"\t\t\t\t\tfor (let seq = op.startSeq; seq <= op.endSeq; seq += 1) hidden.add(seq);\n" +
"\t\t\t\t}\n" +
"\t\t\t\tconst raw = event.sourceEventSeqs;\n" +
"\t\t\t\tif (Array.isArray(raw)) {\n" +
"\t\t\t\t\tfor (const row of raw) {\n" +
"\t\t\t\t\t\tif (typeof row === \"number\") hidden.add(row);\n" +
"\t\t\t\t\t\telse if (Array.isArray(row) && row.length === 2 && typeof row[0] === \"number\" && typeof row[1] === \"number\" && row[1] >= row[0] && row[1] - row[0] < 100000) {\n" +
"\t\t\t\t\t\t\tfor (let seq = row[0]; seq <= row[1]; seq += 1) hidden.add(seq);\n" +
"\t\t\t\t\t\t}\n" +
"\t\t\t\t\t}\n" +
"\t\t\t\t}\n" +
"\t\t\t\tconst cutEnd = op && typeof op.endSeq === \"number\" ? op.endSeq : event.seq;\n" +
"\t\t\t\tlet turnStart = null;\n" +
"\t\t\t\tlet turnEnd = null;\n" +
"\t\t\t\tfor (const row of list) {\n" +
"\t\t\t\t\tconst ev = row && row.event;\n" +
"\t\t\t\t\tif (!ev || ev.seq >= event.seq) continue;\n" +
"\t\t\t\t\tif (ev.type === \"turn/start\") turnStart = ev.seq;\n" +
"\t\t\t\t\tif (ev.type === \"turn/end\" && ev.seq >= cutEnd && turnEnd === null) turnEnd = ev.seq;\n" +
"\t\t\t\t}\n" +
"\t\t\t\tif (turnStart !== null) {\n" +
"\t\t\t\t\tconst last = turnEnd === null ? event.seq : turnEnd;\n" +
"\t\t\t\t\tfor (const row of list) {\n" +
"\t\t\t\t\t\tconst ev = row && row.event;\n" +
"\t\t\t\t\t\tif (!ev || ev.seq < turnStart || ev.seq > last) continue;\n" +
"\t\t\t\t\t\tif (ev.type === \"system/message\") continue;\n" +
"\t\t\t\t\t\thidden.add(ev.seq);\n" +
"\t\t\t\t\t}\n" +
"\t\t\t\t}\n",
},
{
pattern:
"\t\tfunction rewindVisibleEntries(entries) {\n" +
@@ -4247,7 +4328,7 @@ const NEW_TOOL_PATCHES = [
"\t\t\t\tconst event = entry && entry.event;\n" +
"\t\t\t\treturn !!event && !hidden.has(event.seq);\n" +
"\t\t\t});\n" +
"\t\t} // [dsh-purge] rewind hides only the cut range",
"\t\t} // [dsh-purge] rewind hides the cut turn",
},
{
pattern:
@@ -4312,7 +4393,7 @@ const NEW_TOOL_PATCHES = [
"\t\t\t\tconst event = entry && entry.event;\n" +
"\t\t\t\treturn !!event && !hidden.has(event.seq);\n" +
"\t\t\t});\n" +
"\t\t} // [dsh-purge] rewind hides only the cut range\n" +
"\t\t} // [dsh-purge] rewind hides the cut turn\n" +
"\t\tvar ConversationNodeAssembler = class {",
},
{
@@ -4325,7 +4406,7 @@ const NEW_TOOL_PATCHES = [
"\t\t\t\tthis.contexts.clear();",
},
],
markers: ["[dsh-purge] rewind hides only the cut range"],
markers: ["[dsh-purge] rewind hides the cut turn"],
},
{
id: 57,