fix: accept a path-less skill root URI in normalizeSkillUri (#2295)

`skill://data-analysis` has an authority and an empty path, which RFC 3986
permits, but the guard required a pathname starting with "/". A server echoing
the skill root back in a directory read was therefore labelled "outside this
skill" instead of "not a direct child". Opaque URIs (`skill:demo`) stay
rejected; a path-less root still names no skill file, so it fails every check
that needs one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ2eszDCUqTmhtTMaznw3W
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-09-14 00:00:49 -04:00
commit 528a37be38

View file

@ -174,6 +174,31 @@ describe("normalizeSkillUri", () => {
// `skill:demo/../x.md` parses but keeps its `..` verbatim, so containment
// could not be decided on it — accepting it would reopen the hole.
expect(normalizeSkillUri("skill:demo/SKILL.md")).toBeUndefined();
// Path-less but still opaque: no authority, so it stays rejected.
expect(normalizeSkillUri("skill:demo")).toBeUndefined();
});
it("accepts a path-less authority URI — a skill's root directory (#2295)", () => {
// RFC 3986 gives an authority URI an empty path, so `skill://data-analysis`
// is well-formed; rejecting it mislabelled a root echoed back by a
// directory read as "outside this skill".
expect(normalizeSkillUri("skill://data-analysis")).toBe(
"skill://data-analysis",
);
expect(normalizeSkillUri("skill://%64ata-analysis")).toBe(
"skill://data-analysis",
);
});
it("still treats a path-less root as naming no skill file", () => {
// Accepting the root must not let it pass a check that needs a file.
expect(skillNameFromUri("skill://data-analysis")).toBeUndefined();
const issues = checkSkillConformance({
uri: "skill://data-analysis",
frontmatter: { name: "data-analysis", description: "d" },
resources: [],
});
expect(issues.map((issue) => issue.code)).toContain("malformed-uri");
});
it("decodes escapes that stand for unreserved characters", () => {