Skip to content
1,220 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;
11use crate::deployments::DeploymentsOp;
Actions: keep workflow runs safe12use crate::protection::ProtectionOp;
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 (
63 "Invites",
64 "While g1t is invite-only, every new account needs an invite. Your invites, and inviting people into a workspace by email.",
65 &[
66 Op::ListInvites,
67 Op::CreateInvite,
68 Op::RevokeInvite,
69 Op::ListWorkspaceInvites,
70 Op::InviteMember,
71 Op::RevokeWorkspaceInvite,
72 ],
Merge branch 'worktree-agent-ab2e39e11a6493412'73 ),
74 (
Usage, Billing settings and prepaid AI credit; fixes from the UX audit75 "Billing",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens76 "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 audit77 &[
78 Op::GetUsage,
79 Op::GetBudget,
80 Op::SetBudget,
81 Op::GetAiCredit,
82 Op::BuyAiCredit,
83 Op::ListInvoices,
84 Op::GetBillingDetails,
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens85 Op::ListGatewayRequests,
Usage, Billing settings and prepaid AI credit; fixes from the UX audit86 ],
87 ),
88 (
Merge branch 'worktree-agent-ab2e39e11a6493412'89 "Repositories",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look90 "A repository, how it handles pull requests, and its timeline: renaming, archiving, moving and deleting it.",
Merge branch 'worktree-agent-ab2e39e11a6493412'91 &[
92 Op::ListRepos,
93 Op::CreateRepo,
94 Op::GetRepo,
95 Op::UpdateRepo,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look96 Op::RenameRepo,
97 Op::RenameBranch,
98 Op::SetRepoVisibility,
99 Op::ArchiveRepo,
100 Op::UnarchiveRepo,
101 Op::TransferRepo,
102 Op::DeleteRepo,
103 Op::ListDeletedRepos,
104 Op::RestoreRepo,
105 Op::PurgeRepo,
Merge branch 'worktree-agent-ab2e39e11a6493412'106 Op::GetRepoSettings,
107 Op::UpdateRepoSettings,
Fast pages, required checks on the branch, self-hosted runners, honest incidents108 Op::ListCheckNames,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar109 Op::GetCodeownersErrors,
Merge branch 'worktree-agent-ab2e39e11a6493412'110 Op::ListEvents,
111 ],
112 ),
113 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97114 "Repository insights",
115 "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.",
116 &[Op::About(AboutOp::GetLanguages), Op::About(AboutOp::ListContributors), Op::About(AboutOp::GetLicense)],
117 ),
118 (
119 "Stars",
120 "Starring a repository, to keep it and to say you like it: who starred one, and what you starred.",
121 &[
122 Op::About(AboutOp::ListStargazers),
123 Op::About(AboutOp::ListStarred),
124 Op::About(AboutOp::CheckStarred),
125 Op::About(AboutOp::Star),
126 Op::About(AboutOp::Unstar),
127 ],
128 ),
129 (
130 "Releases",
131 "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.",
132 &[
133 Op::About(AboutOp::ListReleases),
134 Op::About(AboutOp::CreateRelease),
135 Op::About(AboutOp::GetLatestRelease),
136 Op::About(AboutOp::GetReleaseByTag),
137 Op::About(AboutOp::GetRelease),
138 Op::About(AboutOp::UpdateRelease),
139 Op::About(AboutOp::DeleteRelease),
140 ],
141 ),
142 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look143 "Access",
144 "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.",
145 &[
146 Op::ListCollaborators,
147 Op::AddCollaborator,
148 Op::UpdateCollaborator,
149 Op::RemoveCollaborator,
150 Op::GetCollaboratorPermission,
151 Op::ListRepoInvitations,
152 Op::RevokeRepoInvitation,
153 Op::ListMyRepoInvitations,
154 Op::AcceptRepoInvitation,
155 Op::DeclineRepoInvitation,
156 Op::SetBasePermission,
157 Op::ListOutsideCollaborators,
158 ],
159 ),
160 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar161 "Teams",
162 "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.",
163 &[
164 Op::ListTeams,
165 Op::CreateTeam,
166 Op::GetTeam,
167 Op::UpdateTeam,
168 Op::DeleteTeam,
169 Op::ListTeamMembers,
170 Op::SetTeamMember,
171 Op::RemoveTeamMember,
172 Op::ListChildTeams,
173 Op::ListTeamRepos,
174 Op::SetTeamRepo,
175 Op::RemoveTeamRepo,
176 Op::SetTeamReviewAssignment,
177 Op::ListUserTeams,
178 ],
179 ),
180 (
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily181 "Security",
182 "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.",
183 &[Op::ListSecurityAlerts, Op::DismissSecurityAlert, Op::ReopenSecurityAlert],
184 ),
185 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar186 "Secret scanning",
187 "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.",
188 &[
189 Op::Security(SecurityOp::ListSecretAlerts),
190 Op::Security(SecurityOp::GetSecretAlert),
191 Op::Security(SecurityOp::UpdateSecretAlert),
192 Op::Security(SecurityOp::ListSecretLocations),
193 Op::Security(SecurityOp::BypassPushProtection),
194 Op::Security(SecurityOp::CheckSecretValidity),
195 Op::Security(SecurityOp::ListBypassRequests),
196 Op::Security(SecurityOp::ReviewBypassRequest),
197 Op::Security(SecurityOp::ListCustomPatterns),
198 Op::Security(SecurityOp::CreateCustomPattern),
199 Op::Security(SecurityOp::UpdateCustomPattern),
200 Op::Security(SecurityOp::DeleteCustomPattern),
201 Op::Security(SecurityOp::DryRunCustomPattern),
202 ],
203 ),
204 (
205 "Code scanning",
206 "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.",
207 &[
208 Op::Security(SecurityOp::ListCodeAlerts),
209 Op::Security(SecurityOp::GetCodeAlert),
210 Op::Security(SecurityOp::UpdateCodeAlert),
211 Op::Security(SecurityOp::ListAnalyses),
212 Op::Security(SecurityOp::UploadSarif),
213 Op::Security(SecurityOp::GetSarifUpload),
214 Op::Security(SecurityOp::FixAlert),
215 ],
216 ),
217 (
218 "Supply chain",
219 "What a repository depends on: vulnerability alerts, the dependency graph, an SPDX SBOM of it, and comparing two commits' dependencies as dependency review does.",
220 &[
221 Op::Security(SecurityOp::ListVulnerabilityAlerts),
222 Op::Security(SecurityOp::GetVulnerabilityAlert),
223 Op::Security(SecurityOp::UpdateVulnerabilityAlert),
224 Op::Security(SecurityOp::GetDependencyGraph),
225 Op::Security(SecurityOp::GetSbom),
226 Op::Security(SecurityOp::CompareDependencies),
227 ],
228 ),
229 (
230 "Security settings",
231 "When pull request checks fail, dependency review's policy, delegated bypass and validity checks, and a workspace's security overview.",
232 &[
233 Op::Security(SecurityOp::GetSettings),
234 Op::Security(SecurityOp::UpdateSettings),
235 Op::Security(SecurityOp::GetWorkspaceSettings),
236 Op::Security(SecurityOp::UpdateWorkspaceSettings),
237 Op::Security(SecurityOp::GetOverview),
238 ],
239 ),
240 (
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge241 "Rules",
242 "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.",
243 &[
244 Op::Rules(RulesOp::ListRepoRulesets),
245 Op::Rules(RulesOp::CreateRepoRuleset),
246 Op::Rules(RulesOp::GetRepoRuleset),
247 Op::Rules(RulesOp::UpdateRepoRuleset),
248 Op::Rules(RulesOp::DeleteRepoRuleset),
249 Op::Rules(RulesOp::GetBranchRules),
250 Op::Rules(RulesOp::ListRuleEvaluations),
251 Op::Rules(RulesOp::ListWorkspaceRulesets),
252 Op::Rules(RulesOp::CreateWorkspaceRuleset),
253 Op::Rules(RulesOp::GetWorkspaceRuleset),
254 Op::Rules(RulesOp::UpdateWorkspaceRuleset),
255 Op::Rules(RulesOp::DeleteWorkspaceRuleset),
256 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
257 ],
258 ),
259 (
Merge checks: statuses and check runs on every commit260 "Checks",
261 "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.",
262 &[
263 Op::Checks(ChecksOp::CreateCommitStatus),
264 Op::Checks(ChecksOp::ListCommitStatuses),
265 Op::Checks(ChecksOp::GetCombinedStatus),
266 Op::Checks(ChecksOp::CreateCheckRun),
267 Op::Checks(ChecksOp::UpdateCheckRun),
268 Op::Checks(ChecksOp::GetCheckRun),
269 Op::Checks(ChecksOp::ListCheckRunAnnotations),
270 Op::Checks(ChecksOp::RerequestCheckRun),
271 Op::Checks(ChecksOp::ListCheckRunsForRef),
272 Op::Checks(ChecksOp::ListCheckSuitesForRef),
273 Op::Checks(ChecksOp::GetCheckSuite),
274 Op::Checks(ChecksOp::RerequestCheckSuite),
275 ],
276 ),
277 (
Merge branch 'worktree-agent-ab2e39e11a6493412'278 "Issues",
279 "What should change in a repository, with labels and comments. Issues and pull requests share one sequence of numbers.",
280 &[
281 Op::ListIssues,
282 Op::CreateIssue,
283 Op::GetIssue,
284 Op::UpdateIssue,
285 Op::CloseIssue,
286 Op::ReopenIssue,
287 Op::AssignIssue,
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step288 Op::Delegate,
Merge branch 'worktree-agent-ab2e39e11a6493412'289 Op::AddComment,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar290 Op::ListIssueLabels,
291 Op::AddIssueLabels,
292 Op::SetIssueLabels,
293 Op::RemoveIssueLabels,
294 ],
295 ),
296 (
297 "Labels and milestones",
298 "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.",
299 &[
Merge branch 'worktree-agent-ab2e39e11a6493412'300 Op::ListLabels,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar301 Op::CreateLabel,
302 Op::UpdateLabel,
303 Op::DeleteLabel,
304 Op::AddDefaultLabels,
305 Op::ListMilestones,
306 Op::CreateMilestone,
307 Op::GetMilestone,
308 Op::UpdateMilestone,
309 Op::DeleteMilestone,
Merge branch 'worktree-agent-ab2e39e11a6493412'310 ],
311 ),
312 (
313 "Plans",
314 "An outcome turned into the issues that would get there, with the order they must merge in.",
315 &[Op::PlanWork, Op::GetPlan, Op::ApplyPlan],
316 ),
317 (
318 "Pull requests",
319 "A proposed change in its own fork or on a branch. Several can be made for one issue; the one merged resolves it.",
320 &[
321 Op::ListPullRequests,
322 Op::CreatePullRequest,
323 Op::GetPullRequest,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar324 Op::UpdatePullRequest,
Merge branch 'worktree-agent-ab2e39e11a6493412'325 Op::GetPullRequestChanges,
326 Op::MarkPullRequestReady,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar327 Op::RequestReviewers,
328 Op::RemoveRequestedReviewers,
Merge branch 'worktree-agent-ab2e39e11a6493412'329 Op::ReviewPullRequest,
330 Op::MergePullRequest,
331 Op::ClosePullRequest,
332 Op::GetMergeQueue,
333 Op::MessageAgent,
334 Op::AnswerMessage,
335 Op::TakeMessages,
336 ],
337 ),
338 (
339 "Sessions",
340 "The record of how a pull request was made: prompts, reasoning and the tools that ran.",
341 &[Op::ReadSession, Op::RecordSession],
342 ),
343 (
Agents and memory, checks and conflicts, profiles, slug renames, custom domains344 "Memory",
345 "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.",
346 &[Op::Remember, Op::Recall],
347 ),
348 (
Search across all of g1t, Explore, and a command palette349 "Search",
350 "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.",
351 &[Op::Search],
352 ),
353 (
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API354 "Context",
355 "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.",
356 &[Op::SearchContext, Op::GetEntity],
357 ),
358 (
Merge branch 'worktree-agent-ab2e39e11a6493412'359 "Actions",
360 "GitHub Actions workflows in .g1t/workflows, their runs, and their jobs' logs.",
361 &[
362 Op::ListWorkflows,
363 Op::ListWorkflowRuns,
364 Op::GetWorkflowRun,
365 Op::GetJobLogs,
366 Op::DispatchWorkflow,
367 Op::CancelWorkflowRun,
368 Op::RerunWorkflowRun,
369 Op::UpdateWorkflow,
370 ],
371 ),
372 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97373 "Deployments",
374 "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.",
375 &[
376 Op::Deployments(DeploymentsOp::ListDeployments),
377 Op::Deployments(DeploymentsOp::CreateDeployment),
378 Op::Deployments(DeploymentsOp::GetDeployment),
379 Op::Deployments(DeploymentsOp::ListDeploymentStatuses),
380 Op::Deployments(DeploymentsOp::CreateDeploymentStatus),
381 Op::Deployments(DeploymentsOp::ListEnvironments),
382 Op::Deployments(DeploymentsOp::GetEnvironment),
383 ],
384 ),
385 (
Actions: keep workflow runs safe386 "Run protection",
387 "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.",
388 &[
389 Op::Protection(ProtectionOp::UpdateEnvironment),
390 Op::Protection(ProtectionOp::DeleteEnvironment),
391 Op::Protection(ProtectionOp::GetPendingDeployments),
392 Op::Protection(ProtectionOp::ReviewPendingDeployments),
393 Op::Protection(ProtectionOp::ApproveWorkflowRun),
394 Op::Protection(ProtectionOp::GetWorkflowPermissions),
395 Op::Protection(ProtectionOp::SetWorkflowPermissions),
396 Op::Protection(ProtectionOp::GetForkPrApproval),
397 Op::Protection(ProtectionOp::SetForkPrApproval),
398 Op::Protection(ProtectionOp::CreateRepositoryDispatch),
399 ],
400 ),
401 (
Merge branch 'worktree-agent-ab2e39e11a6493412'402 "Secrets and variables",
403 "Values that workflows and deployments read, per repository or for a whole workspace, with a row per environment.",
404 &[
405 Op::ListActionsSecrets,
406 Op::SetActionsSecret,
407 Op::DeleteActionsSecret,
408 Op::ListActionsVariables,
409 Op::SetActionsVariable,
410 Op::DeleteActionsVariable,
411 ],
412 ),
413 (
Fast pages, required checks on the branch, self-hosted runners, honest incidents414 "Runners",
415 "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.",
416 &[
417 Op::ListRunners,
418 Op::CreateRunnerRegistrationToken,
419 Op::RemoveRunner,
420 Op::ListRunnerGroups,
421 Op::CreateRunnerGroup,
422 Op::UpdateRunnerGroup,
423 Op::DeleteRunnerGroup,
424 Op::GetRunnerSettings,
425 Op::UpdateRunnerSettings,
426 ],
427 ),
428 (
Merge branch 'worktree-agent-ab2e39e11a6493412'429 "Webhooks",
430 "Signed HTTPS requests sent to your own address as things happen, for a repository or a whole workspace.",
431 &[
432 Op::ListWebhooks,
433 Op::CreateWebhook,
434 Op::UpdateWebhook,
435 Op::DeleteWebhook,
436 Op::PingWebhook,
437 Op::ListWebhookDeliveries,
438 Op::RedeliverWebhook,
439 ],
440 ),
441 (
442 "Integrations",
443 "A workspace's connections to outside systems: model providers, alert sources and issue trackers.",
444 &[
445 Op::ListIntegrations,
446 Op::ConnectIntegration,
AI Gateway: OpenAI's format, open models, and your own providers447 Op::UpdateIntegration,
Merge branch 'worktree-agent-ab2e39e11a6493412'448 Op::DisconnectIntegration,
449 Op::TestIntegration,
450 Op::GetModelRoutes,
451 Op::SetModelRoutes,
452 Op::GetContext,
453 Op::ImportIssue,
454 ],
455 ),
456];
457
API and MCP server in Rust; a public index at the API root458/// The section of the API reference an operation is listed under.
459fn tag(op: Op) -> &'static str {
Merge branch 'worktree-agent-ab2e39e11a6493412'460 SECTIONS
API and MCP server in Rust; a public index at the API root461 .iter()
Merge branch 'worktree-agent-ab2e39e11a6493412'462 .find(|(_, _, ops)| ops.contains(&op))
463 .map_or("Repositories", |(name, _, _)| name)
464}
465
466/// What an operation's page is called, as a short sentence.
467fn title(op: Op) -> &'static str {
468 match op {
469 Op::Whoami => "Get the current user",
Merge branch 'worktree-agent-ad7c6d88d93adc817'470 Op::GetWorkspace => "Get a workspace",
Merge branch 'worktree-agent-ab2e39e11a6493412'471 Op::CreateWorkspace => "Create a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look472 Op::DeleteWorkspace => "Delete a workspace",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily473 Op::UpdateWorkspace => "Update a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look474 Op::ListEmails => "List your email addresses",
475 Op::AddEmail => "Add an email address",
476 Op::RemoveEmail => "Remove an email address",
477 Op::UpdateEmailSettings => "Change your email settings",
478 Op::ListInvites => "List your invites",
479 Op::CreateInvite => "Create an invite",
480 Op::RevokeInvite => "Revoke an invite",
481 Op::ListWorkspaceInvites => "List a workspace's invites",
482 Op::InviteMember => "Invite someone to a workspace",
483 Op::RevokeWorkspaceInvite => "Revoke a workspace's invite",
484 Op::TransferRepo => "Transfer a repository",
485 Op::RenameRepo => "Rename a repository",
486 Op::RenameBranch => "Rename a branch",
487 Op::ArchiveRepo => "Archive a repository",
488 Op::UnarchiveRepo => "Unarchive a repository",
489 Op::SetRepoVisibility => "Change a repository's visibility",
490 Op::DeleteRepo => "Delete a repository",
491 Op::ListDeletedRepos => "List recently deleted repositories",
492 Op::RestoreRepo => "Restore a deleted repository",
493 Op::PurgeRepo => "Purge a deleted repository",
Merge branch 'worktree-agent-ab2e39e11a6493412'494 Op::ListRepos => "List repositories",
495 Op::GetRepo => "Get a repository",
496 Op::CreateRepo => "Create a repository",
497 Op::UpdateRepo => "Update a repository",
498 Op::GetRepoSettings => "Get repository settings",
499 Op::UpdateRepoSettings => "Update repository settings",
Fast pages, required checks on the branch, self-hosted runners, honest incidents500 Op::ListCheckNames => "List check names",
Merge branch 'worktree-agent-ab2e39e11a6493412'501 Op::GetMergeQueue => "Get the merge queue",
502 Op::MessageAgent => "Message an agent",
503 Op::AnswerMessage => "Answer a message",
504 Op::TakeMessages => "Take new messages",
Agents and memory, checks and conflicts, profiles, slug renames, custom domains505 Op::Remember => "Remember something",
506 Op::Recall => "Recall memory",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API507 Op::SearchContext => "Search the context hub",
508 Op::GetEntity => "Get a catalog entry",
Search across all of g1t, Explore, and a command palette509 Op::Search => "Search g1t",
Merge branch 'worktree-agent-ab2e39e11a6493412'510 Op::ListIssues => "List issues",
511 Op::GetIssue => "Get an issue",
512 Op::CreateIssue => "Create an issue",
513 Op::UpdateIssue => "Update an issue",
514 Op::CloseIssue => "Close an issue",
515 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-agent516 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 step517 Op::Delegate => "Put an agent on it",
Merge branch 'worktree-agent-ab2e39e11a6493412'518 Op::PlanWork => "Plan work",
519 Op::GetPlan => "Get a plan",
520 Op::ApplyPlan => "Apply a plan",
521 Op::ListLabels => "List labels",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar522 Op::CreateLabel => "Create a label",
523 Op::UpdateLabel => "Update a label",
524 Op::DeleteLabel => "Delete a label",
525 Op::AddDefaultLabels => "Add the default labels",
526 Op::ListIssueLabels => "List an issue's labels",
527 Op::AddIssueLabels => "Add labels to an issue",
528 Op::SetIssueLabels => "Set an issue's labels",
529 Op::RemoveIssueLabels => "Remove labels from an issue",
530 Op::ListMilestones => "List milestones",
531 Op::GetMilestone => "Get a milestone",
532 Op::CreateMilestone => "Create a milestone",
533 Op::UpdateMilestone => "Update a milestone",
534 Op::DeleteMilestone => "Delete a milestone",
535 Op::UpdatePullRequest => "Update a pull request",
Merge branch 'worktree-agent-ab2e39e11a6493412'536 Op::AddComment => "Add a comment",
537 Op::ReviewPullRequest => "Review a pull request",
538 Op::ListPullRequests => "List pull requests",
539 Op::GetPullRequest => "Get a pull request",
540 Op::CreatePullRequest => "Create a pull request",
541 Op::RecordSession => "Record session entries",
542 Op::ReadSession => "Read a session",
543 Op::MarkPullRequestReady => "Mark a pull request ready",
544 Op::ClosePullRequest => "Close a pull request",
545 Op::GetPullRequestChanges => "Get a pull request's changes",
546 Op::MergePullRequest => "Merge a pull request",
547 Op::ListEvents => "List repository events",
548 Op::ListIntegrations => "List integrations",
549 Op::ConnectIntegration => "Connect an integration",
AI Gateway: OpenAI's format, open models, and your own providers550 Op::UpdateIntegration => "Update an integration",
Merge branch 'worktree-agent-ab2e39e11a6493412'551 Op::DisconnectIntegration => "Disconnect an integration",
552 Op::TestIntegration => "Test an integration",
553 Op::GetContext => "Look up a ticket",
554 Op::ImportIssue => "Import an issue",
555 Op::GetModelRoutes => "Get model routes",
556 Op::SetModelRoutes => "Set model routes",
557 Op::ListWebhooks => "List webhooks",
558 Op::CreateWebhook => "Create a webhook",
559 Op::UpdateWebhook => "Update a webhook",
560 Op::DeleteWebhook => "Delete a webhook",
561 Op::PingWebhook => "Ping a webhook",
562 Op::ListWebhookDeliveries => "List webhook deliveries",
563 Op::RedeliverWebhook => "Redeliver a webhook delivery",
564 Op::ListWorkflows => "List workflows",
565 Op::ListWorkflowRuns => "List workflow runs",
566 Op::GetWorkflowRun => "Get a workflow run",
567 Op::GetJobLogs => "Get a job's log",
568 Op::DispatchWorkflow => "Run a workflow",
569 Op::CancelWorkflowRun => "Cancel a workflow run",
570 Op::RerunWorkflowRun => "Re-run a workflow run",
571 Op::UpdateWorkflow => "Turn a workflow on or off",
572 Op::ListActionsSecrets => "List secrets",
573 Op::SetActionsSecret => "Set a secret",
574 Op::DeleteActionsSecret => "Delete a secret",
575 Op::ListActionsVariables => "List variables",
576 Op::SetActionsVariable => "Set a variable",
577 Op::DeleteActionsVariable => "Delete a variable",
Fast pages, required checks on the branch, self-hosted runners, honest incidents578 Op::ListRunners => "List self-hosted runners",
579 Op::ListRunnerGroups => "List runner groups",
580 Op::GetRunnerSettings => "Get runner settings",
581 Op::CreateRunnerRegistrationToken => "Create a runner registration token",
582 Op::RemoveRunner => "Remove a self-hosted runner",
583 Op::CreateRunnerGroup => "Create a runner group",
584 Op::UpdateRunnerGroup => "Change a runner group",
585 Op::DeleteRunnerGroup => "Delete a runner group",
586 Op::UpdateRunnerSettings => "Change runner settings",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look587 Op::ListCollaborators => "List who has access",
588 Op::AddCollaborator => "Add a collaborator",
589 Op::UpdateCollaborator => "Change a collaborator's role",
590 Op::RemoveCollaborator => "Remove a collaborator",
591 Op::GetCollaboratorPermission => "Get someone's permission",
592 Op::ListRepoInvitations => "List a repository's invitations",
593 Op::RevokeRepoInvitation => "Revoke a repository invitation",
594 Op::ListMyRepoInvitations => "List your repository invitations",
595 Op::AcceptRepoInvitation => "Accept a repository invitation",
596 Op::DeclineRepoInvitation => "Decline a repository invitation",
597 Op::SetBasePermission => "Set the base permission",
598 Op::ListOutsideCollaborators => "List outside collaborators",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily599 Op::ListSecurityAlerts => "List security alerts",
600 Op::DismissSecurityAlert => "Dismiss a security alert",
601 Op::ReopenSecurityAlert => "Reopen a security alert",
API: notifications over REST and MCP, with notifications scopes602 Op::ListNotifications => "List notifications",
603 Op::MarkNotificationsRead => "Mark notifications read",
604 Op::GetNotificationThread => "Get a thread",
605 Op::MarkThreadRead => "Mark a thread read",
606 Op::MarkThreadDone => "Mark a thread done",
607 Op::SaveThread => "Save a thread",
608 Op::SnoozeThread => "Snooze a thread",
609 Op::GetThreadSubscription => "Get a thread subscription",
610 Op::SetThreadSubscription => "Set a thread subscription",
611 Op::DeleteThreadSubscription => "Unsubscribe from a thread",
612 Op::GetRepoSubscription => "Get how you watch a repository",
613 Op::SetRepoSubscription => "Watch a repository",
614 Op::DeleteRepoSubscription => "Stop watching a repository",
615 Op::ListWatchedRepos => "List repositories you watch",
API: pinned projects over REST and MCP616 Op::ListPinnedProjects => "List your pinned projects",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit617 Op::GetUsage => "Get a workspace's usage",
618 Op::GetBudget => "Get a workspace's budget",
619 Op::SetBudget => "Change a workspace's budget",
620 Op::GetAiCredit => "Get a workspace's AI credit",
621 Op::BuyAiCredit => "Buy AI credit",
622 Op::ListInvoices => "List a workspace's invoices",
623 Op::GetBillingDetails => "Get a workspace's billing details",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens624 Op::ListGatewayRequests => "List a workspace's AI Gateway requests",
API: pinned projects over REST and MCP625 Op::PinProject => "Pin a project",
626 Op::UnpinProject => "Unpin a project",
627 Op::ReorderPinnedProjects => "Reorder your pinned projects",
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97628 Op::ListProjects => "List a workspace's projects",
629 Op::GetProject => "Get a project",
630 Op::UpdateProject => "Update a project",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar631 Op::ListTeams => "List teams",
632 Op::GetTeam => "Get a team",
633 Op::CreateTeam => "Create a team",
634 Op::UpdateTeam => "Update a team",
635 Op::DeleteTeam => "Delete a team",
636 Op::ListTeamMembers => "List a team's members",
637 Op::SetTeamMember => "Add or change a team member",
638 Op::RemoveTeamMember => "Remove a team member",
639 Op::ListChildTeams => "List child teams",
640 Op::ListTeamRepos => "List a team's repositories",
641 Op::SetTeamRepo => "Give a team a role on a repository",
642 Op::RemoveTeamRepo => "Remove a team from a repository",
643 Op::SetTeamReviewAssignment => "Set a team's review assignment",
644 Op::ListUserTeams => "List someone's teams",
645 Op::RequestReviewers => "Request reviewers",
646 Op::RemoveRequestedReviewers => "Remove requested reviewers",
647 Op::GetCodeownersErrors => "List CODEOWNERS errors",
648 Op::Security(op) => op.title(),
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge649 Op::Rules(op) => op.title(),
Merge checks: statuses and check runs on every commit650 Op::Checks(op) => op.title(),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97651 Op::About(op) => op.title(),
652 Op::Deployments(op) => op.title(),
Actions: keep workflow runs safe653 Op::Protection(op) => op.title(),
API and MCP server in Rust; a public index at the API root654 }
655}
656
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look657/// Why an operation can be refused with `402 payment_required`, if it
658/// can: the ones that start an agent, when the workspace has no credit,
659/// and the ones that make a repository private in a workspace, when a free
660/// workspace's private storage has no room for it.
661fn may_need_payment(op: Op) -> Option<&'static str> {
662 match op {
663 Op::AssignIssue | Op::PlanWork | Op::ApplyPlan => Some("The workspace has no agent credit."),
664 Op::UpdateRepo | Op::SetRepoVisibility | Op::TransferRepo => Some(
665 "A free workspace's private storage has no room for this private repository.",
666 ),
667 _ => None,
668 }
Merge branch 'worktree-agent-ab2e39e11a6493412'669}
670
671/// What the reference says beyond each operation's own description, keyed
672/// by operation id, written by hand from what the services return: `notes`
673/// (Markdown, added to the description) and example `params` (path),
674/// `query`, `request` (body) and `response`.
675const REFERENCE: &str = include_str!("reference.json");
676
677fn examples() -> Map<String, Value> {
678 match serde_json::from_str(REFERENCE) {
679 Ok(Value::Object(examples)) => examples,
680 _ => Map::new(),
API and MCP server in Rust; a public index at the API root681 }
682}
683
Agents as a team: lifecycle, merge queue, billing and a new shell684/// `/repos/:owner/:name` as OpenAPI writes it: `/repos/{owner}/{name}`.
API and MCP server in Rust; a public index at the API root685fn openapi_path(route: &Route) -> String {
686 route
687 .path
688 .split('/')
689 .map(|segment| match segment.strip_prefix(':') {
690 Some(name) => format!("{{{name}}}"),
691 None => segment.to_owned(),
692 })
693 .collect::<Vec<_>>()
694 .join("/")
695}
696
697fn error_response(description: &str) -> Value {
698 json!({
699 "description": description,
700 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } },
701 })
702}
703
Merge branch 'worktree-agent-ab2e39e11a6493412'704/// A parameter in the path or the query, described by the operation's
705/// input schema where it has the same name.
706fn parameter(name: &str, place: &str, required: bool, schema: Option<&Value>) -> Value {
707 let mut schema = schema.cloned().unwrap_or_else(|| json!({ "type": "string" }));
708 let description = match name {
709 "owner" => Some(Value::from("The workspace that owns the repository.")),
710 "name" => Some(Value::from("The repository's name.")),
711 _ => schema.as_object_mut().and_then(|schema| schema.remove("description")),
712 };
713 let mut parameter = json!({
714 "name": name,
715 "in": place,
716 "required": required,
717 "schema": schema,
718 });
719 if let Some(description) = description {
720 parameter["description"] = description;
721 }
722 parameter
723}
724
725/// The operation id of a route. An operation reached at a workspace's
726/// address as well as a repository's is documented once for each, with its
727/// own id; GitHub's alternative addresses for one operation keep GitHub's
728/// names.
729fn operation_id(route: &Route) -> String {
730 let op = route.op;
731 let base = match (route.method, route.path.rsplit('/').next().unwrap_or_default()) {
732 ("PUT", "enable") => "enable_workflow".to_owned(),
733 ("PUT", "disable") => "disable_workflow".to_owned(),
734 ("POST", "rerun-failed-jobs") => "rerun_failed_jobs".to_owned(),
735 ("PATCH", ":setting") => "update_actions_variable".to_owned(),
736 ("GET", "runs") if route.path.contains("/workflows/:workflow/") => "list_runs_of_workflow".to_owned(),
API: notifications over REST and MCP, with notifications scopes737 // One repository's notifications, and an issue's subscription by
738 // its number rather than a thread's id.
739 (_, "notifications") if route.path.starts_with("/repos/") => match op {
740 Op::ListNotifications => "list_repo_notifications".to_owned(),
741 _ => "mark_repo_notifications_read".to_owned(),
742 },
743 (method, "subscription") if route.path.contains("/issues/:number/") => match method {
744 "GET" => "get_issue_subscription".to_owned(),
745 "PUT" => "set_issue_subscription".to_owned(),
746 _ => "delete_issue_subscription".to_owned(),
747 },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar748 // One label off an issue, by its name in the path.
749 ("DELETE", ":label") if route.path.contains("/issues/:number/") => "remove_issue_label".to_owned(),
API: notifications over REST and MCP, with notifications scopes750 ("DELETE", "saved") => "unsave_thread".to_owned(),
751 ("DELETE", "snooze") => "unsnooze_thread".to_owned(),
Merge branch 'worktree-agent-ab2e39e11a6493412'752 _ => op.name().to_owned(),
753 };
754 if route.path.starts_with("/workspaces/") && ROUTES.iter().any(|other| other.op == op && other.path.starts_with("/repos/")) {
755 format!("{base}_for_workspace")
756 } else {
757 base
758 }
759}
760
761/// The summary of a route: its operation's title, or for one of GitHub's
762/// alternative addresses, what that address does.
763fn summary(route: &Route, id: &str) -> String {
764 let base = match id.trim_end_matches("_for_workspace") {
765 "enable_workflow" => "Turn a workflow on",
766 "disable_workflow" => "Turn a workflow off",
767 "rerun_failed_jobs" => "Re-run failed jobs",
768 "update_actions_variable" => "Update a variable",
769 "list_runs_of_workflow" => "List a workflow's runs",
API: notifications over REST and MCP, with notifications scopes770 "list_repo_notifications" => "List a repository's notifications",
771 "mark_repo_notifications_read" => "Mark a repository's notifications read",
772 "get_issue_subscription" => "Get your subscription to an issue",
773 "set_issue_subscription" => "Subscribe to an issue",
774 "delete_issue_subscription" => "Unsubscribe from an issue",
775 "unsave_thread" => "Unsave a thread",
776 "unsnooze_thread" => "Bring a snoozed thread back",
Merge branch 'worktree-agent-ab2e39e11a6493412'777 _ => title(route.op),
778 };
779 if id.ends_with("_for_workspace") {
780 format!("{base} for a workspace")
781 } else {
782 base.to_owned()
783 }
784}
785
API and MCP server in Rust; a public index at the API root786fn operation(route: &Route) -> Value {
787 let op = route.op;
788 let path_params: Vec<&str> = route.params().collect();
Merge checks: statuses and check runs on every commit789 // `owner` and `name` in the path stand for the operation's `repo` input,
790 // so a `name` in the body, such as a check run's, is the body's own.
791 let stands_for_repo =
792 |name: &str| matches!(name, "owner" | "name") && path_params.contains(&"owner") && path_params.contains(&"name");
793 let covered = |name: &str| name == "repo" || (path_params.contains(&name) && !stands_for_repo(name));
Merge branch 'worktree-agent-ab2e39e11a6493412'794 let all_properties = op.properties();
795 let mut properties = all_properties.clone();
API and MCP server in Rust; a public index at the API root796 properties.retain(|name, _| !covered(name));
797 let required: Vec<String> = op
798 .required()
799 .into_iter()
800 .filter(|name| !covered(name))
801 .collect();
802
803 let mut parameters: Vec<Value> = path_params
804 .iter()
Merge checks: statuses and check runs on every commit805 .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 root806 .collect();
807 let mut body = Value::Null;
808 if route.method == "GET" {
809 for (name, key) in route.query {
Merge branch 'worktree-agent-ab2e39e11a6493412'810 parameters.push(parameter(
811 name,
812 "query",
813 required.iter().any(|required| required == key),
814 properties.get(*key),
815 ));
API and MCP server in Rust; a public index at the API root816 }
817 } else if !properties.is_empty() {
818 let mut schema = json!({ "type": "object", "properties": properties });
819 if !required.is_empty() {
820 schema["required"] = json!(required);
821 }
822 body = json!({
823 "required": !required.is_empty(),
824 "content": { "application/json": { "schema": schema } },
825 });
826 }
827
Merge branch 'worktree-agent-ab2e39e11a6493412'828 let id = operation_id(route);
829 let mut responses = Map::new();
830 responses.insert(
831 "200".into(),
832 json!({
833 "description": "Success.",
834 "content": { "application/json": { "schema": {} } },
835 }),
836 );
837 responses.insert(
838 "401".into(),
839 error_response("A token is required, or the one sent is not valid."),
840 );
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look841 if let Some(reason) = may_need_payment(op) {
842 responses.insert("402".into(), error_response(reason));
Merge branch 'worktree-agent-ab2e39e11a6493412'843 }
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step844 responses.insert(
845 "403".into(),
846 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."),
847 );
Search across all of g1t, Explore, and a command palette848 if !matches!(op, Op::Whoami | Op::ListRepos | Op::Search) {
Merge branch 'worktree-agent-ab2e39e11a6493412'849 responses.insert("404".into(), error_response("It does not exist, or you cannot see it."));
850 }
851 if route.method != "GET" {
852 responses.insert(
853 "409".into(),
854 error_response("The request conflicts with the current state."),
855 );
856 }
857 if op != Op::Whoami {
858 responses.insert("422".into(), error_response("The input is not valid."));
859 }
860 // 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 step861 let scope: Vec<&str> = scope_for(op.name()).map(|scope| scope.as_str()).into_iter().collect();
Merge branch 'worktree-agent-ab2e39e11a6493412'862 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 step863 json!([{ "token": scope }])
Webhooks: every event, to your own addresses, signed and retried864 } else {
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step865 json!([{ "token": scope }, {}])
Webhooks: every event, to your own addresses, signed and retried866 };
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step867 let (tool, action) = crate::tools::TOOLS
868 .iter()
869 .find_map(|tool| {
870 tool.actions
871 .iter()
872 .find(|action| action.op == op)
873 .map(|action| (tool.name, action.name))
874 })
875 .unwrap_or_default();
API and MCP server in Rust; a public index at the API root876 let mut described = json!({
Webhooks: every event, to your own addresses, signed and retried877 "operationId": id,
API and MCP server in Rust; a public index at the API root878 "tags": [tag(op)],
Merge branch 'worktree-agent-ab2e39e11a6493412'879 "summary": summary(route, &id),
API and MCP server in Rust; a public index at the API root880 "description": op.description(),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step881 "x-operation": op.name(),
882 "x-mcp-tool": tool,
883 "x-mcp-action": action,
884 "x-scope": scope.first().copied(),
Merge branch 'worktree-agent-ab2e39e11a6493412'885 "security": security,
API and MCP server in Rust; a public index at the API root886 "parameters": parameters,
Merge branch 'worktree-agent-ab2e39e11a6493412'887 "responses": responses,
API and MCP server in Rust; a public index at the API root888 });
889 if !body.is_null() {
890 described["requestBody"] = body;
891 }
892 described
893}
894
895/// Entries for device sign-in, which is not an operation.
896fn onboarding() -> Map<String, Value> {
897 let paths = json!({
Agents as a team: lifecycle, merge queue, billing and a new shell898 "/device/code": {
API and MCP server in Rust; a public index at the API root899 "post": {
900 "operationId": "device_code",
901 "tags": ["Accounts"],
902 "summary": "Start signing in",
Agents as a team: lifecycle, merge queue, billing and a new shell903 "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 root904 "security": [],
905 "requestBody": {
906 "content": { "application/json": { "schema": {
907 "type": "object",
908 "properties": {
909 "client_name": {
910 "type": "string",
911 "description": "What is asking, shown to the person approving. For example, Claude Code.",
912 },
913 },
914 } } },
915 },
916 "responses": { "200": {
917 "description": "The codes for this sign-in.",
918 "content": { "application/json": { "schema": {
919 "type": "object",
920 "properties": {
Agents as a team: lifecycle, merge queue, billing and a new shell921 "device_code": { "type": "string", "description": "Secret. Send it to /device/token." },
API and MCP server in Rust; a public index at the API root922 "user_code": { "type": "string", "description": "Shown to the person, like WDJB-MJHT." },
923 "verification_uri": { "type": "string" },
924 "verification_uri_complete": {
925 "type": "string",
926 "description": "The link to give the person; it carries the code.",
927 },
928 "expires_in": { "type": "integer", "description": "Seconds until the codes expire." },
929 "interval": { "type": "integer", "description": "Seconds to wait between polls." },
930 },
931 } } },
932 } },
933 },
934 },
Agents as a team: lifecycle, merge queue, billing and a new shell935 "/device/token": {
API and MCP server in Rust; a public index at the API root936 "post": {
937 "operationId": "device_token",
938 "tags": ["Accounts"],
939 "summary": "Finish signing in",
940 "description": "Asks whether the person has approved. Poll no faster than the interval. The token is returned once.",
941 "security": [],
942 "requestBody": {
943 "required": true,
944 "content": { "application/json": { "schema": {
945 "type": "object",
946 "required": ["device_code"],
947 "properties": { "device_code": { "type": "string" } },
948 } } },
949 },
950 "responses": { "200": {
951 "description": "The state of the sign-in.",
952 "content": { "application/json": { "schema": {
953 "type": "object",
954 "required": ["status"],
955 "properties": {
956 "status": { "type": "string", "enum": ["pending", "approved", "denied", "expired"] },
957 "token": { "type": "string", "description": "Present when approved." },
958 "username": { "type": "string" },
959 "verified": {
960 "type": "boolean",
961 "description": "Whether the account's email is confirmed.",
962 },
963 },
964 } } },
965 } },
966 },
967 },
968 });
969 match paths {
970 Value::Object(paths) => paths,
971 _ => Map::new(),
972 }
973}
974
Merge branch 'worktree-agent-ab2e39e11a6493412'975
976/// Puts each operation's examples, where it has them, into its request
977/// and response. Path and query values go under `x-example-params` and
978/// `x-example-query`, which tools that build a request can use.
979fn attach_examples(paths: &mut Map<String, Value>) {
980 let examples = examples();
981 for methods in paths.values_mut() {
982 let Some(methods) = methods.as_object_mut() else { continue };
983 for operation in methods.values_mut() {
984 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 step985 let name = operation["x-operation"].as_str().unwrap_or_default().to_owned();
986 let Some(example) = examples.get(&id).or_else(|| examples.get(&name)) else {
Merge branch 'worktree-agent-ab2e39e11a6493412'987 continue;
988 };
989 if let Some(notes) = example.get("notes").and_then(Value::as_str) {
990 let description = operation["description"].as_str().unwrap_or_default();
991 operation["description"] = json!(format!("{description}\n\n{notes}"));
992 }
993 if let Some(response) = example.get("response") {
994 let content = &mut operation["responses"]["200"]["content"]["application/json"];
995 if content.is_object() {
996 content["example"] = response.clone();
997 }
998 }
999 if let Some(request) = example.get("request") {
1000 let content = &mut operation["requestBody"]["content"]["application/json"];
1001 if content.is_object() {
1002 content["example"] = request.clone();
1003 }
1004 }
1005 for (key, extension) in [("params", "x-example-params"), ("query", "x-example-query")] {
1006 if let Some(values) = example.get(key) {
1007 operation[extension] = values.clone();
1008 }
1009 }
1010 }
1011 }
1012}
1013
API and MCP server in Rust; a public index at the API root1014pub fn document() -> Value {
1015 let mut paths = onboarding();
1016 for route in ROUTES {
1017 let entry = paths
1018 .entry(openapi_path(route))
1019 .or_insert_with(|| json!({}));
1020 entry[route.method.to_lowercase()] = operation(route);
1021 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1022 attach_examples(&mut paths);
1023 let tags: Vec<Value> = SECTIONS
1024 .iter()
1025 .map(|(name, description, ops)| {
1026 json!({
1027 "name": name,
1028 "description": description,
1029 // The section's operations in reading order, by MCP tool name.
1030 "x-tools": ops.iter().map(|op| op.name()).collect::<Vec<_>>(),
1031 })
1032 })
1033 .collect();
1034 let codes = ["unauthenticated", "payment_required", "forbidden", "not_found", "conflict", "invalid"];
API and MCP server in Rust; a public index at the API root1035 json!({
1036 "openapi": "3.1.0",
1037 "info": {
1038 "title": "g1t API",
1039 "version": "1",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1040 "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 root1041 "license": { "name": "MIT", "identifier": "MIT" },
1042 },
1043 "servers": [{ "url": "https://api.g1t.sh" }],
1044 "security": [{ "token": [] }, {}],
Merge branch 'worktree-agent-ab2e39e11a6493412'1045 "tags": tags,
API and MCP server in Rust; a public index at the API root1046 "paths": paths,
1047 "components": {
1048 "securitySchemes": {
1049 "token": {
1050 "type": "http",
1051 "scheme": "bearer",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1052 "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 root1053 },
1054 },
1055 "schemas": {
1056 "Error": {
1057 "type": "object",
1058 "required": ["error"],
1059 "properties": {
1060 "error": {
1061 "type": "object",
1062 "required": ["code", "message"],
1063 "properties": {
Merge branch 'worktree-agent-ab2e39e11a6493412'1064 "code": { "type": "string", "enum": codes },
API and MCP server in Rust; a public index at the API root1065 "message": { "type": "string" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1066 "needed_scope": {
1067 "type": "string",
1068 "description": "On a 403 for an access token without the scope the call needs: that scope, such as `issues:write`.",
1069 },
API and MCP server in Rust; a public index at the API root1070 },
1071 },
1072 },
1073 },
1074 },
1075 },
1076 })
1077}
1078
1079#[cfg(test)]
1080mod tests {
1081 use super::*;
1082
1083 #[test]
1084 fn every_route_is_documented_once() {
1085 let document = document();
1086 let mut ids = Vec::new();
1087 for (_, methods) in document["paths"].as_object().unwrap() {
1088 for (_, operation) in methods.as_object().unwrap() {
1089 ids.push(operation["operationId"].as_str().unwrap().to_owned());
1090 }
1091 }
1092 for op in Op::ALL {
1093 assert_eq!(
1094 ids.iter().filter(|id| *id == op.name()).count(),
1095 1,
1096 "{}",
1097 op.name()
1098 );
1099 }
Webhooks: every event, to your own addresses, signed and retried1100 let mut unique = ids.clone();
1101 unique.sort();
1102 unique.dedup();
1103 assert_eq!(unique.len(), ids.len(), "operation ids repeat");
API and MCP server in Rust; a public index at the API root1104 }
1105
1106 #[test]
1107 fn path_and_query_inputs_are_not_repeated_in_the_body() {
1108 let document = document();
Agents as a team: lifecycle, merge queue, billing and a new shell1109 let merge = &document["paths"]["/repos/{owner}/{name}/pulls/{number}/merge"]["post"];
API and MCP server in Rust; a public index at the API root1110 let body = &merge["requestBody"]["content"]["application/json"]["schema"]["properties"];
1111 assert!(body.get("keep_issue_open").is_some());
1112 assert!(body.get("repo").is_none() && body.get("number").is_none());
Agents as a team: lifecycle, merge queue, billing and a new shell1113 let list = &document["paths"]["/repos"]["get"];
API and MCP server in Rust; a public index at the API root1114 assert_eq!(list["parameters"][0]["name"], "q");
1115 assert!(list.get("requestBody").is_none());
1116 }
1117
1118 #[test]
Merge branch 'worktree-agent-ab2e39e11a6493412'1119 fn every_operation_is_in_one_section() {
1120 for op in Op::ALL {
1121 let sections = SECTIONS
1122 .iter()
1123 .filter(|(_, _, ops)| ops.contains(&op))
1124 .count();
1125 assert_eq!(sections, 1, "{}", op.name());
1126 }
1127 }
1128
1129 #[test]
API and MCP server in Rust; a public index at the API root1130 fn titles_read_as_sentences() {
Merge branch 'worktree-agent-ab2e39e11a6493412'1131 assert_eq!(title(Op::CreateIssue), "Create an issue");
API and MCP server in Rust; a public index at the API root1132 assert_eq!(title(Op::Whoami), "Get the current user");
1133 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1134
1135 #[test]
1136 fn every_operation_has_an_example_response() {
1137 let examples = examples();
1138 assert!(!examples.is_empty(), "reference.json does not parse");
1139 let document = document();
1140 let mut known = Vec::new();
1141 for (path, methods) in document["paths"].as_object().unwrap() {
1142 for (method, operation) in methods.as_object().unwrap() {
1143 known.push(operation["operationId"].as_str().unwrap().to_owned());
1144 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1145 assert!(!example.is_null(), "{method} {path} has no example response");
1146 }
1147 }
1148 for id in examples.keys() {
1149 assert!(known.contains(id), "reference.json names {id}, which is not an operation");
1150 }
1151 }
1152
1153 #[test]
1154 fn example_requests_send_only_what_the_body_takes() {
1155 let document = document();
1156 for (path, methods) in document["paths"].as_object().unwrap() {
1157 for (method, operation) in methods.as_object().unwrap() {
1158 let content = &operation["requestBody"]["content"]["application/json"];
1159 let Some(example) = content["example"].as_object() else { continue };
1160 let properties = &content["schema"]["properties"];
1161 for key in example.keys() {
1162 assert!(!properties[key].is_null(), "{method} {path}: {key} is not in the body");
1163 }
1164 }
1165 }
1166 }
1167
1168 /// The docs site's copy of the document. Run with `G1T_WRITE_OPENAPI=1`
1169 /// to rewrite it after changing an operation.
1170 #[test]
1171 fn the_docs_copy_is_current() {
1172 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../docs/src/data/openapi.json");
1173 let current = serde_json::to_string_pretty(&document()).unwrap() + "\n";
1174 if std::env::var_os("G1T_WRITE_OPENAPI").is_some() {
1175 std::fs::write(path, &current).unwrap();
1176 return;
1177 }
1178 let copy = std::fs::read_to_string(path).unwrap_or_default().replace("\r\n", "\n");
1179 assert!(
1180 copy == current,
1181 "apps/docs/src/data/openapi.json is out of date: run G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi"
1182 );
1183 }
API reference: no example reads as a real secret1184
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1185 /// The reference shows responses as they are sent: `snake_case`.
1186 #[test]
1187 fn example_responses_are_snake_case() {
1188 let document = document();
1189 for (path, methods) in document["paths"].as_object().unwrap() {
1190 for (method, operation) in methods.as_object().unwrap() {
1191 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1192 let leaked = g1t_kit::wire::camel_case_keys(example);
1193 assert!(leaked.is_empty(), "{method} {path} shows {leaked:?}");
1194 }
1195 }
1196 }
1197
API reference: no example reads as a real secret1198 /// Examples never hold anything that reads as a real credential, which
1199 /// secret scanners rightly flag in a public repository: they end in `…`
1200 /// after the prefix, as `whsec_…` and `g1t_…` do.
1201 #[test]
1202 fn examples_hold_no_real_looking_secrets() {
Fast pages, required checks on the branch, self-hosted runners, honest incidents1203 let prefixes = ["whsec_", "g1t_", "g1tr_", "g1trt_", "sk_live_", "sk_test_", "ghp_", "github_pat_", "xoxb-", "AKIA"];
API reference: no example reads as a real secret1204 for (line, text) in REFERENCE.lines().enumerate() {
1205 for prefix in prefixes {
1206 let mut rest = text;
1207 while let Some(at) = rest.find(prefix) {
1208 let after = &rest[at + prefix.len()..];
1209 let run = after.chars().take_while(|c| c.is_ascii_alphanumeric()).count();
1210 assert!(
1211 run < 12,
1212 "reference.json line {}: `{prefix}` followed by {run} characters reads as a real secret; write `{prefix}…`",
1213 line + 1
1214 );
1215 rest = after;
1216 }
1217 }
1218 }
1219 }
API and MCP server in Rust; a public index at the API root1220}

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