From a339d706c1c2ead779de5ef57218f13a11e44c77 Mon Sep 17 00:00:00 2001 From: Devin Robison Date: Mon, 23 Mar 2026 16:56:54 -0600 Subject: [PATCH] Formatting fixes and remove trailing dash acceptance --- src/agents/skills-clawhub.test.ts | 41 ++++++++++++++++++++++++++----- src/agents/skills-clawhub.ts | 2 +- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/agents/skills-clawhub.test.ts b/src/agents/skills-clawhub.test.ts index e28f8bfe185..3fc98cc139e 100644 --- a/src/agents/skills-clawhub.test.ts +++ b/src/agents/skills-clawhub.test.ts @@ -101,7 +101,10 @@ describe("skills-clawhub", () => { workspaceDir: "/tmp/workspace", slug: "re\u0430ct", }); - expect(result).toMatchObject({ ok: false, error: expect.stringContaining("Invalid skill slug") }); + expect(result).toMatchObject({ + ok: false, + error: expect.stringContaining("Invalid skill slug"), + }); }); it("rejects Cyrillic homograph 'е' (U+0435) in slug", async () => { @@ -109,7 +112,10 @@ describe("skills-clawhub", () => { workspaceDir: "/tmp/workspace", slug: "r\u0435act", }); - expect(result).toMatchObject({ ok: false, error: expect.stringContaining("Invalid skill slug") }); + expect(result).toMatchObject({ + ok: false, + error: expect.stringContaining("Invalid skill slug"), + }); }); it("rejects Cyrillic homograph 'о' (U+043E) in slug", async () => { @@ -117,7 +123,10 @@ describe("skills-clawhub", () => { workspaceDir: "/tmp/workspace", slug: "t\u043Edo", }); - expect(result).toMatchObject({ ok: false, error: expect.stringContaining("Invalid skill slug") }); + expect(result).toMatchObject({ + ok: false, + error: expect.stringContaining("Invalid skill slug"), + }); }); it("rejects slug with mixed Unicode and ASCII", async () => { @@ -125,7 +134,10 @@ describe("skills-clawhub", () => { workspaceDir: "/tmp/workspace", slug: "cаlеndаr", }); - expect(result).toMatchObject({ ok: false, error: expect.stringContaining("Invalid skill slug") }); + expect(result).toMatchObject({ + ok: false, + error: expect.stringContaining("Invalid skill slug"), + }); }); it("rejects slug with non-Latin scripts", async () => { @@ -133,7 +145,10 @@ describe("skills-clawhub", () => { workspaceDir: "/tmp/workspace", slug: "技能", }); - expect(result).toMatchObject({ ok: false, error: expect.stringContaining("Invalid skill slug") }); + expect(result).toMatchObject({ + ok: false, + error: expect.stringContaining("Invalid skill slug"), + }); }); it("rejects slug starting with a hyphen", async () => { @@ -141,7 +156,21 @@ describe("skills-clawhub", () => { workspaceDir: "/tmp/workspace", slug: "-calendar", }); - expect(result).toMatchObject({ ok: false, error: expect.stringContaining("Invalid skill slug") }); + expect(result).toMatchObject({ + ok: false, + error: expect.stringContaining("Invalid skill slug"), + }); + }); + + it("rejects slug ending with a hyphen", async () => { + const result = await installSkillFromClawHub({ + workspaceDir: "/tmp/workspace", + slug: "calendar-", + }); + expect(result).toMatchObject({ + ok: false, + error: expect.stringContaining("Invalid skill slug"), + }); }); it("accepts valid ASCII slugs", async () => { diff --git a/src/agents/skills-clawhub.ts b/src/agents/skills-clawhub.ts index a5dd893bafb..f5564d9262b 100644 --- a/src/agents/skills-clawhub.ts +++ b/src/agents/skills-clawhub.ts @@ -62,7 +62,7 @@ type Logger = { info?: (message: string) => void; }; -const VALID_SLUG_PATTERN = /^[a-z0-9][a-z0-9-]*$/; +const VALID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/; function normalizeSlug(raw: string): string { const slug = raw.trim().toLowerCase();