Skip to content
1,317 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.

API and MCP server in Rust; a public index at the API root1//! The OpenAPI document, generated from the same list the routes are.
Merge branch 'worktree-agent-ab2e39e11a6493412'2//!
3//! The docs site builds its API reference from a copy of this document,
4//! `apps/docs/src/data/openapi.json`. A test keeps the copy current: run
5//! `G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi` to rewrite it.
API and MCP server in Rust; a public index at the API root6
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step7use g1t_contracts::scopes::scope_for;
API and MCP server in Rust; a public index at the API root8use serde_json::{Map, Value, json};
9
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9710use crate::about::AboutOp;
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R211use crate::artifacts::ArtifactsOp;
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca12use crate::deploy_keys::DeployKeysOp;
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9713use crate::deployments::DeploymentsOp;
Merge packages: roles, Actions access, source label, soft delete, API14use crate::packages::PackagesOp;
Merge branch 'worktree-agent-a3abfcce648e87dca'15use crate::protection::ProtectionOp;
API and MCP for a workspace's personal access token rules, members' tokens and approvals16use crate::token_policy::TokenOp;
API and MCP server in Rust; a public index at the API root17use crate::operations::Op;
Merge checks: statuses and check runs on every commit18use crate::checks::ChecksOp;
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge19use crate::rules::RulesOp;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar20use crate::security::SecurityOp;
API and MCP server in Rust; a public index at the API root21use crate::rest::{ROUTES, Route};
22
Merge branch 'worktree-agent-ab2e39e11a6493412'23/// The sections of the API reference: a name, what it covers, and its
24/// operations in the order a reader meets them.
25const SECTIONS: &[(&str, &str, &[Op])] = &[
26 (
27 "Accounts",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look28 "Signing in from a tool, who a token acts as, and your email addresses.",
Merge email confirmation gate: a code and a link, nothing until confirmed (identity 0036)29 &[Op::Whoami, Op::ListEmails, Op::AddEmail, Op::ConfirmEmail, Op::RemoveEmail, Op::UpdateEmailSettings],
Merge branch 'worktree-agent-ab2e39e11a6493412'30 ),
31 (
API: notifications over REST and MCP, with notifications scopes32 "Notifications",
33 "Your inbox: a thread for each thing you were told about (an issue, a pull request, a workflow on a branch, a deployment), why you were told, and what you subscribe to and watch. Your own: personal tokens and sessions only.",
34 &[
35 Op::ListNotifications,
36 Op::MarkNotificationsRead,
37 Op::GetNotificationThread,
38 Op::MarkThreadRead,
39 Op::MarkThreadDone,
40 Op::SaveThread,
41 Op::SnoozeThread,
42 Op::GetThreadSubscription,
43 Op::SetThreadSubscription,
44 Op::DeleteThreadSubscription,
45 Op::GetRepoSubscription,
46 Op::SetRepoSubscription,
47 Op::DeleteRepoSubscription,
48 Op::ListWatchedRepos,
49 ],
50 ),
51 (
API: pinned projects over REST and MCP52 "Pinned projects",
53 "The projects you keep at the top of a workspace's sidebar, in your order, up to eight a workspace. Your own: personal tokens and sessions only.",
54 &[Op::ListPinnedProjects, Op::PinProject, Op::UnpinProject, Op::ReorderPinnedProjects],
55 ),
56 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9757 "Projects",
58 "A project is what a workspace builds and runs, from a repository or a root directory in one. Each says what it is, where it runs and where to find it: its homepage, docs and other links.",
59 &[Op::ListProjects, Op::GetProject, Op::UpdateProject],
60 ),
61 (
Merge branch 'worktree-agent-ab2e39e11a6493412'62 "Workspaces",
63 "A workspace owns repositories and is the first part of their address. People and agents work in workspaces.",
Merge branch 'worktree-agent-ad7c6d88d93adc817'64 &[Op::GetWorkspace, Op::CreateWorkspace, Op::UpdateWorkspace, Op::DeleteWorkspace],
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look65 ),
66 (
API and MCP for a workspace's personal access token rules, members' tokens and approvals67 "Personal access tokens",
68 "A workspace's rules for its members' personal access tokens: whether classic and fine-grained tokens reach it, whether fine-grained tokens wait for an owner's approval, and how long a token may last; the tokens that reach it, approving or denying the ones that wait, and revoking one there. Owners only, as people.",
69 &[
70 Op::Tokens(TokenOp::GetTokenPolicy),
71 Op::Tokens(TokenOp::SetTokenPolicy),
72 Op::Tokens(TokenOp::ListMemberTokens),
73 Op::Tokens(TokenOp::ListTokenRequests),
74 Op::Tokens(TokenOp::ReviewTokenRequest),
75 Op::Tokens(TokenOp::RevokeMemberToken),
76 ],
77 ),
78 (
Merge main (membership, two-factor, GitHub repo roles) into tokens79 "Members",
80 "A workspace's members and owners: who belongs to it, their roles (owner or member, with billing manager and security manager on top), handing it to another member, and leaving it.",
81 &[Op::ListMembers, Op::UpdateMember, Op::RemoveMember, Op::TransferOwnership, Op::LeaveWorkspace],
82 ),
83 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look84 "Invites",
Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040)85 "While g1t is invite-only, every new account needs an invite. Your invites, inviting people into a workspace by username or email, and answering the invitations to workspaces sent to you.",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look86 &[
87 Op::ListInvites,
88 Op::CreateInvite,
89 Op::RevokeInvite,
90 Op::ListWorkspaceInvites,
91 Op::InviteMember,
92 Op::RevokeWorkspaceInvite,
Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040)93 Op::ListInvitations,
94 Op::AcceptInvitation,
95 Op::DeclineInvitation,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look96 ],
Merge branch 'worktree-agent-ab2e39e11a6493412'97 ),
98 (
Usage, Billing settings and prepaid AI credit; fixes from the UX audit99 "Billing",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens100 "A workspace's usage, its budget, its AI credit, its invoices and its AI Gateway requests. Members read them; owners change the budget and buy credit, as people. g1t's agents never change billing.",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit101 &[
102 Op::GetUsage,
103 Op::GetBudget,
104 Op::SetBudget,
105 Op::GetAiCredit,
106 Op::BuyAiCredit,
107 Op::ListInvoices,
108 Op::GetBillingDetails,
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens109 Op::ListGatewayRequests,
Usage, Billing settings and prepaid AI credit; fixes from the UX audit110 ],
111 ),
112 (
Merge branch 'worktree-agent-ab2e39e11a6493412'113 "Repositories",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look114 "A repository, how it handles pull requests, and its timeline: renaming, archiving, moving and deleting it.",
Merge branch 'worktree-agent-ab2e39e11a6493412'115 &[
116 Op::ListRepos,
117 Op::CreateRepo,
118 Op::GetRepo,
119 Op::UpdateRepo,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look120 Op::RenameRepo,
121 Op::RenameBranch,
122 Op::SetRepoVisibility,
123 Op::ArchiveRepo,
124 Op::UnarchiveRepo,
125 Op::TransferRepo,
126 Op::DeleteRepo,
127 Op::ListDeletedRepos,
128 Op::RestoreRepo,
129 Op::PurgeRepo,
Merge branch 'worktree-agent-ab2e39e11a6493412'130 Op::GetRepoSettings,
131 Op::UpdateRepoSettings,
Fast pages, required checks on the branch, self-hosted runners, honest incidents132 Op::ListCheckNames,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar133 Op::GetCodeownersErrors,
Merge branch 'worktree-agent-ab2e39e11a6493412'134 Op::ListEvents,
135 ],
136 ),
137 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97138 "Repository insights",
139 "What a repository's default branch says about it, read in the background and kept by commit: the languages it is written in, who made it, and its license.",
140 &[Op::About(AboutOp::GetLanguages), Op::About(AboutOp::ListContributors), Op::About(AboutOp::GetLicense)],
141 ),
142 (
143 "Stars",
144 "Starring a repository, to keep it and to say you like it: who starred one, and what you starred.",
145 &[
146 Op::About(AboutOp::ListStargazers),
147 Op::About(AboutOp::ListStarred),
148 Op::About(AboutOp::CheckStarred),
149 Op::About(AboutOp::Star),
150 Op::About(AboutOp::Unstar),
151 ],
152 ),
153 (
154 "Releases",
155 "A release is a tag published with a title and notes. The latest is the newest published one that is neither a draft nor a prerelease.",
156 &[
157 Op::About(AboutOp::ListReleases),
158 Op::About(AboutOp::CreateRelease),
159 Op::About(AboutOp::GetLatestRelease),
160 Op::About(AboutOp::GetReleaseByTag),
161 Op::About(AboutOp::GetRelease),
162 Op::About(AboutOp::UpdateRelease),
163 Op::About(AboutOp::DeleteRelease),
164 ],
165 ),
166 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look167 "Access",
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca168 "Who can do what in a repository: repository roles, people given a role on one repository (outside collaborators when they are not members), invitations, a workspace's base permission, and deploy keys: SSH keys that reach one repository.",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look169 &[
170 Op::ListCollaborators,
171 Op::AddCollaborator,
172 Op::UpdateCollaborator,
173 Op::RemoveCollaborator,
174 Op::GetCollaboratorPermission,
175 Op::ListRepoInvitations,
176 Op::RevokeRepoInvitation,
177 Op::ListMyRepoInvitations,
178 Op::AcceptRepoInvitation,
179 Op::DeclineRepoInvitation,
180 Op::SetBasePermission,
181 Op::ListOutsideCollaborators,
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca182 Op::DeployKeys(DeployKeysOp::ListDeployKeys),
183 Op::DeployKeys(DeployKeysOp::GetDeployKey),
184 Op::DeployKeys(DeployKeysOp::CreateDeployKey),
185 Op::DeployKeys(DeployKeysOp::DeleteDeployKey),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look186 ],
187 ),
188 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar189 "Teams",
190 "Groups of a workspace's members: given a role on repositories together, mentioned together as @workspace/team, and asked to review together. Any member may create a team; the workspace's owners and the team's maintainers manage it.",
191 &[
192 Op::ListTeams,
193 Op::CreateTeam,
194 Op::GetTeam,
195 Op::UpdateTeam,
196 Op::DeleteTeam,
197 Op::ListTeamMembers,
198 Op::SetTeamMember,
199 Op::RemoveTeamMember,
200 Op::ListChildTeams,
201 Op::ListTeamRepos,
202 Op::SetTeamRepo,
203 Op::RemoveTeamRepo,
204 Op::SetTeamReviewAssignment,
205 Op::ListUserTeams,
206 ],
207 ),
208 (
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily209 "Security",
210 "Secrets found in what is pushed and in a repository's history, and dependencies with known vulnerabilities: listing the alerts, and dismissing or reopening them.",
211 &[Op::ListSecurityAlerts, Op::DismissSecurityAlert, Op::ReopenSecurityAlert],
212 ),
213 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar214 "Secret scanning",
215 "Secrets found in pushes and history, where each one is, pushing past push protection with a reason (and asking for approval when the workspace delegates bypasses), checking with a secret's issuer whether it still works, and custom patterns.",
216 &[
217 Op::Security(SecurityOp::ListSecretAlerts),
218 Op::Security(SecurityOp::GetSecretAlert),
219 Op::Security(SecurityOp::UpdateSecretAlert),
220 Op::Security(SecurityOp::ListSecretLocations),
221 Op::Security(SecurityOp::BypassPushProtection),
222 Op::Security(SecurityOp::CheckSecretValidity),
223 Op::Security(SecurityOp::ListBypassRequests),
224 Op::Security(SecurityOp::ReviewBypassRequest),
225 Op::Security(SecurityOp::ListCustomPatterns),
226 Op::Security(SecurityOp::CreateCustomPattern),
227 Op::Security(SecurityOp::UpdateCustomPattern),
228 Op::Security(SecurityOp::DeleteCustomPattern),
229 Op::Security(SecurityOp::DryRunCustomPattern),
230 ],
231 ),
232 (
233 "Code scanning",
234 "Results of static analysis tools, uploaded as SARIF: alerts on the default branch, the analyses that made them, uploads, and putting g1t on an alert to fix it.",
235 &[
236 Op::Security(SecurityOp::ListCodeAlerts),
237 Op::Security(SecurityOp::GetCodeAlert),
238 Op::Security(SecurityOp::UpdateCodeAlert),
239 Op::Security(SecurityOp::ListAnalyses),
240 Op::Security(SecurityOp::UploadSarif),
241 Op::Security(SecurityOp::GetSarifUpload),
242 Op::Security(SecurityOp::FixAlert),
243 ],
244 ),
245 (
246 "Supply chain",
247 "What a repository depends on: vulnerability alerts, the dependency graph, an SPDX SBOM of it, and comparing two commits' dependencies as dependency review does.",
248 &[
249 Op::Security(SecurityOp::ListVulnerabilityAlerts),
250 Op::Security(SecurityOp::GetVulnerabilityAlert),
251 Op::Security(SecurityOp::UpdateVulnerabilityAlert),
252 Op::Security(SecurityOp::GetDependencyGraph),
253 Op::Security(SecurityOp::GetSbom),
254 Op::Security(SecurityOp::CompareDependencies),
255 ],
256 ),
257 (
258 "Security settings",
259 "When pull request checks fail, dependency review's policy, delegated bypass and validity checks, and a workspace's security overview.",
260 &[
261 Op::Security(SecurityOp::GetSettings),
262 Op::Security(SecurityOp::UpdateSettings),
263 Op::Security(SecurityOp::GetWorkspaceSettings),
264 Op::Security(SecurityOp::UpdateWorkspaceSettings),
265 Op::Security(SecurityOp::GetOverview),
266 ],
267 ),
268 (
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge269 "Rules",
270 "Rulesets: what may happen to a repository's branches and tags and what a pull request needs before it merges, for a repository or across a workspace; the rules that hold for one branch; and how they judged each push and merge, with insights.",
271 &[
272 Op::Rules(RulesOp::ListRepoRulesets),
273 Op::Rules(RulesOp::CreateRepoRuleset),
274 Op::Rules(RulesOp::GetRepoRuleset),
275 Op::Rules(RulesOp::UpdateRepoRuleset),
276 Op::Rules(RulesOp::DeleteRepoRuleset),
277 Op::Rules(RulesOp::GetBranchRules),
278 Op::Rules(RulesOp::ListRuleEvaluations),
279 Op::Rules(RulesOp::ListWorkspaceRulesets),
280 Op::Rules(RulesOp::CreateWorkspaceRuleset),
281 Op::Rules(RulesOp::GetWorkspaceRuleset),
282 Op::Rules(RulesOp::UpdateWorkspaceRuleset),
283 Op::Rules(RulesOp::DeleteWorkspaceRuleset),
284 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
285 ],
286 ),
287 (
Merge checks: statuses and check runs on every commit288 "Checks",
289 "What CI, integrations and g1t Actions say about a commit, in the shapes CI tools already send: statuses (a state per context) and check runs (a lifecycle, a conclusion, a Markdown report, annotations on lines and buttons), grouped per reporter into check suites. g1t Actions jobs are check runs too. Required checks are met by either.",
290 &[
291 Op::Checks(ChecksOp::CreateCommitStatus),
292 Op::Checks(ChecksOp::ListCommitStatuses),
293 Op::Checks(ChecksOp::GetCombinedStatus),
294 Op::Checks(ChecksOp::CreateCheckRun),
295 Op::Checks(ChecksOp::UpdateCheckRun),
296 Op::Checks(ChecksOp::GetCheckRun),
297 Op::Checks(ChecksOp::ListCheckRunAnnotations),
298 Op::Checks(ChecksOp::RerequestCheckRun),
299 Op::Checks(ChecksOp::ListCheckRunsForRef),
300 Op::Checks(ChecksOp::ListCheckSuitesForRef),
301 Op::Checks(ChecksOp::GetCheckSuite),
302 Op::Checks(ChecksOp::RerequestCheckSuite),
303 ],
304 ),
305 (
Merge branch 'worktree-agent-ab2e39e11a6493412'306 "Issues",
307 "What should change in a repository, with labels and comments. Issues and pull requests share one sequence of numbers.",
308 &[
309 Op::ListIssues,
310 Op::CreateIssue,
311 Op::GetIssue,
312 Op::UpdateIssue,
313 Op::CloseIssue,
314 Op::ReopenIssue,
315 Op::AssignIssue,
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step316 Op::Delegate,
Merge branch 'worktree-agent-ab2e39e11a6493412'317 Op::AddComment,
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts318 Op::EditComment,
319 Op::DeleteComment,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar320 Op::ListIssueLabels,
321 Op::AddIssueLabels,
322 Op::SetIssueLabels,
323 Op::RemoveIssueLabels,
324 ],
325 ),
326 (
327 "Labels and milestones",
328 "A repository's labels, which issues and pull requests carry by name, and its milestones, which gather them under a goal and a due date.",
329 &[
Merge branch 'worktree-agent-ab2e39e11a6493412'330 Op::ListLabels,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar331 Op::CreateLabel,
332 Op::UpdateLabel,
333 Op::DeleteLabel,
334 Op::AddDefaultLabels,
335 Op::ListMilestones,
336 Op::CreateMilestone,
337 Op::GetMilestone,
338 Op::UpdateMilestone,
339 Op::DeleteMilestone,
Merge branch 'worktree-agent-ab2e39e11a6493412'340 ],
341 ),
342 (
343 "Plans",
344 "An outcome turned into the issues that would get there, with the order they must merge in.",
345 &[Op::PlanWork, Op::GetPlan, Op::ApplyPlan],
346 ),
347 (
348 "Pull requests",
349 "A proposed change in its own fork or on a branch. Several can be made for one issue; the one merged resolves it.",
350 &[
351 Op::ListPullRequests,
352 Op::CreatePullRequest,
353 Op::GetPullRequest,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar354 Op::UpdatePullRequest,
Merge branch 'worktree-agent-ab2e39e11a6493412'355 Op::GetPullRequestChanges,
356 Op::MarkPullRequestReady,
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts357 Op::ConvertPullRequestToDraft,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar358 Op::RequestReviewers,
359 Op::RemoveRequestedReviewers,
Merge branch 'worktree-agent-ab2e39e11a6493412'360 Op::ReviewPullRequest,
361 Op::MergePullRequest,
362 Op::ClosePullRequest,
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts363 Op::ReopenPullRequest,
Merge branch 'worktree-agent-ab2e39e11a6493412'364 Op::GetMergeQueue,
365 Op::MessageAgent,
366 Op::AnswerMessage,
367 Op::TakeMessages,
368 ],
369 ),
370 (
371 "Sessions",
372 "The record of how a pull request was made: prompts, reasoning and the tools that ran.",
373 &[Op::ReadSession, Op::RecordSession],
374 ),
375 (
Agents and memory, checks and conflicts, profiles, slug renames, custom domains376 "Memory",
377 "What agents and people learned that the next agent should know, for one project or across a workspace. Members and g1t's agents only; never a secret.",
378 &[Op::Remember, Op::Recall],
379 ),
380 (
Search across all of g1t, Explore, and a command palette381 "Search",
382 "One search across all of g1t: repositories, code, issues, pull requests, people and workspaces. Public content for everyone, and private content in workspaces you belong to.",
383 &[Op::Search],
384 ),
385 (
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API386 "Context",
387 "A workspace's context hub: a catalog of what it builds and runs, built from its repositories, deployments and integrations, and one search across the catalog, docs, issues, pull requests and memory.",
388 &[Op::SearchContext, Op::GetEntity],
389 ),
390 (
Merge branch 'worktree-agent-ab2e39e11a6493412'391 "Actions",
392 "GitHub Actions workflows in .g1t/workflows, their runs, and their jobs' logs.",
393 &[
394 Op::ListWorkflows,
395 Op::ListWorkflowRuns,
396 Op::GetWorkflowRun,
397 Op::GetJobLogs,
398 Op::DispatchWorkflow,
399 Op::CancelWorkflowRun,
400 Op::RerunWorkflowRun,
401 Op::UpdateWorkflow,
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2402 Op::Artifacts(ArtifactsOp::ListArtifacts),
403 Op::Artifacts(ArtifactsOp::ListRunArtifacts),
404 Op::Artifacts(ArtifactsOp::GetArtifact),
405 Op::Artifacts(ArtifactsOp::DownloadArtifact),
406 Op::Artifacts(ArtifactsOp::DeleteArtifact),
407 Op::Artifacts(ArtifactsOp::GetArtifactRetention),
408 Op::Artifacts(ArtifactsOp::SetArtifactRetention),
Merge branch 'worktree-agent-ab2e39e11a6493412'409 ],
410 ),
411 (
Merge packages: roles, Actions access, source label, soft delete, API412 "Packages",
413 "A workspace's packages in every registry: their versions and download counts, deleting and restoring them within 30 days, their visibility and repository, the people and teams with a role on them, and which repositories' workflows may use them (Manage Actions access). A package is named by its type and its name, URL-encoded where it holds a slash.",
414 &[
415 Op::Packages(PackagesOp::ListPackages),
416 Op::Packages(PackagesOp::GetPackage),
417 Op::Packages(PackagesOp::UpdatePackage),
418 Op::Packages(PackagesOp::DeletePackage),
419 Op::Packages(PackagesOp::RestorePackage),
420 Op::Packages(PackagesOp::ListVersions),
421 Op::Packages(PackagesOp::GetVersion),
422 Op::Packages(PackagesOp::DeleteVersion),
423 Op::Packages(PackagesOp::RestoreVersion),
424 Op::Packages(PackagesOp::LinkPackage),
425 Op::Packages(PackagesOp::UnlinkPackage),
426 Op::Packages(PackagesOp::ListAccess),
427 Op::Packages(PackagesOp::SetAccess),
428 Op::Packages(PackagesOp::RemoveAccess),
429 Op::Packages(PackagesOp::ListActionsAccess),
430 Op::Packages(PackagesOp::SetActionsAccess),
431 Op::Packages(PackagesOp::RemoveActionsAccess),
432 ],
433 ),
434 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97435 "Deployments",
436 "A repository's deployments wherever they run: reported from any CI with these routes, made by g1t Actions jobs with an `environment:`, or built on g1t.page. Each has statuses, shows on its commit as the check `deploy / <environment>`, and belongs to an environment.",
437 &[
438 Op::Deployments(DeploymentsOp::ListDeployments),
439 Op::Deployments(DeploymentsOp::CreateDeployment),
440 Op::Deployments(DeploymentsOp::GetDeployment),
441 Op::Deployments(DeploymentsOp::ListDeploymentStatuses),
442 Op::Deployments(DeploymentsOp::CreateDeploymentStatus),
443 Op::Deployments(DeploymentsOp::ListEnvironments),
444 Op::Deployments(DeploymentsOp::GetEnvironment),
445 ],
446 ),
447 (
Merge branch 'worktree-agent-a3abfcce648e87dca'448 "Run protection",
449 "What keeps workflow runs safe: environments' protection rules (required reviewers, a wait timer, which branches may deploy) and the reviews of the jobs they hold, approving a pull request's run from outside, what a job's token gets when its workflow writes no `permissions:`, and repository_dispatch, which a job's own token may send.",
450 &[
451 Op::Protection(ProtectionOp::UpdateEnvironment),
452 Op::Protection(ProtectionOp::DeleteEnvironment),
453 Op::Protection(ProtectionOp::GetPendingDeployments),
454 Op::Protection(ProtectionOp::ReviewPendingDeployments),
455 Op::Protection(ProtectionOp::ApproveWorkflowRun),
456 Op::Protection(ProtectionOp::GetWorkflowPermissions),
457 Op::Protection(ProtectionOp::SetWorkflowPermissions),
458 Op::Protection(ProtectionOp::GetForkPrApproval),
459 Op::Protection(ProtectionOp::SetForkPrApproval),
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts460 Op::Protection(ProtectionOp::GetActionsAccess),
461 Op::Protection(ProtectionOp::SetActionsAccess),
Merge branch 'worktree-agent-a3abfcce648e87dca'462 Op::Protection(ProtectionOp::CreateRepositoryDispatch),
463 Op::Protection(ProtectionOp::GetWorkspaceWorkflowPermissions),
464 Op::Protection(ProtectionOp::SetWorkspaceWorkflowPermissions),
465 ],
466 ),
467 (
Merge branch 'worktree-agent-ab2e39e11a6493412'468 "Secrets and variables",
469 "Values that workflows and deployments read, per repository or for a whole workspace, with a row per environment.",
470 &[
471 Op::ListActionsSecrets,
472 Op::SetActionsSecret,
473 Op::DeleteActionsSecret,
474 Op::ListActionsVariables,
475 Op::SetActionsVariable,
476 Op::DeleteActionsVariable,
477 ],
478 ),
479 (
Fast pages, required checks on the branch, self-hosted runners, honest incidents480 "Runners",
481 "Self-hosted runners: your own machines, which run your workflow jobs (and, if you choose, your agents' work) for $0 of g1t compute. They register with a short-lived token and only ever connect out.",
482 &[
483 Op::ListRunners,
484 Op::CreateRunnerRegistrationToken,
485 Op::RemoveRunner,
486 Op::ListRunnerGroups,
487 Op::CreateRunnerGroup,
488 Op::UpdateRunnerGroup,
489 Op::DeleteRunnerGroup,
490 Op::GetRunnerSettings,
491 Op::UpdateRunnerSettings,
492 ],
493 ),
494 (
Merge branch 'worktree-agent-ab2e39e11a6493412'495 "Webhooks",
496 "Signed HTTPS requests sent to your own address as things happen, for a repository or a whole workspace.",
497 &[
498 Op::ListWebhooks,
499 Op::CreateWebhook,
500 Op::UpdateWebhook,
501 Op::DeleteWebhook,
502 Op::PingWebhook,
503 Op::ListWebhookDeliveries,
504 Op::RedeliverWebhook,
505 ],
506 ),
507 (
508 "Integrations",
509 "A workspace's connections to outside systems: model providers, alert sources and issue trackers.",
510 &[
511 Op::ListIntegrations,
512 Op::ConnectIntegration,
AI Gateway: OpenAI's format, open models, and your own providers513 Op::UpdateIntegration,
Merge branch 'worktree-agent-ab2e39e11a6493412'514 Op::DisconnectIntegration,
515 Op::TestIntegration,
516 Op::GetModelRoutes,
517 Op::SetModelRoutes,
518 Op::GetContext,
519 Op::ImportIssue,
520 ],
521 ),
522];
523
API and MCP server in Rust; a public index at the API root524/// The section of the API reference an operation is listed under.
525fn tag(op: Op) -> &'static str {
Merge branch 'worktree-agent-ab2e39e11a6493412'526 SECTIONS
API and MCP server in Rust; a public index at the API root527 .iter()
Merge branch 'worktree-agent-ab2e39e11a6493412'528 .find(|(_, _, ops)| ops.contains(&op))
529 .map_or("Repositories", |(name, _, _)| name)
530}
531
532/// What an operation's page is called, as a short sentence.
533fn title(op: Op) -> &'static str {
534 match op {
535 Op::Whoami => "Get the current user",
Merge branch 'worktree-agent-ad7c6d88d93adc817'536 Op::GetWorkspace => "Get a workspace",
Merge branch 'worktree-agent-ab2e39e11a6493412'537 Op::CreateWorkspace => "Create a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look538 Op::DeleteWorkspace => "Delete a workspace",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily539 Op::UpdateWorkspace => "Update a workspace",
Merge main (membership, two-factor, GitHub repo roles) into tokens540 Op::ListMembers => "List a workspace's members",
541 Op::UpdateMember => "Change a member's role",
542 Op::RemoveMember => "Remove a member",
543 Op::TransferOwnership => "Transfer a workspace's ownership",
544 Op::LeaveWorkspace => "Leave a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look545 Op::ListEmails => "List your email addresses",
546 Op::AddEmail => "Add an email address",
Merge email confirmation gate: a code and a link, nothing until confirmed (identity 0036)547 Op::ConfirmEmail => "Confirm an email address",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look548 Op::RemoveEmail => "Remove an email address",
549 Op::UpdateEmailSettings => "Change your email settings",
550 Op::ListInvites => "List your invites",
551 Op::CreateInvite => "Create an invite",
552 Op::RevokeInvite => "Revoke an invite",
553 Op::ListWorkspaceInvites => "List a workspace's invites",
554 Op::InviteMember => "Invite someone to a workspace",
Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040)555 Op::ListInvitations => "List your workspace invitations",
556 Op::AcceptInvitation => "Accept a workspace invitation",
557 Op::DeclineInvitation => "Decline a workspace invitation",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look558 Op::RevokeWorkspaceInvite => "Revoke a workspace's invite",
559 Op::TransferRepo => "Transfer a repository",
560 Op::RenameRepo => "Rename a repository",
561 Op::RenameBranch => "Rename a branch",
562 Op::ArchiveRepo => "Archive a repository",
563 Op::UnarchiveRepo => "Unarchive a repository",
564 Op::SetRepoVisibility => "Change a repository's visibility",
565 Op::DeleteRepo => "Delete a repository",
566 Op::ListDeletedRepos => "List recently deleted repositories",
567 Op::RestoreRepo => "Restore a deleted repository",
568 Op::PurgeRepo => "Purge a deleted repository",
Merge branch 'worktree-agent-ab2e39e11a6493412'569 Op::ListRepos => "List repositories",
570 Op::GetRepo => "Get a repository",
571 Op::CreateRepo => "Create a repository",
572 Op::UpdateRepo => "Update a repository",
573 Op::GetRepoSettings => "Get repository settings",
574 Op::UpdateRepoSettings => "Update repository settings",
Fast pages, required checks on the branch, self-hosted runners, honest incidents575 Op::ListCheckNames => "List check names",
Merge branch 'worktree-agent-ab2e39e11a6493412'576 Op::GetMergeQueue => "Get the merge queue",
577 Op::MessageAgent => "Message an agent",
578 Op::AnswerMessage => "Answer a message",
579 Op::TakeMessages => "Take new messages",
Agents and memory, checks and conflicts, profiles, slug renames, custom domains580 Op::Remember => "Remember something",
581 Op::Recall => "Recall memory",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API582 Op::SearchContext => "Search the context hub",
583 Op::GetEntity => "Get a catalog entry",
Search across all of g1t, Explore, and a command palette584 Op::Search => "Search g1t",
Merge branch 'worktree-agent-ab2e39e11a6493412'585 Op::ListIssues => "List issues",
586 Op::GetIssue => "Get an issue",
587 Op::CreateIssue => "Create an issue",
588 Op::UpdateIssue => "Update an issue",
589 Op::CloseIssue => "Close an issue",
590 Op::ReopenIssue => "Reopen an issue",
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent591 Op::AssignIssue => "Assign an issue to g1t",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step592 Op::Delegate => "Put an agent on it",
Merge branch 'worktree-agent-ab2e39e11a6493412'593 Op::PlanWork => "Plan work",
594 Op::GetPlan => "Get a plan",
595 Op::ApplyPlan => "Apply a plan",
596 Op::ListLabels => "List labels",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar597 Op::CreateLabel => "Create a label",
598 Op::UpdateLabel => "Update a label",
599 Op::DeleteLabel => "Delete a label",
600 Op::AddDefaultLabels => "Add the default labels",
601 Op::ListIssueLabels => "List an issue's labels",
602 Op::AddIssueLabels => "Add labels to an issue",
603 Op::SetIssueLabels => "Set an issue's labels",
604 Op::RemoveIssueLabels => "Remove labels from an issue",
605 Op::ListMilestones => "List milestones",
606 Op::GetMilestone => "Get a milestone",
607 Op::CreateMilestone => "Create a milestone",
608 Op::UpdateMilestone => "Update a milestone",
609 Op::DeleteMilestone => "Delete a milestone",
610 Op::UpdatePullRequest => "Update a pull request",
Merge branch 'worktree-agent-ab2e39e11a6493412'611 Op::AddComment => "Add a comment",
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts612 Op::EditComment => "Edit a comment",
613 Op::DeleteComment => "Delete a comment",
Merge branch 'worktree-agent-ab2e39e11a6493412'614 Op::ReviewPullRequest => "Review a pull request",
615 Op::ListPullRequests => "List pull requests",
616 Op::GetPullRequest => "Get a pull request",
617 Op::CreatePullRequest => "Create a pull request",
618 Op::RecordSession => "Record session entries",
619 Op::ReadSession => "Read a session",
620 Op::MarkPullRequestReady => "Mark a pull request ready",
621 Op::ClosePullRequest => "Close a pull request",
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts622 Op::ReopenPullRequest => "Reopen a pull request",
623 Op::ConvertPullRequestToDraft => "Convert a pull request to a draft",
Merge branch 'worktree-agent-ab2e39e11a6493412'624 Op::GetPullRequestChanges => "Get a pull request's changes",
625 Op::MergePullRequest => "Merge a pull request",
626 Op::ListEvents => "List repository events",
627 Op::ListIntegrations => "List integrations",
628 Op::ConnectIntegration => "Connect an integration",
AI Gateway: OpenAI's format, open models, and your own providers629 Op::UpdateIntegration => "Update an integration",
Merge branch 'worktree-agent-ab2e39e11a6493412'630 Op::DisconnectIntegration => "Disconnect an integration",
631 Op::TestIntegration => "Test an integration",
632 Op::GetContext => "Look up a ticket",
633 Op::ImportIssue => "Import an issue",
634 Op::GetModelRoutes => "Get model routes",
635 Op::SetModelRoutes => "Set model routes",
636 Op::ListWebhooks => "List webhooks",
637 Op::CreateWebhook => "Create a webhook",
638 Op::UpdateWebhook => "Update a webhook",
639 Op::DeleteWebhook => "Delete a webhook",
640 Op::PingWebhook => "Ping a webhook",
641 Op::ListWebhookDeliveries => "List webhook deliveries",
642 Op::RedeliverWebhook => "Redeliver a webhook delivery",
643 Op::ListWorkflows => "List workflows",
644 Op::ListWorkflowRuns => "List workflow runs",
645 Op::GetWorkflowRun => "Get a workflow run",
646 Op::GetJobLogs => "Get a job's log",
647 Op::DispatchWorkflow => "Run a workflow",
648 Op::CancelWorkflowRun => "Cancel a workflow run",
649 Op::RerunWorkflowRun => "Re-run a workflow run",
650 Op::UpdateWorkflow => "Turn a workflow on or off",
651 Op::ListActionsSecrets => "List secrets",
652 Op::SetActionsSecret => "Set a secret",
653 Op::DeleteActionsSecret => "Delete a secret",
654 Op::ListActionsVariables => "List variables",
655 Op::SetActionsVariable => "Set a variable",
656 Op::DeleteActionsVariable => "Delete a variable",
Fast pages, required checks on the branch, self-hosted runners, honest incidents657 Op::ListRunners => "List self-hosted runners",
658 Op::ListRunnerGroups => "List runner groups",
659 Op::GetRunnerSettings => "Get runner settings",
660 Op::CreateRunnerRegistrationToken => "Create a runner registration token",
661 Op::RemoveRunner => "Remove a self-hosted runner",
662 Op::CreateRunnerGroup => "Create a runner group",
663 Op::UpdateRunnerGroup => "Change a runner group",
664 Op::DeleteRunnerGroup => "Delete a runner group",
665 Op::UpdateRunnerSettings => "Change runner settings",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look666 Op::ListCollaborators => "List who has access",
667 Op::AddCollaborator => "Add a collaborator",
668 Op::UpdateCollaborator => "Change a collaborator's role",
669 Op::RemoveCollaborator => "Remove a collaborator",
670 Op::GetCollaboratorPermission => "Get someone's permission",
671 Op::ListRepoInvitations => "List a repository's invitations",
672 Op::RevokeRepoInvitation => "Revoke a repository invitation",
673 Op::ListMyRepoInvitations => "List your repository invitations",
674 Op::AcceptRepoInvitation => "Accept a repository invitation",
675 Op::DeclineRepoInvitation => "Decline a repository invitation",
676 Op::SetBasePermission => "Set the base permission",
677 Op::ListOutsideCollaborators => "List outside collaborators",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily678 Op::ListSecurityAlerts => "List security alerts",
679 Op::DismissSecurityAlert => "Dismiss a security alert",
680 Op::ReopenSecurityAlert => "Reopen a security alert",
API: notifications over REST and MCP, with notifications scopes681 Op::ListNotifications => "List notifications",
682 Op::MarkNotificationsRead => "Mark notifications read",
683 Op::GetNotificationThread => "Get a thread",
684 Op::MarkThreadRead => "Mark a thread read",
685 Op::MarkThreadDone => "Mark a thread done",
686 Op::SaveThread => "Save a thread",
687 Op::SnoozeThread => "Snooze a thread",
688 Op::GetThreadSubscription => "Get a thread subscription",
689 Op::SetThreadSubscription => "Set a thread subscription",
690 Op::DeleteThreadSubscription => "Unsubscribe from a thread",
691 Op::GetRepoSubscription => "Get how you watch a repository",
692 Op::SetRepoSubscription => "Watch a repository",
693 Op::DeleteRepoSubscription => "Stop watching a repository",
694 Op::ListWatchedRepos => "List repositories you watch",
API: pinned projects over REST and MCP695 Op::ListPinnedProjects => "List your pinned projects",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit696 Op::GetUsage => "Get a workspace's usage",
697 Op::GetBudget => "Get a workspace's budget",
698 Op::SetBudget => "Change a workspace's budget",
699 Op::GetAiCredit => "Get a workspace's AI credit",
700 Op::BuyAiCredit => "Buy AI credit",
701 Op::ListInvoices => "List a workspace's invoices",
702 Op::GetBillingDetails => "Get a workspace's billing details",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens703 Op::ListGatewayRequests => "List a workspace's AI Gateway requests",
API: pinned projects over REST and MCP704 Op::PinProject => "Pin a project",
705 Op::UnpinProject => "Unpin a project",
706 Op::ReorderPinnedProjects => "Reorder your pinned projects",
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97707 Op::ListProjects => "List a workspace's projects",
708 Op::GetProject => "Get a project",
709 Op::UpdateProject => "Update a project",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar710 Op::ListTeams => "List teams",
711 Op::GetTeam => "Get a team",
712 Op::CreateTeam => "Create a team",
713 Op::UpdateTeam => "Update a team",
714 Op::DeleteTeam => "Delete a team",
715 Op::ListTeamMembers => "List a team's members",
716 Op::SetTeamMember => "Add or change a team member",
717 Op::RemoveTeamMember => "Remove a team member",
718 Op::ListChildTeams => "List child teams",
719 Op::ListTeamRepos => "List a team's repositories",
720 Op::SetTeamRepo => "Give a team a role on a repository",
721 Op::RemoveTeamRepo => "Remove a team from a repository",
722 Op::SetTeamReviewAssignment => "Set a team's review assignment",
723 Op::ListUserTeams => "List someone's teams",
724 Op::RequestReviewers => "Request reviewers",
725 Op::RemoveRequestedReviewers => "Remove requested reviewers",
726 Op::GetCodeownersErrors => "List CODEOWNERS errors",
727 Op::Security(op) => op.title(),
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge728 Op::Rules(op) => op.title(),
Merge checks: statuses and check runs on every commit729 Op::Checks(op) => op.title(),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97730 Op::About(op) => op.title(),
731 Op::Deployments(op) => op.title(),
Merge branch 'worktree-agent-a3abfcce648e87dca'732 Op::Protection(op) => op.title(),
API and MCP for a workspace's personal access token rules, members' tokens and approvals733 Op::Tokens(op) => op.title(),
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2734 Op::Artifacts(op) => op.title(),
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca735 Op::DeployKeys(op) => op.title(),
Merge packages: roles, Actions access, source label, soft delete, API736 Op::Packages(op) => op.title(),
API and MCP server in Rust; a public index at the API root737 }
738}
739
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look740/// Why an operation can be refused with `402 payment_required`, if it
741/// can: the ones that start an agent, when the workspace has no credit,
742/// and the ones that make a repository private in a workspace, when a free
743/// workspace's private storage has no room for it.
744fn may_need_payment(op: Op) -> Option<&'static str> {
745 match op {
746 Op::AssignIssue | Op::PlanWork | Op::ApplyPlan => Some("The workspace has no agent credit."),
747 Op::UpdateRepo | Op::SetRepoVisibility | Op::TransferRepo => Some(
748 "A free workspace's private storage has no room for this private repository.",
749 ),
750 _ => None,
751 }
Merge branch 'worktree-agent-ab2e39e11a6493412'752}
753
754/// What the reference says beyond each operation's own description, keyed
755/// by operation id, written by hand from what the services return: `notes`
756/// (Markdown, added to the description) and example `params` (path),
757/// `query`, `request` (body) and `response`.
758const REFERENCE: &str = include_str!("reference.json");
759
760fn examples() -> Map<String, Value> {
761 match serde_json::from_str(REFERENCE) {
762 Ok(Value::Object(examples)) => examples,
763 _ => Map::new(),
API and MCP server in Rust; a public index at the API root764 }
765}
766
Agents as a team: lifecycle, merge queue, billing and a new shell767/// `/repos/:owner/:name` as OpenAPI writes it: `/repos/{owner}/{name}`.
API and MCP server in Rust; a public index at the API root768fn openapi_path(route: &Route) -> String {
769 route
770 .path
771 .split('/')
772 .map(|segment| match segment.strip_prefix(':') {
773 Some(name) => format!("{{{name}}}"),
774 None => segment.to_owned(),
775 })
776 .collect::<Vec<_>>()
777 .join("/")
778}
779
780fn error_response(description: &str) -> Value {
781 json!({
782 "description": description,
783 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } },
784 })
785}
786
Merge branch 'worktree-agent-ab2e39e11a6493412'787/// A parameter in the path or the query, described by the operation's
788/// input schema where it has the same name.
789fn parameter(name: &str, place: &str, required: bool, schema: Option<&Value>) -> Value {
790 let mut schema = schema.cloned().unwrap_or_else(|| json!({ "type": "string" }));
791 let description = match name {
792 "owner" => Some(Value::from("The workspace that owns the repository.")),
793 "name" => Some(Value::from("The repository's name.")),
794 _ => schema.as_object_mut().and_then(|schema| schema.remove("description")),
795 };
796 let mut parameter = json!({
797 "name": name,
798 "in": place,
799 "required": required,
800 "schema": schema,
801 });
802 if let Some(description) = description {
803 parameter["description"] = description;
804 }
805 parameter
806}
807
808/// The operation id of a route. An operation reached at a workspace's
809/// address as well as a repository's is documented once for each, with its
810/// own id; GitHub's alternative addresses for one operation keep GitHub's
811/// names.
812fn operation_id(route: &Route) -> String {
813 let op = route.op;
814 let base = match (route.method, route.path.rsplit('/').next().unwrap_or_default()) {
815 ("PUT", "enable") => "enable_workflow".to_owned(),
816 ("PUT", "disable") => "disable_workflow".to_owned(),
817 ("POST", "rerun-failed-jobs") => "rerun_failed_jobs".to_owned(),
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)818 ("POST", "rerun") if route.path.contains("/jobs/:job/") => "rerun_job".to_owned(),
819 ("POST", "force-cancel") => "force_cancel_workflow_run".to_owned(),
820 ("GET", ":attempt") => "get_workflow_run_attempt".to_owned(),
Merge branch 'worktree-agent-ab2e39e11a6493412'821 ("PATCH", ":setting") => "update_actions_variable".to_owned(),
822 ("GET", "runs") if route.path.contains("/workflows/:workflow/") => "list_runs_of_workflow".to_owned(),
API: notifications over REST and MCP, with notifications scopes823 // One repository's notifications, and an issue's subscription by
824 // its number rather than a thread's id.
825 (_, "notifications") if route.path.starts_with("/repos/") => match op {
826 Op::ListNotifications => "list_repo_notifications".to_owned(),
827 _ => "mark_repo_notifications_read".to_owned(),
828 },
829 (method, "subscription") if route.path.contains("/issues/:number/") => match method {
830 "GET" => "get_issue_subscription".to_owned(),
831 "PUT" => "set_issue_subscription".to_owned(),
832 _ => "delete_issue_subscription".to_owned(),
833 },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar834 // One label off an issue, by its name in the path.
835 ("DELETE", ":label") if route.path.contains("/issues/:number/") => "remove_issue_label".to_owned(),
API: notifications over REST and MCP, with notifications scopes836 ("DELETE", "saved") => "unsave_thread".to_owned(),
837 ("DELETE", "snooze") => "unsnooze_thread".to_owned(),
Merge branch 'worktree-agent-ab2e39e11a6493412'838 _ => op.name().to_owned(),
839 };
840 if route.path.starts_with("/workspaces/") && ROUTES.iter().any(|other| other.op == op && other.path.starts_with("/repos/")) {
841 format!("{base}_for_workspace")
842 } else {
843 base
844 }
845}
846
847/// The summary of a route: its operation's title, or for one of GitHub's
848/// alternative addresses, what that address does.
849fn summary(route: &Route, id: &str) -> String {
850 let base = match id.trim_end_matches("_for_workspace") {
851 "enable_workflow" => "Turn a workflow on",
852 "disable_workflow" => "Turn a workflow off",
853 "rerun_failed_jobs" => "Re-run failed jobs",
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)854 "rerun_job" => "Re-run a job",
855 "force_cancel_workflow_run" => "Force-cancel a workflow run",
856 "get_workflow_run_attempt" => "Get a workflow run attempt",
Merge branch 'worktree-agent-ab2e39e11a6493412'857 "update_actions_variable" => "Update a variable",
858 "list_runs_of_workflow" => "List a workflow's runs",
API: notifications over REST and MCP, with notifications scopes859 "list_repo_notifications" => "List a repository's notifications",
860 "mark_repo_notifications_read" => "Mark a repository's notifications read",
861 "get_issue_subscription" => "Get your subscription to an issue",
862 "set_issue_subscription" => "Subscribe to an issue",
863 "delete_issue_subscription" => "Unsubscribe from an issue",
864 "unsave_thread" => "Unsave a thread",
865 "unsnooze_thread" => "Bring a snoozed thread back",
Merge branch 'worktree-agent-ab2e39e11a6493412'866 _ => title(route.op),
867 };
868 if id.ends_with("_for_workspace") {
869 format!("{base} for a workspace")
870 } else {
871 base.to_owned()
872 }
873}
874
API and MCP server in Rust; a public index at the API root875fn operation(route: &Route) -> Value {
876 let op = route.op;
877 let path_params: Vec<&str> = route.params().collect();
Merge checks: statuses and check runs on every commit878 // `owner` and `name` in the path stand for the operation's `repo` input,
879 // so a `name` in the body, such as a check run's, is the body's own.
880 let stands_for_repo =
881 |name: &str| matches!(name, "owner" | "name") && path_params.contains(&"owner") && path_params.contains(&"name");
882 let covered = |name: &str| name == "repo" || (path_params.contains(&name) && !stands_for_repo(name));
Merge branch 'worktree-agent-ab2e39e11a6493412'883 let all_properties = op.properties();
884 let mut properties = all_properties.clone();
API and MCP server in Rust; a public index at the API root885 properties.retain(|name, _| !covered(name));
886 let required: Vec<String> = op
887 .required()
888 .into_iter()
889 .filter(|name| !covered(name))
890 .collect();
891
892 let mut parameters: Vec<Value> = path_params
893 .iter()
Merge checks: statuses and check runs on every commit894 .map(|name| parameter(name, "path", true, if stands_for_repo(name) { None } else { all_properties.get(*name) }))
API and MCP server in Rust; a public index at the API root895 .collect();
896 let mut body = Value::Null;
897 if route.method == "GET" {
898 for (name, key) in route.query {
Merge branch 'worktree-agent-ab2e39e11a6493412'899 parameters.push(parameter(
900 name,
901 "query",
902 required.iter().any(|required| required == key),
903 properties.get(*key),
904 ));
API and MCP server in Rust; a public index at the API root905 }
906 } else if !properties.is_empty() {
907 let mut schema = json!({ "type": "object", "properties": properties });
908 if !required.is_empty() {
909 schema["required"] = json!(required);
910 }
911 body = json!({
912 "required": !required.is_empty(),
913 "content": { "application/json": { "schema": schema } },
914 });
915 }
916
Merge branch 'worktree-agent-ab2e39e11a6493412'917 let id = operation_id(route);
918 let mut responses = Map::new();
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts919 if route.no_content() {
920 responses.insert("204".into(), json!({ "description": "Success. There is no body." }));
921 } else {
922 responses.insert(
923 "200".into(),
924 json!({
925 "description": "Success.",
926 "content": { "application/json": { "schema": {} } },
927 }),
928 );
929 }
Merge branch 'worktree-agent-ab2e39e11a6493412'930 responses.insert(
931 "401".into(),
932 error_response("A token is required, or the one sent is not valid."),
933 );
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look934 if let Some(reason) = may_need_payment(op) {
935 responses.insert("402".into(), error_response(reason));
Merge branch 'worktree-agent-ab2e39e11a6493412'936 }
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step937 responses.insert(
938 "403".into(),
939 error_response("Signed in, but not allowed to do this: the role you have is not enough, or the token lacks the scope it needs, which `needed_scope` names."),
940 );
Search across all of g1t, Explore, and a command palette941 if !matches!(op, Op::Whoami | Op::ListRepos | Op::Search) {
Merge branch 'worktree-agent-ab2e39e11a6493412'942 responses.insert("404".into(), error_response("It does not exist, or you cannot see it."));
943 }
944 if route.method != "GET" {
945 responses.insert(
946 "409".into(),
947 error_response("The request conflicts with the current state."),
948 );
949 }
950 if op != Op::Whoami {
951 responses.insert("422".into(), error_response("The input is not valid."));
952 }
953 // Public data can be read without a token; everything else needs one.
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step954 let scope: Vec<&str> = scope_for(op.name()).map(|scope| scope.as_str()).into_iter().collect();
Merge branch 'worktree-agent-ab2e39e11a6493412'955 let security = if op.needs_user() {
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step956 json!([{ "token": scope }])
Webhooks: every event, to your own addresses, signed and retried957 } else {
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step958 json!([{ "token": scope }, {}])
Webhooks: every event, to your own addresses, signed and retried959 };
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step960 let (tool, action) = crate::tools::TOOLS
961 .iter()
962 .find_map(|tool| {
963 tool.actions
964 .iter()
965 .find(|action| action.op == op)
966 .map(|action| (tool.name, action.name))
967 })
968 .unwrap_or_default();
API and MCP server in Rust; a public index at the API root969 let mut described = json!({
Webhooks: every event, to your own addresses, signed and retried970 "operationId": id,
API and MCP server in Rust; a public index at the API root971 "tags": [tag(op)],
Merge branch 'worktree-agent-ab2e39e11a6493412'972 "summary": summary(route, &id),
API and MCP server in Rust; a public index at the API root973 "description": op.description(),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step974 "x-operation": op.name(),
975 "x-mcp-tool": tool,
976 "x-mcp-action": action,
977 "x-scope": scope.first().copied(),
Merge branch 'worktree-agent-ab2e39e11a6493412'978 "security": security,
API and MCP server in Rust; a public index at the API root979 "parameters": parameters,
Merge branch 'worktree-agent-ab2e39e11a6493412'980 "responses": responses,
API and MCP server in Rust; a public index at the API root981 });
982 if !body.is_null() {
983 described["requestBody"] = body;
984 }
985 described
986}
987
988/// Entries for device sign-in, which is not an operation.
989fn onboarding() -> Map<String, Value> {
990 let paths = json!({
Agents as a team: lifecycle, merge queue, billing and a new shell991 "/device/code": {
API and MCP server in Rust; a public index at the API root992 "post": {
993 "operationId": "device_code",
994 "tags": ["Accounts"],
995 "summary": "Start signing in",
Agents as a team: lifecycle, merge queue, billing and a new shell996 "description": "Begins a device sign-in. Show the person `verification_uri_complete` and have them open it in a browser, where they sign in or register and approve the code. Then poll `/device/token`.",
API and MCP server in Rust; a public index at the API root997 "security": [],
998 "requestBody": {
999 "content": { "application/json": { "schema": {
1000 "type": "object",
1001 "properties": {
1002 "client_name": {
1003 "type": "string",
1004 "description": "What is asking, shown to the person approving. For example, Claude Code.",
1005 },
1006 },
1007 } } },
1008 },
1009 "responses": { "200": {
1010 "description": "The codes for this sign-in.",
1011 "content": { "application/json": { "schema": {
1012 "type": "object",
1013 "properties": {
Agents as a team: lifecycle, merge queue, billing and a new shell1014 "device_code": { "type": "string", "description": "Secret. Send it to /device/token." },
API and MCP server in Rust; a public index at the API root1015 "user_code": { "type": "string", "description": "Shown to the person, like WDJB-MJHT." },
1016 "verification_uri": { "type": "string" },
1017 "verification_uri_complete": {
1018 "type": "string",
1019 "description": "The link to give the person; it carries the code.",
1020 },
1021 "expires_in": { "type": "integer", "description": "Seconds until the codes expire." },
1022 "interval": { "type": "integer", "description": "Seconds to wait between polls." },
1023 },
1024 } } },
1025 } },
1026 },
1027 },
Agents as a team: lifecycle, merge queue, billing and a new shell1028 "/device/token": {
API and MCP server in Rust; a public index at the API root1029 "post": {
1030 "operationId": "device_token",
1031 "tags": ["Accounts"],
1032 "summary": "Finish signing in",
1033 "description": "Asks whether the person has approved. Poll no faster than the interval. The token is returned once.",
1034 "security": [],
1035 "requestBody": {
1036 "required": true,
1037 "content": { "application/json": { "schema": {
1038 "type": "object",
1039 "required": ["device_code"],
1040 "properties": { "device_code": { "type": "string" } },
1041 } } },
1042 },
1043 "responses": { "200": {
1044 "description": "The state of the sign-in.",
1045 "content": { "application/json": { "schema": {
1046 "type": "object",
1047 "required": ["status"],
1048 "properties": {
1049 "status": { "type": "string", "enum": ["pending", "approved", "denied", "expired"] },
1050 "token": { "type": "string", "description": "Present when approved." },
1051 "username": { "type": "string" },
1052 "verified": {
1053 "type": "boolean",
1054 "description": "Whether the account's email is confirmed.",
1055 },
1056 },
1057 } } },
1058 } },
1059 },
1060 },
1061 });
1062 match paths {
1063 Value::Object(paths) => paths,
1064 _ => Map::new(),
1065 }
1066}
1067
Merge branch 'worktree-agent-ab2e39e11a6493412'1068
1069/// Puts each operation's examples, where it has them, into its request
1070/// and response. Path and query values go under `x-example-params` and
1071/// `x-example-query`, which tools that build a request can use.
1072fn attach_examples(paths: &mut Map<String, Value>) {
1073 let examples = examples();
1074 for methods in paths.values_mut() {
1075 let Some(methods) = methods.as_object_mut() else { continue };
1076 for operation in methods.values_mut() {
1077 let id = operation["operationId"].as_str().unwrap_or_default().to_owned();
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1078 let name = operation["x-operation"].as_str().unwrap_or_default().to_owned();
1079 let Some(example) = examples.get(&id).or_else(|| examples.get(&name)) else {
Merge branch 'worktree-agent-ab2e39e11a6493412'1080 continue;
1081 };
1082 if let Some(notes) = example.get("notes").and_then(Value::as_str) {
1083 let description = operation["description"].as_str().unwrap_or_default();
1084 operation["description"] = json!(format!("{description}\n\n{notes}"));
1085 }
1086 if let Some(response) = example.get("response") {
1087 let content = &mut operation["responses"]["200"]["content"]["application/json"];
1088 if content.is_object() {
1089 content["example"] = response.clone();
1090 }
1091 }
1092 if let Some(request) = example.get("request") {
1093 let content = &mut operation["requestBody"]["content"]["application/json"];
1094 if content.is_object() {
1095 content["example"] = request.clone();
1096 }
1097 }
1098 for (key, extension) in [("params", "x-example-params"), ("query", "x-example-query")] {
1099 if let Some(values) = example.get(key) {
1100 operation[extension] = values.clone();
1101 }
1102 }
1103 }
1104 }
1105}
1106
API and MCP server in Rust; a public index at the API root1107pub fn document() -> Value {
1108 let mut paths = onboarding();
1109 for route in ROUTES {
1110 let entry = paths
1111 .entry(openapi_path(route))
1112 .or_insert_with(|| json!({}));
1113 entry[route.method.to_lowercase()] = operation(route);
1114 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1115 attach_examples(&mut paths);
1116 let tags: Vec<Value> = SECTIONS
1117 .iter()
1118 .map(|(name, description, ops)| {
1119 json!({
1120 "name": name,
1121 "description": description,
1122 // The section's operations in reading order, by MCP tool name.
1123 "x-tools": ops.iter().map(|op| op.name()).collect::<Vec<_>>(),
1124 })
1125 })
1126 .collect();
1127 let codes = ["unauthenticated", "payment_required", "forbidden", "not_found", "conflict", "invalid"];
API and MCP server in Rust; a public index at the API root1128 json!({
1129 "openapi": "3.1.0",
1130 "info": {
1131 "title": "g1t API",
1132 "version": "1",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1133 "description": "The REST API for g1t, a git forge built for agents. The same operations are available to agents as MCP tools at https://mcp.g1t.sh. Every name in a request or response body is `snake_case`; names you chose, such as a workflow's inputs or a secret's name, are returned as you wrote them.",
API and MCP server in Rust; a public index at the API root1134 "license": { "name": "MIT", "identifier": "MIT" },
1135 },
1136 "servers": [{ "url": "https://api.g1t.sh" }],
1137 "security": [{ "token": [] }, {}],
Merge branch 'worktree-agent-ab2e39e11a6493412'1138 "tags": tags,
API and MCP server in Rust; a public index at the API root1139 "paths": paths,
1140 "components": {
1141 "securitySchemes": {
1142 "token": {
1143 "type": "http",
1144 "scheme": "bearer",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1145 "description": "An access token, `g1t_…`. Public data needs none. Each operation names the scope a token needs for it; see https://docs.g1t.sh/guides/authentication/#scopes.",
API and MCP server in Rust; a public index at the API root1146 },
1147 },
1148 "schemas": {
1149 "Error": {
1150 "type": "object",
1151 "required": ["error"],
1152 "properties": {
1153 "error": {
1154 "type": "object",
1155 "required": ["code", "message"],
1156 "properties": {
Merge branch 'worktree-agent-ab2e39e11a6493412'1157 "code": { "type": "string", "enum": codes },
API and MCP server in Rust; a public index at the API root1158 "message": { "type": "string" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1159 "needed_scope": {
1160 "type": "string",
1161 "description": "On a 403 for an access token without the scope the call needs: that scope, such as `issues:write`.",
1162 },
API and MCP server in Rust; a public index at the API root1163 },
1164 },
1165 },
1166 },
1167 },
1168 },
1169 })
1170}
1171
1172#[cfg(test)]
1173mod tests {
1174 use super::*;
1175
1176 #[test]
1177 fn every_route_is_documented_once() {
1178 let document = document();
1179 let mut ids = Vec::new();
1180 for (_, methods) in document["paths"].as_object().unwrap() {
1181 for (_, operation) in methods.as_object().unwrap() {
1182 ids.push(operation["operationId"].as_str().unwrap().to_owned());
1183 }
1184 }
1185 for op in Op::ALL {
1186 assert_eq!(
1187 ids.iter().filter(|id| *id == op.name()).count(),
1188 1,
1189 "{}",
1190 op.name()
1191 );
1192 }
Webhooks: every event, to your own addresses, signed and retried1193 let mut unique = ids.clone();
1194 unique.sort();
1195 unique.dedup();
1196 assert_eq!(unique.len(), ids.len(), "operation ids repeat");
API and MCP server in Rust; a public index at the API root1197 }
1198
1199 #[test]
1200 fn path_and_query_inputs_are_not_repeated_in_the_body() {
1201 let document = document();
Agents as a team: lifecycle, merge queue, billing and a new shell1202 let merge = &document["paths"]["/repos/{owner}/{name}/pulls/{number}/merge"]["post"];
API and MCP server in Rust; a public index at the API root1203 let body = &merge["requestBody"]["content"]["application/json"]["schema"]["properties"];
1204 assert!(body.get("keep_issue_open").is_some());
1205 assert!(body.get("repo").is_none() && body.get("number").is_none());
Agents as a team: lifecycle, merge queue, billing and a new shell1206 let list = &document["paths"]["/repos"]["get"];
API and MCP server in Rust; a public index at the API root1207 assert_eq!(list["parameters"][0]["name"], "q");
1208 assert!(list.get("requestBody").is_none());
1209 }
1210
1211 #[test]
Merge branch 'worktree-agent-ab2e39e11a6493412'1212 fn every_operation_is_in_one_section() {
1213 for op in Op::ALL {
1214 let sections = SECTIONS
1215 .iter()
1216 .filter(|(_, _, ops)| ops.contains(&op))
1217 .count();
1218 assert_eq!(sections, 1, "{}", op.name());
1219 }
1220 }
1221
1222 #[test]
API and MCP server in Rust; a public index at the API root1223 fn titles_read_as_sentences() {
Merge branch 'worktree-agent-ab2e39e11a6493412'1224 assert_eq!(title(Op::CreateIssue), "Create an issue");
API and MCP server in Rust; a public index at the API root1225 assert_eq!(title(Op::Whoami), "Get the current user");
1226 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1227
1228 #[test]
1229 fn every_operation_has_an_example_response() {
1230 let examples = examples();
1231 assert!(!examples.is_empty(), "reference.json does not parse");
1232 let document = document();
1233 let mut known = Vec::new();
1234 for (path, methods) in document["paths"].as_object().unwrap() {
1235 for (method, operation) in methods.as_object().unwrap() {
1236 known.push(operation["operationId"].as_str().unwrap().to_owned());
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts1237 // Nothing to show for a success without a body.
1238 if operation["responses"]["204"].is_object() {
1239 continue;
1240 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1241 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1242 assert!(!example.is_null(), "{method} {path} has no example response");
1243 }
1244 }
1245 for id in examples.keys() {
1246 assert!(known.contains(id), "reference.json names {id}, which is not an operation");
1247 }
1248 }
1249
1250 #[test]
1251 fn example_requests_send_only_what_the_body_takes() {
1252 let document = document();
1253 for (path, methods) in document["paths"].as_object().unwrap() {
1254 for (method, operation) in methods.as_object().unwrap() {
1255 let content = &operation["requestBody"]["content"]["application/json"];
1256 let Some(example) = content["example"].as_object() else { continue };
1257 let properties = &content["schema"]["properties"];
1258 for key in example.keys() {
1259 assert!(!properties[key].is_null(), "{method} {path}: {key} is not in the body");
1260 }
1261 }
1262 }
1263 }
1264
1265 /// The docs site's copy of the document. Run with `G1T_WRITE_OPENAPI=1`
1266 /// to rewrite it after changing an operation.
1267 #[test]
1268 fn the_docs_copy_is_current() {
1269 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../docs/src/data/openapi.json");
1270 let current = serde_json::to_string_pretty(&document()).unwrap() + "\n";
1271 if std::env::var_os("G1T_WRITE_OPENAPI").is_some() {
1272 std::fs::write(path, &current).unwrap();
1273 return;
1274 }
1275 let copy = std::fs::read_to_string(path).unwrap_or_default().replace("\r\n", "\n");
1276 assert!(
1277 copy == current,
1278 "apps/docs/src/data/openapi.json is out of date: run G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi"
1279 );
1280 }
API reference: no example reads as a real secret1281
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1282 /// The reference shows responses as they are sent: `snake_case`.
1283 #[test]
1284 fn example_responses_are_snake_case() {
1285 let document = document();
1286 for (path, methods) in document["paths"].as_object().unwrap() {
1287 for (method, operation) in methods.as_object().unwrap() {
1288 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1289 let leaked = g1t_kit::wire::camel_case_keys(example);
1290 assert!(leaked.is_empty(), "{method} {path} shows {leaked:?}");
1291 }
1292 }
1293 }
1294
API reference: no example reads as a real secret1295 /// Examples never hold anything that reads as a real credential, which
1296 /// secret scanners rightly flag in a public repository: they end in `…`
1297 /// after the prefix, as `whsec_…` and `g1t_…` do.
1298 #[test]
1299 fn examples_hold_no_real_looking_secrets() {
Fast pages, required checks on the branch, self-hosted runners, honest incidents1300 let prefixes = ["whsec_", "g1t_", "g1tr_", "g1trt_", "sk_live_", "sk_test_", "ghp_", "github_pat_", "xoxb-", "AKIA"];
API reference: no example reads as a real secret1301 for (line, text) in REFERENCE.lines().enumerate() {
1302 for prefix in prefixes {
1303 let mut rest = text;
1304 while let Some(at) = rest.find(prefix) {
1305 let after = &rest[at + prefix.len()..];
1306 let run = after.chars().take_while(|c| c.is_ascii_alphanumeric()).count();
1307 assert!(
1308 run < 12,
1309 "reference.json line {}: `{prefix}` followed by {run} characters reads as a real secret; write `{prefix}…`",
1310 line + 1
1311 );
1312 rest = after;
1313 }
1314 }
1315 }
1316 }
API and MCP server in Rust; a public index at the API root1317}

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