Files
t3code/apps/web/src/providerSkillPresentation.ts
T
5e4bb0cb0c Add provider skill discovery (#1905)
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: codex <[email protected]>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
2026-04-13 14:41:45 -07:00

53 lines
1.4 KiB
TypeScript

import type { ServerProviderSkill } from "@t3tools/contracts";
function titleCaseWords(value: string): string {
return value
.split(/[\s:_-]+/)
.filter((segment) => segment.length > 0)
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
.join(" ");
}
function normalizePathSeparators(pathValue: string): string {
return pathValue.replaceAll("\\", "/");
}
export function formatProviderSkillDisplayName(
skill: Pick<ServerProviderSkill, "name" | "displayName">,
): string {
const displayName = skill.displayName?.trim();
if (displayName) {
return displayName;
}
return titleCaseWords(skill.name);
}
export function formatProviderSkillInstallSource(
skill: Pick<ServerProviderSkill, "path" | "scope">,
): string | null {
const normalizedPath = normalizePathSeparators(skill.path);
if (normalizedPath.includes("/.codex/plugins/") || normalizedPath.includes("/.agents/plugins/")) {
return "App";
}
const normalizedScope = skill.scope?.trim().toLowerCase();
if (normalizedScope === "system") {
return "System";
}
if (
normalizedScope === "project" ||
normalizedScope === "workspace" ||
normalizedScope === "local"
) {
return "Project";
}
if (normalizedScope === "user" || normalizedScope === "personal") {
return "Personal";
}
if (normalizedScope) {
return titleCaseWords(normalizedScope);
}
return null;
}