g1t/apps/web/app/routes/repo/settings-guardrails.tsx

66 lines2,910 bytesCodeBlame

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 look1import { Link, useNavigation } from "react-router";
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API2
3import { RUN_KINDS } from "@g1t/contracts";
4
5import type { Route } from "./+types/settings-guardrails";
6import { GuardrailsForm } from "../../components/guardrails";
Project settings move into the sidebar, grouped, with a heading per page7import { 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 API8import { settingsFromForm } from "../../lib/guardrails";
9import { page } from "../../lib/meta";
10import { guardrails } from "../../lib/services.server";
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look11import { assertSameOrigin, getViewer, requireUser, unwrap } from "../../lib/session.server";
12import { 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 API13
14export function meta({ params, ...args }: Route.MetaArgs) {
15 return page(args, { title: `Guardrails · ${params.owner}/${params.repo} · g1t` });
16}
17
18export 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 look20 // 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 API22 const view = await guardrails.getGuardrails(viewer, params.owner, { namespace: params.owner, name: params.repo });
23 return { view: unwrap(view) };
24}
25
26export 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 look29 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 API30 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
42export 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 page47 <RepoSettingsHeading base={base} />
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API48 <p className="mb-8 max-w-3xl text-sm text-muted">
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent49 What g1t, its checks and the merge queue may do in this project's sandboxes. Anything left as the
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API50 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}