AkurAI Build
Menu

popagent

public

Latest change cfe185c25c9dd469690ca202ee3a02629e6925be - fix: align agent capabilities by AkurAI Build

import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import { AgentSkillStore } from "./agent-skills";
import { agentSettings } from "./agent-settings";

const store = new AgentSkillStore();
const name = `test-skill-${crypto.randomUUID().slice(0, 8)}`;
let skillId: string | undefined;

beforeAll(async () => {
  await agentSettings.init();
  await store.init();
});
afterAll(async () => {
  if (skillId) await store.delete("orchistrator", skillId);
});

describe("AgentSkillStore", () => {
  test("bootstraps source-attributed skills for every system agent", async () => {
    const expected = {
      orchistrator: ["delivery-coordination", "multi-agent-orchestration", "popagent-cli"],
      researcher: ["codebase-investigation", "source-research"],
      implementer: ["implementation-verification", "minimal-change-implementation"],
      reviewer: ["code-review", "evidence-gate"],
      "build-maintainer": ["build-maintenance"],
      "build-release-manager": ["governed-release"],
      "community-steward": ["public-community"],
    };
    for (const [agentId, names] of Object.entries(expected)) {
      const skills = await store.list(agentId);
      expect(skills.map((skill) => skill.name)).toEqual(expect.arrayContaining(names));
      for (const skill of skills.filter((item) => names.includes(item.name))) {
        if (skill.name === "popagent-cli") {
          expect(skill.instructions).toContain("./popagent help");
          expect(skill.instructions).toContain("Popagent Docs is canonical");
        } else if (skill.agentId.startsWith("build-") || skill.agentId === "community-steward") {
          expect(skill.sourceUrls).toEqual(
            expect.arrayContaining([expect.stringContaining("olibuijr/AkurAI-Build")]),
          );
        } else {
          expect(skill.sourceUrls).toEqual(
            expect.arrayContaining([expect.stringContaining("msitarzewski/agency-agents")]),
          );
        }
      }
    }
  });

  test("creates, updates, resolves, and deletes an agent skill", async () => {
    const created = await store.create("orchistrator", {
      name,
      description: "Use for the persisted skill test.",
      instructions: "Answer persisted skill tests with SKILL_READY.",
      references: { "guide.md": "Reference content" },
      enabled: true,
      userInvocable: true,
    });
    skillId = created.id;
    expect(created.evolutionManaged).toBe(false);
    await store.storage.db.none(
      "UPDATE popagent_agent_skills SET evolution_managed=TRUE WHERE id=$1",
      [created.id],
    );
    expect((await store.list("orchistrator")).find((skill) => skill.id === created.id)?.evolutionManaged).toBe(true);
    expect(await store.list("orchistrator")).toContainEqual(expect.objectContaining({ id: created.id, name }));
    expect((await store.resolve("orchistrator")).map((skill) => skill.name)).toContain(name);

    const updated = await store.update("orchistrator", created.id, { ...created, enabled: false });
    expect(updated).toMatchObject({ enabled: false, evolutionManaged: false });
    expect((await store.list("orchistrator")).find((skill) => skill.id === created.id)?.evolutionManaged).toBe(false);
    expect((await store.resolve("orchistrator")).map((skill) => skill.name)).not.toContain(name);

    expect(await store.delete("orchistrator", created.id)).toBe(true);
    skillId = undefined;
    expect(await store.delete("orchistrator", created.id)).toBe(false);
  });
});