release: 1.1.68

Co-authored-by: Cursor <cursoragent@cursor.com>

#92 技能块标量 description;#93 红队更新路径与 GitHub 回落;#94 桌面 CLI unpacked 回退;#95 拆除 refusal-recover;#96 bash 等待迁回 60s。注入置顶,capability 改名,用户 prompt 一律 followup,默认关闭自动继续。
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-11 02:21:35 +08:00
1 parent 723b276e6f
commit eb9af6b8fa
26 files changed
+1730 -1371

No files matched your search

+49 -22
View File
@@ -1050,6 +1050,10 @@ export function scheduleAsarRenameWhenIdle({ exe, asar } = {}) {
],
{ detached: true, stdio: "ignore", windowsHide: true, shell: false },
);
// detached spawn 的 ENOENT / 权限错误走 'error' 事件,没监听会 uncaught → 整个进程崩。
child.on("error", (err) => {
try { console.warn("[dsh-purge] asar rename idle PS1 spawn 失败:", err?.message || err); } catch { /* 忽略 */ }
});
child.unref();
return { pending: true };
}
@@ -1060,6 +1064,9 @@ export function scheduleAsarRenameWhenIdle({ exe, asar } = {}) {
stdio: "ignore",
shell: false,
});
child.on("error", (err) => {
try { console.warn("[dsh-purge] asar rename idle sh spawn 失败:", err?.message || err); } catch { /* 忽略 */ }
});
child.unref();
return { pending: true };
}
@@ -1555,6 +1562,10 @@ export function scheduleCleanupRestart({ cleanup = [], ctx } = {}) {
const CLI_ENTRY_BEGIN = "# dsh-purge cli entry begin";
const CLI_ENTRY_END = "# dsh-purge cli entry end";
const CLI_ASAR_ENTRY = "app.asar/dsh/node_modules/@deepseek-ai/dsh-desktop-host/lib/cli.js";
// #94:官方桌面版把 dsh host 放在 app.asar.unpacked(见 isAiBase 的 app.asar.unpacked 分支),
// 不在封装的 app.asar 里。stock 启动脚本却写死 app.asar/.../cli.js → Cannot find module。
// 回退链必须是 app.asar → app.asar.unpacked → app/,少了中间这级 macOS 开箱即坏。
const CLI_UNPACKED_ENTRY = "app.asar.unpacked/dsh/node_modules/@deepseek-ai/dsh-desktop-host/lib/cli.js";
const CLI_DIR_ENTRY = "app/dsh/node_modules/@deepseek-ai/dsh-desktop-host/lib/cli.js";
function ensureAppRuntimeSymlink(resources) {
@@ -1587,26 +1598,17 @@ function ensureAppRuntimeSymlink(resources) {
}
}
function stripShimEntryBlock(text) {
return text.replace(/# dsh-purge cli entry begin[\s\S]*?# dsh-purge cli entry end\r?\n?/g, "");
}
function patchOfficialCliShimText(text) {
if (!text || !text.includes(CLI_ASAR_ENTRY)) return { changed: false, text };
if (text.includes(CLI_ENTRY_BEGIN) && text.includes('"$entry"')) {
return { changed: false, text, already: true };
}
const block = [
CLI_ENTRY_BEGIN,
`entry="$resources/${CLI_ASAR_ENTRY}"`,
'if [ ! -f "$entry" ]; then',
` entry="$resources/${CLI_DIR_ENTRY}"`,
"fi",
CLI_ENTRY_END,
"",
].join("\n");
let next = text;
if (!next.includes(CLI_ENTRY_BEGIN)) {
const insertAt = next.search(/ELECTRON_RUN_AS_NODE=1/);
if (insertAt >= 0) next = `${next.slice(0, insertAt)}${block}${next.slice(insertAt)}`;
else next = `${block}${next}`;
}
if (!text) return { changed: false, text };
// 老版本已改成 "$entry"、asar 原文不在了,但 BEGIN 标记还在 → 也要进来升级成三级回退。
if (!text.includes(CLI_ASAR_ENTRY) && !text.includes(CLI_ENTRY_BEGIN)) return { changed: false, text };
// 先铲掉旧块(可能是两级回退),再把裸 asar 路径归一成 "$entry",最后插入最新三级块,保证幂等升级。
let next = stripShimEntryBlock(text);
next = next.replace(
/"\$resources\/app\.asar\/dsh\/node_modules\/@deepseek-ai\/dsh-desktop-host\/lib\/cli\.js"/g,
'"$entry"',
@@ -1615,7 +1617,27 @@ function patchOfficialCliShimText(text) {
/\$resources\/app\.asar\/dsh\/node_modules\/@deepseek-ai\/dsh-desktop-host\/lib\/cli\.js/g,
'"$entry"',
);
return { changed: next !== text, text: next };
if (!next.includes('"$entry"')) return { changed: false, text };
const block = [
CLI_ENTRY_BEGIN,
`entry="$resources/${CLI_ASAR_ENTRY}"`,
`if [ ! -f "$entry" ]; then entry="$resources/${CLI_UNPACKED_ENTRY}"; fi`,
`if [ ! -f "$entry" ]; then entry="$resources/${CLI_DIR_ENTRY}"; fi`,
CLI_ENTRY_END,
"",
].join("\n");
const insertAt = next.search(/ELECTRON_RUN_AS_NODE=1/);
if (insertAt >= 0) {
// 插到该行行首,避免把 `export ELECTRON_RUN_AS_NODE=1` 从中间劈开。
const lineStart = next.lastIndexOf("\n", insertAt) + 1;
next = `${next.slice(0, lineStart)}${block}${next.slice(lineStart)}`;
} else {
next = `${block}${next}`;
}
if (next === text) return { changed: false, text, already: true };
return { changed: true, text: next };
}
const CMD_ENTRY_BEGIN = "REM dsh-purge cli entry begin";
@@ -1626,6 +1648,8 @@ function cmdEntryAlreadyGood(text) {
if (!text.includes(CMD_ENTRY_BEGIN) || !text.includes(CMD_ENTRY_END)) return false;
if (/set\s+"entry=%entry%"/i.test(text)) return false;
if (!/set\s+"entry=%~dp0[^"\r\n]*app\.asar\\dsh\\node_modules\\@deepseek-ai\\dsh-desktop-host\\lib\\cli\.js"/i.test(text)) return false;
// #94:必须含 app.asar.unpacked 这一级回退,否则判为旧块强制升级。
if (!/if not exist "%entry%" set "entry=%~dp0[^"\r\n]*app\.asar\.unpacked\\dsh\\node_modules\\@deepseek-ai\\dsh-desktop-host\\lib\\cli\.js"/i.test(text)) return false;
if (!/if not exist "%entry%" set "entry=%~dp0[^"\r\n]*app\\dsh\\node_modules\\@deepseek-ai\\dsh-desktop-host\\lib\\cli\.js"/i.test(text)) return false;
const outside = text.replace(/set\s+"entry=[^"]*"/gi, "");
if (/app\.asar\\dsh\\node_modules\\@deepseek-ai\\dsh-desktop-host\\lib\\cli\.js/i.test(outside)) return false;
@@ -1664,17 +1688,20 @@ export function patchOfficialCliCmdText(text) {
if (cmdEntryAlreadyGood(text)) return { changed: false, text, already: true };
const nl = text.includes("\r\n") ? "\r\n" : "\n";
let next = stripCmdEntryBlock(text);
const found = next.match(/%~dp0[^"\r\n]*?app\.asar\\dsh\\node_modules\\@deepseek-ai\\dsh-desktop-host\\lib\\cli\.js/i);
// 先从原文(含旧块的 set 行)取 %~dp0 前缀,这样两级旧块也能升级成三级。
const found = text.match(/%~dp0[^"\r\n]*?app\.asar\\dsh\\node_modules\\@deepseek-ai\\dsh-desktop-host\\lib\\cli\.js/i);
if (!found) return { changed: false, text };
const cut = found[0].toLowerCase().indexOf("app.asar\\");
if (cut < 0) return { changed: false, text };
const prefix = found[0].slice(0, cut);
let next = stripCmdEntryBlock(text);
next = replaceQuotedInsensitive(next, `${prefix}app.asar\\${CMD_CLI_TAIL}`, '"%entry%"');
next = replaceQuotedInsensitive(next, `${prefix}app.asar.unpacked\\${CMD_CLI_TAIL}`, '"%entry%"');
next = replaceQuotedInsensitive(next, `${prefix}app\\${CMD_CLI_TAIL}`, '"%entry%"');
const block = [
CMD_ENTRY_BEGIN,
`set "entry=${prefix}app.asar\\${CMD_CLI_TAIL}"`,
`if not exist "%entry%" set "entry=${prefix}app.asar.unpacked\\${CMD_CLI_TAIL}"`,
`if not exist "%entry%" set "entry=${prefix}app\\${CMD_CLI_TAIL}"`,
CMD_ENTRY_END,
"",