fix: 发布 1.1.48,桌面跟 Web 配置、红队派活与 skill/MCP 按任务选用。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-02 17:25:49 +08:00
1 parent 33baeeef45
commit eb09b2e62d
12 files changed
+389 -38

No files matched your search

+82
View File
@@ -1026,6 +1026,88 @@ function officialExeFromProcess() {
return fs.existsSync(beside) ? beside : "";
}
const WEB_PROFILE_RESOLVER =
"function resolveDesktopPaths(dshHome = resolveDshHome()) {\n" +
'\tconst webProfile = join(dshHome, "profiles", "web");\n' +
'\tconst desktopProfile = join(dshHome, "profiles", "desktop");\n' +
'\tconst profile = existsSync(join(webProfile, "package.json")) ? webProfile : desktopProfile;\n' +
"\treturn {\n" +
"\t\tprofile,\n" +
'\t\tlock: join(profile, "lock")\n' +
"\t};\n" +
"}";
const WEB_PROFILE_RESOLVER_RE =
/function resolveDesktopPaths\(dshHome = resolveDshHome\(\)\) \{\s*return \{\s*profile: join\(dshHome, "profiles", "desktop"\),\s*lock: join\(dshHome, "profiles", "desktop", "lock"\)\s*\};\s*\}/;
function officialShellMainCandidates(appDir) {
if (!appDir) return [];
return [path.join(appDir, "lib", "main.js"), path.join(appDir, "main.js")];
}
/** 官方壳默认只开 profiles/desktop。同一 DSH_HOME 下已有 Web profile 时改读那一份,渠道和插件才能跟过来。 */
export function useWebProfileInOfficialShell(appDir) {
const mains = officialShellMainCandidates(appDir).filter((fp) => isFile(fp));
if (!mains.length) return { changed: false, missing: true };
let changed = false;
let already = false;
let missing = false;
for (const mainJs of mains) {
const text = fs.readFileSync(mainJs, "utf8");
if (text.includes('const webProfile = join(dshHome, "profiles", "web")')) {
already = true;
continue;
}
if (!WEB_PROFILE_RESOLVER_RE.test(text)) {
missing = true;
continue;
}
fs.writeFileSync(mainJs, text.replace(WEB_PROFILE_RESOLVER_RE, WEB_PROFILE_RESOLVER), "utf8");
changed = true;
}
return { changed, already: already && !changed, missing: missing && !changed && !already };
}
/** Electron 桌面读 Web profile 时关掉远程配对页,避免一启动卡在 pairing。 */
export function ensureDesktopRemoteUiOff(dshHome) {
const home = dshHome || process.env.DSH_HOME || "";
if (!home) return { changed: false };
const patchFile = path.join(home, "profiles", "web", "cordis.patch.yml");
if (!isFile(patchFile)) return { changed: false, missing: true };
const text = fs.readFileSync(patchFile, "utf8");
if (/^\s*-\s*id:\s*web-ui-remote-web-ui\b/m.test(text)) {
if (/-\s*id:\s*web-ui-remote-web-ui[\s\S]*?disabled:\s*true/.test(text)) {
return { changed: false, already: true };
}
}
const block =
"\n# [dsh-purge] official desktop shares this profile; keep remote pairing off in the exe window\n" +
"- id: web-ui-remote-web-ui\n" +
" disabled: true\n";
if (text.includes("web-ui-remote-web-ui")) return { changed: false, already: true };
fs.writeFileSync(patchFile, text.replace(/\s*$/, "\n") + block, "utf8");
return { changed: true };
}
export function alignOfficialDesktopProfile(input = {}) {
const exe =
input.exe ||
officialExeFromProcess() ||
findDesktopAppExecutable() ||
"";
if (!exe || !isOfficialHarnessExecutable(exe)) return { changed: false };
const appDir = input.appDir || appDirForExecutable(exe);
const shell = useWebProfileInOfficialShell(appDir);
const remote = ensureDesktopRemoteUiOff(input.dshHome || process.env.DSH_HOME || "");
return {
changed: Boolean(shell.changed || remote.changed),
shell,
remote,
appDir,
exe,
};
}
function dshHomeForRelaunch() {
const current = String(process.env.DSH_HOME || "").replace(/[\\/]+$/, "");
if (!current) return "";