mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 09:30:22 +08:00
fix: 发布 1.1.44,提示词按模式注入并让子代理吃到同一份。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b47ebfb976
commit
2ecce304db
10 files changed
+816
-221
No files matched your search
+17
-7
@@ -12,7 +12,7 @@ import {
|
||||
isRedteamSession,
|
||||
rewritePromptAssembly,
|
||||
} from "./identity.js";
|
||||
import { installSubagentRoleCapture } from "./redteam/role-section.js";
|
||||
import { installSubagentRoleCapture, resolveSubagentRoleText } from "./redteam/role-section.js";
|
||||
import * as rewind from "./rewind.js";
|
||||
import * as continueRetry from "./continue-retry.js";
|
||||
import * as uninstaller from "./uninstall.js";
|
||||
@@ -188,9 +188,9 @@ export function registerPromptSections(ctx, config, _injectFile) {
|
||||
name: "dsh-purge",
|
||||
order: GLOBAL_PROMPT_ORDER,
|
||||
interpolate: false,
|
||||
text: () => {
|
||||
text: (context) => {
|
||||
if (!injectAllowedNow(config)) return "";
|
||||
return rules.resolveInjectText(core.findDshHome()).text;
|
||||
return rules.resolveModeInject(core.findDshHome(), isRedteamSession(context));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -234,21 +234,30 @@ function installMnemonMessageStrip(ctx, config = {}) {
|
||||
|
||||
function rewriteLiveAssembly(config, assembled, context) {
|
||||
const enabled = config.enabled !== false;
|
||||
const redteam = enabled && isRedteamSession(context);
|
||||
const inject = enabled ? readInjectFallback(context) : "";
|
||||
return rewritePromptAssembly(assembled, {
|
||||
fallbackInject: inject,
|
||||
dropMnemon: config.stripMnemon !== false,
|
||||
dropPurgeAfterFold: false,
|
||||
context,
|
||||
roleText: redteam ? resolveSubagentRoleText(context) : "",
|
||||
});
|
||||
}
|
||||
|
||||
function permissionPresetsOf(ctx) {
|
||||
if (ctx?.permissionPresets && typeof ctx.permissionPresets.set === "function") return ctx.permissionPresets;
|
||||
try {
|
||||
const direct = ctx?.permissionPresets;
|
||||
if (direct && typeof direct.set === "function") return direct;
|
||||
} catch {
|
||||
/* 未 inject 这项服务时,Cordis 代理会抛,不能让新会话的全开权限钉死失败。 */
|
||||
}
|
||||
try {
|
||||
const svc = ctx?.get?.("permissionPresets");
|
||||
if (svc && typeof svc.set === "function") return svc;
|
||||
} catch {}
|
||||
} catch {
|
||||
/* 没有这项服务。 */
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -318,8 +327,9 @@ function shimNeedsPatch(state) {
|
||||
}
|
||||
|
||||
async function settleInstalledPatches(config, ctx) {
|
||||
try { core.rememberUnpackedArchive(); } catch { /* 没有官方安装目录时不必记归档 */ }
|
||||
if (officialUpdate.upgradeMarkerExists(process.execPath)) {
|
||||
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, forceExtract: true });
|
||||
const upgraded = await reapply.reapplyInstalled({ scheduleSwap: false, upgrade: true });
|
||||
if (!upgraded.ok) {
|
||||
log(config, "official upgrade reapply failed:", upgraded.error || "");
|
||||
return "reapply-failed";
|
||||
@@ -1262,7 +1272,7 @@ function installWebServer(ctx, cfg) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeof body?.content === "string") {
|
||||
if (typeof body?.content === "string" && core.normalizeOverride(body.content)) {
|
||||
await core.saveOverrideContent(state.dsh_home, body.content);
|
||||
}
|
||||
await core.backupAll(state.ai_base);
|
||||
|
||||
Reference in new issue
Block a user