Skip to content
1,221 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 'main' into worktree-agent-a69aeabc4b0deeb9712use crate::deployments::DeploymentsOp;
API and MCP server in Rust; a public index at the API root13use crate::operations::Op;
Merge checks: statuses and check runs on every commit14use crate::checks::ChecksOp;
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge15use crate::rules::RulesOp;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar16use crate::security::SecurityOp;
API and MCP server in Rust; a public index at the API root17use crate::rest::{ROUTES, Route};
18
Merge branch 'worktree-agent-ab2e39e11a6493412'19/// The sections of the API reference: a name, what it covers, and its
20/// operations in the order a reader meets them.
21const SECTIONS: &[(&str, &str, &[Op])] = &[
22 (
23 "Accounts",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look24 "Signing in from a tool, who a token acts as, and your email addresses.",
25 &[Op::Whoami, Op::ListEmails, Op::AddEmail, Op::RemoveEmail, Op::UpdateEmailSettings],
Merge branch 'worktree-agent-ab2e39e11a6493412'26 ),
27 (
API: notifications over REST and MCP, with notifications scopes28 "Notifications",
29 "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.",
30 &[
31 Op::ListNotifications,
32 Op::MarkNotificationsRead,
33 Op::GetNotificationThread,
34 Op::MarkThreadRead,
35 Op::MarkThreadDone,
36 Op::SaveThread,
37 Op::SnoozeThread,
38 Op::GetThreadSubscription,
39 Op::SetThreadSubscription,
40 Op::DeleteThreadSubscription,
41 Op::GetRepoSubscription,
42 Op::SetRepoSubscription,
43 Op::DeleteRepoSubscription,
44 Op::ListWatchedRepos,
45 ],
46 ),
47 (
API: pinned projects over REST and MCP48 "Pinned projects",
49 "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.",
50 &[Op::ListPinnedProjects, Op::PinProject, Op::UnpinProject, Op::ReorderPinnedProjects],
51 ),
52 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9753 "Projects",
54 "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.",
55 &[Op::ListProjects, Op::GetProject, Op::UpdateProject],
56 ),
57 (
Merge branch 'worktree-agent-ab2e39e11a6493412'58 "Workspaces",
59 "A workspace owns repositories and is the first part of their address. People and agents work in workspaces.",
Merge branch 'worktree-agent-ad7c6d88d93adc817'60 &[Op::GetWorkspace, Op::CreateWorkspace, Op::UpdateWorkspace, Op::DeleteWorkspace],
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look61 ),
62 (
Membership as GitHub has it: owners, roles, member privileges, 2FA63 "Members",
64 "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.",
65 &[Op::ListMembers, Op::UpdateMember, Op::RemoveMember, Op::TransferOwnership, Op::LeaveWorkspace],
66 ),
67 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look68 "Invites",
69 "While g1t is invite-only, every new account needs an invite. Your invites, and inviting people into a workspace by email.",
70 &[
71 Op::ListInvites,
72 Op::CreateInvite,
73 Op::RevokeInvite,
74 Op::ListWorkspaceInvites,
75 Op::InviteMember,
76 Op::RevokeWorkspaceInvite,
77 ],
Merge branch 'worktree-agent-ab2e39e11a6493412'78 ),
79 (
Usage, Billing settings and prepaid AI credit; fixes from the UX audit80 "Billing",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens81 "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 audit82 &[
83 Op::GetUsage,
84 Op::GetBudget,
85 Op::SetBudget,
86 Op::GetAiCredit,
87 Op::BuyAiCredit,
88 Op::ListInvoices,
89 Op::GetBillingDetails,
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens90 Op::ListGatewayRequests,
Usage, Billing settings and prepaid AI credit; fixes from the UX audit91 ],
92 ),
93 (
Merge branch 'worktree-agent-ab2e39e11a6493412'94 "Repositories",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look95 "A repository, how it handles pull requests, and its timeline: renaming, archiving, moving and deleting it.",
Merge branch 'worktree-agent-ab2e39e11a6493412'96 &[
97 Op::ListRepos,
98 Op::CreateRepo,
99 Op::GetRepo,
100 Op::UpdateRepo,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look101 Op::RenameRepo,
102 Op::RenameBranch,
103 Op::SetRepoVisibility,
104 Op::ArchiveRepo,
105 Op::UnarchiveRepo,
106 Op::TransferRepo,
107 Op::DeleteRepo,
108 Op::ListDeletedRepos,
109 Op::RestoreRepo,
110 Op::PurgeRepo,
Merge branch 'worktree-agent-ab2e39e11a6493412'111 Op::GetRepoSettings,
112 Op::UpdateRepoSettings,
Fast pages, required checks on the branch, self-hosted runners, honest incidents113 Op::ListCheckNames,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar114 Op::GetCodeownersErrors,
Merge branch 'worktree-agent-ab2e39e11a6493412'115 Op::ListEvents,
116 ],
117 ),
118 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97119 "Repository insights",
120 "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.",
121 &[Op::About(AboutOp::GetLanguages), Op::About(AboutOp::ListContributors), Op::About(AboutOp::GetLicense)],
122 ),
123 (
124 "Stars",
125 "Starring a repository, to keep it and to say you like it: who starred one, and what you starred.",
126 &[
127 Op::About(AboutOp::ListStargazers),
128 Op::About(AboutOp::ListStarred),
129 Op::About(AboutOp::CheckStarred),
130 Op::About(AboutOp::Star),
131 Op::About(AboutOp::Unstar),
132 ],
133 ),
134 (
135 "Releases",
136 "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.",
137 &[
138 Op::About(AboutOp::ListReleases),
139 Op::About(AboutOp::CreateRelease),
140 Op::About(AboutOp::GetLatestRelease),
141 Op::About(AboutOp::GetReleaseByTag),
142 Op::About(AboutOp::GetRelease),
143 Op::About(AboutOp::UpdateRelease),
144 Op::About(AboutOp::DeleteRelease),
145 ],
146 ),
147 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look148 "Access",
149 "Who can do what in a repository: repository roles, people given a role on one repository (outside collaborators when they are not members), invitations, and a workspace's base permission.",
150 &[
151 Op::ListCollaborators,
152 Op::AddCollaborator,
153 Op::UpdateCollaborator,
154 Op::RemoveCollaborator,
155 Op::GetCollaboratorPermission,
156 Op::ListRepoInvitations,
157 Op::RevokeRepoInvitation,
158 Op::ListMyRepoInvitations,
159 Op::AcceptRepoInvitation,
160 Op::DeclineRepoInvitation,
161 Op::SetBasePermission,
162 Op::ListOutsideCollaborators,
163 ],
164 ),
165 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar166 "Teams",
167 "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.",
168 &[
169 Op::ListTeams,
170 Op::CreateTeam,
171 Op::GetTeam,
172 Op::UpdateTeam,
173 Op::DeleteTeam,
174 Op::ListTeamMembers,
175 Op::SetTeamMember,
176 Op::RemoveTeamMember,
177 Op::ListChildTeams,
178 Op::ListTeamRepos,
179 Op::SetTeamRepo,
180 Op::RemoveTeamRepo,
181 Op::SetTeamReviewAssignment,
182 Op::ListUserTeams,
183 ],
184 ),
185 (
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily186 "Security",
187 "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.",
188 &[Op::ListSecurityAlerts, Op::DismissSecurityAlert, Op::ReopenSecurityAlert],
189 ),
190 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar191 "Secret scanning",
192 "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.",
193 &[
194 Op::Security(SecurityOp::ListSecretAlerts),
195 Op::Security(SecurityOp::GetSecretAlert),
196 Op::Security(SecurityOp::UpdateSecretAlert),
197 Op::Security(SecurityOp::ListSecretLocations),
198 Op::Security(SecurityOp::BypassPushProtection),
199 Op::Security(SecurityOp::CheckSecretValidity),
200 Op::Security(SecurityOp::ListBypassRequests),
201 Op::Security(SecurityOp::ReviewBypassRequest),
202 Op::Security(SecurityOp::ListCustomPatterns),
203 Op::Security(SecurityOp::CreateCustomPattern),
204 Op::Security(SecurityOp::UpdateCustomPattern),
205 Op::Security(SecurityOp::DeleteCustomPattern),
206 Op::Security(SecurityOp::DryRunCustomPattern),
207 ],
208 ),
209 (
210 "Code scanning",
211 "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.",
212 &[
213 Op::Security(SecurityOp::ListCodeAlerts),
214 Op::Security(SecurityOp::GetCodeAlert),
215 Op::Security(SecurityOp::UpdateCodeAlert),
216 Op::Security(SecurityOp::ListAnalyses),
217 Op::Security(SecurityOp::UploadSarif),
218 Op::Security(SecurityOp::GetSarifUpload),
219 Op::Security(SecurityOp::FixAlert),
220 ],
221 ),
222 (
223 "Supply chain",
224 "What a repository depends on: vulnerability alerts, the dependency graph, an SPDX SBOM of it, and comparing two commits' dependencies as dependency review does.",
225 &[
226 Op::Security(SecurityOp::ListVulnerabilityAlerts),
227 Op::Security(SecurityOp::GetVulnerabilityAlert),
228 Op::Security(SecurityOp::UpdateVulnerabilityAlert),
229 Op::Security(SecurityOp::GetDependencyGraph),
230 Op::Security(SecurityOp::GetSbom),
231 Op::Security(SecurityOp::CompareDependencies),
232 ],
233 ),
234 (
235 "Security settings",
236 "When pull request checks fail, dependency review's policy, delegated bypass and validity checks, and a workspace's security overview.",
237 &[
238 Op::Security(SecurityOp::GetSettings),
239 Op::Security(SecurityOp::UpdateSettings),
240 Op::Security(SecurityOp::GetWorkspaceSettings),
241 Op::Security(SecurityOp::UpdateWorkspaceSettings),
242 Op::Security(SecurityOp::GetOverview),
243 ],
244 ),
245 (
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge246 "Rules",
247 "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.",
248 &[
249 Op::Rules(RulesOp::ListRepoRulesets),
250 Op::Rules(RulesOp::CreateRepoRuleset),
251 Op::Rules(RulesOp::GetRepoRuleset),
252 Op::Rules(RulesOp::UpdateRepoRuleset),
253 Op::Rules(RulesOp::DeleteRepoRuleset),
254 Op::Rules(RulesOp::GetBranchRules),
255 Op::Rules(RulesOp::ListRuleEvaluations),
256 Op::Rules(RulesOp::ListWorkspaceRulesets),
257 Op::Rules(RulesOp::CreateWorkspaceRuleset),
258 Op::Rules(RulesOp::GetWorkspaceRuleset),
259 Op::Rules(RulesOp::UpdateWorkspaceRuleset),
260 Op::Rules(RulesOp::DeleteWorkspaceRuleset),
261 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
262 ],
263 ),
264 (
Merge checks: statuses and check runs on every commit265 "Checks",
266 "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.",
267 &[
268 Op::Checks(ChecksOp::CreateCommitStatus),
269 Op::Checks(ChecksOp::ListCommitStatuses),
270 Op::Checks(ChecksOp::GetCombinedStatus),
271 Op::Checks(ChecksOp::CreateCheckRun),
272 Op::Checks(ChecksOp::UpdateCheckRun),
273 Op::Checks(ChecksOp::GetCheckRun),
274 Op::Checks(ChecksOp::ListCheckRunAnnotations),
275 Op::Checks(ChecksOp::RerequestCheckRun),
276 Op::Checks(ChecksOp::ListCheckRunsForRef),
277 Op::Checks(ChecksOp::ListCheckSuitesForRef),
278 Op::Checks(ChecksOp::GetCheckSuite),
279 Op::Checks(ChecksOp::RerequestCheckSuite),
280 ],
281 ),
282 (
Merge branch 'worktree-agent-ab2e39e11a6493412'283 "Issues",
284 "What should change in a repository, with labels and comments. Issues and pull requests share one sequence of numbers.",
285 &[
286 Op::ListIssues,
287 Op::CreateIssue,
288 Op::GetIssue,
289 Op::UpdateIssue,
290 Op::CloseIssue,
291 Op::ReopenIssue,
292 Op::AssignIssue,
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step293 Op::Delegate,
Merge branch 'worktree-agent-ab2e39e11a6493412'294 Op::AddComment,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar295 Op::ListIssueLabels,
296 Op::AddIssueLabels,
297 Op::SetIssueLabels,
298 Op::RemoveIssueLabels,
299 ],
300 ),
301 (
302 "Labels and milestones",
303 "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.",
304 &[
Merge branch 'worktree-agent-ab2e39e11a6493412'305 Op::ListLabels,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar306 Op::CreateLabel,
307 Op::UpdateLabel,
308 Op::DeleteLabel,
309 Op::AddDefaultLabels,
310 Op::ListMilestones,
311 Op::CreateMilestone,
312 Op::GetMilestone,
313 Op::UpdateMilestone,
314 Op::DeleteMilestone,
Merge branch 'worktree-agent-ab2e39e11a6493412'315 ],
316 ),
317 (
318 "Plans",
319 "An outcome turned into the issues that would get there, with the order they must merge in.",
320 &[Op::PlanWork, Op::GetPlan, Op::ApplyPlan],
321 ),
322 (
323 "Pull requests",
324 "A proposed change in its own fork or on a branch. Several can be made for one issue; the one merged resolves it.",
325 &[
326 Op::ListPullRequests,
327 Op::CreatePullRequest,
328 Op::GetPullRequest,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar329 Op::UpdatePullRequest,
Merge branch 'worktree-agent-ab2e39e11a6493412'330 Op::GetPullRequestChanges,
331 Op::MarkPullRequestReady,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar332 Op::RequestReviewers,
333 Op::RemoveRequestedReviewers,
Merge branch 'worktree-agent-ab2e39e11a6493412'334 Op::ReviewPullRequest,
335 Op::MergePullRequest,
336 Op::ClosePullRequest,
337 Op::GetMergeQueue,
338 Op::MessageAgent,
339 Op::AnswerMessage,
340 Op::TakeMessages,
341 ],
342 ),
343 (
344 "Sessions",
345 "The record of how a pull request was made: prompts, reasoning and the tools that ran.",
346 &[Op::ReadSession, Op::RecordSession],
347 ),
348 (
Agents and memory, checks and conflicts, profiles, slug renames, custom domains349 "Memory",
350 "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.",
351 &[Op::Remember, Op::Recall],
352 ),
353 (
Search across all of g1t, Explore, and a command palette354 "Search",
355 "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.",
356 &[Op::Search],
357 ),
358 (
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API359 "Context",
360 "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.",
361 &[Op::SearchContext, Op::GetEntity],
362 ),
363 (
Merge branch 'worktree-agent-ab2e39e11a6493412'364 "Actions",
365 "GitHub Actions workflows in .g1t/workflows, their runs, and their jobs' logs.",
366 &[
367 Op::ListWorkflows,
368 Op::ListWorkflowRuns,
369 Op::GetWorkflowRun,
370 Op::GetJobLogs,
371 Op::DispatchWorkflow,
372 Op::CancelWorkflowRun,
373 Op::RerunWorkflowRun,
374 Op::UpdateWorkflow,
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2375 Op::Artifacts(ArtifactsOp::ListArtifacts),
376 Op::Artifacts(ArtifactsOp::ListRunArtifacts),
377 Op::Artifacts(ArtifactsOp::GetArtifact),
378 Op::Artifacts(ArtifactsOp::DownloadArtifact),
379 Op::Artifacts(ArtifactsOp::DeleteArtifact),
380 Op::Artifacts(ArtifactsOp::GetArtifactRetention),
381 Op::Artifacts(ArtifactsOp::SetArtifactRetention),
Merge branch 'worktree-agent-ab2e39e11a6493412'382 ],
383 ),
384 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97385 "Deployments",
386 "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.",
387 &[
388 Op::Deployments(DeploymentsOp::ListDeployments),
389 Op::Deployments(DeploymentsOp::CreateDeployment),
390 Op::Deployments(DeploymentsOp::GetDeployment),
391 Op::Deployments(DeploymentsOp::ListDeploymentStatuses),
392 Op::Deployments(DeploymentsOp::CreateDeploymentStatus),
393 Op::Deployments(DeploymentsOp::ListEnvironments),
394 Op::Deployments(DeploymentsOp::GetEnvironment),
395 ],
396 ),
397 (
Merge branch 'worktree-agent-ab2e39e11a6493412'398 "Secrets and variables",
399 "Values that workflows and deployments read, per repository or for a whole workspace, with a row per environment.",
400 &[
401 Op::ListActionsSecrets,
402 Op::SetActionsSecret,
403 Op::DeleteActionsSecret,
404 Op::ListActionsVariables,
405 Op::SetActionsVariable,
406 Op::DeleteActionsVariable,
407 ],
408 ),
409 (
Fast pages, required checks on the branch, self-hosted runners, honest incidents410 "Runners",
411 "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.",
412 &[
413 Op::ListRunners,
414 Op::CreateRunnerRegistrationToken,
415 Op::RemoveRunner,
416 Op::ListRunnerGroups,
417 Op::CreateRunnerGroup,
418 Op::UpdateRunnerGroup,
419 Op::DeleteRunnerGroup,
420 Op::GetRunnerSettings,
421 Op::UpdateRunnerSettings,
422 ],
423 ),
424 (
Merge branch 'worktree-agent-ab2e39e11a6493412'425 "Webhooks",
426 "Signed HTTPS requests sent to your own address as things happen, for a repository or a whole workspace.",
427 &[
428 Op::ListWebhooks,
429 Op::CreateWebhook,
430 Op::UpdateWebhook,
431 Op::DeleteWebhook,
432 Op::PingWebhook,
433 Op::ListWebhookDeliveries,
434 Op::RedeliverWebhook,
435 ],
436 ),
437 (
438 "Integrations",
439 "A workspace's connections to outside systems: model providers, alert sources and issue trackers.",
440 &[
441 Op::ListIntegrations,
442 Op::ConnectIntegration,
AI Gateway: OpenAI's format, open models, and your own providers443 Op::UpdateIntegration,
Merge branch 'worktree-agent-ab2e39e11a6493412'444 Op::DisconnectIntegration,
445 Op::TestIntegration,
446 Op::GetModelRoutes,
447 Op::SetModelRoutes,
448 Op::GetContext,
449 Op::ImportIssue,
450 ],
451 ),
452];
453
API and MCP server in Rust; a public index at the API root454/// The section of the API reference an operation is listed under.
455fn tag(op: Op) -> &'static str {
Merge branch 'worktree-agent-ab2e39e11a6493412'456 SECTIONS
API and MCP server in Rust; a public index at the API root457 .iter()
Merge branch 'worktree-agent-ab2e39e11a6493412'458 .find(|(_, _, ops)| ops.contains(&op))
459 .map_or("Repositories", |(name, _, _)| name)
460}
461
462/// What an operation's page is called, as a short sentence.
463fn title(op: Op) -> &'static str {
464 match op {
465 Op::Whoami => "Get the current user",
Merge branch 'worktree-agent-ad7c6d88d93adc817'466 Op::GetWorkspace => "Get a workspace",
Merge branch 'worktree-agent-ab2e39e11a6493412'467 Op::CreateWorkspace => "Create a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look468 Op::DeleteWorkspace => "Delete a workspace",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily469 Op::UpdateWorkspace => "Update a workspace",
Membership as GitHub has it: owners, roles, member privileges, 2FA470 Op::ListMembers => "List a workspace's members",
471 Op::UpdateMember => "Change a member's role",
472 Op::RemoveMember => "Remove a member",
473 Op::TransferOwnership => "Transfer a workspace's ownership",
474 Op::LeaveWorkspace => "Leave a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look475 Op::ListEmails => "List your email addresses",
476 Op::AddEmail => "Add an email address",
477 Op::RemoveEmail => "Remove an email address",
478 Op::UpdateEmailSettings => "Change your email settings",
479 Op::ListInvites => "List your invites",
480 Op::CreateInvite => "Create an invite",
481 Op::RevokeInvite => "Revoke an invite",
482 Op::ListWorkspaceInvites => "List a workspace's invites",
483 Op::InviteMember => "Invite someone to a workspace",
484 Op::RevokeWorkspaceInvite => "Revoke a workspace's invite",
485 Op::TransferRepo => "Transfer a repository",
486 Op::RenameRepo => "Rename a repository",
487 Op::RenameBranch => "Rename a branch",
488 Op::ArchiveRepo => "Archive a repository",
489 Op::UnarchiveRepo => "Unarchive a repository",
490 Op::SetRepoVisibility => "Change a repository's visibility",
491 Op::DeleteRepo => "Delete a repository",
492 Op::ListDeletedRepos => "List recently deleted repositories",
493 Op::RestoreRepo => "Restore a deleted repository",
494 Op::PurgeRepo => "Purge a deleted repository",
Merge branch 'worktree-agent-ab2e39e11a6493412'495 Op::ListRepos => "List repositories",
496 Op::GetRepo => "Get a repository",
497 Op::CreateRepo => "Create a repository",
498 Op::UpdateRepo => "Update a repository",
499 Op::GetRepoSettings => "Get repository settings",
500 Op::UpdateRepoSettings => "Update repository settings",
Fast pages, required checks on the branch, self-hosted runners, honest incidents501 Op::ListCheckNames => "List check names",
Merge branch 'worktree-agent-ab2e39e11a6493412'502 Op::GetMergeQueue => "Get the merge queue",
503 Op::MessageAgent => "Message an agent",
504 Op::AnswerMessage => "Answer a message",
505 Op::TakeMessages => "Take new messages",
Agents and memory, checks and conflicts, profiles, slug renames, custom domains506 Op::Remember => "Remember something",
507 Op::Recall => "Recall memory",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API508 Op::SearchContext => "Search the context hub",
509 Op::GetEntity => "Get a catalog entry",
Search across all of g1t, Explore, and a command palette510 Op::Search => "Search g1t",
Merge branch 'worktree-agent-ab2e39e11a6493412'511 Op::ListIssues => "List issues",
512 Op::GetIssue => "Get an issue",
513 Op::CreateIssue => "Create an issue",
514 Op::UpdateIssue => "Update an issue",
515 Op::CloseIssue => "Close an issue",
516 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-agent517 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 step518 Op::Delegate => "Put an agent on it",
Merge branch 'worktree-agent-ab2e39e11a6493412'519 Op::PlanWork => "Plan work",
520 Op::GetPlan => "Get a plan",
521 Op::ApplyPlan => "Apply a plan",
522 Op::ListLabels => "List labels",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar523 Op::CreateLabel => "Create a label",
524 Op::UpdateLabel => "Update a label",
525 Op::DeleteLabel => "Delete a label",
526 Op::AddDefaultLabels => "Add the default labels",
527 Op::ListIssueLabels => "List an issue's labels",
528 Op::AddIssueLabels => "Add labels to an issue",
529 Op::SetIssueLabels => "Set an issue's labels",
530 Op::RemoveIssueLabels => "Remove labels from an issue",
531 Op::ListMilestones => "List milestones",
532 Op::GetMilestone => "Get a milestone",
533 Op::CreateMilestone => "Create a milestone",
534 Op::UpdateMilestone => "Update a milestone",
535 Op::DeleteMilestone => "Delete a milestone",
536 Op::UpdatePullRequest => "Update a pull request",
Merge branch 'worktree-agent-ab2e39e11a6493412'537 Op::AddComment => "Add a comment",
538 Op::ReviewPullRequest => "Review a pull request",
539 Op::ListPullRequests => "List pull requests",
540 Op::GetPullRequest => "Get a pull request",
541 Op::CreatePullRequest => "Create a pull request",
542 Op::RecordSession => "Record session entries",
543 Op::ReadSession => "Read a session",
544 Op::MarkPullRequestReady => "Mark a pull request ready",
545 Op::ClosePullRequest => "Close a pull request",
546 Op::GetPullRequestChanges => "Get a pull request's changes",
547 Op::MergePullRequest => "Merge a pull request",
548 Op::ListEvents => "List repository events",
549 Op::ListIntegrations => "List integrations",
550 Op::ConnectIntegration => "Connect an integration",
AI Gateway: OpenAI's format, open models, and your own providers551 Op::UpdateIntegration => "Update an integration",
Merge branch 'worktree-agent-ab2e39e11a6493412'552 Op::DisconnectIntegration => "Disconnect an integration",
553 Op::TestIntegration => "Test an integration",
554 Op::GetContext => "Look up a ticket",
555 Op::ImportIssue => "Import an issue",
556 Op::GetModelRoutes => "Get model routes",
557 Op::SetModelRoutes => "Set model routes",
558 Op::ListWebhooks => "List webhooks",
559 Op::CreateWebhook => "Create a webhook",
560 Op::UpdateWebhook => "Update a webhook",
561 Op::DeleteWebhook => "Delete a webhook",
562 Op::PingWebhook => "Ping a webhook",
563 Op::ListWebhookDeliveries => "List webhook deliveries",
564 Op::RedeliverWebhook => "Redeliver a webhook delivery",
565 Op::ListWorkflows => "List workflows",
566 Op::ListWorkflowRuns => "List workflow runs",
567 Op::GetWorkflowRun => "Get a workflow run",
568 Op::GetJobLogs => "Get a job's log",
569 Op::DispatchWorkflow => "Run a workflow",
570 Op::CancelWorkflowRun => "Cancel a workflow run",
571 Op::RerunWorkflowRun => "Re-run a workflow run",
572 Op::UpdateWorkflow => "Turn a workflow on or off",
573 Op::ListActionsSecrets => "List secrets",
574 Op::SetActionsSecret => "Set a secret",
575 Op::DeleteActionsSecret => "Delete a secret",
576 Op::ListActionsVariables => "List variables",
577 Op::SetActionsVariable => "Set a variable",
578 Op::DeleteActionsVariable => "Delete a variable",
Fast pages, required checks on the branch, self-hosted runners, honest incidents579 Op::ListRunners => "List self-hosted runners",
580 Op::ListRunnerGroups => "List runner groups",
581 Op::GetRunnerSettings => "Get runner settings",
582 Op::CreateRunnerRegistrationToken => "Create a runner registration token",
583 Op::RemoveRunner => "Remove a self-hosted runner",
584 Op::CreateRunnerGroup => "Create a runner group",
585 Op::UpdateRunnerGroup => "Change a runner group",
586 Op::DeleteRunnerGroup => "Delete a runner group",
587 Op::UpdateRunnerSettings => "Change runner settings",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look588 Op::ListCollaborators => "List who has access",
589 Op::AddCollaborator => "Add a collaborator",
590 Op::UpdateCollaborator => "Change a collaborator's role",
591 Op::RemoveCollaborator => "Remove a collaborator",
592 Op::GetCollaboratorPermission => "Get someone's permission",
593 Op::ListRepoInvitations => "List a repository's invitations",
594 Op::RevokeRepoInvitation => "Revoke a repository invitation",
595 Op::ListMyRepoInvitations => "List your repository invitations",
596 Op::AcceptRepoInvitation => "Accept a repository invitation",
597 Op::DeclineRepoInvitation => "Decline a repository invitation",
598 Op::SetBasePermission => "Set the base permission",
599 Op::ListOutsideCollaborators => "List outside collaborators",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily600 Op::ListSecurityAlerts => "List security alerts",
601 Op::DismissSecurityAlert => "Dismiss a security alert",
602 Op::ReopenSecurityAlert => "Reopen a security alert",
API: notifications over REST and MCP, with notifications scopes603 Op::ListNotifications => "List notifications",
604 Op::MarkNotificationsRead => "Mark notifications read",
605 Op::GetNotificationThread => "Get a thread",
606 Op::MarkThreadRead => "Mark a thread read",
607 Op::MarkThreadDone => "Mark a thread done",
608 Op::SaveThread => "Save a thread",
609 Op::SnoozeThread => "Snooze a thread",
610 Op::GetThreadSubscription => "Get a thread subscription",
611 Op::SetThreadSubscription => "Set a thread subscription",
612 Op::DeleteThreadSubscription => "Unsubscribe from a thread",
613 Op::GetRepoSubscription => "Get how you watch a repository",
614 Op::SetRepoSubscription => "Watch a repository",
615 Op::DeleteRepoSubscription => "Stop watching a repository",
616 Op::ListWatchedRepos => "List repositories you watch",
API: pinned projects over REST and MCP617 Op::ListPinnedProjects => "List your pinned projects",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit618 Op::GetUsage => "Get a workspace's usage",
619 Op::GetBudget => "Get a workspace's budget",
620 Op::SetBudget => "Change a workspace's budget",
621 Op::GetAiCredit => "Get a workspace's AI credit",
622 Op::BuyAiCredit => "Buy AI credit",
623 Op::ListInvoices => "List a workspace's invoices",
624 Op::GetBillingDetails => "Get a workspace's billing details",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens625 Op::ListGatewayRequests => "List a workspace's AI Gateway requests",
API: pinned projects over REST and MCP626 Op::PinProject => "Pin a project",
627 Op::UnpinProject => "Unpin a project",
628 Op::ReorderPinnedProjects => "Reorder your pinned projects",
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97629 Op::ListProjects => "List a workspace's projects",
630 Op::GetProject => "Get a project",
631 Op::UpdateProject => "Update a project",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar632 Op::ListTeams => "List teams",
633 Op::GetTeam => "Get a team",
634 Op::CreateTeam => "Create a team",
635 Op::UpdateTeam => "Update a team",
636 Op::DeleteTeam => "Delete a team",
637 Op::ListTeamMembers => "List a team's members",
638 Op::SetTeamMember => "Add or change a team member",
639 Op::RemoveTeamMember => "Remove a team member",
640 Op::ListChildTeams => "List child teams",
641 Op::ListTeamRepos => "List a team's repositories",
642 Op::SetTeamRepo => "Give a team a role on a repository",
643 Op::RemoveTeamRepo => "Remove a team from a repository",
644 Op::SetTeamReviewAssignment => "Set a team's review assignment",
645 Op::ListUserTeams => "List someone's teams",
646 Op::RequestReviewers => "Request reviewers",
647 Op::RemoveRequestedReviewers => "Remove requested reviewers",
648 Op::GetCodeownersErrors => "List CODEOWNERS errors",
649 Op::Security(op) => op.title(),
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge650 Op::Rules(op) => op.title(),
Merge checks: statuses and check runs on every commit651 Op::Checks(op) => op.title(),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97652 Op::About(op) => op.title(),
653 Op::Deployments(op) => op.title(),
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2654 Op::Artifacts(op) => op.title(),
API and MCP server in Rust; a public index at the API root655 }
656}
657
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look658/// Why an operation can be refused with `402 payment_required`, if it
659/// can: the ones that start an agent, when the workspace has no credit,
660/// and the ones that make a repository private in a workspace, when a free
661/// workspace's private storage has no room for it.
662fn may_need_payment(op: Op) -> Option<&'static str> {
663 match op {
664 Op::AssignIssue | Op::PlanWork | Op::ApplyPlan => Some("The workspace has no agent credit."),
665 Op::UpdateRepo | Op::SetRepoVisibility | Op::TransferRepo => Some(
666 "A free workspace's private storage has no room for this private repository.",
667 ),
668 _ => None,
669 }
Merge branch 'worktree-agent-ab2e39e11a6493412'670}
671
672/// What the reference says beyond each operation's own description, keyed
673/// by operation id, written by hand from what the services return: `notes`
674/// (Markdown, added to the description) and example `params` (path),
675/// `query`, `request` (body) and `response`.
676const REFERENCE: &str = include_str!("reference.json");
677
678fn examples() -> Map<String, Value> {
679 match serde_json::from_str(REFERENCE) {
680 Ok(Value::Object(examples)) => examples,
681 _ => Map::new(),
API and MCP server in Rust; a public index at the API root682 }
683}
684
Agents as a team: lifecycle, merge queue, billing and a new shell685/// `/repos/:owner/:name` as OpenAPI writes it: `/repos/{owner}/{name}`.
API and MCP server in Rust; a public index at the API root686fn openapi_path(route: &Route) -> String {
687 route
688 .path
689 .split('/')
690 .map(|segment| match segment.strip_prefix(':') {
691 Some(name) => format!("{{{name}}}"),
692 None => segment.to_owned(),
693 })
694 .collect::<Vec<_>>()
695 .join("/")
696}
697
698fn error_response(description: &str) -> Value {
699 json!({
700 "description": description,
701 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } },
702 })
703}
704
Merge branch 'worktree-agent-ab2e39e11a6493412'705/// A parameter in the path or the query, described by the operation's
706/// input schema where it has the same name.
707fn parameter(name: &str, place: &str, required: bool, schema: Option<&Value>) -> Value {
708 let mut schema = schema.cloned().unwrap_or_else(|| json!({ "type": "string" }));
709 let description = match name {
710 "owner" => Some(Value::from("The workspace that owns the repository.")),
711 "name" => Some(Value::from("The repository's name.")),
712 _ => schema.as_object_mut().and_then(|schema| schema.remove("description")),
713 };
714 let mut parameter = json!({
715 "name": name,
716 "in": place,
717 "required": required,
718 "schema": schema,
719 });
720 if let Some(description) = description {
721 parameter["description"] = description;
722 }
723 parameter
724}
725
726/// The operation id of a route. An operation reached at a workspace's
727/// address as well as a repository's is documented once for each, with its
728/// own id; GitHub's alternative addresses for one operation keep GitHub's
729/// names.
730fn operation_id(route: &Route) -> String {
731 let op = route.op;
732 let base = match (route.method, route.path.rsplit('/').next().unwrap_or_default()) {
733 ("PUT", "enable") => "enable_workflow".to_owned(),
734 ("PUT", "disable") => "disable_workflow".to_owned(),
735 ("POST", "rerun-failed-jobs") => "rerun_failed_jobs".to_owned(),
736 ("PATCH", ":setting") => "update_actions_variable".to_owned(),
737 ("GET", "runs") if route.path.contains("/workflows/:workflow/") => "list_runs_of_workflow".to_owned(),
API: notifications over REST and MCP, with notifications scopes738 // One repository's notifications, and an issue's subscription by
739 // its number rather than a thread's id.
740 (_, "notifications") if route.path.starts_with("/repos/") => match op {
741 Op::ListNotifications => "list_repo_notifications".to_owned(),
742 _ => "mark_repo_notifications_read".to_owned(),
743 },
744 (method, "subscription") if route.path.contains("/issues/:number/") => match method {
745 "GET" => "get_issue_subscription".to_owned(),
746 "PUT" => "set_issue_subscription".to_owned(),
747 _ => "delete_issue_subscription".to_owned(),
748 },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar749 // One label off an issue, by its name in the path.
750 ("DELETE", ":label") if route.path.contains("/issues/:number/") => "remove_issue_label".to_owned(),
API: notifications over REST and MCP, with notifications scopes751 ("DELETE", "saved") => "unsave_thread".to_owned(),
752 ("DELETE", "snooze") => "unsnooze_thread".to_owned(),
Merge branch 'worktree-agent-ab2e39e11a6493412'753 _ => op.name().to_owned(),
754 };
755 if route.path.starts_with("/workspaces/") && ROUTES.iter().any(|other| other.op == op && other.path.starts_with("/repos/")) {
756 format!("{base}_for_workspace")
757 } else {
758 base
759 }
760}
761
762/// The summary of a route: its operation's title, or for one of GitHub's
763/// alternative addresses, what that address does.
764fn summary(route: &Route, id: &str) -> String {
765 let base = match id.trim_end_matches("_for_workspace") {
766 "enable_workflow" => "Turn a workflow on",
767 "disable_workflow" => "Turn a workflow off",
768 "rerun_failed_jobs" => "Re-run failed jobs",
769 "update_actions_variable" => "Update a variable",
770 "list_runs_of_workflow" => "List a workflow's runs",
API: notifications over REST and MCP, with notifications scopes771 "list_repo_notifications" => "List a repository's notifications",
772 "mark_repo_notifications_read" => "Mark a repository's notifications read",
773 "get_issue_subscription" => "Get your subscription to an issue",
774 "set_issue_subscription" => "Subscribe to an issue",
775 "delete_issue_subscription" => "Unsubscribe from an issue",
776 "unsave_thread" => "Unsave a thread",
777 "unsnooze_thread" => "Bring a snoozed thread back",
Merge branch 'worktree-agent-ab2e39e11a6493412'778 _ => title(route.op),
779 };
780 if id.ends_with("_for_workspace") {
781 format!("{base} for a workspace")
782 } else {
783 base.to_owned()
784 }
785}
786
API and MCP server in Rust; a public index at the API root787fn operation(route: &Route) -> Value {
788 let op = route.op;
789 let path_params: Vec<&str> = route.params().collect();
Merge checks: statuses and check runs on every commit790 // `owner` and `name` in the path stand for the operation's `repo` input,
791 // so a `name` in the body, such as a check run's, is the body's own.
792 let stands_for_repo =
793 |name: &str| matches!(name, "owner" | "name") && path_params.contains(&"owner") && path_params.contains(&"name");
794 let covered = |name: &str| name == "repo" || (path_params.contains(&name) && !stands_for_repo(name));
Merge branch 'worktree-agent-ab2e39e11a6493412'795 let all_properties = op.properties();
796 let mut properties = all_properties.clone();
API and MCP server in Rust; a public index at the API root797 properties.retain(|name, _| !covered(name));
798 let required: Vec<String> = op
799 .required()
800 .into_iter()
801 .filter(|name| !covered(name))
802 .collect();
803
804 let mut parameters: Vec<Value> = path_params
805 .iter()
Merge checks: statuses and check runs on every commit806 .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 root807 .collect();
808 let mut body = Value::Null;
809 if route.method == "GET" {
810 for (name, key) in route.query {
Merge branch 'worktree-agent-ab2e39e11a6493412'811 parameters.push(parameter(
812 name,
813 "query",
814 required.iter().any(|required| required == key),
815 properties.get(*key),
816 ));
API and MCP server in Rust; a public index at the API root817 }
818 } else if !properties.is_empty() {
819 let mut schema = json!({ "type": "object", "properties": properties });
820 if !required.is_empty() {
821 schema["required"] = json!(required);
822 }
823 body = json!({
824 "required": !required.is_empty(),
825 "content": { "application/json": { "schema": schema } },
826 });
827 }
828
Merge branch 'worktree-agent-ab2e39e11a6493412'829 let id = operation_id(route);
830 let mut responses = Map::new();
831 responses.insert(
832 "200".into(),
833 json!({
834 "description": "Success.",
835 "content": { "application/json": { "schema": {} } },
836 }),
837 );
838 responses.insert(
839 "401".into(),
840 error_response("A token is required, or the one sent is not valid."),
841 );
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look842 if let Some(reason) = may_need_payment(op) {
843 responses.insert("402".into(), error_response(reason));
Merge branch 'worktree-agent-ab2e39e11a6493412'844 }
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step845 responses.insert(
846 "403".into(),
847 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."),
848 );
Search across all of g1t, Explore, and a command palette849 if !matches!(op, Op::Whoami | Op::ListRepos | Op::Search) {
Merge branch 'worktree-agent-ab2e39e11a6493412'850 responses.insert("404".into(), error_response("It does not exist, or you cannot see it."));
851 }
852 if route.method != "GET" {
853 responses.insert(
854 "409".into(),
855 error_response("The request conflicts with the current state."),
856 );
857 }
858 if op != Op::Whoami {
859 responses.insert("422".into(), error_response("The input is not valid."));
860 }
861 // 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 step862 let scope: Vec<&str> = scope_for(op.name()).map(|scope| scope.as_str()).into_iter().collect();
Merge branch 'worktree-agent-ab2e39e11a6493412'863 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 step864 json!([{ "token": scope }])
Webhooks: every event, to your own addresses, signed and retried865 } else {
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step866 json!([{ "token": scope }, {}])
Webhooks: every event, to your own addresses, signed and retried867 };
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step868 let (tool, action) = crate::tools::TOOLS
869 .iter()
870 .find_map(|tool| {
871 tool.actions
872 .iter()
873 .find(|action| action.op == op)
874 .map(|action| (tool.name, action.name))
875 })
876 .unwrap_or_default();
API and MCP server in Rust; a public index at the API root877 let mut described = json!({
Webhooks: every event, to your own addresses, signed and retried878 "operationId": id,
API and MCP server in Rust; a public index at the API root879 "tags": [tag(op)],
Merge branch 'worktree-agent-ab2e39e11a6493412'880 "summary": summary(route, &id),
API and MCP server in Rust; a public index at the API root881 "description": op.description(),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step882 "x-operation": op.name(),
883 "x-mcp-tool": tool,
884 "x-mcp-action": action,
885 "x-scope": scope.first().copied(),
Merge branch 'worktree-agent-ab2e39e11a6493412'886 "security": security,
API and MCP server in Rust; a public index at the API root887 "parameters": parameters,
Merge branch 'worktree-agent-ab2e39e11a6493412'888 "responses": responses,
API and MCP server in Rust; a public index at the API root889 });
890 if !body.is_null() {
891 described["requestBody"] = body;
892 }
893 described
894}
895
896/// Entries for device sign-in, which is not an operation.
897fn onboarding() -> Map<String, Value> {
898 let paths = json!({
Agents as a team: lifecycle, merge queue, billing and a new shell899 "/device/code": {
API and MCP server in Rust; a public index at the API root900 "post": {
901 "operationId": "device_code",
902 "tags": ["Accounts"],
903 "summary": "Start signing in",
Agents as a team: lifecycle, merge queue, billing and a new shell904 "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 root905 "security": [],
906 "requestBody": {
907 "content": { "application/json": { "schema": {
908 "type": "object",
909 "properties": {
910 "client_name": {
911 "type": "string",
912 "description": "What is asking, shown to the person approving. For example, Claude Code.",
913 },
914 },
915 } } },
916 },
917 "responses": { "200": {
918 "description": "The codes for this sign-in.",
919 "content": { "application/json": { "schema": {
920 "type": "object",
921 "properties": {
Agents as a team: lifecycle, merge queue, billing and a new shell922 "device_code": { "type": "string", "description": "Secret. Send it to /device/token." },
API and MCP server in Rust; a public index at the API root923 "user_code": { "type": "string", "description": "Shown to the person, like WDJB-MJHT." },
924 "verification_uri": { "type": "string" },
925 "verification_uri_complete": {
926 "type": "string",
927 "description": "The link to give the person; it carries the code.",
928 },
929 "expires_in": { "type": "integer", "description": "Seconds until the codes expire." },
930 "interval": { "type": "integer", "description": "Seconds to wait between polls." },
931 },
932 } } },
933 } },
934 },
935 },
Agents as a team: lifecycle, merge queue, billing and a new shell936 "/device/token": {
API and MCP server in Rust; a public index at the API root937 "post": {
938 "operationId": "device_token",
939 "tags": ["Accounts"],
940 "summary": "Finish signing in",
941 "description": "Asks whether the person has approved. Poll no faster than the interval. The token is returned once.",
942 "security": [],
943 "requestBody": {
944 "required": true,
945 "content": { "application/json": { "schema": {
946 "type": "object",
947 "required": ["device_code"],
948 "properties": { "device_code": { "type": "string" } },
949 } } },
950 },
951 "responses": { "200": {
952 "description": "The state of the sign-in.",
953 "content": { "application/json": { "schema": {
954 "type": "object",
955 "required": ["status"],
956 "properties": {
957 "status": { "type": "string", "enum": ["pending", "approved", "denied", "expired"] },
958 "token": { "type": "string", "description": "Present when approved." },
959 "username": { "type": "string" },
960 "verified": {
961 "type": "boolean",
962 "description": "Whether the account's email is confirmed.",
963 },
964 },
965 } } },
966 } },
967 },
968 },
969 });
970 match paths {
971 Value::Object(paths) => paths,
972 _ => Map::new(),
973 }
974}
975
Merge branch 'worktree-agent-ab2e39e11a6493412'976
977/// Puts each operation's examples, where it has them, into its request
978/// and response. Path and query values go under `x-example-params` and
979/// `x-example-query`, which tools that build a request can use.
980fn attach_examples(paths: &mut Map<String, Value>) {
981 let examples = examples();
982 for methods in paths.values_mut() {
983 let Some(methods) = methods.as_object_mut() else { continue };
984 for operation in methods.values_mut() {
985 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 step986 let name = operation["x-operation"].as_str().unwrap_or_default().to_owned();
987 let Some(example) = examples.get(&id).or_else(|| examples.get(&name)) else {
Merge branch 'worktree-agent-ab2e39e11a6493412'988 continue;
989 };
990 if let Some(notes) = example.get("notes").and_then(Value::as_str) {
991 let description = operation["description"].as_str().unwrap_or_default();
992 operation["description"] = json!(format!("{description}\n\n{notes}"));
993 }
994 if let Some(response) = example.get("response") {
995 let content = &mut operation["responses"]["200"]["content"]["application/json"];
996 if content.is_object() {
997 content["example"] = response.clone();
998 }
999 }
1000 if let Some(request) = example.get("request") {
1001 let content = &mut operation["requestBody"]["content"]["application/json"];
1002 if content.is_object() {
1003 content["example"] = request.clone();
1004 }
1005 }
1006 for (key, extension) in [("params", "x-example-params"), ("query", "x-example-query")] {
1007 if let Some(values) = example.get(key) {
1008 operation[extension] = values.clone();
1009 }
1010 }
1011 }
1012 }
1013}
1014
API and MCP server in Rust; a public index at the API root1015pub fn document() -> Value {
1016 let mut paths = onboarding();
1017 for route in ROUTES {
1018 let entry = paths
1019 .entry(openapi_path(route))
1020 .or_insert_with(|| json!({}));
1021 entry[route.method.to_lowercase()] = operation(route);
1022 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1023 attach_examples(&mut paths);
1024 let tags: Vec<Value> = SECTIONS
1025 .iter()
1026 .map(|(name, description, ops)| {
1027 json!({
1028 "name": name,
1029 "description": description,
1030 // The section's operations in reading order, by MCP tool name.
1031 "x-tools": ops.iter().map(|op| op.name()).collect::<Vec<_>>(),
1032 })
1033 })
1034 .collect();
1035 let codes = ["unauthenticated", "payment_required", "forbidden", "not_found", "conflict", "invalid"];
API and MCP server in Rust; a public index at the API root1036 json!({
1037 "openapi": "3.1.0",
1038 "info": {
1039 "title": "g1t API",
1040 "version": "1",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1041 "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 root1042 "license": { "name": "MIT", "identifier": "MIT" },
1043 },
1044 "servers": [{ "url": "https://api.g1t.sh" }],
1045 "security": [{ "token": [] }, {}],
Merge branch 'worktree-agent-ab2e39e11a6493412'1046 "tags": tags,
API and MCP server in Rust; a public index at the API root1047 "paths": paths,
1048 "components": {
1049 "securitySchemes": {
1050 "token": {
1051 "type": "http",
1052 "scheme": "bearer",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1053 "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 root1054 },
1055 },
1056 "schemas": {
1057 "Error": {
1058 "type": "object",
1059 "required": ["error"],
1060 "properties": {
1061 "error": {
1062 "type": "object",
1063 "required": ["code", "message"],
1064 "properties": {
Merge branch 'worktree-agent-ab2e39e11a6493412'1065 "code": { "type": "string", "enum": codes },
API and MCP server in Rust; a public index at the API root1066 "message": { "type": "string" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1067 "needed_scope": {
1068 "type": "string",
1069 "description": "On a 403 for an access token without the scope the call needs: that scope, such as `issues:write`.",
1070 },
API and MCP server in Rust; a public index at the API root1071 },
1072 },
1073 },
1074 },
1075 },
1076 },
1077 })
1078}
1079
1080#[cfg(test)]
1081mod tests {
1082 use super::*;
1083
1084 #[test]
1085 fn every_route_is_documented_once() {
1086 let document = document();
1087 let mut ids = Vec::new();
1088 for (_, methods) in document["paths"].as_object().unwrap() {
1089 for (_, operation) in methods.as_object().unwrap() {
1090 ids.push(operation["operationId"].as_str().unwrap().to_owned());
1091 }
1092 }
1093 for op in Op::ALL {
1094 assert_eq!(
1095 ids.iter().filter(|id| *id == op.name()).count(),
1096 1,
1097 "{}",
1098 op.name()
1099 );
1100 }
Webhooks: every event, to your own addresses, signed and retried1101 let mut unique = ids.clone();
1102 unique.sort();
1103 unique.dedup();
1104 assert_eq!(unique.len(), ids.len(), "operation ids repeat");
API and MCP server in Rust; a public index at the API root1105 }
1106
1107 #[test]
1108 fn path_and_query_inputs_are_not_repeated_in_the_body() {
1109 let document = document();
Agents as a team: lifecycle, merge queue, billing and a new shell1110 let merge = &document["paths"]["/repos/{owner}/{name}/pulls/{number}/merge"]["post"];
API and MCP server in Rust; a public index at the API root1111 let body = &merge["requestBody"]["content"]["application/json"]["schema"]["properties"];
1112 assert!(body.get("keep_issue_open").is_some());
1113 assert!(body.get("repo").is_none() && body.get("number").is_none());
Agents as a team: lifecycle, merge queue, billing and a new shell1114 let list = &document["paths"]["/repos"]["get"];
API and MCP server in Rust; a public index at the API root1115 assert_eq!(list["parameters"][0]["name"], "q");
1116 assert!(list.get("requestBody").is_none());
1117 }
1118
1119 #[test]
Merge branch 'worktree-agent-ab2e39e11a6493412'1120 fn every_operation_is_in_one_section() {
1121 for op in Op::ALL {
1122 let sections = SECTIONS
1123 .iter()
1124 .filter(|(_, _, ops)| ops.contains(&op))
1125 .count();
1126 assert_eq!(sections, 1, "{}", op.name());
1127 }
1128 }
1129
1130 #[test]
API and MCP server in Rust; a public index at the API root1131 fn titles_read_as_sentences() {
Merge branch 'worktree-agent-ab2e39e11a6493412'1132 assert_eq!(title(Op::CreateIssue), "Create an issue");
API and MCP server in Rust; a public index at the API root1133 assert_eq!(title(Op::Whoami), "Get the current user");
1134 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1135
1136 #[test]
1137 fn every_operation_has_an_example_response() {
1138 let examples = examples();
1139 assert!(!examples.is_empty(), "reference.json does not parse");
1140 let document = document();
1141 let mut known = Vec::new();
1142 for (path, methods) in document["paths"].as_object().unwrap() {
1143 for (method, operation) in methods.as_object().unwrap() {
1144 known.push(operation["operationId"].as_str().unwrap().to_owned());
1145 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1146 assert!(!example.is_null(), "{method} {path} has no example response");
1147 }
1148 }
1149 for id in examples.keys() {
1150 assert!(known.contains(id), "reference.json names {id}, which is not an operation");
1151 }
1152 }
1153
1154 #[test]
1155 fn example_requests_send_only_what_the_body_takes() {
1156 let document = document();
1157 for (path, methods) in document["paths"].as_object().unwrap() {
1158 for (method, operation) in methods.as_object().unwrap() {
1159 let content = &operation["requestBody"]["content"]["application/json"];
1160 let Some(example) = content["example"].as_object() else { continue };
1161 let properties = &content["schema"]["properties"];
1162 for key in example.keys() {
1163 assert!(!properties[key].is_null(), "{method} {path}: {key} is not in the body");
1164 }
1165 }
1166 }
1167 }
1168
1169 /// The docs site's copy of the document. Run with `G1T_WRITE_OPENAPI=1`
1170 /// to rewrite it after changing an operation.
1171 #[test]
1172 fn the_docs_copy_is_current() {
1173 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../docs/src/data/openapi.json");
1174 let current = serde_json::to_string_pretty(&document()).unwrap() + "\n";
1175 if std::env::var_os("G1T_WRITE_OPENAPI").is_some() {
1176 std::fs::write(path, &current).unwrap();
1177 return;
1178 }
1179 let copy = std::fs::read_to_string(path).unwrap_or_default().replace("\r\n", "\n");
1180 assert!(
1181 copy == current,
1182 "apps/docs/src/data/openapi.json is out of date: run G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi"
1183 );
1184 }
API reference: no example reads as a real secret1185
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1186 /// The reference shows responses as they are sent: `snake_case`.
1187 #[test]
1188 fn example_responses_are_snake_case() {
1189 let document = document();
1190 for (path, methods) in document["paths"].as_object().unwrap() {
1191 for (method, operation) in methods.as_object().unwrap() {
1192 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1193 let leaked = g1t_kit::wire::camel_case_keys(example);
1194 assert!(leaked.is_empty(), "{method} {path} shows {leaked:?}");
1195 }
1196 }
1197 }
1198
API reference: no example reads as a real secret1199 /// Examples never hold anything that reads as a real credential, which
1200 /// secret scanners rightly flag in a public repository: they end in `…`
1201 /// after the prefix, as `whsec_…` and `g1t_…` do.
1202 #[test]
1203 fn examples_hold_no_real_looking_secrets() {
Fast pages, required checks on the branch, self-hosted runners, honest incidents1204 let prefixes = ["whsec_", "g1t_", "g1tr_", "g1trt_", "sk_live_", "sk_test_", "ghp_", "github_pat_", "xoxb-", "AKIA"];
API reference: no example reads as a real secret1205 for (line, text) in REFERENCE.lines().enumerate() {
1206 for prefix in prefixes {
1207 let mut rest = text;
1208 while let Some(at) = rest.find(prefix) {
1209 let after = &rest[at + prefix.len()..];
1210 let run = after.chars().take_while(|c| c.is_ascii_alphanumeric()).count();
1211 assert!(
1212 run < 12,
1213 "reference.json line {}: `{prefix}` followed by {run} characters reads as a real secret; write `{prefix}…`",
1214 line + 1
1215 );
1216 rest = after;
1217 }
1218 }
1219 }
1220 }
API and MCP server in Rust; a public index at the API root1221}

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