d92c5f827d
Duplicate names in resourceLoader resolve to the first skill with a one-time UI warning during re-inject expansion. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
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",
|
|
);
|
|
});
|
|
});
|