flagon-io/g1t

public

Git for AI scale: a forge for thousands of agents working on the same code at once.

g1t/apps/web/app/routes/home.tsx

473 lines19,247 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.

Workspace things at the bottom of the sidebar, and on mission control1import { ArrowRight, Hand, Plus, Settings, Users } from "lucide-react";
New workspaces are told to connect a model, before anything fails2import { env } from "cloudflare:workers";
Agents as a team: lifecycle, merge queue, billing and a new shell3import { type ReactNode, useEffect } from "react";
Get started on mission control4import { Link, data, useRevalidator, useRouteLoaderData } from "react-router";
Agents as a team: lifecycle, merge queue, billing and a new shell5
6import type { Lifecycle, Pull, Repo } from "@g1t/contracts";
Initial g1t: services, event bus, intents and attempts7
8import type { Route } from "./+types/home";
API and MCP server, Rust identity service, registration, site redesign9import { Landing } from "../components/landing";
Get started on mission control10import type { ShellData } from "../components/shell";
Agents as a team: lifecycle, merge queue, billing and a new shell11import { STAGE_LABEL, StageDots } from "../components/lifecycle";
API and MCP server, Rust identity service, registration, site redesign12import { RepoList } from "../components/repo-list";
13import {
14 Avatar,
15 ButtonLink,
16 CopyLine,
17 EmptyState,
18 TimeAgo,
19} from "../components/ui";
Agents as a team: lifecycle, merge queue, billing and a new shell20import { Assignee, IssueIcon, PullIcon } from "../components/work";
Work service in Rust, with RFC 3339 timestamps21import { repos as reposApi, work } from "../lib/services.server";
Initial g1t: services, event bus, intents and attempts22import { getViewer } from "../lib/session.server";
23
Agents as a team: lifecycle, merge queue, billing and a new shell24const REFRESH_MS = 5000;
25
A free allowance on g1t's models, so anyone can try its agents26const dollars = (micros: number) => `$${(Math.max(0, micros) / 1_000_000).toFixed(2)}`;
27
Initial g1t: services, event bus, intents and attempts28export function meta({}: Route.MetaArgs) {
29 return [
Email verification, password reset, and Git for AI scale positioning30 { title: "g1t — Git for AI scale" },
Initial g1t: services, event bus, intents and attempts31 {
32 name: "description",
33 content:
Issues and pull requests replace intents and attempts34 "A git forge for thousands of agents working on the same code at once: every change isolated, every decision recorded, every change landed in order. Open source, built on Cloudflare.",
Initial g1t: services, event bus, intents and attempts35 },
36 ];
37}
38
Agents as a team: lifecycle, merge queue, billing and a new shell39export function headers({ loaderHeaders }: Route.HeadersArgs) {
40 return { "Server-Timing": loaderHeaders.get("Server-Timing") ?? "" };
41}
42
Initial g1t: services, event bus, intents and attempts43export async function loader({ context }: Route.LoaderArgs) {
44 const viewer = getViewer(context);
Agents as a team: lifecycle, merge queue, billing and a new shell45 const started = Date.now();
46 const times: Record<string, number> = {};
47 const timed = <T,>(name: string, promise: Promise<T>) =>
48 promise.then((value) => ((times[name] = Date.now() - started), value));
New workspaces are told to connect a model, before anything fails49 // The workspace the sidebar shows, as the shell picks it.
50 const workspace = viewer?.workspaces?.[0]?.slug ?? null;
51 const [repos, pulls, assigned, models] = await Promise.all([
Agents as a team: lifecycle, merge queue, billing and a new shell52 timed("repos", reposApi.list(viewer, { memberOnly: Boolean(viewer) })),
53 timed("pulls", work.listActivePulls(viewer)),
54 timed("assigned", work.listAssignedIssues(viewer)),
New workspaces are told to connect a model, before anything fails55 // Whether its agents can reach a model: g1t's, or one it connected.
56 workspace ? timed("models", env.RUNNER.modelAccess(workspace).catch(() => null)) : Promise.resolve(null),
Initial g1t: services, event bus, intents and attempts57 ]);
Agents as a team: lifecycle, merge queue, billing and a new shell58 // Each issue and pull request is shown under its repository. Most are in
59 // the viewer's own, already listed; the rest are looked up once each, all
60 // at once. One the viewer can no longer see drops out.
61 const known = new Map<string, Repo>(repos.map((repo) => [repo.id, repo]));
62 const missing = [
63 ...new Set([...assigned.map((issue) => issue.repoId), ...pulls.map(({ pull }) => pull.repoId)]),
64 ].filter((id) => !known.has(id));
65 const looked = await Promise.all(missing.map((id) => reposApi.getById(id, viewer)));
66 for (const found of looked) if (found.ok) known.set(found.value.id, found.value);
67 times.lookups = Date.now() - started;
68 const serverTiming = Object.entries(times)
69 .map(([name, ms]) => `${name};dur=${ms}`)
70 .join(", ");
71 return data({
Initial g1t: services, event bus, intents and attempts72 viewer,
73 repos,
New workspaces are told to connect a model, before anything fails74 canRunAgents: models == null || models.hosted || models.own != null,
A free allowance on g1t's models, so anyone can try its agents75 // Its free allowance on g1t's models, when that is what it runs on.
76 trial: models?.own == null ? (models?.trial ?? null) : null,
Agents as a team: lifecycle, merge queue, billing and a new shell77 assigned: assigned.flatMap((issue) => {
78 const repo = known.get(issue.repoId);
79 return repo ? [{ issue, repo }] : [];
Initial g1t: services, event bus, intents and attempts80 }),
Agents as a team: lifecycle, merge queue, billing and a new shell81 active: pulls.flatMap((item) => {
82 const repo = known.get(item.pull.repoId);
83 return repo ? [{ ...item, repo }] : [];
84 }),
85 }, { headers: { "Server-Timing": serverTiming } });
86}
87
88type Active = { pull: Pull; lifecycle: Lifecycle | null; repo: Repo };
89
90/** What a pull request is waiting on, in a word or two. */
91function standing({ pull, lifecycle }: Active): string {
92 if (lifecycle) return STAGE_LABEL[lifecycle.stage];
93 return pull.status === "draft" ? "In progress" : "Ready for review";
94}
95
96function PullRows({ items, detail }: { items: Active[]; detail?: boolean }) {
97 return (
98 <ul className="divide-y divide-line overflow-hidden rounded-xl border border-line bg-surface">
99 {items.map((item) => {
100 const { pull, lifecycle, repo } = item;
101 return (
102 <li key={pull.id}>
103 <Link
104 prefetch="intent"
105 to={`/${repo.namespace}/${repo.name}/pull/${pull.number}`}
106 className="flex items-center gap-3 px-4 py-3 transition-colors hover:bg-raised"
107 >
108 <PullIcon status={pull.status} />
109 <span className="min-w-0 grow">
110 <span className="block truncate font-medium">{pull.title}</span>
111 <span className="block truncate font-mono text-xs text-muted">
112 {repo.namespace}/{repo.name}#{pull.number}
113 {pull.issue != null && ` · for #${pull.issue}`} · {pull.agent}
114 </span>
115 {detail && lifecycle && (
116 <span className="mt-1 block text-xs text-muted">{lifecycle.detail}</span>
117 )}
118 </span>
119 {lifecycle && (
120 <span className="hidden shrink-0 sm:block">
121 <StageDots stage={lifecycle.stage} />
122 </span>
123 )}
124 <span className="w-28 shrink-0 text-right text-xs text-muted">
125 {standing(item)}
126 </span>
127 <span className="hidden w-14 shrink-0 text-right text-xs text-faint sm:block">
128 <TimeAgo at={pull.updatedAt} />
129 </span>
130 </Link>
131 </li>
132 );
133 })}
134 </ul>
135 );
Initial g1t: services, event bus, intents and attempts136}
137
Agents as a team: lifecycle, merge queue, billing and a new shell138function Section({ title, children }: { title: ReactNode; children: ReactNode }) {
139 return (
140 <section>
141 <h2 className="flex items-center gap-2 text-sm font-medium text-muted">{title}</h2>
142 <div className="mt-3">{children}</div>
143 </section>
144 );
145}
146
147function plural(count: number, one: string, many: string): string {
148 return `${count} ${count === 1 ? one : many}`;
149}
150
Get started on mission control151type Step = { done: boolean; title: string; about: string; to: string | null; action: string };
152
153/**
Workspace things at the bottom of the sidebar, and on mission control154 * The workspace being looked at, from mission control: what it holds and
155 * what is moving in it, and the way to its people and settings. The rest of
156 * the page stays the viewer's own, across every workspace.
157 */
158function WorkspaceCard({ slug, role, repos, active }: { slug: string; role: string; repos: Repo[]; active: Active[] }) {
159 const mine = active.filter((item) => item.repo.namespace.toLowerCase() === slug);
160 const stats = [
161 { value: repos.filter((repo) => repo.namespace.toLowerCase() === slug).length, label: "repositories" },
162 { value: mine.length, label: "pull requests open" },
163 { value: mine.filter((item) => item.lifecycle?.stage === "needs_you").length, label: "need you" },
164 ];
165 return (
166 <div className="rounded-xl border border-line bg-surface p-5">
167 <div className="flex items-center gap-3">
168 <Avatar name={slug} size={32} square />
169 <div className="min-w-0">
170 <Link to={`/${slug}`} className="block truncate font-medium hover:underline">
171 {slug}
172 </Link>
173 <p className="text-xs text-muted">Workspace · {role}</p>
174 </div>
175 </div>
176 <dl className="mt-4 grid grid-cols-3 gap-2">
177 {stats.map((stat) => (
178 <div key={stat.label} className="rounded-lg bg-bg/60 px-2.5 py-2 ring-1 ring-line">
179 <dt className="sr-only">{stat.label}</dt>
180 <dd className="text-lg font-semibold tabular-nums tracking-tight">{stat.value}</dd>
181 <dd className="text-[0.6875rem] leading-tight text-muted">{stat.label}</dd>
182 </div>
183 ))}
184 </dl>
185 <div className="mt-4 flex flex-wrap gap-x-4 gap-y-1 text-sm">
186 <Link to={`/${slug}/-/people`} className="inline-flex items-center gap-1.5 text-muted hover:text-fg">
187 <Users size={13} />
188 Members
189 </Link>
190 <Link
191 to={role === "owner" ? `/${slug}/-/settings` : `/${slug}/-/people`}
192 className="inline-flex items-center gap-1.5 text-muted hover:text-fg"
193 >
194 <Settings size={13} />
195 Settings
196 </Link>
197 <Link to={`/${slug}`} className="inline-flex items-center gap-1 text-accent hover:underline">
198 Its page <ArrowRight size={13} />
199 </Link>
200 </div>
201 </div>
202 );
203}
204
205/**
Get started on mission control206 * The first things to do, ticked off as they are done, until an outcome has
207 * been handed to agents. Shown above everything else on mission control.
208 */
209function GetStarted({ steps }: { steps: Step[] }) {
210 const left = steps.filter((step) => !step.done).length;
211 return (
212 <section className="rounded-2xl bg-surface p-5 ring-1 ring-line">
213 <div className="flex items-baseline justify-between gap-3">
214 <h2 className="font-semibold tracking-tight">Get started</h2>
215 <span className="text-xs text-muted">
216 {steps.length - left} of {steps.length} done
217 </span>
218 </div>
219 <ol className="mt-4 space-y-2">
220 {steps.map((step, index) => (
221 <li
222 key={step.title}
223 className={`flex items-start gap-3 rounded-xl px-3 py-2.5 ${step.done ? "" : "bg-bg/50 ring-1 ring-line"}`}
224 >
225 <span
226 className={`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-[0.6875rem] font-medium ${
227 step.done ? "bg-accent text-bg" : "text-muted ring-1 ring-line-strong"
228 }`}
229 >
230 {step.done ? "✓" : index + 1}
231 </span>
232 <span className="min-w-0 grow">
233 <span className={`block text-sm font-medium ${step.done ? "text-muted line-through decoration-faint" : ""}`}>
234 {step.title}
235 </span>
236 {!step.done && <span className="mt-0.5 block text-xs leading-5 text-muted">{step.about}</span>}
237 </span>
238 {!step.done && step.to && (
239 <Link
240 to={step.to}
241 className="shrink-0 rounded-md bg-fg px-2.5 py-1 text-xs font-medium text-bg transition-colors hover:bg-white"
242 >
243 {step.action}
244 </Link>
245 )}
246 </li>
247 ))}
248 </ol>
249 </section>
250 );
251}
252
Initial g1t: services, event bus, intents and attempts253export default function Home({ loaderData }: Route.ComponentProps) {
A free allowance on g1t's models, so anyone can try its agents254 const { viewer, repos, active, assigned, canRunAgents, trial } = loaderData;
Agents as a team: lifecycle, merge queue, billing and a new shell255
256 const needsYou = active.filter((item) => item.lifecycle?.stage === "needs_you");
257 const ready = active.filter((item) => item.lifecycle?.stage === "ready");
258 const moving = active.filter(
259 (item) => item.lifecycle?.stage !== "needs_you" && item.lifecycle?.stage !== "ready",
260 );
261 // Agents are at work, so the page changes without anyone touching it.
262 const changing = moving.some((item) => item.lifecycle || item.pull.status === "draft");
263 const revalidator = useRevalidator();
264 useEffect(() => {
265 if (!changing) return;
266 const timer = setInterval(() => {
267 if (document.visibilityState === "visible") revalidator.revalidate();
268 }, REFRESH_MS);
269 return () => clearInterval(timer);
270 }, [changing, revalidator]);
271
Get started on mission control272 const shell = useRouteLoaderData("root")?.shell as ShellData | null | undefined;
API and MCP server, Rust identity service, registration, site redesign273 if (!viewer) return <Landing repos={repos} />;
Initial g1t: services, event bus, intents and attempts274
Get started on mission control275 const workspace = shell?.workspace?.slug;
276 const first = repos[0];
Usage while free is shown at cost; agents get rustfmt and clippy277 const handedOff = active.length > 0 || (shell?.monthUsageMicros ?? 0) > 0;
Get started on mission control278 const steps: Step[] = [
279 {
280 done: Boolean(workspace),
281 title: "Create a workspace",
282 about: "Repositories, people and agent credit live in one.",
283 to: "/workspaces/new",
284 action: "Create",
285 },
286 {
287 done: repos.length > 0,
288 title: "Add a repository",
289 about: "Create one, or import one from GitHub by its address. Push to it with git as usual.",
290 to: workspace ? `/new?workspace=${workspace}` : "/new",
291 action: "Add",
292 },
A free allowance on g1t's models, so anyone can try its agents293 trial?.open
New workspaces are told to connect a model, before anything fails294 ? {
A free allowance on g1t's models, so anyone can try its agents295 done: true,
296 title: "Try g1t's agents free",
297 about: `This workspace has ${dollars(trial.limitMicros - trial.usedMicros)} of its free ${dollars(trial.limitMicros)} left on g1t's models${trial.endsAt ? `, until ${new Date(trial.endsAt).toLocaleDateString("en-US", { month: "long", day: "numeric", timeZone: "America/Los_Angeles" })}` : ""}: assign issues and watch agents land them. Connect your own model under Integrations any time for more.`,
298 to: workspace ? `/${workspace}/-/integrations` : null,
299 action: "Connect",
300 }
301 : canRunAgents
302 ? {
Billing accounts, terms and enterprises; g1t is no longer free303 // Done unless the workspace is near or at its usage limit.
304 done: Boolean(shell?.free) || shell?.limit == null || shell.limit.comped || shell.limit.state === "ok",
305 title: "Keep work running",
306 about: "Usage is charged after it runs, at what it costs g1t plus a markup. Add a card under Billing, so g1t charges it as you near your limit instead of stopping work.",
New workspaces are told to connect a model, before anything fails307 to: workspace ? `/${workspace}/-/billing` : null,
Billing accounts, terms and enterprises; g1t is no longer free308 action: "Billing",
New workspaces are told to connect a model, before anything fails309 }
310 : {
311 done: false,
312 title: "Connect a model",
A free allowance on g1t's models, so anyone can try its agents313 about: `${
314 trial?.reason === "used"
315 ? "This workspace has used its free allowance on g1t's models. "
316 : trial?.reason === "pool" || trial?.reason === "ended"
317 ? "The free allowance on g1t's models has ended. "
318 : ""
319 }Agents need a model to think with. Connect your Anthropic or OpenAI key, or any compatible endpoint; g1t itself costs nothing while it is being built out.`,
New workspaces are told to connect a model, before anything fails320 to: workspace ? `/${workspace}/-/integrations` : null,
321 action: "Connect",
322 },
Get started on mission control323 {
324 done: handedOff,
325 title: "Hand off an outcome",
326 about: "Write what you want on a repository's Plan page. A planner splits it into issues, and agents take them and land them on main.",
327 to: first ? `/${first.namespace}/${first.name}/plans` : null,
328 action: "Write one",
329 },
330 ];
331 const starting = steps.some((step) => !step.done);
332
Agents as a team: lifecycle, merge queue, billing and a new shell333 const summary = [
334 moving.length > 0 && `${moving.length} in progress`,
335 ready.length > 0 && `${ready.length} ready to merge`,
336 needsYou.length > 0 && plural(needsYou.length, "needs you", "need you"),
337 assigned.length > 0 && `${assigned.length} assigned to you`,
338 ].filter(Boolean);
API and MCP server, Rust identity service, registration, site redesign339 return (
340 <main className="mx-auto grid max-w-6xl gap-10 px-4 py-10 lg:grid-cols-[1fr_20rem]">
341 <div className="min-w-0 space-y-10">
Initial g1t: services, event bus, intents and attempts342 <section>
API and MCP server, Rust identity service, registration, site redesign343 <div className="flex items-center gap-3">
344 <Avatar name={viewer.username} size={36} />
345 <div>
346 <h1 className="text-xl font-semibold tracking-tight">
347 Mission control
348 </h1>
349 <p className="text-sm text-muted">
Agents as a team: lifecycle, merge queue, billing and a new shell350 {summary.length === 0
Issues and pull requests replace intents and attempts351 ? "Nothing is being worked on right now."
Agents as a team: lifecycle, merge queue, billing and a new shell352 : `${summary.join(" · ")}.`}
API and MCP server, Rust identity service, registration, site redesign353 </p>
354 </div>
355 </div>
356 </section>
357
Get started on mission control358 {starting && <GetStarted steps={steps} />}
359
Agents as a team: lifecycle, merge queue, billing and a new shell360 {needsYou.length > 0 && (
361 <Section
362 title={
363 <>
364 <Hand size={14} className="text-warn" />
365 Needs you
366 </>
367 }
368 >
369 <PullRows items={needsYou} detail />
370 </Section>
371 )}
372
373 {ready.length > 0 && (
374 <Section title="Ready to merge">
375 <PullRows items={ready} />
376 </Section>
377 )}
378
379 {assigned.length > 0 && (
380 <Section title="Assigned to you">
381 <ul className="divide-y divide-line overflow-hidden rounded-xl border border-line bg-surface">
382 {assigned.map(({ issue, repo }) => (
383 <li key={issue.id}>
384 <Link
385 prefetch="intent"
386 to={`/${repo.namespace}/${repo.name}/issues/${issue.number}`}
387 className="flex items-center gap-3 px-4 py-3 transition-colors hover:bg-raised"
388 >
389 <IssueIcon issue={issue} />
390 <span className="min-w-0 grow">
391 <span className="block truncate font-medium">{issue.title}</span>
392 <span className="block truncate font-mono text-xs text-muted">
393 {repo.namespace}/{repo.name}#{issue.number}
Initial g1t: services, event bus, intents and attempts394 </span>
Agents as a team: lifecycle, merge queue, billing and a new shell395 </span>
396 {issue.agent && <Assignee agent={issue.agent} />}
397 <span className="hidden w-14 shrink-0 text-right text-xs text-faint sm:block">
398 <TimeAgo at={issue.updatedAt} />
399 </span>
400 </Link>
401 </li>
402 ))}
403 </ul>
404 </Section>
405 )}
406
407 <Section title="In progress">
408 {moving.length === 0 ? (
409 <EmptyState title="No pull requests in progress">
410 Assign issues to the g1t agent from a repository's Issues tab,
411 or point your own agent at one.
412 </EmptyState>
413 ) : (
414 <PullRows items={moving} />
415 )}
416 </Section>
API and MCP server, Rust identity service, registration, site redesign417
Initial g1t: services, event bus, intents and attempts418 <section>
API and MCP server, Rust identity service, registration, site redesign419 <div className="flex items-center justify-between">
420 <h2 className="text-sm font-medium text-muted">Your repositories</h2>
421 <ButtonLink to="/new" variant="quiet">
422 <Plus size={14} />
423 New
424 </ButtonLink>
425 </div>
Initial g1t: services, event bus, intents and attempts426 <RepoList repos={repos} />
427 </section>
API and MCP server, Rust identity service, registration, site redesign428 </div>
Initial g1t: services, event bus, intents and attempts429
API and MCP server, Rust identity service, registration, site redesign430 <aside className="space-y-4">
Workspace things at the bottom of the sidebar, and on mission control431 {shell?.workspace && (
432 <WorkspaceCard
433 slug={shell.workspace.slug.toLowerCase()}
434 role={shell.workspace.role}
435 repos={repos}
436 active={active}
437 />
438 )}
API and MCP server, Rust identity service, registration, site redesign439 <div className="rounded-xl border border-line bg-surface p-5">
440 <h2 className="font-medium">Connect an agent</h2>
441 <p className="mt-1.5 text-sm text-muted">
OAuth 2.1 sign-in for MCP clients and other applications442 Add g1t to Claude Code, then run /mcp in it to sign in through
443 your browser.
API and MCP server, Rust identity service, registration, site redesign444 </p>
445 <div className="mt-4 space-y-2">
446 <CopyLine
447 prompt
OAuth 2.1 sign-in for MCP clients and other applications448 text="claude mcp add --transport http g1t https://mcp.g1t.sh"
API and MCP server, Rust identity service, registration, site redesign449 />
450 </div>
451 <Link
Docs as their own app; shared theme package452 to="https://docs.g1t.sh/guides/bring-your-own-agent/"
API and MCP server, Rust identity service, registration, site redesign453 className="mt-4 inline-flex items-center gap-1 text-sm text-accent hover:underline"
454 >
455 How it works <ArrowRight size={13} />
456 </Link>
457 </div>
458 <div className="rounded-xl border border-line bg-surface p-5">
459 <h2 className="font-medium">Explore</h2>
460 <p className="mt-1.5 text-sm text-muted">
Issues and pull requests replace intents and attempts461 Browse public repositories and the issues open on them.
API and MCP server, Rust identity service, registration, site redesign462 </p>
463 <Link
464 to="/explore"
465 className="mt-3 inline-flex items-center gap-1 text-sm text-accent hover:underline"
466 >
467 Public repositories <ArrowRight size={13} />
468 </Link>
469 </div>
470 </aside>
Initial g1t: services, event bus, intents and attempts471 </main>
472 );
473}