{"draft":null,"from":75,"to":76,"files":[{"path":"client/src/main.ts","added":36,"removed":1,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -38,6 +38,7 @@\n } from \"./commands.ts\";\n import { configPath, findRoot, installKey, readConfig, readToken } from \"./config.ts\";\n import { newsBlockLines, newsShown, TOKEN_SERVERS } 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@@ -202,6 +203,27 @@\n \t\t\treturn { text: boxText(record, server), json: { box: boxPublic(record) } };\n \t\t},\n \t},\n+\twhoami: {\n+\t\tflags: { server: \"string\" },\n+\t\tusage: \"abso whoami [--server <url>]\",\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.\",\n+\t\trun: async (args, env) => {\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+\tdoctor: {\n+\t\tflags: { server: \"string\" },\n+\t\tusage: \"abso doctor [--server <url>]\",\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.\",\n+\t\trun: async (args, env) => {\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+\t},\n \tlogout: {\n \t\tflags: { server: \"string\" },\n \t\tusage: \"abso logout [--server <url>]\",\n@@ -803,6 +825,16 @@\n \treturn newsBlockLines(news.map((n) => newsShown(n)));\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+\ttry {\n+\t\tconst root = findRoot(env.cwd);\n+\t\treturn root ? readConfig(root, env.env).token !== undefined : readToken(env.env) !== undefined;\n+\t} catch {\n+\t\treturn false;\n+\t}\n+}\n+\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@@ -865,7 +897,10 @@\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\terr instanceof UsageError || err instanceof ApiError ? e.message : `${e.message}${e.stack ? `\\n${e.stack}` : \"\"}`;\n+\t\t\tplainError(err, carriesCredential(env)) ??\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}` : \"\"}`);\n \t\t// The server refusing (409) is like a collision: exit 2, not a failure.\n \t\tconst exit = err instanceof ApiError && err.status === 409 ? EXIT.refused : EXIT.error;\n \t\t// News taken before the failure still shows."}],"unmatched":[]}