mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 10:20:22 +08:00
release: 1.1.84,尾部锚点与子代理审批接管,红队模式中文化,#194/#188
- 接线 lib/anchor.js:锚点物理追加到 system prompt sections 末尾, identity.js 支持 anchorText(对象/字符串两种入参),已有同名段先滤再追加; 锚点改为跟随操作者语言,删除写死的英文开头句(红队回答变英文的根因) - 接线 lib/subagent-control.js:子会话 approval/policy=never 改回 ask, 并在 approval/request 瀑布放行;anchorMode/subagentControl 提供回滚开关 - index.js:真实 anchorApplied / injectTail 判定、审批策略探针、iso 分支 注册锚点、applyHostHooks 注册锚点与子代理接管并统一释放 - office 技能自愈:core/desktop 增加 healOfficeSkillsRuntimeOnDisk,桌面端触发 - 红队模式中文化:preset 文案、角色名、五阶段、25 项计分规则与 POC 分类、 技能修复说明、环境适配提示、面板报错、成果报告与复现报告 - #194:hung-operator 改按内容变更缓存,加风暴/慢调用熔断;WeakMap 去重 同次 assemble 的重复改写;新增 #91 记录宿主信号退出的持久化日志 - #188(rc.4 专属部分):新增 #89 沙箱策略去品牌、#90 skill-badge 中文描述, 扩展 #32/#53 的 rc.3 变体与 marker,均 optional - 新增锚点接线与红队文案测试,81/81 通过
This commit is contained in:
1 parent
ec4c8b889f
commit
5d0ebdae81
19 files changed
+1521
-847
No files matched your search
+67
-1
@@ -4,7 +4,7 @@ import { execFileSync, spawn } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { isWshAscii, wshLiteral } from "./official-update.js";
|
||||
import { asarArchiveIsFile, hostFs } from "./extract-asar.js";
|
||||
import { asarArchiveIsFile, diskFs, hostFs } from "./extract-asar.js";
|
||||
import { hostPromptKeepsInject } from "./host-clean.js";
|
||||
import { atomicCopyFileSync, atomicWriteSync } from "./core.js";
|
||||
|
||||
@@ -258,6 +258,72 @@ export function appDirForExecutable(exe) {
|
||||
return dir ? path.join(dir, "app") : "";
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- office-skills 自愈
|
||||
* resources/runtime/office-skills/office/SKILL.md 缺失时,dsh-skill-office 初始化
|
||||
* 同步读七个文件,桌面端直接 DesktopHostFatalError 退出。这里在“应用能起来”的
|
||||
* 前提下把缺的文件从 app.asar / npm 安装树补回磁盘,避免下次再崩。
|
||||
* 注意:救不了崩溃当次(崩溃发生在 Fiber._reload,比插件早)。
|
||||
*/
|
||||
const OFFICE_SKILL_MARKER = ["office", "SKILL.md"];
|
||||
const OFFICE_COPY_MAX_DEPTH = 12;
|
||||
|
||||
function copySkillTree(src, dest, reader, writer, depth = 0) {
|
||||
if (depth > OFFICE_COPY_MAX_DEPTH) return;
|
||||
try { writer.mkdirSync(dest, { recursive: true }); } catch { return; }
|
||||
let entries;
|
||||
try { entries = reader.readdirSync(src, { withFileTypes: true }); } catch { return; }
|
||||
for (const entry of entries) {
|
||||
if (!entry || !entry.name) continue;
|
||||
// 只跟真目录;符号链接可能指回上层,递归会绕圈。
|
||||
if (entry.isSymbolicLink && entry.isSymbolicLink()) continue;
|
||||
const from = path.join(src, entry.name);
|
||||
const to = path.join(dest, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
copySkillTree(from, to, reader, writer, depth + 1);
|
||||
} else if (entry.isFile()) {
|
||||
try {
|
||||
if (writer.existsSync(to)) continue;
|
||||
writer.mkdirSync(path.dirname(to), { recursive: true });
|
||||
writer.writeFileSync(to, reader.readFileSync(from));
|
||||
} catch { /* 单个文件失败不挡整棵树 */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function healOfficeSkillsAt(resourcesDir, appDir = "", extraSources = []) {
|
||||
if (!resourcesDir) return { ok: false, reason: "no-resources" };
|
||||
const dest = path.join(resourcesDir, "runtime", "office-skills");
|
||||
const marker = path.join(dest, ...OFFICE_SKILL_MARKER);
|
||||
const out = diskFs();
|
||||
try { if (out.existsSync(marker)) return { ok: true, healed: false, dest }; } catch { /* 下面按缺失处理 */ }
|
||||
const sources = [
|
||||
appDir ? path.join(appDir, "runtime", "office-skills") : "",
|
||||
appDir ? path.join(appDir, "dsh", "node_modules", "@deepseek-ai", "dsh-skill-office", "assets") : "",
|
||||
path.join(resourcesDir, "app", "runtime", "office-skills"),
|
||||
path.join(resourcesDir, "app", "dsh", "node_modules", "@deepseek-ai", "dsh-skill-office", "assets"),
|
||||
// 打包安装的资源在 asar 里,hostFs 认 asar 路径。
|
||||
path.join(resourcesDir, "app.asar", "dsh", "node_modules", "@deepseek-ai", "dsh-skill-office", "assets"),
|
||||
path.join(resourcesDir, "app.asar.unpacked", "dsh", "node_modules", "@deepseek-ai", "dsh-skill-office", "assets"),
|
||||
...(Array.isArray(extraSources) ? extraSources : []),
|
||||
].filter(Boolean);
|
||||
const src = sources.find((dir) => {
|
||||
try { return hostFs.existsSync(path.join(dir, ...OFFICE_SKILL_MARKER)); } catch { return false; }
|
||||
});
|
||||
if (!src) return { ok: false, reason: "no-source", dest };
|
||||
try {
|
||||
copySkillTree(src, dest, hostFs, out);
|
||||
return { ok: out.existsSync(marker), healed: true, src, dest };
|
||||
} catch (error) {
|
||||
return { ok: false, reason: String(error?.message || error), src, dest };
|
||||
}
|
||||
}
|
||||
|
||||
export function healOfficeSkillsRuntimeOnDisk(extraSources = []) {
|
||||
const exe = findDesktopAppExecutable();
|
||||
if (!exe || !isOfficialHarnessExecutable(exe)) return { ok: false, reason: "no-exe" };
|
||||
return healOfficeSkillsAt(resourcesDirForExecutable(exe), appDirForExecutable(exe), extraSources);
|
||||
}
|
||||
|
||||
function exeCandidatesBeside(dir) {
|
||||
if (!dir) return [];
|
||||
return [
|
||||
|
||||
Reference in new issue
Block a user