Skip to content
1,365 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.

Fixes from the page sweep1//! The OpenAPI document, generated from the same list the routes are.
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.
6
7use g1t_contracts::scopes::scope_for;
8use serde_json::{Map, Value, json};
9
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9710use crate::about::AboutOp;
The artifacts service is services/artifacts, the Worker g1t-artifacts, bound as ARTIFACTS by the API, the site and the agents; its live rooms move to it with a Durable Object transfer from g1t-docs-service, and its database, bucket, indexes and queue keep their names. The git store's binding and settings are GITSTORE, its ops scripts gitstore-*, and workflow run artifacts keep their compatible API under run_artifacts modules. The deploy tool puts a Worker that has never deployed before the Workers in its stage that bind to it, and the deploy guide gives the cutover runbook.11use crate::run_artifacts::ArtifactsOp;
Merge GitHub pull request #8 (claude/cool-newton-7nm8r9): Docker deployments on g1t.page behind a switch that stays off until Cloudflare's container APIs are checked live, workflows a workspace manages in its repositories, tarball and zipball downloads, refs/pull/* kept to g1t alone, framework detection for g1t.page builds, and a workflow's event payload matching GitHub's.12use crate::archives::ArchiveOp;
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca13use crate::deploy_keys::DeployKeysOp;
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9714use crate::deployments::DeploymentsOp;
Projects have Observability: their requests, logs, traces, metrics and errors, from apps on g1t.page with nothing to set up, and from software anywhere else over OpenTelemetry.15use crate::telemetry::TelemetryOp;
Merge packages: roles, Actions access, source label, soft delete, API16use crate::packages::PackagesOp;
Merge main into Artifacts Phase 217use crate::folios::FoliosOp;
Merge branch 'worktree-agent-a3abfcce648e87dca'18use crate::protection::ProtectionOp;
API and MCP for a workspace's personal access token rules, members' tokens and approvals19use crate::token_policy::TokenOp;
Fixes from the page sweep20use crate::operations::Op;
Merge checks: statuses and check runs on every commit21use crate::checks::ChecksOp;
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge22use crate::rules::RulesOp;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar23use crate::security::SecurityOp;
Fixes from the page sweep24use crate::rest::{ROUTES, Route};
25
26/// The sections of the API reference: a name, what it covers, and its
27/// operations in the order a reader meets them.
28const SECTIONS: &[(&str, &str, &[Op])] = &[
29 (
30 "Accounts",
31 "Signing in from a tool, who a token acts as, and your email addresses.",
Merge email confirmation gate: a code and a link, nothing until confirmed (identity 0036)32 &[Op::Whoami, Op::ListEmails, Op::AddEmail, Op::ConfirmEmail, Op::RemoveEmail, Op::UpdateEmailSettings],
Fixes from the page sweep33 ),
34 (
API: notifications over REST and MCP, with notifications scopes35 "Notifications",
36 "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.",
37 &[
38 Op::ListNotifications,
39 Op::MarkNotificationsRead,
40 Op::GetNotificationThread,
41 Op::MarkThreadRead,
42 Op::MarkThreadDone,
43 Op::SaveThread,
44 Op::SnoozeThread,
45 Op::GetThreadSubscription,
46 Op::SetThreadSubscription,
47 Op::DeleteThreadSubscription,
48 Op::GetRepoSubscription,
49 Op::SetRepoSubscription,
50 Op::DeleteRepoSubscription,
51 Op::ListWatchedRepos,
52 ],
53 ),
54 (
API: pinned projects over REST and MCP55 "Pinned projects",
56 "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.",
57 &[Op::ListPinnedProjects, Op::PinProject, Op::UnpinProject, Op::ReorderPinnedProjects],
58 ),
59 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9760 "Projects",
61 "A project is what a workspace builds and runs, from a repository or a root directory in one. Each says what it is, where it runs and where to find it: its homepage, docs and other links.",
62 &[Op::ListProjects, Op::GetProject, Op::UpdateProject],
63 ),
64 (
Fixes from the page sweep65 "Workspaces",
66 "A workspace owns repositories and is the first part of their address. People and agents work in workspaces.",
Merge branch 'worktree-agent-ad7c6d88d93adc817'67 &[Op::GetWorkspace, Op::CreateWorkspace, Op::UpdateWorkspace, Op::DeleteWorkspace],
Fixes from the page sweep68 ),
69 (
API and MCP for a workspace's personal access token rules, members' tokens and approvals70 "Personal access tokens",
One kind of access token; presence and status; usernames keep their case; the tour is a miniature of the real app; icons for password managers71 "A workspace's rules for its members' personal access tokens: whether tokens made for all of a member's workspaces reach it, whether tokens may be made for it alone and wait for an owner's approval, and how long a token may last; the tokens that reach it, approving or denying the ones that wait, and revoking one there. Owners only, as people.",
API and MCP for a workspace's personal access token rules, members' tokens and approvals72 &[
73 Op::Tokens(TokenOp::GetTokenPolicy),
74 Op::Tokens(TokenOp::SetTokenPolicy),
75 Op::Tokens(TokenOp::ListMemberTokens),
76 Op::Tokens(TokenOp::ListTokenRequests),
77 Op::Tokens(TokenOp::ReviewTokenRequest),
78 Op::Tokens(TokenOp::RevokeMemberToken),
79 ],
80 ),
81 (
Merge main (membership, two-factor, GitHub repo roles) into tokens82 "Members",
83 "A workspace's members and owners: who belongs to it, their roles (owner or member, with billing manager and security manager on top), handing it to another member, and leaving it.",
84 &[Op::ListMembers, Op::UpdateMember, Op::RemoveMember, Op::TransferOwnership, Op::LeaveWorkspace],
85 ),
86 (
Fixes from the page sweep87 "Invites",
Merge main into rm-agents: mirroring removal, open signups, free-tier limits, the g1t CLI and runner fixes, with the agent removal kept. The CLI's table of operations is regenerated from the API without the agent, customize and AI credit operations; no CLI command used them.88 "Inviting people into a workspace by username or email, and answering the invitations to workspaces sent to you.",
Fixes from the page sweep89 &[
90 Op::ListWorkspaceInvites,
91 Op::InviteMember,
92 Op::RevokeWorkspaceInvite,
Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040)93 Op::ListInvitations,
94 Op::AcceptInvitation,
95 Op::DeclineInvitation,
Fixes from the page sweep96 ],
97 ),
98 (
Usage, Billing settings and prepaid AI credit; fixes from the UX audit99 "Billing",
Billing, integrations, security and identity no longer serve g1t's own agents. Billing stops metering agent runs, model tokens and AI Gateway requests, drops its model catalogue and price-keeper model prices, and stops selling AI credit, which only ever paid for those; credit bought earlier still pays toward what is owed. A usage report, statement or invoice that holds an old agent or model meter shows it as "Other usage" rather than failing, and the get_ai_credit and buy_ai_credit API operations and MCP billing actions go. Integrations no longer connects model providers or routes models, and no longer assigns imported issues or alerts to g1t; a model provider already connected can still be disconnected. Security drops "Fix with g1t". Identity no longer creates agent tokens or puts agents on teams, a team's lead is a person, and run credentials are issued only for checks, the merge queue, merge checks, deployments and bumps; tokens and credentials already issued keep working until they expire. The reserved names g1t and g1t-agent stay reserved. No tables are dropped.100 "A workspace's usage, its budget and its invoices. Members read them; owners change the budget, as people. A run's token never changes billing.",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit101 &[
102 Op::GetUsage,
103 Op::GetBudget,
104 Op::SetBudget,
105 Op::ListInvoices,
106 Op::GetBillingDetails,
107 ],
108 ),
109 (
Fixes from the page sweep110 "Repositories",
Merge GitHub pull request #8 (claude/cool-newton-7nm8r9): Docker deployments on g1t.page behind a switch that stays off until Cloudflare's container APIs are checked live, workflows a workspace manages in its repositories, tarball and zipball downloads, refs/pull/* kept to g1t alone, framework detection for g1t.page builds, and a workflow's event payload matching GitHub's.111 "A repository, how it handles pull requests, and its timeline: renaming, archiving, moving and deleting it; and its files at a branch, tag or commit as a tarball or zipball.",
Fixes from the page sweep112 &[
113 Op::ListRepos,
114 Op::CreateRepo,
115 Op::GetRepo,
Merge GitHub pull request #8 (claude/cool-newton-7nm8r9): Docker deployments on g1t.page behind a switch that stays off until Cloudflare's container APIs are checked live, workflows a workspace manages in its repositories, tarball and zipball downloads, refs/pull/* kept to g1t alone, framework detection for g1t.page builds, and a workflow's event payload matching GitHub's.116 Op::Archives(ArchiveOp::DownloadTarball),
117 Op::Archives(ArchiveOp::DownloadZipball),
Fixes from the page sweep118 Op::UpdateRepo,
119 Op::RenameRepo,
120 Op::RenameBranch,
The Branches page does things to branches now. It has tabs (Overview, Yours, Active, Stale, All, kept in the address as ?tab=) and search; Overview shows the default branch, then the first five of your branches, the active ones and the stale ones, each linking to the rest. Each branch is a row with its name in a code chip with a copy button, who made its latest commit and when, that commit's checks, behind and ahead counts with bars drawn against the largest shown, and its pull request (the open one, else the newest merged or closed) with its state; on a phone the columns fold under the name. Yours is branches whose latest commit is the viewer's; stale is no commit in 90 days.121 Op::CreateBranch,
122 Op::DeleteBranch,
Fixes from the page sweep123 Op::SetRepoVisibility,
124 Op::ArchiveRepo,
125 Op::UnarchiveRepo,
126 Op::TransferRepo,
127 Op::DeleteRepo,
128 Op::ListDeletedRepos,
129 Op::RestoreRepo,
130 Op::PurgeRepo,
131 Op::GetRepoSettings,
132 Op::UpdateRepoSettings,
133 Op::ListCheckNames,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar134 Op::GetCodeownersErrors,
Fixes from the page sweep135 Op::ListEvents,
136 ],
137 ),
138 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97139 "Repository insights",
140 "What a repository's default branch says about it, read in the background and kept by commit: the languages it is written in, who made it, and its license.",
141 &[Op::About(AboutOp::GetLanguages), Op::About(AboutOp::ListContributors), Op::About(AboutOp::GetLicense)],
142 ),
143 (
144 "Stars",
145 "Starring a repository, to keep it and to say you like it: who starred one, and what you starred.",
146 &[
147 Op::About(AboutOp::ListStargazers),
148 Op::About(AboutOp::ListStarred),
149 Op::About(AboutOp::CheckStarred),
150 Op::About(AboutOp::Star),
151 Op::About(AboutOp::Unstar),
152 ],
153 ),
154 (
155 "Releases",
156 "A release is a tag published with a title and notes. The latest is the newest published one that is neither a draft nor a prerelease.",
157 &[
158 Op::About(AboutOp::ListReleases),
159 Op::About(AboutOp::CreateRelease),
160 Op::About(AboutOp::GetLatestRelease),
161 Op::About(AboutOp::GetReleaseByTag),
162 Op::About(AboutOp::GetRelease),
163 Op::About(AboutOp::UpdateRelease),
164 Op::About(AboutOp::DeleteRelease),
165 ],
166 ),
167 (
Fixes from the page sweep168 "Access",
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca169 "Who can do what in a repository: repository roles, people given a role on one repository (outside collaborators when they are not members), invitations, a workspace's base permission, and deploy keys: SSH keys that reach one repository.",
Fixes from the page sweep170 &[
171 Op::ListCollaborators,
172 Op::AddCollaborator,
173 Op::UpdateCollaborator,
174 Op::RemoveCollaborator,
175 Op::GetCollaboratorPermission,
176 Op::ListRepoInvitations,
177 Op::RevokeRepoInvitation,
178 Op::ListMyRepoInvitations,
179 Op::AcceptRepoInvitation,
180 Op::DeclineRepoInvitation,
181 Op::SetBasePermission,
182 Op::ListOutsideCollaborators,
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca183 Op::DeployKeys(DeployKeysOp::ListDeployKeys),
184 Op::DeployKeys(DeployKeysOp::GetDeployKey),
185 Op::DeployKeys(DeployKeysOp::CreateDeployKey),
186 Op::DeployKeys(DeployKeysOp::DeleteDeployKey),
Merge branch 'mirroring' into artifacts-mode187 ],
188 ),
189 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar190 "Teams",
191 "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.",
192 &[
193 Op::ListTeams,
194 Op::CreateTeam,
195 Op::GetTeam,
196 Op::UpdateTeam,
197 Op::DeleteTeam,
198 Op::ListTeamMembers,
199 Op::SetTeamMember,
200 Op::RemoveTeamMember,
201 Op::ListChildTeams,
202 Op::ListTeamRepos,
203 Op::SetTeamRepo,
204 Op::RemoveTeamRepo,
205 Op::SetTeamReviewAssignment,
206 Op::ListUserTeams,
207 ],
208 ),
209 (
Fixes from the page sweep210 "Security",
211 "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.",
212 &[Op::ListSecurityAlerts, Op::DismissSecurityAlert, Op::ReopenSecurityAlert],
213 ),
214 (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar215 "Secret scanning",
216 "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.",
217 &[
218 Op::Security(SecurityOp::ListSecretAlerts),
219 Op::Security(SecurityOp::GetSecretAlert),
220 Op::Security(SecurityOp::UpdateSecretAlert),
221 Op::Security(SecurityOp::ListSecretLocations),
222 Op::Security(SecurityOp::BypassPushProtection),
223 Op::Security(SecurityOp::CheckSecretValidity),
224 Op::Security(SecurityOp::ListBypassRequests),
225 Op::Security(SecurityOp::ReviewBypassRequest),
226 Op::Security(SecurityOp::ListCustomPatterns),
227 Op::Security(SecurityOp::CreateCustomPattern),
228 Op::Security(SecurityOp::UpdateCustomPattern),
229 Op::Security(SecurityOp::DeleteCustomPattern),
230 Op::Security(SecurityOp::DryRunCustomPattern),
231 ],
232 ),
233 (
234 "Code scanning",
235 "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.",
236 &[
237 Op::Security(SecurityOp::ListCodeAlerts),
238 Op::Security(SecurityOp::GetCodeAlert),
239 Op::Security(SecurityOp::UpdateCodeAlert),
240 Op::Security(SecurityOp::ListAnalyses),
241 Op::Security(SecurityOp::UploadSarif),
242 Op::Security(SecurityOp::GetSarifUpload),
243 ],
244 ),
245 (
246 "Supply chain",
247 "What a repository depends on: vulnerability alerts, the dependency graph, an SPDX SBOM of it, and comparing two commits' dependencies as dependency review does.",
248 &[
249 Op::Security(SecurityOp::ListVulnerabilityAlerts),
250 Op::Security(SecurityOp::GetVulnerabilityAlert),
251 Op::Security(SecurityOp::UpdateVulnerabilityAlert),
252 Op::Security(SecurityOp::GetDependencyGraph),
253 Op::Security(SecurityOp::GetSbom),
254 Op::Security(SecurityOp::CompareDependencies),
255 ],
256 ),
257 (
258 "Security settings",
259 "When pull request checks fail, dependency review's policy, delegated bypass and validity checks, and a workspace's security overview.",
260 &[
261 Op::Security(SecurityOp::GetSettings),
262 Op::Security(SecurityOp::UpdateSettings),
263 Op::Security(SecurityOp::GetWorkspaceSettings),
264 Op::Security(SecurityOp::UpdateWorkspaceSettings),
265 Op::Security(SecurityOp::GetOverview),
266 ],
267 ),
268 (
Merge remote-tracking branch 'origin/claude/cool-newton-7nm8r9' into claude/cool-newton-7nm8r9269 "Security advisories",
270 "What a repository says about vulnerabilities in what it ships: advisories drafted, published and withdrawn by its maintainers, and the vulnerability reports people send them privately when the repository takes them.",
271 &[
272 Op::Security(SecurityOp::ListAdvisories),
273 Op::Security(SecurityOp::CreateAdvisory),
274 Op::Security(SecurityOp::GetAdvisory),
275 Op::Security(SecurityOp::UpdateAdvisory),
276 Op::Security(SecurityOp::SetAdvisoryState),
277 Op::Security(SecurityOp::ListReports),
278 Op::Security(SecurityOp::ReportVulnerability),
279 Op::Security(SecurityOp::ReviewReport),
280 ],
281 ),
282 (
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge283 "Rules",
284 "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.",
285 &[
286 Op::Rules(RulesOp::ListRepoRulesets),
287 Op::Rules(RulesOp::CreateRepoRuleset),
288 Op::Rules(RulesOp::GetRepoRuleset),
289 Op::Rules(RulesOp::UpdateRepoRuleset),
290 Op::Rules(RulesOp::DeleteRepoRuleset),
291 Op::Rules(RulesOp::GetBranchRules),
292 Op::Rules(RulesOp::ListRuleEvaluations),
293 Op::Rules(RulesOp::ListWorkspaceRulesets),
294 Op::Rules(RulesOp::CreateWorkspaceRuleset),
295 Op::Rules(RulesOp::GetWorkspaceRuleset),
296 Op::Rules(RulesOp::UpdateWorkspaceRuleset),
297 Op::Rules(RulesOp::DeleteWorkspaceRuleset),
298 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
299 ],
300 ),
301 (
Merge checks: statuses and check runs on every commit302 "Checks",
303 "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.",
304 &[
305 Op::Checks(ChecksOp::CreateCommitStatus),
306 Op::Checks(ChecksOp::ListCommitStatuses),
307 Op::Checks(ChecksOp::GetCombinedStatus),
308 Op::Checks(ChecksOp::CreateCheckRun),
309 Op::Checks(ChecksOp::UpdateCheckRun),
310 Op::Checks(ChecksOp::GetCheckRun),
311 Op::Checks(ChecksOp::ListCheckRunAnnotations),
312 Op::Checks(ChecksOp::RerequestCheckRun),
313 Op::Checks(ChecksOp::ListCheckRunsForRef),
314 Op::Checks(ChecksOp::ListCheckSuitesForRef),
315 Op::Checks(ChecksOp::GetCheckSuite),
316 Op::Checks(ChecksOp::RerequestCheckSuite),
317 ],
318 ),
319 (
Fixes from the page sweep320 "Issues",
321 "What should change in a repository, with labels and comments. Issues and pull requests share one sequence of numbers.",
322 &[
323 Op::ListIssues,
324 Op::CreateIssue,
325 Op::GetIssue,
326 Op::UpdateIssue,
327 Op::CloseIssue,
328 Op::ReopenIssue,
329 Op::AddComment,
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts330 Op::EditComment,
331 Op::DeleteComment,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar332 Op::ListIssueLabels,
333 Op::AddIssueLabels,
334 Op::SetIssueLabels,
335 Op::RemoveIssueLabels,
336 ],
337 ),
338 (
339 "Labels and milestones",
340 "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.",
341 &[
Fixes from the page sweep342 Op::ListLabels,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar343 Op::CreateLabel,
344 Op::UpdateLabel,
345 Op::DeleteLabel,
346 Op::AddDefaultLabels,
347 Op::ListMilestones,
348 Op::CreateMilestone,
349 Op::GetMilestone,
350 Op::UpdateMilestone,
351 Op::DeleteMilestone,
Fixes from the page sweep352 ],
353 ),
354 (
355 "Pull requests",
356 "A proposed change in its own fork or on a branch. Several can be made for one issue; the one merged resolves it.",
357 &[
358 Op::ListPullRequests,
359 Op::CreatePullRequest,
360 Op::GetPullRequest,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar361 Op::UpdatePullRequest,
Fixes from the page sweep362 Op::GetPullRequestChanges,
363 Op::MarkPullRequestReady,
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts364 Op::ConvertPullRequestToDraft,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar365 Op::RequestReviewers,
366 Op::RemoveRequestedReviewers,
Fixes from the page sweep367 Op::ReviewPullRequest,
368 Op::MergePullRequest,
369 Op::ClosePullRequest,
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts370 Op::ReopenPullRequest,
Fixes from the page sweep371 Op::GetMergeQueue,
372 ],
373 ),
374 (
375 "Sessions",
376 "The record of how a pull request was made: prompts, reasoning and the tools that ran.",
377 &[Op::ReadSession, Op::RecordSession],
378 ),
379 (
Merge branch 'worktree-agent-ab8033ab973f8d99a'380 "Decisions and why",
381 "Decision records: why the work is the way it is, and how sure that is (claimed, tested by a check or the merge queue, or approved by a person). And why a line of code is the way it is: its commit, pull request, issue, decisions and session.",
382 &[Op::ListDecisions, Op::RecordDecision, Op::Why],
383 ),
384 (
Fixes from the page sweep385 "Memory",
The API and MCP server no longer offer g1t's own agents. g1t is what your coding agents work against, not an agent of its own, so the operations that drove hosted agents are gone: messaging an agent on a pull request (message_agent, take_messages, answer_message), assigning or delegating an issue to g1t (assign_issue, delegate), plans (plan_work, get_plan, apply_plan), the context hub (search_context, get_entity), model routes, agents' computers, AI Gateway requests, "Fix with g1t" on a security alert, and every Customize route (marketplaces, plugins, connectors). The callbacks the agent sandbox reported through (/agent-runs/*, /runs/:id/usage, /plans/:id, /reviews/:id) go with them, update_repo_settings stops accepting agent_review, max_revisions and hold_low_confidence, import_issue stops accepting assign, and an old agent token with no run behind it is refused.386 "What agents and people learned that the next agent should know, for one project or across a workspace. Members only; never a secret.",
Fixes from the page sweep387 &[Op::Remember, Op::Recall],
388 ),
389 (
390 "Search",
391 "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.",
392 &[Op::Search],
393 ),
394 (
395 "Actions",
396 "GitHub Actions workflows in .g1t/workflows, their runs, and their jobs' logs.",
397 &[
398 Op::ListWorkflows,
399 Op::ListWorkflowRuns,
400 Op::GetWorkflowRun,
401 Op::GetJobLogs,
402 Op::DispatchWorkflow,
403 Op::CancelWorkflowRun,
404 Op::RerunWorkflowRun,
405 Op::UpdateWorkflow,
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2406 Op::Artifacts(ArtifactsOp::ListArtifacts),
407 Op::Artifacts(ArtifactsOp::ListRunArtifacts),
408 Op::Artifacts(ArtifactsOp::GetArtifact),
409 Op::Artifacts(ArtifactsOp::DownloadArtifact),
410 Op::Artifacts(ArtifactsOp::DeleteArtifact),
411 Op::Artifacts(ArtifactsOp::GetArtifactRetention),
412 Op::Artifacts(ArtifactsOp::SetArtifactRetention),
Fixes from the page sweep413 ],
414 ),
415 (
Merge packages: roles, Actions access, source label, soft delete, API416 "Packages",
417 "A workspace's packages in every registry: their versions and download counts, deleting and restoring them within 30 days, their visibility and repository, the people and teams with a role on them, and which repositories' workflows may use them (Manage Actions access). A package is named by its type and its name, URL-encoded where it holds a slash.",
418 &[
419 Op::Packages(PackagesOp::ListPackages),
420 Op::Packages(PackagesOp::GetPackage),
421 Op::Packages(PackagesOp::UpdatePackage),
422 Op::Packages(PackagesOp::DeletePackage),
423 Op::Packages(PackagesOp::RestorePackage),
424 Op::Packages(PackagesOp::ListVersions),
425 Op::Packages(PackagesOp::GetVersion),
426 Op::Packages(PackagesOp::DeleteVersion),
427 Op::Packages(PackagesOp::RestoreVersion),
428 Op::Packages(PackagesOp::LinkPackage),
429 Op::Packages(PackagesOp::UnlinkPackage),
430 Op::Packages(PackagesOp::ListAccess),
431 Op::Packages(PackagesOp::SetAccess),
432 Op::Packages(PackagesOp::RemoveAccess),
433 Op::Packages(PackagesOp::ListActionsAccess),
434 Op::Packages(PackagesOp::SetActionsAccess),
435 Op::Packages(PackagesOp::RemoveActionsAccess),
436 ],
437 ),
438 (
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97439 "Deployments",
440 "A repository's deployments wherever they run: reported from any CI with these routes, made by g1t Actions jobs with an `environment:`, or built on g1t.page. Each has statuses, shows on its commit as the check `deploy / <environment>`, and belongs to an environment.",
441 &[
442 Op::Deployments(DeploymentsOp::ListDeployments),
443 Op::Deployments(DeploymentsOp::CreateDeployment),
444 Op::Deployments(DeploymentsOp::GetDeployment),
445 Op::Deployments(DeploymentsOp::ListDeploymentStatuses),
446 Op::Deployments(DeploymentsOp::CreateDeploymentStatus),
447 Op::Deployments(DeploymentsOp::ListEnvironments),
448 Op::Deployments(DeploymentsOp::GetEnvironment),
Merge branch 'worktree-agent-a4d35ee70c50683d0' into claude/cool-newton-7nm8r9449 Op::Deployments(DeploymentsOp::StartDeploymentBuild),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97450 ],
451 ),
452 (
Projects have Observability: their requests, logs, traces, metrics and errors, from apps on g1t.page with nothing to set up, and from software anywhere else over OpenTelemetry.453 "Observability",
454 "What a project's running software did: its requests, logs, traces, grouped errors and metrics, from its apps on g1t.page with nothing to set up and from OpenTelemetry (OTLP over HTTP) sent from anywhere with an ingest token. Reading needs a role of your own on the project's repository; resolving errors, Triage; settings, ingest tokens, exports and usage, Admin.",
455 &[
456 Op::Telemetry(TelemetryOp::GetOverview),
457 Op::Telemetry(TelemetryOp::ListRequests),
458 Op::Telemetry(TelemetryOp::GetRequest),
459 Op::Telemetry(TelemetryOp::ListLogs),
460 Op::Telemetry(TelemetryOp::ListTraces),
461 Op::Telemetry(TelemetryOp::GetTrace),
462 Op::Telemetry(TelemetryOp::ListErrors),
463 Op::Telemetry(TelemetryOp::UpdateError),
464 Op::Telemetry(TelemetryOp::ListMetrics),
465 Op::Telemetry(TelemetryOp::GetMetric),
466 Op::Telemetry(TelemetryOp::GetSettings),
467 Op::Telemetry(TelemetryOp::UpdateSettings),
468 Op::Telemetry(TelemetryOp::ListTokens),
469 Op::Telemetry(TelemetryOp::CreateToken),
470 Op::Telemetry(TelemetryOp::DeleteToken),
471 Op::Telemetry(TelemetryOp::ListExports),
472 Op::Telemetry(TelemetryOp::CreateExport),
473 Op::Telemetry(TelemetryOp::UpdateExport),
474 Op::Telemetry(TelemetryOp::DeleteExport),
475 Op::Telemetry(TelemetryOp::GetUsage),
476 ],
477 ),
478 (
Merge branch 'worktree-agent-a3abfcce648e87dca'479 "Run protection",
480 "What keeps workflow runs safe: environments' protection rules (required reviewers, a wait timer, which branches may deploy) and the reviews of the jobs they hold, approving a pull request's run from outside, what a job's token gets when its workflow writes no `permissions:`, and repository_dispatch, which a job's own token may send.",
481 &[
482 Op::Protection(ProtectionOp::UpdateEnvironment),
483 Op::Protection(ProtectionOp::DeleteEnvironment),
484 Op::Protection(ProtectionOp::GetPendingDeployments),
485 Op::Protection(ProtectionOp::ReviewPendingDeployments),
486 Op::Protection(ProtectionOp::ApproveWorkflowRun),
487 Op::Protection(ProtectionOp::GetWorkflowPermissions),
488 Op::Protection(ProtectionOp::SetWorkflowPermissions),
489 Op::Protection(ProtectionOp::GetForkPrApproval),
490 Op::Protection(ProtectionOp::SetForkPrApproval),
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts491 Op::Protection(ProtectionOp::GetActionsAccess),
492 Op::Protection(ProtectionOp::SetActionsAccess),
Merge branch 'worktree-agent-a3abfcce648e87dca'493 Op::Protection(ProtectionOp::CreateRepositoryDispatch),
494 Op::Protection(ProtectionOp::GetWorkspaceWorkflowPermissions),
495 Op::Protection(ProtectionOp::SetWorkspaceWorkflowPermissions),
Merge GitHub pull request #8 (claude/cool-newton-7nm8r9): Docker deployments on g1t.page behind a switch that stays off until Cloudflare's container APIs are checked live, workflows a workspace manages in its repositories, tarball and zipball downloads, refs/pull/* kept to g1t alone, framework detection for g1t.page builds, and a workflow's event payload matching GitHub's.496 Op::Protection(ProtectionOp::ListWorkspaceManagedWorkflows),
497 Op::Protection(ProtectionOp::CreateWorkspaceManagedWorkflow),
498 Op::Protection(ProtectionOp::UpdateWorkspaceManagedWorkflow),
499 Op::Protection(ProtectionOp::DeleteWorkspaceManagedWorkflow),
Merge branch 'worktree-agent-a3abfcce648e87dca'500 ],
501 ),
502 (
Fixes from the page sweep503 "Secrets and variables",
504 "Values that workflows and deployments read, per repository or for a whole workspace, with a row per environment.",
505 &[
506 Op::ListActionsSecrets,
507 Op::SetActionsSecret,
508 Op::DeleteActionsSecret,
509 Op::ListActionsVariables,
510 Op::SetActionsVariable,
511 Op::DeleteActionsVariable,
512 ],
513 ),
514 (
515 "Runners",
The API and MCP server no longer offer g1t's own agents. g1t is what your coding agents work against, not an agent of its own, so the operations that drove hosted agents are gone: messaging an agent on a pull request (message_agent, take_messages, answer_message), assigning or delegating an issue to g1t (assign_issue, delegate), plans (plan_work, get_plan, apply_plan), the context hub (search_context, get_entity), model routes, agents' computers, AI Gateway requests, "Fix with g1t" on a security alert, and every Customize route (marketplaces, plugins, connectors). The callbacks the agent sandbox reported through (/agent-runs/*, /runs/:id/usage, /plans/:id, /reviews/:id) go with them, update_repo_settings stops accepting agent_review, max_revisions and hold_low_confidence, import_issue stops accepting assign, and an old agent token with no run behind it is refused.516 "Self-hosted runners: your own machines, which run your workflow jobs for $0 of g1t compute. They register with a short-lived token and only ever connect out.",
Fixes from the page sweep517 &[
518 Op::ListRunners,
519 Op::CreateRunnerRegistrationToken,
520 Op::RemoveRunner,
521 Op::ListRunnerGroups,
522 Op::CreateRunnerGroup,
523 Op::UpdateRunnerGroup,
524 Op::DeleteRunnerGroup,
525 Op::GetRunnerSettings,
526 Op::UpdateRunnerSettings,
Every agent can have its own computer. A session that needs one wakes it: a home of its own on g1t cloud, one per agent and never shared, where it runs commands, reads and writes files and keeps what it made, with each session working in its own folder under a shared home; after ten idle minutes it sleeps, its home kept as a snapshot and restored when it wakes, and Reset wipes the home while memory and artifacts stay. Its shell and files are abilities with the usual choices, Alone, Alone when asked, Ask first or Never, offered only inside sessions and never to a chat reply; every command shows on the session with its output, and the agent's new Computer tab shows the state, the disk used of the five gigabytes included, the recent commands, and Wake, Put to sleep and Reset. Machine time counts only while it is awake, on the sandbox lines of the ledger that name the agent and who asked, held to the same spend caps as the session; the disk itself costs nothing in this version. The runner gained a long-lived supervisor that answers the computer's requests inside the container, and the runner service a computer per agent that keeps its snapshot in the agent homes bucket when one is attached, and says so when none is. The REST API and the agent tool can read a computer, wake it, put it to sleep and reset it. The agents, abilities, sessions, runners, billing and deploy guides say how it works and what an operator sets up; pinning a computer to your own runner, its browser and take-over come next.527 ],
528 ),
529 (
Fixes from the page sweep530 "Webhooks",
531 "Signed HTTPS requests sent to your own address as things happen, for a repository or a whole workspace.",
532 &[
533 Op::ListWebhooks,
534 Op::CreateWebhook,
535 Op::UpdateWebhook,
536 Op::DeleteWebhook,
537 Op::PingWebhook,
538 Op::ListWebhookDeliveries,
539 Op::RedeliverWebhook,
540 ],
541 ),
542 (
543 "Integrations",
The contracts no longer describe g1t's own agents, and workspaces can keep their AI providers. Every consumer had already stopped using them, so the TypeScript and Rust contracts drop the workspace-agent, ability, look, skill-library, context, runner-agent and mention modules, the chat and docs RPCs agents posted and read through, the folio agent methods, the agent_waiting notification, agent.asked and memory.changed events, AI credit, token and gateway billing types, model routes and sessions, team agents, agent tokens, plan, review, message and confidence types, command rules, cost caps and confidence rules. The agents:run and models:* scopes are no longer offered by any preset, OAuth default or permission form, but a stored token or grant that names them still reads; and the removed operations are gone from the scope table, so the API's check that every operation has exactly one scope is strict again. What stored data needs in order to parse (old run and credential kinds, an agent team lead, retired rules and webhook events, old guardrail and integration settings) still parses, and a run's token is still PrincipalKind::Agent, which now means a run's token and the @g1t rows written before. The customize, marketplace, skills and claude-plugin contracts stay only until the mobile app drops its Customize screens.544 "A workspace's connections to outside systems: AI providers, alert sources and issue trackers.",
Fixes from the page sweep545 &[
546 Op::ListIntegrations,
547 Op::ConnectIntegration,
AI Gateway: OpenAI's format, open models, and your own providers548 Op::UpdateIntegration,
Fixes from the page sweep549 Op::DisconnectIntegration,
550 Op::TestIntegration,
551 Op::GetContext,
552 Op::ImportIssue,
Merge remote-tracking branch 'origin/claude/cool-newton-7nm8r9' into claude/cool-newton-7nm8r9553 ],
554 ),
555 (
Merge main into Artifacts Phase 2556 "Artifacts",
557 "A workspace's docs, slides, designs and dashboards (Artifacts mode): listing and searching the ones you can open, reading and editing their content in Markdown, making, moving, trashing and restoring them, their versions, and who can open them. Each answers for your own role on it. Not workflow runs' artifacts, which are under Actions. Slides, designs and dashboards answer that they are not here yet.",
558 &[
559 Op::Folios(FoliosOp::List),
560 Op::Folios(FoliosOp::Search),
561 Op::Folios(FoliosOp::Get),
562 Op::Folios(FoliosOp::GetContent),
563 Op::Folios(FoliosOp::ListVersions),
564 Op::Folios(FoliosOp::GetAccess),
565 Op::Folios(FoliosOp::ListTemplates),
566 Op::Folios(FoliosOp::ListSpaces),
567 Op::Folios(FoliosOp::QueryDataset),
568 Op::Folios(FoliosOp::Create),
569 Op::Folios(FoliosOp::Update),
570 Op::Folios(FoliosOp::Edit),
571 Op::Folios(FoliosOp::Trash),
572 Op::Folios(FoliosOp::Restore),
573 Op::Folios(FoliosOp::RestoreVersion),
574 Op::Folios(FoliosOp::SetAccess),
575 Op::Folios(FoliosOp::Purge),
576 ],
577 ),
Fixes from the page sweep578];
579
580/// The section of the API reference an operation is listed under.
581fn tag(op: Op) -> &'static str {
582 SECTIONS
583 .iter()
584 .find(|(_, _, ops)| ops.contains(&op))
585 .map_or("Repositories", |(name, _, _)| name)
586}
587
588/// What an operation's page is called, as a short sentence.
589fn title(op: Op) -> &'static str {
590 match op {
591 Op::Whoami => "Get the current user",
Merge branch 'worktree-agent-ad7c6d88d93adc817'592 Op::GetWorkspace => "Get a workspace",
Fixes from the page sweep593 Op::CreateWorkspace => "Create a workspace",
594 Op::DeleteWorkspace => "Delete a workspace",
595 Op::UpdateWorkspace => "Update a workspace",
Merge main (membership, two-factor, GitHub repo roles) into tokens596 Op::ListMembers => "List a workspace's members",
597 Op::UpdateMember => "Change a member's role",
598 Op::RemoveMember => "Remove a member",
599 Op::TransferOwnership => "Transfer a workspace's ownership",
600 Op::LeaveWorkspace => "Leave a workspace",
Fixes from the page sweep601 Op::ListEmails => "List your email addresses",
602 Op::AddEmail => "Add an email address",
Merge email confirmation gate: a code and a link, nothing until confirmed (identity 0036)603 Op::ConfirmEmail => "Confirm an email address",
Fixes from the page sweep604 Op::RemoveEmail => "Remove an email address",
605 Op::UpdateEmailSettings => "Change your email settings",
606 Op::ListWorkspaceInvites => "List a workspace's invites",
607 Op::InviteMember => "Invite someone to a workspace",
Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040)608 Op::ListInvitations => "List your workspace invitations",
609 Op::AcceptInvitation => "Accept a workspace invitation",
610 Op::DeclineInvitation => "Decline a workspace invitation",
Fixes from the page sweep611 Op::RevokeWorkspaceInvite => "Revoke a workspace's invite",
612 Op::TransferRepo => "Transfer a repository",
613 Op::RenameRepo => "Rename a repository",
614 Op::RenameBranch => "Rename a branch",
The Branches page does things to branches now. It has tabs (Overview, Yours, Active, Stale, All, kept in the address as ?tab=) and search; Overview shows the default branch, then the first five of your branches, the active ones and the stale ones, each linking to the rest. Each branch is a row with its name in a code chip with a copy button, who made its latest commit and when, that commit's checks, behind and ahead counts with bars drawn against the largest shown, and its pull request (the open one, else the newest merged or closed) with its state; on a phone the columns fold under the name. Yours is branches whose latest commit is the viewer's; stale is no commit in 90 days.615 Op::CreateBranch => "Create a branch",
616 Op::DeleteBranch => "Delete a branch",
Fixes from the page sweep617 Op::ArchiveRepo => "Archive a repository",
618 Op::UnarchiveRepo => "Unarchive a repository",
619 Op::SetRepoVisibility => "Change a repository's visibility",
620 Op::DeleteRepo => "Delete a repository",
621 Op::ListDeletedRepos => "List recently deleted repositories",
622 Op::RestoreRepo => "Restore a deleted repository",
623 Op::PurgeRepo => "Purge a deleted repository",
624 Op::ListRepos => "List repositories",
625 Op::GetRepo => "Get a repository",
626 Op::CreateRepo => "Create a repository",
627 Op::UpdateRepo => "Update a repository",
628 Op::GetRepoSettings => "Get repository settings",
629 Op::UpdateRepoSettings => "Update repository settings",
630 Op::ListCheckNames => "List check names",
631 Op::GetMergeQueue => "Get the merge queue",
632 Op::Remember => "Remember something",
633 Op::Recall => "Recall memory",
634 Op::Search => "Search g1t",
635 Op::ListIssues => "List issues",
636 Op::GetIssue => "Get an issue",
637 Op::CreateIssue => "Create an issue",
638 Op::UpdateIssue => "Update an issue",
639 Op::CloseIssue => "Close an issue",
640 Op::ReopenIssue => "Reopen an issue",
641 Op::ListLabels => "List labels",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar642 Op::CreateLabel => "Create a label",
643 Op::UpdateLabel => "Update a label",
644 Op::DeleteLabel => "Delete a label",
645 Op::AddDefaultLabels => "Add the default labels",
646 Op::ListIssueLabels => "List an issue's labels",
647 Op::AddIssueLabels => "Add labels to an issue",
648 Op::SetIssueLabels => "Set an issue's labels",
649 Op::RemoveIssueLabels => "Remove labels from an issue",
650 Op::ListMilestones => "List milestones",
651 Op::GetMilestone => "Get a milestone",
652 Op::CreateMilestone => "Create a milestone",
653 Op::UpdateMilestone => "Update a milestone",
654 Op::DeleteMilestone => "Delete a milestone",
655 Op::UpdatePullRequest => "Update a pull request",
Fixes from the page sweep656 Op::AddComment => "Add a comment",
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts657 Op::EditComment => "Edit a comment",
658 Op::DeleteComment => "Delete a comment",
Fixes from the page sweep659 Op::ReviewPullRequest => "Review a pull request",
660 Op::ListPullRequests => "List pull requests",
661 Op::GetPullRequest => "Get a pull request",
662 Op::CreatePullRequest => "Create a pull request",
663 Op::RecordSession => "Record session entries",
664 Op::ReadSession => "Read a session",
Merge branch 'worktree-agent-ab8033ab973f8d99a'665 Op::RecordDecision => "Record a decision",
666 Op::ListDecisions => "List a pull request's decisions",
667 Op::Why => "Explain a line",
Fixes from the page sweep668 Op::MarkPullRequestReady => "Mark a pull request ready",
669 Op::ClosePullRequest => "Close a pull request",
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts670 Op::ReopenPullRequest => "Reopen a pull request",
671 Op::ConvertPullRequestToDraft => "Convert a pull request to a draft",
Fixes from the page sweep672 Op::GetPullRequestChanges => "Get a pull request's changes",
673 Op::MergePullRequest => "Merge a pull request",
674 Op::ListEvents => "List repository events",
675 Op::ListIntegrations => "List integrations",
676 Op::ConnectIntegration => "Connect an integration",
AI Gateway: OpenAI's format, open models, and your own providers677 Op::UpdateIntegration => "Update an integration",
Fixes from the page sweep678 Op::DisconnectIntegration => "Disconnect an integration",
679 Op::TestIntegration => "Test an integration",
680 Op::GetContext => "Look up a ticket",
681 Op::ImportIssue => "Import an issue",
682 Op::ListWebhooks => "List webhooks",
683 Op::CreateWebhook => "Create a webhook",
684 Op::UpdateWebhook => "Update a webhook",
685 Op::DeleteWebhook => "Delete a webhook",
686 Op::PingWebhook => "Ping a webhook",
687 Op::ListWebhookDeliveries => "List webhook deliveries",
688 Op::RedeliverWebhook => "Redeliver a webhook delivery",
689 Op::ListWorkflows => "List workflows",
690 Op::ListWorkflowRuns => "List workflow runs",
691 Op::GetWorkflowRun => "Get a workflow run",
692 Op::GetJobLogs => "Get a job's log",
693 Op::DispatchWorkflow => "Run a workflow",
694 Op::CancelWorkflowRun => "Cancel a workflow run",
695 Op::RerunWorkflowRun => "Re-run a workflow run",
696 Op::UpdateWorkflow => "Turn a workflow on or off",
697 Op::ListActionsSecrets => "List secrets",
698 Op::SetActionsSecret => "Set a secret",
699 Op::DeleteActionsSecret => "Delete a secret",
700 Op::ListActionsVariables => "List variables",
701 Op::SetActionsVariable => "Set a variable",
702 Op::DeleteActionsVariable => "Delete a variable",
703 Op::ListRunners => "List self-hosted runners",
704 Op::ListRunnerGroups => "List runner groups",
705 Op::GetRunnerSettings => "Get runner settings",
706 Op::CreateRunnerRegistrationToken => "Create a runner registration token",
707 Op::RemoveRunner => "Remove a self-hosted runner",
708 Op::CreateRunnerGroup => "Create a runner group",
709 Op::UpdateRunnerGroup => "Change a runner group",
710 Op::DeleteRunnerGroup => "Delete a runner group",
711 Op::UpdateRunnerSettings => "Change runner settings",
712 Op::ListCollaborators => "List who has access",
713 Op::AddCollaborator => "Add a collaborator",
714 Op::UpdateCollaborator => "Change a collaborator's role",
715 Op::RemoveCollaborator => "Remove a collaborator",
716 Op::GetCollaboratorPermission => "Get someone's permission",
717 Op::ListRepoInvitations => "List a repository's invitations",
718 Op::RevokeRepoInvitation => "Revoke a repository invitation",
719 Op::ListMyRepoInvitations => "List your repository invitations",
720 Op::AcceptRepoInvitation => "Accept a repository invitation",
721 Op::DeclineRepoInvitation => "Decline a repository invitation",
722 Op::SetBasePermission => "Set the base permission",
723 Op::ListOutsideCollaborators => "List outside collaborators",
724 Op::ListSecurityAlerts => "List security alerts",
725 Op::DismissSecurityAlert => "Dismiss a security alert",
726 Op::ReopenSecurityAlert => "Reopen a security alert",
API: notifications over REST and MCP, with notifications scopes727 Op::ListNotifications => "List notifications",
728 Op::MarkNotificationsRead => "Mark notifications read",
729 Op::GetNotificationThread => "Get a thread",
730 Op::MarkThreadRead => "Mark a thread read",
731 Op::MarkThreadDone => "Mark a thread done",
732 Op::SaveThread => "Save a thread",
733 Op::SnoozeThread => "Snooze a thread",
734 Op::GetThreadSubscription => "Get a thread subscription",
735 Op::SetThreadSubscription => "Set a thread subscription",
736 Op::DeleteThreadSubscription => "Unsubscribe from a thread",
737 Op::GetRepoSubscription => "Get how you watch a repository",
738 Op::SetRepoSubscription => "Watch a repository",
739 Op::DeleteRepoSubscription => "Stop watching a repository",
740 Op::ListWatchedRepos => "List repositories you watch",
API: pinned projects over REST and MCP741 Op::ListPinnedProjects => "List your pinned projects",
Usage, Billing settings and prepaid AI credit; fixes from the UX audit742 Op::GetUsage => "Get a workspace's usage",
743 Op::GetBudget => "Get a workspace's budget",
744 Op::SetBudget => "Change a workspace's budget",
745 Op::ListInvoices => "List a workspace's invoices",
746 Op::GetBillingDetails => "Get a workspace's billing details",
API: pinned projects over REST and MCP747 Op::PinProject => "Pin a project",
748 Op::UnpinProject => "Unpin a project",
749 Op::ReorderPinnedProjects => "Reorder your pinned projects",
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97750 Op::ListProjects => "List a workspace's projects",
751 Op::GetProject => "Get a project",
752 Op::UpdateProject => "Update a project",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar753 Op::ListTeams => "List teams",
754 Op::GetTeam => "Get a team",
755 Op::CreateTeam => "Create a team",
756 Op::UpdateTeam => "Update a team",
757 Op::DeleteTeam => "Delete a team",
758 Op::ListTeamMembers => "List a team's members",
759 Op::SetTeamMember => "Add or change a team member",
760 Op::RemoveTeamMember => "Remove a team member",
761 Op::ListChildTeams => "List child teams",
762 Op::ListTeamRepos => "List a team's repositories",
763 Op::SetTeamRepo => "Give a team a role on a repository",
764 Op::RemoveTeamRepo => "Remove a team from a repository",
765 Op::SetTeamReviewAssignment => "Set a team's review assignment",
766 Op::ListUserTeams => "List someone's teams",
767 Op::RequestReviewers => "Request reviewers",
768 Op::RemoveRequestedReviewers => "Remove requested reviewers",
769 Op::GetCodeownersErrors => "List CODEOWNERS errors",
770 Op::Security(op) => op.title(),
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge771 Op::Rules(op) => op.title(),
Merge checks: statuses and check runs on every commit772 Op::Checks(op) => op.title(),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97773 Op::About(op) => op.title(),
774 Op::Deployments(op) => op.title(),
Projects have Observability: their requests, logs, traces, metrics and errors, from apps on g1t.page with nothing to set up, and from software anywhere else over OpenTelemetry.775 Op::Telemetry(op) => op.title(),
Merge branch 'worktree-agent-a3abfcce648e87dca'776 Op::Protection(op) => op.title(),
API and MCP for a workspace's personal access token rules, members' tokens and approvals777 Op::Tokens(op) => op.title(),
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2778 Op::Artifacts(op) => op.title(),
Merge GitHub pull request #8 (claude/cool-newton-7nm8r9): Docker deployments on g1t.page behind a switch that stays off until Cloudflare's container APIs are checked live, workflows a workspace manages in its repositories, tarball and zipball downloads, refs/pull/* kept to g1t alone, framework detection for g1t.page builds, and a workflow's event payload matching GitHub's.779 Op::Archives(op) => op.title(),
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca780 Op::DeployKeys(op) => op.title(),
Merge packages: roles, Actions access, source label, soft delete, API781 Op::Packages(op) => op.title(),
Merge main into Artifacts Phase 2782 Op::Folios(op) => op.title(),
Fixes from the page sweep783 }
784}
785
786/// Why an operation can be refused with `402 payment_required`, if it
The API and MCP server no longer offer g1t's own agents. g1t is what your coding agents work against, not an agent of its own, so the operations that drove hosted agents are gone: messaging an agent on a pull request (message_agent, take_messages, answer_message), assigning or delegating an issue to g1t (assign_issue, delegate), plans (plan_work, get_plan, apply_plan), the context hub (search_context, get_entity), model routes, agents' computers, AI Gateway requests, "Fix with g1t" on a security alert, and every Customize route (marketplaces, plugins, connectors). The callbacks the agent sandbox reported through (/agent-runs/*, /runs/:id/usage, /plans/:id, /reviews/:id) go with them, update_repo_settings stops accepting agent_review, max_revisions and hold_low_confidence, import_issue stops accepting assign, and an old agent token with no run behind it is refused.787/// can: the ones that make a repository private in a workspace, when a
788/// free workspace's private storage has no room for it.
Fixes from the page sweep789fn may_need_payment(op: Op) -> Option<&'static str> {
790 match op {
791 Op::UpdateRepo | Op::SetRepoVisibility | Op::TransferRepo => Some(
792 "A free workspace's private storage has no room for this private repository.",
793 ),
794 _ => None,
795 }
796}
797
798/// What the reference says beyond each operation's own description, keyed
799/// by operation id, written by hand from what the services return: `notes`
800/// (Markdown, added to the description) and example `params` (path),
801/// `query`, `request` (body) and `response`.
802const REFERENCE: &str = include_str!("reference.json");
803
804fn examples() -> Map<String, Value> {
805 match serde_json::from_str(REFERENCE) {
806 Ok(Value::Object(examples)) => examples,
807 _ => Map::new(),
808 }
809}
810
811/// `/repos/:owner/:name` as OpenAPI writes it: `/repos/{owner}/{name}`.
812fn openapi_path(route: &Route) -> String {
813 route
814 .path
815 .split('/')
816 .map(|segment| match segment.strip_prefix(':') {
817 Some(name) => format!("{{{name}}}"),
818 None => segment.to_owned(),
819 })
820 .collect::<Vec<_>>()
821 .join("/")
822}
823
824fn error_response(description: &str) -> Value {
825 json!({
826 "description": description,
827 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } },
828 })
829}
830
831/// A parameter in the path or the query, described by the operation's
832/// input schema where it has the same name.
833fn parameter(name: &str, place: &str, required: bool, schema: Option<&Value>) -> Value {
834 let mut schema = schema.cloned().unwrap_or_else(|| json!({ "type": "string" }));
835 let description = match name {
836 "owner" => Some(Value::from("The workspace that owns the repository.")),
837 "name" => Some(Value::from("The repository's name.")),
838 _ => schema.as_object_mut().and_then(|schema| schema.remove("description")),
839 };
840 let mut parameter = json!({
841 "name": name,
842 "in": place,
843 "required": required,
844 "schema": schema,
845 });
846 if let Some(description) = description {
847 parameter["description"] = description;
848 }
849 parameter
850}
851
852/// The operation id of a route. An operation reached at a workspace's
853/// address as well as a repository's is documented once for each, with its
854/// own id; GitHub's alternative addresses for one operation keep GitHub's
855/// names.
856fn operation_id(route: &Route) -> String {
857 let op = route.op;
858 let base = match (route.method, route.path.rsplit('/').next().unwrap_or_default()) {
859 ("PUT", "enable") => "enable_workflow".to_owned(),
860 ("PUT", "disable") => "disable_workflow".to_owned(),
861 ("POST", "rerun-failed-jobs") => "rerun_failed_jobs".to_owned(),
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)862 ("POST", "rerun") if route.path.contains("/jobs/:job/") => "rerun_job".to_owned(),
863 ("POST", "force-cancel") => "force_cancel_workflow_run".to_owned(),
864 ("GET", ":attempt") => "get_workflow_run_attempt".to_owned(),
Fixes from the page sweep865 ("PATCH", ":setting") => "update_actions_variable".to_owned(),
866 ("GET", "runs") if route.path.contains("/workflows/:workflow/") => "list_runs_of_workflow".to_owned(),
API: notifications over REST and MCP, with notifications scopes867 // One repository's notifications, and an issue's subscription by
868 // its number rather than a thread's id.
869 (_, "notifications") if route.path.starts_with("/repos/") => match op {
870 Op::ListNotifications => "list_repo_notifications".to_owned(),
871 _ => "mark_repo_notifications_read".to_owned(),
872 },
873 (method, "subscription") if route.path.contains("/issues/:number/") => match method {
874 "GET" => "get_issue_subscription".to_owned(),
875 "PUT" => "set_issue_subscription".to_owned(),
876 _ => "delete_issue_subscription".to_owned(),
877 },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar878 // One label off an issue, by its name in the path.
879 ("DELETE", ":label") if route.path.contains("/issues/:number/") => "remove_issue_label".to_owned(),
API: notifications over REST and MCP, with notifications scopes880 ("DELETE", "saved") => "unsave_thread".to_owned(),
881 ("DELETE", "snooze") => "unsnooze_thread".to_owned(),
Merge branch 'worktree-agent-ab8033ab973f8d99a'882 // An issue's decisions, by its number.
883 ("GET", "decisions") if route.path.contains("/issues/:number/") => "list_issue_decisions".to_owned(),
Fixes from the page sweep884 _ => op.name().to_owned(),
885 };
886 if route.path.starts_with("/workspaces/") && ROUTES.iter().any(|other| other.op == op && other.path.starts_with("/repos/")) {
887 format!("{base}_for_workspace")
888 } else {
889 base
890 }
891}
892
893/// The summary of a route: its operation's title, or for one of GitHub's
894/// alternative addresses, what that address does.
895fn summary(route: &Route, id: &str) -> String {
896 let base = match id.trim_end_matches("_for_workspace") {
897 "enable_workflow" => "Turn a workflow on",
898 "disable_workflow" => "Turn a workflow off",
899 "rerun_failed_jobs" => "Re-run failed jobs",
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)900 "rerun_job" => "Re-run a job",
901 "force_cancel_workflow_run" => "Force-cancel a workflow run",
902 "get_workflow_run_attempt" => "Get a workflow run attempt",
Fixes from the page sweep903 "update_actions_variable" => "Update a variable",
904 "list_runs_of_workflow" => "List a workflow's runs",
API: notifications over REST and MCP, with notifications scopes905 "list_repo_notifications" => "List a repository's notifications",
906 "mark_repo_notifications_read" => "Mark a repository's notifications read",
907 "get_issue_subscription" => "Get your subscription to an issue",
908 "set_issue_subscription" => "Subscribe to an issue",
909 "delete_issue_subscription" => "Unsubscribe from an issue",
910 "unsave_thread" => "Unsave a thread",
911 "unsnooze_thread" => "Bring a snoozed thread back",
Merge branch 'worktree-agent-ab8033ab973f8d99a'912 "list_issue_decisions" => "List an issue's decisions",
Fixes from the page sweep913 _ => title(route.op),
914 };
915 if id.ends_with("_for_workspace") {
916 format!("{base} for a workspace")
917 } else {
918 base.to_owned()
919 }
920}
921
922fn operation(route: &Route) -> Value {
923 let op = route.op;
924 let path_params: Vec<&str> = route.params().collect();
Merge checks: statuses and check runs on every commit925 // `owner` and `name` in the path stand for the operation's `repo` input,
926 // so a `name` in the body, such as a check run's, is the body's own.
927 let stands_for_repo =
928 |name: &str| matches!(name, "owner" | "name") && path_params.contains(&"owner") && path_params.contains(&"name");
929 let covered = |name: &str| name == "repo" || (path_params.contains(&name) && !stands_for_repo(name));
Fixes from the page sweep930 let all_properties = op.properties();
931 let mut properties = all_properties.clone();
932 properties.retain(|name, _| !covered(name));
933 let required: Vec<String> = op
934 .required()
935 .into_iter()
936 .filter(|name| !covered(name))
937 .collect();
938
939 let mut parameters: Vec<Value> = path_params
940 .iter()
Merge checks: statuses and check runs on every commit941 .map(|name| parameter(name, "path", true, if stands_for_repo(name) { None } else { all_properties.get(*name) }))
Fixes from the page sweep942 .collect();
943 let mut body = Value::Null;
944 if route.method == "GET" {
945 for (name, key) in route.query {
946 parameters.push(parameter(
947 name,
948 "query",
949 required.iter().any(|required| required == key),
950 properties.get(*key),
951 ));
952 }
953 } else if !properties.is_empty() {
954 let mut schema = json!({ "type": "object", "properties": properties });
955 if !required.is_empty() {
956 schema["required"] = json!(required);
957 }
958 body = json!({
959 "required": !required.is_empty(),
960 "content": { "application/json": { "schema": schema } },
961 });
962 }
963
964 let id = operation_id(route);
965 let mut responses = Map::new();
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts966 if route.no_content() {
967 responses.insert("204".into(), json!({ "description": "Success. There is no body." }));
968 } else {
969 responses.insert(
970 "200".into(),
971 json!({
972 "description": "Success.",
973 "content": { "application/json": { "schema": {} } },
974 }),
975 );
976 }
Fixes from the page sweep977 responses.insert(
978 "401".into(),
979 error_response("A token is required, or the one sent is not valid."),
980 );
981 if let Some(reason) = may_need_payment(op) {
982 responses.insert("402".into(), error_response(reason));
983 }
984 responses.insert(
985 "403".into(),
986 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."),
987 );
988 if !matches!(op, Op::Whoami | Op::ListRepos | Op::Search) {
989 responses.insert("404".into(), error_response("It does not exist, or you cannot see it."));
990 }
991 if route.method != "GET" {
992 responses.insert(
993 "409".into(),
994 error_response("The request conflicts with the current state."),
995 );
996 }
997 if op != Op::Whoami {
998 responses.insert("422".into(), error_response("The input is not valid."));
999 }
1000 // Public data can be read without a token; everything else needs one.
1001 let scope: Vec<&str> = scope_for(op.name()).map(|scope| scope.as_str()).into_iter().collect();
1002 let security = if op.needs_user() {
1003 json!([{ "token": scope }])
1004 } else {
1005 json!([{ "token": scope }, {}])
1006 };
1007 let (tool, action) = crate::tools::TOOLS
1008 .iter()
1009 .find_map(|tool| {
1010 tool.actions
1011 .iter()
1012 .find(|action| action.op == op)
1013 .map(|action| (tool.name, action.name))
1014 })
1015 .unwrap_or_default();
1016 let mut described = json!({
1017 "operationId": id,
1018 "tags": [tag(op)],
1019 "summary": summary(route, &id),
1020 "description": op.description(),
1021 "x-operation": op.name(),
1022 "x-mcp-tool": tool,
1023 "x-mcp-action": action,
1024 "x-scope": scope.first().copied(),
1025 "security": security,
1026 "parameters": parameters,
1027 "responses": responses,
1028 });
1029 if !body.is_null() {
1030 described["requestBody"] = body;
1031 }
1032 described
1033}
1034
1035/// Entries for device sign-in, which is not an operation.
1036fn onboarding() -> Map<String, Value> {
1037 let paths = json!({
1038 "/device/code": {
1039 "post": {
1040 "operationId": "device_code",
1041 "tags": ["Accounts"],
1042 "summary": "Start signing in",
1043 "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`.",
1044 "security": [],
1045 "requestBody": {
1046 "content": { "application/json": { "schema": {
1047 "type": "object",
1048 "properties": {
1049 "client_name": {
1050 "type": "string",
1051 "description": "What is asking, shown to the person approving. For example, Claude Code.",
1052 },
1053 },
1054 } } },
1055 },
1056 "responses": { "200": {
1057 "description": "The codes for this sign-in.",
1058 "content": { "application/json": { "schema": {
1059 "type": "object",
1060 "properties": {
1061 "device_code": { "type": "string", "description": "Secret. Send it to /device/token." },
1062 "user_code": { "type": "string", "description": "Shown to the person, like WDJB-MJHT." },
1063 "verification_uri": { "type": "string" },
1064 "verification_uri_complete": {
1065 "type": "string",
1066 "description": "The link to give the person; it carries the code.",
1067 },
1068 "expires_in": { "type": "integer", "description": "Seconds until the codes expire." },
1069 "interval": { "type": "integer", "description": "Seconds to wait between polls." },
1070 },
1071 } } },
1072 } },
1073 },
1074 },
1075 "/device/token": {
1076 "post": {
1077 "operationId": "device_token",
1078 "tags": ["Accounts"],
1079 "summary": "Finish signing in",
1080 "description": "Asks whether the person has approved. Poll no faster than the interval. The token is returned once.",
1081 "security": [],
1082 "requestBody": {
1083 "required": true,
1084 "content": { "application/json": { "schema": {
1085 "type": "object",
1086 "required": ["device_code"],
1087 "properties": { "device_code": { "type": "string" } },
1088 } } },
1089 },
1090 "responses": { "200": {
1091 "description": "The state of the sign-in.",
1092 "content": { "application/json": { "schema": {
1093 "type": "object",
1094 "required": ["status"],
1095 "properties": {
1096 "status": { "type": "string", "enum": ["pending", "approved", "denied", "expired"] },
1097 "token": { "type": "string", "description": "Present when approved." },
Cards you act on in chat; agents comment and review as themselves; names shown cleanly; commits on the calendar1098 "username": { "type": "string", "description": "Lowercased: what the account is found and linked by." },
1099 "display_username": { "type": "string", "description": "The username as its owner wrote it; the same as username when they chose no case." },
Fixes from the page sweep1100 "verified": {
1101 "type": "boolean",
1102 "description": "Whether the account's email is confirmed.",
1103 },
1104 },
1105 } } },
1106 } },
1107 },
1108 },
1109 });
1110 match paths {
1111 Value::Object(paths) => paths,
1112 _ => Map::new(),
1113 }
1114}
1115
1116
1117/// Puts each operation's examples, where it has them, into its request
1118/// and response. Path and query values go under `x-example-params` and
1119/// `x-example-query`, which tools that build a request can use.
1120fn attach_examples(paths: &mut Map<String, Value>) {
1121 let examples = examples();
1122 for methods in paths.values_mut() {
1123 let Some(methods) = methods.as_object_mut() else { continue };
1124 for operation in methods.values_mut() {
1125 let id = operation["operationId"].as_str().unwrap_or_default().to_owned();
1126 let name = operation["x-operation"].as_str().unwrap_or_default().to_owned();
1127 let Some(example) = examples.get(&id).or_else(|| examples.get(&name)) else {
1128 continue;
1129 };
1130 if let Some(notes) = example.get("notes").and_then(Value::as_str) {
1131 let description = operation["description"].as_str().unwrap_or_default();
1132 operation["description"] = json!(format!("{description}\n\n{notes}"));
1133 }
1134 if let Some(response) = example.get("response") {
1135 let content = &mut operation["responses"]["200"]["content"]["application/json"];
1136 if content.is_object() {
1137 content["example"] = response.clone();
1138 }
1139 }
1140 if let Some(request) = example.get("request") {
1141 let content = &mut operation["requestBody"]["content"]["application/json"];
1142 if content.is_object() {
1143 content["example"] = request.clone();
1144 }
1145 }
1146 for (key, extension) in [("params", "x-example-params"), ("query", "x-example-query")] {
1147 if let Some(values) = example.get(key) {
1148 operation[extension] = values.clone();
1149 }
1150 }
1151 }
1152 }
1153}
1154
1155pub fn document() -> Value {
1156 let mut paths = onboarding();
1157 for route in ROUTES {
1158 let entry = paths
1159 .entry(openapi_path(route))
1160 .or_insert_with(|| json!({}));
1161 entry[route.method.to_lowercase()] = operation(route);
1162 }
1163 attach_examples(&mut paths);
1164 let tags: Vec<Value> = SECTIONS
1165 .iter()
1166 .map(|(name, description, ops)| {
1167 json!({
1168 "name": name,
1169 "description": description,
1170 // The section's operations in reading order, by MCP tool name.
1171 "x-tools": ops.iter().map(|op| op.name()).collect::<Vec<_>>(),
1172 })
1173 })
1174 .collect();
1175 let codes = ["unauthenticated", "payment_required", "forbidden", "not_found", "conflict", "invalid"];
1176 json!({
1177 "openapi": "3.1.0",
1178 "info": {
1179 "title": "g1t API",
1180 "version": "1",
1181 "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.",
1182 "license": { "name": "MIT", "identifier": "MIT" },
1183 },
1184 "servers": [{ "url": "https://api.g1t.sh" }],
1185 "security": [{ "token": [] }, {}],
1186 "tags": tags,
1187 "paths": paths,
1188 "components": {
1189 "securitySchemes": {
1190 "token": {
1191 "type": "http",
1192 "scheme": "bearer",
1193 "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.",
1194 },
1195 },
1196 "schemas": {
1197 "Error": {
1198 "type": "object",
1199 "required": ["error"],
1200 "properties": {
1201 "error": {
1202 "type": "object",
1203 "required": ["code", "message"],
1204 "properties": {
1205 "code": { "type": "string", "enum": codes },
1206 "message": { "type": "string" },
1207 "needed_scope": {
1208 "type": "string",
1209 "description": "On a 403 for an access token without the scope the call needs: that scope, such as `issues:write`.",
1210 },
1211 },
1212 },
1213 },
1214 },
1215 },
1216 },
1217 })
1218}
1219
1220#[cfg(test)]
1221mod tests {
1222 use super::*;
1223
1224 #[test]
1225 fn every_route_is_documented_once() {
1226 let document = document();
1227 let mut ids = Vec::new();
1228 for (_, methods) in document["paths"].as_object().unwrap() {
1229 for (_, operation) in methods.as_object().unwrap() {
1230 ids.push(operation["operationId"].as_str().unwrap().to_owned());
1231 }
1232 }
1233 for op in Op::ALL {
1234 assert_eq!(
1235 ids.iter().filter(|id| *id == op.name()).count(),
1236 1,
1237 "{}",
1238 op.name()
1239 );
1240 }
1241 let mut unique = ids.clone();
1242 unique.sort();
1243 unique.dedup();
1244 assert_eq!(unique.len(), ids.len(), "operation ids repeat");
1245 }
1246
1247 #[test]
1248 fn path_and_query_inputs_are_not_repeated_in_the_body() {
1249 let document = document();
1250 let merge = &document["paths"]["/repos/{owner}/{name}/pulls/{number}/merge"]["post"];
1251 let body = &merge["requestBody"]["content"]["application/json"]["schema"]["properties"];
1252 assert!(body.get("keep_issue_open").is_some());
1253 assert!(body.get("repo").is_none() && body.get("number").is_none());
1254 let list = &document["paths"]["/repos"]["get"];
1255 assert_eq!(list["parameters"][0]["name"], "q");
1256 assert!(list.get("requestBody").is_none());
1257 }
1258
1259 #[test]
1260 fn every_operation_is_in_one_section() {
1261 for op in Op::ALL {
1262 let sections = SECTIONS
1263 .iter()
1264 .filter(|(_, _, ops)| ops.contains(&op))
1265 .count();
1266 assert_eq!(sections, 1, "{}", op.name());
1267 }
1268 }
1269
1270 #[test]
1271 fn titles_read_as_sentences() {
1272 assert_eq!(title(Op::CreateIssue), "Create an issue");
1273 assert_eq!(title(Op::Whoami), "Get the current user");
1274 }
1275
1276 #[test]
1277 fn every_operation_has_an_example_response() {
1278 let examples = examples();
1279 assert!(!examples.is_empty(), "reference.json does not parse");
1280 let document = document();
1281 let mut known = Vec::new();
1282 for (path, methods) in document["paths"].as_object().unwrap() {
1283 for (method, operation) in methods.as_object().unwrap() {
1284 known.push(operation["operationId"].as_str().unwrap().to_owned());
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts1285 // Nothing to show for a success without a body.
1286 if operation["responses"]["204"].is_object() {
1287 continue;
1288 }
Fixes from the page sweep1289 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1290 assert!(!example.is_null(), "{method} {path} has no example response");
1291 }
1292 }
1293 for id in examples.keys() {
1294 assert!(known.contains(id), "reference.json names {id}, which is not an operation");
1295 }
1296 }
1297
1298 #[test]
1299 fn example_requests_send_only_what_the_body_takes() {
1300 let document = document();
1301 for (path, methods) in document["paths"].as_object().unwrap() {
1302 for (method, operation) in methods.as_object().unwrap() {
1303 let content = &operation["requestBody"]["content"]["application/json"];
1304 let Some(example) = content["example"].as_object() else { continue };
1305 let properties = &content["schema"]["properties"];
1306 for key in example.keys() {
1307 assert!(!properties[key].is_null(), "{method} {path}: {key} is not in the body");
1308 }
1309 }
1310 }
1311 }
1312
1313 /// The docs site's copy of the document. Run with `G1T_WRITE_OPENAPI=1`
1314 /// to rewrite it after changing an operation.
1315 #[test]
1316 fn the_docs_copy_is_current() {
1317 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../docs/src/data/openapi.json");
1318 let current = serde_json::to_string_pretty(&document()).unwrap() + "\n";
1319 if std::env::var_os("G1T_WRITE_OPENAPI").is_some() {
1320 std::fs::write(path, &current).unwrap();
1321 return;
1322 }
1323 let copy = std::fs::read_to_string(path).unwrap_or_default().replace("\r\n", "\n");
1324 assert!(
1325 copy == current,
1326 "apps/docs/src/data/openapi.json is out of date: run G1T_WRITE_OPENAPI=1 cargo test -p g1t-api openapi"
1327 );
1328 }
1329
1330 /// The reference shows responses as they are sent: `snake_case`.
1331 #[test]
1332 fn example_responses_are_snake_case() {
1333 let document = document();
1334 for (path, methods) in document["paths"].as_object().unwrap() {
1335 for (method, operation) in methods.as_object().unwrap() {
1336 let example = &operation["responses"]["200"]["content"]["application/json"]["example"];
1337 let leaked = g1t_kit::wire::camel_case_keys(example);
1338 assert!(leaked.is_empty(), "{method} {path} shows {leaked:?}");
1339 }
1340 }
1341 }
1342
1343 /// Examples never hold anything that reads as a real credential, which
1344 /// secret scanners rightly flag in a public repository: they end in `…`
1345 /// after the prefix, as `whsec_…` and `g1t_…` do.
1346 #[test]
1347 fn examples_hold_no_real_looking_secrets() {
1348 let prefixes = ["whsec_", "g1t_", "g1tr_", "g1trt_", "sk_live_", "sk_test_", "ghp_", "github_pat_", "xoxb-", "AKIA"];
1349 for (line, text) in REFERENCE.lines().enumerate() {
1350 for prefix in prefixes {
1351 let mut rest = text;
1352 while let Some(at) = rest.find(prefix) {
1353 let after = &rest[at + prefix.len()..];
1354 let run = after.chars().take_while(|c| c.is_ascii_alphanumeric()).count();
1355 assert!(
1356 run < 12,
1357 "reference.json line {}: `{prefix}` followed by {run} characters reads as a real secret; write `{prefix}…`",
1358 line + 1
1359 );
1360 rest = after;
1361 }
1362 }
1363 }
1364 }
1365}

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