mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 07:40:22 +08:00
fix: 发布 1.1.41,官方模式与红队分开注入,回退留在当前会话。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3bc63beca4
commit
eed95f79cb
13 files changed
+1442
-423
No files matched your search
+16
-5
@@ -181,16 +181,27 @@ export function overrideFileText(dshHome) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 提示词优先;为空则用当前启用的规则集。两边都空则不注入。 */
|
||||
/** 没启用规则集时只注入可编辑提示词。启用规则集后以规则集为主。两边都空则不注入。 */
|
||||
export function resolveInjectText(dshHome) {
|
||||
const prompt = overrideFileText(dshHome);
|
||||
if (normalizeOverride(prompt)) return { text: prompt, source: "prompt", ruleId: null };
|
||||
const ruleId = activeRuleId(dshHome);
|
||||
const rule = activeRuleText(dshHome);
|
||||
if (normalizeOverride(rule)) return { text: rule, source: "rule", ruleId };
|
||||
const rule = normalizeOverride(activeRuleText(dshHome));
|
||||
if (rule) return { text: rule, source: "rule", ruleId };
|
||||
const prompt = normalizeOverride(overrideFileText(dshHome));
|
||||
if (prompt) return { text: prompt, source: "prompt", ruleId: null };
|
||||
return { text: "", source: "none", ruleId };
|
||||
}
|
||||
|
||||
/** 红队在当前正文之外,再带上另一份没有重复的提示词或规则集。 */
|
||||
export function resolveModeInject(dshHome, redteam) {
|
||||
const prompt = normalizeOverride(overrideFileText(dshHome));
|
||||
const rule = normalizeOverride(activeRuleText(dshHome));
|
||||
if (!redteam) return rule || prompt;
|
||||
const parts = [];
|
||||
if (prompt) parts.push(prompt);
|
||||
if (rule && rule !== prompt) parts.push(rule);
|
||||
return parts.join("\n\n");
|
||||
}
|
||||
|
||||
export async function activateRule(dshHome, id) {
|
||||
const content = await readRule(dshHome, id);
|
||||
if (content === null) throw new Error(`rule not found: ${id}`);
|
||||
|
||||
Reference in new issue
Block a user