Skip to content

g1t/apps/web/app/lib/opened-by.ts

24 lines1,054 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent1import type { Pull } from "@g1t/contracts";
2
3/** g1t's own name: its agent's, and the system's. */
4export const G1T = "g1t";
5
6/**
7 * Whether g1t's own agent made a pull request: in a fork of its own, not
8 * on a branch someone pushed.
9 */
10export function madeByG1t(pull: Pick<Pull, "agent" | "branch">): boolean {
11 return pull.agent === G1T && !pull.branch;
12}
13
14/**
15 * Who shows as having opened a pull request. g1t for one its agent made,
16 * with the person who asked for the work as `requestedBy`; anyone else's
17 * is its author's, with no `requestedBy`. Only the face: who may change
18 * the pull request is still decided by its stored author.
19 */
20export function openedBy(pull: Pick<Pull, "agent" | "branch" | "author">): { name: string; requestedBy: string | null } {
21 if (!madeByG1t(pull)) return { name: pull.author.username, requestedBy: null };
22 // Work g1t started itself, such as a security update's code change, was asked for by nobody else.
23 return { name: G1T, requestedBy: pull.author.username === G1T ? null : pull.author.username };
24}