Skip to content
1,102 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;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar11use crate::security::SecurityOp;
API and MCP server in Rust; a public index at the API root12use crate::rest::{ROUTES, Route};
13
Merge branch 'worktree-agent-ab2e39e11a6493412'14/// The sections of the API reference: a name, what it covers, and its
15/// operations in the order a reader meets them.
16const SECTIONS: &[(&str, &str, &[Op])] = &[
17 (
18 "Accounts",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look19 "Signing in from a tool, who a token acts as, and your email addresses.",
20 &[Op::Whoami, Op::ListEmails, Op::AddEmail, Op::RemoveEmail, Op::UpdateEmailSettings],
Merge branch 'worktree-agent-ab2e39e11a6493412'21 ),
22 (
API: notifications over REST and MCP, with notifications scopes23 "Notifications",
24 "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.",
25 &[
26 Op::ListNotifications,
27 Op::MarkNotificationsRead,
28 Op::GetNotificationThread,
29 Op::MarkThreadRead,
30 Op::MarkThreadDone,
31 Op::SaveThread,
32 Op::SnoozeThread,
33 Op::GetThreadSubscription,
34 Op::SetThreadSubscription,
35 Op::DeleteThreadSubscription,
36 Op::GetRepoSubscription,
37 Op::SetRepoSubscription,
38 Op::DeleteRepoSubscription,
39 Op::ListWatchedRepos,
40 ],
41 ),
42 (
API: pinned projects over REST and MCP43 "Pinned projects",
44 "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.",
45 &[Op::ListPinnedProjects, Op::PinProject, Op::UnpinProject, Op::ReorderPinnedProjects],
46 ),
47 (
Merge branch 'worktree-agent-ab2e39e11a6493412'48 "Workspaces",
49 "A workspace owns repositories and is the first part of their address. People and agents work in workspaces.",
Merge branch 'worktree-agent-ad7c6d88d93adc817'50 &[Op::GetWorkspace, Op::CreateWorkspace, Op::UpdateWorkspace, Op::DeleteWorkspace],
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look51 ),
52 (
53 "Invites",
54 "While g1t is invite-only, every new account needs an invite. Your invites, and inviting people into a workspace by email.",
55 &[
56 Op::ListInvites,
57 Op::CreateInvite,
58 Op::RevokeInvite,
59 Op::ListWorkspaceInvites,
60 Op::InviteMember,
61 Op::RevokeWorkspaceInvite,
62 ],
Merge branch 'worktree-agent-ab2e39e11a6493412'63 ),
64 (
Usage, Billing settings and prepaid AI credit; fixes from the UX audit65 "Billing",
AI Gateway: your own code calls models with a workspace token66 "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 audit67 &[
68 Op::GetUsage,
69 Op::GetBudget,
70 Op::SetBudget,
71 Op::GetAiCredit,
72 Op::BuyAiCredit,
73 Op::ListInvoices,
74 Op::GetBillingDetails,
AI Gateway: your own code calls models with a workspace token75 Op::ListGatewayRequests,
Usage, Billing settings and prepaid AI credit; fixes from the UX audit76 ],
77 ),
78 (
Merge branch 'worktree-agent-ab2e39e11a6493412'79 "Repositories",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look80 "A repository, how it handles pull requests, and its timeline: renaming, archiving, moving and deleting it.",
Merge branch 'worktree-agent-ab2e39e11a6493412'81 &[
82 Op::ListRepos,
83 Op::CreateRepo,
84 Op::GetRepo,
85 Op::UpdateRepo,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look86 Op::RenameRepo,
87 Op::RenameBranch,
88 Op::SetRepoVisibility,
89 Op::ArchiveRepo,
90 Op::UnarchiveRepo,
91 Op::TransferRepo,
92 Op::DeleteRepo,
93 Op::ListDeletedRepos,
94 Op::RestoreRepo,
95 Op::PurgeRepo,
Merge branch 'worktree-agent-ab2e39e11a6493412'96 Op::GetRepoSettings,
97 Op::UpdateRepoSettings,
Fast pages, required checks on the branch, self-hosted runners, honest incidents98 Op::ListCheckNames,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar99 Op::GetCodeownersErrors,
Merge branch 'worktree-agent-ab2e39e11a6493412'100 Op::ListEvents,
101 ],
102 ),
103 (
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look104 "Access",
105 "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.",
106 &[
107 Op::ListCollaborators,
108 Op::AddCollaborator,
109 Op::UpdateCollaborator,
110 Op::RemoveCollaborator,
111 Op::GetCollaboratorPermission,
112 Op::ListRepoInvitations,
113 Op::RevokeRepoInvitation,
114 Op::ListMyRepoInvitations,
115 Op::AcceptRepoInvitation,
116 Op::DeclineRepoInvitation,
117 Op::SetBasePermission,
118 Op::ListOutsideCollaborators,
119 ],
120 ),
121 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar122 "Teams",
123 "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.",
124 &[
125 Op::ListTeams,
126 Op::CreateTeam,
127 Op::GetTeam,
128 Op::UpdateTeam,
129 Op::DeleteTeam,
130 Op::ListTeamMembers,
131 Op::SetTeamMember,
132 Op::RemoveTeamMember,
133 Op::ListChildTeams,
134 Op::ListTeamRepos,
135 Op::SetTeamRepo,
136 Op::RemoveTeamRepo,
137 Op::SetTeamReviewAssignment,
138 Op::ListUserTeams,
139 ],
140 ),
141 (
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily142 "Security",
143 "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.",
144 &[Op::ListSecurityAlerts, Op::DismissSecurityAlert, Op::ReopenSecurityAlert],
145 ),
146 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar147 "Secret scanning",
148 "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.",
149 &[
150 Op::Security(SecurityOp::ListSecretAlerts),
151 Op::Security(SecurityOp::GetSecretAlert),
152 Op::Security(SecurityOp::UpdateSecretAlert),
153 Op::Security(SecurityOp::ListSecretLocations),
154 Op::Security(SecurityOp::BypassPushProtection),
155 Op::Security(SecurityOp::CheckSecretValidity),
156 Op::Security(SecurityOp::ListBypassRequests),
157 Op::Security(SecurityOp::ReviewBypassRequest),
158 Op::Security(SecurityOp::ListCustomPatterns),
159 Op::Security(SecurityOp::CreateCustomPattern),
160 Op::Security(SecurityOp::UpdateCustomPattern),
161 Op::Security(SecurityOp::DeleteCustomPattern),
162 Op::Security(SecurityOp::DryRunCustomPattern),
163 ],
164 ),
165 (
166 "Code scanning",
167 "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.",
168 &[
169 Op::Security(SecurityOp::ListCodeAlerts),
170 Op::Security(SecurityOp::GetCodeAlert),
171 Op::Security(SecurityOp::UpdateCodeAlert),
172 Op::Security(SecurityOp::ListAnalyses),
173 Op::Security(SecurityOp::UploadSarif),
174 Op::Security(SecurityOp::GetSarifUpload),
175 Op::Security(SecurityOp::FixAlert),
176 ],
177 ),
178 (
179 "Supply chain",
180 "What a repository depends on: vulnerability alerts, the dependency graph, an SPDX SBOM of it, and comparing two commits' dependencies as dependency review does.",
181 &[
182 Op::Security(SecurityOp::ListVulnerabilityAlerts),
183 Op::Security(SecurityOp::GetVulnerabilityAlert),
184 Op::Security(SecurityOp::UpdateVulnerabilityAlert),
185 Op::Security(SecurityOp::GetDependencyGraph),
186 Op::Security(SecurityOp::GetSbom),
187 Op::Security(SecurityOp::CompareDependencies),
188 ],
189 ),
190 (
191 "Security settings",
192 "When pull request checks fail, dependency review's policy, delegated bypass and validity checks, and a workspace's security overview.",
193 &[
194 Op::Security(SecurityOp::GetSettings),
195 Op::Security(SecurityOp::UpdateSettings),
196 Op::Security(SecurityOp::GetWorkspaceSettings),
197 Op::Security(SecurityOp::UpdateWorkspaceSettings),
198 Op::Security(SecurityOp::GetOverview),
199 ],
200 ),
201 (
Merge branch 'worktree-agent-ab2e39e11a6493412'202 "Issues",
203 "What should change in a repository, with labels and comments. Issues and pull requests share one sequence of numbers.",
204 &[
205 Op::ListIssues,
206 Op::CreateIssue,
207 Op::GetIssue,
208 Op::UpdateIssue,
209 Op::CloseIssue,
210 Op::ReopenIssue,
211 Op::AssignIssue,
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step212 Op::Delegate,
Merge branch 'worktree-agent-ab2e39e11a6493412'213 Op::AddComment,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar214 Op::ListIssueLabels,
215 Op::AddIssueLabels,
216 Op::SetIssueLabels,
217 Op::RemoveIssueLabels,
218 ],
219 ),
220 (
221 "Labels and milestones",
222 "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.",
223 &[
Merge branch 'worktree-agent-ab2e39e11a6493412'224 Op::ListLabels,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar225 Op::CreateLabel,
226 Op::UpdateLabel,
227 Op::DeleteLabel,
228 Op::AddDefaultLabels,
229 Op::ListMilestones,
230 Op::CreateMilestone,
231 Op::GetMilestone,
232 Op::UpdateMilestone,
233 Op::DeleteMilestone,
Merge branch 'worktree-agent-ab2e39e11a6493412'234 ],
235 ),
236 (
237 "Plans",
238 "An outcome turned into the issues that would get there, with the order they must merge in.",
239 &[Op::PlanWork, Op::GetPlan, Op::ApplyPlan],
240 ),
241 (
242 "Pull requests",
243 "A proposed change in its own fork or on a branch. Several can be made for one issue; the one merged resolves it.",
244 &[
245 Op::ListPullRequests,
246 Op::CreatePullRequest,
247 Op::GetPullRequest,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar248 Op::UpdatePullRequest,
Merge branch 'worktree-agent-ab2e39e11a6493412'249 Op::GetPullRequestChanges,
250 Op::MarkPullRequestReady,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar251 Op::RequestReviewers,
252 Op::RemoveRequestedReviewers,
Merge branch 'worktree-agent-ab2e39e11a6493412'253 Op::ReviewPullRequest,
254 Op::MergePullRequest,
255 Op::ClosePullRequest,
256 Op::GetMergeQueue,
257 Op::MessageAgent,
258 Op::AnswerMessage,
259 Op::TakeMessages,
260 ],
261 ),
262 (
263 "Sessions",
264 "The record of how a pull request was made: prompts, reasoning and the tools that ran.",
265 &[Op::ReadSession, Op::RecordSession],
266 ),
267 (
Agents and memory, checks and conflicts, profiles, slug renames, custom domains268 "Memory",
269 "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.",
270 &[Op::Remember, Op::Recall],
271 ),
272 (
Search across all of g1t, Explore, and a command palette273 "Search",
274 "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.",
275 &[Op::Search],
276 ),
277 (
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API278 "Context",
279 "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.",
280 &[Op::SearchContext, Op::GetEntity],
281 ),
282 (
Merge branch 'worktree-agent-ab2e39e11a6493412'283 "Actions",
284 "GitHub Actions workflows in .g1t/workflows, their runs, and their jobs' logs.",
285 &[
286 Op::ListWorkflows,
287 Op::ListWorkflowRuns,
288 Op::GetWorkflowRun,
289 Op::GetJobLogs,
290 Op::DispatchWorkflow,
291 Op::CancelWorkflowRun,
292 Op::RerunWorkflowRun,
293 Op::UpdateWorkflow,
294 ],
295 ),
296 (
297 "Secrets and variables",
298 "Values that workflows and deployments read, per repository or for a whole workspace, with a row per environment.",
299 &[
300 Op::ListActionsSecrets,
301 Op::SetActionsSecret,
302 Op::DeleteActionsSecret,
303 Op::ListActionsVariables,
304 Op::SetActionsVariable,
305 Op::DeleteActionsVariable,
306 ],
307 ),
308 (
Fast pages, required checks on the branch, self-hosted runners, honest incidents309 "Runners",
310 "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.",
311 &[
312 Op::ListRunners,
313 Op::CreateRunnerRegistrationToken,
314 Op::RemoveRunner,
315 Op::ListRunnerGroups,
316 Op::CreateRunnerGroup,
317 Op::UpdateRunnerGroup,
318 Op::DeleteRunnerGroup,
319 Op::GetRunnerSettings,
320 Op::UpdateRunnerSettings,
321 ],
322 ),
323 (
Merge branch 'worktree-agent-ab2e39e11a6493412'324 "Webhooks",
325 "Signed HTTPS requests sent to your own address as things happen, for a repository or a whole workspace.",
326 &[
327 Op::ListWebhooks,
328 Op::CreateWebhook,
329 Op::UpdateWebhook,
330 Op::DeleteWebhook,
331 Op::PingWebhook,
332 Op::ListWebhookDeliveries,
333 Op::RedeliverWebhook,
334 ],
335 ),
336 (
337 "Integrations",
338 "A workspace's connections to outside systems: model providers, alert sources and issue trackers.",
339 &[
340 Op::ListIntegrations,
341 Op::ConnectIntegration,
342 Op::DisconnectIntegration,
343 Op::TestIntegration,
344 Op::GetModelRoutes,
345 Op::SetModelRoutes,
346 Op::GetContext,
347 Op::ImportIssue,
348 ],
349 ),
350];
351
API and MCP server in Rust; a public index at the API root352/// The section of the API reference an operation is listed under.
353fn tag(op: Op) -> &'static str {
Merge branch 'worktree-agent-ab2e39e11a6493412'354 SECTIONS
API and MCP server in Rust; a public index at the API root355 .iter()
Merge branch 'worktree-agent-ab2e39e11a6493412'356 .find(|(_, _, ops)| ops.contains(&op))
357 .map_or("Repositories", |(name, _, _)| name)
358}
359
360/// What an operation's page is called, as a short sentence.
361fn title(op: Op) -> &'static str {
362 match op {
363 Op::Whoami => "Get the current user",
Merge branch 'worktree-agent-ad7c6d88d93adc817'364 Op::GetWorkspace => "Get a workspace",
Merge branch 'worktree-agent-ab2e39e11a6493412'365 Op::CreateWorkspace => "Create a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look366 Op::DeleteWorkspace => "Delete a workspace",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily367 Op::UpdateWorkspace => "Update a workspace",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look368 Op::ListEmails => "List your email addresses",
369 Op::AddEmail => "Add an email address",
370 Op::RemoveEmail => "Remove an email address",
371 Op::UpdateEmailSettings => "Change your email settings",
372 Op::ListInvites => "List your invites",
373 Op::CreateInvite => "Create an invite",
374 Op::RevokeInvite => "Revoke an invite",
375 Op::ListWorkspaceInvites => "List a workspace's invites",
376 Op::InviteMember => "Invite someone to a workspace",
377 Op::RevokeWorkspaceInvite => "Revoke a workspace's invite",
378 Op::TransferRepo => "Transfer a repository",
379 Op::RenameRepo => "Rename a repository",
380 Op::RenameBranch => "Rename a branch",
381 Op::ArchiveRepo => "Archive a repository",
382 Op::UnarchiveRepo => "Unarchive a repository",
383 Op::SetRepoVisibility => "Change a repository's visibility",
384 Op::DeleteRepo => "Delete a repository",
385 Op::ListDeletedRepos => "List recently deleted repositories",
386 Op::RestoreRepo => "Restore a deleted repository",
387 Op::PurgeRepo => "Purge a deleted repository",
Merge branch 'worktree-agent-ab2e39e11a6493412'388 Op::ListRepos => "List repositories",
389 Op::GetRepo => "Get a repository",
390 Op::CreateRepo => "Create a repository",
391 Op::UpdateRepo => "Update a repository",
392 Op::GetRepoSettings => "Get repository settings",
393 Op::UpdateRepoSettings => "Update repository settings",
Fast pages, required checks on the branch, self-hosted runners, honest incidents394 Op::ListCheckNames => "List check names",
Merge branch 'worktree-agent-ab2e39e11a6493412'395 Op::GetMergeQueue => "Get the merge queue",
396 Op::MessageAgent => "Message an agent",
397 Op::AnswerMessage => "Answer a message",
398 Op::TakeMessages => "Take new messages",
Agents and memory, checks and conflicts, profiles, slug renames, custom domains399 Op::Remember => "Remember something",
400 Op::Recall => "Recall memory",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API401 Op::SearchContext => "Search the context hub",
402 Op::GetEntity => "Get a catalog entry",
Search across all of g1t, Explore, and a command palette403 Op::Search => "Search g1t",
Merge branch 'worktree-agent-ab2e39e11a6493412'404 Op::ListIssues => "List issues",
405 Op::GetIssue => "Get an issue",
406 Op::CreateIssue => "Create an issue",
407 Op::UpdateIssue => "Update an issue",
408 Op::CloseIssue => "Close an issue",
409 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-agent410 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 step411 Op::Delegate => "Put an agent on it",
Merge branch 'worktree-agent-ab2e39e11a6493412'412 Op::PlanWork => "Plan work",
413 Op::GetPlan => "Get a plan",
414 Op::ApplyPlan => "Apply a plan",
415 Op::ListLabels => "List labels",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar416 Op::CreateLabel => "Create a label",
417 Op::UpdateLabel => "Update a label",
418 Op::DeleteLabel => "Delete a label",
419 Op::AddDefaultLabels => "Add the default labels",
420 Op::ListIssueLabels => "List an issue's labels",
421 Op::AddIssueLabels => "Add labels to an issue",
422 Op::SetIssueLabels => "Set an issue's labels",
423 Op::RemoveIssueLabels => "Remove labels from an issue",
424 Op::ListMilestones => "List milestones",
425 Op::GetMilestone => "Get a milestone",
426 Op::CreateMilestone => "Create a milestone",
427 Op::UpdateMilestone => "Update a milestone",
428 Op::DeleteMilestone => "Delete a milestone",
429 Op::UpdatePullRequest => "Update a pull request",
Merge branch 'worktree-agent-ab2e39e11a6493412'430 Op::AddComment => "Add a comment",
431 Op::ReviewPullRequest => "Review a pull request",
432 Op::ListPullRequests => "List pull requests",
433 Op::GetPullRequest => "Get a pull request",
434 Op::CreatePullRequest => "Create a pull request",
435 Op::RecordSession => "Record session entries",
436 Op::ReadSession => "Read a session",
437 Op::MarkPullRequestReady => "Mark a pull request ready",
438 Op::ClosePullRequest => "Close a pull request",
439 Op::GetPullRequestChanges => "Get a pull request's changes",
440 Op::MergePullRequest => "Merge a pull request",
441 Op::ListEvents => "List repository events",
442 Op::ListIntegrations => "List integrations",
443 Op::ConnectIntegration => "Connect an integration",
444 Op::DisconnectIntegration => "Disconnect an integration",
445 Op::TestIntegration => "Test an integration",
446 Op::GetContext => "Look up a ticket",
447 Op::ImportIssue => "Import an issue",
448 Op::GetModelRoutes => "Get model routes",
449 Op::SetModelRoutes => "Set model routes",
450 Op::ListWebhooks => "List webhooks",
451 Op::CreateWebhook => "Create a webhook",
452 Op::UpdateWebhook => "Update a webhook",
453 Op::DeleteWebhook => "Delete a webhook",
454 Op::PingWebhook => "Ping a webhook",
455 Op::ListWebhookDeliveries => "List webhook deliveries",
456 Op::RedeliverWebhook => "Redeliver a webhook delivery",
457 Op::ListWorkflows => "List workflows",
458 Op::ListWorkflowRuns => "List workflow runs",
459 Op::GetWorkflowRun => "Get a workflow run",
460 Op::GetJobLogs => "Get a job's log",
461 Op::DispatchWorkflow => "Run a workflow",
462 Op::CancelWorkflowRun => "Cancel a workflow run",
463 Op::RerunWorkflowRun => "Re-run a workflow run",
464 Op::UpdateWorkflow => "Turn a workflow on or off",
465 Op::ListActionsSecrets => "List secrets",
466 Op::SetActionsSecret => "Set a secret",
467 Op::DeleteActionsSecret => "Delete a secret",
468 Op::ListActionsVariables => "List variables",
469 Op::SetActionsVariable => "Set a variable",
470 Op::DeleteActionsVariable => "Delete a variable",
Fast pages, required checks on the branch, self-hosted runners, honest incidents471 Op::ListRunners => "List self-hosted runners",
472 Op::ListRunnerGroups => "List runner groups",
473 Op::GetRunnerSettings => "Get runner settings",
474 Op::CreateRunnerRegistrationToken => "Create a runner registration token",
475 Op::RemoveRunner => "Remove a self-hosted runner",
476 Op::CreateRunnerGroup => "Create a runner group",
477 Op::UpdateRunnerGroup => "Change a runner group",
478 Op::DeleteRunnerGroup => "Delete a runner group",
479 Op::UpdateRunnerSettings => "Change runner settings",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look480 Op::ListCollaborators => "List who has access",
481 Op::AddCollaborator => "Add a collaborator",
482 Op::UpdateCollaborator => "Change a collaborator's role",
483 Op::RemoveCollaborator => "Remove a collaborator",
484 Op::GetCollaboratorPermission => "Get someone's permission",
485 Op::ListRepoInvitations => "List a repository's invitations",
486 Op::RevokeRepoInvitation => "Revoke a repository invitation",
487 Op::ListMyRepoInvitations => "List your repository invitations",
488 Op::AcceptRepoInvitation => "Accept a repository invitation",
489 Op::DeclineRepoInvitation => "Decline a repository invitation",
490 Op::SetBasePermission => "Set the base permission",
491 Op::ListOutsideCollaborators => "List outside collaborators",
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily492 Op::ListSecurityAlerts => "List security alerts",
493 Op::DismissSecurityAlert => "Dismiss a security alert",
494 Op::ReopenSecurityAlert => "Reopen a security alert",
API: notifications over REST and MCP, with notifications scopes495 Op::ListNotifications => "List notifications",
496 Op::MarkNotificationsRead => "Mark notifications read",
497 Op::GetNotificationThread => "Get a thread",
498 Op::MarkThreadRead => "Mark a thread read",
499 Op::MarkThreadDone => "Mark a thread done",
500 Op::SaveThread => "Save a thread",
501 Op::SnoozeThread => "Snooze a thread",
502 Op::GetThreadSubscription => "Get a thread subscription",
503 Op::SetThreadSubscription => "Set a thread subscription",
504 Op::DeleteThreadSubscription => "Unsubscribe from a thread",
505 Op::GetRepoSubscription => "Get how you watch a repository",
506 Op::SetRepoSubscription => "Watch a repository",
507 Op::DeleteRepoSubscription => "Stop watching a repository",
508 Op::ListWatchedRepos => "List repositories you watch",
API: pinned projects over REST and MCP509 Op::ListPinnedProjects => "List your pinned projects",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit510 Op::GetUsage => "Get a workspace's usage",
511 Op::GetBudget => "Get a workspace's budget",
512 Op::SetBudget => "Change a workspace's budget",
513 Op::GetAiCredit => "Get a workspace's AI credit",
514 Op::BuyAiCredit => "Buy AI credit",
515 Op::ListInvoices => "List a workspace's invoices",
516 Op::GetBillingDetails => "Get a workspace's billing details",
AI Gateway: your own code calls models with a workspace token517 Op::ListGatewayRequests => "List a workspace's AI Gateway requests",
API: pinned projects over REST and MCP518 Op::PinProject => "Pin a project",
519 Op::UnpinProject => "Unpin a project",
520 Op::ReorderPinnedProjects => "Reorder your pinned projects",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar521 Op::ListTeams => "List teams",
522 Op::GetTeam => "Get a team",
523 Op::CreateTeam => "Create a team",
524 Op::UpdateTeam => "Update a team",
525 Op::DeleteTeam => "Delete a team",
526 Op::ListTeamMembers => "List a team's members",
527 Op::SetTeamMember => "Add or change a team member",
528 Op::RemoveTeamMember => "Remove a team member",
529 Op::ListChildTeams => "List child teams",
530 Op::ListTeamRepos => "List a team's repositories",
531 Op::SetTeamRepo => "Give a team a role on a repository",
532 Op::RemoveTeamRepo => "Remove a team from a repository",
533 Op::SetTeamReviewAssignment => "Set a team's review assignment",
534 Op::ListUserTeams => "List someone's teams",
535 Op::RequestReviewers => "Request reviewers",
536 Op::RemoveRequestedReviewers => "Remove requested reviewers",
537 Op::GetCodeownersErrors => "List CODEOWNERS errors",
538 Op::Security(op) => op.title(),
API and MCP server in Rust; a public index at the API root539 }
540}
541
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look542/// Why an operation can be refused with `402 payment_required`, if it
543/// can: the ones that start an agent, when the workspace has no credit,
544/// and the ones that make a repository private in a workspace, when a free
545/// workspace's private storage has no room for it.
546fn may_need_payment(op: Op) -> Option<&'static str> {
547 match op {
548 Op::AssignIssue | Op::PlanWork | Op::ApplyPlan => Some("The workspace has no agent credit."),
549 Op::UpdateRepo | Op::SetRepoVisibility | Op::TransferRepo => Some(
550 "A free workspace's private storage has no room for this private repository.",
551 ),
552 _ => None,
553 }
Merge branch 'worktree-agent-ab2e39e11a6493412'554}
555
556/// What the reference says beyond each operation's own description, keyed
557/// by operation id, written by hand from what the services return: `notes`
558/// (Markdown, added to the description) and example `params` (path),
559/// `query`, `request` (body) and `response`.
560const REFERENCE: &str = include_str!("reference.json");
561
562fn examples() -> Map<String, Value> {
563 match serde_json::from_str(REFERENCE) {
564 Ok(Value::Object(examples)) => examples,
565 _ => Map::new(),
API and MCP server in Rust; a public index at the API root566 }
567}
568
Agents as a team: lifecycle, merge queue, billing and a new shell569/// `/repos/:owner/:name` as OpenAPI writes it: `/repos/{owner}/{name}`.
API and MCP server in Rust; a public index at the API root570fn openapi_path(route: &Route) -> String {
571 route
572 .path
573 .split('/')
574 .map(|segment| match segment.strip_prefix(':') {
575 Some(name) => format!("{{{name}}}"),
576 None => segment.to_owned(),
577 })
578 .collect::<Vec<_>>()
579 .join("/")
580}
581
582fn error_response(description: &str) -> Value {
583 json!({
584 "description": description,
585 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } },
586 })
587}
588
Merge branch 'worktree-agent-ab2e39e11a6493412'589/// A parameter in the path or the query, described by the operation's
590/// input schema where it has the same name.
591fn parameter(name: &str, place: &str, required: bool, schema: Option<&Value>) -> Value {
592 let mut schema = schema.cloned().unwrap_or_else(|| json!({ "type": "string" }));
593 let description = match name {
594 "owner" => Some(Value::from("The workspace that owns the repository.")),
595 "name" => Some(Value::from("The repository's name.")),
596 _ => schema.as_object_mut().and_then(|schema| schema.remove("description")),
597 };
598 let mut parameter = json!({
599 "name": name,
600 "in": place,
601 "required": required,
602 "schema": schema,
603 });
604 if let Some(description) = description {
605 parameter["description"] = description;
606 }
607 parameter
608}
609
610/// The operation id of a route. An operation reached at a workspace's
611/// address as well as a repository's is documented once for each, with its
612/// own id; GitHub's alternative addresses for one operation keep GitHub's
613/// names.
614fn operation_id(route: &Route) -> String {
615 let op = route.op;
616 let base = match (route.method, route.path.rsplit('/').next().unwrap_or_default()) {
617 ("PUT", "enable") => "enable_workflow".to_owned(),
618 ("PUT", "disable") => "disable_workflow".to_owned(),
619 ("POST", "rerun-failed-jobs") => "rerun_failed_jobs".to_owned(),
620 ("PATCH", ":setting") => "update_actions_variable".to_owned(),
621 ("GET", "runs") if route.path.contains("/workflows/:workflow/") => "list_runs_of_workflow".to_owned(),
API: notifications over REST and MCP, with notifications scopes622 // One repository's notifications, and an issue's subscription by
623 // its number rather than a thread's id.
624 (_, "notifications") if route.path.starts_with("/repos/") => match op {
625 Op::ListNotifications => "list_repo_notifications".to_owned(),
626 _ => "mark_repo_notifications_read".to_owned(),
627 },
628 (method, "subscription") if route.path.contains("/issues/:number/") => match method {
629 "GET" => "get_issue_subscription".to_owned(),
630 "PUT" => "set_issue_subscription".to_owned(),
631 _ => "delete_issue_subscription".to_owned(),
632 },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar633 // One label off an issue, by its name in the path.
634 ("DELETE", ":label") if route.path.contains("/issues/:number/") => "remove_issue_label".to_owned(),
API: notifications over REST and MCP, with notifications scopes635 ("DELETE", "saved") => "unsave_thread".to_owned(),
636 ("DELETE", "snooze") => "unsnooze_thread".to_owned(),
Merge branch 'worktree-agent-ab2e39e11a6493412'637 _ => op.name().to_owned(),
638 };
639 if route.path.starts_with("/workspaces/") && ROUTES.iter().any(|other| other.op == op && other.path.starts_with("/repos/")) {
640 format!("{base}_for_workspace")
641 } else {
642 base
643 }
644}
645
646/// The summary of a route: its operation's title, or for one of GitHub's
647/// alternative addresses, what that address does.
648fn summary(route: &Route, id: &str) -> String {
649 let base = match id.trim_end_matches("_for_workspace") {
650 "enable_workflow" => "Turn a workflow on",
651 "disable_workflow" => "Turn a workflow off",
652 "rerun_failed_jobs" => "Re-run failed jobs",
653 "update_actions_variable" => "Update a variable",
654 "list_runs_of_workflow" => "List a workflow's runs",
API: notifications over REST and MCP, with notifications scopes655 "list_repo_notifications" => "List a repository's notifications",
656 "mark_repo_notifications_read" => "Mark a repository's notifications read",
657 "get_issue_subscription" => "Get your subscription to an issue",
658 "set_issue_subscription" => "Subscribe to an issue",
659 "delete_issue_subscription" => "Unsubscribe from an issue",
660 "unsave_thread" => "Unsave a thread",
661 "unsnooze_thread" => "Bring a snoozed thread back",
Merge branch 'worktree-agent-ab2e39e11a6493412'662 _ => title(route.op),
663 };
664 if id.ends_with("_for_workspace") {
665 format!("{base} for a workspace")
666 } else {
667 base.to_owned()
668 }
669}
670
API and MCP server in Rust; a public index at the API root671fn operation(route: &Route) -> Value {
672 let op = route.op;
673 let path_params: Vec<&str> = route.params().collect();
674 // `owner` and `name` in the path stand for the operation's `repo` input.
675 let covered = |name: &str| name == "repo" || path_params.contains(&name);
Merge branch 'worktree-agent-ab2e39e11a6493412'676 let all_properties = op.properties();
677 let mut properties = all_properties.clone();
API and MCP server in Rust; a public index at the API root678 properties.retain(|name, _| !covered(name));
679 let required: Vec<String> = op
680 .required()
681 .into_iter()
682 .filter(|name| !covered(name))
683 .collect();
684
685 let mut parameters: Vec<Value> = path_params
686 .iter()
Merge branch 'worktree-agent-ab2e39e11a6493412'687 .map(|name| parameter(name, "path", true, all_properties.get(*name)))
API and MCP server in Rust; a public index at the API root688 .collect();
689 let mut body = Value::Null;
690 if route.method == "GET" {
691 for (name, key) in route.query {
Merge branch 'worktree-agent-ab2e39e11a6493412'692 parameters.push(parameter(
693 name,
694 "query",
695 required.iter().any(|required| required == key),
696 properties.get(*key),
697 ));
API and MCP server in Rust; a public index at the API root698 }
699 } else if !properties.is_empty() {
700 let mut schema = json!({ "type": "object", "properties": properties });
701 if !required.is_empty() {
702 schema["required"] = json!(required);
703 }
704 body = json!({
705 "required": !required.is_empty(),
706 "content": { "application/json": { "schema": schema } },
707 });
708 }
709
Merge branch 'worktree-agent-ab2e39e11a6493412'710 let id = operation_id(route);
711 let mut responses = Map::new();
712 responses.insert(
713 "200".into(),
714 json!({
715 "description": "Success.",
716 "content": { "application/json": { "schema": {} } },
717 }),
718 );
719 responses.insert(
720 "401".into(),
721 error_response("A token is required, or the one sent is not valid."),
722 );
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look723 if let Some(reason) = may_need_payment(op) {
724 responses.insert("402".into(), error_response(reason));
Merge branch 'worktree-agent-ab2e39e11a6493412'725 }
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step726 responses.insert(
727 "403".into(),
728 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."),
729 );
Search across all of g1t, Explore, and a command palette730 if !matches!(op, Op::Whoami | Op::ListRepos | Op::Search) {
Merge branch 'worktree-agent-ab2e39e11a6493412'731 responses.insert("404".into(), error_response("It does not exist, or you cannot see it."));
732 }
733 if route.method != "GET" {
734 responses.insert(
735 "409".into(),
736 error_response("The request conflicts with the current state."),
737 );
738 }
739 if op != Op::Whoami {
740 responses.insert("422".into(), error_response("The input is not valid."));
741 }
742 // 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 step743 let scope: Vec<&str> = scope_for(op.name()).map(|scope| scope.as_str()).into_iter().collect();
Merge branch 'worktree-agent-ab2e39e11a6493412'744 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 step745 json!([{ "token": scope }])
Webhooks: every event, to your own addresses, signed and retried746 } else {
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step747 json!([{ "token": scope }, {}])
Webhooks: every event, to your own addresses, signed and retried748 };
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step749 let (tool, action) = crate::tools::TOOLS
750 .iter()
751 .find_map(|tool| {
752 tool.actions
753 .iter()
754 .find(|action| action.op == op)
755 .map(|action| (tool.name, action.name))
756 })
757 .unwrap_or_default();
API and MCP server in Rust; a public index at the API root758 let mut described = json!({
Webhooks: every event, to your own addresses, signed and retried759 "operationId": id,
API and MCP server in Rust; a public index at the API root760 "tags": [tag(op)],
Merge branch 'worktree-agent-ab2e39e11a6493412'761 "summary": summary(route, &id),
API and MCP server in Rust; a public index at the API root762 "description": op.description(),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step763 "x-operation": op.name(),
764 "x-mcp-tool": tool,
765 "x-mcp-action": action,
766 "x-scope": scope.first().copied(),
Merge branch 'worktree-agent-ab2e39e11a6493412'767 "security": security,
API and MCP server in Rust; a public index at the API root768 "parameters": parameters,
Merge branch 'worktree-agent-ab2e39e11a6493412'769 "responses": responses,
API and MCP server in Rust; a public index at the API root770 });
771 if !body.is_null() {
772 described["requestBody"] = body;
773 }
774 described
775}
776
777/// Entries for device sign-in, which is not an operation.
778fn onboarding() -> Map<String, Value> {
779 let paths = json!({
Agents as a team: lifecycle, merge queue, billing and a new shell780 "/device/code": {
API and MCP server in Rust; a public index at the API root781 "post": {
782 "operationId": "device_code",
783 "tags": ["Accounts"],
784 "summary": "Start signing in",
Agents as a team: lifecycle, merge queue, billing and a new shell785 "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 root786 "security": [],
787 "requestBody": {
788 "content": { "application/json": { "schema": {
789 "type": "object",
790 "properties": {
791 "client_name": {
792 "type": "string",
793 "description": "What is asking, shown to the person approving. For example, Claude Code.",
794 },
795 },
796 } } },
797 },
798 "responses": { "200": {
799 "description": "The codes for this sign-in.",
800 "content": { "application/json": { "schema": {
801 "type": "object",
802 "properties": {
Agents as a team: lifecycle, merge queue, billing and a new shell803 "device_code": { "type": "string", "description": "Secret. Send it to /device/token." },
API and MCP server in Rust; a public index at the API root804 "user_code": { "type": "string", "description": "Shown to the person, like WDJB-MJHT." },
805 "verification_uri": { "type": "string" },
806 "verification_uri_complete": {
807 "type": "string",
808 "description": "The link to give the person; it carries the code.",
809 },
810 "expires_in": { "type": "integer", "description": "Seconds until the codes expire." },
811 "interval": { "type": "integer", "description": "Seconds to wait between polls." },
812 },
813 } } },
814 } },
815 },
816 },
Agents as a team: lifecycle, merge queue, billing and a new shell817 "/device/token": {
API and MCP server in Rust; a public index at the API root818 "post": {
819 "operationId": "device_token",
820 "tags": ["Accounts"],
821 "summary": "Finish signing in",
822 "description": "Asks whether the person has approved. Poll no faster than the interval. The token is returned once.",
823 "security": [],
824 "requestBody": {
825 "required": true,
826 "content": { "application/json": { "schema": {
827 "type": "object",
828 "required": ["device_code"],
829 "properties": { "device_code": { "type": "string" } },
830 } } },
831 },
832 "responses": { "200": {
833 "description": "The state of the sign-in.",
834 "content": { "application/json": { "schema": {
835 "type": "object",
836 "required": ["status"],
837 "properties": {
838 "status": { "type": "string", "enum": ["pending", "approved", "denied", "expired"] },
839 "token": { "type": "string", "description": "Present when approved." },
840 "username": { "type": "string" },
841 "verified": {
842 "type": "boolean",
843 "description": "Whether the account's email is confirmed.",
844 },
845 },
846 } } },
847 } },
848 },
849 },
850 });
851 match paths {
852 Value::Object(paths) => paths,
853 _ => Map::new(),
854 }
855}
856
Merge branch 'worktree-agent-ab2e39e11a6493412'857
858/// Puts each operation's examples, where it has them, into its request
859/// and response. Path and query values go under `x-example-params` and
860/// `x-example-query`, which tools that build a request can use.
861fn attach_examples(paths: &mut Map<String, Value>) {
862 let examples = examples();
863 for methods in paths.values_mut() {
864 let Some(methods) = methods.as_object_mut() else { continue };
865 for operation in methods.values_mut() {
866 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 step867 let name = operation["x-operation"].as_str().unwrap_or_default().to_owned();
868 let Some(example) = examples.get(&id).or_else(|| examples.get(&name)) else {
Merge branch 'worktree-agent-ab2e39e11a6493412'869 continue;
870 };
871 if let Some(notes) = example.get("notes").and_then(Value::as_str) {
872 let description = operation["description"].as_str().unwrap_or_default();
873 operation["description"] = json!(format!("{description}\n\n{notes}"));
874 }
875 if let Some(response) = example.get("response") {
876 let content = &mut operation["responses"]["200"]["content"]["application/json"];
877 if content.is_object() {
878 content["example"] = response.clone();
879 }
880 }
881 if let Some(request) = example.get("request") {
882 let content = &mut operation["requestBody"]["content"]["application/json"];
883 if content.is_object() {
884 content["example"] = request.clone();
885 }
886 }
887 for (key, extension) in [("params", "x-example-params"), ("query", "x-example-query")] {
888 if let Some(values) = example.get(key) {
889 operation[extension] = values.clone();
890 }
891 }
892 }
893 }
894}
895
API and MCP server in Rust; a public index at the API root896pub fn document() -> Value {
897 let mut paths = onboarding();
898 for route in ROUTES {
899 let entry = paths
900 .entry(openapi_path(route))
901 .or_insert_with(|| json!({}));
902 entry[route.method.to_lowercase()] = operation(route);
903 }
Merge branch 'worktree-agent-ab2e39e11a6493412'904 attach_examples(&mut paths);
905 let tags: Vec<Value> = SECTIONS
906 .iter()
907 .map(|(name, description, ops)| {
908 json!({
909 "name": name,
910 "description": description,
911 // The section's operations in reading order, by MCP tool name.
912 "x-tools": ops.iter().map(|op| op.name()).collect::<Vec<_>>(),
913 })
914 })
915 .collect();
916 let codes = ["unauthenticated", "payment_required", "forbidden", "not_found", "conflict", "invalid"];
API and MCP server in Rust; a public index at the API root917 json!({
918 "openapi": "3.1.0",
919 "info": {
920 "title": "g1t API",
921 "version": "1",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API922 "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 root923 "license": { "name": "MIT", "identifier": "MIT" },
924 },
925 "servers": [{ "url": "https://api.g1t.sh" }],
926 "security": [{ "token": [] }, {}],
Merge branch 'worktree-agent-ab2e39e11a6493412'927 "tags": tags,
API and MCP server in Rust; a public index at the API root928 "paths": paths,
929 "components": {
930 "securitySchemes": {
931 "token": {
932 "type": "http",
933 "scheme": "bearer",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step934 "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 root935 },
936 },
937 "schemas": {
938 "Error": {
939 "type": "object",
940 "required": ["error"],
941 "properties": {
942 "error": {
943 "type": "object",
944 "required": ["code", "message"],
945 "properties": {
Merge branch 'worktree-agent-ab2e39e11a6493412'946 "code": { "type": "string", "enum": codes },
API and MCP server in Rust; a public index at the API root947 "message": { "type": "string" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step948 "needed_scope": {
949 "type": "string",
950 "description": "On a 403 for an access token without the scope the call needs: that scope, such as `issues:write`.",
951 },
API and MCP server in Rust; a public index at the API root952 },
953 },
954 },
955 },
956 },
957 },
958 })
959}
960
961#[cfg(test)]
962mod tests {
963 use super::*;
964
965 #[test]
966 fn every_route_is_documented_once() {
967 let document = document();
968 let mut ids = Vec::new();
969 for (_, methods) in document["paths"].as_object().unwrap() {
970 for (_, operation) in methods.as_object().unwrap() {
971 ids.push(operation["operationId"].as_str().unwrap().to_owned());
972 }
973 }
974 for op in Op::ALL {
975 assert_eq!(
976 ids.iter().filter(|id| *id == op.name()).count(),
977 1,
978 "{}",
979 op.name()
980 );
981 }
Webhooks: every event, to your own addresses, signed and retried982 let mut unique = ids.clone();
983 unique.sort();
984 unique.dedup();
985 assert_eq!(unique.len(), ids.len(), "operation ids repeat");
API and MCP server in Rust; a public index at the API root986 }
987
988 #[test]
989 fn path_and_query_inputs_are_not_repeated_in_the_body() {
990 let document = document();
Agents as a team: lifecycle, merge queue, billing and a new shell991 let merge = &document["paths"]["/repos/{owner}/{name}/pulls/{number}/merge"]["post"];
API and MCP server in Rust; a public index at the API root992 let body = &merge["requestBody"]["content"]["application/json"]["schema"]["properties"];
993 assert!(body.get("keep_issue_open").is_some());
994 assert!(body.get("repo").is_none() && body.get("number").is_none());
Agents as a team: lifecycle, merge queue, billing and a new shell995 let list = &document["paths"]["/repos"]["get"];
API and MCP server in Rust; a public index at the API root996 assert_eq!(list["parameters"][0]["name"], "q");
997 assert!(list.get("requestBody").is_none());
998 }
999
1000 #[test]
Merge branch 'worktree-agent-ab2e39e11a6493412'1001 fn every_operation_is_in_one_section() {
1002 for op in Op::ALL {
1003 let sections = SECTIONS
1004 .iter()
1005 .filter(|(_, _, ops)| ops.contains(&op))
1006 .count();
1007 assert_eq!(sections, 1, "{}", op.name());
1008 }
1009 }
1010
1011 #[test]
API and MCP server in Rust; a public index at the API root1012 fn titles_read_as_sentences() {
Merge branch 'worktree-agent-ab2e39e11a6493412'1013 assert_eq!(title(Op::CreateIssue), "Create an issue");
API and MCP server in Rust; a public index at the API root1014 assert_eq!(title(Op::Whoami), "Get the current user");
1015 }
Merge branch 'worktree-agent-ab2e39e11a6493412'1016
1017 #[test]
1018 fn every_operation_has_an_example_response() {
1019 let examples = examples();
1020 assert!(!examples.is_empty(), "reference.json does not parse");
1021 let document = document();
1022 let mut known = Vec::new();
1023 for (path, methods) in document["paths"].as_object().unwrap() {
1024 for (method, operation) in methods.as_object().unwrap() {
1025 known.push(operation["operationId"].as_str().unwrap().to_owned());
1026 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1027 assert!(!example.is_null(), "{method} {path} has no example response");
1028 }
1029 }
1030 for id in examples.keys() {
1031 assert!(known.contains(id), "reference.json names {id}, which is not an operation");
1032 }
1033 }
1034
1035 #[test]
1036 fn example_requests_send_only_what_the_body_takes() {
1037 let document = document();
1038 for (path, methods) in document["paths"].as_object().unwrap() {
1039 for (method, operation) in methods.as_object().unwrap() {
1040 let content = &operation["requestBody"]["content"]["application/json"];
1041 let Some(example) = content["example"].as_object() else { continue };
1042 let properties = &content["schema"]["properties"];
1043 for key in example.keys() {
1044 assert!(!properties[key].is_null(), "{method} {path}: {key} is not in the body");
1045 }
1046 }
1047 }
1048 }
1049
1050 /// The docs site's copy of the document. Run with `G1T_WRITE_OPENAPI=1`
1051 /// to rewrite it after changing an operation.
1052 #[test]
1053 fn the_docs_copy_is_current() {
1054 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../docs/src/data/openapi.json");
1055 let current = serde_json::to_string_pretty(&document()).unwrap() + "\n";
1056 if std::env::var_os("G1T_WRITE_OPENAPI").is_some() {
1057 std::fs::write(path, &current).unwrap();
1058 return;
1059 }
1060 let copy = std::fs::read_to_string(path).unwrap_or_default().replace("\r\n", "\n");
1061 assert!(
1062 copy == current,
1063 "apps/docs/src/data/openapi.json is out of date: run G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi"
1064 );
1065 }
API reference: no example reads as a real secret1066
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1067 /// The reference shows responses as they are sent: `snake_case`.
1068 #[test]
1069 fn example_responses_are_snake_case() {
1070 let document = document();
1071 for (path, methods) in document["paths"].as_object().unwrap() {
1072 for (method, operation) in methods.as_object().unwrap() {
1073 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1074 let leaked = g1t_kit::wire::camel_case_keys(example);
1075 assert!(leaked.is_empty(), "{method} {path} shows {leaked:?}");
1076 }
1077 }
1078 }
1079
API reference: no example reads as a real secret1080 /// Examples never hold anything that reads as a real credential, which
1081 /// secret scanners rightly flag in a public repository: they end in `…`
1082 /// after the prefix, as `whsec_…` and `g1t_…` do.
1083 #[test]
1084 fn examples_hold_no_real_looking_secrets() {
Fast pages, required checks on the branch, self-hosted runners, honest incidents1085 let prefixes = ["whsec_", "g1t_", "g1tr_", "g1trt_", "sk_live_", "sk_test_", "ghp_", "github_pat_", "xoxb-", "AKIA"];
API reference: no example reads as a real secret1086 for (line, text) in REFERENCE.lines().enumerate() {
1087 for prefix in prefixes {
1088 let mut rest = text;
1089 while let Some(at) = rest.find(prefix) {
1090 let after = &rest[at + prefix.len()..];
1091 let run = after.chars().take_while(|c| c.is_ascii_alphanumeric()).count();
1092 assert!(
1093 run < 12,
1094 "reference.json line {}: `{prefix}` followed by {run} characters reads as a real secret; write `{prefix}…`",
1095 line + 1
1096 );
1097 rest = after;
1098 }
1099 }
1100 }
1101 }
API and MCP server in Rust; a public index at the API root1102}

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