← Public packages
@kody/kody-factory
Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.
Files
/**
* Read-only GitHub readiness check for one repo (default: the pilot's first repo).
* Never writes, never hangs on an unmapped credential, prints no credential data.
*/
import { loadSettings } from '../lib/settings.ts'
import { githubPreflight, optionalGithubFetch, NOT_REQUESTED, PREVIEW_PERMISSIONS, SHIP_PERMISSIONS } from '../lib/github-permissions.ts'
import type { GithubFetch } from '../lib/github-readonly.ts'
/**
* @param params - `{ repoRef? }` (must be in the pilot scope's repoRefs when set)
* @example
* import preflight from 'kody:@kody/kody-factory/github-preflight'
* await preflight({ repoRef: 'kody-hq/kody' })
*/
export default async function githubPreflightExport(params: { repoRef?: string } = {}, deps: { fetch?: GithubFetch | null } = {}) {
const scope = (await loadSettings()).pilotScope
const repoRef = params?.repoRef ?? scope.repoRefs[0]
if (!repoRef) return { ok: false, error: 'No repoRef given and no pilot scope repo set.', required: { preview: PREVIEW_PERMISSIONS, ship: SHIP_PERMISSIONS, notRequested: NOT_REQUESTED } }
if (scope.mode !== 'all' && scope.repoRefs.length && !scope.repoRefs.some((r) => r.toLowerCase() === repoRef.toLowerCase())) {
return { ok: false, error: `${repoRef} is outside the pilot scope.` }
}
const fetchFn = deps.fetch !== undefined ? deps.fetch : await optionalGithubFetch()
const result = await githubPreflight(fetchFn, repoRef)
return { ok: true, ...result, required: { preview: PREVIEW_PERMISSIONS, ship: SHIP_PERMISSIONS, notRequested: NOT_REQUESTED } }
}