@@ -2,6 +2,8 @@ import { afterEach, beforeEach, describe, expect, it } from "bun:test"
22import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
33import { tmpdir } from "node:os"
44import { join } from "node:path"
5+ import { agents } from "../src/metadata"
6+ import { AGENT_NAMES } from "../src/paths.mjs"
57
68describe("postinstall.mjs", () => {
79 const testDir = join(tmpdir(), `opencoder-test-${Date.now()}`)
@@ -58,6 +60,32 @@ describe("agent files existence", () => {
5860 })
5961})
6062
63+ describe("agent metadata consistency", () => {
64+ const agentsDir = join(import.meta.dir, "..", "agents")
65+
66+ it("should have AGENT_NAMES match agents export from metadata", () => {
67+ expect(AGENT_NAMES).toEqual(agents)
68+ })
69+
70+ it("should have agents export match actual files in agents/ directory", () => {
71+ const actualFiles = readdirSync(agentsDir)
72+ .filter((f) => f.endsWith(".md"))
73+ .map((f) => f.replace(/\.md$/, ""))
74+ .sort()
75+ const expectedAgents = [...agents].sort()
76+ expect(actualFiles).toEqual(expectedAgents)
77+ })
78+
79+ it("should have AGENT_NAMES match actual files in agents/ directory", () => {
80+ const actualFiles = readdirSync(agentsDir)
81+ .filter((f) => f.endsWith(".md"))
82+ .map((f) => f.replace(/\.md$/, ""))
83+ .sort()
84+ const expectedAgents = [...AGENT_NAMES].sort()
85+ expect(actualFiles).toEqual(expectedAgents)
86+ })
87+ })
88+
6189describe("agent files YAML frontmatter", () => {
6290 const agentsDir = join(import.meta.dir, "..", "agents")
6391 const agentFiles = ["opencoder.md", "opencoder-planner.md", "opencoder-builder.md"]
0 commit comments