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.
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 1 | import { Link, useNavigation } from "react-router"; |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 2 | |
| 3 | import { RUN_KINDS } from "@g1t/contracts"; | |
| 4 | ||
| 5 | import type { Route } from "./+types/settings-guardrails"; | |
| 6 | import { GuardrailsForm } from "../../components/guardrails"; | |
| Project settings move into the sidebar, grouped, with a heading per page | 7 | import { RepoSettingsHeading } from "../../components/repo-settings-heading"; |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 8 | import { settingsFromForm } from "../../lib/guardrails"; |
| 9 | import { page } from "../../lib/meta"; | |
| 10 | import { guardrails } from "../../lib/services.server"; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 11 | import { assertSameOrigin, getViewer, requireUser, unwrap } from "../../lib/session.server"; |
| 12 | import { requireCapability, requireInsider } from "../../lib/access.server"; | |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 13 | |
| 14 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 15 | return page(args, { title: `Guardrails · ${params.owner}/${params.repo} · g1t` }); | |
| 16 | } | |
| 17 | ||
| 18 | export async function loader({ params, context }: Route.LoaderArgs) { | |
| 19 | const viewer = getViewer(context); | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 20 | // Maintain and up; to anyone without a role here the page does not exist. |
| 21 | await requireInsider(context, params, "manage_protection"); | |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 22 | const view = await guardrails.getGuardrails(viewer, params.owner, { namespace: params.owner, name: params.repo }); |
| 23 | return { view: unwrap(view) }; | |
| 24 | } | |
| 25 | ||
| 26 | export async function action({ request, params, context }: Route.ActionArgs) { | |
| 27 | assertSameOrigin(request); | |
| 28 | const user = requireUser(context, request); | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 29 | await requireCapability(context, params, "manage_protection"); |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 30 | const form = await request.formData(); |
| 31 | const current = await guardrails.getGuardrails(user, params.owner); | |
| 32 | if (!current.ok) return { saved: false, error: current.error.message }; | |
| 33 | const settings = settingsFromForm(form, { | |
| 34 | registries: current.value.registries.map((registry) => registry.id), | |
| 35 | rules: current.value.rules.map((rule) => rule.id), | |
| 36 | kinds: RUN_KINDS, | |
| 37 | }); | |
| 38 | const saved = await guardrails.updateGuardrails(user, params.owner, { namespace: params.owner, name: params.repo }, settings); | |
| 39 | return saved.ok ? { saved: true, error: null } : { saved: false, error: saved.error.message }; | |
| 40 | } | |
| 41 | ||
| 42 | export default function RepoGuardrails({ loaderData, actionData, params }: Route.ComponentProps) { | |
| 43 | const saving = useNavigation().state === "submitting"; | |
| 44 | const base = `/${params.owner}/${params.repo}`; | |
| 45 | return ( | |
| 46 | <> | |
| Project settings move into the sidebar, grouped, with a heading per page | 47 | <RepoSettingsHeading base={base} /> |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 48 | <p className="mb-8 max-w-3xl text-sm text-muted"> |
| 49 | What g1t's agents, checks and merge queue may do in this project's sandboxes. Anything left as the | |
| 50 | workspace's follows the{" "} | |
| 51 | <Link to={`/${params.owner}/-/guardrails`} className="text-fg underline-offset-2 hover:underline"> | |
| 52 | workspace's defaults | |
| 53 | </Link> | |
| 54 | . Changes apply to runs that start after you save. | |
| 55 | </p> | |
| 56 | <GuardrailsForm | |
| 57 | view={loaderData.view} | |
| 58 | level="project" | |
| 59 | editable | |
| 60 | saving={saving} | |
| 61 | saved={actionData?.saved ?? false} | |
| 62 | error={actionData?.error} | |
| 63 | /> | |
| 64 | </> | |
| 65 | ); | |
| 66 | } |