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. Version 34 of shared· pinch· Oct 9 (2026-10-09 10:56 UTC) · 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 @@
6 6 // The box credential lives in the user's config folder, one file per server, 7 7 // 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. 10 11 import { createHash } from "node:crypto"; 11 12 import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; @@ -84,7 +85,7 @@
87 − interface Answer {
88 + export interface Answer { 88 89 readonly status: number; 89 90 readonly body: Record<string, unknown>; @@ -127,6 +128,32 @@
127 128 return { status: response.status, body: parsed }; 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. 135 + export async function boxGet(record: BoxRecord, path: string, fetcher: typeof fetch = fetch): Promise<Answer> { 136 + const secrets = [record.credential]; 137 + let response: Response; 139 + response = await fetcher(`${originOf(record.server)}${path}`, { 140 + headers: { authorization: `Box ${record.credential}` }, 141 + signal: AbortSignal.timeout(30_000), 144 + throw new UsageError( 145 + `couldn't reach ${originOf(record.server)}: ${scrub(err instanceof Error ? err.message : String(err), secrets)}`, 148 + const text = await response.text(); 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> }; 154 + return { status: response.status, body: { error: scrub(text.slice(0, 300), secrets) } }; 130 157 /** This machine's name, as the server takes a box's name: 1-64 letters, digits, '.', '_' or '-'. */ 131 158 function boxName(): string { 132 159 const name = hostname() --- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -43,6 +43,7 @@
43 43 import { runBlame, runWhere, runWho, runWhy } from "./history.ts"; 44 44 import { runAnswer, runAsk, runIssue, runIssues, runSearch, runWaiting } from "./issues.ts"; 45 45 import { adminToken, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from "./key-admin.ts"; 46 + import { initInOrg, runOrg, runOrgs } from "./orgs.ts"; 46 47 import { runUnqueue } from "./queue.ts"; 47 48 import { runNote, runNotes, runReview } from "./review.ts"; 48 49 import { installSkill, SKILL, skillPath } from "./skill.ts"; @@ -86,11 +87,14 @@
87 88 const COMMANDS: Readonly<Record<string, CommandDef>> = { 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>]", 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)); @@ -207,6 +211,31 @@
215 + flags: { server: "string" }, 216 + usage: "abso orgs [--server <url>]", 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)), 231 + "projects-by": "string", 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>]", 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)), 211 240 flags: { dir: "string" }, 212 241 usage: "abso skill install [--dir <skills folder>] | abso skill show", --- a/client/src/mcp.ts
+++ b/client/src/mcp.ts
@@ -52,6 +52,8 @@
57 59 const 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. 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 { 14 + const url = new URL(server); 15 + if (url.hostname.startsWith("api.")) url.hostname = url.hostname.slice("api.".length); 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" }, 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; 41 + async function read(server: string, path: string, io: OrgIo): Promise<Answer> { 42 + const record = io.home === undefined ? readBox(server) : readBox(server, io.home); 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`, 47 + return boxGet(record, path, io.fetch); 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}`); 60 + const when = (iso: unknown) => (typeof iso === "string" ? `${iso.slice(0, 16).replace("T", " ")} UTC` : "?"); 67 + interface Invitation { 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[]; 82 + ? ["You're in no organizations."] 84 + `Your organizations (${orgs.length}):`, 86 + (o) => ` ${o.name}${o.displayName && o.displayName !== o.name ? ` (${o.displayName})` : ""}: ${o.role}`, 89 + if (invitations.length > 0) 92 + ...invitations.map((i) => ` ${i.org} as ${i.role}, until ${when(i.expiresAt)}`), 93 + `Accept them on the website, signed in: ${siteOf(server)}.`, 95 + return { text: lines.join("\n"), json: { orgs, invitations } }; 101 + name: string | null; 102 + raised?: { project: string; role: string }[]; 107 + kind: "link" | "person"; 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.`); 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}.`, 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 { 133 + displayName: string; 134 + description: string | null; 136 + membersCan?: string; 137 + whoMakesProjects?: string; 139 + projects?: string[]; 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 } }; 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.`, 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}`); 158 + ` ${m.name ?? "(no name yet)"}: ${m.role}${raised.length > 0 ? `, raised to ${raised.join(", ")}` : ""}`, 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)}`); 166 + return { text: lines.join("\n"), json: { org } }; 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.`, --- /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. 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-")); 23 + credential: CREDENTIAL, 24 + grant: { projects: [{ project: "web", role: "writer" }], max_agents: 3 }, 25 + expiresAt: Date.now() + 86_400_000, 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)); 39 + method: init?.method ?? "GET", 40 + auth: new Headers(init?.headers).get("authorization"), 42 + const r = routes[u.pathname] ?? { status: 404, body: { error: "no such route" } }; 43 + return new Response(JSON.stringify(r.body), { status: r.status }); 45 + return { fetcher, asked }; 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(); 58 + { name: "acme-labs", displayName: "Acme Labs", role: "owner" }, 59 + { name: "beta", displayName: "beta", role: "member" }, 61 + invitations: [{ id: "inv_1", org: "gamma", role: "member", expiresAt: "2026-10-16T10:00:00.000Z" }], 65 + const out = await runOrgs(SERVER, { home, fetch: s.fetcher }); 69 + "Your organizations (2):", 70 + " acme-labs (Acme Labs): owner", 73 + " gamma as member, until 2026-10-16 10:00 UTC", 74 + "Accept them on the website, signed in: https://example.dev.", 77 + assert.deepEqual(s.asked, [{ url: `${SERVER}/orgs`, method: "GET", auth: `Box ${CREDENTIAL}` }]); 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/); 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)); 97 + describe("abso org <name>", () => { 100 + displayName: "Acme Labs", 101 + description: "We make labs.", 103 + membersCan: "write", 104 + whoMakesProjects: "members", 106 + { id: "cf-1", role: "owner", name: "sam", raised: [] }, 107 + { id: "cf-2", role: "member", name: null, raised: [{ project: "web", role: "owner" }] }, 109 + projects: ["api", "web"], 110 + invites: [{ id: "inv_2", role: "member", kind: "link", for: null, expiresAt: "2026-10-16T10:00:00.000Z" }], 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 }); 120 + "acme-labs (Acme Labs)", 122 + "You're an owner. Members can write every project; members make projects.", 123 + "Projects (2): api, web", 126 + " (no name yet): member, raised to owner in web", 128 + " a link, as member, until 2026-10-16 10:00 UTC", 131 + assert.equal(out.text.includes("cf-"), false); 134 + it("shows a non-member only what the org shows everyone", async () => { 135 + const home = signedIn(); 137 + "/orgs/acme-labs": { status: 200, body: { name: "acme-labs", displayName: "Acme Labs", description: null } }, 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."); 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/); 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\./], 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/); 165 + assert.deepEqual(s.asked, []); 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/, 175 + await assert.rejects( 176 + runOrg(args(["acme-labs", "--as", "owner"]), SERVER, { home, fetch: s.fetcher }), 177 + /--as goes with --invite/, 179 + await assert.rejects(runOrg(args([]), SERVER, { home, fetch: s.fetcher }), /abso org <name>/); 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"); 191 + describe("abso init --org", () => { 192 + it("says the project is made on the website for now, with the org as its owner", () => { 194 + () => initInOrg("acme-labs", SERVER), 195 + /made on the website for now: New project at https:\/\/example\.dev, with acme-labs as its owner/,