Skip to content
40 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.

Cards you act on in chat; agents comment and review as themselves; names shown cleanly; commits on the calendar1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { draftCard, parseMoney, sessionActions } from "./card-views.ts";
5
6test("money is read the way people type it", () => {
7 assert.equal(parseMoney("5"), 5_000_000);
8 assert.equal(parseMoney("$12.50"), 12_500_000);
9 assert.equal(parseMoney("1,200"), 1_200_000_000);
10 assert.equal(parseMoney("0"), null);
11 assert.equal(parseMoney("-3"), null);
12 assert.equal(parseMoney("5.123"), null);
13 assert.equal(parseMoney("lots"), null);
14 assert.equal(parseMoney(null), null);
15});
16
17test("a draft issue's card offers File and Discard, then shows what happened", () => {
18 const draft = { id: "drf_1", repo: "acme/web", title: "CSV export times out", body: "Over 100k rows.", labels: '["bug"]', status: "draft", filed_by: null, number: null };
19 const open = draftCard(draft);
20 assert.deepEqual(open.actions?.map((a) => a.id), ["file", "discard"]);
21 assert.equal(open.owner, "agents");
22 assert.equal(open.ref, "drf_1");
23 assert.deepEqual(open.fields, [{ label: "Repository", value: "acme/web" }, { label: "Labels", value: "bug" }]);
24 const filed = draftCard({ ...draft, status: "filed", filed_by: "dana", number: 42 });
25 assert.equal(filed.state, "Filed");
26 assert.equal(filed.href, "/acme/web/issues/42");
27 assert.deepEqual(filed.actions, [{ id: "open", label: "Open issue", href: "/acme/web/issues/42" }]);
28 assert.equal(draftCard({ ...draft, status: "discarded" }).actions, undefined);
29});
30
31test("a session's card offers what fits its state", () => {
32 const href = "/acme/-/agents/margo/sessions/asn_1";
33 assert.deepEqual(sessionActions("working", 2_000_000, 500_000, href).map((a) => a.id), ["steer", "stop", "open"]);
34 const approval = sessionActions("needs_approval", 2_000_000, 2_000_000, href);
35 assert.deepEqual(approval.map((a) => a.id), ["approve", "stop", "open"]);
36 assert.equal(approval[0].input?.kind, "money");
37 assert.equal(approval[0].input?.initial, "4.00", "suggests double the cap");
38 assert.deepEqual(sessionActions("done", 2_000_000, 1_000_000, href).map((a) => a.id), ["steer", "open"]);
39 assert.ok(sessionActions("working", null, 0, href).find((a) => a.id === "stop")?.confirm);
40});