53 lines · 1.4 KB · TypeScript
RawDownload
import type { ServerProviderSkill } from "@t3tools/contracts"; function titleCaseWords(value: string): string {  const words: string[] = [];  for (const segment of value.split(/[\s:_-]+/)) {    if (segment.length === 0) continue;    words.push(segment.charAt(0).toUpperCase() + segment.slice(1));  }  return words.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;}