UNPKG

framework

Version:

The (AI) Framework: turnkey, zero-config AI orchestration that wraps a coding-agent CLI (Claude Code) as a black box and takes you from an idea to a running app. Vite for AI.

34 lines 1.96 kB
import { nodeGitRunner } from '../project.js'; import { cachedPrView, cachedPrsForBranch, pickAgentPr } from './gh.js'; /** * Read a project's git status: the current branch and dirty flag (from git), plus the linked * PR (best-effort). Returns undefined when the path is not a git repo. Forgiving — a failed * `git status` reads as clean, and a failed PR lookup simply omits the PR. */ export async function readGitStatus(cwd, deps = {}) { const git = deps.git ?? nodeGitRunner(); let branch; try { branch = (await git(['rev-parse', '--abbrev-ref', 'HEAD'], cwd)).trim(); } catch { return undefined; // not a git repo (or git failed) } const dirty = (await git(['status', '--porcelain'], cwd).catch(() => '')).trim().length > 0; // The branch and the dirty flag are what this row is for, and they are ten milliseconds of git. // The PR is a `gh` call an order of magnitude slower, so it is read through the cache and is // allowed to arrive late (#1028) rather than holding the whole row back on every poll. const pr = await linkedPr(cwd, branch, deps); return { branch, dirty, ...(pr.value ? { pr: pr.value } : {}), ...(pr.pending ? { prPending: true } : {}) }; } /** The PR half of the status: the injected seam, the run-scoped history pick, or the plain view. */ async function linkedPr(cwd, branch, deps) { if (deps.pr) return { value: await deps.pr(cwd).catch(() => undefined), pending: false }; if (deps.since === undefined) return cachedPrView(cwd).catch(() => ({ value: undefined, pending: false })); if (deps.prs) return { value: pickAgentPr(await deps.prs(cwd, branch).catch(() => []), deps.since), pending: false }; return cachedPrsForBranch(cwd, branch).then(read => ({ value: pickAgentPr(read.value ?? [], deps.since), pending: read.pending }), () => ({ value: undefined, pending: false })); } //# sourceMappingURL=git-status.js.map