Skip to content
1,287 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.",
Email confirmation gate: a code and a link, nothing else until confirmed29 &[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",
85 "While g1t is invite-only, every new account needs an invite. Your invites, and inviting people into a workspace by email.",
86 &[
87 Op::ListInvites,
88 Op::CreateInvite,
89 Op::RevokeInvite,
90 Op::ListWorkspaceInvites,
91 Op::InviteMember,
92 Op::RevokeWorkspaceInvite,
93 ],
Merge branch 'worktree-agent-ab2e39e11a6493412'94 ),
95 (
Usage, Billing settings and prepaid AI credit; fixes from the UX audit96 "Billing",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens97 "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 audit98 &[
99 Op::GetUsage,
100 Op::GetBudget,
101 Op::SetBudget,
102 Op::GetAiCredit,
103 Op::BuyAiCredit,
104 Op::ListInvoices,
105 Op::GetBillingDetails,
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens106 Op::ListGatewayRequests,
Usage, Billing settings and prepaid AI credit; fixes from the UX audit107 ],
108 ),
109 (
Merge branch 'worktree-agent-ab2e39e11a6493412'110 "Repositories",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look111 "A repository, how it handles pull requests, and its timeline: renaming, archiving, moving and deleting it.",
Merge branch 'worktree-agent-ab2e39e11a6493412'112 &[
113 Op::ListRepos,
114 Op::CreateRepo,
115 Op::GetRepo,
116 Op::UpdateRepo,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look117 Op::RenameRepo,
118 Op::RenameBranch,
119 Op::SetRepoVisibility,
120 Op::ArchiveRepo,
121 Op::UnarchiveRepo,
122 Op::TransferRepo,
123 Op::DeleteRepo,
124 Op::ListDeletedRepos,
125 Op::RestoreRepo,
126 Op::PurgeRepo,
Merge branch 'worktree-agent-ab2e39e11a6493412'127 Op::GetRepoSettings,
128 Op::UpdateRepoSettings,
Fast pages, required checks on the branch, self-hosted runners, honest incidents129 Op::ListCheckNames,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar130 Op::GetCodeownersErrors,
Merge branch 'worktree-agent-ab2e39e11a6493412'131 Op::ListEvents,
132 ],
133 ),
134 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97135 "Repository insights",
136 "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.",
137 &[Op::About(AboutOp::GetLanguages), Op::About(AboutOp::ListContributors), Op::About(AboutOp::GetLicense)],
138 ),
139 (
140 "Stars",
141 "Starring a repository, to keep it and to say you like it: who starred one, and what you starred.",
142 &[
143 Op::About(AboutOp::ListStargazers),
144 Op::About(AboutOp::ListStarred),
145 Op::About(AboutOp::CheckStarred),
146 Op::About(AboutOp::Star),
147 Op::About(AboutOp::Unstar),
148 ],
149 ),
150 (
151 "Releases",
152 "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.",
153 &[
154 Op::About(AboutOp::ListReleases),
155 Op::About(AboutOp::CreateRelease),
156 Op::About(AboutOp::GetLatestRelease),
157 Op::About(AboutOp::GetReleaseByTag),
158 Op::About(AboutOp::GetRelease),
159 Op::About(AboutOp::UpdateRelease),
160 Op::About(AboutOp::DeleteRelease),
161 ],
162 ),
163 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look164 "Access",
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca165 "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 look166 &[
167 Op::ListCollaborators,
168 Op::AddCollaborator,
169 Op::UpdateCollaborator,
170 Op::RemoveCollaborator,
171 Op::GetCollaboratorPermission,
172 Op::ListRepoInvitations,
173 Op::RevokeRepoInvitation,
174 Op::ListMyRepoInvitations,
175 Op::AcceptRepoInvitation,
176 Op::DeclineRepoInvitation,
177 Op::SetBasePermission,
178 Op::ListOutsideCollaborators,
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca179 Op::DeployKeys(DeployKeysOp::ListDeployKeys),
180 Op::DeployKeys(DeployKeysOp::GetDeployKey),
181 Op::DeployKeys(DeployKeysOp::CreateDeployKey),
182 Op::DeployKeys(DeployKeysOp::DeleteDeployKey),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look183 ],
184 ),
185 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar186 "Teams",
187 "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.",
188 &[
189 Op::ListTeams,
190 Op::CreateTeam,
191 Op::GetTeam,
192 Op::UpdateTeam,
193 Op::DeleteTeam,
194 Op::ListTeamMembers,
195 Op::SetTeamMember,
196 Op::RemoveTeamMember,
197 Op::ListChildTeams,
198 Op::ListTeamRepos,
199 Op::SetTeamRepo,
200 Op::RemoveTeamRepo,
201 Op::SetTeamReviewAssignment,
202 Op::ListUserTeams,
203 ],
204 ),
205 (
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily206 "Security",
207 "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.",
208 &[Op::ListSecurityAlerts, Op::DismissSecurityAlert, Op::ReopenSecurityAlert],
209 ),
210 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar211 "Secret scanning",
212 "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.",
213 &[
214 Op::Security(SecurityOp::ListSecretAlerts),
215 Op::Security(SecurityOp::GetSecretAlert),
216 Op::Security(SecurityOp::UpdateSecretAlert),
217 Op::Security(SecurityOp::ListSecretLocations),
218 Op::Security(SecurityOp::BypassPushProtection),
219 Op::Security(SecurityOp::CheckSecretValidity),
220 Op::Security(SecurityOp::ListBypassRequests),
221 Op::Security(SecurityOp::ReviewBypassRequest),
222 Op::Security(SecurityOp::ListCustomPatterns),
223 Op::Security(SecurityOp::CreateCustomPattern),
224 Op::Security(SecurityOp::UpdateCustomPattern),
225 Op::Security(SecurityOp::DeleteCustomPattern),
226 Op::Security(SecurityOp::DryRunCustomPattern),
227 ],
228 ),
229 (
230 "Code scanning",
231 "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.",
232 &[
233 Op::Security(SecurityOp::ListCodeAlerts),
234 Op::Security(SecurityOp::GetCodeAlert),
235 Op::Security(SecurityOp::UpdateCodeAlert),
236 Op::Security(SecurityOp::ListAnalyses),
237 Op::Security(SecurityOp::UploadSarif),
238 Op::Security(SecurityOp::GetSarifUpload),
239 Op::Security(SecurityOp::FixAlert),
240 ],
241 ),
242 (
243 "Supply chain",
244 "What a repository depends on: vulnerability alerts, the dependency graph, an SPDX SBOM of it, and comparing two commits' dependencies as dependency review does.",
245 &[
246 Op::Security(SecurityOp::ListVulnerabilityAlerts),
247 Op::Security(SecurityOp::GetVulnerabilityAlert),
248 Op::Security(SecurityOp::UpdateVulnerabilityAlert),
249 Op::Security(SecurityOp::GetDependencyGraph),
250 Op::Security(SecurityOp::GetSbom),
251 Op::Security(SecurityOp::CompareDependencies),
252 ],
253 ),
254 (
255 "Security settings",
256 "When pull request checks fail, dependency review's policy, delegated bypass and validity checks, and a workspace's security overview.",
257 &[
258 Op::Security(SecurityOp::GetSettings),
259 Op::Security(SecurityOp::UpdateSettings),
260 Op::Security(SecurityOp::GetWorkspaceSettings),
261 Op::Security(SecurityOp::UpdateWorkspaceSettings),
262 Op::Security(SecurityOp::GetOverview),
263 ],
264 ),
265 (
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge266 "Rules",
267 "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.",
268 &[
269 Op::Rules(RulesOp::ListRepoRulesets),
270 Op::Rules(RulesOp::CreateRepoRuleset),
271 Op::Rules(RulesOp::GetRepoRuleset),
272 Op::Rules(RulesOp::UpdateRepoRuleset),
273 Op::Rules(RulesOp::DeleteRepoRuleset),
274 Op::Rules(RulesOp::GetBranchRules),
275 Op::Rules(RulesOp::ListRuleEvaluations),
276 Op::Rules(RulesOp::ListWorkspaceRulesets),
277 Op::Rules(RulesOp::CreateWorkspaceRuleset),
278 Op::Rules(RulesOp::GetWorkspaceRuleset),
279 Op::Rules(RulesOp::UpdateWorkspaceRuleset),
280 Op::Rules(RulesOp::DeleteWorkspaceRuleset),
281 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
282 ],
283 ),
284 (
Merge checks: statuses and check runs on every commit285 "Checks",
286 "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.",
287 &[
288 Op::Checks(ChecksOp::CreateCommitStatus),
289 Op::Checks(ChecksOp::ListCommitStatuses),
290 Op::Checks(ChecksOp::GetCombinedStatus),
291 Op::Checks(ChecksOp::CreateCheckRun),
292 Op::Checks(ChecksOp::UpdateCheckRun),
293 Op::Checks(ChecksOp::GetCheckRun),
294 Op::Checks(ChecksOp::ListCheckRunAnnotations),
295 Op::Checks(ChecksOp::RerequestCheckRun),
296 Op::Checks(ChecksOp::ListCheckRunsForRef),
297 Op::Checks(ChecksOp::ListCheckSuitesForRef),
298 Op::Checks(ChecksOp::GetCheckSuite),
299 Op::Checks(ChecksOp::RerequestCheckSuite),
300 ],
301 ),
302 (
Merge branch 'worktree-agent-ab2e39e11a6493412'303 "Issues",
304 "What should change in a repository, with labels and comments. Issues and pull requests share one sequence of numbers.",
305 &[
306 Op::ListIssues,
307 Op::CreateIssue,
308 Op::GetIssue,
309 Op::UpdateIssue,
310 Op::CloseIssue,
311 Op::ReopenIssue,
312 Op::AssignIssue,
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step313 Op::Delegate,
Merge branch 'worktree-agent-ab2e39e11a6493412'314 Op::AddComment,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar315 Op::ListIssueLabels,
316 Op::AddIssueLabels,
317 Op::SetIssueLabels,
318 Op::RemoveIssueLabels,
319 ],
320 ),
321 (
322 "Labels and milestones",
323 "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.",
324 &[
Merge branch 'worktree-agent-ab2e39e11a6493412'325 Op::ListLabels,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar326 Op::CreateLabel,
327 Op::UpdateLabel,
328 Op::DeleteLabel,
329 Op::AddDefaultLabels,
330 Op::ListMilestones,
331 Op::CreateMilestone,
332 Op::GetMilestone,
333 Op::UpdateMilestone,
334 Op::DeleteMilestone,
Merge branch 'worktree-agent-ab2e39e11a6493412'335 ],
336 ),
337 (
338 "Plans",
339 "An outcome turned into the issues that would get there, with the order they must merge in.",
340 &[Op::PlanWork, Op::GetPlan, Op::ApplyPlan],
341 ),
342 (
343 "Pull requests",
344 "A proposed change in its own fork or on a branch. Several can be made for one issue; the one merged resolves it.",
345 &[
346 Op::ListPullRequests,
347 Op::CreatePullRequest,
348 Op::GetPullRequest,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar349 Op::UpdatePullRequest,
Merge branch 'worktree-agent-ab2e39e11a6493412'350 Op::GetPullRequestChanges,
351 Op::MarkPullRequestReady,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar352 Op::RequestReviewers,
353 Op::RemoveRequestedReviewers,
Merge branch 'worktree-agent-ab2e39e11a6493412'354 Op::ReviewPullRequest,
355 Op::MergePullRequest,
356 Op::ClosePullRequest,
357 Op::GetMergeQueue,
358 Op::MessageAgent,
359 Op::AnswerMessage,
360 Op::TakeMessages,
361 ],
362 ),
363 (
364 "Sessions",
365 "The record of how a pull request was made: prompts, reasoning and the tools that ran.",
366 &[Op::ReadSession, Op::RecordSession],
367 ),
368 (
Agents and memory, checks and conflicts, profiles, slug renames, custom domains369 "Memory",
370 "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.",
371 &[Op::Remember, Op::Recall],
372 ),
373 (
Search across all of g1t, Explore, and a command palette374 "Search",
375 "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.",
376 &[Op::Search],
377 ),
378 (
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API379 "Context",
380 "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.",
381 &[Op::SearchContext, Op::GetEntity],
382 ),
383 (
Merge branch 'worktree-agent-ab2e39e11a6493412'384 "Actions",
385 "GitHub Actions workflows in .g1t/workflows, their runs, and their jobs' logs.",
386 &[
387 Op::ListWorkflows,
388 Op::ListWorkflowRuns,
389 Op::GetWorkflowRun,
390 Op::GetJobLogs,
391 Op::DispatchWorkflow,
392 Op::CancelWorkflowRun,
393 Op::RerunWorkflowRun,
394 Op::UpdateWorkflow,
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2395 Op::Artifacts(ArtifactsOp::ListArtifacts),
396 Op::Artifacts(ArtifactsOp::ListRunArtifacts),
397 Op::Artifacts(ArtifactsOp::GetArtifact),
398 Op::Artifacts(ArtifactsOp::DownloadArtifact),
399 Op::Artifacts(ArtifactsOp::DeleteArtifact),
400 Op::Artifacts(ArtifactsOp::GetArtifactRetention),
401 Op::Artifacts(ArtifactsOp::SetArtifactRetention),
Merge branch 'worktree-agent-ab2e39e11a6493412'402 ],
403 ),
404 (
Merge packages: roles, Actions access, source label, soft delete, API405 "Packages",
406 "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.",
407 &[
408 Op::Packages(PackagesOp::ListPackages),
409 Op::Packages(PackagesOp::GetPackage),
410 Op::Packages(PackagesOp::UpdatePackage),
411 Op::Packages(PackagesOp::DeletePackage),
412 Op::Packages(PackagesOp::RestorePackage),
413 Op::Packages(PackagesOp::ListVersions),
414 Op::Packages(PackagesOp::GetVersion),
415 Op::Packages(PackagesOp::DeleteVersion),
416 Op::Packages(PackagesOp::RestoreVersion),
417 Op::Packages(PackagesOp::LinkPackage),
418 Op::Packages(PackagesOp::UnlinkPackage),
419 Op::Packages(PackagesOp::ListAccess),
420 Op::Packages(PackagesOp::SetAccess),
421 Op::Packages(PackagesOp::RemoveAccess),
422 Op::Packages(PackagesOp::ListActionsAccess),
423 Op::Packages(PackagesOp::SetActionsAccess),
424 Op::Packages(PackagesOp::RemoveActionsAccess),
425 ],
426 ),
427 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97428 "Deployments",
429 "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.",
430 &[
431 Op::Deployments(DeploymentsOp::ListDeployments),
432 Op::Deployments(DeploymentsOp::CreateDeployment),
433 Op::Deployments(DeploymentsOp::GetDeployment),
434 Op::Deployments(DeploymentsOp::ListDeploymentStatuses),
435 Op::Deployments(DeploymentsOp::CreateDeploymentStatus),
436 Op::Deployments(DeploymentsOp::ListEnvironments),
437 Op::Deployments(DeploymentsOp::GetEnvironment),
438 ],
439 ),
440 (
Merge branch 'worktree-agent-a3abfcce648e87dca'441 "Run protection",
442 "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.",
443 &[
444 Op::Protection(ProtectionOp::UpdateEnvironment),
445 Op::Protection(ProtectionOp::DeleteEnvironment),
446 Op::Protection(ProtectionOp::GetPendingDeployments),
447 Op::Protection(ProtectionOp::ReviewPendingDeployments),
448 Op::Protection(ProtectionOp::ApproveWorkflowRun),
449 Op::Protection(ProtectionOp::GetWorkflowPermissions),
450 Op::Protection(ProtectionOp::SetWorkflowPermissions),
451 Op::Protection(ProtectionOp::GetForkPrApproval),
452 Op::Protection(ProtectionOp::SetForkPrApproval),
453 Op::Protection(ProtectionOp::CreateRepositoryDispatch),
454 Op::Protection(ProtectionOp::GetWorkspaceWorkflowPermissions),
455 Op::Protection(ProtectionOp::SetWorkspaceWorkflowPermissions),
456 ],
457 ),
458 (
Merge branch 'worktree-agent-ab2e39e11a6493412'459 "Secrets and variables",
460 "Values that workflows and deployments read, per repository or for a whole workspace, with a row per environment.",
461 &[
462 Op::ListActionsSecrets,
463 Op::SetActionsSecret,
464 Op::DeleteActionsSecret,
465 Op::ListActionsVariables,
466 Op::SetActionsVariable,
467 Op::DeleteActionsVariable,
468 ],
469 ),
470 (
Fast pages, required checks on the branch, self-hosted runners, honest incidents471 "Runners",
472 "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.",
473 &[
474 Op::ListRunners,
475 Op::CreateRunnerRegistrationToken,
476 Op::RemoveRunner,
477 Op::ListRunnerGroups,
478 Op::CreateRunnerGroup,
479 Op::UpdateRunnerGroup,
480 Op::DeleteRunnerGroup,
481 Op::GetRunnerSettings,
482 Op::UpdateRunnerSettings,
483 ],
484 ),
485 (
Merge branch 'worktree-agent-ab2e39e11a6493412'486 "Webhooks",
487 "Signed HTTPS requests sent to your own address as things happen, for a repository or a whole workspace.",
488 &[
489 Op::ListWebhooks,
490 Op::CreateWebhook,
491 Op::UpdateWebhook,
492 Op::DeleteWebhook,
493 Op::PingWebhook,
494 Op::ListWebhookDeliveries,
495 Op::RedeliverWebhook,
496 ],
497 ),
498 (
499 "Integrations",
500 "A workspace's connections to outside systems: model providers, alert sources and issue trackers.",
501 &[
502 Op::ListIntegrations,
503 Op::ConnectIntegration,
AI Gateway: OpenAI's format, open models, and your own providers504 Op::UpdateIntegration,
Merge branch 'worktree-agent-ab2e39e11a6493412'505 Op::DisconnectIntegration,
506 Op::TestIntegration,
507 Op::GetModelRoutes,
508 Op::SetModelRoutes,
509 Op::GetContext,
510 Op::ImportIssue,
511 ],
512 ),
513];
514
API and MCP server in Rust; a public index at the API root515/// The section of the API reference an operation is listed under.
516fn tag(op: Op) -> &'static str {
Merge branch 'worktree-agent-ab2e39e11a6493412'517 SECTIONS
API and MCP server in Rust; a public index at the API root518 .iter()
Merge branch 'worktree-agent-ab2e39e11a6493412'519 .find(|(_, _, ops)| ops.contains(&op))
520 .map_or("Repositories", |(name, _, _)| name)
521}
522
523/// What an operation's page is called, as a short sentence.
524fn title(op: Op) -> &'static str {
525 match op {
526 Op::Whoami => "Get the current user",
Merge branch 'worktree-agent-ad7c6d88d93adc817'527 Op::GetWorkspace => "Get a workspace",
Merge branch 'worktree-agent-ab2e39e11a6493412'528 Op::CreateWorkspace => "Create a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look529 Op::DeleteWorkspace => "Delete a workspace",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily530 Op::UpdateWorkspace => "Update a workspace",
Merge main (membership, two-factor, GitHub repo roles) into tokens531 Op::ListMembers => "List a workspace's members",
532 Op::UpdateMember => "Change a member's role",
533 Op::RemoveMember => "Remove a member",
534 Op::TransferOwnership => "Transfer a workspace's ownership",
535 Op::LeaveWorkspace => "Leave a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look536 Op::ListEmails => "List your email addresses",
537 Op::AddEmail => "Add an email address",
Email confirmation gate: a code and a link, nothing else until confirmed538 Op::ConfirmEmail => "Confirm an email address",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look539 Op::RemoveEmail => "Remove an email address",
540 Op::UpdateEmailSettings => "Change your email settings",
541 Op::ListInvites => "List your invites",
542 Op::CreateInvite => "Create an invite",
543 Op::RevokeInvite => "Revoke an invite",
544 Op::ListWorkspaceInvites => "List a workspace's invites",
545 Op::InviteMember => "Invite someone to a workspace",
546 Op::RevokeWorkspaceInvite => "Revoke a workspace's invite",
547 Op::TransferRepo => "Transfer a repository",
548 Op::RenameRepo => "Rename a repository",
549 Op::RenameBranch => "Rename a branch",
550 Op::ArchiveRepo => "Archive a repository",
551 Op::UnarchiveRepo => "Unarchive a repository",
552 Op::SetRepoVisibility => "Change a repository's visibility",
553 Op::DeleteRepo => "Delete a repository",
554 Op::ListDeletedRepos => "List recently deleted repositories",
555 Op::RestoreRepo => "Restore a deleted repository",
556 Op::PurgeRepo => "Purge a deleted repository",
Merge branch 'worktree-agent-ab2e39e11a6493412'557 Op::ListRepos => "List repositories",
558 Op::GetRepo => "Get a repository",
559 Op::CreateRepo => "Create a repository",
560 Op::UpdateRepo => "Update a repository",
561 Op::GetRepoSettings => "Get repository settings",
562 Op::UpdateRepoSettings => "Update repository settings",
Fast pages, required checks on the branch, self-hosted runners, honest incidents563 Op::ListCheckNames => "List check names",
Merge branch 'worktree-agent-ab2e39e11a6493412'564 Op::GetMergeQueue => "Get the merge queue",
565 Op::MessageAgent => "Message an agent",
566 Op::AnswerMessage => "Answer a message",
567 Op::TakeMessages => "Take new messages",
Agents and memory, checks and conflicts, profiles, slug renames, custom domains568 Op::Remember => "Remember something",
569 Op::Recall => "Recall memory",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API570 Op::SearchContext => "Search the context hub",
571 Op::GetEntity => "Get a catalog entry",
Search across all of g1t, Explore, and a command palette572 Op::Search => "Search g1t",
Merge branch 'worktree-agent-ab2e39e11a6493412'573 Op::ListIssues => "List issues",
574 Op::GetIssue => "Get an issue",
575 Op::CreateIssue => "Create an issue",
576 Op::UpdateIssue => "Update an issue",
577 Op::CloseIssue => "Close an issue",
578 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-agent579 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 step580 Op::Delegate => "Put an agent on it",
Merge branch 'worktree-agent-ab2e39e11a6493412'581 Op::PlanWork => "Plan work",
582 Op::GetPlan => "Get a plan",
583 Op::ApplyPlan => "Apply a plan",
584 Op::ListLabels => "List labels",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar585 Op::CreateLabel => "Create a label",
586 Op::UpdateLabel => "Update a label",
587 Op::DeleteLabel => "Delete a label",
588 Op::AddDefaultLabels => "Add the default labels",
589 Op::ListIssueLabels => "List an issue's labels",
590 Op::AddIssueLabels => "Add labels to an issue",
591 Op::SetIssueLabels => "Set an issue's labels",
592 Op::RemoveIssueLabels => "Remove labels from an issue",
593 Op::ListMilestones => "List milestones",
594 Op::GetMilestone => "Get a milestone",
595 Op::CreateMilestone => "Create a milestone",
596 Op::UpdateMilestone => "Update a milestone",
597 Op::DeleteMilestone => "Delete a milestone",
598 Op::UpdatePullRequest => "Update a pull request",
Merge branch 'worktree-agent-ab2e39e11a6493412'599 Op::AddComment => "Add a comment",
600 Op::ReviewPullRequest => "Review a pull request",
601 Op::ListPullRequests => "List pull requests",
602 Op::GetPullRequest => "Get a pull request",
603 Op::CreatePullRequest => "Create a pull request",
604 Op::RecordSession => "Record session entries",
605 Op::ReadSession => "Read a session",
606 Op::MarkPullRequestReady => "Mark a pull request ready",
607 Op::ClosePullRequest => "Close a pull request",
608 Op::GetPullRequestChanges => "Get a pull request's changes",
609 Op::MergePullRequest => "Merge a pull request",
610 Op::ListEvents => "List repository events",
611 Op::ListIntegrations => "List integrations",
612 Op::ConnectIntegration => "Connect an integration",
AI Gateway: OpenAI's format, open models, and your own providers613 Op::UpdateIntegration => "Update an integration",
Merge branch 'worktree-agent-ab2e39e11a6493412'614 Op::DisconnectIntegration => "Disconnect an integration",
615 Op::TestIntegration => "Test an integration",
616 Op::GetContext => "Look up a ticket",
617 Op::ImportIssue => "Import an issue",
618 Op::GetModelRoutes => "Get model routes",
619 Op::SetModelRoutes => "Set model routes",
620 Op::ListWebhooks => "List webhooks",
621 Op::CreateWebhook => "Create a webhook",
622 Op::UpdateWebhook => "Update a webhook",
623 Op::DeleteWebhook => "Delete a webhook",
624 Op::PingWebhook => "Ping a webhook",
625 Op::ListWebhookDeliveries => "List webhook deliveries",
626 Op::RedeliverWebhook => "Redeliver a webhook delivery",
627 Op::ListWorkflows => "List workflows",
628 Op::ListWorkflowRuns => "List workflow runs",
629 Op::GetWorkflowRun => "Get a workflow run",
630 Op::GetJobLogs => "Get a job's log",
631 Op::DispatchWorkflow => "Run a workflow",
632 Op::CancelWorkflowRun => "Cancel a workflow run",
633 Op::RerunWorkflowRun => "Re-run a workflow run",
634 Op::UpdateWorkflow => "Turn a workflow on or off",
635 Op::ListActionsSecrets => "List secrets",
636 Op::SetActionsSecret => "Set a secret",
637 Op::DeleteActionsSecret => "Delete a secret",
638 Op::ListActionsVariables => "List variables",
639 Op::SetActionsVariable => "Set a variable",
640 Op::DeleteActionsVariable => "Delete a variable",
Fast pages, required checks on the branch, self-hosted runners, honest incidents641 Op::ListRunners => "List self-hosted runners",
642 Op::ListRunnerGroups => "List runner groups",
643 Op::GetRunnerSettings => "Get runner settings",
644 Op::CreateRunnerRegistrationToken => "Create a runner registration token",
645 Op::RemoveRunner => "Remove a self-hosted runner",
646 Op::CreateRunnerGroup => "Create a runner group",
647 Op::UpdateRunnerGroup => "Change a runner group",
648 Op::DeleteRunnerGroup => "Delete a runner group",
649 Op::UpdateRunnerSettings => "Change runner settings",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look650 Op::ListCollaborators => "List who has access",
651 Op::AddCollaborator => "Add a collaborator",
652 Op::UpdateCollaborator => "Change a collaborator's role",
653 Op::RemoveCollaborator => "Remove a collaborator",
654 Op::GetCollaboratorPermission => "Get someone's permission",
655 Op::ListRepoInvitations => "List a repository's invitations",
656 Op::RevokeRepoInvitation => "Revoke a repository invitation",
657 Op::ListMyRepoInvitations => "List your repository invitations",
658 Op::AcceptRepoInvitation => "Accept a repository invitation",
659 Op::DeclineRepoInvitation => "Decline a repository invitation",
660 Op::SetBasePermission => "Set the base permission",
661 Op::ListOutsideCollaborators => "List outside collaborators",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily662 Op::ListSecurityAlerts => "List security alerts",
663 Op::DismissSecurityAlert => "Dismiss a security alert",
664 Op::ReopenSecurityAlert => "Reopen a security alert",
API: notifications over REST and MCP, with notifications scopes665 Op::ListNotifications => "List notifications",
666 Op::MarkNotificationsRead => "Mark notifications read",
667 Op::GetNotificationThread => "Get a thread",
668 Op::MarkThreadRead => "Mark a thread read",
669 Op::MarkThreadDone => "Mark a thread done",
670 Op::SaveThread => "Save a thread",
671 Op::SnoozeThread => "Snooze a thread",
672 Op::GetThreadSubscription => "Get a thread subscription",
673 Op::SetThreadSubscription => "Set a thread subscription",
674 Op::DeleteThreadSubscription => "Unsubscribe from a thread",
675 Op::GetRepoSubscription => "Get how you watch a repository",
676 Op::SetRepoSubscription => "Watch a repository",
677 Op::DeleteRepoSubscription => "Stop watching a repository",
678 Op::ListWatchedRepos => "List repositories you watch",
API: pinned projects over REST and MCP679 Op::ListPinnedProjects => "List your pinned projects",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit680 Op::GetUsage => "Get a workspace's usage",
681 Op::GetBudget => "Get a workspace's budget",
682 Op::SetBudget => "Change a workspace's budget",
683 Op::GetAiCredit => "Get a workspace's AI credit",
684 Op::BuyAiCredit => "Buy AI credit",
685 Op::ListInvoices => "List a workspace's invoices",
686 Op::GetBillingDetails => "Get a workspace's billing details",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens687 Op::ListGatewayRequests => "List a workspace's AI Gateway requests",
API: pinned projects over REST and MCP688 Op::PinProject => "Pin a project",
689 Op::UnpinProject => "Unpin a project",
690 Op::ReorderPinnedProjects => "Reorder your pinned projects",
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97691 Op::ListProjects => "List a workspace's projects",
692 Op::GetProject => "Get a project",
693 Op::UpdateProject => "Update a project",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar694 Op::ListTeams => "List teams",
695 Op::GetTeam => "Get a team",
696 Op::CreateTeam => "Create a team",
697 Op::UpdateTeam => "Update a team",
698 Op::DeleteTeam => "Delete a team",
699 Op::ListTeamMembers => "List a team's members",
700 Op::SetTeamMember => "Add or change a team member",
701 Op::RemoveTeamMember => "Remove a team member",
702 Op::ListChildTeams => "List child teams",
703 Op::ListTeamRepos => "List a team's repositories",
704 Op::SetTeamRepo => "Give a team a role on a repository",
705 Op::RemoveTeamRepo => "Remove a team from a repository",
706 Op::SetTeamReviewAssignment => "Set a team's review assignment",
707 Op::ListUserTeams => "List someone's teams",
708 Op::RequestReviewers => "Request reviewers",
709 Op::RemoveRequestedReviewers => "Remove requested reviewers",
710 Op::GetCodeownersErrors => "List CODEOWNERS errors",
711 Op::Security(op) => op.title(),
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge712 Op::Rules(op) => op.title(),
Merge checks: statuses and check runs on every commit713 Op::Checks(op) => op.title(),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97714 Op::About(op) => op.title(),
715 Op::Deployments(op) => op.title(),
Merge branch 'worktree-agent-a3abfcce648e87dca'716 Op::Protection(op) => op.title(),
API and MCP for a workspace's personal access token rules, members' tokens and approvals717 Op::Tokens(op) => op.title(),
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2718 Op::Artifacts(op) => op.title(),
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca719 Op::DeployKeys(op) => op.title(),
Merge packages: roles, Actions access, source label, soft delete, API720 Op::Packages(op) => op.title(),
API and MCP server in Rust; a public index at the API root721 }
722}
723
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look724/// Why an operation can be refused with `402 payment_required`, if it
725/// can: the ones that start an agent, when the workspace has no credit,
726/// and the ones that make a repository private in a workspace, when a free
727/// workspace's private storage has no room for it.
728fn may_need_payment(op: Op) -> Option<&'static str> {
729 match op {
730 Op::AssignIssue | Op::PlanWork | Op::ApplyPlan => Some("The workspace has no agent credit."),
731 Op::UpdateRepo | Op::SetRepoVisibility | Op::TransferRepo => Some(
732 "A free workspace's private storage has no room for this private repository.",
733 ),
734 _ => None,
735 }
Merge branch 'worktree-agent-ab2e39e11a6493412'736}
737
738/// What the reference says beyond each operation's own description, keyed
739/// by operation id, written by hand from what the services return: `notes`
740/// (Markdown, added to the description) and example `params` (path),
741/// `query`, `request` (body) and `response`.
742const REFERENCE: &str = include_str!("reference.json");
743
744fn examples() -> Map<String, Value> {
745 match serde_json::from_str(REFERENCE) {
746 Ok(Value::Object(examples)) => examples,
747 _ => Map::new(),
API and MCP server in Rust; a public index at the API root748 }
749}
750
Agents as a team: lifecycle, merge queue, billing and a new shell751/// `/repos/:owner/:name` as OpenAPI writes it: `/repos/{owner}/{name}`.
API and MCP server in Rust; a public index at the API root752fn openapi_path(route: &Route) -> String {
753 route
754 .path
755 .split('/')
756 .map(|segment| match segment.strip_prefix(':') {
757 Some(name) => format!("{{{name}}}"),
758 None => segment.to_owned(),
759 })
760 .collect::<Vec<_>>()
761 .join("/")
762}
763
764fn error_response(description: &str) -> Value {
765 json!({
766 "description": description,
767 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } },
768 })
769}
770
Merge branch 'worktree-agent-ab2e39e11a6493412'771/// A parameter in the path or the query, described by the operation's
772/// input schema where it has the same name.
773fn parameter(name: &str, place: &str, required: bool, schema: Option<&Value>) -> Value {
774 let mut schema = schema.cloned().unwrap_or_else(|| json!({ "type": "string" }));
775 let description = match name {
776 "owner" => Some(Value::from("The workspace that owns the repository.")),
777 "name" => Some(Value::from("The repository's name.")),
778 _ => schema.as_object_mut().and_then(|schema| schema.remove("description")),
779 };
780 let mut parameter = json!({
781 "name": name,
782 "in": place,
783 "required": required,
784 "schema": schema,
785 });
786 if let Some(description) = description {
787 parameter["description"] = description;
788 }
789 parameter
790}
791
792/// The operation id of a route. An operation reached at a workspace's
793/// address as well as a repository's is documented once for each, with its
794/// own id; GitHub's alternative addresses for one operation keep GitHub's
795/// names.
796fn operation_id(route: &Route) -> String {
797 let op = route.op;
798 let base = match (route.method, route.path.rsplit('/').next().unwrap_or_default()) {
799 ("PUT", "enable") => "enable_workflow".to_owned(),
800 ("PUT", "disable") => "disable_workflow".to_owned(),
801 ("POST", "rerun-failed-jobs") => "rerun_failed_jobs".to_owned(),
802 ("PATCH", ":setting") => "update_actions_variable".to_owned(),
803 ("GET", "runs") if route.path.contains("/workflows/:workflow/") => "list_runs_of_workflow".to_owned(),
API: notifications over REST and MCP, with notifications scopes804 // One repository's notifications, and an issue's subscription by
805 // its number rather than a thread's id.
806 (_, "notifications") if route.path.starts_with("/repos/") => match op {
807 Op::ListNotifications => "list_repo_notifications".to_owned(),
808 _ => "mark_repo_notifications_read".to_owned(),
809 },
810 (method, "subscription") if route.path.contains("/issues/:number/") => match method {
811 "GET" => "get_issue_subscription".to_owned(),
812 "PUT" => "set_issue_subscription".to_owned(),
813 _ => "delete_issue_subscription".to_owned(),
814 },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar815 // One label off an issue, by its name in the path.
816 ("DELETE", ":label") if route.path.contains("/issues/:number/") => "remove_issue_label".to_owned(),
API: notifications over REST and MCP, with notifications scopes817 ("DELETE", "saved") => "unsave_thread".to_owned(),
818 ("DELETE", "snooze") => "unsnooze_thread".to_owned(),
Merge branch 'worktree-agent-ab2e39e11a6493412'819 _ => op.name().to_owned(),
820 };
821 if route.path.starts_with("/workspaces/") && ROUTES.iter().any(|other| other.op == op && other.path.starts_with("/repos/")) {
822 format!("{base}_for_workspace")
823 } else {
824 base
825 }
826}
827
828/// The summary of a route: its operation's title, or for one of GitHub's
829/// alternative addresses, what that address does.
830fn summary(route: &Route, id: &str) -> String {
831 let base = match id.trim_end_matches("_for_workspace") {
832 "enable_workflow" => "Turn a workflow on",
833 "disable_workflow" => "Turn a workflow off",
834 "rerun_failed_jobs" => "Re-run failed jobs",
835 "update_actions_variable" => "Update a variable",
836 "list_runs_of_workflow" => "List a workflow's runs",
API: notifications over REST and MCP, with notifications scopes837 "list_repo_notifications" => "List a repository's notifications",
838 "mark_repo_notifications_read" => "Mark a repository's notifications read",
839 "get_issue_subscription" => "Get your subscription to an issue",
840 "set_issue_subscription" => "Subscribe to an issue",
841 "delete_issue_subscription" => "Unsubscribe from an issue",
842 "unsave_thread" => "Unsave a thread",
843 "unsnooze_thread" => "Bring a snoozed thread back",
Merge branch 'worktree-agent-ab2e39e11a6493412'844 _ => title(route.op),
845 };
846 if id.ends_with("_for_workspace") {
847 format!("{base} for a workspace")
848 } else {
849 base.to_owned()
850 }
851}
852
API and MCP server in Rust; a public index at the API root853fn operation(route: &Route) -> Value {
854 let op = route.op;
855 let path_params: Vec<&str> = route.params().collect();
Merge checks: statuses and check runs on every commit856 // `owner` and `name` in the path stand for the operation's `repo` input,
857 // so a `name` in the body, such as a check run's, is the body's own.
858 let stands_for_repo =
859 |name: &str| matches!(name, "owner" | "name") && path_params.contains(&"owner") && path_params.contains(&"name");
860 let covered = |name: &str| name == "repo" || (path_params.contains(&name) && !stands_for_repo(name));
Merge branch 'worktree-agent-ab2e39e11a6493412'861 let all_properties = op.properties();
862 let mut properties = all_properties.clone();
API and MCP server in Rust; a public index at the API root863 properties.retain(|name, _| !covered(name));
864 let required: Vec<String> = op
865 .required()
866 .into_iter()
867 .filter(|name| !covered(name))
868 .collect();
869
870 let mut parameters: Vec<Value> = path_params
871 .iter()
Merge checks: statuses and check runs on every commit872 .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 root873 .collect();
874 let mut body = Value::Null;
875 if route.method == "GET" {
876 for (name, key) in route.query {
Merge branch 'worktree-agent-ab2e39e11a6493412'877 parameters.push(parameter(
878 name,
879 "query",
880 required.iter().any(|required| required == key),
881 properties.get(*key),
882 ));
API and MCP server in Rust; a public index at the API root883 }
884 } else if !properties.is_empty() {
885 let mut schema = json!({ "type": "object", "properties": properties });
886 if !required.is_empty() {
887 schema["required"] = json!(required);
888 }
889 body = json!({
890 "required": !required.is_empty(),
891 "content": { "application/json": { "schema": schema } },
892 });
893 }
894
Merge branch 'worktree-agent-ab2e39e11a6493412'895 let id = operation_id(route);
896 let mut responses = Map::new();
897 responses.insert(
898 "200".into(),
899 json!({
900 "description": "Success.",
901 "content": { "application/json": { "schema": {} } },
902 }),
903 );
904 responses.insert(
905 "401".into(),
906 error_response("A token is required, or the one sent is not valid."),
907 );
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look908 if let Some(reason) = may_need_payment(op) {
909 responses.insert("402".into(), error_response(reason));
Merge branch 'worktree-agent-ab2e39e11a6493412'910 }
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step911 responses.insert(
912 "403".into(),
913 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."),
914 );
Search across all of g1t, Explore, and a command palette915 if !matches!(op, Op::Whoami | Op::ListRepos | Op::Search) {
Merge branch 'worktree-agent-ab2e39e11a6493412'916 responses.insert("404".into(), error_response("It does not exist, or you cannot see it."));
917 }
918 if route.method != "GET" {
919 responses.insert(
920 "409".into(),
921 error_response("The request conflicts with the current state."),
922 );
923 }
924 if op != Op::Whoami {
925 responses.insert("422".into(), error_response("The input is not valid."));
926 }
927 // 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 step928 let scope: Vec<&str> = scope_for(op.name()).map(|scope| scope.as_str()).into_iter().collect();
Merge branch 'worktree-agent-ab2e39e11a6493412'929 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 step930 json!([{ "token": scope }])
Webhooks: every event, to your own addresses, signed and retried931 } else {
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step932 json!([{ "token": scope }, {}])
Webhooks: every event, to your own addresses, signed and retried933 };
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step934 let (tool, action) = crate::tools::TOOLS
935 .iter()
936 .find_map(|tool| {
937 tool.actions
938 .iter()
939 .find(|action| action.op == op)
940 .map(|action| (tool.name, action.name))
941 })
942 .unwrap_or_default();
API and MCP server in Rust; a public index at the API root943 let mut described = json!({
Webhooks: every event, to your own addresses, signed and retried944 "operationId": id,
API and MCP server in Rust; a public index at the API root945 "tags": [tag(op)],
Merge branch 'worktree-agent-ab2e39e11a6493412'946 "summary": summary(route, &id),
API and MCP server in Rust; a public index at the API root947 "description": op.description(),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step948 "x-operation": op.name(),
949 "x-mcp-tool": tool,
950 "x-mcp-action": action,
951 "x-scope": scope.first().copied(),
Merge branch 'worktree-agent-ab2e39e11a6493412'952 "security": security,
API and MCP server in Rust; a public index at the API root953 "parameters": parameters,
Merge branch 'worktree-agent-ab2e39e11a6493412'954 "responses": responses,
API and MCP server in Rust; a public index at the API root955 });
956 if !body.is_null() {
957 described["requestBody"] = body;
958 }
959 described
960}
961
962/// Entries for device sign-in, which is not an operation.
963fn onboarding() -> Map<String, Value> {
964 let paths = json!({
Agents as a team: lifecycle, merge queue, billing and a new shell965 "/device/code": {
API and MCP server in Rust; a public index at the API root966 "post": {
967 "operationId": "device_code",
968 "tags": ["Accounts"],
969 "summary": "Start signing in",
Agents as a team: lifecycle, merge queue, billing and a new shell970 "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 root971 "security": [],
972 "requestBody": {
973 "content": { "application/json": { "schema": {
974 "type": "object",
975 "properties": {
976 "client_name": {
977 "type": "string",
978 "description": "What is asking, shown to the person approving. For example, Claude Code.",
979 },
980 },
981 } } },
982 },
983 "responses": { "200": {
984 "description": "The codes for this sign-in.",
985 "content": { "application/json": { "schema": {
986 "type": "object",
987 "properties": {
Agents as a team: lifecycle, merge queue, billing and a new shell988 "device_code": { "type": "string", "description": "Secret. Send it to /device/token." },
API and MCP server in Rust; a public index at the API root989 "user_code": { "type": "string", "description": "Shown to the person, like WDJB-MJHT." },
990 "verification_uri": { "type": "string" },
991 "verification_uri_complete": {
992 "type": "string",
993 "description": "The link to give the person; it carries the code.",
994 },
995 "expires_in": { "type": "integer", "description": "Seconds until the codes expire." },
996 "interval": { "type": "integer", "description": "Seconds to wait between polls." },
997 },
998 } } },
999 } },
1000 },
1001 },
Agents as a team: lifecycle, merge queue, billing and a new shell1002 "/device/token": {
API and MCP server in Rust; a public index at the API root1003 "post": {
1004 "operationId": "device_token",
1005 "tags": ["Accounts"],
1006 "summary": "Finish signing in",
1007 "description": "Asks whether the person has approved. Poll no faster than the interval. The token is returned once.",
1008 "security": [],
1009 "requestBody": {
1010 "required": true,
1011 "content": { "application/json": { "schema": {
1012 "type": "object",
1013 "required": ["device_code"],
1014 "properties": { "device_code": { "type": "string" } },
1015 } } },
1016 },
1017 "responses": { "200": {
1018 "description": "The state of the sign-in.",
1019 "content": { "application/json": { "schema": {
1020 "type": "object",
1021 "required": ["status"],
1022 "properties": {
1023 "status": { "type": "string", "enum": ["pending", "approved", "denied", "expired"] },
1024 "token": { "type": "string", "description": "Present when approved." },
1025 "username": { "type": "string" },
1026 "verified": {
1027 "type": "boolean",
1028 "description": "Whether the account's email is confirmed.",
1029 },
1030 },
1031 } } },
1032 } },
1033 },
1034 },
1035 });
1036 match paths {
1037 Value::Object(paths) => paths,
1038 _ => Map::new(),
1039 }
1040}
1041
Merge branch 'worktree-agent-ab2e39e11a6493412'1042
1043/// Puts each operation's examples, where it has them, into its request
1044/// and response. Path and query values go under `x-example-params` and
1045/// `x-example-query`, which tools that build a request can use.
1046fn attach_examples(paths: &mut Map<String, Value>) {
1047 let examples = examples();
1048 for methods in paths.values_mut() {
1049 let Some(methods) = methods.as_object_mut() else { continue };
1050 for operation in methods.values_mut() {
1051 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 step1052 let name = operation["x-operation"].as_str().unwrap_or_default().to_owned();
1053 let Some(example) = examples.get(&id).or_else(|| examples.get(&name)) else {
Merge branch 'worktree-agent-ab2e39e11a6493412'1054 continue;
1055 };
1056 if let Some(notes) = example.get("notes").and_then(Value::as_str) {
1057 let description = operation["description"].as_str().unwrap_or_default();
1058 operation["description"] = json!(format!("{description}\n\n{notes}"));
1059 }
1060 if let Some(response) = example.get("response") {
1061 let content = &mut operation["responses"]["200"]["content"]["application/json"];
1062 if content.is_object() {
1063 content["example"] = response.clone();
1064 }
1065 }
1066 if let Some(request) = example.get("request") {
1067 let content = &mut operation["requestBody"]["content"]["application/json"];
1068 if content.is_object() {
1069 content["example"] = request.clone();
1070 }
1071 }
1072 for (key, extension) in [("params", "x-example-params"), ("query", "x-example-query")] {
1073 if let Some(values) = example.get(key) {
1074 operation[extension] = values.clone();
1075 }
1076 }
1077 }
1078 }
1079}
1080
API and MCP server in Rust; a public index at the API root1081pub fn document() -> Value {
1082 let mut paths = onboarding();
1083 for route in ROUTES {
1084 let entry = paths
1085 .entry(openapi_path(route))
1086 .or_insert_with(|| json!({}));
1087 entry[route.method.to_lowercase()] = operation(route);
1088 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1089 attach_examples(&mut paths);
1090 let tags: Vec<Value> = SECTIONS
1091 .iter()
1092 .map(|(name, description, ops)| {
1093 json!({
1094 "name": name,
1095 "description": description,
1096 // The section's operations in reading order, by MCP tool name.
1097 "x-tools": ops.iter().map(|op| op.name()).collect::<Vec<_>>(),
1098 })
1099 })
1100 .collect();
1101 let codes = ["unauthenticated", "payment_required", "forbidden", "not_found", "conflict", "invalid"];
API and MCP server in Rust; a public index at the API root1102 json!({
1103 "openapi": "3.1.0",
1104 "info": {
1105 "title": "g1t API",
1106 "version": "1",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1107 "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 root1108 "license": { "name": "MIT", "identifier": "MIT" },
1109 },
1110 "servers": [{ "url": "https://api.g1t.sh" }],
1111 "security": [{ "token": [] }, {}],
Merge branch 'worktree-agent-ab2e39e11a6493412'1112 "tags": tags,
API and MCP server in Rust; a public index at the API root1113 "paths": paths,
1114 "components": {
1115 "securitySchemes": {
1116 "token": {
1117 "type": "http",
1118 "scheme": "bearer",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1119 "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 root1120 },
1121 },
1122 "schemas": {
1123 "Error": {
1124 "type": "object",
1125 "required": ["error"],
1126 "properties": {
1127 "error": {
1128 "type": "object",
1129 "required": ["code", "message"],
1130 "properties": {
Merge branch 'worktree-agent-ab2e39e11a6493412'1131 "code": { "type": "string", "enum": codes },
API and MCP server in Rust; a public index at the API root1132 "message": { "type": "string" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1133 "needed_scope": {
1134 "type": "string",
1135 "description": "On a 403 for an access token without the scope the call needs: that scope, such as `issues:write`.",
1136 },
API and MCP server in Rust; a public index at the API root1137 },
1138 },
1139 },
1140 },
1141 },
1142 },
1143 })
1144}
1145
1146#[cfg(test)]
1147mod tests {
1148 use super::*;
1149
1150 #[test]
1151 fn every_route_is_documented_once() {
1152 let document = document();
1153 let mut ids = Vec::new();
1154 for (_, methods) in document["paths"].as_object().unwrap() {
1155 for (_, operation) in methods.as_object().unwrap() {
1156 ids.push(operation["operationId"].as_str().unwrap().to_owned());
1157 }
1158 }
1159 for op in Op::ALL {
1160 assert_eq!(
1161 ids.iter().filter(|id| *id == op.name()).count(),
1162 1,
1163 "{}",
1164 op.name()
1165 );
1166 }
Webhooks: every event, to your own addresses, signed and retried1167 let mut unique = ids.clone();
1168 unique.sort();
1169 unique.dedup();
1170 assert_eq!(unique.len(), ids.len(), "operation ids repeat");
API and MCP server in Rust; a public index at the API root1171 }
1172
1173 #[test]
1174 fn path_and_query_inputs_are_not_repeated_in_the_body() {
1175 let document = document();
Agents as a team: lifecycle, merge queue, billing and a new shell1176 let merge = &document["paths"]["/repos/{owner}/{name}/pulls/{number}/merge"]["post"];
API and MCP server in Rust; a public index at the API root1177 let body = &merge["requestBody"]["content"]["application/json"]["schema"]["properties"];
1178 assert!(body.get("keep_issue_open").is_some());
1179 assert!(body.get("repo").is_none() && body.get("number").is_none());
Agents as a team: lifecycle, merge queue, billing and a new shell1180 let list = &document["paths"]["/repos"]["get"];
API and MCP server in Rust; a public index at the API root1181 assert_eq!(list["parameters"][0]["name"], "q");
1182 assert!(list.get("requestBody").is_none());
1183 }
1184
1185 #[test]
Merge branch 'worktree-agent-ab2e39e11a6493412'1186 fn every_operation_is_in_one_section() {
1187 for op in Op::ALL {
1188 let sections = SECTIONS
1189 .iter()
1190 .filter(|(_, _, ops)| ops.contains(&op))
1191 .count();
1192 assert_eq!(sections, 1, "{}", op.name());
1193 }
1194 }
1195
1196 #[test]
API and MCP server in Rust; a public index at the API root1197 fn titles_read_as_sentences() {
Merge branch 'worktree-agent-ab2e39e11a6493412'1198 assert_eq!(title(Op::CreateIssue), "Create an issue");
API and MCP server in Rust; a public index at the API root1199 assert_eq!(title(Op::Whoami), "Get the current user");
1200 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1201
1202 #[test]
1203 fn every_operation_has_an_example_response() {
1204 let examples = examples();
1205 assert!(!examples.is_empty(), "reference.json does not parse");
1206 let document = document();
1207 let mut known = Vec::new();
1208 for (path, methods) in document["paths"].as_object().unwrap() {
1209 for (method, operation) in methods.as_object().unwrap() {
1210 known.push(operation["operationId"].as_str().unwrap().to_owned());
1211 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1212 assert!(!example.is_null(), "{method} {path} has no example response");
1213 }
1214 }
1215 for id in examples.keys() {
1216 assert!(known.contains(id), "reference.json names {id}, which is not an operation");
1217 }
1218 }
1219
1220 #[test]
1221 fn example_requests_send_only_what_the_body_takes() {
1222 let document = document();
1223 for (path, methods) in document["paths"].as_object().unwrap() {
1224 for (method, operation) in methods.as_object().unwrap() {
1225 let content = &operation["requestBody"]["content"]["application/json"];
1226 let Some(example) = content["example"].as_object() else { continue };
1227 let properties = &content["schema"]["properties"];
1228 for key in example.keys() {
1229 assert!(!properties[key].is_null(), "{method} {path}: {key} is not in the body");
1230 }
1231 }
1232 }
1233 }
1234
1235 /// The docs site's copy of the document. Run with `G1T_WRITE_OPENAPI=1`
1236 /// to rewrite it after changing an operation.
1237 #[test]
1238 fn the_docs_copy_is_current() {
1239 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../docs/src/data/openapi.json");
1240 let current = serde_json::to_string_pretty(&document()).unwrap() + "\n";
1241 if std::env::var_os("G1T_WRITE_OPENAPI").is_some() {
1242 std::fs::write(path, &current).unwrap();
1243 return;
1244 }
1245 let copy = std::fs::read_to_string(path).unwrap_or_default().replace("\r\n", "\n");
1246 assert!(
1247 copy == current,
1248 "apps/docs/src/data/openapi.json is out of date: run G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi"
1249 );
1250 }
API reference: no example reads as a real secret1251
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1252 /// The reference shows responses as they are sent: `snake_case`.
1253 #[test]
1254 fn example_responses_are_snake_case() {
1255 let document = document();
1256 for (path, methods) in document["paths"].as_object().unwrap() {
1257 for (method, operation) in methods.as_object().unwrap() {
1258 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1259 let leaked = g1t_kit::wire::camel_case_keys(example);
1260 assert!(leaked.is_empty(), "{method} {path} shows {leaked:?}");
1261 }
1262 }
1263 }
1264
API reference: no example reads as a real secret1265 /// Examples never hold anything that reads as a real credential, which
1266 /// secret scanners rightly flag in a public repository: they end in `…`
1267 /// after the prefix, as `whsec_…` and `g1t_…` do.
1268 #[test]
1269 fn examples_hold_no_real_looking_secrets() {
Fast pages, required checks on the branch, self-hosted runners, honest incidents1270 let prefixes = ["whsec_", "g1t_", "g1tr_", "g1trt_", "sk_live_", "sk_test_", "ghp_", "github_pat_", "xoxb-", "AKIA"];
API reference: no example reads as a real secret1271 for (line, text) in REFERENCE.lines().enumerate() {
1272 for prefix in prefixes {
1273 let mut rest = text;
1274 while let Some(at) = rest.find(prefix) {
1275 let after = &rest[at + prefix.len()..];
1276 let run = after.chars().take_while(|c| c.is_ascii_alphanumeric()).count();
1277 assert!(
1278 run < 12,
1279 "reference.json line {}: `{prefix}` followed by {run} characters reads as a real secret; write `{prefix}…`",
1280 line + 1
1281 );
1282 rest = after;
1283 }
1284 }
1285 }
1286 }
API and MCP server in Rust; a public index at the API root1287}

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