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

64 lines2,814 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.

Merge branch 'worktree-agent-a985c01f43538af01'1import { Link } 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 base = `/${params.owner}/${params.repo}`;
44 return (
45 <>
Project settings move into the sidebar, grouped, with a heading per page46 <RepoSettingsHeading base={base} />
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API47 <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-agent48 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 API49 workspace's follows the{" "}
50 <Link to={`/${params.owner}/-/guardrails`} className="text-fg underline-offset-2 hover:underline">
51 workspace's defaults
52 </Link>
53 . Changes apply to runs that start after you save.
54 </p>
55 <GuardrailsForm
56 view={loaderData.view}
57 level="project"
58 editable
59 saved={actionData?.saved ?? false}
60 error={actionData?.error}
61 />
62 </>
63 );
64}

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