49 lines
2.2 KiB
TypeScript
49 lines
2.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { parseConfig } from "../src/config.js";
|
|
import { BotProfileResolver } from "../src/roles/role-registry.js";
|
|
|
|
function resolvedBot(botOverrides: Record<string, unknown> = {}) {
|
|
const config = parseConfig({
|
|
configVersion: 3,
|
|
bot: {
|
|
id: "test-bot", workspace: "/tmp", persona: "Worker 人格:严格的安全/运维边界。",
|
|
agent: { id: "kimi", command: "kimi", args: ["acp"], env: {} },
|
|
skills: [], permissions: { mode: "deny" },
|
|
...botOverrides
|
|
},
|
|
gateway: { platform: { type: "webhook", secret: "secret" } },
|
|
runtime: {}
|
|
});
|
|
return new BotProfileResolver(config).bot;
|
|
}
|
|
|
|
test("assistant uses assistantPersona while worker keeps persona", () => {
|
|
const bot = resolvedBot({ assistantPersona: "Assistant 人格:像运维老同事一样说人话。" });
|
|
assert.match(bot.assistantBootstrap, /Assistant 人格:像运维老同事一样说人话。/);
|
|
assert.doesNotMatch(bot.assistantBootstrap, /Worker 人格:严格的安全\/运维边界。/);
|
|
assert.match(bot.workerBootstrap, /Worker 人格:严格的安全\/运维边界。/);
|
|
assert.doesNotMatch(bot.workerBootstrap, /Assistant 人格/);
|
|
});
|
|
|
|
test("assistant falls back to persona when assistantPersona is empty", () => {
|
|
const bot = resolvedBot();
|
|
assert.match(bot.assistantBootstrap, /Worker 人格:严格的安全\/运维边界。/);
|
|
assert.match(bot.workerBootstrap, /Worker 人格:严格的安全\/运维边界。/);
|
|
});
|
|
|
|
test("assistant bootstrap carries human speaking-style rules, worker bootstrap does not", () => {
|
|
const bot = resolvedBot({ assistantPersona: "Assistant 人格" });
|
|
assert.match(bot.assistantBootstrap, /reliable colleague/);
|
|
assert.match(bot.assistantBootstrap, /conclusion, then the reason, then the next step/);
|
|
assert.match(bot.assistantBootstrap, /2-4 sentences/);
|
|
assert.match(bot.assistantBootstrap, /actionable next step/);
|
|
assert.doesNotMatch(bot.workerBootstrap, /reliable colleague/);
|
|
});
|
|
|
|
test("assistantPersona participates in the bot fingerprint", () => {
|
|
const base = resolvedBot();
|
|
const withPersona = resolvedBot({ assistantPersona: "Assistant 人格" });
|
|
assert.notEqual(base.fingerprint, withPersona.fingerprint);
|
|
});
|