mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 06:40:22 +08:00
1.1.79: 修复 bug,修复稳定性(#165 #166 #167)
This commit is contained in:
1 parent
add692e491
commit
82da559cff
17 files changed
+872
-185
No files matched your search
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Apply / 还原 / 卸载的内存进度。
|
||||
* 只给 /dsh-purge/status 轮询用,不落盘,也不进 gatherState。
|
||||
*/
|
||||
const IDLE = Object.freeze({
|
||||
active: false,
|
||||
kind: "apply",
|
||||
stage: "idle",
|
||||
detail: "",
|
||||
applied: 0,
|
||||
total: 0,
|
||||
error: "",
|
||||
startedAt: 0,
|
||||
updatedAt: 0,
|
||||
});
|
||||
|
||||
let current = { ...IDLE };
|
||||
|
||||
export function getApplyProgress() {
|
||||
return { ...current };
|
||||
}
|
||||
|
||||
export function beginJob(kind = "apply", stage = "home") {
|
||||
const now = Date.now();
|
||||
current = {
|
||||
active: true,
|
||||
kind,
|
||||
stage,
|
||||
detail: "",
|
||||
applied: 0,
|
||||
total: 0,
|
||||
error: "",
|
||||
startedAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
return getApplyProgress();
|
||||
}
|
||||
|
||||
export function beginApply(stage = "home") {
|
||||
return beginJob("apply", stage);
|
||||
}
|
||||
|
||||
export function setApplyProgress(patch = {}) {
|
||||
current = {
|
||||
...current,
|
||||
...patch,
|
||||
active: patch.active == null ? true : Boolean(patch.active),
|
||||
updatedAt: Date.now(),
|
||||
};
|
||||
return getApplyProgress();
|
||||
}
|
||||
|
||||
export function endApply(patch = {}) {
|
||||
current = {
|
||||
...current,
|
||||
...patch,
|
||||
active: false,
|
||||
updatedAt: Date.now(),
|
||||
};
|
||||
return getApplyProgress();
|
||||
}
|
||||
|
||||
export function resetApplyProgress() {
|
||||
current = { ...IDLE, updatedAt: Date.now() };
|
||||
return getApplyProgress();
|
||||
}
|
||||
@@ -21,28 +21,12 @@ const OFFICIAL_PROTOCOL = `## Capability selection by task (mandatory)
|
||||
5. **Subagents / sub-delegates inherit this rule**: Any \`subagent\`, teammate, or child agent you start must also read the catalog and call task-matched skills/MCP the same way. Put that requirement in the child brief when you dispatch.
|
||||
6. Host skills and MCP stay available; this prompt does not remove them.`;
|
||||
|
||||
const REDTEAM_LEAD_PROTOCOL = `## Capability selection by task (redteam lead)
|
||||
|
||||
1. You plan, dispatch with \`subagent\`, verify results, and report. Executors do hands-on work.
|
||||
2. Before dispatch, know which skills/MCP fit the next stage (from \`<available_skills>\` / redteam skills / session MCP).
|
||||
3. In every \`subagent\` brief: require the child to **read the skill/MCP catalog, then call only what the assigned task needs** (name concrete skill codes when you know them).
|
||||
4. Do not ban skill or MCP for children. Leaf limits apply only to further delegation tools (\`subagent_fork\` / workflow / ralph), not to skill/MCP.
|
||||
5. Vague “go investigate” briefs are wrong; task-matched skill/MCP instructions are right.`;
|
||||
|
||||
const REDTEAM_CHILD_PROTOCOL = `## Capability selection by task (redteam executor)
|
||||
|
||||
1. **Read** \`<available_skills>\` / your role skills and available MCP/CLI tools.
|
||||
2. **Match** them to *your assigned task* (not every skill, not zero skills).
|
||||
3. **Call** matching skills via \`skill\`, and matching MCP/CLI tools by schema, before freelancing equivalent shell work.
|
||||
4. DIY only for gaps the catalog does not cover; stay in role; do not re-delegate.`;
|
||||
|
||||
/**
|
||||
* 主智能体和子智能体同一份。红队调度正文仍在预设 ops 里,这里不按身份拆协议。
|
||||
* @param {{ redteam?: boolean, redteamChild?: boolean, enabled?: boolean }} [opts]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function capabilityProtocolText(opts = {}) {
|
||||
if (opts.enabled === false) return "";
|
||||
if (opts.redteamChild) return REDTEAM_CHILD_PROTOCOL;
|
||||
if (opts.redteam) return REDTEAM_LEAD_PROTOCOL;
|
||||
return OFFICIAL_PROTOCOL;
|
||||
}
|
||||
+13
-4
@@ -2008,6 +2008,13 @@ export async function applyPatchesAllHosts(patches = ALL_PATCHES, options = {})
|
||||
hostWritten: hostCleanMarkersPresent(aiBase),
|
||||
flash: silenceCmdFlash(aiBase),
|
||||
});
|
||||
if (typeof options.onHost === "function") {
|
||||
try {
|
||||
options.onHost({ index: hosts.length, aiBase });
|
||||
} catch {
|
||||
/* 进度回调失败不能中断清洗 */
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
hosts,
|
||||
@@ -2053,9 +2060,9 @@ export function missingAiBaseMessage() {
|
||||
}
|
||||
return `已找到桌面应用 ${exe},但其 resources/app(或 app.asar.unpacked)下没有 @deepseek-ai`;
|
||||
}
|
||||
return "未定位到当前桌面应用的 @deepseek-ai。官方客户端点「应用」会解开 app.asar 并重启;第三方 DSH Desktop 直接点「应用」。安装目录任意盘符。";
|
||||
return "未定位到当前桌面应用的 @deepseek-ai。官方客户端点「应用」会解开 app.asar 并重启;第三方 DSH Desktop / DS Bot 直接点「应用」。安装目录任意盘符。";
|
||||
}
|
||||
return "插件根未找到 / set DSH_BASE";
|
||||
return "插件根未找到 / set DSH_BASE。社区 Electron(DS Bot)若报这句,点「应用」解开 app.asar,或把 DSH_BASE 指到 resources/app 下的 @deepseek-ai。";
|
||||
}
|
||||
|
||||
function aiBaseUnderAppDir(appDir) {
|
||||
@@ -2365,8 +2372,10 @@ export function desktopAsarStillSealed(input = {}) {
|
||||
|
||||
export function findAiBase() {
|
||||
return remember("ai", () => {
|
||||
if (adapterFor(detectSurface()) === "desktop") return findAiBaseDesktop();
|
||||
return findAiBaseWeb();
|
||||
const desktopFirst = adapterFor(detectSurface()) === "desktop";
|
||||
const primary = desktopFirst ? findAiBaseDesktop() : findAiBaseWeb();
|
||||
if (primary) return primary;
|
||||
return desktopFirst ? findAiBaseWeb() : findAiBaseDesktop();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+35
-5
@@ -124,8 +124,14 @@ export function looksLikeDesktopName(p) {
|
||||
/\/deepseek[\s._-]*harness(\/|$)/.test(n) ||
|
||||
n.includes("/deepseek harness.app/") ||
|
||||
n.endsWith("/deepseek harness.app") ||
|
||||
n.includes("/deepseek bot/") ||
|
||||
n.includes("/deepseek-bot/") ||
|
||||
n.includes("/ds-bot/") ||
|
||||
n.endsWith("/deepseek bot") ||
|
||||
n.endsWith("/deepseek bot.app") ||
|
||||
/\/dsh desktop\.exe$/i.test(n) ||
|
||||
/\/deepseek[\s._-]*harness\.exe$/i.test(n)
|
||||
/\/deepseek[\s._-]*harness\.exe$/i.test(n) ||
|
||||
/\/deepseek[\s._-]*bot\.exe$/i.test(n)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -163,7 +169,12 @@ export function looksLikeDesktopNameTail(p) {
|
||||
tail === "deepseek-harness" ||
|
||||
tail === "deepseekharness" ||
|
||||
/^dsh-desktop/.test(tail) ||
|
||||
/^deepseek[\s._-]*harness(\.exe)?$/.test(tail)
|
||||
/^deepseek[\s._-]*harness(\.exe)?$/.test(tail) ||
|
||||
tail === "deepseek bot" ||
|
||||
tail === "deepseek bot.app" ||
|
||||
tail === "deepseek-bot" ||
|
||||
tail === "ds-bot" ||
|
||||
/^deepseek[\s._-]*bot(\.exe)?$/.test(tail)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -175,6 +186,7 @@ export function isDesktopExecutable(fp) {
|
||||
const base = path.basename(String(fp || "")).toLowerCase();
|
||||
if (base === "dsh desktop.exe" || base === "dsh desktop") return true;
|
||||
if (OFFICIAL_HARNESS_BASES.has(base)) return true;
|
||||
if (/^deepseek[\s._-]*bot(\.exe)?$/.test(base) || /^ds[\s._-]*bot(\.exe)?$/.test(base)) return true;
|
||||
return /^deepseek[\s._-]*harness(\.exe)?$/.test(base);
|
||||
}
|
||||
|
||||
@@ -237,12 +249,17 @@ function exeCandidatesBeside(dir) {
|
||||
path.join(dir, "deepseek-harness"),
|
||||
path.join(dir, "DSH Desktop.exe"),
|
||||
path.join(dir, "DSH Desktop"),
|
||||
path.join(dir, "DeepSeek Bot.exe"),
|
||||
path.join(dir, "DeepSeek-Bot.exe"),
|
||||
path.join(dir, "DeepSeek Bot"),
|
||||
path.join(dir, "MacOS", "DeepSeek Harness"),
|
||||
path.join(dir, "MacOS", "deepseek-harness"),
|
||||
path.join(dir, "MacOS", "DSH Desktop"),
|
||||
path.join(dir, "MacOS", "DeepSeek Bot"),
|
||||
path.join(dir, "Contents", "MacOS", "DeepSeek Harness"),
|
||||
path.join(dir, "Contents", "MacOS", "deepseek-harness"),
|
||||
path.join(dir, "Contents", "MacOS", "DSH Desktop"),
|
||||
path.join(dir, "Contents", "MacOS", "DeepSeek Bot"),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -307,7 +324,7 @@ function trustedInstallDir(dir) {
|
||||
|
||||
const REGISTRY_INSTALL_SCRIPT = `
|
||||
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
|
||||
$names = @('DeepSeek Harness','DSH Desktop')
|
||||
$names = @('DeepSeek Harness','DSH Desktop','DeepSeek Bot','DS Bot')
|
||||
$roots = @(
|
||||
'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
|
||||
'HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
|
||||
@@ -568,17 +585,21 @@ export function commonDesktopInstallDirs(env = process.env, input = {}) {
|
||||
...extraDiscoveredInstallDirs(env, { discover }),
|
||||
path.join(local, "Programs", "DeepSeek Harness"),
|
||||
path.join(local, "Programs", "DSH Desktop"),
|
||||
path.join(local, "Programs", "DeepSeek Bot"),
|
||||
path.join(local, "DeepSeek Harness"),
|
||||
path.join(local, "DeepSeek Bot"),
|
||||
...(pf
|
||||
? [path.join(pf, "DeepSeek Harness"), path.join(pf, "DSH Desktop")]
|
||||
? [path.join(pf, "DeepSeek Harness"), path.join(pf, "DSH Desktop"), path.join(pf, "DeepSeek Bot")]
|
||||
: []),
|
||||
...(pf86
|
||||
? [path.join(pf86, "DeepSeek Harness"), path.join(pf86, "DSH Desktop")]
|
||||
? [path.join(pf86, "DeepSeek Harness"), path.join(pf86, "DSH Desktop"), path.join(pf86, "DeepSeek Bot")]
|
||||
: []),
|
||||
"/Applications/DeepSeek Harness.app",
|
||||
"/Applications/DSH Desktop.app",
|
||||
"/Applications/DeepSeek Bot.app",
|
||||
path.join(home, "Applications", "DeepSeek Harness.app"),
|
||||
path.join(home, "Applications", "DSH Desktop.app"),
|
||||
path.join(home, "Applications", "DeepSeek Bot.app"),
|
||||
"/opt/DeepSeek Harness",
|
||||
"/opt/deepseek-harness",
|
||||
"/usr/lib/DeepSeek Harness",
|
||||
@@ -655,6 +676,15 @@ export function findDesktopAppExecutable(input = {}) {
|
||||
|
||||
if (isDesktopExecutable(execPath) && isFile(execPath)) return path.normalize(execPath);
|
||||
|
||||
const electron = (input.versions ?? process.versions)?.electron;
|
||||
if (
|
||||
electron
|
||||
&& isFile(execPath)
|
||||
&& !/^node(\.exe)?$/i.test(path.basename(execPath))
|
||||
) {
|
||||
return path.normalize(execPath);
|
||||
}
|
||||
|
||||
if (resourcesPath) {
|
||||
const hit = firstExistingExe([path.dirname(path.normalize(resourcesPath))]);
|
||||
if (hit) return hit;
|
||||
|
||||
+6
-10
@@ -507,10 +507,11 @@ function mountedPresetId(context) {
|
||||
}
|
||||
|
||||
export function sessionAgentPreset(context) {
|
||||
const session = sessionOfContext(context);
|
||||
// 先看这一轮已经挂上的预设,再看用户选过的事件。
|
||||
// 投影和会话头经常停在创建时的 standard,不能拿它们盖住当前选择。
|
||||
const mounted = mountedPresetId(context);
|
||||
const own = sessionOfContext(context);
|
||||
const session = sessionForInject(context) || own;
|
||||
// 子会话沿父会话读预设。子自己的 mounted/standard 不能盖住父会话的红队/极简。
|
||||
const walked = Boolean(session && own && session !== own);
|
||||
const mounted = walked ? "" : mountedPresetId(context);
|
||||
if (mounted) return mounted;
|
||||
let selected = "";
|
||||
for (const event of eventList(session)) {
|
||||
@@ -527,10 +528,6 @@ export function sessionAgentPreset(context) {
|
||||
}
|
||||
|
||||
export function isRedteamSession(context) {
|
||||
const session = sessionForInject(context);
|
||||
if (session && session !== sessionOfContext(context)) {
|
||||
return isRedteamPresetId(sessionAgentPreset({ session }));
|
||||
}
|
||||
return isRedteamPresetId(sessionAgentPreset(context));
|
||||
}
|
||||
|
||||
@@ -953,7 +950,6 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options =
|
||||
}
|
||||
|
||||
const redteam = isRedteamSession(opts.context) || assemblyLooksRedteam(originalSections);
|
||||
const redteamChild = redteam && isRedteamSubagent(opts.context);
|
||||
const rawInject = modePromptText(collectInjectText(purge, opts.fallbackInject), redteam);
|
||||
const injectText = escapeDshInterpolation(
|
||||
peelChatmlEnvelope(adaptInjectForMinimalPreset(withOwnServers(rawInject), opts.context)),
|
||||
@@ -962,7 +958,7 @@ export function rewritePromptAssembly(assembled, fallbackInject = "", options =
|
||||
? ""
|
||||
: capabilityProtocolText({
|
||||
redteam,
|
||||
redteamChild,
|
||||
redteamChild: false,
|
||||
enabled: true,
|
||||
});
|
||||
// #29: 不要把上一条 system/message 全文钉回 sections。
|
||||
|
||||
+119
-8
@@ -41,6 +41,15 @@ import {
|
||||
settleMayRestart,
|
||||
watchContextLife,
|
||||
} from "./settle-policy.js";
|
||||
import { ensureAllProfileInstall } from "./profile-insert.js";
|
||||
import {
|
||||
beginApply,
|
||||
beginJob,
|
||||
endApply,
|
||||
getApplyProgress,
|
||||
resetApplyProgress,
|
||||
setApplyProgress,
|
||||
} from "./apply-progress.js";
|
||||
|
||||
export const name = "dsh-purge";
|
||||
|
||||
@@ -75,6 +84,7 @@ const log = (config, ...args) => {
|
||||
};
|
||||
|
||||
let webTreeReady = false;
|
||||
let lastStatusPayload = null;
|
||||
|
||||
function watchWebTreeReady(ctx) {
|
||||
// 必须挂在 connection 上再 await,与官方打印 URL 同一时刻。
|
||||
@@ -406,7 +416,7 @@ export function registerPromptSections(ctx, config) {
|
||||
const redteam = isRedteamSession(context);
|
||||
return capabilityProtocolText({
|
||||
redteam,
|
||||
redteamChild: redteam && context?.agent?.session?.header?.origin === "subagent",
|
||||
redteamChild: false,
|
||||
enabled: true,
|
||||
});
|
||||
},
|
||||
@@ -604,8 +614,27 @@ function permissionPresetsOf(ctx) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function parentPermissionPreset(ctx, session) {
|
||||
const parentId = session?.header?.parentSession;
|
||||
if (!parentId || !ctx) return "";
|
||||
try {
|
||||
const registry = ctx.agents || ctx.get?.("agents");
|
||||
const parent = registry?.get?.(parentId);
|
||||
let parentSession = parent?.session;
|
||||
if (!parentSession) {
|
||||
const store = ctx.get?.("sessions");
|
||||
parentSession = typeof store?.get === "function" ? store.get(parentId) : null;
|
||||
}
|
||||
if (!parentSession) return "";
|
||||
const svc = permissionPresetsOf(ctx);
|
||||
const state = typeof svc?.permissionState === "function" ? svc.permissionState(parentSession) : null;
|
||||
return state?.preset || parentSession?.header?.permissionPreset || "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function shouldKeepFreshFullAccess(session, svc) {
|
||||
if (session?.header?.origin === "subagent") return false;
|
||||
const state = typeof svc.permissionState === "function" ? svc.permissionState(session) : null;
|
||||
const preset = state?.preset;
|
||||
if (preset === "danger-full-access" || preset === "auto" || preset === "custom") return false;
|
||||
@@ -618,7 +647,14 @@ function shouldKeepFreshFullAccess(session, svc) {
|
||||
function upgradeFreshSessionAccess(ctx, session) {
|
||||
try {
|
||||
const svc = permissionPresetsOf(ctx);
|
||||
if (!svc || !shouldKeepFreshFullAccess(session, svc)) return;
|
||||
if (!svc) return;
|
||||
const inherited = parentPermissionPreset(ctx, session);
|
||||
if (inherited) {
|
||||
const state = typeof svc.permissionState === "function" ? svc.permissionState(session) : null;
|
||||
if (state?.preset !== inherited) svc.set(session, inherited);
|
||||
return;
|
||||
}
|
||||
if (!shouldKeepFreshFullAccess(session, svc)) return;
|
||||
svc.set(session, "danger-full-access");
|
||||
} catch (error) {
|
||||
console.warn("[dsh-purge] full-access pin:", error instanceof Error ? error.message : String(error));
|
||||
@@ -626,6 +662,16 @@ function upgradeFreshSessionAccess(ctx, session) {
|
||||
}
|
||||
|
||||
/** 空会话界面按部署默认显示完全权限;建会话时若钉成 workspace-write,发消息后芯片会掉下去。 */
|
||||
function pinExistingSessionAccess(ctx) {
|
||||
try {
|
||||
const store = ctx.get?.("sessions");
|
||||
const all = typeof store?.all === "function" ? store.all()
|
||||
: typeof store?.list === "function" ? store.list()
|
||||
: [];
|
||||
for (const session of all || []) upgradeFreshSessionAccess(ctx, session);
|
||||
} catch { /* 注册表还没起来时等 session/created */ }
|
||||
}
|
||||
|
||||
function installFreshFullAccess(ctx) {
|
||||
if (typeof ctx.on !== "function" || ctx.__dshPurgeFullPin) return;
|
||||
ctx.__dshPurgeFullPin = true;
|
||||
@@ -635,6 +681,7 @@ function installFreshFullAccess(ctx) {
|
||||
try { disposer = ctx.on("session/created", (session) => {
|
||||
queueMicrotask(() => upgradeFreshSessionAccess(ctx, session));
|
||||
}); } catch { /* ignore */ }
|
||||
queueMicrotask(() => pinExistingSessionAccess(ctx));
|
||||
return () => {
|
||||
try { if (typeof disposer === "function") disposer(); } catch { /* ignore */ }
|
||||
delete ctx.__dshPurgeFullPin;
|
||||
@@ -1509,6 +1556,15 @@ export function apply(ctx, config) {
|
||||
return;
|
||||
}
|
||||
log(cfg, "plugin enabled");
|
||||
try {
|
||||
const home = core.pinDshHome() || core.findDshHome();
|
||||
const healed = ensureAllProfileInstall(home);
|
||||
for (const item of healed) {
|
||||
if (item.insert?.wrote || item.bundles?.wrote) {
|
||||
log(cfg, "profile heal:", item.dir, item.insert?.wrote ? "insert" : "", item.bundles?.wrote ? "bundles" : "");
|
||||
}
|
||||
}
|
||||
} catch { /* 自愈失败不挡主入口 */ }
|
||||
core.applyRuntimeEnv();
|
||||
try {
|
||||
const home = core.pinDshHome() || core.findDshHome();
|
||||
@@ -1813,14 +1869,25 @@ function installWebServer(ctx, cfg) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const progress = getApplyProgress();
|
||||
if (progress.active) {
|
||||
const base = lastStatusPayload || { ok: true };
|
||||
sendJson(response, 200, {
|
||||
...base,
|
||||
ok: true,
|
||||
ready: webTreeReady || Boolean(lastStatusPayload),
|
||||
apply_progress: progress,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!webTreeReady) {
|
||||
sendJson(response, 503, { ok: false, ready: false });
|
||||
sendJson(response, 503, { ok: false, ready: false, apply_progress: progress });
|
||||
return;
|
||||
}
|
||||
const state = await core.gatherState();
|
||||
const patch_names = {};
|
||||
for (const p of core.ALL_PATCHES) patch_names[String(p.id)] = p.name;
|
||||
sendJson(response, 200, {
|
||||
const payload = {
|
||||
ok: true,
|
||||
ready: true,
|
||||
surface: state.surface || hostctl.currentSurface(),
|
||||
@@ -1857,9 +1924,11 @@ function installWebServer(ctx, cfg) {
|
||||
...updater.channelPublic(),
|
||||
hooks_deny_bypass: core.getHooksDenySettings().hooksDenyBypass,
|
||||
...(await skills.skillsStatus(core.findDshHome()).catch(() => ({ skills: [] }))),
|
||||
});
|
||||
};
|
||||
lastStatusPayload = payload;
|
||||
sendJson(response, 200, { ...payload, apply_progress: progress });
|
||||
} catch (e) {
|
||||
sendJson(response, 500, { ok: false, error: String(e) });
|
||||
sendJson(response, 500, { ok: false, error: String(e), apply_progress: getApplyProgress() });
|
||||
}
|
||||
},
|
||||
}, "dsh-purge: status");
|
||||
@@ -2011,6 +2080,7 @@ function installWebServer(ctx, cfg) {
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
beginApply("home");
|
||||
try {
|
||||
const body = await readJsonBody(request);
|
||||
const incoming = typeof body?.content === "string" ? body.content : null;
|
||||
@@ -2021,13 +2091,16 @@ function installWebServer(ctx, cfg) {
|
||||
const state = await core.gatherState();
|
||||
if (home) state.dsh_home = home;
|
||||
let located;
|
||||
setApplyProgress({ stage: "locate" });
|
||||
try {
|
||||
located = await core.resolveOfficialAiBase(state.ai_base, { forApply: true });
|
||||
} catch (e) {
|
||||
endApply({ stage: "locate", error: String(e && e.message ? e.message : e) });
|
||||
sendJson(response, 500, { ok: false, error: String(e && e.message ? e.message : e) });
|
||||
return;
|
||||
}
|
||||
if (!located.aiBase) {
|
||||
endApply({ stage: "locate", error: "no_base" });
|
||||
sendJson(response, 500, { ok: false, error: core.missingAiBaseMessage() });
|
||||
return;
|
||||
}
|
||||
@@ -2039,6 +2112,7 @@ function installWebServer(ctx, cfg) {
|
||||
const handoff = located.handoff && located.handoff.swapAsar ? located.handoff : null;
|
||||
const blocked = rejectIfNeedPrompt(state.dsh_home, incoming === null ? undefined : incoming);
|
||||
if (blocked) {
|
||||
resetApplyProgress();
|
||||
const ui = await core.readOverrideForUi(state.dsh_home);
|
||||
sendJson(response, 400, {
|
||||
ok: false,
|
||||
@@ -2049,16 +2123,26 @@ function installWebServer(ctx, cfg) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
setApplyProgress({ stage: "override" });
|
||||
try {
|
||||
await core.commitOverrideOnApply(state.dsh_home, incoming);
|
||||
} catch (e) {
|
||||
console.warn("[dsh-purge] apply override:", String(e && e.message ? e.message : e));
|
||||
}
|
||||
setApplyProgress({ stage: "patch" });
|
||||
const httpMulti = await core.applyPatchesAllHosts(core.ALL_PATCHES, {
|
||||
preserveClientBundles: false,
|
||||
forApply: true,
|
||||
onHost(info) {
|
||||
setApplyProgress({
|
||||
stage: "patch",
|
||||
applied: info.index || 0,
|
||||
detail: info.aiBase || "",
|
||||
});
|
||||
},
|
||||
});
|
||||
const report = httpMulti.report;
|
||||
setApplyProgress({ stage: "shim" });
|
||||
const shim = await core.patchAllShims();
|
||||
let cliRepair = null;
|
||||
try {
|
||||
@@ -2066,6 +2150,7 @@ function installWebServer(ctx, cfg) {
|
||||
} catch (e) {
|
||||
cliRepair = { ok: false, error: String(e && e.message ? e.message : e) };
|
||||
}
|
||||
setApplyProgress({ stage: "flash" });
|
||||
const flash = core.silenceCmdFlash(httpMulti.hosts[0]?.aiBase || state.ai_base);
|
||||
const summary = core.summarizeApplyReport(report);
|
||||
const hostWritten =
|
||||
@@ -2088,6 +2173,7 @@ function installWebServer(ctx, cfg) {
|
||||
else bootFullQuit = false;
|
||||
if (shouldRestart) reapply.markSettleRestart();
|
||||
let promptInjectInstall = "skipped";
|
||||
setApplyProgress({ stage: "seed" });
|
||||
if (hostWritten && flash.ok === true) {
|
||||
// Apply → cleanup → restart 成功后,默认把加密提示词 seed 进 prompt-inject.md。
|
||||
// 用户自改过的内容保留;仅当文件不存在或仍是插件旧默认时才写。
|
||||
@@ -2100,6 +2186,10 @@ function installWebServer(ctx, cfg) {
|
||||
}
|
||||
const hung = refreshHungOperator(state.dsh_home);
|
||||
const override = await core.readOverrideForUi(state.dsh_home);
|
||||
endApply({
|
||||
stage: "done",
|
||||
error: complete || (promptReady && hostWritten) ? "" : "incomplete",
|
||||
});
|
||||
sendJson(response, 200, {
|
||||
ok: true,
|
||||
complete,
|
||||
@@ -2129,6 +2219,7 @@ function installWebServer(ctx, cfg) {
|
||||
cmd_flash: flash,
|
||||
});
|
||||
} catch (e) {
|
||||
endApply({ error: String(e && e.message ? e.message : e) });
|
||||
sendJson(response, 500, { ok: false, error: String(e) });
|
||||
}
|
||||
},
|
||||
@@ -2142,17 +2233,26 @@ function installWebServer(ctx, cfg) {
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
beginJob("revert", "locate");
|
||||
try {
|
||||
const state = await core.gatherState();
|
||||
const result = {};
|
||||
setApplyProgress({ kind: "revert", stage: "revert" });
|
||||
if (state.ai_base) {
|
||||
const { reverted, errors } = await core.revertAll(state.ai_base);
|
||||
result.reverted = reverted.length;
|
||||
result.errors = errors.length;
|
||||
}
|
||||
setApplyProgress({ kind: "revert", stage: "shim" });
|
||||
result.shim = await core.revertAllShims();
|
||||
endApply({
|
||||
kind: "revert",
|
||||
stage: "done",
|
||||
error: result.errors ? "incomplete" : "",
|
||||
});
|
||||
sendJson(response, 200, { ok: true, ...result, note: "重启 dsh 恢复; prompt-inject.md 保留" });
|
||||
} catch (e) {
|
||||
endApply({ kind: "revert", error: String(e && e.message ? e.message : e) });
|
||||
sendJson(response, 500, { ok: false, error: String(e) });
|
||||
}
|
||||
},
|
||||
@@ -2166,8 +2266,18 @@ function installWebServer(ctx, cfg) {
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
beginJob("uninstall", "locate");
|
||||
try {
|
||||
const result = await uninstaller.uninstallPurge();
|
||||
const result = await uninstaller.uninstallPurge({
|
||||
onStage(stage) {
|
||||
setApplyProgress({ kind: "uninstall", stage });
|
||||
},
|
||||
});
|
||||
endApply({
|
||||
kind: "uninstall",
|
||||
stage: "done",
|
||||
error: result.ok ? "" : (result.errors && result.errors[0]) || "incomplete",
|
||||
});
|
||||
sendJson(response, result.ok ? 200 : 500, {
|
||||
...result,
|
||||
surface: hostctl.currentSurface(),
|
||||
@@ -2182,6 +2292,7 @@ function installWebServer(ctx, cfg) {
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
endApply({ kind: "uninstall", error: String(e && e.message ? e.message : e) });
|
||||
sendJson(response, 500, { ok: false, error: String(e && e.message ? e.message : e) });
|
||||
}
|
||||
},
|
||||
|
||||
+49
-3
@@ -92,19 +92,65 @@ export function listProfileDirs(dshHome) {
|
||||
return out;
|
||||
}
|
||||
|
||||
export function ensureProfileBundles(profileDir) {
|
||||
const fp = path.join(profileDir, "package.json");
|
||||
const pkg = readJson(fp);
|
||||
if (!pkg) return { ok: false, wrote: false, path: fp };
|
||||
pkg.dsh = pkg.dsh && typeof pkg.dsh === "object" ? pkg.dsh : {};
|
||||
pkg.dsh.profile = pkg.dsh.profile && typeof pkg.dsh.profile === "object" ? pkg.dsh.profile : {};
|
||||
const bundles = Array.isArray(pkg.dsh.profile.bundles) ? pkg.dsh.profile.bundles : [];
|
||||
if (bundles.includes(PURGE_NAME)) return { ok: true, wrote: false, path: fp };
|
||||
pkg.dsh.profile.bundles = [...bundles, PURGE_NAME];
|
||||
fs.writeFileSync(fp, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
||||
return { ok: true, wrote: true, path: fp };
|
||||
}
|
||||
|
||||
/** pnpm 11/12 默认拦 postinstall(ERR_PNPM_IGNORED_BUILDS)。写进 profile 的 allowBuilds,下次 add 能跑脚本。 */
|
||||
export function ensurePnpmAllowBuild(profileDir) {
|
||||
const fp = path.join(profileDir, "pnpm-workspace.yaml");
|
||||
let text = "";
|
||||
try { text = fs.readFileSync(fp, "utf8"); } catch { text = ""; }
|
||||
if (/(^|\n)[ \t]*dsh-purge[ \t]*:[ \t]*true\b/.test(text)) return { ok: true, wrote: false, path: fp };
|
||||
if (!String(text).trim()) {
|
||||
fs.writeFileSync(fp, "allowBuilds:\n dsh-purge: true\n", "utf8");
|
||||
return { ok: true, wrote: true, path: fp };
|
||||
}
|
||||
if (/(^|\n)allowBuilds[ \t]*:/.test(text)) {
|
||||
const next = text.replace(/(^|\n)(allowBuilds[ \t]*:[ \t]*\n)/, "$1$2 dsh-purge: true\n");
|
||||
if (next === text) return { ok: true, wrote: false, path: fp };
|
||||
fs.writeFileSync(fp, next, "utf8");
|
||||
return { ok: true, wrote: true, path: fp };
|
||||
}
|
||||
const prefix = text.endsWith("\n") ? "" : "\n";
|
||||
fs.writeFileSync(fp, `${text}${prefix}\nallowBuilds:\n dsh-purge: true\n`, "utf8");
|
||||
return { ok: true, wrote: true, path: fp };
|
||||
}
|
||||
|
||||
/** 已装进 bundles / node_modules 但缺 insert 的 profile,补上本体行。 */
|
||||
export function ensureAllProfileBodyInserts(dshHome) {
|
||||
return ensureAllProfileInstall(dshHome).map((item) => ({
|
||||
dir: item.dir,
|
||||
ok: item.ok,
|
||||
wrote: Boolean(item.insert?.wrote),
|
||||
path: item.insert?.path || path.join(item.dir || "", "cordis.patch.yml"),
|
||||
error: item.error,
|
||||
}));
|
||||
}
|
||||
|
||||
/** bundles + 本体 insert + pnpm allowBuilds。postinstall 被跳过、升级覆盖 overlay 之后靠这条把按钮找回来。 */
|
||||
export function ensureAllProfileInstall(dshHome) {
|
||||
const results = [];
|
||||
for (const dir of listProfileDirs(dshHome)) {
|
||||
if (!profileOwnsPurge(dir)) continue;
|
||||
try {
|
||||
results.push({ dir, ...ensureProfileBodyInsert(dir) });
|
||||
const bundles = ensureProfileBundles(dir);
|
||||
const insert = ensureProfileBodyInsert(dir);
|
||||
const pnpm = ensurePnpmAllowBuild(dir);
|
||||
results.push({ dir, ok: true, bundles, insert, pnpm });
|
||||
} catch (error) {
|
||||
results.push({
|
||||
dir,
|
||||
ok: false,
|
||||
wrote: false,
|
||||
path: path.join(dir, "cordis.patch.yml"),
|
||||
error: error && error.message ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
|
||||
+108
-8
@@ -22,12 +22,24 @@ window.__ModuleLoader__.load({
|
||||
*/
|
||||
const CSS = `
|
||||
.rt-dock{position:fixed;top:12px;right:12px;z-index:20;display:flex;flex-direction:column;box-sizing:border-box;
|
||||
background:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1c1c) 52%,transparent);
|
||||
backdrop-filter:blur(20px) saturate(1.3);-webkit-backdrop-filter:blur(20px) saturate(1.3);
|
||||
border:1px solid color-mix(in srgb,var(--dsw-alias-border-l1,#444) 70%,transparent);
|
||||
--rt-glass:blur(18px) saturate(1.35);--rt-ease:cubic-bezier(.22,1,.36,1);
|
||||
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);
|
||||
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#f3f0e8) 38%,transparent);
|
||||
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 32%,transparent);
|
||||
--rt-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent);
|
||||
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);
|
||||
--rt-line-2:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 50%,transparent);
|
||||
--rt-hi:color-mix(in srgb,#fff 42%,transparent);
|
||||
--rt-ink:var(--dsw-alias-label-primary,#16140f);
|
||||
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 72%,var(--dsw-alias-label-secondary,#5c564c));
|
||||
--rt-accent:var(--dsw-alias-brand-primary,#3d8f68);
|
||||
--rt-ok:#2f6b4f;--rt-warn:#8a5a12;--rt-bad:#9a3434;
|
||||
background:var(--rt-paper);
|
||||
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);
|
||||
border:1px solid var(--rt-line);
|
||||
border-radius:12px;
|
||||
box-shadow:0 18px 48px color-mix(in srgb,#000 28%,transparent);pointer-events:auto;color:var(--dsw-alias-label-primary);
|
||||
font-size:13px;line-height:1.5}
|
||||
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 16%,transparent);
|
||||
pointer-events:auto;color:var(--rt-ink);font-family:inherit;font-size:13px;line-height:1.5}
|
||||
.rt-dock.rt-embedded{position:relative;inset:auto;width:100%;height:100%;max-width:none;border:0;border-radius:0;box-shadow:none;background:transparent!important;backdrop-filter:none;-webkit-backdrop-filter:none}
|
||||
.rt-grip,.rt-resize-r,.rt-resize-b,.rt-resize-c{position:absolute;z-index:3;touch-action:none}
|
||||
.rt-grip{left:-3px;top:0;bottom:0;width:8px;cursor:ew-resize;background:transparent}
|
||||
@@ -165,8 +177,20 @@ window.__ModuleLoader__.load({
|
||||
.rt-link{color:var(--dsw-alias-brand-primary);text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.rt-link:hover{text-decoration:underline}
|
||||
.rt-full{position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;
|
||||
background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;
|
||||
border-top:3px solid var(--dsw-alias-brand-primary)}
|
||||
--rt-glass:blur(18px) saturate(1.35);--rt-ease:cubic-bezier(.22,1,.36,1);
|
||||
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fffcf7) 46%,transparent);
|
||||
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#f3f0e8) 38%,transparent);
|
||||
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#fff) 32%,transparent);
|
||||
--rt-fill:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 14%,transparent);
|
||||
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6d8f78) 34%,transparent);
|
||||
--rt-hi:color-mix(in srgb,#fff 42%,transparent);
|
||||
--rt-ink:var(--dsw-alias-label-primary,#16140f);
|
||||
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#16140f) 72%,var(--dsw-alias-label-secondary,#5c564c));
|
||||
--rt-accent:var(--dsw-alias-brand-primary,#3d8f68);
|
||||
--rt-ok:#2f6b4f;--rt-warn:#8a5a12;--rt-bad:#9a3434;
|
||||
background:var(--rt-paper);color:var(--rt-ink);font-family:inherit;font-size:13px;line-height:1.5;
|
||||
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);
|
||||
border:1px solid var(--rt-line);box-shadow:inset 0 1px 0 var(--rt-hi)}
|
||||
.rt-full .rt-head{padding:12px 18px}
|
||||
.rt-full .rt-tabs{padding:10px 18px 0;gap:6px;flex-wrap:wrap}
|
||||
.rt-full .rt-side{width:260px}
|
||||
@@ -558,7 +582,83 @@ window.__ModuleLoader__.load({
|
||||
.rt-shot-zoom{position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.82);display:flex;flex-direction:column;
|
||||
align-items:center;justify-content:center;gap:10px;cursor:zoom-out;padding:18px}
|
||||
.rt-shot-zoom img{max-width:96vw;max-height:86vh;border-radius:6px;box-shadow:0 18px 48px rgba(0,0,0,.5)}
|
||||
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}` /* ---------------------------------------------------------- 桥接与状态 */
|
||||
.rt-shot-zoom-cap{color:#e5e7eb;font-size:12px;text-align:center;max-width:90vw;overflow-wrap:anywhere}
|
||||
body[data-ds-dark-theme] .rt-dock,body[data-ds-dark-theme] .rt-full,
|
||||
.dshp-dock[data-theme="dusk"] .rt-dock,.dshp-dock[data-theme="dusk"] .rt-full{
|
||||
--rt-paper:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 42%,transparent);
|
||||
--rt-paper-2:color-mix(in srgb,var(--dsw-alias-bg-layer-2,#1c1e24) 34%,transparent);
|
||||
--rt-well:color-mix(in srgb,var(--dsw-alias-bg-layer-1,#1c1e24) 26%,transparent);
|
||||
--rt-hi:color-mix(in srgb,#fff 10%,transparent);
|
||||
--rt-ink:var(--dsw-alias-label-primary,#f4f1ea);
|
||||
--rt-mute:color-mix(in srgb,var(--dsw-alias-label-primary,#f4f1ea) 78%,var(--dsw-alias-label-secondary,#c9c3b8));
|
||||
--rt-line:color-mix(in srgb,var(--dsw-alias-brand-primary,#6dbf8c) 32%,transparent);
|
||||
--rt-ok:#8fd0a8;--rt-warn:#e4c48a;--rt-bad:#f0b4b4;
|
||||
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 28%,transparent)}
|
||||
.rt-card,.rt-sess,.rt-hit,.rt-cred,.rt-evi,.rt-kb,.rt-rep,.rt-flow-node,.rt-hflow-node,.rt-atest,.rt-hcol,.rt-ap-hit,.rt-rep-req,.rt-rep-trace,.rt-shots,.rt-modal-box{
|
||||
background:var(--rt-paper)!important;border-color:var(--rt-line)!important;color:var(--rt-ink);
|
||||
backdrop-filter:var(--rt-glass);-webkit-backdrop-filter:var(--rt-glass);box-shadow:inset 0 1px 0 var(--rt-hi)}
|
||||
.rt-score-group,.rt-sec,.rt-kb-cat,.rt-evi-head,.rt-rep-req-head,.rt-ap-head,.rt-ap-goal,.rt-rep-stage{
|
||||
background:var(--rt-paper-2)!important;border-color:var(--rt-line)!important;color:var(--rt-ink)}
|
||||
.rt-head,.rt-tabs,.rt-toolbar,.rt-foot,.rt-side,.rt-list,.rt-pane,.rt-livebar,.rt-concl,.rt-subtabs,.rt-kb-filter,.rt-kb-cats,.rt-body,.rt-table,.rt-main{
|
||||
background:transparent!important;box-shadow:none}
|
||||
.rt-row.head,.rt-score-row.head,.rt-vrow.head{
|
||||
background:var(--rt-paper)!important;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
|
||||
.rt-row:hover,.rt-vrow:hover,.rt-score-row:hover,.rt-item:hover,.rt-item.on,.rt-seg:hover,.rt-seg.on,.rt-icon-btn:hover,.rt-hbtn:hover,.rt-kb-head:hover,.rt-sidehead-btn:hover,.rt-sec:hover,.rt-rep-stage:hover,.rt-concl-i:hover,.rt-concl-i.on{
|
||||
background:var(--rt-fill)!important}
|
||||
.rt-btn,.rt-icon-btn,.rt-hbtn,.rt-input,.rt-eng-select,.rt-textarea,.rt-chip,.rt-code,.rt-hit-evi,.rt-atest-notes,.rt-clip-body,.rt-evi-body,.rt-rep-http,.rt-md,.rt-kb-tpl-row,.rt-hit-row,.rt-ap-asset,.rt-ap-tunnel{
|
||||
background:var(--rt-well)!important;border-color:var(--rt-line)!important;color:var(--rt-ink)!important;
|
||||
backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
|
||||
.rt-btn{border-radius:8px;transition:transform 500ms var(--rt-ease),opacity 300ms var(--rt-ease)}
|
||||
.rt-btn:hover:not(:disabled){transform:translateY(-1px);border-color:var(--rt-accent)}
|
||||
.rt-btn:active:not(:disabled){transform:scale(.98)}
|
||||
.rt-btn:focus-visible,.rt-input:focus-visible,.rt-tab:focus-visible,.rt-icon-btn:focus-visible,.rt-hbtn:focus-visible{
|
||||
outline:2px solid var(--rt-accent);outline-offset:2px}
|
||||
.rt-btn-primary,.rt-btn-primary:hover:not(:disabled){background:var(--rt-accent)!important;border-color:var(--rt-accent)!important;color:#fff!important;backdrop-filter:none}
|
||||
.rt-input option,.rt-eng-select option{background:var(--dsw-alias-bg-layer-1,#fff);color:var(--rt-ink)}
|
||||
body[data-ds-dark-theme] .rt-input option,body[data-ds-dark-theme] .rt-eng-select option,.dshp-dock[data-theme="dusk"] .rt-input option,.dshp-dock[data-theme="dusk"] .rt-eng-select option{background:#1b1d22;color:#f4f1ea}
|
||||
.rt-pri-high,.rt-test-blocked,.rt-sev-critical,.rt-sev-high{color:var(--rt-bad)!important;background:color-mix(in srgb,var(--rt-bad) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-bad) 40%,var(--rt-line))!important}
|
||||
.rt-pri-medium,.rt-test-testing,.rt-tag-active{color:var(--rt-warn)!important;background:color-mix(in srgb,var(--rt-warn) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-warn) 40%,var(--rt-line))!important}
|
||||
.rt-pri-low{color:var(--rt-mute)!important;background:var(--rt-paper-2)!important;border:1px solid var(--rt-line)!important}
|
||||
.rt-gain,.rt-counted,.rt-scorepts,.rt-flow-pts,.rt-hflow-pts,.rt-hcol-pts,.rt-ap-pts{color:var(--rt-ok)!important;background:color-mix(in srgb,var(--rt-ok) 16%,transparent)!important;border:1px solid color-mix(in srgb,var(--rt-ok) 38%,var(--rt-line))!important}
|
||||
.rt-secret{color:var(--rt-warn)!important;background:color-mix(in srgb,var(--rt-warn) 14%,transparent)!important;border-color:color-mix(in srgb,var(--rt-warn) 40%,var(--rt-line))!important}
|
||||
.rt-scope-internal{color:#0e7490;background:color-mix(in srgb,#06b6d4 16%,transparent);border:1px solid color-mix(in srgb,#06b6d4 32%,transparent)}
|
||||
.rt-scope-external{color:var(--rt-warn);background:color-mix(in srgb,var(--rt-warn) 16%,transparent);border:1px solid color-mix(in srgb,var(--rt-warn) 32%,transparent)}
|
||||
.rt-scope-testing{color:#5b21b6;background:color-mix(in srgb,#8b5cf6 16%,transparent);border:1px solid color-mix(in srgb,#8b5cf6 32%,transparent)}
|
||||
body[data-ds-dark-theme] .rt-scope-internal,.dshp-dock[data-theme="dusk"] .rt-scope-internal{color:#67e8f9}
|
||||
body[data-ds-dark-theme] .rt-scope-testing,.dshp-dock[data-theme="dusk"] .rt-scope-testing{color:#c4b5fd}
|
||||
.rt-modal-box{border-radius:16px;backdrop-filter:blur(22px) saturate(1.4);-webkit-backdrop-filter:blur(22px) saturate(1.4);
|
||||
box-shadow:inset 0 1px 0 var(--rt-hi),0 16px 40px color-mix(in srgb,#000 28%,transparent)}
|
||||
.rt-flow-action.inferred,.rt-ap-act.inferred{font-style:normal}
|
||||
@media (prefers-reduced-motion:reduce){.rt-btn,.rt-live-dot{transition:opacity 300ms var(--rt-ease);animation:none;transform:none}}
|
||||
.rt-head,.rt-toolbar,.rt-foot,.rt-livebar,.rt-concl{padding:8px 12px}
|
||||
.rt-tabs,.rt-subtabs{gap:8px;padding:0 12px}
|
||||
.rt-tab{padding:8px 12px;gap:4px}
|
||||
.rt-pane,.rt-chain,.rt-sess-grid,.rt-flow,.rt-ap,.rt-rep-list,.rt-live-body{padding:12px}
|
||||
.rt-side,.rt-list{width:192px;padding:8px;box-sizing:border-box}
|
||||
.rt-seg,.rt-item{padding:8px;border-radius:8px;margin-bottom:4px}
|
||||
.rt-card{padding:12px;margin-bottom:12px;border-radius:8px}
|
||||
.rt-card h4{margin:0 0 8px}
|
||||
.rt-btn{padding:4px 12px;border-radius:8px;font-size:12px;line-height:20px}
|
||||
.rt-input,.rt-eng-select{padding:4px 12px;border-radius:8px;min-height:32px;box-sizing:border-box}
|
||||
.rt-textarea{padding:8px 12px;border-radius:8px}
|
||||
.rt-row,.rt-score-row,.rt-vrow{padding:8px 12px;gap:8px}
|
||||
.rt-row{grid-template-columns:minmax(96px,1.1fr) minmax(56px,72px) minmax(64px,96px) minmax(0,1.2fr) minmax(0,1fr)}
|
||||
.rt-toolbar{gap:8px}
|
||||
.rt-hint{padding:8px 12px;margin-bottom:8px;border-radius:8px}
|
||||
.rt-empty,.rt-err{padding:8px 12px}
|
||||
.rt-empty{padding:24px 12px}
|
||||
.rt-sess{padding:12px;border-radius:8px}
|
||||
.rt-sess-grid{gap:12px}
|
||||
.rt-expand,.rt-score-detail,.rt-vdetail{padding:8px 12px 12px}
|
||||
.rt-section{padding:8px 12px 4px}
|
||||
.rt-full .rt-head{padding:12px 16px}
|
||||
.rt-full .rt-tabs{padding:0 16px;gap:8px}
|
||||
.rt-full .rt-pane,.rt-full .rt-chain,.rt-full .rt-sess-grid{padding:16px}
|
||||
.rt-full .rt-foot,.rt-full .rt-toolbar,.rt-full .rt-livebar,.rt-full .rt-concl{padding:8px 16px}
|
||||
.rt-full .rt-side{width:240px}
|
||||
.rt-full .rt-list{width:256px}
|
||||
.rt-full .rt-row{grid-template-columns:minmax(0,1.2fr) minmax(64px,90px) minmax(80px,130px) minmax(0,1.4fr) minmax(0,1.2fr)}
|
||||
` /* ---------------------------------------------------------- 桥接与状态 */
|
||||
/** 是否在「全面浏览」独立窗口里(URL hash 标记,复用同一套界面代码)。 */
|
||||
const isFullWindow = () => {
|
||||
try { return String(window.location.hash || '') === '#redteam-full' } catch { return false }
|
||||
|
||||
@@ -31,6 +31,9 @@ export function pathLooksDesktop(p) {
|
||||
n.includes("/dsh desktop.app/") ||
|
||||
n.includes("dsh-desktop") ||
|
||||
n.includes("dsh-plugin-desktop") ||
|
||||
n.includes("/deepseek bot/") ||
|
||||
n.includes("/deepseek-bot/") ||
|
||||
n.includes("/ds-bot/") ||
|
||||
n.includes("/deepseek harness.app/") ||
|
||||
(harnessDir && (n.includes("/resources/") || n.includes("/contents/resources/") || n.endsWith("/resources"))) ||
|
||||
/\/dsh desktop\.exe$/i.test(n) ||
|
||||
@@ -56,8 +59,25 @@ function resourcesLookLikeDesktopInstall(resourcesPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 社区 Electron(DS Bot / DeepSeek Bot):profile 常是 ds-bot,DSH_SURFACE 还可能被写成 web。 */
|
||||
export function isCommunityElectronHost(input = {}) {
|
||||
const env = input.env ?? process.env;
|
||||
const profile = norm(env.DSH_PROFILE);
|
||||
if (profile === "ds-bot" || profile === "dsbot" || profile === "deepseek-bot") return true;
|
||||
const execPath = input.execPath ?? process.execPath;
|
||||
const name = exeName(execPath);
|
||||
if (/^deepseek[\s._-]*bot(\.exe)?$/.test(name) || /^ds[\s._-]*bot(\.exe)?$/.test(name)) return true;
|
||||
const p = slash(execPath);
|
||||
if (p.includes("/deepseek bot") || p.includes("/deepseek-bot") || p.includes("/ds-bot/") || p.endsWith("/ds-bot")) return true;
|
||||
const resourcesPath = input.resourcesPath ?? process.resourcesPath;
|
||||
const electron = (input.versions ?? process.versions)?.electron;
|
||||
if (electron && resourcesLookLikeDesktopInstall(resourcesPath)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isDesktopSurface(input = {}) {
|
||||
const env = input.env ?? process.env;
|
||||
if (isCommunityElectronHost(input)) return true;
|
||||
const forced = norm(env.DSH_SURFACE);
|
||||
if (forced === "desktop") return true;
|
||||
if (forced && SURFACES.includes(forced)) return false;
|
||||
@@ -95,6 +115,7 @@ function forcedSurface(env) {
|
||||
|
||||
export function detectSurface(input = {}) {
|
||||
const env = input.env ?? process.env;
|
||||
if (isCommunityElectronHost(input)) return "desktop";
|
||||
const forced = forcedSurface(env);
|
||||
if (forced) return forced;
|
||||
if (isDesktopSurface(input)) return "desktop";
|
||||
|
||||
+8
-1
@@ -205,7 +205,9 @@ function unregisterProfiles(profiles) {
|
||||
return { stripped, errors };
|
||||
}
|
||||
|
||||
export async function uninstallPurge() {
|
||||
export async function uninstallPurge(options = {}) {
|
||||
const onStage = typeof options.onStage === "function" ? options.onStage : () => {};
|
||||
onStage("locate");
|
||||
const state = await core.gatherState();
|
||||
const applied = wasApplied(state);
|
||||
const dshHome = state.dsh_home || core.findDshHome();
|
||||
@@ -225,6 +227,7 @@ export async function uninstallPurge() {
|
||||
};
|
||||
|
||||
try {
|
||||
onStage("revert");
|
||||
if (state.ai_base) {
|
||||
report.patches = await core.revertAll(state.ai_base);
|
||||
if (applied) report.reverted = true;
|
||||
@@ -240,6 +243,7 @@ export async function uninstallPurge() {
|
||||
}
|
||||
|
||||
try {
|
||||
onStage("shim");
|
||||
report.shim = await core.revertAllShims();
|
||||
if (state.shim_cmd === "patched" || state.shim_ps1 === "patched" || state.shim_bin === "patched") {
|
||||
report.reverted = true;
|
||||
@@ -248,6 +252,7 @@ export async function uninstallPurge() {
|
||||
report.errors.push(`revert shims: ${e.message || e}`);
|
||||
}
|
||||
|
||||
onStage("flash");
|
||||
try {
|
||||
report.flash = core.revertCmdFlash(state.ai_base, dshHome);
|
||||
} catch (e) {
|
||||
@@ -297,7 +302,9 @@ export async function uninstallPurge() {
|
||||
return report;
|
||||
}
|
||||
|
||||
onStage("cleanup");
|
||||
report.cleanup = collectCleanupDirs(profiles, dshHome);
|
||||
onStage("done");
|
||||
return report;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { atomicWriteSync, findDshHome } from "./core.js";
|
||||
import { ensureAllProfileInstall } from "./profile-insert.js";
|
||||
import { extractZipArchive } from "./zip-extract.js";
|
||||
|
||||
const REPO = "YuJunZhiXue/dsh-purge";
|
||||
@@ -1025,6 +1026,7 @@ async function _applyUpdateImpl(jobs, options) {
|
||||
vias.add("zip");
|
||||
}
|
||||
for (const dir of specProfiles) pinInstalledSpec(dir, ref);
|
||||
try { ensureAllProfileInstall(findDshHome()); } catch { /* 升级后补 insert,失败不挡这次覆盖 */ }
|
||||
const sha = (gitOk() ? gitHead(PLUGIN_ROOT) : "") || (await remoteHeadSha(ref).catch(() => ""));
|
||||
const via = vias.size > 1 ? "mixed" : [...vias][0] || detectVia();
|
||||
const saved = writeChannelState({ channel, pin });
|
||||
|
||||
Reference in new issue
Block a user