Phase 12: skill name collision warn — SPEC §11.
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>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user