Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

providerSkills.test.ts

120 lines3.4 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import {
4 formatProviderSkillDisplayName,
5 getProviderSlashCommandsForSlashMenu,
6 getProviderSkillsForSlashMenu,
7 resolveProviderSkillSourceKind,
8} from "./providerSkills.ts";
9​
10describe("formatProviderSkillDisplayName", () => {
11 it("prefers the provider display name", () => {
12 expect(
13 formatProviderSkillDisplayName({
14 name: "review-follow-up",
15 displayName: "Review Follow-up",
16 }),
17 ).toBe("Review Follow-up");
18 });
19​
20 it("falls back to a title-cased skill name", () => {
21 expect(
22 formatProviderSkillDisplayName({
23 name: "review-follow-up",
24 }),
25 ).toBe("Review Follow Up");
26 });
27});
28​
29describe("getProviderSkillsForSlashMenu", () => {
30 it("keeps the skill alias when the provider also exposes it as a slash command", () => {
31 const askMatt = {
32 name: "ask-matt",
33 path: "/Users/matt/.agents/skills/ask-matt/SKILL.md",
34 enabled: true,
35 };
36 expect(getProviderSkillsForSlashMenu([askMatt], true).map((skill) => skill.name)).toEqual([
37 "ask-matt",
38 ]);
39 });
40});
41​
42describe("getProviderSlashCommandsForSlashMenu", () => {
43 const commands = [
44 { name: "ask-matt", description: "Ask which skill fits your situation." },
45 { name: "compact", description: "Compact the conversation." },
46 ];
47 const skills = [
48 {
49 name: "ask-matt",
50 path: "/Users/matt/.agents/skills/ask-matt/SKILL.md",
51 enabled: true,
52 },
53 ];
54​
55 it("lets the skill alias win when a provider command has the same name", () => {
56 expect(
57 getProviderSlashCommandsForSlashMenu(commands, skills).map((command) => command.name),
58 ).toEqual(["compact"]);
59 });
60​
61 it("keeps the provider command when the matching skill alias is hidden", () => {
62 const visibleSkills = getProviderSkillsForSlashMenu(skills, false);
63​
64 expect(
65 getProviderSlashCommandsForSlashMenu(commands, visibleSkills).map((command) => command.name),
66 ).toEqual(["ask-matt", "compact"]);
67 });
68});
69​
70describe("resolveProviderSkillSourceKind", () => {
71 it("marks plugin-backed skills as app installs", () => {
72 expect(
73 resolveProviderSkillSourceKind({
74 path: "/Users/julius/.codex/plugins/cache/openai-curated/github/skills/gh-fix-ci/SKILL.md",
75 scope: "user",
76 }),
77 ).toBe("app");
78 });
79​
80 it("maps standard scopes to source kinds", () => {
81 expect(
82 resolveProviderSkillSourceKind({
83 path: "/workspace/.codex/skills/review-follow-up/SKILL.md",
84 scope: "repo",
85 }),
86 ).toBe("repo");
87 expect(
88 resolveProviderSkillSourceKind({
89 path: "/workspace/.codex/skills/review-follow-up/SKILL.md",
90 scope: "project",
91 }),
92 ).toBe("project");
93 expect(
94 resolveProviderSkillSourceKind({
95 path: "/Users/julius/.agents/skills/agent-browser/SKILL.md",
96 scope: "user",
97 }),
98 ).toBe("personal");
99 expect(
100 resolveProviderSkillSourceKind({
101 path: "/usr/local/share/codex/skills/imagegen/SKILL.md",
102 scope: "system",
103 }),
104 ).toBe("system");
105 });
106​
107 it("keeps unknown and missing scopes usable", () => {
108 expect(
109 resolveProviderSkillSourceKind({
110 path: "/opt/skills/team-review/SKILL.md",
111 scope: "team_shared",
112 }),
113 ).toBe("other");
114 expect(
115 resolveProviderSkillSourceKind({
116 path: "/opt/skills/team-review/SKILL.md",
117 }),
118 ).toBe("other");
119 });
120});