重构世界模拟器为模块化配方架构,完善创作编排、会话运行时与 Web UI,并清理过时技能。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-30 00:39:32 +08:00
parent 2b74c30d36
commit e670a5129c
167 changed files with 22955 additions and 5659 deletions

View File

@@ -1,6 +1,11 @@
import { describe, expect, it } from "vitest";
import { assemblePresetMessages } from "../src/preset/assembler.js";
import { listEnabledPresetEntries, countInjectingEntries } from "../src/preset/entries.js";
import {
applyPresetEntryPatches,
countInjectingEntries,
listAllPresetEntries,
listEnabledPresetEntries,
} from "../src/preset/entries.js";
import { importSillyTavernPreset } from "../src/preset/importer.js";
const samplePreset = {
@@ -82,3 +87,29 @@ describe("listEnabledPresetEntries", () => {
]);
});
});
describe("applyPresetEntryPatches", () => {
it("toggles enable and edits content", () => {
const report = importSillyTavernPreset(samplePreset);
const disabled = applyPresetEntryPatches(report.preset, [
{ id: "custom-a", enabled: false },
]);
expect(listAllPresetEntries(disabled).find((e) => e.id === "custom-a")?.enabled).toBe(
false,
);
expect(assemblePresetMessages(disabled).map((m) => m.content)).toEqual([
"prefill B",
]);
const edited = applyPresetEntryPatches(disabled, [
{ id: "main", enabled: true, content: "hello main", name: "主提示" },
]);
const main = listAllPresetEntries(edited).find((e) => e.id === "main");
expect(main?.enabled).toBe(true);
expect(main?.willInject).toBe(true);
expect(main?.name).toBe("主提示");
expect(
assemblePresetMessages(edited).some((m) => m.content === "hello main"),
).toBe(true);
});
});