UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

82 lines (81 loc) • 4.28 kB
import { type Json } from "./protocol.js"; import { detectHost } from "./git-hosts.js"; export { checkRollup, checkRuns } from "./git-hosts.js"; interface Counts { additions: number; deletions: number; binary: boolean; countsComplete: boolean; } /** NUL records preserve tabs/newlines in names and both sides of renames. */ export declare function parseNumstat(out: string): Map<string, Counts>; /** The remote's default branch as its `HEAD` records it. With no recorded * `HEAD`, `main` and `master` are treated as default so the guard errs on the * side of asking. */ export declare function defaultBranch(root: string, remote?: string): Promise<string | null>; export interface GitStatusFile { path: string; status: string; staged: boolean; additions: number; deletions: number; binary?: boolean; directory?: boolean; countsComplete?: boolean; } export interface GitStatus { repository: string; observedAt: string; truncated: boolean; countsComplete: boolean; totalFiles: number; branch: string; upstream: string | null; ahead: number; behind: number; staged: number; unstaged: number; untracked: number; additions: number; deletions: number; files: GitStatusFile[]; /** The branch a push guards: the upstream remote's `HEAD`, else `main`/`master`. */ defaultBranch: string | null; host: Awaited<ReturnType<typeof detectHost>>; } /** Working-tree status, one record per section: a file edited in both the index * and the working tree appears once with `staged: true` and once with `false`. */ export declare function gitStatus(cwd: string, untrackedPath?: string): Promise<GitStatus>; /** Commits newest first, plus a one-line summary of what is not committed yet. */ export declare function gitLog(cwd: string, limit?: number, ref?: string): Promise<Json>; /** Local branches with their upstream and ahead/behind counts, and remote refs. */ export declare function gitBranches(cwd: string): Promise<Json>; /** Invalidate every branch/host lookup of this checkout's repository after a Hook write. */ export declare function invalidatePulls(root: string): void; /** Tokens belong to a domain, so revoke every checkout and pending generation. */ export declare function invalidatePullsForDomain(domain: string): void; /** Open pull or merge requests and the checked-out branch's own (any state) * with its checks, from whichever host the remote is on (git-hosts.ts). A * host that cannot answer (a missing CLI, a stubbed provider, an unknown * domain) is `{ available: false, reason, message }`, never an error. */ export declare function gitPulls(cwd: string, retried?: boolean): Promise<Json>; /** A repo-relative tree path, or the repository root for `""`. */ export declare function repositoryPath(root: string, raw: unknown, allowRoot?: boolean): Promise<string>; /** Drop the cached tree after a write (commit, push) outside this module. */ export declare function invalidateTree(root: string): void; /** One lazy directory response from a bounded repo/HEAD/status-hash snapshot. * Every request still validates the pane's repo and the requested path. A HEAD * move invalidates immediately; external working-tree edits age out after 2s. * Status refresh and phone mutations invalidate immediately as well. With * `ignored`, git-ignored folders and files at that level are added, marked. */ export declare function gitTree(cwd: string, relPath?: unknown, ignored?: boolean): Promise<Json>; export declare function gitStage(cwd: string, paths: unknown, confirmBulk?: boolean): Promise<Json>; export declare function gitUnstage(cwd: string, paths: unknown): Promise<Json>; /** Destructive: tracked files go back to the index, untracked files are * removed. The phone confirms first; no `-d` (directories) and no `-x`. */ export declare function gitDiscard(cwd: string, paths: unknown): Promise<Json>; /** One commit as the phone's commit screen shows it: message, author and * committer, parents and refs, and every file it changed against its first * parent (what GitHub shows for a merge) with counts and a bounded patch in * the same section shape `/v1/diff` uses. */ export declare function gitShow(cwd: string, sha: unknown): Promise<Json>;