feat: add skill installer (#279)

* feat: add skill installer with install/uninstall and settings UI

* feat: refactor skill installer with extracted SkillLibraryList component

* feat: simplify SkillsEditor, extract SkillLibraryList

* feat: refactor skill installer components and add github utility
This commit is contained in:
Chris Scott authored and GitHub committed 2026-06-17 23:11:29 -04:00
1 parent 24d34f28a3
commit 6e80cdfb8c
24 files changed
+2381 -577

No files matched your search

+3 -14
View File
@@ -1,4 +1,5 @@
import type { GitCredential } from '@opencode-manager/shared'
import { githubFetch } from './github'
export function isGitHubHttpsUrl(repoUrl: string): boolean {
const url = normalizeGitCredentialUrl(repoUrl)
@@ -202,20 +203,8 @@ export function createGitIdentityEnv(identity: GitIdentity): Record<string, stri
export async function fetchGitHubUserInfo(token: string): Promise<GitHubUserInfo | null> {
try {
const [userResponse, emailsResponse] = await Promise.all([
fetch('https://api.github.com/user', {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28'
}
}),
fetch('https://api.github.com/user/emails', {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28'
}
})
githubFetch('https://api.github.com/user', { token, apiVersion: '2022-11-28' }),
githubFetch('https://api.github.com/user/emails', { token, apiVersion: '2022-11-28' }),
])
if (!userResponse.ok) return null
+45
View File
@@ -0,0 +1,45 @@
export type GithubFetchFn = (url: string | URL | Request, init?: RequestInit) => Promise<Response>
interface GithubRequestOptions {
token?: string
apiVersion?: string
accept?: string
}
export function githubFetch(
url: string,
options: GithubRequestOptions = {},
fetchFn: GithubFetchFn = fetch,
): Promise<Response> {
const headers: Record<string, string> = {
Accept: options.accept ?? 'application/vnd.github+json',
'User-Agent': 'opencode-manager',
}
if (options.token) headers.Authorization = `Bearer ${options.token}`
if (options.apiVersion) headers['X-GitHub-Api-Version'] = options.apiVersion
return fetchFn(url, { headers })
}
export async function githubFetchJson<T = unknown>(
url: string,
options: GithubRequestOptions = {},
fetchFn: GithubFetchFn = fetch,
): Promise<T> {
const response = await githubFetch(url, options, fetchFn)
if (!response.ok) {
throw new Error(`GitHub request failed with status ${response.status}`)
}
return response.json() as Promise<T>
}
export async function githubFetchBinary(
url: string,
options: GithubRequestOptions = {},
fetchFn: GithubFetchFn = fetch,
): Promise<ArrayBuffer> {
const response = await githubFetch(url, options, fetchFn)
if (!response.ok) {
throw new Error(`GitHub request failed with status ${response.status}`)
}
return response.arrayBuffer()
}