Open History to see the last commit
1import type { ServerProviderSkill } from "@t3tools/contracts";
2
3function titleCaseWords(value: string): string {
4 return value
5 .split(/[\s:_-]+/)
6 .filter((segment) => segment.length > 0)
7 .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
8 .join(" ");
9}
10
11function normalizePathSeparators(pathValue: string): string {
12 return pathValue.replaceAll("\\", "/");
13}
14
15export function formatProviderSkillDisplayName(
16 skill: Pick<ServerProviderSkill, "name" | "displayName">,
17): string {
18 const displayName = skill.displayName?.trim();
19 if (displayName) {
20 return displayName;
21 }
22 return titleCaseWords(skill.name);
23}
24
25export function formatProviderSkillInstallSource(
26 skill: Pick<ServerProviderSkill, "path" | "scope">,
27): string | null {
28 const normalizedPath = normalizePathSeparators(skill.path);
29 if (normalizedPath.includes("/.codex/plugins/") || normalizedPath.includes("/.agents/plugins/")) {
30 return "App";
31 }
32
33 const normalizedScope = skill.scope?.trim().toLowerCase();
34 if (normalizedScope === "system") {
35 return "System";
36 }
37 if (
38 normalizedScope === "project" ||
39 normalizedScope === "workspace" ||
40 normalizedScope === "local"
41 ) {
42 return "Project";
43 }
44 if (normalizedScope === "user" || normalizedScope === "personal") {
45 return "Personal";
46 }
47 if (normalizedScope) {
48 return titleCaseWords(normalizedScope);
49 }
50
51 return null;
52}