Auditor packets can request generation-rule pools without LLM randomness; results land in 运行.本轮.旁观.生成抽样 and clear each play turn. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildChanceBatchFromGenerationRule,
|
|
runMaintainNeedGenerateSampling,
|
|
} from "../src/skills/maintain-need-generate.js";
|
|
|
|
const SAMPLE_RULES = JSON.stringify({
|
|
schema: "context-fragment.v1",
|
|
正文: {
|
|
rules: [
|
|
{
|
|
rule_id: "npc-trait",
|
|
池: [
|
|
{
|
|
pool_id: "mood",
|
|
条目: [
|
|
{ id: "calm", 权重: 2 },
|
|
{ id: "angry", 权重: 1 },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
describe("maintain need_generate sampling", () => {
|
|
it("builds pick requests from generation rule pools", () => {
|
|
const batch = buildChanceBatchFromGenerationRule(SAMPLE_RULES, "npc-trait");
|
|
expect(batch).toHaveLength(1);
|
|
expect(batch![0]!.id).toBe("pool:mood");
|
|
expect(batch![0]!.op).toBe("pick");
|
|
});
|
|
|
|
it("runs batch sampling for need_generate", () => {
|
|
const result = runMaintainNeedGenerateSampling({
|
|
need: { rule_id: "npc-trait", reason: "补一条" },
|
|
generationRulesRaw: SAMPLE_RULES,
|
|
});
|
|
expect(result?.schema).toBe("chance.batch.v1");
|
|
expect(result?.results[0]?.id).toBe("pool:mood");
|
|
});
|
|
});
|