import { describe, expect, it } from "vitest"; import { augmentProjectBrainInitialize, handleProjectBrainSkillMethod } from "../src/mcp/skills.js"; type SkillList = { skills: Array<{ uri: string }> }; type SkillResource = { contents: Array<{ text: string }> }; describe("ProjectBrain MCP skills", () => { it("publishes canonical public workflows for repository bootstrap and delivery", () => { const listed = handleProjectBrainSkillMethod("skills/list", {}) as SkillList; const uris = listed.skills.map((skill) => skill.uri); expect(uris).toContain("skill://projectbrain/repository-bootstrap/SKILL.md"); expect(uris).toContain("skill://projectbrain/feature-delivery/SKILL.md"); const bootstrap = handleProjectBrainSkillMethod("resources/read", { uri: "skill://projectbrain/repository-bootstrap/SKILL.md" }) as SkillResource; expect(bootstrap.contents[0]?.text).toContain("gitea.repository.create"); expect(bootstrap.contents[0]?.text).toContain("projectbrain.portfolio.repository.reconcile"); const delivery = handleProjectBrainSkillMethod("resources/read", { uri: "skill://projectbrain/feature-delivery/SKILL.md" }) as SkillResource; expect(delivery.contents[0]?.text).toContain("projectbrain.delivery.changeset.apply"); expect(delivery.contents[0]?.text).toContain("projectbrain.delivery.merge"); expect(delivery.contents[0]?.text).toContain("gitea.workspace.run"); expect(delivery.contents[0]?.text).not.toContain("apply_feature_changeset"); expect(delivery.contents[0]?.text).not.toContain("merge_feature_delivery"); }); it("publishes the Gitea-first Auto execution contract", () => { const operator = handleProjectBrainSkillMethod("resources/read", { uri: "skill://projectbrain/projectbrain-operator/SKILL.md" }) as SkillResource; const text = operator.contents[0]?.text ?? ""; expect(text).toContain("Gitea is the only primary repository execution surface"); expect(text).toContain("projectbrain/auto/"); expect(text).toContain("atomic execution claim"); expect(text).toContain("exact-head validation evidence"); expect(text).toContain("missing or interrupted report_auto_work callback"); expect(text).toContain("No OpenAI API key is required"); }); it("advertises Gitea as the primary Auto execution surface during MCP initialization", () => { const initialized = augmentProjectBrainInitialize({ result: { capabilities: {} } }) as { result: { instructions: string }; }; expect(initialized.result.instructions).toContain( "Gitea as its only primary repository execution surface", ); expect(initialized.result.instructions).toContain("projectbrain/auto/"); expect(initialized.result.instructions).toContain("Branch existence is the atomic claim"); expect(initialized.result.instructions).toContain( "report_auto_work are backward-compatible coordination/bookkeeping surfaces only", ); expect(initialized.result.instructions).toContain( "Never write directly to the default branch", ); }); });