fix: 发布 1.1.36,解决红队模式拒绝问题

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-29 00:13:29 +08:00
1 parent 065d00633b
commit 776812569a
7 files changed
+62 -6

No files matched your search

+31 -1
View File
@@ -106,6 +106,33 @@ function ensureFullInject(sections, inject) {
return [{ name: "dsh-purge", text: inject, order: -10000 }, ...sections];
}
/** 红队预设里要留下来的操作说明起点。这句前面的「你是红队指挥」身份句丢掉。 */
const REDTEAM_OPS_MARK = "## 运行环境前提";
function redteamOpsBody(text) {
const raw = String(text || "");
const at = raw.indexOf(REDTEAM_OPS_MARK);
if (at < 0) return null;
return raw.slice(at).trim();
}
/**
* 主模式仍只有清洗提示词。
* 红队模式把同一份清洗提示词放在最前,后面只接派活和操作说明,不保留红队身份句。
*/
function attachInjectToRedteamPersona(sections, inject) {
let attached = false;
const next = sections.map((section) => {
const ops = redteamOpsBody(section?.text);
if (ops == null) return section;
attached = true;
const text = inject ? `${inject}\n\n${ops}` : ops;
return { ...section, text, order: -10000 };
});
if (!attached) return sections;
return next.filter((section) => section?.name !== "dsh-purge");
}
function stripIdentityPrefix(text) {
let rest = String(text || "").trim();
if (rest.startsWith(IDENTITY_CARD_PREFIX)) {
@@ -274,6 +301,9 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options =
const extras = opts.dropPurgeAfterFold
? purge.filter((section) => section.name !== "dsh-purge")
: purge;
assembled.sections = ensureFullInject([...folded, ...extras], injectText);
assembled.sections = ensureFullInject(
attachInjectToRedteamPersona([...folded, ...extras], injectText),
injectText,
);
return assembled;
}