Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 34 --json
JSON
/christopher/abso-core/versions/34?format=json

Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.

of shared·pinch··Not checked

Version 33 · Files at version 34

5 files, 436 lines added, 6 removed.

--- a/client/src/box.ts
+++ b/client/src/box.ts
@@ -5,7 +5,8 @@
55//
66// The box credential lives in the user's config folder, one file per server,
77// never in a project folder. It is never printed, never an argument, and only
8−// ever sent to the server that issued it, on /box/ routes.
8+// ever sent to the server that issued it: on /box/ routes, and on the org reads,
9+// which answer as the person who approved the box.
1011import { createHash } from "node:crypto";
1112import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -84,7 +85,7 @@
8485 return out;
8586}
8687
87−interface Answer {
88+export interface Answer {
8889 readonly status: number;
8990 readonly body: Record<string, unknown>;
9091}
@@ -127,6 +128,32 @@
127128 return { status: response.status, body: parsed };
128129}
129130
131+/**
132+ * A read that answers as the person who approved this box: the org reads (GET /orgs, /orgs/<name>). Answers the
133+ * status and body as they came, refusals included, so the caller can say what each means; never the credential.
134+ */
135+export async function boxGet(record: BoxRecord, path: string, fetcher: typeof fetch = fetch): Promise<Answer> {
136+ const secrets = [record.credential];
137+ let response: Response;
138+ try {
139+ response = await fetcher(`${originOf(record.server)}${path}`, {
140+ headers: { authorization: `Box ${record.credential}` },
141+ signal: AbortSignal.timeout(30_000),
142+ });
143+ } catch (err) {
144+ throw new UsageError(
145+ `couldn't reach ${originOf(record.server)}: ${scrub(err instanceof Error ? err.message : String(err), secrets)}`,
146+ );
147+ }
148+ const text = await response.text();
149+ try {
150+ const body = JSON.parse(text) as unknown;
151+ if (typeof body === "object" && body !== null && !Array.isArray(body))
152+ return { status: response.status, body: body as Record<string, unknown> };
153+ } catch {}
154+ return { status: response.status, body: { error: scrub(text.slice(0, 300), secrets) } };
155+}
130157/** This machine's name, as the server takes a box's name: 1-64 letters, digits, '.', '_' or '-'. */
131158function boxName(): string {
132159 const name = hostname()
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -43,6 +43,7 @@
4343import { runBlame, runWhere, runWho, runWhy } from "./history.ts";
4444import { runAnswer, runAsk, runIssue, runIssues, runSearch, runWaiting } from "./issues.ts";
4545import { adminToken, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from "./key-admin.ts";
46+import { initInOrg, runOrg, runOrgs } from "./orgs.ts";
4647import { runUnqueue } from "./queue.ts";
4748import { runNote, runNotes, runReview } from "./review.ts";
4849import { installSkill, SKILL, skillPath } from "./skill.ts";
@@ -86,11 +87,14 @@
8687
8788const COMMANDS: Readonly<Record<string, CommandDef>> = {
8889 init: {
89− flags: { server: "string", project: "string", agent: "string", "as-is": "boolean" },
90− usage: "abso init [folder] --server <url> --project <name> --agent <name> [--as-is]",
90+ flags: { server: "string", project: "string", agent: "string", "as-is": "boolean", org: "string" },
91+ usage: "abso init [folder] --server <url> --project <name> --agent <name> [--as-is] [--org <org>]",
9192 about:
92− "Create a project on the server from a folder's text files. The folder becomes that agent's folder. It writes a starting .absoignore, and, when the folder has no avcs.json and package.json gives a check or a build to guess, an avcs.json (setup, check, build and out): what the server's CI runs on each new version of shared. Without one, CI runs what it can guess itself, or nothing. --as-is writes neither: the folder goes up exactly as it is (an import).",
93− run: runInit,
93+ "Create a project on the server from a folder's text files. The folder becomes that agent's folder. It writes a starting .absoignore, and, when the folder has no avcs.json and package.json gives a check or a build to guess, an avcs.json (setup, check, build and out): what the server's CI runs on each new version of shared. Without one, CI runs what it can guess itself, or nothing. --as-is writes neither: the folder goes up exactly as it is (an import). --org <org> makes it an organization's project: for now that is done on the website, and abso says where.",
94+ run: (args, env) => {
95+ const org = str(args, "org");
96+ return org === undefined ? runInit(args, env) : initInOrg(org, boxServer(args, env));
97+ },
9498 },
9599 key: {
96100 flags: {
@@ -207,6 +211,31 @@
207211 };
208212 },
209213 },
214+ orgs: {
215+ flags: { server: "string" },
216+ usage: "abso orgs [--server <url>]",
217+ about:
218+ "Your organizations and your role in each, and invitations waiting for you. It reads as the person who approved this box's sign-in (abso login).",
219+ run: (args, env) => runOrgs(boxServer(args, env)),
220+ },
221+ org: {
222+ flags: {
223+ server: "string",
224+ name: "string",
225+ invite: "string",
226+ as: "string",
227+ role: "string",
228+ remove: "string",
229+ leave: "boolean",
230+ members: "string",
231+ "projects-by": "string",
232+ },
233+ usage:
234+ "abso org <name> [--invite <person>|link [--as owner] | --role <person>=owner|member | --remove <person> | --leave | --members read|write | --projects-by members|owners] | abso org new <name> [--name <shown name>]",
235+ about:
236+ "An organization: its projects, people, open invites and settings, as the person who approved this box's sign-in sees them (people and settings only to members). One change at a time. Changes and abso org new are made on the website for now, and abso says where.",
237+ run: (args, env) => runOrg(args, boxServer(args, env)),
238+ },
210239 skill: {
211240 flags: { dir: "string" },
212241 usage: "abso skill install [--dir <skills folder>] | abso skill show",
--- a/client/src/mcp.ts
+++ b/client/src/mcp.ts
@@ -52,6 +52,8 @@
5252 "ask",
5353 "waiting",
5454 "answer",
55+ "orgs",
56+ "org",
5557] as const;
5658
5759const PROTOCOLS = ["2025-06-18", "2025-03-26", "2024-11-05"];
--- /dev/null
+++ b/client/src/orgs.ts
@@ -0,0 +1,174 @@
1+// Organizations from the CLI: abso orgs and abso org <name>. They read as the
2+// person who approved this box's sign-in (abso login). Changing an org (new,
3+// invite, role, remove, leave, settings) and making a project in one are done on
4+// the website for now: a box sits where agents run, and its sign-in was given
5+// for project work, so the server takes only reads from it.
6+
7+import { type Parsed, UsageError } from "./args.ts";
8+import { type Answer, boxGet, originOf, readBox } from "./box.ts";
9+import type { Output } from "./commands.ts";
11+/** The website for an API server: api.<site> serves <site>; any other server serves its own pages. */
12+export function siteOf(server: string): string {
13+ try {
14+ const url = new URL(server);
15+ if (url.hostname.startsWith("api.")) url.hostname = url.hostname.slice("api.".length);
16+ return url.origin;
17+ } catch {
18+ return server;
19+ }
20+}
22+/** The flags that change an org, in the order Design wrote them; each names where the website does it. */
23+const CHANGES: readonly { flag: string; tab: string }[] = [
24+ { flag: "invite", tab: "People" },
25+ { flag: "role", tab: "People" },
26+ { flag: "remove", tab: "People" },
27+ { flag: "leave", tab: "People" },
28+ { flag: "members", tab: "Settings" },
29+ { flag: "projects-by", tab: "Settings" },
30+];
32+const WEBSITE_ONLY =
33+ "Organizations are changed on the website for now; from the CLI they can only be read, as the person who approved this box's sign-in";
35+/** Where the box's sign-in is read from and how the server is reached; tests pass their own. */
36+export interface OrgIo {
37+ readonly home?: string;
38+ readonly fetch?: typeof fetch;
39+}
41+async function read(server: string, path: string, io: OrgIo): Promise<Answer> {
42+ const record = io.home === undefined ? readBox(server) : readBox(server, io.home);
43+ if (!record)
44+ throw new UsageError(
45+ `this box isn't signed in to ${originOf(server)}. abso login signs it in; org reads answer as the person who approves it`,
46+ );
47+ return boxGet(record, path, io.fetch);
48+}
50+/** What a refusal from an org read means, in words. */
51+function refused(a: Answer, what: string, server: string): UsageError {
52+ const said = typeof a.body.error === "string" ? a.body.error : `status ${a.status}`;
53+ if (a.status === 401)
54+ return new UsageError(`${originOf(server)} didn't take this box's sign-in (${said}). abso login renews it`);
55+ if (a.status === 404 && /aren't on here/.test(said)) return new UsageError(`${originOf(server)}: ${said}`);
56+ if (a.status === 404) return new UsageError(`${what}: ${said}`);
57+ return new UsageError(`${originOf(server)} refused ${what} (${a.status}): ${said}`);
58+}
60+const when = (iso: unknown) => (typeof iso === "string" ? `${iso.slice(0, 16).replace("T", " ")} UTC` : "?");
62+interface OrgRow {
63+ name: string;
64+ displayName: string;
65+ role: string;
66+}
67+interface Invitation {
68+ id: string;
69+ org: string;
70+ role: string;
71+ expiresAt: string;
72+}
74+/** abso orgs: your organizations, your role in each, and invitations waiting for you. */
75+export async function runOrgs(server: string, io: OrgIo = {}): Promise<Output> {
76+ const a = await read(server, "/orgs", io);
77+ if (a.status !== 200) throw refused(a, "the list of your organizations", server);
78+ const orgs = (a.body.orgs ?? []) as OrgRow[];
79+ const invitations = (a.body.invitations ?? []) as Invitation[];
80+ const lines =
81+ orgs.length === 0
82+ ? ["You're in no organizations."]
83+ : [
84+ `Your organizations (${orgs.length}):`,
85+ ...orgs.map(
86+ (o) => ` ${o.name}${o.displayName && o.displayName !== o.name ? ` (${o.displayName})` : ""}: ${o.role}`,
87+ ),
88+ ];
89+ if (invitations.length > 0)
90+ lines.push(
91+ "Invited to:",
92+ ...invitations.map((i) => ` ${i.org} as ${i.role}, until ${when(i.expiresAt)}`),
93+ `Accept them on the website, signed in: ${siteOf(server)}.`,
94+ );
95+ return { text: lines.join("\n"), json: { orgs, invitations } };
96+}
98+interface Member {
99+ id: string;
100+ role: string;
101+ name: string | null;
102+ raised?: { project: string; role: string }[];
103+}
104+interface Invite {
105+ id: string;
106+ role: string;
107+ kind: "link" | "person";
108+ expiresAt: string;
109+}
111+/** abso org <name>, abso org new <name>, and the change flags, which say where the website does each. */
112+export async function runOrg(args: Parsed, server: string, io: OrgIo = {}): Promise<Output> {
113+ const [first, second, ...more] = args.positionals;
114+ const asked = CHANGES.filter((c) => args.flags.has(c.flag));
115+ if (first === "new") {
116+ if (second === undefined || more.length > 0) throw new UsageError('abso org new <name> [--name "<shown name>"]');
117+ throw new UsageError(`${WEBSITE_ONLY}. Make ${second} at ${siteOf(server)}/orgs/new.`);
118+ }
119+ if (first === undefined || second !== undefined)
120+ throw new UsageError("abso org <name> [one change], or abso org new <name>");
121+ if (args.flags.has("as") && !args.flags.has("invite")) throw new UsageError("--as goes with --invite");
122+ if (asked.length > 1)
123+ throw new UsageError(`one change at a time: --${asked.map((c) => c.flag).join(" and --")} were given together`);
124+ if (asked.length === 1)
125+ throw new UsageError(
126+ `${WEBSITE_ONLY}. --${asked[0]!.flag} is on ${first}'s ${asked[0]!.tab} tab: ${siteOf(server)}/${first}.`,
127+ );
129+ const a = await read(server, `/orgs/${encodeURIComponent(first)}`, io);
130+ if (a.status !== 200) throw refused(a, first, server);
131+ const org = a.body as {
132+ name: string;
133+ displayName: string;
134+ description: string | null;
135+ role?: string;
136+ membersCan?: string;
137+ whoMakesProjects?: string;
138+ members?: Member[];
139+ projects?: string[];
140+ invites?: Invite[];
141+ };
142+ const lines = [`${org.name}${org.displayName && org.displayName !== org.name ? ` (${org.displayName})` : ""}`];
143+ if (org.description) lines.push(` ${org.description.replace(/\r?\n/g, "\n ")}`);
144+ if (org.role === undefined) {
145+ lines.push("You aren't a member, so its people and settings aren't shown.");
146+ return { text: lines.join("\n"), json: { org } };
147+ }
148+ lines.push(
149+ `You're ${org.role === "owner" ? "an owner" : "a member"}. Members can ${org.membersCan ?? "?"} every project; ${org.whoMakesProjects === "owners" ? "only owners make" : "members make"} projects.`,
150+ );
151+ const projects = org.projects ?? [];
152+ lines.push(projects.length === 0 ? "Projects: none yet." : `Projects (${projects.length}): ${projects.join(", ")}`);
153+ const members = org.members ?? [];
154+ lines.push(`People (${members.length}):`);
155+ for (const m of members) {
156+ const raised = (m.raised ?? []).map((r) => `${r.role} in ${r.project}`);
157+ lines.push(
158+ ` ${m.name ?? "(no name yet)"}: ${m.role}${raised.length > 0 ? `, raised to ${raised.join(", ")}` : ""}`,
159+ );
160+ }
161+ if (org.invites !== undefined && org.invites.length > 0) {
162+ lines.push("Open invites:");
163+ for (const i of org.invites)
164+ lines.push(` ${i.kind === "link" ? "a link" : "a person, by name"}, as ${i.role}, until ${when(i.expiresAt)}`);
165+ }
166+ return { text: lines.join("\n"), json: { org } };
167+}
169+/** abso init --org: making a project in an org is a website step for now. */
170+export function initInOrg(org: string, server: string): never {
171+ throw new UsageError(
172+ `projects in an organization are made on the website for now: New project at ${siteOf(server)}, with ${org} as its owner.`,
173+ );
174+}
--- /dev/null
+++ b/client/test/orgs.test.ts
@@ -0,0 +1,198 @@
1+// abso orgs and abso org: reads as the person who approved the box's sign-in, and the changes say where the
2+// website makes them. The server here is a stand-in that answers the org routes' documented shapes.
3+
4+import assert from "node:assert/strict";
5+import { mkdtempSync } from "node:fs";
6+import { tmpdir } from "node:os";
7+import { join } from "node:path";
8+import { describe, it } from "node:test";
9+import { parseArgs } from "../src/args.ts";
10+import { writeBox } from "../src/box.ts";
11+import { commandTable } from "../src/main.ts";
12+import { initInOrg, runOrg, runOrgs, siteOf } from "../src/orgs.ts";
14+const SERVER = "https://api.example.dev";
15+const CREDENTIAL = "abso_bx_test0000000000";
17+function signedIn(): string {
18+ const home = mkdtempSync(join(tmpdir(), "abso-orgs-"));
19+ writeBox(
20+ {
21+ server: SERVER,
22+ id: "box_1",
23+ credential: CREDENTIAL,
24+ grant: { projects: [{ project: "web", role: "writer" }], max_agents: 3 },
25+ expiresAt: Date.now() + 86_400_000,
26+ },
27+ home,
28+ );
29+ return home;
30+}
32+/** A stand-in server: answers from `routes` by path, and keeps what was asked. */
33+function server(routes: Record<string, { status: number; body: unknown }>) {
34+ const asked: { url: string; method: string; auth: string | null }[] = [];
35+ const fetcher = (async (url: string | URL | Request, init?: RequestInit) => {
36+ const u = new URL(String(url));
37+ asked.push({
38+ url: String(url),
39+ method: init?.method ?? "GET",
40+ auth: new Headers(init?.headers).get("authorization"),
41+ });
42+ const r = routes[u.pathname] ?? { status: 404, body: { error: "no such route" } };
43+ return new Response(JSON.stringify(r.body), { status: r.status });
44+ }) as typeof fetch;
45+ return { fetcher, asked };
46+}
48+const args = (line: string[]) => parseArgs("org", line, commandTable().org!.flags);
50+describe("abso orgs", () => {
51+ it("lists yours with your role, and invitations waiting, reading with the box's sign-in", async () => {
52+ const home = signedIn();
53+ const s = server({
54+ "/orgs": {
55+ status: 200,
56+ body: {
57+ orgs: [
58+ { name: "acme-labs", displayName: "Acme Labs", role: "owner" },
59+ { name: "beta", displayName: "beta", role: "member" },
60+ ],
61+ invitations: [{ id: "inv_1", org: "gamma", role: "member", expiresAt: "2026-10-16T10:00:00.000Z" }],
62+ },
63+ },
64+ });
65+ const out = await runOrgs(SERVER, { home, fetch: s.fetcher });
66+ assert.equal(
67+ out.text,
68+ [
69+ "Your organizations (2):",
70+ " acme-labs (Acme Labs): owner",
71+ " beta: member",
72+ "Invited to:",
73+ " gamma as member, until 2026-10-16 10:00 UTC",
74+ "Accept them on the website, signed in: https://example.dev.",
75+ ].join("\n"),
76+ );
77+ assert.deepEqual(s.asked, [{ url: `${SERVER}/orgs`, method: "GET", auth: `Box ${CREDENTIAL}` }]);
78+ });
80+ it("says so when the box isn't signed in, the sign-in isn't taken, or orgs aren't on", async () => {
81+ const empty = mkdtempSync(join(tmpdir(), "abso-orgs-"));
82+ await assert.rejects(runOrgs(SERVER, { home: empty, fetch: server({}).fetcher }), /abso login signs it in/);
83+ const home = signedIn();
84+ const expired = server({ "/orgs": { status: 401, body: { error: "missing or wrong token" } } });
85+ await assert.rejects(runOrgs(SERVER, { home, fetch: expired.fetcher }), /abso login renews it/);
86+ const off = server({ "/orgs": { status: 404, body: { error: "organizations aren't on here yet" } } });
87+ await assert.rejects(runOrgs(SERVER, { home, fetch: off.fetcher }), /api\.example\.dev: organizations aren't on/);
88+ });
90+ it("never prints the credential, even when the server echoes it", async () => {
91+ const home = signedIn();
92+ const s = server({ "/orgs": { status: 500, body: `oops ${CREDENTIAL}` } });
93+ await assert.rejects(runOrgs(SERVER, { home, fetch: s.fetcher }), (e: Error) => !e.message.includes(CREDENTIAL));
94+ });
95+});
97+describe("abso org <name>", () => {
98+ const acme = {
99+ name: "acme-labs",
100+ displayName: "Acme Labs",
101+ description: "We make labs.",
102+ role: "owner",
103+ membersCan: "write",
104+ whoMakesProjects: "members",
105+ members: [
106+ { id: "cf-1", role: "owner", name: "sam", raised: [] },
107+ { id: "cf-2", role: "member", name: null, raised: [{ project: "web", role: "owner" }] },
108+ ],
109+ projects: ["api", "web"],
110+ invites: [{ id: "inv_2", role: "member", kind: "link", for: null, expiresAt: "2026-10-16T10:00:00.000Z" }],
111+ };
113+ it("shows its projects, people, settings and open invites to a member, never a person's id", async () => {
114+ const home = signedIn();
115+ const s = server({ "/orgs/acme-labs": { status: 200, body: acme } });
116+ const out = await runOrg(args(["acme-labs"]), SERVER, { home, fetch: s.fetcher });
117+ assert.equal(
118+ out.text,
119+ [
120+ "acme-labs (Acme Labs)",
121+ " We make labs.",
122+ "You're an owner. Members can write every project; members make projects.",
123+ "Projects (2): api, web",
124+ "People (2):",
125+ " sam: owner",
126+ " (no name yet): member, raised to owner in web",
127+ "Open invites:",
128+ " a link, as member, until 2026-10-16 10:00 UTC",
129+ ].join("\n"),
130+ );
131+ assert.equal(out.text.includes("cf-"), false);
132+ });
134+ it("shows a non-member only what the org shows everyone", async () => {
135+ const home = signedIn();
136+ const s = server({
137+ "/orgs/acme-labs": { status: 200, body: { name: "acme-labs", displayName: "Acme Labs", description: null } },
138+ });
139+ const out = await runOrg(args(["acme-labs"]), SERVER, { home, fetch: s.fetcher });
140+ assert.equal(out.text, "acme-labs (Acme Labs)\nYou aren't a member, so its people and settings aren't shown.");
141+ });
143+ it("says when there's no such org", async () => {
144+ const home = signedIn();
145+ await assert.rejects(runOrg(args(["nope"]), SERVER, { home, fetch: server({}).fetcher }), /^.*nope: no such route/);
146+ });
148+ it("sends no change: each says where on the website it is made, and nothing reaches the server", async () => {
149+ const home = signedIn();
150+ const s = server({});
151+ const cases: [string[], RegExp][] = [
152+ [["acme-labs", "--invite", "sam"], /--invite is on acme-labs's People tab: https:\/\/example\.dev\/acme-labs\./],
153+ [["acme-labs", "--invite", "link"], /People tab/],
154+ [["acme-labs", "--role", "sam=owner"], /--role is on acme-labs's People tab/],
155+ [["acme-labs", "--remove", "jo"], /--remove is on/],
156+ [["acme-labs", "--leave"], /--leave is on acme-labs's People tab/],
157+ [["acme-labs", "--members", "read"], /--members is on acme-labs's Settings tab/],
158+ [["acme-labs", "--projects-by", "owners"], /--projects-by is on acme-labs's Settings tab/],
159+ [["new", "acme-labs", "--name", "Acme Labs"], /Make acme-labs at https:\/\/example\.dev\/orgs\/new\./],
160+ ];
161+ for (const [line, said] of cases) {
162+ await assert.rejects(runOrg(args(line), SERVER, { home, fetch: s.fetcher }), said, line.join(" "));
163+ await assert.rejects(runOrg(args(line), SERVER, { home, fetch: s.fetcher }), /changed on the website for now/);
164+ }
165+ assert.deepEqual(s.asked, []);
166+ });
168+ it("takes one change at a time, and --as only with --invite", async () => {
169+ const home = signedIn();
170+ const s = server({});
171+ await assert.rejects(
172+ runOrg(args(["acme-labs", "--remove", "jo", "--leave"]), SERVER, { home, fetch: s.fetcher }),
173+ /one change at a time: --remove and --leave were given together/,
174+ );
175+ await assert.rejects(
176+ runOrg(args(["acme-labs", "--as", "owner"]), SERVER, { home, fetch: s.fetcher }),
177+ /--as goes with --invite/,
178+ );
179+ await assert.rejects(runOrg(args([]), SERVER, { home, fetch: s.fetcher }), /abso org <name>/);
180+ });
181+});
183+describe("the website for a server", () => {
184+ it("is the site api. serves, or the server itself", () => {
185+ assert.equal(siteOf("https://api.abso.dev"), "https://abso.dev");
186+ assert.equal(siteOf("https://staging.example.workers.dev/"), "https://staging.example.workers.dev");
187+ assert.equal(siteOf("http://localhost:8787"), "http://localhost:8787");
188+ });
189+});
191+describe("abso init --org", () => {
192+ it("says the project is made on the website for now, with the org as its owner", () => {
193+ assert.throws(
194+ () => initInOrg("acme-labs", SERVER),
195+ /made on the website for now: New project at https:\/\/example\.dev, with acme-labs as its owner/,
196+ );
197+ });
198+});