{"version":156,"agent":"speed","message":"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.","time":1791913882665,"timeIso":"2026-10-13T17:51:22.665Z","changes":8,"change":1949,"files":["client/src/doctor.ts","client/src/join-commands.ts","client/src/main.ts","client/src/server-choice.ts","client/test/box.test.ts","client/test/client.test.ts","client/test/doctor.test.ts","client/test/server-flag.test.ts"],"draft":null,"diff":[{"path":"client/src/doctor.ts","added":12,"removed":25,"diff":"--- a/client/src/doctor.ts\n+++ b/client/src/doctor.ts\n@@ -3,12 +3,10 @@\n // when one fails. Neither prints a credential. plainError words the commonest failures the same way.\n \n import { ApiError } from \"./api-error.ts\";\n-import { UsageError } from \"./args.ts\";\n import { type Answer, type BoxRecord, boxGet, boxText, originOf, readBox, signedInServers } from \"./box.ts\";\n import { builtCopy } from \"./client-version.ts\";\n import { type Config, credentialLabel, findRoot, readConfig } from \"./config.ts\";\n-import { TOKEN_SERVERS } from \"./core.ts\";\n-import { fromEnv } from \"./env-names.ts\";\n+import { sameServer } from \"./server-choice.ts\";\n \n /** The lowest Node major each kind of copy runs on: the npm package is built for 20, a checkout runs its .ts as is. */\n export function nodeNeeded(built: boolean): number {\n@@ -43,25 +41,13 @@\n }\n \n /**\n- * The server whoami and doctor look at, in the order join picks one: --server, then ABSO_SERVER, then this\n- * folder's server, then the one this box signed in to with abso login, then https://api.abso.dev. A box signed\n- * in to more than one server has to say which.\n+ * The servers other than `server` this box is signed in to, as one sentence for a refusal or a report to end\n+ * with, naming how to use one: a box signed in elsewhere is never used for `server` by itself.\n  */\n-export function checkServer(\n-\tflag: string | undefined,\n-\tcwd: string,\n-\tenv: Readonly<Record<string, string | undefined>>,\n-\thome?: string,\n-\tnow = Date.now(),\n-): string {\n-\tconst named = flag ?? fromEnv(env, \"SERVER\");\n-\tif (named) return named;\n-\tconst folder = folderOf(cwd, env)?.config?.server;\n-\tif (folder) return folder;\n-\tconst signedIn = signedInServers(home, now);\n-\tif (signedIn.length > 1)\n-\t\tthrow new UsageError(`this box is signed in to ${signedIn.join(\" and \")}: say which with --server <url>`);\n-\treturn signedIn[0] ?? TOKEN_SERVERS[0]!;\n+export function elsewhereText(server: string, command: string, home?: string, now = Date.now()): string {\n+\tconst others = signedInServers(home, now).filter((s) => !sameServer(s, originOf(server)));\n+\tif (others.length === 0) return \"\";\n+\treturn ` This box is signed in to ${others.join(\" and \")}: ${command} --server <url> uses ${others.length === 1 ? \"it\" : \"one\"}.`;\n }\n \n const day = (ms: number) => new Date(ms).toISOString().slice(0, 16).replace(\"T\", \" \");\n@@ -102,7 +88,9 @@\n \tconst record = readBox(server, probe.home);\n \tlet box: Record<string, unknown> | null = null;\n \tif (!record) {\n-\t\tlines.push(`This box isn't signed in to ${originOf(server)}. Run abso login.`);\n+\t\tlines.push(\n+\t\t\t`This box isn't signed in to ${originOf(server)}. Run abso login.${elsewhereText(server, \"abso whoami\", probe.home, probe.now)}`,\n+\t\t);\n \t} else {\n \t\tconst answer = await serverBox(record, probe);\n \t\tconst [first, ...rest] = boxText(record, server, probe.now).split(\"\\n\");\n@@ -155,7 +143,6 @@\n \tcwd: string,\n \tenv: Readonly<Record<string, string | undefined>>,\n \tprobe: Probe,\n-\texplicit = false,\n ): Promise<Check[]> {\n \tconst checks: Check[] = [];\n \tconst need = nodeNeeded(probe.built);\n@@ -171,8 +158,8 @@\n \t);\n \n \tconst folder = folderOf(cwd, env);\n-\t// The folder's own server when there is one (it's the one its commands talk to), unless --server named one.\n-\tconst target = explicit ? server : (folder?.config?.server ?? server);\n+\t// Chosen as every command chooses (server-choice.ts): --server, else the folder's own, else ABSO_SERVER, else prod.\n+\tconst target = server;\n \tconst origin = originOf(target);\n \tlet reachable = false;\n \tconst started = Date.now();"},{"path":"client/src/join-commands.ts","added":7,"removed":14,"diff":"--- a/client/src/join-commands.ts\n+++ b/client/src/join-commands.ts\n@@ -5,13 +5,13 @@\n import { Api, ApiError } from \"./api.ts\";\n import { bool, type Parsed, str, UsageError } from \"./args.ts\";\n import { writeKnownBlobs } from \"./blobs.ts\";\n-import { defaultAgentName, mintFreeName, mintKey, readBox, signedInServers } from \"./box.ts\";\n+import { defaultAgentName, mintFreeName, mintKey, readBox } from \"./box.ts\";\n import { STARTING_ABSOIGNORE } from \"./check-ignore.ts\";\n import { CLIENT_DIR } from \"./client-version.ts\";\n import { type Env, type Output, plural } from \"./command-env.ts\";\n import { leftOutText, syncFolder, uploadBlobs } from \"./commands.ts\";\n import { findRoot, installKey, readConfig, type Settings, tokenFor, writeConfig } from \"./config.ts\";\n-import { TOKEN_SERVERS } from \"./core.ts\";\n+import { elsewhereText } from \"./doctor.ts\";\n import { fromEnv } from \"./env-names.ts\";\n import { clearKnown, loadIgnore, readFolder, writeKnown } from \"./folder.ts\";\n import { modInstalled } from \"./install.ts\";\n@@ -19,19 +19,12 @@\n import { siteOf } from \"./orgs.ts\";\n import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from \"./project-file.ts\";\n import { refusedText } from \"./safety.ts\";\n+import { chooseServer, serverFlag } from \"./server-choice.ts\";\n import { OLD_STATE_DIR, STATE_DIR, stateDir } from \"./state-dir.ts\";\n \n-/**\n- * The server to join or start on: --server, then ABSO_SERVER, then the server this box is signed in\n- * to (abso login wrote it), then https://api.abso.dev. A box signed in to more than one server has to say which.\n- */\n-export function serverFrom(args: Parsed, env: Pick<Env, \"env\">, home?: string): string {\n-\tconst named = str(args, \"server\") ?? fromEnv(env.env, \"SERVER\");\n-\tif (named) return named;\n-\tconst signedIn = signedInServers(home);\n-\tif (signedIn.length > 1)\n-\t\tthrow new UsageError(`this box is signed in to ${signedIn.join(\" and \")}: say which with --server <url>`);\n-\treturn signedIn[0] ?? TOKEN_SERVERS[0]!;\n+/** The server to join or start on, in the order every command picks one (server-choice.ts chooseServer). */\n+export function serverFrom(args: Parsed, env: Pick<Env, \"env\" | \"cwd\">): string {\n+\treturn chooseServer(serverFlag(args), env.cwd, env.env);\n }\n \n const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\n@@ -150,7 +143,7 @@\n async function signedOut(server: string, project: string): Promise<string> {\n \treturn (await isPublic(server, project))\n \t\t? `${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.`\n-\t\t: `This box isn't signed in to ${server}. abso login signs it in.`;\n+\t\t: `This box isn't signed in to ${server}. abso login signs it in.${elsewhereText(server, `abso join ${project}`)}`;\n }\n \n /** A folder that reads a public project signed out: no agent, no key, no copy of the files. */"},{"path":"client/src/main.ts","added":24,"removed":24,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -38,8 +38,8 @@\n \ttakeNews,\n } from \"./commands.ts\";\n import { configPath, findRoot, installKey, isVisitor, readConfig, readToken } from \"./config.ts\";\n-import { newsBlockLines, newsShown, TOKEN_SERVERS } from \"./core.ts\";\n-import { checkServer, doctor, doctorText, plainError, realProbe, whoami } from \"./doctor.ts\";\n+import { newsBlockLines, newsShown } from \"./core.ts\";\n+import { doctor, doctorText, plainError, realProbe, whoami } from \"./doctor.ts\";\n import { runDraftSync, runLand, runSwitch } from \"./drafts.ts\";\n import { runExport } from \"./export.ts\";\n import { runBlame, runWhere, runWho, runWhy } from \"./history.ts\";\n@@ -49,7 +49,15 @@\n import { initInOrg, runOrg, runOrgs } from \"./orgs.ts\";\n import { runUnqueue } from \"./queue.ts\";\n import { runNote, runNotes, runReview } from \"./review.ts\";\n-import { checkFolderServer, localRefusal, serverFlag, serverHelp, serverUse } from \"./server-choice.ts\";\n+import {\n+\tcheckFolderServer,\n+\tchooseServer,\n+\tlocalRefusal,\n+\tSERVER_ORDER,\n+\tserverFlag,\n+\tserverHelp,\n+\tserverUse,\n+} from \"./server-choice.ts\";\n import { installSkill, SKILL, skillPath } from \"./skill.ts\";\n import { colorsPass, terminalText } from \"./terminal-text.ts\";\n import { runAmend, runDrop, runFollow, runLabel, runLabels, runPluck } from \"./versions.ts\";\n@@ -65,13 +73,9 @@\n \treadonly run: (args: Parsed, env: Env) => Promise<Output>;\n }\n \n-/** The server login, box and logout act on: --server, the folder's, or outside a folder abso.dev's (TOKEN_SERVERS[0]). */\n-export function boxServer(args: Parsed, env: Pick<Env, \"cwd\">): string {\n-\tconst flag = str(args, \"server\");\n-\tif (flag) return flag;\n-\tconst root = findRoot(env.cwd);\n-\tif (!root) return TOKEN_SERVERS[0]!;\n-\treturn (JSON.parse(readFileSync(configPath(root), \"utf8\")) as { server: string }).server;\n+/** The server login, box, logout, orgs, org, whoami and doctor act on, in the order every command picks one (server-choice.ts). */\n+export function boxServer(args: Parsed, env: Pick<Env, \"cwd\" | \"env\">): string {\n+\treturn chooseServer(serverFlag(args), env.cwd, env.env);\n }\n \n async function runKeyInstall(args: Parsed, env: Env): Promise<Output> {\n@@ -96,7 +100,7 @@\n \t\tflags: { server: \"string\", project: \"string\", agent: \"string\", \"as-is\": \"boolean\", org: \"string\" },\n \t\tusage: \"abso init [folder] --project <name> --agent <name> [--as-is] [--org <org>]\",\n \t\tabout:\n-\t\t\t\"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.\",\n+\t\t\t\"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.\",\n \t\trun: (args, env) => {\n \t\t\tconst org = str(args, \"org\");\n \t\t\treturn org === undefined ? runInit(args, env) : initInOrg(org, boxServer(args, env));\n@@ -186,7 +190,7 @@\n \t\tusage:\n \t\t\t\"abso login [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--max-agents <1-50>] [--days <1-90>]\",\n \t\tabout:\n-\t\t\t\"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.\",\n+\t\t\t\"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.\",\n \t\trun: async (args, env) => {\n \t\t\tconst server = boxServer(args, env);\n \t\t\tconst open =\n@@ -219,9 +223,9 @@\n \t\tflags: { server: \"string\" },\n \t\tusage: \"abso whoami\",\n \t\tabout:\n-\t\t\t\"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.\",\n+\t\t\t\"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.\",\n \t\trun: async (args, env) => {\n-\t\t\tconst out = await whoami(checkServer(str(args, \"server\"), env.cwd, env.env), env.cwd, env.env, realProbe());\n+\t\t\tconst out = await whoami(boxServer(args, env), env.cwd, env.env, realProbe());\n \t\t\treturn { text: out.text, json: out.json };\n \t\t},\n \t},\n@@ -229,15 +233,9 @@\n \t\tflags: { server: \"string\" },\n \t\tusage: \"abso doctor\",\n \t\tabout:\n-\t\t\t\"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.\",\n+\t\t\t\"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.\",\n \t\trun: async (args, env) => {\n-\t\t\tconst checks = await doctor(\n-\t\t\t\tcheckServer(str(args, \"server\"), env.cwd, env.env),\n-\t\t\t\tenv.cwd,\n-\t\t\t\tenv.env,\n-\t\t\t\trealProbe(),\n-\t\t\t\tstr(args, \"server\") !== undefined,\n-\t\t\t);\n+\t\t\tconst checks = await doctor(boxServer(args, env), env.cwd, env.env, realProbe());\n \t\t\tconst failed = checks.some((c) => c.result === \"fail\");\n \t\t\treturn { text: doctorText(checks), json: { checks }, ...(failed ? { exit: EXIT.error } : {}) };\n \t\t},\n@@ -308,7 +306,7 @@\n \t\tflags: { server: \"string\", agent: \"string\", dir: \"string\", reader: \"boolean\" },\n \t\tusage: \"abso join <project> [--agent <name>] [--dir <folder>] [--reader]\",\n \t\tabout:\n-\t\t\t\"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.\",\n+\t\t\t\"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.\",\n \t\trun: runJoin,\n \t},\n \trecord: {\n@@ -811,7 +809,9 @@\n const HELP_INTRO = \"abso: version control for agents. This is its command-line client.\";\n const HELP_NOTE =\n \t\"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). \" +\n-\t\"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.\";\n+\t\"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 \" +\n+\tSERVER_ORDER +\n+\t\": which servers this box is signed in to plays no part.\";\n \n /** A command's flags: its own, and --server for every command that talks to a server (server-choice.ts). */\n function flagsOf(name: string, def: CommandDef): FlagSpec {"},{"path":"client/src/server-choice.ts","added":34,"removed":2,"diff":"--- a/client/src/server-choice.ts\n+++ b/client/src/server-choice.ts\n@@ -8,15 +8,47 @@\n //   - A command that works on this machine only (\"local\") takes no --server, and says so.\n // A value that isn't an http or https URL (a user name, a query or a fragment included) is refused before any\n // call, as is an empty one.\n+//\n+// When nothing names a server (abso-core issue 9), every command picks it in one order (chooseServer):\n+//   1. --server <url>;\n+//   2. the server of the joined folder the command runs in (its .abso/config.json);\n+//   3. ABSO_SERVER (or the older AVCS_SERVER);\n+//   4. prod, https://api.abso.dev.\n+// Which servers this box is signed in to plays no part: signed in to staging and prod both, or to staging\n+// alone, a command with nothing named goes to prod, and staging is a deliberate --server, folder or ABSO_SERVER.\n \n import { readFileSync } from \"node:fs\";\n import { type Parsed, UsageError } from \"./args.ts\";\n import { configPath, findRoot } from \"./config.ts\";\n-import { serverBase } from \"./core.ts\";\n+import { serverBase, TOKEN_SERVERS } from \"./core.ts\";\n+import { fromEnv } from \"./env-names.ts\";\n \n /** How a command uses a server: its joined folder's, one it picks, or none. */\n export type ServerUse = \"folder\" | \"chosen\" | \"local\";\n \n+/** The server a command goes to when nothing names one: prod. */\n+export const PROD_SERVER = TOKEN_SERVERS[0]!;\n+\n+/** The order of precedence, in the words help uses. */\n+export const SERVER_ORDER = `--server <url>, else the server of the abso folder you're in, else ABSO_SERVER, else prod (${PROD_SERVER})`;\n+\n+/**\n+ * The server a command goes to: `flag` (checked by serverFlag), else the joined folder's, else ABSO_SERVER\n+ * (checked here), else prod. An explicit choice is returned as given, never swapped for another.\n+ */\n+export function chooseServer(\n+\tflag: string | undefined,\n+\tcwd: string,\n+\tenv: Readonly<Record<string, string | undefined>>,\n+): string {\n+\tif (flag !== undefined) return flag;\n+\tconst folder = folderServer(cwd);\n+\tif (folder !== undefined) return folder;\n+\tconst named = fromEnv(env, \"SERVER\");\n+\tif (named !== undefined) return checkedServer(named, env.ABSO_SERVER ? \"ABSO_SERVER\" : \"AVCS_SERVER\");\n+\treturn PROD_SERVER;\n+}\n+\n /** The commands that pick a server for themselves rather than use a joined folder's. */\n const CHOSEN: ReadonlySet<string> = new Set([\n \t\"init\",\n@@ -101,7 +133,7 @@\n \t\tcase \"chosen\":\n \t\t\treturn command === \"key\"\n \t\t\t\t? \"--server <url>: the server the key is for; without it, this folder's. It is used as given, never swapped for another.\"\n-\t\t\t\t: \"--server <url>: the server to use, as given, never swapped for another. Each server gets only its own sign-in.\";\n+\t\t\t\t: `--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.`;\n \t}\n }\n "},{"path":"client/test/box.test.ts","added":8,"removed":13,"diff":"--- a/client/test/box.test.ts\n+++ b/client/test/box.test.ts\n@@ -383,27 +383,22 @@\n \tassert.equal(forgetBox(SERVER, h), false);\n });\n \n-test(\"join and init pick the server: --server, ABSO_SERVER, the box's sign-in, then api.abso.dev\", () => {\n+test(\"join and init pick the server in the one order: --server, the folder's, ABSO_SERVER, then prod\", () => {\n \tconst h = home();\n+\tconst outside = home();\n \tconst args = (server?: string) => ({ positionals: [], flags: new Map(server ? [[\"server\", server]] : []) });\n-\tconst none = { env: {} };\n-\tassert.equal(serverFrom(args(), none, h), \"https://api.abso.dev\", \"nothing signed in: the abso API\");\n+\tconst none = { env: {}, cwd: outside };\n+\tassert.equal(serverFrom(args(), none), \"https://api.abso.dev\", \"nothing named: prod\");\n \twriteBox({ ...record, expiresAt: Date.now() + 1e6 }, h);\n \tassert.deepEqual(signedInServers(h), [SERVER]);\n-\tassert.equal(serverFrom(args(), none, h), SERVER, \"the server abso login signed this box in to\");\n+\tassert.equal(serverFrom(args(), none), \"https://api.abso.dev\", \"a sign-in elsewhere doesn't pick the server\");\n \tassert.deepEqual(signedInServers(h, Date.now() + 2e6), [], \"an expired sign-in doesn't count\");\n-\tassert.equal(serverFrom(args(), { env: { ABSO_SERVER: \"https://env.example\" } }, h), \"https://env.example\");\n+\tassert.equal(serverFrom(args(), { ...none, env: { ABSO_SERVER: \"https://env.example\" } }), \"https://env.example\");\n \tassert.equal(\n-\t\tserverFrom(args(\"https://flag.example\"), { env: { ABSO_SERVER: \"https://env.example\" } }, h),\n+\t\tserverFrom(args(\"https://flag.example\"), { ...none, env: { ABSO_SERVER: \"https://env.example\" } }),\n \t\t\"https://flag.example\",\n \t);\n-\twriteBox({ ...record, server: \"https://other.abso.example\", expiresAt: Date.now() + 1e6 }, h);\n-\twriteBox({ ...record, expiresAt: Date.now() + 1e6 }, h);\n-\tassert.throws(\n-\t\t() => serverFrom(args(), none, h),\n-\t\t/signed in to https:\\/\\/other\\.abso\\.example and https:\\/\\/staging\\.abso\\.example: say which with --server/,\n-\t);\n-\tassert.equal(serverFrom(args(SERVER), none, h), SERVER, \"--server settles it\");\n+\tassert.equal(serverFrom(args(SERVER), none), SERVER, \"--server is used as given\");\n });\n \n test(\"join with no --agent takes the box's name, skips names this box holds, and moves past a taken one\", async () => {"},{"path":"client/test/client.test.ts","added":5,"removed":2,"diff":"--- a/client/test/client.test.ts\n+++ b/client/test/client.test.ts\n@@ -2846,9 +2846,12 @@\n \tit(\"abso login, box and logout outside a folder act on https://api.abso.dev\", () => {\n \t\tconst outside = mkdtempSync(join(tmpdir(), \"abso-login-\"));\n \t\ttry {\n-\t\t\tassert.equal(boxServer(parseArgs(\"login\", [], { server: \"string\" }), { cwd: outside }), \"https://api.abso.dev\");\n+\t\t\tassert.equal(\n+\t\t\t\tboxServer(parseArgs(\"login\", [], { server: \"string\" }), { cwd: outside, env: {} }),\n+\t\t\t\t\"https://api.abso.dev\",\n+\t\t\t);\n \t\t\tconst given = parseArgs(\"login\", [\"--server\", \"https://example.test\"], { server: \"string\" });\n-\t\t\tassert.equal(boxServer(given, { cwd: outside }), \"https://example.test\");\n+\t\t\tassert.equal(boxServer(given, { cwd: outside, env: {} }), \"https://example.test\");\n \t\t} finally {\n \t\t\trmSync(outside, { recursive: true, force: true });\n \t\t}"},{"path":"client/test/doctor.test.ts","added":10,"removed":17,"diff":"--- a/client/test/doctor.test.ts\n+++ b/client/test/doctor.test.ts\n@@ -8,7 +8,7 @@\n import { test } from \"node:test\";\n import { ApiError } from \"../src/api-error.ts\";\n import { writeBox } from \"../src/box.ts\";\n-import { checkServer, doctor, doctorText, nodeNeeded, type Probe, plainError, whoami } from \"../src/doctor.ts\";\n+import { doctor, doctorText, nodeNeeded, type Probe, plainError, whoami } from \"../src/doctor.ts\";\n \n const SERVER = \"https://staging.abso.example\";\n const CREDENTIAL = \"abso_bx_the-secret-credential\";\n@@ -228,25 +228,18 @@\n \tassert.equal(plainError(new Error(\"anything else\"), true), undefined);\n });\n \n-test(\"whoami and doctor pick the server as join does: --server, ABSO_SERVER, the folder's, the box's sign-in, then abso.dev\", () => {\n+test(\"whoami with nothing named shows prod, and names the other servers this box is signed in to\", async () => {\n \tconst outside = temp(\"outside\");\n-\tconst empty = temp(\"home\");\n-\tassert.equal(checkServer(undefined, outside, {}, empty, NOW), \"https://api.abso.dev\");\n \tconst home = temp(\"home\");\n \twriteBox(box(), home);\n-\tassert.equal(checkServer(undefined, outside, {}, home, NOW), SERVER);\n-\tassert.equal(checkServer(undefined, folder(), {}, empty, NOW), SERVER);\n-\tassert.equal(checkServer(undefined, outside, { ABSO_SERVER: \"http://env.example\" }, home, NOW), \"http://env.example\");\n-\tassert.equal(\n-\t\tcheckServer(\"http://flag.example\", folder(), { ABSO_SERVER: \"http://env.example\" }, home, NOW),\n-\t\t\"http://flag.example\",\n+\tconst fetcher = server({ \"/box\": [200, { revoked_at: null }] });\n+\tconst prod = await whoami(\"https://api.abso.dev\", outside, {}, probe(fetcher, home));\n+\tassert.match(\n+\t\tprod.text,\n+\t\t/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\\./,\n \t);\n-\tconst expired = temp(\"home\");\n-\twriteBox(box(NOW - 1), expired);\n-\tassert.equal(checkServer(undefined, outside, {}, expired, NOW), \"https://api.abso.dev\");\n \twriteBox({ ...box(), server: \"https://api.abso.dev\" }, home);\n-\tassert.throws(\n-\t\t() => checkServer(undefined, outside, {}, home, NOW),\n-\t\t/signed in to .* and .*: say which with --server/,\n-\t);\n+\tconst both = await whoami(\"https://api.abso.dev\", outside, {}, probe(fetcher, home));\n+\tassert.match(both.text, /Signed in to https:\\/\\/api\\.abso\\.dev as box b_0123abcd/);\n+\tassert.equal(both.json.server, \"https://api.abso.dev\");\n });"},{"path":"client/test/server-flag.test.ts","added":51,"removed":2,"diff":"--- a/client/test/server-flag.test.ts\n+++ b/client/test/server-flag.test.ts\n@@ -5,7 +5,9 @@\n // - in a joined folder, --server naming the folder's own server reaches it; another server is refused, never\n //   swapped in, and nothing is sent; outside a joined folder a folder command with --server is refused too;\n // - an explicit --server goes to that server's own Issues Worker, which ABSO_ISSUES_SERVER doesn't redirect;\n-// - a command that picks its server (whoami, box, logout) uses the one named, even inside a folder on another.\n+// - a command that picks its server (whoami, box, logout) uses the one named, even inside a folder on another;\n+// - with nothing named (abso-core issue 9) the server is the joined folder's, else ABSO_SERVER, else prod, whatever\n+//   this box is signed in to (doctor.test.ts has whoami with staging alone and with staging and prod both).\n \n import assert from \"node:assert/strict\";\n import { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\n@@ -16,7 +18,7 @@\n import { after, before, describe, it } from \"node:test\";\n import { writeConfig } from \"../src/config.ts\";\n import { commandTable, main } from \"../src/main.ts\";\n-import { sameServer, serverHelp, serverUse } from \"../src/server-choice.ts\";\n+import { chooseServer, PROD_SERVER, SERVER_ORDER, sameServer, serverHelp, serverUse } from \"../src/server-choice.ts\";\n \n /** A made-up token: the tests never read the real ~/.abso/token. */\n const TOKEN = \"abso_test-token-for-server-flag\";\n@@ -216,3 +218,50 @@\n \t\tassert.ok(!sameServer(\"https://x.example/a\", \"https://x.example/b\"));\n \t});\n });\n+\n+describe(\"the server when nothing names one\", () => {\n+\tconst STAGING = \"https://staging.abso.example\";\n+\n+\tit(\"is --server, else the joined folder's, else ABSO_SERVER, else prod\", () => {\n+\t\tconst outside = temp(\"outside\");\n+\t\tconst staging = folder(STAGING);\n+\t\tassert.equal(PROD_SERVER, \"https://api.abso.dev\");\n+\t\tassert.equal(chooseServer(undefined, outside, {}), PROD_SERVER, \"nothing named: prod\");\n+\t\tassert.equal(chooseServer(undefined, outside, { ABSO_SERVER: STAGING }), STAGING, \"the environment\");\n+\t\tassert.equal(chooseServer(undefined, outside, { AVCS_SERVER: STAGING }), STAGING, \"its older name\");\n+\t\tassert.equal(chooseServer(undefined, staging, {}), STAGING, \"a joined staging folder\");\n+\t\tassert.equal(chooseServer(undefined, staging, { ABSO_SERVER: \"https://env.example\" }), STAGING, \"folder first\");\n+\t\tassert.equal(chooseServer(PROD_SERVER, staging, { ABSO_SERVER: STAGING }), PROD_SERVER, \"explicit prod\");\n+\t\tassert.equal(chooseServer(STAGING, outside, {}), STAGING, \"explicit staging\");\n+\t\tassert.throws(\n+\t\t\t() => chooseServer(undefined, outside, { ABSO_SERVER: \"staging\" }),\n+\t\t\t/ABSO_SERVER takes an http or https URL/,\n+\t\t);\n+\t});\n+\n+\tit(\"help names the order once for every command that picks its server\", async () => {\n+\t\tassert.equal(\n+\t\t\tSERVER_ORDER,\n+\t\t\t\"--server <url>, else the server of the abso folder you're in, else ABSO_SERVER, else prod (https://api.abso.dev)\",\n+\t\t);\n+\t\tfor (const name of [\"join\", \"init\", \"login\", \"whoami\", \"doctor\", \"box\", \"logout\", \"orgs\", \"org\"])\n+\t\t\tassert.ok(serverHelp(name)?.includes(SERVER_ORDER), name);\n+\t\tassert.ok((await run(process.cwd(), [\"help\"])).stdout.includes(SERVER_ORDER));\n+\t});\n+\n+\tit(\"a joined folder's commands go to its server with nothing named, and ABSO_SERVER doesn't move them\", async () => {\n+\t\tconst root = folder();\n+\t\tclear();\n+\t\tawait run(root, [\"status\"], { ABSO_SERVER: other.url });\n+\t\tassert.ok(home.paths.length > 0);\n+\t\tassert.equal(other.paths.length, 0);\n+\t});\n+\n+\tit(\"whoami in a joined folder looks at the folder's server, and another named there is used as given\", async () => {\n+\t\tconst root = folder();\n+\t\tconst here = await run(root, [\"whoami\"], { ABSO_SERVER: other.url });\n+\t\tassert.ok(here.stdout.includes(`isn't signed in to ${home.url}`), here.stdout);\n+\t\tconst named = await run(root, [\"box\", \"--server\", other.url]);\n+\t\tassert.ok(named.stdout.includes(`isn't signed in to ${other.url}`), named.stdout);\n+\t});\n+});"}],"ci":null}