UNPKG

aiwg

Version:

Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo

69 lines 1.9 kB
/** * GitHub Adapter * * Resolves "github:owner/name[@version]" shorthands against github.com. * * Authentication: * - SSH clone: uses default SSH agent * - HTTPS clone: reads token from GITHUB_TOKEN env or ~/.aiwg/credentials/github * * @implements #557 */ import { existsSync } from 'fs'; import { readFile } from 'fs/promises'; import { join } from 'path'; import { homedir } from 'os'; import { GitAdapter } from './git.js'; const GITHUB_HOST = 'github.com'; /** * Read GitHub token from standard locations */ async function readGitHubToken() { if (process.env.GITHUB_TOKEN) return process.env.GITHUB_TOKEN; const tokenPaths = [ join(homedir(), '.aiwg', 'credentials', 'github'), ]; for (const p of tokenPaths) { if (existsSync(p)) { return (await readFile(p, 'utf-8')).trim(); } } return undefined; } /** * GitHubAdapter * * Handles "github:owner/repo[@version]" shorthands. */ export class GitHubAdapter extends GitAdapter { id = 'github'; name = 'GitHub (shorthand)'; /** * Matches "github:owner/repo" and "github:owner/repo@version" */ canResolve(ref) { return ref.startsWith('github:'); } async resolve(ref) { if (!ref.owner || !ref.name) return null; const token = await readGitHubToken(); let gitUrl; if (token) { gitUrl = `https://${token}@${GITHUB_HOST}/${ref.owner}/${ref.name}.git`; } else { gitUrl = `git@${GITHUB_HOST}:${ref.owner}/${ref.name}.git`; } return { gitUrl, ref: ref.version, label: `github.com/${ref.owner}/${ref.name}${ref.version ? `@${ref.version}` : ''}`, }; } async fetch(source, options = {}) { return super.fetch(source, options); } } //# sourceMappingURL=github.js.map