fix: 回退只撤最后一轮,提示词只保留一份。

解包改到旁边的目录,失败时放回上一份。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-01 13:10:15 +08:00
1 parent 3cede10253
commit 10a597d6ff
8 files changed
+354 -45

No files matched your search

+22 -5
View File
@@ -98,6 +98,10 @@ function stripHarnessPersona(text) {
/You are a coding agent powered by the \{\{model\}\} model\. Your working directory is \{\{cwd\}\}\.?\s*/g,
"Working directory: {{cwd}}. ",
)
.replace(
/The DeepSeek Harness implementation checkout is at [\s\S]*?Use this checkout only to inspect or extend DSH itself\.?\s*/g,
"",
)
.replace(
/You are a coding agent powered by the [^\n.]+ model, running on the DeepSeek Harness\.?\s*/g,
"",
@@ -140,19 +144,34 @@ function withoutRedteamPreset(sections) {
});
}
/** 每次组装都把提示词放到最前。已经嵌在后面的同一份正文拆出来,避免宿主段落挡在前面。 */
const OWN_SERVER_MARK = "OWN SERVERS — EXACT LIST ONLY";
function injectNeedles(inject) {
const text = String(inject || "").trim();
if (!text) return [];
const at = text.indexOf(OWN_SERVER_MARK);
const base = at >= 0 ? text.slice(0, at).trim() : "";
const needles = [text];
if (base && base !== text) needles.push(base);
return needles;
}
/** 每次组装都把提示词放到最前。后面段落里的同一份正文拆掉,避免再拼一份。 */
function leadWithInject(sections, inject) {
const text = String(inject || "").trim();
if (!text) return sections;
const needles = injectNeedles(text);
const rest = [];
for (const section of sections) {
if (!section || section.name === "dsh-purge") continue;
const body = typeof section.text === "string" ? section.text : "";
if (!body.includes(text)) {
if (!needles.some((needle) => body.includes(needle))) {
rest.push(section);
continue;
}
const next = body.split(text).join("").replace(/\n{3,}/g, "\n\n").trim();
let next = body;
for (const needle of needles) next = next.split(needle).join("");
next = next.replace(/\n{3,}/g, "\n\n").trim();
if (!next) continue;
rest.push({ ...section, text: next });
}
@@ -418,8 +437,6 @@ function foldInjectIntoPersona(sections, injectText) {
return [{ name: "deployment:persona-prefix", text: inject, order }, ...out];
}
const OWN_SERVER_MARK = "OWN SERVERS — EXACT LIST ONLY";
function withOwnServers(injectText) {
const text = String(injectText || "").trim();
if (!text) return text;