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.
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 1 | import { env } from "cloudflare:workers"; |
| 2 | import { Download, Sparkles } from "lucide-react"; | |
| Merge branch 'worktree-agent-a985c01f43538af01' | 3 | import { Form, Link, redirect, useSearchParams } from "react-router"; |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 4 | |
| 5 | import { PROVIDERS } from "@g1t/contracts"; | |
| Issues and pull requests replace intents and attempts | 6 | |
| 7 | import type { Route } from "./+types/issue-new"; | |
| Social cards for every page: og.g1t.sh | 8 | import { page } from "../../lib/meta"; |
| Merge branch 'worktree-agent-a985c01f43538af01' | 9 | import { ErrorText, Field, Input, SubmitButton, Textarea } from "../../components/ui"; |
| Workspace names and icons, and a component kit for every control | 10 | import { CheckboxOption } from "../../components/ui/checkbox"; |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 11 | import { LabelChip } from "../../components/labels"; |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 12 | import { integrations, work } from "../../lib/services.server"; |
| Issues and pull requests replace intents and attempts | 13 | import { assertSameOrigin, requireUser, unwrap } from "../../lib/session.server"; |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 14 | import { accessTo } from "../../lib/access.server"; |
| 15 | import { computeNoteFor } from "../../lib/compute.server"; | |
| 16 | import { delegateForm, issuePath, notStarted } from "../../lib/delegate"; | |
| Issues and pull requests replace intents and attempts | 17 | |
| Social cards for every page: og.g1t.sh | 18 | export function meta({ params, ...args }: Route.MetaArgs) { |
| 19 | return page(args, { title: `New issue · ${params.owner}/${params.repo} · g1t` }); | |
| Issues and pull requests replace intents and attempts | 20 | } |
| 21 | ||
| 22 | export async function loader({ request, params, context }: Route.LoaderArgs) { | |
| 23 | const user = requireUser(context, request); | |
| 24 | const path = { namespace: params.owner, name: params.repo }; | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 25 | // Putting an agent on it needs Write (Run): Read cannot spend compute. |
| 26 | const { can } = await accessTo(context, params); | |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 27 | const [labels, milestones, connections, agents, computeNote] = await Promise.all([ |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 28 | work.listLabels(path, user), |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 29 | can.triage ? work.listMilestones(path, user, "open") : null, |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 30 | integrations.list(params.owner.toLowerCase(), user), |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 31 | can.run ? env.RUNNER.enabled(user, path) : false, |
| 32 | can.run ? computeNoteFor(params.owner, "agent") : null, | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 33 | ]); |
| 34 | // Systems a ticket can be imported from. | |
| 35 | const sources = connections.ok | |
| 36 | ? [...new Set(connections.value.filter((c) => c.kind === "tracker" || c.provider === "sentry").map((c) => c.provider))] | |
| 37 | : []; | |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 38 | return { |
| 39 | labels: unwrap(labels), | |
| 40 | milestones: milestones?.ok ? milestones.value : [], | |
| 41 | // Making labels, and choosing a milestone, need Triage. | |
| 42 | canTriage: can.triage, | |
| 43 | sources, | |
| 44 | canAssign: can.run, | |
| 45 | agents, | |
| 46 | computeNote, | |
| 47 | }; | |
| Issues and pull requests replace intents and attempts | 48 | } |
| 49 | ||
| 50 | export async function action({ request, params, context }: Route.ActionArgs) { | |
| 51 | assertSameOrigin(request); | |
| 52 | const user = requireUser(context, request); | |
| 53 | const form = await request.formData(); | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 54 | if (form.get("intent") === "import") { |
| 55 | const imported = await integrations.import( | |
| 56 | user, | |
| 57 | { namespace: params.owner, name: params.repo }, | |
| 58 | String(form.get("reference") ?? ""), | |
| 59 | form.get("assign") === "on", | |
| 60 | ); | |
| 61 | if (!imported.ok) return { importError: imported.error.message }; | |
| 62 | throw redirect(`/${params.owner}/${params.repo}/issues/${imported.value.number}`); | |
| 63 | } | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 64 | const path = { namespace: params.owner, name: params.repo }; |
| g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent | 65 | // Assigned to g1t as it opens: one step, and the agent starts. |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 66 | if (form.get("agent") === "on") { |
| 67 | const delegated = await env.RUNNER.delegate(user, path, delegateForm(form)); | |
| 68 | if (!delegated.ok) return { error: delegated.error.message }; | |
| 69 | const { issue, agent } = delegated.value; | |
| 70 | const refused = notStarted(agent, path, issue.number); | |
| 71 | if (!refused) throw redirect(issuePath(path, issue.number)); | |
| 72 | return { notStarted: refused }; | |
| 73 | } | |
| Issues and pull requests replace intents and attempts | 74 | const result = await work.openIssue( |
| 75 | user, | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 76 | path, |
| Issues and pull requests replace intents and attempts | 77 | { |
| 78 | title: String(form.get("title") ?? ""), | |
| 79 | body: String(form.get("body") ?? ""), | |
| 80 | labels: [ | |
| 81 | ...form.getAll("label").map(String), | |
| 82 | ...String(form.get("labels") ?? "").split(","), | |
| 83 | ], | |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 84 | milestone: Number(form.get("milestone")) || undefined, |
| Issues and pull requests replace intents and attempts | 85 | }, |
| 86 | ); | |
| 87 | if (!result.ok) return { error: result.error.message }; | |
| 88 | throw redirect(`/${params.owner}/${params.repo}/issues/${result.value.number}`); | |
| 89 | } | |
| 90 | ||
| 91 | export default function NewIssue({ loaderData, actionData }: Route.ComponentProps) { | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 92 | // "Put an agent on …" in the palette arrives with ?agent=1. |
| 93 | const [params] = useSearchParams(); | |
| 94 | const refused = actionData && "notStarted" in actionData ? actionData.notStarted : null; | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 95 | const names = loaderData.sources.map((source) => PROVIDERS[source].label); |
| Issues and pull requests replace intents and attempts | 96 | return ( |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 97 | <div className="max-w-2xl"> |
| 98 | {names.length > 0 && ( | |
| 99 | <Form method="post" className="mb-8 rounded-xl border border-line bg-surface p-4"> | |
| 100 | <input type="hidden" name="intent" value="import" /> | |
| 101 | <p className="flex items-center gap-2 text-sm font-medium"> | |
| 102 | <Download size={15} className="text-muted" /> | |
| 103 | Bring one in from {names.join(" or ")} | |
| 104 | </p> | |
| 105 | <p className="mt-1 text-xs text-muted"> | |
| 106 | Give a key such as TECH-1234 or paste its address. The issue stays linked: agents read the | |
| 107 | original, and it hears back when the work lands. | |
| 108 | </p> | |
| 109 | <div className="mt-3 flex flex-wrap items-center gap-2"> | |
| 110 | <div className="min-w-56 grow"> | |
| 111 | <Input name="reference" required placeholder="TECH-1234" aria-label="Ticket key or address" /> | |
| 112 | </div> | |
| Workspace names and icons, and a component kit for every control | 113 | <CheckboxOption name="assign" label="Put an agent on it" className="items-center" labelClassName="text-muted" /> |
| Merge branch 'worktree-agent-a985c01f43538af01' | 114 | <SubmitButton variant="quiet" match={{ intent: "import" }} pending="Importing…"> |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 115 | Import |
| Merge branch 'worktree-agent-a985c01f43538af01' | 116 | </SubmitButton> |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 117 | </div> |
| 118 | {actionData && "importError" in actionData && ( | |
| 119 | <div className="mt-2"> | |
| 120 | <ErrorText>{actionData.importError}</ErrorText> | |
| 121 | </div> | |
| 122 | )} | |
| 123 | </Form> | |
| 124 | )} | |
| 125 | <Form method="post" className="space-y-4"> | |
| 126 | <Field label="Title"> | |
| Issues and pull requests replace intents and attempts | 127 | <Input |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 128 | name="title" |
| 129 | required | |
| 130 | autoFocus | |
| 131 | maxLength={200} | |
| 132 | placeholder="Parser drops the last line of a file without a trailing newline" | |
| Issues and pull requests replace intents and attempts | 133 | /> |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 134 | </Field> |
| 135 | <Field | |
| 136 | label="Description" | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 137 | hint="What is wrong or wanted, and anything needed to act on it. An agent given this issue works from this text. To say what done looks like, add a list under a “## Definition of done” heading. Pull requests for it merge once the checks the default branch requires pass." |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 138 | > |
| 139 | <Textarea name="body" rows={8} /> | |
| 140 | </Field> | |
| 141 | <fieldset> | |
| 142 | <legend className="mb-1.5 text-sm font-medium text-muted">Labels</legend> | |
| 143 | <div className="flex flex-wrap items-center gap-x-3 gap-y-2"> | |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 144 | {loaderData.labels.map((label) => ( |
| 145 | <CheckboxOption | |
| 146 | key={label.name} | |
| 147 | name="label" | |
| 148 | value={label.name} | |
| 149 | label={<LabelChip name={label.name} color={label.color} />} | |
| 150 | className="items-center gap-1.5" | |
| 151 | /> | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 152 | ))} |
| 153 | </div> | |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 154 | {loaderData.canTriage && ( |
| 155 | <div className="mt-2"> | |
| 156 | <Input | |
| 157 | name="labels" | |
| 158 | aria-label="New labels" | |
| 159 | placeholder="New labels, separated by commas: performance, area: cli" | |
| 160 | /> | |
| 161 | </div> | |
| 162 | )} | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 163 | </fieldset> |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 164 | {loaderData.canTriage && loaderData.milestones.length > 0 && ( |
| 165 | <Field label="Milestone"> | |
| 166 | <select | |
| 167 | name="milestone" | |
| 168 | defaultValue="" | |
| 169 | className="h-9 w-full rounded-md border border-line bg-bg px-2 text-sm outline-none hover:border-line-strong focus:border-accent-dim" | |
| 170 | > | |
| 171 | <option value="">None</option> | |
| 172 | {loaderData.milestones.map((milestone) => ( | |
| 173 | <option key={milestone.number} value={milestone.number}> | |
| 174 | {milestone.title} | |
| 175 | {milestone.dueOn ? ` (due ${milestone.dueOn})` : ""} | |
| 176 | </option> | |
| 177 | ))} | |
| 178 | </select> | |
| 179 | </Field> | |
| 180 | )} | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 181 | {loaderData.canAssign && ( |
| Merge branch 'worktree-agent-ad7c6d88d93adc817' | 182 | <div className="rounded-xl border border-accent/25 bg-accent/[0.04] px-3.5 py-3"> |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 183 | <CheckboxOption |
| 184 | name="agent" | |
| 185 | defaultChecked={params.get("agent") === "1"} | |
| 186 | label={ | |
| 187 | <span className="flex items-center gap-1.5 font-medium"> | |
| Merge branch 'worktree-agent-ad7c6d88d93adc817' | 188 | <Sparkles size={14} className="text-accent" /> |
| g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent | 189 | Assign g1t now |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 190 | </span> |
| 191 | } | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 192 | description="It opens a pull request for this issue in a sandbox of its own and sees it through: this repository's workflows run on it as its checks, and it revises until the required ones pass and the review approves. There is no model or agent count to choose." |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 193 | /> |
| 194 | {(!loaderData.agents || loaderData.computeNote) && ( | |
| 195 | <p className="mt-2 pl-6 text-xs text-warn"> | |
| 196 | {loaderData.computeNote ?? "This workspace's agents have no model yet. The issue still opens, and says why the agent did not start."} | |
| 197 | </p> | |
| 198 | )} | |
| 199 | </div> | |
| 200 | )} | |
| 201 | {refused && ( | |
| 202 | <div className="rounded-lg border border-warn/30 bg-warn/[0.06] p-3 text-sm"> | |
| 203 | <p> | |
| 204 | Opened{" "} | |
| 205 | <Link to={refused.to} className="font-medium text-fg hover:underline"> | |
| 206 | #{refused.number} | |
| 207 | </Link> | |
| g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent | 208 | , but g1t did not start. {refused.message} |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 209 | </p> |
| 210 | {refused.fix && ( | |
| 211 | <Link to={refused.fix.to} className="mt-2 inline-block text-sm font-medium text-fg hover:underline"> | |
| 212 | {refused.fix.label} | |
| 213 | </Link> | |
| 214 | )} | |
| 215 | </div> | |
| 216 | )} | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 217 | <ErrorText>{actionData && "error" in actionData ? actionData.error : null}</ErrorText> |
| Merge branch 'worktree-agent-a985c01f43538af01' | 218 | <SubmitButton name="intent" value="open" pending="Opening…"> |
| 219 | Open issue | |
| 220 | </SubmitButton> | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 221 | </Form> |
| 222 | </div> | |
| Issues and pull requests replace intents and attempts | 223 | ); |
| 224 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.