fix: 发布 1.1.55,重启后提示词稳定注入且不再误取消

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-03 16:49:49 +08:00
1 parent e139407af8
commit 6cdf5596cd
10 files changed
+124 -178

No files matched your search

-65
View File
@@ -1,65 +0,0 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-purge-stamp-"));
process.env.DSH_HOME = tmp;
const {
stampMatches,
resolveApplySha,
markPatchesApplied,
readAppliedStamp,
healEmptyAppliedStamp,
ensureInstalledRevSeed,
shouldSkipSettleRestart,
markSettleRestart,
canHealEmptyStamp,
} = await import("../lib/reapply.js");
assert.equal(stampMatches({ version: "1.1.52", sha: "" }, "1.1.52", "abc"), false);
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "abc"), true);
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", ""), true);
assert.equal(stampMatches({ version: "1.1.52", sha: "apply:1.1.52" }, "1.1.52", "deadbeef"), true);
assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "def"), false);
assert.equal(stampMatches({ version: "1.1.51", sha: "abc" }, "1.1.52", "abc"), false);
// #56:空 sha 仍不能当对齐;#57:密封/缺标记不能就地补戳。
assert.equal(canHealEmptyStamp({ sealed: true, hasAiBase: true, markersPresent: true }), false);
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: false }), false);
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: true }), true);
assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: false, markersPresent: false }), true);
assert.equal(resolveApplySha("deadbeef"), "deadbeef");
assert.match(resolveApplySha(""), /^(apply:|applied)/);
const sha = markPatchesApplied();
assert.ok(sha);
assert.ok(sha.length > 0);
const stamp = readAppliedStamp();
assert.equal(stamp.sha, sha);
assert.ok(stamp.sha);
const revFile = path.join(tmp, "dsh-purge", "installed-rev");
assert.equal(fs.readFileSync(revFile, "utf8").trim(), sha);
assert.equal(stampMatches(stamp, stamp.version, sha), true);
fs.writeFileSync(path.join(tmp, "dsh-purge", "applied.json"), `${JSON.stringify({
version: stamp.version,
sha: "",
at: new Date().toISOString(),
}, null, 2)}\n`);
assert.equal(healEmptyAppliedStamp(), true);
assert.ok(readAppliedStamp().sha);
// #60:缺 installed-rev 时种子
fs.rmSync(path.join(tmp, "dsh-purge", "installed-rev"), { force: true });
const seeded = ensureInstalledRevSeed();
assert.ok(seeded);
assert.equal(fs.readFileSync(path.join(tmp, "dsh-purge", "installed-rev"), "utf8").trim(), seeded);
assert.equal(shouldSkipSettleRestart(), false);
markSettleRestart();
assert.equal(shouldSkipSettleRestart(), true);
console.log("ok: reapply stamp / infinite-restart guards");
-50
View File
@@ -1,50 +0,0 @@
import assert from "node:assert/strict";
import {
DESKTOP_SETTLE_DELAY_MS,
isInactiveContextError,
settleDelayMs,
settleMayReapply,
settleMayRestart,
watchContextLife,
} from "../lib/settle-policy.js";
assert.equal(settleMayRestart({ surface: "desktop", sealed: false }), false);
assert.equal(settleMayRestart({ surface: "desktop", sealed: true }), false);
assert.equal(settleMayRestart({ surface: "web", sealed: true }), false);
assert.equal(settleMayRestart({ surface: "web", sealed: false }), true);
assert.equal(settleMayReapply({ surface: "desktop", sealed: true }), false);
assert.equal(settleMayReapply({ surface: "desktop", sealed: false }), true);
assert.equal(settleMayReapply({ surface: "web", sealed: false }), true);
assert.equal(settleDelayMs("desktop"), DESKTOP_SETTLE_DELAY_MS);
assert.equal(settleDelayMs("web"), 0);
assert.ok(DESKTOP_SETTLE_DELAY_MS >= 3000);
assert.equal(isInactiveContextError({ code: "INACTIVE_EFFECT" }), true);
assert.equal(isInactiveContextError(new Error("cannot create effect on inactive context")), true);
assert.equal(isInactiveContextError(new Error("ENOENT")), false);
const missing = watchContextLife(null);
assert.equal(missing.alive, true);
let disposed = null;
const active = watchContextLife({
effect(factory) {
disposed = factory();
},
});
assert.equal(active.alive, true);
disposed();
assert.equal(active.alive, false);
const inactive = watchContextLife({
effect() {
const err = new Error("cannot create effect on inactive context");
err.code = "INACTIVE_EFFECT";
throw err;
},
});
assert.equal(inactive.alive, false);
console.log("ok: settle policy / inactive-context guards");