The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import type { ServerProviderSkill } from "@t3tools/contracts"; |
| 4 | |
| 5 | import { searchProviderSkills } from "./providerSkillSearch"; |
| 6 | |
| 7 | function makeSkill(input: Partial<ServerProviderSkill> & Pick<ServerProviderSkill, "name">) { |
| 8 | return { |
| 9 | path: `/tmp/${input.name}/SKILL.md`, |
| 10 | enabled: true, |
| 11 | ...input, |
| 12 | } satisfies ServerProviderSkill; |
| 13 | } |
| 14 | |
| 15 | describe("searchProviderSkills", () => { |
| 16 | // regression: #12098 unicode currency symbols must work as skill aliases |
| 17 | it.each(["$", "€", "£", "¥", "₹", "₩", "₿", "𑿝"])( |
| 18 | "searches skills with a %s prefix", |
| 19 | (prefix) => { |
| 20 | const skill = makeSkill({ name: "review" }); |
| 21 | expect(searchProviderSkills([skill], `${prefix}review`)).toEqual([skill]); |
| 22 | }, |
| 23 | ); |
| 24 | |
| 25 | it("uses fuzzy ranking for abbreviated queries", () => { |
| 26 | const skills = [ |
| 27 | makeSkill({ name: "gh-fix-ci", displayName: "Gh Fix Ci" }), |
| 28 | makeSkill({ name: "github", displayName: "Github" }), |
| 29 | makeSkill({ name: "agent-browser", displayName: "Agent Browser" }), |
| 30 | ]; |
| 31 | |
| 32 | expect(searchProviderSkills(skills, "gfc").map((skill) => skill.name)).toEqual(["gh-fix-ci"]); |
| 33 | }); |
| 34 | |
| 35 | it("returns the first enabled definition for each skill name", () => { |
| 36 | const skills = [ |
| 37 | makeSkill({ name: "branch-audit", path: "/Users/matt/.codex/skills/branch-audit/SKILL.md" }), |
| 38 | makeSkill({ name: "browser" }), |
| 39 | makeSkill({ name: "branch-audit", path: "/Users/matt/.agents/skills/branch-audit/SKILL.md" }), |
| 40 | ]; |
| 41 | |
| 42 | expect(searchProviderSkills(skills, "").map((skill) => skill.path)).toEqual([ |
| 43 | "/Users/matt/.codex/skills/branch-audit/SKILL.md", |
| 44 | "/tmp/browser/SKILL.md", |
| 45 | ]); |
| 46 | }); |
| 47 | }); |