import { describe, expect, it, vi } from "vitest"; import { registeredSkillsByName } from "../src/reinject"; describe("registeredSkillsByName", () => { it("keeps the first skill when names collide", () => { const first = { name: "alpha", filePath: "/a/SKILL.md", baseDir: "/a" }; const second = { name: "alpha", filePath: "/b/SKILL.md", baseDir: "/b" }; const byName = registeredSkillsByName([first, second]); expect(byName.get("alpha")).toBe(first); }); it("warns once per duplicate name", () => { const notify = vi.fn(); const ctx = { hasUI: true, ui: { notify } } as never; const skills = [ { name: "alpha", filePath: "/a/SKILL.md", baseDir: "/a" }, { name: "alpha", filePath: "/b/SKILL.md", baseDir: "/b" }, { name: "alpha", filePath: "/c/SKILL.md", baseDir: "/c" }, ]; registeredSkillsByName(skills, ctx); expect(notify).toHaveBeenCalledTimes(1); expect(notify).toHaveBeenCalledWith( 'skill-reinject: duplicate skill name "alpha" — using first from resourceLoader', "warning", ); }); });