- MCP
- show on this site's /mcp
- CLI
- abso show 156 --json
- JSON
- /christopher/abso-core/versions/156?format=json
With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.
of shared·speed··Not checked
Version 155 · Files at version 156
8 files, 151 lines added, 99 removed.
--- a/client/src/doctor.ts
+++ b/client/src/doctor.ts
@@ -3,12 +3,10 @@
33// when one fails. Neither prints a credential. plainError words the commonest failures the same way.
44
6−import { UsageError } from "./args.ts";
76import { type Answer, type BoxRecord, boxGet, boxText, originOf, readBox, signedInServers } from "./box.ts";
10−import { TOKEN_SERVERS } from "./core.ts";
11−import { fromEnv } from "./env-names.ts";
1210
1311/** The lowest Node major each kind of copy runs on: the npm package is built for 20, a checkout runs its .ts as is. */
@@ -43,25 +41,13 @@
4442
46− * The server whoami and doctor look at, in the order join picks one: --server, then ABSO_SERVER, then this
47− * folder's server, then the one this box signed in to with abso login, then https://api.abso.dev. A box signed
48− * in to more than one server has to say which.
44+ * The servers other than `server` this box is signed in to, as one sentence for a refusal or a report to end
50−export function checkServer(
51− flag: string | undefined,
52− cwd: string,
53− env: Readonly<Record<string, string | undefined>>,
54− home?: string,
55− now = Date.now(),
56−): string {
57− const named = flag ?? fromEnv(env, "SERVER");
58− if (named) return named;
59− const folder = folderOf(cwd, env)?.config?.server;
60− if (folder) return folder;
61− const signedIn = signedInServers(home, now);
62− if (signedIn.length > 1)
63− throw new UsageError(`this box is signed in to ${signedIn.join(" and ")}: say which with --server <url>`);
64− return signedIn[0] ?? TOKEN_SERVERS[0]!;
47+export function elsewhereText(server: string, command: string, home?: string, now = Date.now()): string {
50+ return ` This box is signed in to ${others.join(" and ")}: ${command} --server <url> uses ${others.length === 1 ? "it" : "one"}.`;
6652
@@ -102,7 +88,9 @@
105− lines.push(`This box isn't signed in to ${originOf(server)}. Run abso login.`);
92+ `This box isn't signed in to ${originOf(server)}. Run abso login.${elsewhereText(server, "abso whoami", probe.home, probe.now)}`,
@@ -155,7 +143,6 @@
158− explicit = false,
@@ -171,8 +158,8 @@
172159
174− // The folder's own server when there is one (it's the one its commands talk to), unless --server named one.
175− const target = explicit ? server : (folder?.config?.server ?? server);
161+ // Chosen as every command chooses (server-choice.ts): --server, else the folder's own, else ABSO_SERVER, else prod.
--- a/client/src/join-commands.ts
+++ b/client/src/join-commands.ts
@@ -5,13 +5,13 @@
8−import { defaultAgentName, mintFreeName, mintKey, readBox, signedInServers } from "./box.ts";
1313import { findRoot, installKey, readConfig, type Settings, tokenFor, writeConfig } from "./config.ts";
14−import { TOKEN_SERVERS } from "./core.ts";
@@ -19,19 +19,12 @@
2020import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from "./project-file.ts";
2324
24−/**
25− * The server to join or start on: --server, then ABSO_SERVER, then the server this box is signed in
26− * to (abso login wrote it), then https://api.abso.dev. A box signed in to more than one server has to say which.
27− */
28−export function serverFrom(args: Parsed, env: Pick<Env, "env">, home?: string): string {
29− const named = str(args, "server") ?? fromEnv(env.env, "SERVER");
30− if (named) return named;
31− const signedIn = signedInServers(home);
32− if (signedIn.length > 1)
33− throw new UsageError(`this box is signed in to ${signedIn.join(" and ")}: say which with --server <url>`);
34− return signedIn[0] ?? TOKEN_SERVERS[0]!;
25+/** The server to join or start on, in the order every command picks one (server-choice.ts chooseServer). */
3629
@@ -150,7 +143,7 @@
152145 ? `${project} is public: read it at ${siteOf(server)}/${SITE_OWNER}/${project} (every page is also JSON), or here with abso join ${project} --reader. To work on it: abso login.`
153− : `This box isn't signed in to ${server}. abso login signs it in.`;
146+ : `This box isn't signed in to ${server}. abso login signs it in.${elsewhereText(server, `abso join ${project}`)}`;
155148
156149/** A folder that reads a public project signed out: no agent, no key, no copy of the files. */
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -38,8 +38,8 @@
4040import { configPath, findRoot, installKey, isVisitor, readConfig, readToken } from "./config.ts";
41−import { newsBlockLines, newsShown, TOKEN_SERVERS } from "./core.ts";
42−import { checkServer, doctor, doctorText, plainError, realProbe, whoami } from "./doctor.ts";
@@ -49,7 +49,15 @@
52−import { checkFolderServer, localRefusal, serverFlag, serverHelp, serverUse } from "./server-choice.ts";
@@ -65,13 +73,9 @@
6775
68−/** The server login, box and logout act on: --server, the folder's, or outside a folder abso.dev's (TOKEN_SERVERS[0]). */
69−export function boxServer(args: Parsed, env: Pick<Env, "cwd">): string {
70− const flag = str(args, "server");
71− if (flag) return flag;
72− const root = findRoot(env.cwd);
73− if (!root) return TOKEN_SERVERS[0]!;
74− return (JSON.parse(readFileSync(configPath(root), "utf8")) as { server: string }).server;
76+/** The server login, box, logout, orgs, org, whoami and doctor act on, in the order every command picks one (server-choice.ts). */
7680
@@ -96,7 +100,7 @@
96100 flags: { server: "string", project: "string", agent: "string", "as-is": "boolean", org: "string" },
99− "Create a project on the server from a folder's text files (the server is chosen as abso join chooses it). 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.",
103+ "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.",
@@ -186,7 +190,7 @@
187191 "abso login [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--max-agents <1-50>] [--days <1-90>]",
189− "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how many agents. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. Without --server, the folder's server, or https://api.abso.dev outside a folder. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display.",
193+ "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how many agents. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display.",
@@ -219,9 +223,9 @@
222− "Who and where you're signed in: this box's sign-in, as the server sees it (so a revoked one shows), its projects, roles and expiry, and this folder's project, agent and kind of key. Never a credential. The server is --server, else ABSO_SERVER, else this folder's, else the one this box signed in to with abso login, else https://api.abso.dev.",
226+ "Who and where you're signed in: this box's sign-in, as the server sees it (so a revoked one shows), its projects, roles and expiry, and this folder's project, agent and kind of key. Never a credential.",
224− const out = await whoami(checkServer(str(args, "server"), env.cwd, env.env), env.cwd, env.env, realProbe());
@@ -229,15 +233,9 @@
232− "Checks what commands need, one line each: Node's version, that the server answers, this box's sign-in (present, unexpired, accepted), and this folder's key against its project. A failed check says what to do next, and the exit is 1. Never prints a credential. It picks the server as whoami does.",
236+ "Checks what commands need, one line each: Node's version, that the server answers, this box's sign-in (present, unexpired, accepted), and this folder's key against its project. A failed check says what to do next, and the exit is 1. Never prints a credential.",
234− const checks = await doctor(
235− checkServer(str(args, "server"), env.cwd, env.env),
236− env.cwd,
237− env.env,
238− realProbe(),
239− str(args, "server") !== undefined,
240− );
242240 return { text: doctorText(checks), json: { checks }, ...(failed ? { exit: EXIT.error } : {}) };
@@ -308,7 +306,7 @@
311− "Join a project as a new agent and write its shared files into a folder: --dir, else here when this folder is empty, else ./<project> (which has to be new or empty). Without --agent the agent is named after this box (the name abso login gave it, lower-cased), or the next free <name>-2, <name>-3; that needs the box signed in with abso login. The server is --server, else ABSO_SERVER, else the one this box signed in to with abso login, else https://api.abso.dev. --reader joins as a reader: it reads everything and records nothing, and the server refuses its edits, records and pushes. With --reader and no sign-in, a public project is joined to read signed out: the folder holds only its settings, sends no sign-in, and runs status, log, show, files, blame, why, where, issues, issue and search; every other command is refused.",
309+ "Join a project as a new agent and write its shared files into a folder: --dir, else here when this folder is empty, else ./<project> (which has to be new or empty). Without --agent the agent is named after this box (the name abso login gave it, lower-cased), or the next free <name>-2, <name>-3; that needs the box signed in with abso login. --reader joins as a reader: it reads everything and records nothing, and the server refuses its edits, records and pushes. With --reader and no sign-in, a public project is joined to read signed out: the folder holds only its settings, sends no sign-in, and runs status, log, show, files, blame, why, where, issues, issue and search; every other command is refused.",
@@ -811,7 +809,9 @@
813811 "Every command takes --json. Settings live in .abso/config.json (.avcs/config.json in a folder from before the rename). The token comes from ABSO_TOKEN, or else ~/.abso/token (or ~/.avcs/token from before). " +
814− "Every command that talks to a server takes --server <url>; one that works only on this machine (skill, check-ignore, pause, resume, fix-eol) doesn't. In a joined folder --server must be the folder's own server: another is refused, never swapped in. An explicit --server is used as given, and no setting redirects it.";
812+ "Every command that talks to a server takes --server <url>; one that works only on this machine (skill, check-ignore, pause, resume, fix-eol) doesn't. In a joined folder --server must be the folder's own server: another is refused, never swapped in. An explicit --server is used as given, and no setting redirects it. The server is " +
815815
816816/** A command's flags: its own, and --server for every command that talks to a server (server-choice.ts). */
--- a/client/src/server-choice.ts
+++ b/client/src/server-choice.ts
@@ -8,15 +8,47 @@
99// A value that isn't an http or https URL (a user name, a query or a fragment included) is refused before any
12+// When nothing names a server (abso-core issue 9), every command picks it in one order (chooseServer):
17+// Which servers this box is signed in to plays no part: signed in to staging and prod both, or to staging
18+// alone, a command with nothing named goes to prod, and staging is a deliberate --server, folder or ABSO_SERVER.
1119
15−import { serverBase } from "./core.ts";
1625
1928
31+
33+export const SERVER_ORDER = `--server <url>, else the server of the abso folder you're in, else ABSO_SERVER, else prod (${PROD_SERVER})`;
34+
36+ * The server a command goes to: `flag` (checked by serverFlag), else the joined folder's, else ABSO_SERVER
37+ * (checked here), else prod. An explicit choice is returned as given, never swapped for another.
48+ if (named !== undefined) return checkedServer(named, env.ABSO_SERVER ? "ABSO_SERVER" : "AVCS_SERVER");
51+
@@ -101,7 +133,7 @@
103135 ? "--server <url>: the server the key is for; without it, this folder's. It is used as given, never swapped for another."
104− : "--server <url>: the server to use, as given, never swapped for another. Each server gets only its own sign-in.";
136+ : `--server <url>: the server to use, as given, never swapped for another. The order: ${SERVER_ORDER}. This box's sign-in for one server is never sent to another.`;
107139
--- a/client/test/box.test.ts
+++ b/client/test/box.test.ts
@@ -383,27 +383,22 @@
385385
386−test("join and init pick the server: --server, ABSO_SERVER, the box's sign-in, then api.abso.dev", () => {
386+test("join and init pick the server in the one order: --server, the folder's, ABSO_SERVER, then prod", () => {
388389 const args = (server?: string) => ({ positionals: [], flags: new Map(server ? [["server", server]] : []) });
389− const none = { env: {} };
390− assert.equal(serverFrom(args(), none, h), "https://api.abso.dev", "nothing signed in: the abso API");
393− assert.equal(serverFrom(args(), none, h), SERVER, "the server abso login signed this box in to");
394+ assert.equal(serverFrom(args(), none), "https://api.abso.dev", "a sign-in elsewhere doesn't pick the server");
394395 assert.deepEqual(signedInServers(h, Date.now() + 2e6), [], "an expired sign-in doesn't count");
395− assert.equal(serverFrom(args(), { env: { ABSO_SERVER: "https://env.example" } }, h), "https://env.example");
396+ assert.equal(serverFrom(args(), { ...none, env: { ABSO_SERVER: "https://env.example" } }), "https://env.example");
397− serverFrom(args("https://flag.example"), { env: { ABSO_SERVER: "https://env.example" } }, h),
398+ serverFrom(args("https://flag.example"), { ...none, env: { ABSO_SERVER: "https://env.example" } }),
400− writeBox({ ...record, server: "https://other.abso.example", expiresAt: Date.now() + 1e6 }, h);
401− writeBox({ ...record, expiresAt: Date.now() + 1e6 }, h);
402− assert.throws(
403− () => serverFrom(args(), none, h),
404− /signed in to https:\/\/other\.abso\.example and https:\/\/staging\.abso\.example: say which with --server/,
405− );
406− assert.equal(serverFrom(args(SERVER), none, h), SERVER, "--server settles it");
408403
409404test("join with no --agent takes the box's name, skips names this box holds, and moves past a taken one", async () => {
--- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -2846,9 +2846,12 @@
2849− assert.equal(boxServer(parseArgs("login", [], { server: "string" }), { cwd: outside }), "https://api.abso.dev");
28502853 const given = parseArgs("login", ["--server", "https://example.test"], { server: "string" });
2851− assert.equal(boxServer(given, { cwd: outside }), "https://example.test");
--- a/client/test/doctor.test.ts
+++ b/client/test/doctor.test.ts
@@ -8,7 +8,7 @@
11−import { checkServer, doctor, doctorText, nodeNeeded, type Probe, plainError, whoami } from "../src/doctor.ts";
11+import { doctor, doctorText, nodeNeeded, type Probe, plainError, whoami } from "../src/doctor.ts";
1212
@@ -228,25 +228,18 @@
230230
231−test("whoami and doctor pick the server as join does: --server, ABSO_SERVER, the folder's, the box's sign-in, then abso.dev", () => {
231+test("whoami with nothing named shows prod, and names the other servers this box is signed in to", async () => {
233− const empty = temp("home");
234− assert.equal(checkServer(undefined, outside, {}, empty, NOW), "https://api.abso.dev");
237− assert.equal(checkServer(undefined, outside, {}, home, NOW), SERVER);
238− assert.equal(checkServer(undefined, folder(), {}, empty, NOW), SERVER);
239− assert.equal(checkServer(undefined, outside, { ABSO_SERVER: "http://env.example" }, home, NOW), "http://env.example");
240− assert.equal(
241− checkServer("http://flag.example", folder(), { ABSO_SERVER: "http://env.example" }, home, NOW),
242− "http://flag.example",
239+ /This box isn't signed in to https:\/\/api\.abso\.dev\. Run abso login\. This box is signed in to https:\/\/staging\.abso\.example: abso whoami --server <url> uses it\./,
244− const expired = temp("home");
245− writeBox(box(NOW - 1), expired);
246− assert.equal(checkServer(undefined, outside, {}, expired, NOW), "https://api.abso.dev");
248− assert.throws(
249− () => checkServer(undefined, outside, {}, home, NOW),
250− /signed in to .* and .*: say which with --server/,
251− );
--- a/client/test/server-flag.test.ts
+++ b/client/test/server-flag.test.ts
@@ -5,7 +5,9 @@
55// - in a joined folder, --server naming the folder's own server reaches it; another server is refused, never
66// swapped in, and nothing is sent; outside a joined folder a folder command with --server is refused too;
77// - an explicit --server goes to that server's own Issues Worker, which ABSO_ISSUES_SERVER doesn't redirect;
8−// - a command that picks its server (whoami, box, logout) uses the one named, even inside a folder on another.
8+// - a command that picks its server (whoami, box, logout) uses the one named, even inside a folder on another;
9+// - with nothing named (abso-core issue 9) the server is the joined folder's, else ABSO_SERVER, else prod, whatever
10+// this box is signed in to (doctor.test.ts has whoami with staging alone and with staging and prod both).
911
@@ -16,7 +18,7 @@
19−import { sameServer, serverHelp, serverUse } from "../src/server-choice.ts";
21+import { chooseServer, PROD_SERVER, SERVER_ORDER, sameServer, serverHelp, serverUse } from "../src/server-choice.ts";
2022
@@ -216,3 +218,50 @@
221+
224+
230+ assert.equal(chooseServer(undefined, outside, { ABSO_SERVER: STAGING }), STAGING, "the environment");
231+ assert.equal(chooseServer(undefined, outside, { AVCS_SERVER: STAGING }), STAGING, "its older name");
233+ assert.equal(chooseServer(undefined, staging, { ABSO_SERVER: "https://env.example" }), STAGING, "folder first");
234+ assert.equal(chooseServer(PROD_SERVER, staging, { ABSO_SERVER: STAGING }), PROD_SERVER, "explicit prod");
241+
245+ "--server <url>, else the server of the abso folder you're in, else ABSO_SERVER, else prod (https://api.abso.dev)",
247+ for (const name of ["join", "init", "login", "whoami", "doctor", "box", "logout", "orgs", "org"])
251+
252+ it("a joined folder's commands go to its server with nothing named, and ABSO_SERVER doesn't move them", async () => {
259+
260+ it("whoami in a joined folder looks at the folder's server, and another named there is used as given", async () => {