{"draft":null,"from":154,"to":155,"files":[{"path":"client/src/main.ts","added":50,"removed":17,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -49,6 +49,7 @@\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 { 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@@ -93,7 +94,7 @@\n const COMMANDS: Readonly<Record<string, CommandDef>> = {\n \tinit: {\n \t\tflags: { server: \"string\", project: \"string\", agent: \"string\", \"as-is\": \"boolean\", org: \"string\" },\n-\t\tusage: \"abso init [folder] [--server <url>] --project <name> --agent <name> [--as-is] [--org <org>]\",\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\trun: (args, env) => {\n@@ -183,7 +184,7 @@\n \t\t\tdays: \"string\",\n \t\t},\n \t\tusage:\n-\t\t\t\"abso login [--server <url>] [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--max-agents <1-50>] [--days <1-90>]\",\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\trun: async (args, env) => {\n@@ -205,7 +206,7 @@\n \t},\n \tbox: {\n \t\tflags: { server: \"string\" },\n-\t\tusage: \"abso box [--server <url>]\",\n+\t\tusage: \"abso box\",\n \t\tabout:\n \t\t\t\"What this box's sign-in allows: its projects, the highest role its agents may have, how many agents it has made and may make, and when it expires. Never the credential.\",\n \t\trun: async (args, env) => {\n@@ -216,7 +217,7 @@\n \t},\n \twhoami: {\n \t\tflags: { server: \"string\" },\n-\t\tusage: \"abso whoami [--server <url>]\",\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\trun: async (args, env) => {\n@@ -226,18 +227,24 @@\n \t},\n \tdoctor: {\n \t\tflags: { server: \"string\" },\n-\t\tusage: \"abso doctor [--server <url>]\",\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\trun: async (args, env) => {\n-\t\t\tconst checks = await doctor(checkServer(str(args, \"server\"), env.cwd, env.env), env.cwd, env.env, realProbe());\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 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+\t\tusage: \"abso logout\",\n \t\tabout:\n \t\t\t\"End this box's sign-in on the server and forget it here. Keys its agents already have stop working with it.\",\n \t\trun: async (args, env) => {\n@@ -255,7 +262,7 @@\n \t},\n \torgs: {\n \t\tflags: { server: \"string\" },\n-\t\tusage: \"abso orgs [--server <url>]\",\n+\t\tusage: \"abso orgs\",\n \t\tabout:\n \t\t\t\"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).\",\n \t\trun: (args, env) => runOrgs(boxServer(args, env)),\n@@ -299,7 +306,7 @@\n \t},\n \tjoin: {\n \t\tflags: { server: \"string\", agent: \"string\", dir: \"string\", reader: \"boolean\" },\n-\t\tusage: \"abso join <project> [--agent <name>] [--dir <folder>] [--server <url>] [--reader]\",\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\trun: runJoin,\n@@ -803,12 +810,21 @@\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). 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 \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 {\n+\treturn serverUse(name) === \"local\" ? def.flags : { ...def.flags, server: \"string\" };\n+}\n+\n /** Every command as help shows it, in order: the table's, then the three it doesn't hold. */\n-function helpEntries(): { name: string; usage: string; about: string; flags: FlagSpec }[] {\n+function helpEntries(): { name: string; usage: string; about: string; flags: FlagSpec; server?: string }[] {\n \treturn [\n-\t\t...Object.entries(COMMANDS).map(([name, c]) => ({ name, usage: c.usage, about: c.about, flags: c.flags })),\n+\t\t...Object.entries(COMMANDS).map(([name, c]) => {\n+\t\t\tconst server = serverHelp(name);\n+\t\t\treturn { name, usage: c.usage, about: c.about, flags: flagsOf(name, c), ...(server ? { server } : {}) };\n+\t\t}),\n \t\t{\n \t\t\tname: \"hook\",\n \t\t\tusage: \"abso hook\",\n@@ -832,7 +848,11 @@\n }\n \n function help(): string {\n-\tconst entries = helpEntries().flatMap((c) => [`  ${c.usage}`, `      ${c.about}`]);\n+\tconst entries = helpEntries().flatMap((c) => [\n+\t\t`  ${c.usage}`,\n+\t\t`      ${c.about}`,\n+\t\t...(c.server ? [`      ${c.server}`] : []),\n+\t]);\n \treturn [HELP_INTRO, \"\", ...entries, \"\", HELP_NOTE].join(\"\\n\");\n }\n \n@@ -864,7 +884,7 @@\n export function commandTable(): Readonly<\n \tRecord<string, { readonly flags: FlagSpec; readonly usage: string; readonly about: string }>\n > {\n-\treturn COMMANDS;\n+\treturn Object.fromEntries(Object.entries(COMMANDS).map(([name, c]) => [name, { ...c, flags: flagsOf(name, c) }]));\n }\n \n function newsBlock(news: readonly string[]): string[] {\n@@ -932,21 +952,34 @@\n \t\t\t);\n \t\tconst gitOnly = gitOnlyForm(command, argv.slice(1));\n \t\tif (gitOnly) throw new UsageError(gitOnly);\n-\t\tconst parsed = parseArgs(command, argv.slice(1), withBodyFiles(command, def.flags), def.rest);\n+\t\tconst use = serverUse(command);\n+\t\tconst words = argv.includes(\"--\") ? argv.slice(1, argv.indexOf(\"--\")) : argv.slice(1);\n+\t\tif (use === \"local\" && words.some((w) => w === \"--server\" || w.startsWith(\"--server=\")))\n+\t\t\tthrow new UsageError(localRefusal(command));\n+\t\tconst parsed = parseArgs(command, argv.slice(1), withBodyFiles(command, flagsOf(command, def)), def.rest);\n \t\tif ((command === \"push\" || command === \"pull\") && parsed.positionals.length > 0)\n \t\t\tthrow new UsageError(\n \t\t\t\t`abso ${command} takes no remote or branch: it ${command === \"push\" ? \"adds your draft to shared\" : \"brings shared into this folder\"}. A named draft is abso switch <name>.`,\n \t\t\t);\n \t\tif (bool(parsed, \"help\")) {\n \t\t\tconst files = bodyFilesHelp(command, def.flags);\n-\t\t\treturn { stdout: `${def.usage}\\n  ${def.about}\\n${files ? `  ${files}\\n` : \"\"}`, stderr: \"\", exit: EXIT.ok };\n+\t\t\tconst server = serverHelp(command);\n+\t\t\treturn {\n+\t\t\t\tstdout: `${def.usage}\\n  ${def.about}\\n${server ? `  ${server}\\n` : \"\"}${files ? `  ${files}\\n` : \"\"}`,\n+\t\t\t\tstderr: \"\",\n+\t\t\t\texit: EXIT.ok,\n+\t\t\t};\n \t\t}\n+\t\t// --server is checked before anything is read or sent: a bad value, or (for a command on a joined folder)\n+\t\t// a server that isn't the folder's own, is refused here.\n+\t\tconst named = use === \"local\" ? undefined : serverFlag(parsed);\n+\t\tif (named !== undefined && use === \"folder\") checkFolderServer(command, named, env.cwd);\n \t\t// A folder that reads signed out runs its reads and nothing else, refused before any call.\n \t\tconst root = findRoot(env.cwd);\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, env);\n+\t\tconst out = await def.run(args, named === undefined ? env : { ...env, server: named });\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();"}],"unmatched":[]}