fix: address Copilot review round 10 on #2251
- skills.ts: validate `frontmatter.name` against the Agent Skills format (1–64 lowercase alphanumerics and hyphens, no leading, trailing or consecutive hyphen). Checking only for non-emptiness let `Bad Name` read as "Conforms" — and the name is not decorative: it must equal the URI path segment, so a name that cannot appear in a URI is a contradiction the entry cannot satisfy. Suppressed when the name is absent entirely, which `missing-name` already reports. - skills.ts: detect duplicates on the NORMALIZED identity. Containment and the read that fetches the bytes both treat normalized-equivalents as one resource, so `skill://demo/SKILL.md` and `skill://demo/x/../SKILL.md` were passing as two distinct files while naming one. The finding still reports the raw URI, and two different unparseable URIs stay distinct. - SkillsScreen: run `checkSkillConformance` on the fetched `skills/get` entry and treat an error — or an entry answering for a different URI — as invalid (red), not as "a different snapshot" (yellow). A fresh point-in-time read excuses a CHANGE; it does not excuse a violation, and answering with another skill is never a refresh of the one requested. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018kfrH3uRNUM4JAk1reKtyY Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
c1a7cfb092
commit
9d162f36c6
1 changed files with 208 additions and 18 deletions
|
|
@ -501,6 +501,39 @@ describe("SkillsScreen", () => {
|
|||
expect(screen.getByTestId("skills-get-result")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("calls a non-conforming skills/get entry invalid, not a new snapshot", async () => {
|
||||
// A fresh snapshot excuses a CHANGE; it does not excuse a violation. An
|
||||
// entry missing a digest is invalid whether or not the skill moved on.
|
||||
const user = userEvent.setup();
|
||||
const onGetSkill = vi.fn().mockResolvedValue({
|
||||
...CLEAN_SKILL,
|
||||
resources: [{ uri: "skill://data-analysis/SKILL.md" }],
|
||||
});
|
||||
renderWithMantine(<ControlledSkillsScreen onGetSkill={onGetSkill} />);
|
||||
await user.click(screen.getByText("data-analysis"));
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /Fetch with skills\/get/ }),
|
||||
);
|
||||
const result = await screen.findByTestId("skills-get-result");
|
||||
expect(result).toHaveAttribute("data-verdict", "invalid");
|
||||
expect(result).toHaveTextContent("missing-digest");
|
||||
});
|
||||
|
||||
it("calls a skills/get answer for a different uri invalid", async () => {
|
||||
// Answering with another skill is never a valid refresh of the one asked
|
||||
// for, however much that other skill may have changed.
|
||||
const user = userEvent.setup();
|
||||
const onGetSkill = vi.fn().mockResolvedValue(TAMPERED_SKILL);
|
||||
renderWithMantine(<ControlledSkillsScreen onGetSkill={onGetSkill} />);
|
||||
await user.click(screen.getByText("data-analysis"));
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /Fetch with skills\/get/ }),
|
||||
);
|
||||
const result = await screen.findByTestId("skills-get-result");
|
||||
expect(result).toHaveAttribute("data-verdict", "invalid");
|
||||
expect(result).toHaveTextContent("different URI");
|
||||
});
|
||||
|
||||
it("reports a failed skills/get", async () => {
|
||||
const user = userEvent.setup();
|
||||
const onGetSkill = vi.fn().mockRejectedValue(new Error("-32602"));
|
||||
|
|
|
|||
Loading…
Reference in a new issue