/** Skillfarm's own repos live on Branchwell, not GitHub. Other makers' repos stay on GitHub. */ export const BRANCHWELL = 'https://branchwell.ai'; /** Repo names still stored in the database for Skillfarm's own skills, and where each one lives on Branchwell. */ const OWN_REPOS: Record = { 'projectatomai/skills': 'skillfarm/skills', }; /** The Branchwell owner/project for one of Skillfarm's own repos, or null for anyone else's repo. */ export function ownRepo(repo: string | null | undefined): string | null { return repo ? OWN_REPOS[repo.toLowerCase()] ?? null : null; } /** The web address of a repo, or of a folder in it, on the host where it lives. */ export function repoWebUrl(repo: string, path?: string | null, ref?: string | null): string { const own = ownRepo(repo); const clean = (path ?? '').replace(/^\/+|\/+$/g, ''); if (own) return `${BRANCHWELL}/${own}${clean ? `/tree/main/${clean}` : ''}`; return `https://github.com/${repo}${clean ? `/tree/${ref ?? 'HEAD'}/${clean}` : ''}`; } /** The address to clone a repo from. */ export function repoCloneUrl(repo: string): string { const own = ownRepo(repo); return own ? `${BRANCHWELL}/${own}.git` : `https://github.com/${repo}.git`; } /** The repo name to show people: Skillfarm's own repos show their Branchwell name. */ export function repoLabel(repo: string): string { return ownRepo(repo) ?? repo; } /** The name of the site a link goes to, for button text such as "Get it on Branchwell". */ export function hostName(url: string): string { try { const host = new URL(url).hostname.replace(/^www\./, ''); if (host === 'branchwell.ai') return 'Branchwell'; if (host === 'github.com') return 'GitHub'; if (host === 'gitlab.com') return 'GitLab'; return host; } catch { return 'the maker\'s site'; } }