50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
|
|
let runtimeRoot = "";
|
|
let readState: (typeof import("../src/lib/boss-data"))["readState"];
|
|
let updateMasterAgentEvolutionConfig: (typeof import("../src/lib/boss-data"))["updateMasterAgentEvolutionConfig"];
|
|
|
|
async function setup() {
|
|
if (runtimeRoot) {
|
|
return;
|
|
}
|
|
runtimeRoot = await mkdtemp(path.join(os.tmpdir(), "boss-master-agent-evolution-state-"));
|
|
process.env.BOSS_RUNTIME_ROOT = runtimeRoot;
|
|
process.env.BOSS_STATE_FILE = path.join(runtimeRoot, "boss-state.json");
|
|
const data = await import("../src/lib/boss-data.ts");
|
|
readState = data.readState;
|
|
updateMasterAgentEvolutionConfig = data.updateMasterAgentEvolutionConfig;
|
|
}
|
|
|
|
test.after(async () => {
|
|
if (runtimeRoot) {
|
|
await rm(runtimeRoot, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test.beforeEach(async () => {
|
|
await setup();
|
|
await rm(runtimeRoot, { recursive: true, force: true });
|
|
await mkdir(runtimeRoot, { recursive: true });
|
|
});
|
|
|
|
test("boss state 初始化时包含 master agent evolution 默认配置与空集合", async () => {
|
|
const state = await readState();
|
|
assert.equal(state.masterAgentEvolutionConfig.mode, "controlled");
|
|
assert.equal(state.masterAgentEvolutionConfig.autoApplyLowRiskRules, false);
|
|
assert.deepEqual(state.masterAgentEvolutionSignals, []);
|
|
assert.deepEqual(state.masterAgentEvolutionProposals, []);
|
|
assert.deepEqual(state.masterAgentEvolutionRules, []);
|
|
assert.deepEqual(state.masterAgentEvolutionRunLogs, []);
|
|
});
|
|
|
|
test("master agent evolution 配置可切换 autonomous 并自动打开低风险自动采纳", async () => {
|
|
const config = await updateMasterAgentEvolutionConfig({ mode: "autonomous" });
|
|
assert.equal(config.mode, "autonomous");
|
|
assert.equal(config.autoApplyLowRiskRules, true);
|
|
});
|