Skip to content
1,146 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
10use crate::operations::Op;
Checks: statuses and check runs on every commit, for CI and integrations11use crate::checks::ChecksOp;
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge12use crate::rules::RulesOp;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar13use crate::security::SecurityOp;
API and MCP server in Rust; a public index at the API root14use crate::rest::{ROUTES, Route};
15
Merge branch 'worktree-agent-ab2e39e11a6493412'16/// The sections of the API reference: a name, what it covers, and its
17/// operations in the order a reader meets them.
18const SECTIONS: &[(&str, &str, &[Op])] = &[
19 (
20 "Accounts",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look21 "Signing in from a tool, who a token acts as, and your email addresses.",
22 &[Op::Whoami, Op::ListEmails, Op::AddEmail, Op::RemoveEmail, Op::UpdateEmailSettings],
Merge branch 'worktree-agent-ab2e39e11a6493412'23 ),
24 (
API: notifications over REST and MCP, with notifications scopes25 "Notifications",
26 "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.",
27 &[
28 Op::ListNotifications,
29 Op::MarkNotificationsRead,
30 Op::GetNotificationThread,
31 Op::MarkThreadRead,
32 Op::MarkThreadDone,
33 Op::SaveThread,
34 Op::SnoozeThread,
35 Op::GetThreadSubscription,
36 Op::SetThreadSubscription,
37 Op::DeleteThreadSubscription,
38 Op::GetRepoSubscription,
39 Op::SetRepoSubscription,
40 Op::DeleteRepoSubscription,
41 Op::ListWatchedRepos,
42 ],
43 ),
44 (
API: pinned projects over REST and MCP45 "Pinned projects",
46 "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.",
47 &[Op::ListPinnedProjects, Op::PinProject, Op::UnpinProject, Op::ReorderPinnedProjects],
48 ),
49 (
Merge branch 'worktree-agent-ab2e39e11a6493412'50 "Workspaces",
51 "A workspace owns repositories and is the first part of their address. People and agents work in workspaces.",
Merge branch 'worktree-agent-ad7c6d88d93adc817'52 &[Op::GetWorkspace, Op::CreateWorkspace, Op::UpdateWorkspace, Op::DeleteWorkspace],
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look53 ),
54 (
55 "Invites",
56 "While g1t is invite-only, every new account needs an invite. Your invites, and inviting people into a workspace by email.",
57 &[
58 Op::ListInvites,
59 Op::CreateInvite,
60 Op::RevokeInvite,
61 Op::ListWorkspaceInvites,
62 Op::InviteMember,
63 Op::RevokeWorkspaceInvite,
64 ],
Merge branch 'worktree-agent-ab2e39e11a6493412'65 ),
66 (
Usage, Billing settings and prepaid AI credit; fixes from the UX audit67 "Billing",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens68 "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 audit69 &[
70 Op::GetUsage,
71 Op::GetBudget,
72 Op::SetBudget,
73 Op::GetAiCredit,
74 Op::BuyAiCredit,
75 Op::ListInvoices,
76 Op::GetBillingDetails,
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens77 Op::ListGatewayRequests,
Usage, Billing settings and prepaid AI credit; fixes from the UX audit78 ],
79 ),
80 (
Merge branch 'worktree-agent-ab2e39e11a6493412'81 "Repositories",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look82 "A repository, how it handles pull requests, and its timeline: renaming, archiving, moving and deleting it.",
Merge branch 'worktree-agent-ab2e39e11a6493412'83 &[
84 Op::ListRepos,
85 Op::CreateRepo,
86 Op::GetRepo,
87 Op::UpdateRepo,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look88 Op::RenameRepo,
89 Op::RenameBranch,
90 Op::SetRepoVisibility,
91 Op::ArchiveRepo,
92 Op::UnarchiveRepo,
93 Op::TransferRepo,
94 Op::DeleteRepo,
95 Op::ListDeletedRepos,
96 Op::RestoreRepo,
97 Op::PurgeRepo,
Merge branch 'worktree-agent-ab2e39e11a6493412'98 Op::GetRepoSettings,
99 Op::UpdateRepoSettings,
Fast pages, required checks on the branch, self-hosted runners, honest incidents100 Op::ListCheckNames,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar101 Op::GetCodeownersErrors,
Merge branch 'worktree-agent-ab2e39e11a6493412'102 Op::ListEvents,
103 ],
104 ),
105 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look106 "Access",
107 "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.",
108 &[
109 Op::ListCollaborators,
110 Op::AddCollaborator,
111 Op::UpdateCollaborator,
112 Op::RemoveCollaborator,
113 Op::GetCollaboratorPermission,
114 Op::ListRepoInvitations,
115 Op::RevokeRepoInvitation,
116 Op::ListMyRepoInvitations,
117 Op::AcceptRepoInvitation,
118 Op::DeclineRepoInvitation,
119 Op::SetBasePermission,
120 Op::ListOutsideCollaborators,
121 ],
122 ),
123 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar124 "Teams",
125 "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.",
126 &[
127 Op::ListTeams,
128 Op::CreateTeam,
129 Op::GetTeam,
130 Op::UpdateTeam,
131 Op::DeleteTeam,
132 Op::ListTeamMembers,
133 Op::SetTeamMember,
134 Op::RemoveTeamMember,
135 Op::ListChildTeams,
136 Op::ListTeamRepos,
137 Op::SetTeamRepo,
138 Op::RemoveTeamRepo,
139 Op::SetTeamReviewAssignment,
140 Op::ListUserTeams,
141 ],
142 ),
143 (
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily144 "Security",
145 "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.",
146 &[Op::ListSecurityAlerts, Op::DismissSecurityAlert, Op::ReopenSecurityAlert],
147 ),
148 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar149 "Secret scanning",
150 "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.",
151 &[
152 Op::Security(SecurityOp::ListSecretAlerts),
153 Op::Security(SecurityOp::GetSecretAlert),
154 Op::Security(SecurityOp::UpdateSecretAlert),
155 Op::Security(SecurityOp::ListSecretLocations),
156 Op::Security(SecurityOp::BypassPushProtection),
157 Op::Security(SecurityOp::CheckSecretValidity),
158 Op::Security(SecurityOp::ListBypassRequests),
159 Op::Security(SecurityOp::ReviewBypassRequest),
160 Op::Security(SecurityOp::ListCustomPatterns),
161 Op::Security(SecurityOp::CreateCustomPattern),
162 Op::Security(SecurityOp::UpdateCustomPattern),
163 Op::Security(SecurityOp::DeleteCustomPattern),
164 Op::Security(SecurityOp::DryRunCustomPattern),
165 ],
166 ),
167 (
168 "Code scanning",
169 "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.",
170 &[
171 Op::Security(SecurityOp::ListCodeAlerts),
172 Op::Security(SecurityOp::GetCodeAlert),
173 Op::Security(SecurityOp::UpdateCodeAlert),
174 Op::Security(SecurityOp::ListAnalyses),
175 Op::Security(SecurityOp::UploadSarif),
176 Op::Security(SecurityOp::GetSarifUpload),
177 Op::Security(SecurityOp::FixAlert),
178 ],
179 ),
180 (
181 "Supply chain",
182 "What a repository depends on: vulnerability alerts, the dependency graph, an SPDX SBOM of it, and comparing two commits' dependencies as dependency review does.",
183 &[
184 Op::Security(SecurityOp::ListVulnerabilityAlerts),
185 Op::Security(SecurityOp::GetVulnerabilityAlert),
186 Op::Security(SecurityOp::UpdateVulnerabilityAlert),
187 Op::Security(SecurityOp::GetDependencyGraph),
188 Op::Security(SecurityOp::GetSbom),
189 Op::Security(SecurityOp::CompareDependencies),
190 ],
191 ),
192 (
193 "Security settings",
194 "When pull request checks fail, dependency review's policy, delegated bypass and validity checks, and a workspace's security overview.",
195 &[
196 Op::Security(SecurityOp::GetSettings),
197 Op::Security(SecurityOp::UpdateSettings),
198 Op::Security(SecurityOp::GetWorkspaceSettings),
199 Op::Security(SecurityOp::UpdateWorkspaceSettings),
200 Op::Security(SecurityOp::GetOverview),
201 ],
202 ),
203 (
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge204 "Rules",
205 "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.",
206 &[
207 Op::Rules(RulesOp::ListRepoRulesets),
208 Op::Rules(RulesOp::CreateRepoRuleset),
209 Op::Rules(RulesOp::GetRepoRuleset),
210 Op::Rules(RulesOp::UpdateRepoRuleset),
211 Op::Rules(RulesOp::DeleteRepoRuleset),
212 Op::Rules(RulesOp::GetBranchRules),
213 Op::Rules(RulesOp::ListRuleEvaluations),
214 Op::Rules(RulesOp::ListWorkspaceRulesets),
215 Op::Rules(RulesOp::CreateWorkspaceRuleset),
216 Op::Rules(RulesOp::GetWorkspaceRuleset),
217 Op::Rules(RulesOp::UpdateWorkspaceRuleset),
218 Op::Rules(RulesOp::DeleteWorkspaceRuleset),
219 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
220 ],
221 ),
222 (
Checks: statuses and check runs on every commit, for CI and integrations223 "Checks",
224 "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.",
225 &[
226 Op::Checks(ChecksOp::CreateCommitStatus),
227 Op::Checks(ChecksOp::ListCommitStatuses),
228 Op::Checks(ChecksOp::GetCombinedStatus),
229 Op::Checks(ChecksOp::CreateCheckRun),
230 Op::Checks(ChecksOp::UpdateCheckRun),
231 Op::Checks(ChecksOp::GetCheckRun),
232 Op::Checks(ChecksOp::ListCheckRunAnnotations),
233 Op::Checks(ChecksOp::RerequestCheckRun),
234 Op::Checks(ChecksOp::ListCheckRunsForRef),
235 Op::Checks(ChecksOp::ListCheckSuitesForRef),
236 Op::Checks(ChecksOp::GetCheckSuite),
237 Op::Checks(ChecksOp::RerequestCheckSuite),
238 ],
239 ),
240 (
Merge branch 'worktree-agent-ab2e39e11a6493412'241 "Issues",
242 "What should change in a repository, with labels and comments. Issues and pull requests share one sequence of numbers.",
243 &[
244 Op::ListIssues,
245 Op::CreateIssue,
246 Op::GetIssue,
247 Op::UpdateIssue,
248 Op::CloseIssue,
249 Op::ReopenIssue,
250 Op::AssignIssue,
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step251 Op::Delegate,
Merge branch 'worktree-agent-ab2e39e11a6493412'252 Op::AddComment,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar253 Op::ListIssueLabels,
254 Op::AddIssueLabels,
255 Op::SetIssueLabels,
256 Op::RemoveIssueLabels,
257 ],
258 ),
259 (
260 "Labels and milestones",
261 "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.",
262 &[
Merge branch 'worktree-agent-ab2e39e11a6493412'263 Op::ListLabels,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar264 Op::CreateLabel,
265 Op::UpdateLabel,
266 Op::DeleteLabel,
267 Op::AddDefaultLabels,
268 Op::ListMilestones,
269 Op::CreateMilestone,
270 Op::GetMilestone,
271 Op::UpdateMilestone,
272 Op::DeleteMilestone,
Merge branch 'worktree-agent-ab2e39e11a6493412'273 ],
274 ),
275 (
276 "Plans",
277 "An outcome turned into the issues that would get there, with the order they must merge in.",
278 &[Op::PlanWork, Op::GetPlan, Op::ApplyPlan],
279 ),
280 (
281 "Pull requests",
282 "A proposed change in its own fork or on a branch. Several can be made for one issue; the one merged resolves it.",
283 &[
284 Op::ListPullRequests,
285 Op::CreatePullRequest,
286 Op::GetPullRequest,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar287 Op::UpdatePullRequest,
Merge branch 'worktree-agent-ab2e39e11a6493412'288 Op::GetPullRequestChanges,
289 Op::MarkPullRequestReady,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar290 Op::RequestReviewers,
291 Op::RemoveRequestedReviewers,
Merge branch 'worktree-agent-ab2e39e11a6493412'292 Op::ReviewPullRequest,
293 Op::MergePullRequest,
294 Op::ClosePullRequest,
295 Op::GetMergeQueue,
296 Op::MessageAgent,
297 Op::AnswerMessage,
298 Op::TakeMessages,
299 ],
300 ),
301 (
302 "Sessions",
303 "The record of how a pull request was made: prompts, reasoning and the tools that ran.",
304 &[Op::ReadSession, Op::RecordSession],
305 ),
306 (
Agents and memory, checks and conflicts, profiles, slug renames, custom domains307 "Memory",
308 "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.",
309 &[Op::Remember, Op::Recall],
310 ),
311 (
Search across all of g1t, Explore, and a command palette312 "Search",
313 "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.",
314 &[Op::Search],
315 ),
316 (
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API317 "Context",
318 "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.",
319 &[Op::SearchContext, Op::GetEntity],
320 ),
321 (
Merge branch 'worktree-agent-ab2e39e11a6493412'322 "Actions",
323 "GitHub Actions workflows in .g1t/workflows, their runs, and their jobs' logs.",
324 &[
325 Op::ListWorkflows,
326 Op::ListWorkflowRuns,
327 Op::GetWorkflowRun,
328 Op::GetJobLogs,
329 Op::DispatchWorkflow,
330 Op::CancelWorkflowRun,
331 Op::RerunWorkflowRun,
332 Op::UpdateWorkflow,
333 ],
334 ),
335 (
336 "Secrets and variables",
337 "Values that workflows and deployments read, per repository or for a whole workspace, with a row per environment.",
338 &[
339 Op::ListActionsSecrets,
340 Op::SetActionsSecret,
341 Op::DeleteActionsSecret,
342 Op::ListActionsVariables,
343 Op::SetActionsVariable,
344 Op::DeleteActionsVariable,
345 ],
346 ),
347 (
Fast pages, required checks on the branch, self-hosted runners, honest incidents348 "Runners",
349 "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.",
350 &[
351 Op::ListRunners,
352 Op::CreateRunnerRegistrationToken,
353 Op::RemoveRunner,
354 Op::ListRunnerGroups,
355 Op::CreateRunnerGroup,
356 Op::UpdateRunnerGroup,
357 Op::DeleteRunnerGroup,
358 Op::GetRunnerSettings,
359 Op::UpdateRunnerSettings,
360 ],
361 ),
362 (
Merge branch 'worktree-agent-ab2e39e11a6493412'363 "Webhooks",
364 "Signed HTTPS requests sent to your own address as things happen, for a repository or a whole workspace.",
365 &[
366 Op::ListWebhooks,
367 Op::CreateWebhook,
368 Op::UpdateWebhook,
369 Op::DeleteWebhook,
370 Op::PingWebhook,
371 Op::ListWebhookDeliveries,
372 Op::RedeliverWebhook,
373 ],
374 ),
375 (
376 "Integrations",
377 "A workspace's connections to outside systems: model providers, alert sources and issue trackers.",
378 &[
379 Op::ListIntegrations,
380 Op::ConnectIntegration,
381 Op::DisconnectIntegration,
382 Op::TestIntegration,
383 Op::GetModelRoutes,
384 Op::SetModelRoutes,
385 Op::GetContext,
386 Op::ImportIssue,
387 ],
388 ),
389];
390
API and MCP server in Rust; a public index at the API root391/// The section of the API reference an operation is listed under.
392fn tag(op: Op) -> &'static str {
Merge branch 'worktree-agent-ab2e39e11a6493412'393 SECTIONS
API and MCP server in Rust; a public index at the API root394 .iter()
Merge branch 'worktree-agent-ab2e39e11a6493412'395 .find(|(_, _, ops)| ops.contains(&op))
396 .map_or("Repositories", |(name, _, _)| name)
397}
398
399/// What an operation's page is called, as a short sentence.
400fn title(op: Op) -> &'static str {
401 match op {
402 Op::Whoami => "Get the current user",
Merge branch 'worktree-agent-ad7c6d88d93adc817'403 Op::GetWorkspace => "Get a workspace",
Merge branch 'worktree-agent-ab2e39e11a6493412'404 Op::CreateWorkspace => "Create a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look405 Op::DeleteWorkspace => "Delete a workspace",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily406 Op::UpdateWorkspace => "Update a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look407 Op::ListEmails => "List your email addresses",
408 Op::AddEmail => "Add an email address",
409 Op::RemoveEmail => "Remove an email address",
410 Op::UpdateEmailSettings => "Change your email settings",
411 Op::ListInvites => "List your invites",
412 Op::CreateInvite => "Create an invite",
413 Op::RevokeInvite => "Revoke an invite",
414 Op::ListWorkspaceInvites => "List a workspace's invites",
415 Op::InviteMember => "Invite someone to a workspace",
416 Op::RevokeWorkspaceInvite => "Revoke a workspace's invite",
417 Op::TransferRepo => "Transfer a repository",
418 Op::RenameRepo => "Rename a repository",
419 Op::RenameBranch => "Rename a branch",
420 Op::ArchiveRepo => "Archive a repository",
421 Op::UnarchiveRepo => "Unarchive a repository",
422 Op::SetRepoVisibility => "Change a repository's visibility",
423 Op::DeleteRepo => "Delete a repository",
424 Op::ListDeletedRepos => "List recently deleted repositories",
425 Op::RestoreRepo => "Restore a deleted repository",
426 Op::PurgeRepo => "Purge a deleted repository",
Merge branch 'worktree-agent-ab2e39e11a6493412'427 Op::ListRepos => "List repositories",
428 Op::GetRepo => "Get a repository",
429 Op::CreateRepo => "Create a repository",
430 Op::UpdateRepo => "Update a repository",
431 Op::GetRepoSettings => "Get repository settings",
432 Op::UpdateRepoSettings => "Update repository settings",
Fast pages, required checks on the branch, self-hosted runners, honest incidents433 Op::ListCheckNames => "List check names",
Merge branch 'worktree-agent-ab2e39e11a6493412'434 Op::GetMergeQueue => "Get the merge queue",
435 Op::MessageAgent => "Message an agent",
436 Op::AnswerMessage => "Answer a message",
437 Op::TakeMessages => "Take new messages",
Agents and memory, checks and conflicts, profiles, slug renames, custom domains438 Op::Remember => "Remember something",
439 Op::Recall => "Recall memory",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API440 Op::SearchContext => "Search the context hub",
441 Op::GetEntity => "Get a catalog entry",
Search across all of g1t, Explore, and a command palette442 Op::Search => "Search g1t",
Merge branch 'worktree-agent-ab2e39e11a6493412'443 Op::ListIssues => "List issues",
444 Op::GetIssue => "Get an issue",
445 Op::CreateIssue => "Create an issue",
446 Op::UpdateIssue => "Update an issue",
447 Op::CloseIssue => "Close an issue",
448 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-agent449 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 step450 Op::Delegate => "Put an agent on it",
Merge branch 'worktree-agent-ab2e39e11a6493412'451 Op::PlanWork => "Plan work",
452 Op::GetPlan => "Get a plan",
453 Op::ApplyPlan => "Apply a plan",
454 Op::ListLabels => "List labels",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar455 Op::CreateLabel => "Create a label",
456 Op::UpdateLabel => "Update a label",
457 Op::DeleteLabel => "Delete a label",
458 Op::AddDefaultLabels => "Add the default labels",
459 Op::ListIssueLabels => "List an issue's labels",
460 Op::AddIssueLabels => "Add labels to an issue",
461 Op::SetIssueLabels => "Set an issue's labels",
462 Op::RemoveIssueLabels => "Remove labels from an issue",
463 Op::ListMilestones => "List milestones",
464 Op::GetMilestone => "Get a milestone",
465 Op::CreateMilestone => "Create a milestone",
466 Op::UpdateMilestone => "Update a milestone",
467 Op::DeleteMilestone => "Delete a milestone",
468 Op::UpdatePullRequest => "Update a pull request",
Merge branch 'worktree-agent-ab2e39e11a6493412'469 Op::AddComment => "Add a comment",
470 Op::ReviewPullRequest => "Review a pull request",
471 Op::ListPullRequests => "List pull requests",
472 Op::GetPullRequest => "Get a pull request",
473 Op::CreatePullRequest => "Create a pull request",
474 Op::RecordSession => "Record session entries",
475 Op::ReadSession => "Read a session",
476 Op::MarkPullRequestReady => "Mark a pull request ready",
477 Op::ClosePullRequest => "Close a pull request",
478 Op::GetPullRequestChanges => "Get a pull request's changes",
479 Op::MergePullRequest => "Merge a pull request",
480 Op::ListEvents => "List repository events",
481 Op::ListIntegrations => "List integrations",
482 Op::ConnectIntegration => "Connect an integration",
483 Op::DisconnectIntegration => "Disconnect an integration",
484 Op::TestIntegration => "Test an integration",
485 Op::GetContext => "Look up a ticket",
486 Op::ImportIssue => "Import an issue",
487 Op::GetModelRoutes => "Get model routes",
488 Op::SetModelRoutes => "Set model routes",
489 Op::ListWebhooks => "List webhooks",
490 Op::CreateWebhook => "Create a webhook",
491 Op::UpdateWebhook => "Update a webhook",
492 Op::DeleteWebhook => "Delete a webhook",
493 Op::PingWebhook => "Ping a webhook",
494 Op::ListWebhookDeliveries => "List webhook deliveries",
495 Op::RedeliverWebhook => "Redeliver a webhook delivery",
496 Op::ListWorkflows => "List workflows",
497 Op::ListWorkflowRuns => "List workflow runs",
498 Op::GetWorkflowRun => "Get a workflow run",
499 Op::GetJobLogs => "Get a job's log",
500 Op::DispatchWorkflow => "Run a workflow",
501 Op::CancelWorkflowRun => "Cancel a workflow run",
502 Op::RerunWorkflowRun => "Re-run a workflow run",
503 Op::UpdateWorkflow => "Turn a workflow on or off",
504 Op::ListActionsSecrets => "List secrets",
505 Op::SetActionsSecret => "Set a secret",
506 Op::DeleteActionsSecret => "Delete a secret",
507 Op::ListActionsVariables => "List variables",
508 Op::SetActionsVariable => "Set a variable",
509 Op::DeleteActionsVariable => "Delete a variable",
Fast pages, required checks on the branch, self-hosted runners, honest incidents510 Op::ListRunners => "List self-hosted runners",
511 Op::ListRunnerGroups => "List runner groups",
512 Op::GetRunnerSettings => "Get runner settings",
513 Op::CreateRunnerRegistrationToken => "Create a runner registration token",
514 Op::RemoveRunner => "Remove a self-hosted runner",
515 Op::CreateRunnerGroup => "Create a runner group",
516 Op::UpdateRunnerGroup => "Change a runner group",
517 Op::DeleteRunnerGroup => "Delete a runner group",
518 Op::UpdateRunnerSettings => "Change runner settings",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look519 Op::ListCollaborators => "List who has access",
520 Op::AddCollaborator => "Add a collaborator",
521 Op::UpdateCollaborator => "Change a collaborator's role",
522 Op::RemoveCollaborator => "Remove a collaborator",
523 Op::GetCollaboratorPermission => "Get someone's permission",
524 Op::ListRepoInvitations => "List a repository's invitations",
525 Op::RevokeRepoInvitation => "Revoke a repository invitation",
526 Op::ListMyRepoInvitations => "List your repository invitations",
527 Op::AcceptRepoInvitation => "Accept a repository invitation",
528 Op::DeclineRepoInvitation => "Decline a repository invitation",
529 Op::SetBasePermission => "Set the base permission",
530 Op::ListOutsideCollaborators => "List outside collaborators",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily531 Op::ListSecurityAlerts => "List security alerts",
532 Op::DismissSecurityAlert => "Dismiss a security alert",
533 Op::ReopenSecurityAlert => "Reopen a security alert",
API: notifications over REST and MCP, with notifications scopes534 Op::ListNotifications => "List notifications",
535 Op::MarkNotificationsRead => "Mark notifications read",
536 Op::GetNotificationThread => "Get a thread",
537 Op::MarkThreadRead => "Mark a thread read",
538 Op::MarkThreadDone => "Mark a thread done",
539 Op::SaveThread => "Save a thread",
540 Op::SnoozeThread => "Snooze a thread",
541 Op::GetThreadSubscription => "Get a thread subscription",
542 Op::SetThreadSubscription => "Set a thread subscription",
543 Op::DeleteThreadSubscription => "Unsubscribe from a thread",
544 Op::GetRepoSubscription => "Get how you watch a repository",
545 Op::SetRepoSubscription => "Watch a repository",
546 Op::DeleteRepoSubscription => "Stop watching a repository",
547 Op::ListWatchedRepos => "List repositories you watch",
API: pinned projects over REST and MCP548 Op::ListPinnedProjects => "List your pinned projects",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit549 Op::GetUsage => "Get a workspace's usage",
550 Op::GetBudget => "Get a workspace's budget",
551 Op::SetBudget => "Change a workspace's budget",
552 Op::GetAiCredit => "Get a workspace's AI credit",
553 Op::BuyAiCredit => "Buy AI credit",
554 Op::ListInvoices => "List a workspace's invoices",
555 Op::GetBillingDetails => "Get a workspace's billing details",
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens556 Op::ListGatewayRequests => "List a workspace's AI Gateway requests",
API: pinned projects over REST and MCP557 Op::PinProject => "Pin a project",
558 Op::UnpinProject => "Unpin a project",
559 Op::ReorderPinnedProjects => "Reorder your pinned projects",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar560 Op::ListTeams => "List teams",
561 Op::GetTeam => "Get a team",
562 Op::CreateTeam => "Create a team",
563 Op::UpdateTeam => "Update a team",
564 Op::DeleteTeam => "Delete a team",
565 Op::ListTeamMembers => "List a team's members",
566 Op::SetTeamMember => "Add or change a team member",
567 Op::RemoveTeamMember => "Remove a team member",
568 Op::ListChildTeams => "List child teams",
569 Op::ListTeamRepos => "List a team's repositories",
570 Op::SetTeamRepo => "Give a team a role on a repository",
571 Op::RemoveTeamRepo => "Remove a team from a repository",
572 Op::SetTeamReviewAssignment => "Set a team's review assignment",
573 Op::ListUserTeams => "List someone's teams",
574 Op::RequestReviewers => "Request reviewers",
575 Op::RemoveRequestedReviewers => "Remove requested reviewers",
576 Op::GetCodeownersErrors => "List CODEOWNERS errors",
577 Op::Security(op) => op.title(),
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge578 Op::Rules(op) => op.title(),
Checks: statuses and check runs on every commit, for CI and integrations579 Op::Checks(op) => op.title(),
API and MCP server in Rust; a public index at the API root580 }
581}
582
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look583/// Why an operation can be refused with `402 payment_required`, if it
584/// can: the ones that start an agent, when the workspace has no credit,
585/// and the ones that make a repository private in a workspace, when a free
586/// workspace's private storage has no room for it.
587fn may_need_payment(op: Op) -> Option<&'static str> {
588 match op {
589 Op::AssignIssue | Op::PlanWork | Op::ApplyPlan => Some("The workspace has no agent credit."),
590 Op::UpdateRepo | Op::SetRepoVisibility | Op::TransferRepo => Some(
591 "A free workspace's private storage has no room for this private repository.",
592 ),
593 _ => None,
594 }
Merge branch 'worktree-agent-ab2e39e11a6493412'595}
596
597/// What the reference says beyond each operation's own description, keyed
598/// by operation id, written by hand from what the services return: `notes`
599/// (Markdown, added to the description) and example `params` (path),
600/// `query`, `request` (body) and `response`.
601const REFERENCE: &str = include_str!("reference.json");
602
603fn examples() -> Map<String, Value> {
604 match serde_json::from_str(REFERENCE) {
605 Ok(Value::Object(examples)) => examples,
606 _ => Map::new(),
API and MCP server in Rust; a public index at the API root607 }
608}
609
Agents as a team: lifecycle, merge queue, billing and a new shell610/// `/repos/:owner/:name` as OpenAPI writes it: `/repos/{owner}/{name}`.
API and MCP server in Rust; a public index at the API root611fn openapi_path(route: &Route) -> String {
612 route
613 .path
614 .split('/')
615 .map(|segment| match segment.strip_prefix(':') {
616 Some(name) => format!("{{{name}}}"),
617 None => segment.to_owned(),
618 })
619 .collect::<Vec<_>>()
620 .join("/")
621}
622
623fn error_response(description: &str) -> Value {
624 json!({
625 "description": description,
626 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } },
627 })
628}
629
Merge branch 'worktree-agent-ab2e39e11a6493412'630/// A parameter in the path or the query, described by the operation's
631/// input schema where it has the same name.
632fn parameter(name: &str, place: &str, required: bool, schema: Option<&Value>) -> Value {
633 let mut schema = schema.cloned().unwrap_or_else(|| json!({ "type": "string" }));
634 let description = match name {
635 "owner" => Some(Value::from("The workspace that owns the repository.")),
636 "name" => Some(Value::from("The repository's name.")),
637 _ => schema.as_object_mut().and_then(|schema| schema.remove("description")),
638 };
639 let mut parameter = json!({
640 "name": name,
641 "in": place,
642 "required": required,
643 "schema": schema,
644 });
645 if let Some(description) = description {
646 parameter["description"] = description;
647 }
648 parameter
649}
650
651/// The operation id of a route. An operation reached at a workspace's
652/// address as well as a repository's is documented once for each, with its
653/// own id; GitHub's alternative addresses for one operation keep GitHub's
654/// names.
655fn operation_id(route: &Route) -> String {
656 let op = route.op;
657 let base = match (route.method, route.path.rsplit('/').next().unwrap_or_default()) {
658 ("PUT", "enable") => "enable_workflow".to_owned(),
659 ("PUT", "disable") => "disable_workflow".to_owned(),
660 ("POST", "rerun-failed-jobs") => "rerun_failed_jobs".to_owned(),
661 ("PATCH", ":setting") => "update_actions_variable".to_owned(),
662 ("GET", "runs") if route.path.contains("/workflows/:workflow/") => "list_runs_of_workflow".to_owned(),
API: notifications over REST and MCP, with notifications scopes663 // One repository's notifications, and an issue's subscription by
664 // its number rather than a thread's id.
665 (_, "notifications") if route.path.starts_with("/repos/") => match op {
666 Op::ListNotifications => "list_repo_notifications".to_owned(),
667 _ => "mark_repo_notifications_read".to_owned(),
668 },
669 (method, "subscription") if route.path.contains("/issues/:number/") => match method {
670 "GET" => "get_issue_subscription".to_owned(),
671 "PUT" => "set_issue_subscription".to_owned(),
672 _ => "delete_issue_subscription".to_owned(),
673 },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar674 // One label off an issue, by its name in the path.
675 ("DELETE", ":label") if route.path.contains("/issues/:number/") => "remove_issue_label".to_owned(),
API: notifications over REST and MCP, with notifications scopes676 ("DELETE", "saved") => "unsave_thread".to_owned(),
677 ("DELETE", "snooze") => "unsnooze_thread".to_owned(),
Merge branch 'worktree-agent-ab2e39e11a6493412'678 _ => op.name().to_owned(),
679 };
680 if route.path.starts_with("/workspaces/") && ROUTES.iter().any(|other| other.op == op && other.path.starts_with("/repos/")) {
681 format!("{base}_for_workspace")
682 } else {
683 base
684 }
685}
686
687/// The summary of a route: its operation's title, or for one of GitHub's
688/// alternative addresses, what that address does.
689fn summary(route: &Route, id: &str) -> String {
690 let base = match id.trim_end_matches("_for_workspace") {
691 "enable_workflow" => "Turn a workflow on",
692 "disable_workflow" => "Turn a workflow off",
693 "rerun_failed_jobs" => "Re-run failed jobs",
694 "update_actions_variable" => "Update a variable",
695 "list_runs_of_workflow" => "List a workflow's runs",
API: notifications over REST and MCP, with notifications scopes696 "list_repo_notifications" => "List a repository's notifications",
697 "mark_repo_notifications_read" => "Mark a repository's notifications read",
698 "get_issue_subscription" => "Get your subscription to an issue",
699 "set_issue_subscription" => "Subscribe to an issue",
700 "delete_issue_subscription" => "Unsubscribe from an issue",
701 "unsave_thread" => "Unsave a thread",
702 "unsnooze_thread" => "Bring a snoozed thread back",
Merge branch 'worktree-agent-ab2e39e11a6493412'703 _ => title(route.op),
704 };
705 if id.ends_with("_for_workspace") {
706 format!("{base} for a workspace")
707 } else {
708 base.to_owned()
709 }
710}
711
API and MCP server in Rust; a public index at the API root712fn operation(route: &Route) -> Value {
713 let op = route.op;
714 let path_params: Vec<&str> = route.params().collect();
Checks: statuses and check runs on every commit, for CI and integrations715 // `owner` and `name` in the path stand for the operation's `repo` input,
716 // so a `name` in the body, such as a check run's, is the body's own.
717 let stands_for_repo =
718 |name: &str| matches!(name, "owner" | "name") && path_params.contains(&"owner") && path_params.contains(&"name");
719 let covered = |name: &str| name == "repo" || (path_params.contains(&name) && !stands_for_repo(name));
Merge branch 'worktree-agent-ab2e39e11a6493412'720 let all_properties = op.properties();
721 let mut properties = all_properties.clone();
API and MCP server in Rust; a public index at the API root722 properties.retain(|name, _| !covered(name));
723 let required: Vec<String> = op
724 .required()
725 .into_iter()
726 .filter(|name| !covered(name))
727 .collect();
728
729 let mut parameters: Vec<Value> = path_params
730 .iter()
Checks: statuses and check runs on every commit, for CI and integrations731 .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 root732 .collect();
733 let mut body = Value::Null;
734 if route.method == "GET" {
735 for (name, key) in route.query {
Merge branch 'worktree-agent-ab2e39e11a6493412'736 parameters.push(parameter(
737 name,
738 "query",
739 required.iter().any(|required| required == key),
740 properties.get(*key),
741 ));
API and MCP server in Rust; a public index at the API root742 }
743 } else if !properties.is_empty() {
744 let mut schema = json!({ "type": "object", "properties": properties });
745 if !required.is_empty() {
746 schema["required"] = json!(required);
747 }
748 body = json!({
749 "required": !required.is_empty(),
750 "content": { "application/json": { "schema": schema } },
751 });
752 }
753
Merge branch 'worktree-agent-ab2e39e11a6493412'754 let id = operation_id(route);
755 let mut responses = Map::new();
756 responses.insert(
757 "200".into(),
758 json!({
759 "description": "Success.",
760 "content": { "application/json": { "schema": {} } },
761 }),
762 );
763 responses.insert(
764 "401".into(),
765 error_response("A token is required, or the one sent is not valid."),
766 );
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look767 if let Some(reason) = may_need_payment(op) {
768 responses.insert("402".into(), error_response(reason));
Merge branch 'worktree-agent-ab2e39e11a6493412'769 }
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step770 responses.insert(
771 "403".into(),
772 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."),
773 );
Search across all of g1t, Explore, and a command palette774 if !matches!(op, Op::Whoami | Op::ListRepos | Op::Search) {
Merge branch 'worktree-agent-ab2e39e11a6493412'775 responses.insert("404".into(), error_response("It does not exist, or you cannot see it."));
776 }
777 if route.method != "GET" {
778 responses.insert(
779 "409".into(),
780 error_response("The request conflicts with the current state."),
781 );
782 }
783 if op != Op::Whoami {
784 responses.insert("422".into(), error_response("The input is not valid."));
785 }
786 // 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 step787 let scope: Vec<&str> = scope_for(op.name()).map(|scope| scope.as_str()).into_iter().collect();
Merge branch 'worktree-agent-ab2e39e11a6493412'788 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 step789 json!([{ "token": scope }])
Webhooks: every event, to your own addresses, signed and retried790 } else {
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step791 json!([{ "token": scope }, {}])
Webhooks: every event, to your own addresses, signed and retried792 };
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step793 let (tool, action) = crate::tools::TOOLS
794 .iter()
795 .find_map(|tool| {
796 tool.actions
797 .iter()
798 .find(|action| action.op == op)
799 .map(|action| (tool.name, action.name))
800 })
801 .unwrap_or_default();
API and MCP server in Rust; a public index at the API root802 let mut described = json!({
Webhooks: every event, to your own addresses, signed and retried803 "operationId": id,
API and MCP server in Rust; a public index at the API root804 "tags": [tag(op)],
Merge branch 'worktree-agent-ab2e39e11a6493412'805 "summary": summary(route, &id),
API and MCP server in Rust; a public index at the API root806 "description": op.description(),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step807 "x-operation": op.name(),
808 "x-mcp-tool": tool,
809 "x-mcp-action": action,
810 "x-scope": scope.first().copied(),
Merge branch 'worktree-agent-ab2e39e11a6493412'811 "security": security,
API and MCP server in Rust; a public index at the API root812 "parameters": parameters,
Merge branch 'worktree-agent-ab2e39e11a6493412'813 "responses": responses,
API and MCP server in Rust; a public index at the API root814 });
815 if !body.is_null() {
816 described["requestBody"] = body;
817 }
818 described
819}
820
821/// Entries for device sign-in, which is not an operation.
822fn onboarding() -> Map<String, Value> {
823 let paths = json!({
Agents as a team: lifecycle, merge queue, billing and a new shell824 "/device/code": {
API and MCP server in Rust; a public index at the API root825 "post": {
826 "operationId": "device_code",
827 "tags": ["Accounts"],
828 "summary": "Start signing in",
Agents as a team: lifecycle, merge queue, billing and a new shell829 "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 root830 "security": [],
831 "requestBody": {
832 "content": { "application/json": { "schema": {
833 "type": "object",
834 "properties": {
835 "client_name": {
836 "type": "string",
837 "description": "What is asking, shown to the person approving. For example, Claude Code.",
838 },
839 },
840 } } },
841 },
842 "responses": { "200": {
843 "description": "The codes for this sign-in.",
844 "content": { "application/json": { "schema": {
845 "type": "object",
846 "properties": {
Agents as a team: lifecycle, merge queue, billing and a new shell847 "device_code": { "type": "string", "description": "Secret. Send it to /device/token." },
API and MCP server in Rust; a public index at the API root848 "user_code": { "type": "string", "description": "Shown to the person, like WDJB-MJHT." },
849 "verification_uri": { "type": "string" },
850 "verification_uri_complete": {
851 "type": "string",
852 "description": "The link to give the person; it carries the code.",
853 },
854 "expires_in": { "type": "integer", "description": "Seconds until the codes expire." },
855 "interval": { "type": "integer", "description": "Seconds to wait between polls." },
856 },
857 } } },
858 } },
859 },
860 },
Agents as a team: lifecycle, merge queue, billing and a new shell861 "/device/token": {
API and MCP server in Rust; a public index at the API root862 "post": {
863 "operationId": "device_token",
864 "tags": ["Accounts"],
865 "summary": "Finish signing in",
866 "description": "Asks whether the person has approved. Poll no faster than the interval. The token is returned once.",
867 "security": [],
868 "requestBody": {
869 "required": true,
870 "content": { "application/json": { "schema": {
871 "type": "object",
872 "required": ["device_code"],
873 "properties": { "device_code": { "type": "string" } },
874 } } },
875 },
876 "responses": { "200": {
877 "description": "The state of the sign-in.",
878 "content": { "application/json": { "schema": {
879 "type": "object",
880 "required": ["status"],
881 "properties": {
882 "status": { "type": "string", "enum": ["pending", "approved", "denied", "expired"] },
883 "token": { "type": "string", "description": "Present when approved." },
884 "username": { "type": "string" },
885 "verified": {
886 "type": "boolean",
887 "description": "Whether the account's email is confirmed.",
888 },
889 },
890 } } },
891 } },
892 },
893 },
894 });
895 match paths {
896 Value::Object(paths) => paths,
897 _ => Map::new(),
898 }
899}
900
Merge branch 'worktree-agent-ab2e39e11a6493412'901
902/// Puts each operation's examples, where it has them, into its request
903/// and response. Path and query values go under `x-example-params` and
904/// `x-example-query`, which tools that build a request can use.
905fn attach_examples(paths: &mut Map<String, Value>) {
906 let examples = examples();
907 for methods in paths.values_mut() {
908 let Some(methods) = methods.as_object_mut() else { continue };
909 for operation in methods.values_mut() {
910 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 step911 let name = operation["x-operation"].as_str().unwrap_or_default().to_owned();
912 let Some(example) = examples.get(&id).or_else(|| examples.get(&name)) else {
Merge branch 'worktree-agent-ab2e39e11a6493412'913 continue;
914 };
915 if let Some(notes) = example.get("notes").and_then(Value::as_str) {
916 let description = operation["description"].as_str().unwrap_or_default();
917 operation["description"] = json!(format!("{description}\n\n{notes}"));
918 }
919 if let Some(response) = example.get("response") {
920 let content = &mut operation["responses"]["200"]["content"]["application/json"];
921 if content.is_object() {
922 content["example"] = response.clone();
923 }
924 }
925 if let Some(request) = example.get("request") {
926 let content = &mut operation["requestBody"]["content"]["application/json"];
927 if content.is_object() {
928 content["example"] = request.clone();
929 }
930 }
931 for (key, extension) in [("params", "x-example-params"), ("query", "x-example-query")] {
932 if let Some(values) = example.get(key) {
933 operation[extension] = values.clone();
934 }
935 }
936 }
937 }
938}
939
API and MCP server in Rust; a public index at the API root940pub fn document() -> Value {
941 let mut paths = onboarding();
942 for route in ROUTES {
943 let entry = paths
944 .entry(openapi_path(route))
945 .or_insert_with(|| json!({}));
946 entry[route.method.to_lowercase()] = operation(route);
947 }
Merge branch 'worktree-agent-ab2e39e11a6493412'948 attach_examples(&mut paths);
949 let tags: Vec<Value> = SECTIONS
950 .iter()
951 .map(|(name, description, ops)| {
952 json!({
953 "name": name,
954 "description": description,
955 // The section's operations in reading order, by MCP tool name.
956 "x-tools": ops.iter().map(|op| op.name()).collect::<Vec<_>>(),
957 })
958 })
959 .collect();
960 let codes = ["unauthenticated", "payment_required", "forbidden", "not_found", "conflict", "invalid"];
API and MCP server in Rust; a public index at the API root961 json!({
962 "openapi": "3.1.0",
963 "info": {
964 "title": "g1t API",
965 "version": "1",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API966 "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 root967 "license": { "name": "MIT", "identifier": "MIT" },
968 },
969 "servers": [{ "url": "https://api.g1t.sh" }],
970 "security": [{ "token": [] }, {}],
Merge branch 'worktree-agent-ab2e39e11a6493412'971 "tags": tags,
API and MCP server in Rust; a public index at the API root972 "paths": paths,
973 "components": {
974 "securitySchemes": {
975 "token": {
976 "type": "http",
977 "scheme": "bearer",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step978 "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 root979 },
980 },
981 "schemas": {
982 "Error": {
983 "type": "object",
984 "required": ["error"],
985 "properties": {
986 "error": {
987 "type": "object",
988 "required": ["code", "message"],
989 "properties": {
Merge branch 'worktree-agent-ab2e39e11a6493412'990 "code": { "type": "string", "enum": codes },
API and MCP server in Rust; a public index at the API root991 "message": { "type": "string" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step992 "needed_scope": {
993 "type": "string",
994 "description": "On a 403 for an access token without the scope the call needs: that scope, such as `issues:write`.",
995 },
API and MCP server in Rust; a public index at the API root996 },
997 },
998 },
999 },
1000 },
1001 },
1002 })
1003}
1004
1005#[cfg(test)]
1006mod tests {
1007 use super::*;
1008
1009 #[test]
1010 fn every_route_is_documented_once() {
1011 let document = document();
1012 let mut ids = Vec::new();
1013 for (_, methods) in document["paths"].as_object().unwrap() {
1014 for (_, operation) in methods.as_object().unwrap() {
1015 ids.push(operation["operationId"].as_str().unwrap().to_owned());
1016 }
1017 }
1018 for op in Op::ALL {
1019 assert_eq!(
1020 ids.iter().filter(|id| *id == op.name()).count(),
1021 1,
1022 "{}",
1023 op.name()
1024 );
1025 }
Webhooks: every event, to your own addresses, signed and retried1026 let mut unique = ids.clone();
1027 unique.sort();
1028 unique.dedup();
1029 assert_eq!(unique.len(), ids.len(), "operation ids repeat");
API and MCP server in Rust; a public index at the API root1030 }
1031
1032 #[test]
1033 fn path_and_query_inputs_are_not_repeated_in_the_body() {
1034 let document = document();
Agents as a team: lifecycle, merge queue, billing and a new shell1035 let merge = &document["paths"]["/repos/{owner}/{name}/pulls/{number}/merge"]["post"];
API and MCP server in Rust; a public index at the API root1036 let body = &merge["requestBody"]["content"]["application/json"]["schema"]["properties"];
1037 assert!(body.get("keep_issue_open").is_some());
1038 assert!(body.get("repo").is_none() && body.get("number").is_none());
Agents as a team: lifecycle, merge queue, billing and a new shell1039 let list = &document["paths"]["/repos"]["get"];
API and MCP server in Rust; a public index at the API root1040 assert_eq!(list["parameters"][0]["name"], "q");
1041 assert!(list.get("requestBody").is_none());
1042 }
1043
1044 #[test]
Merge branch 'worktree-agent-ab2e39e11a6493412'1045 fn every_operation_is_in_one_section() {
1046 for op in Op::ALL {
1047 let sections = SECTIONS
1048 .iter()
1049 .filter(|(_, _, ops)| ops.contains(&op))
1050 .count();
1051 assert_eq!(sections, 1, "{}", op.name());
1052 }
1053 }
1054
1055 #[test]
API and MCP server in Rust; a public index at the API root1056 fn titles_read_as_sentences() {
Merge branch 'worktree-agent-ab2e39e11a6493412'1057 assert_eq!(title(Op::CreateIssue), "Create an issue");
API and MCP server in Rust; a public index at the API root1058 assert_eq!(title(Op::Whoami), "Get the current user");
1059 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1060
1061 #[test]
1062 fn every_operation_has_an_example_response() {
1063 let examples = examples();
1064 assert!(!examples.is_empty(), "reference.json does not parse");
1065 let document = document();
1066 let mut known = Vec::new();
1067 for (path, methods) in document["paths"].as_object().unwrap() {
1068 for (method, operation) in methods.as_object().unwrap() {
1069 known.push(operation["operationId"].as_str().unwrap().to_owned());
1070 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1071 assert!(!example.is_null(), "{method} {path} has no example response");
1072 }
1073 }
1074 for id in examples.keys() {
1075 assert!(known.contains(id), "reference.json names {id}, which is not an operation");
1076 }
1077 }
1078
1079 #[test]
1080 fn example_requests_send_only_what_the_body_takes() {
1081 let document = document();
1082 for (path, methods) in document["paths"].as_object().unwrap() {
1083 for (method, operation) in methods.as_object().unwrap() {
1084 let content = &operation["requestBody"]["content"]["application/json"];
1085 let Some(example) = content["example"].as_object() else { continue };
1086 let properties = &content["schema"]["properties"];
1087 for key in example.keys() {
1088 assert!(!properties[key].is_null(), "{method} {path}: {key} is not in the body");
1089 }
1090 }
1091 }
1092 }
1093
1094 /// The docs site's copy of the document. Run with `G1T_WRITE_OPENAPI=1`
1095 /// to rewrite it after changing an operation.
1096 #[test]
1097 fn the_docs_copy_is_current() {
1098 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../docs/src/data/openapi.json");
1099 let current = serde_json::to_string_pretty(&document()).unwrap() + "\n";
1100 if std::env::var_os("G1T_WRITE_OPENAPI").is_some() {
1101 std::fs::write(path, &current).unwrap();
1102 return;
1103 }
1104 let copy = std::fs::read_to_string(path).unwrap_or_default().replace("\r\n", "\n");
1105 assert!(
1106 copy == current,
1107 "apps/docs/src/data/openapi.json is out of date: run G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi"
1108 );
1109 }
API reference: no example reads as a real secret1110
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1111 /// The reference shows responses as they are sent: `snake_case`.
1112 #[test]
1113 fn example_responses_are_snake_case() {
1114 let document = document();
1115 for (path, methods) in document["paths"].as_object().unwrap() {
1116 for (method, operation) in methods.as_object().unwrap() {
1117 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1118 let leaked = g1t_kit::wire::camel_case_keys(example);
1119 assert!(leaked.is_empty(), "{method} {path} shows {leaked:?}");
1120 }
1121 }
1122 }
1123
API reference: no example reads as a real secret1124 /// Examples never hold anything that reads as a real credential, which
1125 /// secret scanners rightly flag in a public repository: they end in `…`
1126 /// after the prefix, as `whsec_…` and `g1t_…` do.
1127 #[test]
1128 fn examples_hold_no_real_looking_secrets() {
Fast pages, required checks on the branch, self-hosted runners, honest incidents1129 let prefixes = ["whsec_", "g1t_", "g1tr_", "g1trt_", "sk_live_", "sk_test_", "ghp_", "github_pat_", "xoxb-", "AKIA"];
API reference: no example reads as a real secret1130 for (line, text) in REFERENCE.lines().enumerate() {
1131 for prefix in prefixes {
1132 let mut rest = text;
1133 while let Some(at) = rest.find(prefix) {
1134 let after = &rest[at + prefix.len()..];
1135 let run = after.chars().take_while(|c| c.is_ascii_alphanumeric()).count();
1136 assert!(
1137 run < 12,
1138 "reference.json line {}: `{prefix}` followed by {run} characters reads as a real secret; write `{prefix}…`",
1139 line + 1
1140 );
1141 rest = after;
1142 }
1143 }
1144 }
1145 }
API and MCP server in Rust; a public index at the API root1146}

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