fix: 发布 1.1.64,红队流程八项修复

新建靶标才换角色稿;计分、预检和并发名额按现行规则走。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-08 11:04:18 +08:00
1 parent f4f43c1733
commit ed676bcb11
22 files changed
+273 -1771

No files matched your search

+20 -80
View File
@@ -2,7 +2,7 @@ import nodeFs from "node:fs";
import os from "node:os";
import path from "node:path";
import { createHash } from "node:crypto";
import { execFileSync, execSync, spawn } from "node:child_process";
import { execFileSync, spawn } from "node:child_process";
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
import {
@@ -76,14 +76,6 @@ function execFileText(bin, args) {
}
}
function execText(command) {
try {
return execSync(command, { ...HIDDEN_EXEC, shell: isWindows }).trim();
} catch {
return "";
}
}
function npmCliJs() {
const cli = path.join(path.dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
return isFile(cli) ? cli : "";
@@ -1465,11 +1457,6 @@ function aiBaseGuessesFor(base) {
];
}
export function normPath(p) {
if (!p) return p;
return path.normalize(p);
}
export function isDshHomeDir(dir) {
if (!dir || !isDir(dir)) return false;
const base = path.basename(path.normalize(dir)).toLowerCase();
@@ -2145,10 +2132,6 @@ export function desktopAsarStillSealed(input = {}) {
return Boolean(handoff?.asar && asarArchiveIsFile(handoff.asar));
}
export function officialHostMustStayUp() {
return process.env.ELECTRON_RUN_AS_NODE === "1" && desktop.isOfficialHarnessExecutable(process.execPath);
}
export function findAiBase() {
return remember("ai", () => {
if (adapterFor(detectSurface()) === "desktop") return findAiBaseDesktop();
@@ -2209,15 +2192,6 @@ export function readPromptInjectFileSync(dshHome) {
return norm ? disk.replace(/\r\n/g, "\n") : "";
}
/** 与加密默认 hash 不同 → 用户自改(installOverride 不得覆盖)。 */
export function readCustomizedOverrideSync(dshHome) {
const disk = readPromptInjectFileSync(dshHome);
const norm = normalizeOverride(disk);
if (!norm) return "";
if (hashOverride(norm) === defaultOverrideHash()) return "";
return norm;
}
/** 仅本进程提示词框提交;重启后为空,注入改读 prompt-inject.md(#74)。 */
export function peekCommittedOverride(dshHome) {
if (!committedOverride) return null;
@@ -3716,7 +3690,7 @@ const NEW_TOOL_PATCHES = [
'import { parse, stringify } from "yaml";',
},
{
// 0.1.7 官方已自带 legacyApplyPath;再插一份会导致 SyntaxError,settings 整包起不来。
// 0.2.0-rc.2 已去掉 legacyApplyPath,mutate 走同文件里的 applyPathOp。不要再插函数定义。
pattern:
"/** Project Config schemas into forms and own optional instance-level UI policy. */\n" +
"var SettingsForms = class extends Service {",
@@ -3865,7 +3839,7 @@ const NEW_TOOL_PATCHES = [
"\t\tawait this.write(ns, (current, base, schema) => ops.reduce((value, op) => {",
replace:
"\tasync mutate(ns, ops, expectedRevision) {\n" +
"\t\tif (this.legacyRegistrations?.has(ns)) return this.commitLegacy(ns, (user) => (ops ?? []).reduce((section, op) => legacyApplyPath(section, op), user ?? {}), expectedRevision);\n" +
"\t\tif (this.legacyRegistrations?.has(ns)) return this.commitLegacy(ns, (user) => (ops ?? []).reduce((section, op) => applyPathOp(section, op), user ?? {}), expectedRevision);\n" +
"\t\tawait this.write(ns, (current, base, schema) => ops.reduce((value, op) => {",
},
{
@@ -5792,9 +5766,21 @@ export function collapseDuplicateLegacyApplyPath(text) {
return crlf ? out.replace(/\n/g, "\r\n") : out;
}
const STALE_LEGACY_APPLY_CALL = "=> legacyApplyPath(section, op)";
const SETTINGS_APPLY_CALL = "=> applyPathOp(section, op)";
/** #42 旧产物调用已删除的 legacyApplyPath。只换这一处调用,不动函数定义。 */
function rewriteStaleLegacyApplyCall(text) {
const hay = asLf(text);
if (!hay.includes(STALE_LEGACY_APPLY_CALL)) return text;
const next = hay.split(STALE_LEGACY_APPLY_CALL).join(SETTINGS_APPLY_CALL);
return text.includes("\r\n") ? next.replace(/\n/g, "\r\n") : next;
}
function patchApplied(text, patch) {
const hay = asLf(text);
if (patch?.id === 42 && legacyApplyPathStarts(hay) > 1) return false;
if (patch?.id === 42 && hay.includes(STALE_LEGACY_APPLY_CALL)) return false;
if (Array.isArray(patch.forbid) && patch.forbid.some((marker) => hay.includes(asLf(marker)))) return false;
if (Array.isArray(patch.markers) && patch.markers.length > 0) {
// markersAny:任一标记即可;默认要全部命中。
@@ -5917,6 +5903,11 @@ export function applyReplacementsToText(text, patch, fp = "") {
source = collapsed;
preChanged = true;
}
const rewritten = rewriteStaleLegacyApplyCall(source);
if (rewritten !== source) {
source = rewritten;
preChanged = true;
}
}
// 插入型补丁锚点仍在,已有标记则不再 replaceAll。
if (patch.skipIfMarked && patchApplied(source, patch)) {
@@ -6674,41 +6665,6 @@ export async function readOverrideForUi(dshHome) {
};
}
/** 磁盘尚无正文时,把加密槽写入 prompt-inject.md(显式编辑 / 兜底)。 */
export function seedOverrideSync(dshHome) {
const fp = findOverrideFile(dshHome);
fs.mkdirSync(dshHome, { recursive: true });
let disk = "";
try {
if (fs.existsSync(fp)) disk = fs.readFileSync(fp, "utf8");
} catch {
disk = "";
}
if (normalizeOverride(disk)) return "exists";
const bundled = defaultOverrideText();
if (!normalizeOverride(bundled)) return fs.existsSync(fp) ? "empty" : "missing";
fs.writeFileSync(fp, bundled, "utf8");
try {
const state = readOverrideStateSync(dshHome);
if (state.customized !== true) {
fs.mkdirSync(path.dirname(overrideStatePath(dshHome)), { recursive: true });
fs.writeFileSync(
overrideStatePath(dshHome),
`${JSON.stringify({
customized: false,
hash: hashOverride(bundled),
seedHash: defaultOverrideHash(),
updatedAt: new Date().toISOString(),
}, null, 2)}\n`,
"utf8",
);
}
} catch {
// 状态写失败不挡注入文件
}
return "wrote";
}
/**
* 解包/应用成功后:把加密槽写入 $DSH_HOME/prompt-inject.md(用户自改时不覆盖)。
* force 仅用于显式「恢复默认」。
@@ -6750,16 +6706,6 @@ export async function installOverride(dshHome, force = false) {
return "wrote";
}
/** 应用提交:框内字 > 已有 prompt-inject.md > 加密槽。 */
export function resolveApplyOverrideText(dshHome, incoming) {
if (normalizeOverride(incoming)) return String(incoming);
const disk = readPromptInjectFileSync(dshHome);
if (normalizeOverride(disk)) return disk;
const bundled = defaultOverrideText();
if (normalizeOverride(bundled)) return bundled;
return "";
}
export async function saveOverrideContent(dshHome, content) {
const bundled = defaultOverrideText();
const incoming = typeof content === "string" ? content : "";
@@ -6781,12 +6727,6 @@ export async function saveOverrideContent(dshHome, content) {
return { path: fp, customized, content: incoming, defaultContent: bundled };
}
/** 只读当前提示词。不补内置默认。 */
export async function ensureOverrideContent(dshHome, _force = false) {
const ui = await readOverrideForUi(dshHome);
return { ...ui, installed: ui.exists ? "exists" : "missing" };
}
export function editOverride(dshHome) {
const fp = findOverrideFile(dshHome);
if (!fs.existsSync(fp)) {