mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 11:10:22 +08:00
fix: 发布 1.1.45,稳住默认注入并修正清洗进度显示。
点应用即写入默认提示词,不必先保存。剥掉外层 project_instructions 壳并钉死会话系统提示,避免第二轮注入失效。未定位宿主不再显示 0/63,本机不需要的项计入已就绪。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
21dfd934a4
commit
f2c244c78f
36 files changed
+2309
-738
No files matched your search
+40
-5
@@ -8,6 +8,7 @@ import * as reapply from "./reapply.js";
|
||||
import * as officialUpdate from "./official-update.js";
|
||||
import {
|
||||
GLOBAL_PROMPT_ORDER,
|
||||
clearPinnedSystemPrompt,
|
||||
isMnemonPluginMessage,
|
||||
isRedteamSession,
|
||||
rewritePromptAssembly,
|
||||
@@ -17,6 +18,7 @@ import * as rewind from "./rewind.js";
|
||||
import * as continueRetry from "./continue-retry.js";
|
||||
import * as uninstaller from "./uninstall.js";
|
||||
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
|
||||
import * as refusalRecover from "./refusal-recover.js";
|
||||
|
||||
export const name = "dsh-purge";
|
||||
|
||||
@@ -39,6 +41,9 @@ const DEFAULTS = {
|
||||
autoContinue: true,
|
||||
continueMax: 3,
|
||||
continueText: "继续",
|
||||
refusalRecover: true,
|
||||
refusalRecoverMax: 2,
|
||||
refusalRecoverText: "",
|
||||
};
|
||||
|
||||
const log = (config, ...args) => {
|
||||
@@ -47,6 +52,7 @@ const log = (config, ...args) => {
|
||||
|
||||
let webTreeReady = false;
|
||||
let continueRuntime = null;
|
||||
let refusalRecoverRuntime = null;
|
||||
let savedContinueSettings = {};
|
||||
let continuePluginCfg = { ...DEFAULTS };
|
||||
|
||||
@@ -132,7 +138,7 @@ function renderStatus(state) {
|
||||
out.push(line("注入文件 / inject", state.override_path));
|
||||
out.push(line("注入状态 / override", state.override_status));
|
||||
out.push("");
|
||||
out.push(`补丁 / patches: ${state.patches_applied}/${core.ALL_PATCHES.length} applied, ${state.patches_pending} pending`);
|
||||
out.push(`补丁 / patches: ${state.patches_applied}/${state.patches_total || core.ALL_PATCHES.length} applied, ${state.patches_pending} pending`);
|
||||
for (const p of core.ALL_PATCHES) {
|
||||
const s = state.patch_status[p.id];
|
||||
const mark = s === "applied" ? "✓" : s === "pending" ? "✗" : "·";
|
||||
@@ -323,6 +329,12 @@ function installIdentityOverride(ctx, config = {}) {
|
||||
};
|
||||
// 只挂一次。不改 contexts,不改 pre-step 白名单,梁神 phase-1 和其它插件的消息原样保留。
|
||||
ctx.on("system-prompt/assemble", hook, { global: true, prepend: true });
|
||||
try {
|
||||
ctx.on("session/created", (session) => {
|
||||
const id = session?.id ?? session?.header?.id;
|
||||
if (id != null && id !== "") clearPinnedSystemPrompt(id);
|
||||
});
|
||||
} catch { /* ignore */ }
|
||||
// 0.1.5 起 complete:true 在 waterfall 之后用调用前的快照盖掉 sections。
|
||||
// 换宿主版本时文件补丁还没写上,或换插件版本时旧钩子把 dsh-purge 段删掉,注入都会丢。
|
||||
// 包住 assemble 的返回值,按 prompt-inject.md 再补回。
|
||||
@@ -472,6 +484,8 @@ async function handlePurgeCommand(rawInput, config) {
|
||||
} else {
|
||||
handoff = core.sealedAsarHandoff();
|
||||
}
|
||||
core.seedOverrideSync(state.dsh_home);
|
||||
await core.ensureOverrideContent(state.dsh_home, false);
|
||||
const blocked = rejectIfNeedPrompt(state.dsh_home);
|
||||
if (blocked) return { kind: "error", text: blocked.error };
|
||||
await core.backupAll(state.ai_base);
|
||||
@@ -815,6 +829,16 @@ export function apply(ctx, config) {
|
||||
}
|
||||
installIdentityOverride(ctx, cfg);
|
||||
installRegionGate(ctx);
|
||||
try {
|
||||
refusalRecoverRuntime?.dispose?.();
|
||||
} catch { /* ignore */ }
|
||||
refusalRecoverRuntime = refusalRecover.installRefusalRecover(ctx, {
|
||||
getConfig: () => ({
|
||||
enabled: cfg.refusalRecover !== false,
|
||||
maxPerTurn: cfg.refusalRecoverMax ?? DEFAULTS.refusalRecoverMax,
|
||||
recoverText: cfg.refusalRecoverText ?? DEFAULTS.refusalRecoverText,
|
||||
}),
|
||||
});
|
||||
installFreshFullAccess(ctx);
|
||||
installRewindDeriveFilter(ctx);
|
||||
installMnemonMessageStrip(ctx, cfg);
|
||||
@@ -930,6 +954,8 @@ export function apply(ctx, config) {
|
||||
const scrubbed = core.sanitizeDesktopCommandRuntimes();
|
||||
const state = await core.gatherState();
|
||||
if (!state.ai_base) return { text: "ERROR: " + core.missingAiBaseMessage() };
|
||||
core.seedOverrideSync(state.dsh_home);
|
||||
await core.ensureOverrideContent(state.dsh_home, false);
|
||||
const blocked = rejectIfNeedPrompt(state.dsh_home);
|
||||
if (blocked) return { text: "ERROR: " + blocked.error };
|
||||
await core.backupAll(state.ai_base);
|
||||
@@ -1053,11 +1079,14 @@ function installWebServer(ctx, cfg) {
|
||||
surface: state.surface || hostctl.currentSurface(),
|
||||
ai_base: state.ai_base,
|
||||
desktop_install: state.desktop_install || "",
|
||||
desktop_exe: state.desktop_exe || "",
|
||||
asar_still_sealed: state.asar_still_sealed || false,
|
||||
missing_ai_base: state.ai_base ? "" : core.missingAiBaseMessage(),
|
||||
patches_applied: state.patches_applied,
|
||||
patches_pending: state.patches_pending,
|
||||
patches_skipped: state.patches_skipped || 0,
|
||||
patches_total: core.ALL_PATCHES.length,
|
||||
patches_na: state.patches_na || 0,
|
||||
patches_total: state.patches_total || core.ALL_PATCHES.length,
|
||||
patch_status: state.patch_status,
|
||||
patch_names,
|
||||
shim_cmd: state.shim_cmd,
|
||||
@@ -1279,8 +1308,14 @@ function installWebServer(ctx, cfg) {
|
||||
handoff = core.sealedAsarHandoff();
|
||||
}
|
||||
const body = await readJsonBody(request);
|
||||
// 点应用就落下默认提示词;框空时用内置默认,不必先点保存。
|
||||
core.seedOverrideSync(state.dsh_home);
|
||||
await core.ensureOverrideContent(state.dsh_home, false);
|
||||
const ui = await core.readOverrideForUi(state.dsh_home);
|
||||
const boxText = typeof body?.content === "string" ? body.content : ui.content;
|
||||
const incoming = typeof body?.content === "string" ? body.content : "";
|
||||
const boxText = core.normalizeOverride(incoming)
|
||||
? incoming
|
||||
: (ui.content || ui.defaultContent || "");
|
||||
const blocked = rejectIfNeedPrompt(state.dsh_home, boxText);
|
||||
if (blocked) {
|
||||
sendJson(response, 400, {
|
||||
@@ -1292,8 +1327,8 @@ function installWebServer(ctx, cfg) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeof body?.content === "string" && core.normalizeOverride(body.content)) {
|
||||
await core.saveOverrideContent(state.dsh_home, body.content);
|
||||
if (core.normalizeOverride(boxText)) {
|
||||
await core.saveOverrideContent(state.dsh_home, boxText);
|
||||
}
|
||||
await core.backupAll(state.ai_base);
|
||||
const report = await core.applyPatches(state.ai_base);
|
||||
|
||||
Reference in new issue
Block a user