Skip to content
459 linesCodeBlameRaw

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.

Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971import type { Contributors, Languages, License, NewRelease, Release, ReleaseChange, RepoAbout, Stargazer, StarredRepo, Stars } from "./about";
Initial g1t: services, event bus, intents and attempts2import type { User, Viewer } from "./identity";
3import type { Result } from "./result";
4
5export type Repo = {
6 id: string;
Workspaces own repositories7 /** The slug of the workspace that owns it: the first URL segment. */
Initial g1t: services, event bus, intents and attempts8 namespace: string;
9 name: string;
10 description: string | null;
11 isPrivate: boolean;
12 ownerId: string;
13 defaultBranch: string;
Issues and pull requests replace intents and attempts14 /** Set when this repo is a pull request's working copy of another repo. */
Initial g1t: services, event bus, intents and attempts15 forkOf: string | null;
Agents as a team: lifecycle, merge queue, billing and a new shell16 /**
17 * Whether the default branch is protected: it changes only by merging a
18 * pull request, and pushes to it are refused.
19 */
20 protected: boolean;
RFC 3339 timestamps in identity and repos21 /** RFC 3339. */
22 createdAt: string;
Search across all of g1t, Explore, and a command palette23 /**
24 * Words that say what it is about, for search and Explore: lowercase
25 * letters, digits and hyphens, at most 20.
26 */
27 topics: string[];
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look28 /** Its home page, an http(s) address. */
29 website?: string | null;
30 /**
31 * RFC 3339: when it was archived. While archived it is read-only:
32 * pushes, merges, agents and workflows are refused, and issues and pull
33 * requests are locked. Null when it is not archived.
34 */
35 archivedAt?: string | null;
36};
37
38/** How long a deleted repository can be restored before it is purged. */
39export const RESTORE_DAYS = 30;
40
41/** A deleted repository, as its workspace's Recently deleted list shows it. */
42export type DeletedRepo = {
43 id: string;
44 namespace: string;
45 name: string;
46 description: string | null;
47 isPrivate: boolean;
48 /** RFC 3339. */
49 deletedAt: string;
50 /** The username of who deleted it. */
51 deletedBy: string;
52 /** RFC 3339: when it is purged, unless restored first. */
53 purgeAfter: string;
Initial g1t: services, event bus, intents and attempts54};
55
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look56/** Whether a repository is archived or deleted, for services deciding whether to act on it. */
57export type RepoStatus = { archived: boolean; deleted: boolean };
58
Search across all of g1t, Explore, and a command palette59/** The most topics a repository has, and the longest topic. */
60export const MAX_TOPICS = 20;
61export const MAX_TOPIC_CHARS = 35;
62
Initial g1t: services, event bus, intents and attempts63export type RepoPath = { namespace: string; name: string };
64
65export type Commit = {
66 hash: string;
67 treeHash: string;
68 message: string;
69 author: { name: string; email: string };
70 parents: string[];
RFC 3339 timestamps in identity and repos71 /** RFC 3339. */
72 authoredAt: string;
Initial g1t: services, event bus, intents and attempts73};
74
75export type TreeEntry = {
76 name: string;
77 hash: string;
78 kind: "tree" | "blob" | "symlink" | "gitlink" | "exec";
79};
80
81export type TreeView = {
82 repo: Repo;
83 ref: string;
84 path: string;
85 /** Null when the repo has no commits yet. */
86 head: Commit | null;
87 entries: TreeEntry[];
88 readme: { name: string; text: string | null } | null;
89};
90
91export type BlobView = {
92 repo: Repo;
93 ref: string;
94 path: string;
95 size: number;
96 /** Null when the file is binary or too large to show. */
97 text: string | null;
98};
99
100/** A git remote and a short-lived credential for it. */
101export type GitAccess = { remote: string; token: string };
102
103export type GitService = "git-upload-pack" | "git-receive-pack";
104
105export type CreateRepoInput = {
Workspaces own repositories106 /** The workspace to create it in; the creator must be a member. */
107 namespace: string;
Initial g1t: services, event bus, intents and attempts108 name: string;
109 description?: string | null;
110 isPrivate?: boolean;
Agents as a team: lifecycle, merge queue, billing and a new shell111 /**
112 * The https address of a public git repository to copy the default branch
113 * of, such as `https://github.com/owner/repo`.
114 */
115 importUrl?: string;
Initial g1t: services, event bus, intents and attempts116};
117
Merge branch 'worktree-agent-a2013627e5ea4ab13'118/**
119 * Where repositories may be kept. `euAvailable`: an EU namespace takes new
120 * repositories, so a workspace may keep its data in the EU.
121 */
122export type StorageOptions = { euAvailable: boolean };
123
Initial g1t: services, event bus, intents and attempts124/** Repositories: metadata, contents and git access. */
125export interface ReposApi {
126 get(path: RepoPath, viewer: Viewer): Promise<Result<Repo>>;
127 getById(id: string, viewer: Viewer): Promise<Result<Repo>>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains128 /**
Fast pages, required checks on the branch, self-hosted runners, honest incidents129 * Of these ids (at most 500), the repositories the viewer can read, in
130 * one call. Forks and deleted repositories are left out.
131 */
132 readable(ids: string[], viewer: Viewer): Promise<Repo[]>;
133 /**
Agents and memory, checks and conflicts, profiles, slug renames, custom domains134 * The workspaces in which this account made a public repository, and so
135 * a public project anyone can see. By account id.
136 */
137 publicNamespaces(ownerId: string): Promise<string[]>;
Initial g1t: services, event bus, intents and attempts138 /** Repos the viewer may see, newest first, optionally matching `query`. */
Workspaces own repositories139 list(
140 viewer: Viewer,
141 options?: {
142 query?: string;
143 /** Only repos in this workspace. */
144 namespace?: string;
145 /** Only repos in workspaces the viewer belongs to. */
146 memberOnly?: boolean;
147 },
148 ): Promise<Repo[]>;
Initial g1t: services, event bus, intents and attempts149 create(owner: User, input: CreateRepoInput): Promise<Result<Repo>>;
Agents as a team: lifecycle, merge queue, billing and a new shell150 /**
151 * Changes whichever details are given. Members of the repository's
152 * workspace only. An empty description clears it.
153 */
154 update(
155 actor: User,
156 path: RepoPath,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look157 changes: {
158 description?: string;
159 isPrivate?: boolean;
160 protected?: boolean;
161 topics?: string[];
162 /** An empty string clears it. */
163 website?: string;
164 },
Agents as a team: lifecycle, merge queue, billing and a new shell165 ): Promise<Result<Repo>>;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look166 /**
167 * Deletes the repository. Owners only, who type its full name as
168 * `confirm`. It is hidden at once and can be restored for
169 * `RESTORE_DAYS` days, then purged. Publishes `repo.deleted`.
170 */
171 delete(actor: User, path: RepoPath, confirm: string): Promise<Result<DeletedRepo>>;
172 /** A workspace's recently deleted repositories, newest first. Owners only; empty otherwise. */
173 deleted(viewer: Viewer, namespace: string): Promise<DeletedRepo[]>;
174 /** Brings a deleted repository back as it was. Owners only. Publishes `repo.restored`. */
175 restore(actor: User, path: RepoPath): Promise<Result<Repo>>;
176 /**
177 * Removes a deleted repository for good now, its git data with it, and
178 * frees its name. Owners only, who type its full name. Publishes `repo.purged`.
179 */
180 purge(actor: User, path: RepoPath, confirm: string): Promise<Result<boolean>>;
181 /**
182 * Renames the repository in its workspace. Owners only. The old path
183 * redirects until a repository is made there. Publishes `repo.renamed`.
184 */
185 rename(actor: User, path: RepoPath, name: string): Promise<Result<Repo>>;
186 /**
187 * Archives the repository (read-only) or unarchives it. Owners only.
188 * Publishes `repo.archived` or `repo.unarchived`.
189 */
190 archive(actor: User, path: RepoPath, archived: boolean): Promise<Result<Repo>>;
191 /**
192 * Makes the repository public or private. Owners only, who type its full
193 * name as `confirm`. Publishes `repo.updated` and `repo.visibility_changed`.
194 */
195 setVisibility(actor: User, path: RepoPath, isPrivate: boolean, confirm: string): Promise<Result<Repo>>;
196 /** Makes another existing branch the default. Members. */
197 setDefaultBranch(actor: User, path: RepoPath, branch: string): Promise<Result<Repo>>;
198 /**
199 * Renames a branch; pull requests from it follow, and addresses naming the
200 * old one redirect. Members; only owners rename the default branch.
201 */
202 renameBranch(actor: User, path: RepoPath, from: string, to: string): Promise<Result<Repo>>;
203 /** What a branch renamed away from `branch` is called now, or null. */
204 resolveBranch(repoId: string, branch: string): Promise<string | null>;
205 /** Whether a repository is archived or deleted; an unknown id answers as deleted. */
206 statusById(id: string): Promise<RepoStatus>;
Merge branch 'worktree-agent-a2013627e5ea4ab13'207 /** What a workspace may choose about where its repositories are kept. */
208 storageOptions(): Promise<StorageOptions>;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look209 /**
210 * Moves the repository to the workspace `to`, keeping its name, id and
211 * everything under it. The actor must own both workspaces. The old path
212 * redirects until a repository is made there. Publishes `repo.transferred`.
213 */
214 transfer(actor: User, path: RepoPath, to: string): Promise<Result<Repo>>;
215 /**
216 * Where a repository transferred away from `path` is now; null when
217 * `path` is a repository or never was one that moved. Callers check the
218 * viewer may see it there.
219 */
220 resolvePath(path: RepoPath): Promise<RepoPath | null>;
Initial g1t: services, event bus, intents and attempts221
222 tree(path: RepoPath, viewer: Viewer, ref: string | null, treePath: string): Promise<Result<TreeView>>;
223 blob(path: RepoPath, viewer: Viewer, ref: string, filePath: string): Promise<Result<BlobView>>;
224 log(path: RepoPath, viewer: Viewer, ref: string | null, limit: number): Promise<Result<Commit[]>>;
Agents as a team: lifecycle, merge queue, billing and a new shell225 /**
226 * Who last changed each line of a file as of `ref` (the default branch if
227 * null). Not found when the file is missing or is not text.
228 */
229 blame(path: RepoPath, viewer: Viewer, ref: string | null, filePath: string): Promise<Result<Blame>>;
Initial g1t: services, event bus, intents and attempts230
231 /**
Issues and pull requests replace intents and attempts232 * A copy-on-write copy of `source`, hidden from listings, for one pull request
Initial g1t: services, event bus, intents and attempts233 * to work in.
234 */
Issues and pull requests replace intents and attempts235 forkForPull(sourceId: string, pullId: string, actor: User): Promise<Result<Repo>>;
Initial g1t: services, event bus, intents and attempts236
237 /**
238 * Authorizes a git operation and returns where to send it. Pushing to a
239 * repo that does not exist creates it in the pusher's own namespace.
240 */
241 gitAccess(path: RepoPath, viewer: Viewer, service: GitService): Promise<Result<GitAccess>>;
Rust repos service with shipping; pull requests kept in the model242
Pull requests from branches243 /** The repository's branches, default branch first. */
244 branches(path: RepoPath, viewer: Viewer): Promise<Result<Branch[]>>;
245
Branches and Tags pages, each file's last commit, and the branch menu on files246 /** Which commit last changed each entry of a directory at `ref` (the default branch when null). */
247 lastCommits(path: RepoPath, viewer: Viewer, ref: string | null, treePath: string): Promise<Result<LastCommits>>;
248
Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25249 /**
250 * How far each branch head has moved from `base` (the default branch's
251 * head commit), with each head's commit and `base`'s own, in one call.
252 * Kept by the pair of hashes in the repos service.
253 */
254 branchDrift(path: RepoPath, viewer: Viewer, base: string, heads: string[]): Promise<Result<BranchDrifts>>;
255
Branches and Tags pages, each file's last commit, and the branch menu on files256 /** The repository's tags, newest commit first, at most 100. */
257 tags(path: RepoPath, viewer: Viewer): Promise<Result<Tag[]>>;
258
Rust repos service with shipping; pull requests kept in the model259 /**
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97260 * The Files page's About in one answer: license, security policy,
261 * languages, contributors, stars and releases. What comes from files and
262 * history is kept by commit and worked out in the background when it is
263 * behind the head (see `about.ts`).
264 */
265 about(path: RepoPath, viewer: Viewer): Promise<Result<RepoAbout>>;
266 languages(path: RepoPath, viewer: Viewer): Promise<Result<Languages>>;
267 /** Everyone whose commits are on the default branch, with their weeks. */
268 contributors(path: RepoPath, viewer: Viewer): Promise<Result<Contributors>>;
269 license(path: RepoPath, viewer: Viewer): Promise<Result<License | null>>;
270 /** How many starred it, and whether the viewer did. */
271 stars(path: RepoPath, viewer: Viewer): Promise<Result<Stars>>;
272 /** Stars it for the actor, or takes the star back. */
273 star(actor: User, path: RepoPath, starred: boolean): Promise<Result<Stars>>;
274 /** Who starred it, newest first, 100 a page from 1. */
275 stargazers(path: RepoPath, viewer: Viewer, page?: number): Promise<Result<Stargazer[]>>;
276 /** What a person starred that the viewer can see, newest first, at most 100. */
277 starred(username: string, viewer: Viewer): Promise<StarredRepo[]>;
278 /** Releases, newest first, at most 100: drafts only for those who can push. */
279 releases(path: RepoPath, viewer: Viewer): Promise<Result<Release[]>>;
280 /** One release by id or tag, or the latest. */
281 release(path: RepoPath, viewer: Viewer, which: { id?: string; tag?: string; latest?: boolean }): Promise<Result<Release>>;
282 /** Needs Write. A tag that does not exist yet is made at `target`. */
283 createRelease(actor: User, path: RepoPath, release: NewRelease): Promise<Result<Release>>;
284 updateRelease(actor: User, path: RepoPath, id: string, change: ReleaseChange): Promise<Result<Release>>;
285 /** The tag stays. */
286 deleteRelease(actor: User, path: RepoPath, id: string): Promise<Result<boolean>>;
287
288 /**
Download ZIP from the Code button; a slimmer lifecycle panel; agent steps say what was done, not sandbox paths289 * Every file at `ref` (the default branch when null), at most `limit`
290 * (10,000 at most). No viewer: check access first.
291 */
292 listFiles(repoId: string, ref: string | null, limit: number): Promise<FileList>;
293
294 /** Blobs' bytes as standard base64, at most 100; `data` is null for one missing or over `maxBytes`. No viewer. */
295 rawBlobs(repoId: string, hashes: string[], maxBytes: number): Promise<RawBlob[]>;
296
Repository files and avatars on g1tusercontent.com: raw files, a Raw button, images on file pages and in READMEs297 /** One file's bytes at a branch, tag or commit; null when missing or over `maxBytes`. No viewer: check access first. */
298 rawFile(repoId: string, ref: string, path: string, maxBytes: number): Promise<RawFile | null>;
299
Download ZIP from the Code button; a slimmer lifecycle panel; agent steps say what was done, not sandbox paths300 /**
Fast pages, required checks on the branch, self-hosted runners, honest incidents301 * Writes one file on a new branch made from the default branch's head, as
302 * one commit by `actor`, for a change g1t proposes on their behalf (a
303 * starter workflow). Refused unless they may push, when the branch exists,
304 * or when the file is already there.
305 */
306 commitFile(
307 repo: RepoPath,
308 actor: User,
309 file: { branch: string; path: string; content: string; message: string },
310 ): Promise<Result<{ branch: string; commit: string }>>;
311
312 /**
Pull requests from branches313 * Moves a repository's default branch to the head of a pull request's
314 * source: a fork (`sourceId` is the fork) or one of the repository's own
315 * branches (`sourceId` is the repository, and `branch` is required).
316 * Refused with "conflict" when the source is behind, since that would
Rust repos service with shipping; pull requests kept in the model317 * discard commits.
318 */
Pull requests from branches319 land(sourceId: string, actor: User, branch?: string | null): Promise<Result<{ commit: string; previous: string | null }>>;
Diffs on attempts; hosted agent presented as the g1t agent320
321 /**
Pull requests from branches322 * What `head` changes relative to `base`. `head` is a branch or a commit
323 * and defaults to the default branch. With no `base`, a fork is compared
324 * with the last commit it shares with the repository it came from, and a
325 * branch with the point where it left the default branch.
Diffs on attempts; hosted agent presented as the g1t agent326 */
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar327 /**
328 * With no `base`, a branch is compared from where it left `baseBranch`
329 * (the default branch when absent).
330 */
331 compare(
332 repoId: string,
333 viewer: Viewer,
334 base?: string | null,
335 head?: string | null,
336 baseBranch?: string | null,
337 ): Promise<Result<Comparison>>;
Merge branch 'worktree-agent-ac5b181a013e54348'338
339 /**
340 * Services only, for the runner's sweep: up to `limit` queued nightly
341 * backups, each now running with a token of its own, so long as no more
342 * than `maxRunning` are then running. Empty when backups are off.
343 */
344 claimBackups(limit: number, maxRunning: number): Promise<BackupClaim[]>;
345
346 /**
347 * Services only: a backup's sandbox stopped before it reported, so the
348 * job is tried again later. Refused harmlessly once it has reported.
349 */
350 failBackup(jobId: string, token: string, error: string): Promise<Result<boolean>>;
Initial g1t: services, event bus, intents and attempts351}
Diffs on attempts; hosted agent presented as the g1t agent352
Merge branch 'worktree-agent-ac5b181a013e54348'353/**
354 * A nightly backup to start (`g1t_contracts::backups`): the sandbox is
355 * given the job's id and token, and nothing else.
356 */
357export type BackupClaim = {
358 jobId: string;
359 token: string;
360 repoId: string;
361 path: RepoPath;
362};
363
Agents as a team: lifecycle, merge queue, billing and a new shell364/** Lines `start` to `end` (inclusive, from 1) last changed by `commit`. */
365export type BlameRange = { start: number; end: number; commit: string };
366
367/** Who last changed each line of a file. */
368export type Blame = {
369 /** The commit the file was read at. */
370 head: string;
371 /** Every line, in order, in runs that share a commit. */
372 ranges: BlameRange[];
373 /** The commits the ranges name, each once. */
374 commits: Commit[];
375 /** True when the history was too long to read in full. */
376 partial: boolean;
377};
378
Pull requests from branches379/** A branch and the commit it points to. */
380export type Branch = { name: string; hash: string };
381
Branches and Tags pages, each file's last commit, and the branch menu on files382/** Each entry's last commit; `complete` is false when some were not reached. */
383export type LastCommits = { entries: { name: string; commit: Commit }[]; complete: boolean };
384
Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25385/** Commits a branch has that the default branch does not, and the other way round. */
386export type BranchDriftCount = { ahead: number; behind: number };
387
388/**
389 * `base`'s commit, and each head's commit and drift in the order asked;
390 * `drift` is null when the two histories do not meet within what is read.
391 */
392export type BranchDrifts = {
393 base: Commit | null;
394 branches: { head: string; commit: Commit | null; drift: BranchDriftCount | null }[];
395};
396
Branches and Tags pages, each file's last commit, and the branch menu on files397/** A tag, and its commit when it could be read. */
398export type Tag = { name: string; commit: Commit | null };
399
Download ZIP from the Code button; a slimmer lifecycle panel; agent steps say what was done, not sandbox paths400/** Files at a commit, and whether there were more than were listed. */
401export type FileList = { commit: string | null; files: { path: string; hash: string | null }[]; truncated: boolean };
402
403/** One blob's bytes, standard base64; null when missing or too large. */
404export type RawBlob = { hash: string; size: number; data: string | null };
405
Repository files and avatars on g1tusercontent.com: raw files, a Raw button, images on file pages and in READMEs406/** One file's bytes, standard base64. */
407export type RawFile = { size: number; data: string };
408
Catching up with main takes seconds when the two sides touched different files409/**
410 * What came of bringing a pull request up to date with the default branch
411 * without a sandbox. `needs_agent` pushed nothing: the runner's `update`
412 * merges it in a sandbox, with an agent if it conflicts.
413 */
414export type PullBranchUpdate =
415 | { outcome: "updated"; commit: string; previous: string }
416 | { outcome: "up_to_date"; commit: string }
417 | {
418 outcome: "needs_agent";
419 /**
420 * `overlap`: both sides changed some of the same files. `conflicting`:
421 * merging is known to conflict. `unsupported`: it could not be worked
422 * out without git, such as for a very large change.
423 */
424 reason: "overlap" | "conflicting" | "unsupported";
425 detail: string;
426 /** The files both changed, or that conflict, when known. */
427 paths: string[];
428 };
429
Diffs on attempts; hosted agent presented as the g1t agent430export type DiffLine = {
431 kind: "context" | "add" | "delete";
432 /** Line number in the old file; null for added lines. */
433 old: number | null;
434 /** Line number in the new file; null for deleted lines. */
435 new: number | null;
436 text: string;
437};
438
439/** A run of changed lines with their surrounding context. */
440export type Hunk = { lines: DiffLine[] };
441
442export type FileDiff = {
443 path: string;
444 status: "added" | "modified" | "deleted";
445 additions: number;
446 deletions: number;
447 /** True when the file is binary or too large, so no lines are shown. */
448 binary: boolean;
449 hunks: Hunk[];
450};
451
452/** What changed between two commits. */
453export type Comparison = {
454 base: string | null;
455 head: string;
456 files: FileDiff[];
457 /** True when the change was too large to return in full. */
458 truncated: boolean;
459};

This file's history is long; its oldest lines are credited to the oldest commit read.