«Peppa FACTORY» → «FORGE» в экранах, сообщениях, словарях en/kk, шаблоне и тестах; «Пеппа» → «FORGE» в подсказках агентам и правилах; логотип, значок, версия кэша service worker; в словаре старые названия — в «Нельзя». Внутренние имена (CLI peppa, PEPPA_*, MCP-сервер peppa, ключи PEP-N) не меняются. Второй адрес — в mac-route.sh. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
75 lines
4.3 KiB
TypeScript
75 lines
4.3 KiB
TypeScript
// PEP-75: the platform's team of agents — Kazakh names, one persona per story, character in the
|
||
// agent's prompt (mock-claude sees it in the rules file).
|
||
import assert from "node:assert/strict";
|
||
import { readFileSync } from "node:fs";
|
||
import { after, describe, test } from "node:test";
|
||
import { core, db, project, runner, teardown } from "./helpers.ts";
|
||
|
||
process.env.PEPPA_SECRET = "mock-secret-for-tests";
|
||
after(teardown);
|
||
|
||
const rulesOf = (e: object) => {
|
||
const argv = (e as { argv?: string[] }).argv ?? [];
|
||
return readFileSync(argv[argv.indexOf("--append-system-prompt-file") + 1]!, "utf8");
|
||
};
|
||
|
||
describe("Команда агентов", () => {
|
||
test("Scenario: первая стори получает агента с казахским именем, имя и характер — в промпте", async () => {
|
||
assert.deepEqual(await core.listAgents(db), []);
|
||
const p = await project({ turns: [[{ say: "ok" }]] });
|
||
const sid = await p.start();
|
||
const start = await p.waitLog("started", (e) => e.ev === "start");
|
||
const s = await core.getSession(db, sid);
|
||
assert.equal(s.agentName, core.AGENT_NAMES[0]);
|
||
assert.match(rulesOf(start), new RegExp(`Твоя кличка — \\*\\*${core.AGENT_NAMES[0]}\\*\\*: ты ИИ-агент`));
|
||
const proj = await core.getProject(db, p.key);
|
||
assert.equal((await core.taskAgentNames(db, proj.id)).get((await p.task()).id), core.AGENT_NAMES[0]);
|
||
const [a] = await core.listAgents(db);
|
||
assert.equal(a!.busy, 1);
|
||
|
||
// The PM gives a character; a resume of the same runner keeps the persona and carries it.
|
||
await core.updateAgent(db, a!.id, { character: "Педант по безопасности: любой ввод проверяет." });
|
||
await runner.stopSession(db, sid);
|
||
await runner.resumeSession(db, sid, { prompt: "дальше" });
|
||
const again = await p.waitLog("resumed", (e) => e.ev === "start" && rulesOf(e).includes("Педант по безопасности"));
|
||
assert.match(rulesOf(again), /правила FORGE и AGENTS\.md проекта важнее/);
|
||
assert.equal((await core.getSession(db, sid)).agentName, core.AGENT_NAMES[0]);
|
||
await runner.stopSession(db, sid);
|
||
});
|
||
|
||
test("Scenario: занятый агент не делится — второй раннер получает нового; свободный берётся снова", async () => {
|
||
const p1 = await project({ turns: [[{ say: "ok" }]] });
|
||
const p2 = await project({ turns: [[{ say: "ok" }]] });
|
||
const s1 = await p1.start();
|
||
const s2 = await p2.start();
|
||
const n1 = (await core.getSession(db, s1)).agentName;
|
||
const n2 = (await core.getSession(db, s2)).agentName;
|
||
assert.equal(n1, core.AGENT_NAMES[0], "the free persona of the first test is reused");
|
||
assert.equal(n2, core.AGENT_NAMES[1], "everyone busy → a new persona with the next name");
|
||
await runner.stopSession(db, s1);
|
||
await runner.stopSession(db, s2);
|
||
|
||
// The story's next runner gets the story's persona, even though another one rested longer.
|
||
const s3 = await p2.start();
|
||
assert.equal((await core.getSession(db, s3)).agentName, n2);
|
||
await runner.stopSession(db, s3);
|
||
});
|
||
|
||
test("имена: свои, дубли, выбывший из команды", async () => {
|
||
const mine = await core.createAgent(db, { name: " Қайсар " });
|
||
assert.equal(mine.name, "Қайсар");
|
||
await assert.rejects(core.createAgent(db, { name: "қайсар" }), /уже есть/);
|
||
await assert.rejects(core.updateAgent(db, mine.id, { name: core.AGENT_NAMES[0] }), /уже есть/);
|
||
await assert.rejects(core.updateAgent(db, mine.id, { character: "x".repeat(core.AGENT_CHARACTER_MAX + 1) }), /длиннее/);
|
||
assert.equal((await core.createAgent(db)).name, core.AGENT_NAMES[2], "auto name = the next free one");
|
||
|
||
// Out of the team: not picked for new stories.
|
||
for (const a of await core.listAgents(db)) if (a.id !== mine.id) await core.updateAgent(db, a.id, { disabled: true });
|
||
const p = await project({ turns: [[{ say: "ok" }]] });
|
||
const sid = await p.start();
|
||
assert.equal((await core.getSession(db, sid)).agentName, "Қайсар");
|
||
await runner.stopSession(db, sid);
|
||
assert.equal(core.agentPrompt({ name: "Дана", character: "" }).includes("характер"), false);
|
||
});
|
||
});
|