Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
204 linesCodeBlameRaw

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.

Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import {
5 parseAllowances,
6 parseCredit,
7 parseDecision,
8 parseEmail,
9 parseGoodwill,
10 parsePayment,
11 parseSales,
12 parseSalesNote,
13 parseSlugList,
14 parseTerms,
15} from "./forms.ts";
16
17const NOW = new Date("2026-10-04T12:00:00Z");
18
19function form(entries: Record<string, string>): FormData {
20 const data = new FormData();
21 for (const [name, value] of Object.entries(entries)) data.set(name, value);
22 return data;
23}
24
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging25test("a 100% discount keeps its budget and an end date, and names who set it", () => {
26 const result = parseTerms(form({ preset: "100", note: "g1t's own", ceiling: "500", until: "2026-12-31", discount: "40" }), "owner@g1t.sh", NOW);
Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP27 assert.deepEqual(result, {
28 ok: true,
29 value: {
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging30 kind: "custom",
31 discountPercent: 100,
Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP32 ceilingMicros: 500_000_000,
33 note: "g1t's own",
34 until: "2026-12-31T23:59:59Z",
35 setBy: "owner@g1t.sh",
36 setAt: NOW.toISOString(),
37 },
38 });
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging39 // A form from before discounts, saying comped, is a 100% discount.
40 const old = parseTerms(form({ kind: "comped", note: "g1t's own" }), "a", NOW);
41 assert.ok(old.ok && old.value.kind === "custom" && old.value.discountPercent === 100);
Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP42});
43
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging44test("a discount is a preset or a custom whole percent", () => {
45 const custom = parseTerms(form({ preset: "custom", discount: "30", note: "Design partner" }), "a", NOW);
46 assert.ok(custom.ok && custom.value.discountPercent === 30 && custom.value.kind === "custom");
47 const half = parseTerms(form({ preset: "50", discount: "30", note: "x" }), "a", NOW);
48 assert.ok(half.ok && half.value.discountPercent === 50);
49 // A limit alone is custom terms too.
50 const limit = parseTerms(form({ preset: "0", ceiling: "250", note: "x" }), "a", NOW);
51 assert.ok(limit.ok && limit.value.kind === "custom" && limit.value.discountPercent === 0);
52});
53
54test("no discount and no limit is standard, which clears the end date", () => {
55 const result = parseTerms(form({ preset: "0", note: "back to normal", until: "2027-01-01" }), "a@g1t.sh", NOW);
Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP56 assert.ok(result.ok);
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging57 assert.equal(result.value.kind, "standard");
Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP58 assert.equal(result.value.ceilingMicros, null);
59 assert.equal(result.value.until, null);
60});
61
62test("terms are refused without a note, with a bad discount, or ending in the past", () => {
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging63 assert.equal(parseTerms(form({ preset: "100", note: "" }), "a", NOW).ok, false);
64 assert.equal(parseTerms(form({ preset: "custom", note: "x", discount: "101" }), "a", NOW).ok, false);
65 assert.equal(parseTerms(form({ preset: "custom", note: "x" }), "a", NOW).ok, false);
66 assert.equal(parseTerms(form({ preset: "custom", note: "x", discount: "20", until: "2026-10-01" }), "a", NOW).ok, false);
67 assert.equal(parseTerms(form({ preset: "custom", note: "x", discount: "20", until: "2026-02-30" }), "a", NOW).ok, false);
68 assert.equal(parseTerms(form({ preset: "75", note: "x" }), "a", NOW).ok, true);
69 assert.equal(parseTerms(form({ preset: "free", note: "x" }), "a", NOW).ok, false);
Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP70});
71
72test("workspace lists take commas, spaces and lines, once each", () => {
73 assert.deepEqual(parseSlugList("acme, Acme-labs\nbeta beta"), { ok: true, value: ["acme", "acme-labs", "beta"] });
74 assert.equal(parseSlugList("acme, bad--slug").ok, false);
75 assert.equal(parseSlugList("../etc").ok, false);
76});
77
78test("invoice emails are one address", () => {
79 assert.deepEqual(parseEmail(" Billing@Acme.com "), { ok: true, value: "billing@acme.com" });
80 assert.equal(parseEmail("a@b").ok, false);
81 assert.equal(parseEmail("a@b.com, c@d.com").ok, false);
82 assert.equal(parseEmail("a@@b.com").ok, false);
83 assert.equal(parseEmail("").ok, false);
84});
85
86test("credits are positive and capped", () => {
87 assert.deepEqual(parseCredit("25.50"), { ok: true, value: 25_500_000 });
88 assert.equal(parseCredit("0").ok, false);
89 assert.equal(parseCredit("10000.01").ok, false);
90});
91
92test("a sales record: a stage, an owner's email or nobody, a next step and its day", () => {
93 assert.deepEqual(parseSales(form({ stage: "contacted", owner: " Me@G1t.sh ", nextStep: "Call about\n terms", nextAt: "2026-10-09" })), {
94 ok: true,
95 value: { stage: "contacted", owner: "me@g1t.sh", nextStep: "Call about terms", nextAt: "2026-10-09" },
96 });
97 assert.deepEqual(parseSales(form({ stage: "none", owner: "", nextStep: "", nextAt: "" })), {
98 ok: true,
99 value: { stage: "none", owner: null, nextStep: null, nextAt: null },
100 });
101 assert.equal(parseSales(form({ stage: "closed" })).ok, false);
102 assert.equal(parseSales(form({ stage: "lead", owner: "not an email" })).ok, false);
103 assert.equal(parseSales(form({ stage: "lead", nextStep: "x".repeat(201) })).ok, false);
104 assert.equal(parseSales(form({ stage: "lead", nextStep: "Call", nextAt: "2026-02-30" })).ok, false);
105 assert.equal(parseSales(form({ stage: "lead", nextStep: "Call", nextAt: "next week" })).ok, false);
106 // A date needs a step to go with it.
107 assert.equal(parseSales(form({ stage: "lead", nextAt: "2026-10-09" })).ok, false);
108});
109
110test("a sales note is required, and not endless", () => {
111 assert.deepEqual(parseSalesNote("Spoke to Ana; wants an enterprise quote."), { ok: true, value: "Spoke to Ana; wants an enterprise quote." });
112 assert.equal(parseSalesNote("").ok, false);
113 assert.equal(parseSalesNote("x".repeat(2001)).ok, false);
114});
115
116
117test("allowances: the plan without its price, pool shares, and staff's overrides", () => {
118 assert.deepEqual(parseAllowances(form({})), {
119 ok: true,
120 value: {
121 plan: false,
122 ossRepoMicros: null,
123 trialMicros: null,
124 maxConcurrentAgents: null,
125 auditRetentionDays: null,
126 hold: null,
127 },
128 });
129 assert.deepEqual(
130 parseAllowances(form({ plan: "on", oss: "5", trial: "2.50", agents: "20", runCap: "25", issueCap: "500", auditDays: "365", hold: " Card disputed;\nwaiting on the bank " })),
131 {
132 ok: true,
133 value: {
134 plan: true,
135 ossRepoMicros: 5_000_000,
136 trialMicros: 2_500_000,
The site no longer has g1t's own agents. g1t is where the coding agents you already use do their work, so the Agents mode is gone from the rail, with every page under /<workspace>/-/agents: personas, faces, skills, abilities, routines, computers, sessions and agent spend. Customize (skills, connectors, plugins, marketplaces), the context hub, model providers, the AI Gateway page, the Spend page and pill, Ask g1t, and the repository's Agents, Plans and agent settings pages go too, and their addresses now answer 404.137 // Retired with g1t's own agents: always cleared, whatever an old form sends.
138 maxConcurrentAgents: null,
Docs: inbox threads, reasons, subscriptions, watching, email, API and MCP139 auditRetentionDays: 365,
140 hold: "Card disputed; waiting on the bank",
141 },
142 },
143 );
144 assert.equal(parseAllowances(form({ oss: "lots" })).ok, false);
145 assert.equal(parseAllowances(form({ trial: "5000" })).ok, false);
146 // Audit log days: shorter or longer than the plan's, up to 400.
147 assert.equal((parseAllowances(form({ auditDays: "3" })) as { value: { auditRetentionDays: number } }).value.auditRetentionDays, 3);
148 assert.equal((parseAllowances(form({ auditDays: "400" })) as { value: { auditRetentionDays: number } }).value.auditRetentionDays, 400);
149 assert.equal(parseAllowances(form({ auditDays: "0" })).ok, false);
150 assert.equal(parseAllowances(form({ auditDays: "401" })).ok, false);
151 assert.equal(parseAllowances(form({ auditDays: "30.5" })).ok, false);
152 assert.equal(parseAllowances(form({ auditDays: "a year" })).ok, false);
153 assert.equal(parseAllowances(form({ hold: "x".repeat(201) })).ok, false);
154});
155
156test("a bank transfer: an amount, its reference, a note, and the slug typed out", () => {
157 const ok = { amount: "1,500", reference: " TRX 0042 ", note: "Invoice INV-7, by wire", confirmation: "acme" };
158 assert.deepEqual(parsePayment(form(ok), "acme"), { ok: true, value: { amountMicros: 1_500_000_000, reference: "TRX 0042", note: "Invoice INV-7, by wire" } });
159 assert.equal(parsePayment(form({ ...ok, amount: "0" }), "acme").ok, false);
160 assert.equal(parsePayment(form({ ...ok, amount: "100000.01" }), "acme").ok, false);
161 assert.equal(parsePayment(form({ ...ok, reference: "" }), "acme").ok, false);
162 assert.equal(parsePayment(form({ ...ok, note: "" }), "acme").ok, false);
163 assert.equal(parsePayment(form({ ...ok, confirmation: "Acme" }), "acme").ok, false);
164});
165
166test("a decision: approve as asked or at another amount; decline needs a note", () => {
167 assert.deepEqual(parseDecision(form({ id: "lr_1", decision: "approve" })), {
168 ok: true,
169 value: { id: "lr_1", decision: "approve", amountMicros: null, note: "" },
170 });
171 assert.deepEqual(parseDecision(form({ id: "lr_1", decision: "approve", amount: "750", note: "Half now." })), {
172 ok: true,
173 value: { id: "lr_1", decision: "approve", amountMicros: 750_000_000, note: "Half now." },
174 });
175 assert.equal(parseDecision(form({ id: "lr_1", decision: "approve", amount: "0.50" })).ok, false);
176 assert.equal(parseDecision(form({ id: "lr_1", decision: "approve", amount: "1000000.01" })).ok, false);
177 assert.equal(parseDecision(form({ id: "lr_1", decision: "decline" })).ok, false);
178 assert.deepEqual(parseDecision(form({ id: "lr_1", decision: "decline", note: "After a month of payments.", amount: "5" })), {
179 ok: true,
180 value: { id: "lr_1", decision: "decline", amountMicros: null, note: "After a month of payments." },
181 });
182 assert.equal(parseDecision(form({ id: "../x", decision: "approve" })).ok, false);
183 assert.equal(parseDecision(form({ id: "lr_1", decision: "maybe" })).ok, false);
184});
185
186test("goodwill: no amount is the one-click credit; a reason when one is needed; a day not in the future", () => {
187 const never = () => false;
188 const always = () => true;
189 assert.deepEqual(parseGoodwill(form({}), never, NOW), { ok: true, value: { amountMicros: null, reason: "", day: null } });
190 assert.deepEqual(parseGoodwill(form({ amount: "60", reason: "Looping agent on #12, owner caught it late.", day: "2026-10-03" }), always, NOW), {
191 ok: true,
192 value: { amountMicros: 60_000_000, reason: "Looping agent on #12, owner caught it late.", day: "2026-10-03" },
193 });
194 assert.equal(parseGoodwill(form({ amount: "60", reason: "oops" }), always, NOW).ok, false);
195 assert.equal(parseGoodwill(form({ amount: "0" }), never, NOW).ok, false);
196 assert.equal(parseGoodwill(form({ amount: "10000.01" }), never, NOW).ok, false);
197 assert.equal(parseGoodwill(form({ day: "2026-10-05" }), never, NOW).ok, false);
198 assert.equal(parseGoodwill(form({ day: "2026-02-30" }), never, NOW).ok, false);
199 // The check is given the amount typed, or null for the one-click credit.
200 const seen: (number | null)[] = [];
201 parseGoodwill(form({ amount: "12.50" }), (amount) => (seen.push(amount), false), NOW);
202 parseGoodwill(form({}), (amount) => (seen.push(amount), false), NOW);
203 assert.deepEqual(seen, [12_500_000, null]);
204});

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