{"version":271,"agent":"readspeed","message":"No command picks up a credential from a file nobody asked for\n\nFollows \"abso init signs in with the box sign-in\" (issue 25), and applies it to every command.\n\n- A folder with a key signs in with that key and nothing else: not ABSO_TOKEN, not ~/.abso/token, even when the server refuses the key. A key file that can't be read is now an error (\"abso key install puts a key back\") instead of a quiet fall back to another credential.\n- With no key, a command signs in with ABSO_TOKEN (or a pipeline run's ABSO_KEY_FILE). This machine's ~/.abso/token is used only by a command given --token-file, which every command that talks to a server now takes. Without it, a refused call says \"You're not signed in. Run abso login, then abso join <project>. ~/.abso/token is used only with --token-file.\" abso doctor says the same about a token file it finds unused. The edit hook and MCP tools never read it.\n- The admin token (ABSO_ADMIN_TOKEN, or ~/.abso/admin-token) is read only by abso key and abso flag. Each says \"Using the admin token, from ...\" every time it uses it. A test holds that no other module reads the file.\n\nWhat changes for you: a folder with no key that relied on ~/.abso/token needs --token-file on each command, or ABSO_TOKEN, or a key (abso login, then abso join).\n\nTests: client/test/token-file.test.ts (3, new); client/test/client.test.ts's MCP check covers --token-file. All client tests pass (443).","time":1792101955290,"timeIso":"2026-10-15T22:05:55.290Z","changes":12,"change":4107,"files":["client/src/command-env.ts","client/src/config.ts","client/src/doctor.ts","client/src/flag-commands.ts","client/src/history.ts","client/src/key-admin.ts","client/src/main.ts","client/src/mcp.ts","client/test/token-file.test.ts"],"draft":null,"diff":[{"path":"client/src/command-env.ts","added":3,"removed":1,"diff":"--- a/client/src/command-env.ts\n+++ b/client/src/command-env.ts\n@@ -19,6 +19,8 @@\n \treadonly env: Readonly<Record<string, string | undefined>>;\n \t/** Where `run` streams the box's output as it arrives. */\n \treadonly write: (text: string) => void;\n+\t/** --token-file: this machine's ~/.abso/token may sign in, where nothing else does. Never read otherwise. */\n+\treadonly tokenFile?: boolean;\n \t/** Where `run` streams the box's stderr; `write` when not given. */\n \treadonly writeErr?: (text: string) => void;\n \t/** What a box run is for, when a command runs one for its own ends (shot, bisect, publish --check). */\n@@ -42,7 +44,7 @@\n \t\tthrow new UsageError(\n \t\t\t`You're not in an abso folder: ${env.cwd} has no .abso/config.json, nor does any folder above it. abso join <project> makes one, or abso init a new project.`,\n \t\t);\n-\tconst config = readConfig(root, env.env);\n+\tconst config = readConfig(root, env.env, env.tokenFile === true);\n \treturn { root, config, api: new Api(config) };\n }\n "},{"path":"client/src/config.ts","added":10,"removed":4,"diff":"--- a/client/src/config.ts\n+++ b/client/src/config.ts\n@@ -51,7 +51,7 @@\n export function readConfig(\n \troot: string,\n \tenv: Readonly<Record<string, string | undefined>> = process.env,\n-\ttokenFileOk = true,\n+\ttokenFileOk = false,\n ): Config {\n \tconst raw = JSON.parse(readFileSync(configPath(root), \"utf8\")) as Partial<Settings>;\n \tif (raw.visitor === true) {\n@@ -102,6 +102,7 @@\n \troot: string,\n \tserver: string,\n \tenv: Readonly<Record<string, string | undefined>> = process.env,\n+\ttokenFileOk = false,\n ): { kind: \"agent key\" | \"shared token\" | \"pipeline run key\" | \"none\"; id: string | null } {\n \tconst key = readKeyFile(root);\n \tif (key) {\n@@ -110,7 +111,7 @@\n \t}\n \tif (fromEnv(env, \"TOKEN\")) return { kind: \"shared token\", id: null };\n \tif (fromEnv(env, \"KEY_FILE\")) return { kind: \"pipeline run key\", id: null };\n-\treturn { kind: readToken(env) ? \"shared token\" : \"none\", id: null };\n+\treturn { kind: tokenFileOk && tokenFile() ? \"shared token\" : \"none\", id: null };\n }\n \n interface StoredKey {\n@@ -182,10 +183,15 @@\n \tserver: string,\n \tenv: Readonly<Record<string, string | undefined>> = process.env,\n \troot?: string,\n-\ttokenFileOk = true,\n+\ttokenFileOk = false,\n ): string | undefined {\n \tif (root) {\n \t\tconst key = readKeyFile(root);\n+\t\t// A folder with a key signs in with that key and nothing else, even when the server refuses it.\n+\t\tif (!key && existsSync(keyPath(root)))\n+\t\t\tthrow new UsageError(\n+\t\t\t\t`this folder's key file (${keyPath(root)}) can't be read, so abso sends nothing; abso key install puts a key back`,\n+\t\t\t);\n \t\tif (key) {\n \t\t\tif (originOf(key.server) !== originOf(server))\n \t\t\t\tthrow new UsageError(\"this folder's key was issued for a different server, so abso will not send it\");\n@@ -251,7 +257,7 @@\n \treturn key;\n }\n \n-/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. abso init and join read it only with --token-file. */\n+/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. Read only for a command given --token-file. */\n export function tokenFile(): string | undefined {\n \treturn readToken({});\n }"},{"path":"client/src/doctor.ts","added":6,"removed":4,"diff":"--- a/client/src/doctor.ts\n+++ b/client/src/doctor.ts\n@@ -5,7 +5,7 @@\n import { ApiError } from \"./api-error.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 { type Config, credentialLabel, findRoot, readConfig, tokenFile } from \"./config.ts\";\n import { sameServer } from \"./server-choice.ts\";\n \n /**\n@@ -84,7 +84,9 @@\n \t\t\t? \"the shared token\"\n \t\t\t: c.kind === \"pipeline run key\"\n \t\t\t\t? \"a pipeline run's key\"\n-\t\t\t\t: \"no key\";\n+\t\t\t\t: tokenFile() !== undefined\n+\t\t\t\t\t? \"no key (~/.abso/token is here, and is used only with --token-file)\"\n+\t\t\t\t\t: \"no key\";\n }\n \n export async function whoami(\n@@ -327,12 +329,12 @@\n  * The commonest failures in plain words, with the next step: no credential, a credential the server refuses, and a\n  * server that can't be reached. Anything else is left as it was. `signedIn` is whether the call carried a key or token.\n  */\n-export function plainError(err: unknown, signedIn: boolean): string | undefined {\n+export function plainError(err: unknown, signedIn: boolean, tokenFileUnasked = false): string | undefined {\n \tif (!(err instanceof ApiError)) return undefined;\n \tif (err.status === 401)\n \t\treturn signedIn\n \t\t\t? `The server didn't accept this folder's key: it may be revoked or expired. abso doctor checks it. (${err.message})`\n-\t\t\t: \"You're not signed in. Run abso login, then abso join <project>.\";\n+\t\t\t: `You're not signed in. Run abso login, then abso join <project>.${tokenFileUnasked ? \" ~/.abso/token is used only with --token-file.\" : \"\"}`;\n \tif (err.status === undefined && err.message.startsWith(\"could not reach \")) {\n \t\tconst said = err.message.replace(/^could not reach /, \"Can't reach \");\n \t\t// A message that already gives its next step (publish's \"Run the same command again.\") keeps it as the last word."},{"path":"client/src/flag-commands.ts","added":2,"removed":1,"diff":"--- a/client/src/flag-commands.ts\n+++ b/client/src/flag-commands.ts\n@@ -6,7 +6,7 @@\n import { type Env, type Output, open } from \"./commands.ts\";\n import type { Config } from \"./config.ts\";\n import { fromEnv } from \"./env-names.ts\";\n-import { adminGoesTo, adminToken } from \"./key-admin.ts\";\n+import { adminGoesTo, adminToken, adminTokenWords } from \"./key-admin.ts\";\n import { shortWhen } from \"./times.ts\";\n \n /** One flag as GET /admin/flags answers it: what it takes and gates, and where it's set. */\n@@ -117,6 +117,7 @@\n \tconst [sub = \"list\", flag, value, ...extra] = args.positionals;\n \tconst { config } = open(env);\n \tconst admin = adminFor(config.server, env.env);\n+\tif (admin) (env.writeErr ?? env.write)(`${adminTokenWords(env.env)}\\n`);\n \tif (sub === \"list\" && flag === undefined) {\n \t\tconst body = (await call(config, admin, \"/admin/flags\")) as {\n \t\t\trevision: number;"},{"path":"client/src/history.ts","added":1,"removed":1,"diff":"--- a/client/src/history.ts\n+++ b/client/src/history.ts\n@@ -15,7 +15,7 @@\n \tconst root = findRoot(env.cwd);\n \tif (root === undefined)\n \t\tthrow new UsageError(`${env.cwd} is not in an abso folder (no .abso/config.json here or above)`);\n-\tconst config = readConfig(root, env.env);\n+\tconst config = readConfig(root, env.env, env.tokenFile === true);\n \treturn { root, api: new Api(config), agent: config.agent };\n }\n "},{"path":"client/src/key-admin.ts","added":5,"removed":0,"diff":"--- a/client/src/key-admin.ts\n+++ b/client/src/key-admin.ts\n@@ -38,6 +38,11 @@\n \tthrow new UsageError(\"abso key needs the admin token in ABSO_ADMIN_TOKEN or ~/.abso/admin-token\");\n }\n \n+/** What an admin command says each time it uses the admin token, and where it came from. Never the token. */\n+export function adminTokenWords(env: Readonly<Record<string, string | undefined>> = process.env): string {\n+\treturn `Using the admin token, from ${fromEnv(env, \"ADMIN_TOKEN\")?.trim() ? \"ABSO_ADMIN_TOKEN\" : \"~/.abso/admin-token\"}.`;\n+}\n+\n function scrub(text: string, secrets: readonly string[]): string {\n \tlet out = text.replace(/abso_sk_[A-Za-z0-9_-]+/g, \"[redacted]\");\n \tfor (const secret of secrets) if (secret.length > 0) out = out.split(secret).join(\"[redacted]\");"},{"path":"client/src/main.ts","added":21,"removed":11,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -38,10 +38,11 @@\n \trunSync,\n \ttakeNews,\n } from \"./commands.ts\";\n-import { configPath, findRoot, installKey, isVisitor, readConfig, readToken } from \"./config.ts\";\n+import { configPath, findRoot, installKey, isVisitor, readConfig, tokenFile } from \"./config.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 { fromEnv } from \"./env-names.ts\";\n import { runExport } from \"./export.ts\";\n import { runFlag } from \"./flag-commands.ts\";\n import { runGroup, runGroups } from \"./group-commands.ts\";\n@@ -57,7 +58,7 @@\n \trunSearch,\n \trunWaiting,\n } from \"./issues.ts\";\n-import { adminToken, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from \"./key-admin.ts\";\n+import { adminToken, adminTokenWords, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from \"./key-admin.ts\";\n import { browserSkip, openInBrowser } from \"./open-browser.ts\";\n import { runOrg, runOrgs } from \"./orgs.ts\";\n import { runUnqueue } from \"./queue.ts\";\n@@ -148,17 +149,18 @@\n \t\t\tif (!root) throw new UsageError(\"abso key runs inside an agent's folder, or takes --server <url>\");\n \t\t\tlet config: ReturnType<typeof readConfig>;\n \t\t\ttry {\n-\t\t\t\tconfig = readConfig(root, env.env);\n+\t\t\t\tconfig = readConfig(root, env.env, env.tokenFile === true);\n \t\t\t} catch {\n \t\t\t\tconfig = {\n \t\t\t\t\tserver: serverFlag ?? \"\",\n \t\t\t\t\tproject: str(args, \"project\") ?? \"\",\n \t\t\t\t\tagent: \"admin\",\n-\t\t\t\t\ttoken: readToken(env.env),\n+\t\t\t\t\ttoken: fromEnv(env.env, \"TOKEN\")?.trim() || (env.tokenFile ? tokenFile() : undefined),\n \t\t\t\t};\n \t\t\t}\n \t\t\tif (serverFlag) config = { ...config, server: serverFlag };\n \t\t\tconst admin = adminToken(env.env);\n+\t\t\t(env.writeErr ?? env.write)(`${adminTokenWords(env.env)}\\n`);\n \t\t\tif (sub === \"new\" && args.positionals.length === 2) {\n \t\t\t\tconst server = str(args, \"server\") ?? config.server;\n \t\t\t\tconst project = str(args, \"project\") ?? config.project;\n@@ -876,14 +878,14 @@\n \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 takes --json. Settings live in .abso/config.json (.avcs/config.json in a folder from before the rename). A folder with a key signs in with that key and nothing else. Without one, the token comes from ABSO_TOKEN; this machine's ~/.abso/token (or ~/.avcs/token from before) is used only by a command given --token-file. \" +\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+/** A command's flags: its own, and --server and --token-file for every command that talks to a server (server-choice.ts). */\n function flagsOf(name: string, def: CommandDef): FlagSpec {\n-\treturn serverUse(name) === \"local\" ? def.flags : { ...def.flags, server: \"string\" };\n+\treturn serverUse(name) === \"local\" ? def.flags : { ...def.flags, server: \"string\", \"token-file\": \"boolean\" };\n }\n \n /** Every command as help shows it, in order: the table's, then the three it doesn't hold. */\n@@ -960,10 +962,12 @@\n }\n \n /** Whether this folder's calls carry a key or token, for how a refusal is worded. False when that can't be told. */\n-function carriesCredential(env: Env): boolean {\n+function carriesCredential(env: Env, tokenFileAsked: boolean): boolean {\n \ttry {\n \t\tconst root = findRoot(env.cwd);\n-\t\treturn root ? readConfig(root, env.env).token !== undefined : readToken(env.env) !== undefined;\n+\t\treturn root\n+\t\t\t? readConfig(root, env.env, tokenFileAsked).token !== undefined\n+\t\t\t: (fromEnv(env.env, \"TOKEN\") ?? (tokenFileAsked ? tokenFile() : undefined)) !== undefined;\n \t} catch {\n \t\treturn false;\n \t}\n@@ -984,6 +988,7 @@\n export async function main(argv: readonly string[], env: Env): Promise<MainResult> {\n \tconst command = argv[0];\n \tconst json = argv.includes(\"--json\") && command !== \"run\" && command !== \"logs\";\n+\tconst asked = argv.includes(\"--token-file\");\n \tif (command === undefined || command === \"help\" || command === \"--help\" || command === \"-h\") {\n \t\tif (json) {\n \t\t\tconst data = helpJson();\n@@ -1047,7 +1052,12 @@\n \t\tif (root !== undefined && isVisitor(root)) checkVisitor(command, parsed, readConfig(root, env.env).project);\n \t\tconst args = readBodyFiles(command, parsed, env.cwd, env.readStdin);\n \t\ttakeNews(); // what an earlier call in this process left (tests run many)\n-\t\tconst out = await def.run(args, named === undefined ? env : { ...env, server: named });\n+\t\tconst runEnv: Env = {\n+\t\t\t...env,\n+\t\t\t...(named === undefined ? {} : { server: named }),\n+\t\t\t...(bool(parsed, \"token-file\") ? { tokenFile: true } : {}),\n+\t\t};\n+\t\tconst out = await def.run(args, runEnv);\n \t\tconst exit = out.exit ?? EXIT.ok;\n \t\t// Every command that took news while recording prints it (#37, News Report).\n \t\tconst news = takeNews();\n@@ -1069,7 +1079,7 @@\n \t\tconst e = err as Error;\n \t\tconst code = err instanceof UsageError ? \"usage\" : err instanceof ApiError ? \"server\" : \"error\";\n \t\tconst message =\n-\t\t\tplainError(err, carriesCredential(env)) ??\n+\t\t\tplainError(err, carriesCredential(env, asked), !asked && tokenFile() !== undefined) ??\n \t\t\t(err instanceof UsageError || err instanceof ApiError\n \t\t\t\t? e.message\n \t\t\t\t: `${e.message}${e.stack ? `\\n${e.stack}` : \"\"}`);"},{"path":"client/src/mcp.ts","added":13,"removed":9,"diff":"--- a/client/src/mcp.ts\n+++ b/client/src/mcp.ts\n@@ -78,15 +78,19 @@\n \treturn MCP_COMMANDS.map((command) => {\n \t\tconst def = table[command]!;\n \t\tconst flags = Object.fromEntries(\n-\t\t\tObject.entries(def.flags).map(([flag, kind]) => [\n-\t\t\t\tflag,\n-\t\t\t\tkind === \"boolean\"\n-\t\t\t\t\t? { type: \"boolean\", description: `--${flag}` }\n-\t\t\t\t\t: {\n-\t\t\t\t\t\t\ttype: \"string\",\n-\t\t\t\t\t\t\tdescription: kind === \"optional\" ? `--${flag} \"<value>\"; \"\" gives --${flag} alone` : `--${flag} <value>`,\n-\t\t\t\t\t\t},\n-\t\t\t]),\n+\t\t\t// No --token-file: a tool signs in with its folder's key, never this machine's token file.\n+\t\t\tObject.entries(def.flags)\n+\t\t\t\t.filter(([flag]) => flag !== \"token-file\")\n+\t\t\t\t.map(([flag, kind]) => [\n+\t\t\t\t\tflag,\n+\t\t\t\t\tkind === \"boolean\"\n+\t\t\t\t\t\t? { type: \"boolean\", description: `--${flag}` }\n+\t\t\t\t\t\t: {\n+\t\t\t\t\t\t\t\ttype: \"string\",\n+\t\t\t\t\t\t\t\tdescription:\n+\t\t\t\t\t\t\t\t\tkind === \"optional\" ? `--${flag} \"<value>\"; \"\" gives --${flag} alone` : `--${flag} <value>`,\n+\t\t\t\t\t\t\t},\n+\t\t\t\t]),\n \t\t);\n \t\treturn {\n \t\t\tname: toolName(command),"},{"path":"client/test/token-file.test.ts","added":157,"removed":0,"diff":"--- /dev/null\n+++ b/client/test/token-file.test.ts\n@@ -0,0 +1,157 @@\n+// A credential is never picked up from a file nobody asked for. A folder with a key signs in with that key only, and a\n+// key file that can't be read is an error, not a reason to try another credential. With no key, this machine's\n+// ~/.abso/token signs in only for a command given --token-file. The admin token is read by admin commands alone, and\n+// each says when it uses it.\n+\n+import assert from \"node:assert/strict\";\n+import { execFile } from \"node:child_process\";\n+import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n+import { tmpdir } from \"node:os\";\n+import { join, resolve } from \"node:path\";\n+import { after, before, describe, it } from \"node:test\";\n+import { tokenFor } from \"../src/config.ts\";\n+import { adminTokenWords } from \"../src/key-admin.ts\";\n+import { type Fake, startFake } from \"./fake-server.ts\";\n+\n+const CLIENT = resolve(import.meta.dirname, \"..\", \"abso.ts\");\n+const TOKEN = \"file-token-not-secret\";\n+const KEY = \"abso_sk_folder-key-not-secret\";\n+let fake: Fake;\n+const dirs: string[] = [];\n+const temp = () => {\n+\tconst dir = mkdtempSync(join(tmpdir(), \"abso-test-token-file-\"));\n+\tdirs.push(dir);\n+\treturn dir;\n+};\n+\n+before(async () => {\n+\tfake = await startFake(0, TOKEN);\n+});\n+after(async () => {\n+\tawait fake.close();\n+\tfor (const dir of dirs) rmSync(dir, { recursive: true, force: true });\n+});\n+\n+function homeWithToken(): string {\n+\tconst dir = temp();\n+\tmkdirSync(join(dir, \".abso\"), { recursive: true });\n+\twriteFileSync(join(dir, \".abso\", \"token\"), `${TOKEN}\\n`);\n+\treturn dir;\n+}\n+\n+/** A joined folder on `server`, with the given key file text, or none. */\n+function folder(server: string, key?: string): string {\n+\tconst dir = temp();\n+\tmkdirSync(join(dir, \".abso\"));\n+\twriteFileSync(join(dir, \".abso\", \"config.json\"), JSON.stringify({ server, project: \"p\", agent: \"me\" }));\n+\tif (key !== undefined) writeFileSync(join(dir, \".abso\", \"key\"), key);\n+\treturn dir;\n+}\n+\n+/** Runs `fn` with this home as the user's, so the token file is the test's own. */\n+function asHome<T>(home: string, fn: () => T): T {\n+\tconst saved = { HOME: process.env.HOME, USERPROFILE: process.env.USERPROFILE };\n+\tprocess.env.HOME = home;\n+\tprocess.env.USERPROFILE = home;\n+\ttry {\n+\t\treturn fn();\n+\t} finally {\n+\t\tfor (const [k, v] of Object.entries(saved)) {\n+\t\t\tif (v === undefined) delete process.env[k];\n+\t\t\telse process.env[k] = v;\n+\t\t}\n+\t}\n+}\n+\n+function client(\n+\thome: string,\n+\tcwd: string,\n+\t...args: string[]\n+): Promise<{ code: number; stdout: string; stderr: string }> {\n+\tconst env: Record<string, string> = {\n+\t\tPATH: process.env.PATH ?? \"\",\n+\t\tHOME: home,\n+\t\tUSERPROFILE: home,\n+\t\tAVCS_SERVERS_FILE: \"no-servers.json\",\n+\t\tABSO_NO_BROWSER: \"1\",\n+\t};\n+\tif (process.env.CLAUDE_CONFIG_DIR) env.CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR;\n+\tif (process.env.SystemRoot) env.SystemRoot = process.env.SystemRoot;\n+\treturn new Promise((done) => {\n+\t\texecFile(process.execPath, [CLIENT, ...args], { cwd, env }, (error, stdout, stderr) =>\n+\t\t\tdone({ code: typeof error?.code === \"number\" ? error.code : 0, stdout, stderr }),\n+\t\t);\n+\t});\n+}\n+\n+describe(\"credentials only where asked\", () => {\n+\tit(\"a folder's key is the only credential it sends; an unreadable key file is an error\", () => {\n+\t\tconst server = \"http://127.0.0.1:1\";\n+\t\tasHome(homeWithToken(), () => {\n+\t\t\tconst keyed = folder(server, JSON.stringify({ server, key: KEY, id: \"k_0123abcd\" }));\n+\t\t\tassert.equal(tokenFor(server, {}, keyed), KEY);\n+\t\t\tassert.equal(tokenFor(server, {}, keyed, true), KEY, \"even with --token-file\");\n+\t\t\tassert.equal(tokenFor(server, { ABSO_TOKEN: \"env-token\" }, keyed), KEY, \"even with ABSO_TOKEN\");\n+\t\t\tassert.throws(() => tokenFor(server, {}, folder(server, \"not a key\")), /key file .* can't be read/);\n+\t\t\tconst keyless = folder(server);\n+\t\t\tassert.equal(tokenFor(server, {}, keyless), undefined, \"the token file is never read by itself\");\n+\t\t\tassert.equal(tokenFor(server, {}, keyless, true), TOKEN, \"with --token-file it is\");\n+\t\t\tassert.equal(tokenFor(server, { ABSO_TOKEN: \"env-token\" }, keyless), \"env-token\");\n+\t\t});\n+\t});\n+\n+\tit(\"a keyless folder: refused as signed out, naming --token-file; with --token-file it signs in\", async () => {\n+\t\tconst home = homeWithToken();\n+\t\tconst made = await client(\n+\t\t\thome,\n+\t\t\t(() => {\n+\t\t\t\tconst d = temp();\n+\t\t\t\twriteFileSync(join(d, \"a.txt\"), \"hi\\n\");\n+\t\t\t\treturn d;\n+\t\t\t})(),\n+\t\t\t\"init\",\n+\t\t\t\"--project\",\n+\t\t\t\"p\",\n+\t\t\t\"--agent\",\n+\t\t\t\"first\",\n+\t\t\t\"--token-file\",\n+\t\t\t\"--server\",\n+\t\t\tfake.url,\n+\t\t);\n+\t\tassert.equal(made.code, 0, made.stderr);\n+\t\tconst keyless = folder(fake.url);\n+\t\tconst unasked = await client(home, keyless, \"status\");\n+\t\tassert.notEqual(unasked.code, 0);\n+\t\tassert.match(\n+\t\t\tunasked.stderr,\n+\t\t\t/You're not signed in\\. Run abso login, then abso join <project>\\. ~\\/\\.abso\\/token is used only with --token-file\\./,\n+\t\t);\n+\t\tconst asked = await client(home, keyless, \"status\", \"--token-file\");\n+\t\tassert.equal(asked.code, 0, asked.stderr);\n+\t\tassert.match(asked.stdout, /Project p/);\n+\t});\n+\n+\tit(\"the admin token is read by admin commands alone, and they say when they use it\", () => {\n+\t\tassert.equal(adminTokenWords({ ABSO_ADMIN_TOKEN: \"x\" }), \"Using the admin token, from ABSO_ADMIN_TOKEN.\");\n+\t\tassert.equal(adminTokenWords({}), \"Using the admin token, from ~/.abso/admin-token.\");\n+\t\tconst src = resolve(import.meta.dirname, \"..\", \"src\");\n+\t\tconst readers: string[] = [];\n+\t\tconst users: string[] = [];\n+\t\tfor (const name of readdirSync(src).filter((n) => n.endsWith(\".ts\"))) {\n+\t\t\tconst text = readFileSync(join(src, name), \"utf8\");\n+\t\t\tif (/\"admin-token\"/.test(text)) readers.push(name);\n+\t\t\tif (/\\badminToken\\(/.test(text.replace(/export function adminToken\\(/, \"\"))) users.push(name);\n+\t\t}\n+\t\tassert.deepEqual(readers, [\"key-admin.ts\"], \"only key-admin.ts reads ~/.abso/admin-token\");\n+\t\tassert.deepEqual(users.sort(), [\"flag-commands.ts\", \"main.ts\"], \"abso flag and abso key, and nothing else\");\n+\t\tconst main = readFileSync(join(src, \"main.ts\"), \"utf8\");\n+\t\tassert.match(\n+\t\t\tmain,\n+\t\t\t/const admin = adminToken\\(env\\.env\\);\\s+\\(env\\.writeErr \\?\\? env\\.write\\)\\(`\\$\\{adminTokenWords/,\n+\t\t);\n+\t\tassert.match(\n+\t\t\treadFileSync(join(src, \"flag-commands.ts\"), \"utf8\"),\n+\t\t\t/if \\(admin\\)\\s+\\(env\\.writeErr \\?\\? env\\.write\\)\\(`\\$\\{adminTokenWords/,\n+\t\t);\n+\t});\n+});"}],"ci":null}