@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
47 lines (46 loc) • 2.41 kB
TypeScript
import type { GitHostProvider, HostTerms } from "./git-hosts.js";
import { HostApiError } from "./git-host-http.js";
import type { Json } from "./protocol.js";
/** gitboy, the self-hosted forge, over its REST API (/api/v1). gitboy names a
* pull request by `index`, and an older gitboy has no draft state, no aggregate review decision
* and no web links in its answers, so this provider derives them: web pages
* are `<origin>/<owner>/<repo>/pulls/<n>` and `/pipelines/<iid>?job=<id>`, a
* review decision counts approvals on the head commit, and a newer gitboy
* that sends `html_url`, `draft` or `review_decision` is taken at its word.
* The token is GITBOY_TOKEN (for the domain GITBOY_HOST names) or the Hook's stored one, a gbp_ personal access
* token with read:user and read:repo (write:repo to open or merge); gitboy's
* "Phren Hook" token preset grants exactly those. A gitboy with head_branch and
* sha filters gets them; an older one ignores them and the client filters below
* still pick the right rows. */
export declare const PULL_TERMS: HostTerms;
type Order = "failing" | "pending" | "passing" | "skipped" | "neutral";
/** A gitboy job or pipeline status as one state word. */
export declare function gitboyState(status: unknown, allowFailure?: boolean): Order;
interface Ctx {
api: string;
web: string;
repo: string;
token: string;
domain: string;
account: {
source: string;
user?: string;
};
}
/** Whether a pull request's head lives in this repository rather than a fork
* with a branch of the same name. gitboy names it in `head_repository`
* (owner_username, name); a row without one is taken as this repository's. */
export declare function sameRepository(ctx: Pick<Ctx, "repo">, pull: Json): boolean;
/** gitboy's reasons it will not merge: a 409's `details`, else the message. */
export declare function refusalReasons(error: HostApiError): string;
/** GitHub's reviewDecision from gitboy's reviews: each reviewer's latest
* verdict on the head commit, the author's own left out. */
export declare function gitboyReviewDecision(pull: Json): string | undefined;
/** gitboy's mergeability and blockers in GitHub's mergeStateStatus words. */
export declare function gitboyMergeState(pull: Json): {
mergeState?: string;
mergeDetail?: string;
blockers?: string[];
};
export declare const gitboy: GitHostProvider;
export {};