- MCP
- show on this site's /mcp
- CLI
- abso show 155 --json
- JSON
- /christopher/abso-core/versions/155?format=json
Every command that talks to a server now takes --server <url>, parsed and checked in one place (client/src/server-choice.ts). A missing, empty or malformed value is refused before anything is sent. In a joined folder, --server must be the folder's own server: another one is refused rather than swapped in, so a folder's work and key go only to the server it was joined on. Commands that pick their own server (join, init, login, whoami, doctor, box, logout, orgs, org, key) use the named one as given; doctor no longer swaps in the folder's server over an explicit one, and an explicit --server takes issues to that server's own Issues Worker instead of ABSO_ISSUES_SERVER. The five local-only commands refuse --server and say why. Help shows the same --server line for every command of a kind. For abso-core issue 10.
of shared·speed··Not checked
Version 154 · Files at version 155
7 files, 393 lines added, 22 removed.
--- a/client/src/command-env.ts
+++ b/client/src/command-env.ts
@@ -25,6 +25,11 @@
29+ * The server --server named, checked (server-choice.ts), when the command was given one. It is used as given,
2934
--- a/client/src/doctor.ts
+++ b/client/src/doctor.ts
@@ -155,6 +155,7 @@
@@ -170,8 +171,8 @@
171172
173− // The folder's own server when there is one: it's the one its commands talk to.
174− const target = folder?.config?.server ?? server;
174+ // The folder's own server when there is one (it's the one its commands talk to), unless --server named one.
--- a/client/src/issues.ts
+++ b/client/src/issues.ts
@@ -36,7 +36,10 @@
3636/** The folder, with its Api pointed at the Issues Worker: the token goes only where tokenGoesTo allows, as for the avcs server. */
39− const server = fromEnv(env.env, "ISSUES_SERVER") || issuesServerFor(config.server, readMachineServers(env.env));
39+ // An explicit --server goes to that server's own Issues Worker: ABSO_ISSUES_SERVER doesn't redirect it.
4245 `${config.server} has no Issues Worker beside it that abso knows; ~/.abso/servers.json or ABSO_ISSUES_SERVER names one`,
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -49,6 +49,7 @@
52+import { checkFolderServer, localRefusal, serverFlag, serverHelp, serverUse } from "./server-choice.ts";
@@ -93,7 +94,7 @@
9596 flags: { server: "string", project: "string", agent: "string", "as-is": "boolean", org: "string" },
96− usage: "abso init [folder] [--server <url>] --project <name> --agent <name> [--as-is] [--org <org>]",
9899 "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.",
@@ -183,7 +184,7 @@
186− "abso login [--server <url>] [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--max-agents <1-50>] [--days <1-90>]",
187+ "abso login [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--max-agents <1-50>] [--days <1-90>]",
188189 "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.",
@@ -205,7 +206,7 @@
208− usage: "abso box [--server <url>]",
210211 "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.",
@@ -216,7 +217,7 @@
219− usage: "abso whoami [--server <url>]",
221222 "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,18 +227,24 @@
229− usage: "abso doctor [--server <url>]",
231232 "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.",
233− const checks = await doctor(checkServer(str(args, "server"), env.cwd, env.env), env.cwd, env.env, realProbe());
235242 return { text: doctorText(checks), json: { checks }, ...(failed ? { exit: EXIT.error } : {}) };
240− usage: "abso logout [--server <url>]",
242249 "End this box's sign-in on the server and forget it here. Keys its agents already have stop working with it.",
@@ -255,7 +262,7 @@
258− usage: "abso orgs [--server <url>]",
260267 "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).",
@@ -299,7 +306,7 @@
302− usage: "abso join <project> [--agent <name>] [--dir <folder>] [--server <url>] [--reader]",
304311 "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.",
@@ -803,12 +810,21 @@
803810
806− "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).";
813+ "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.";
807815
816+/** A command's flags: its own, and --server for every command that talks to a server (server-choice.ts). */
820+
809−function helpEntries(): { name: string; usage: string; about: string; flags: FlagSpec }[] {
822+function helpEntries(): { name: string; usage: string; about: string; flags: FlagSpec; server?: string }[] {
811− ...Object.entries(COMMANDS).map(([name, c]) => ({ name, usage: c.usage, about: c.about, flags: c.flags })),
826+ return { name, usage: c.usage, about: c.about, flags: flagsOf(name, c), ...(server ? { server } : {}) };
@@ -832,7 +848,11 @@
833849
835− const entries = helpEntries().flatMap((c) => [` ${c.usage}`, ` ${c.about}`]);
838858
@@ -864,7 +884,7 @@
867− return COMMANDS;
887+ return Object.fromEntries(Object.entries(COMMANDS).map(([name, c]) => [name, { ...c, flags: flagsOf(name, c) }]));
869889
@@ -932,21 +952,34 @@
935− const parsed = parseArgs(command, argv.slice(1), withBodyFiles(command, def.flags), def.rest);
959+ const parsed = parseArgs(command, argv.slice(1), withBodyFiles(command, flagsOf(command, def)), def.rest);
938962 `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>.`,
942− return { stdout: `${def.usage}\n ${def.about}\n${files ? ` ${files}\n` : ""}`, stderr: "", exit: EXIT.ok };
968+ stdout: `${def.usage}\n ${def.about}\n${server ? ` ${server}\n` : ""}${files ? ` ${files}\n` : ""}`,
973+ // --server is checked before anything is read or sent: a bad value, or (for a command on a joined folder)
946979 if (root !== undefined && isVisitor(root)) checkVisitor(command, parsed, readConfig(root, env.env).project);
949− const out = await def.run(args, env);
--- /dev/null
+++ b/client/src/server-choice.ts
@@ -0,0 +1,111 @@
1+// The --server flag (abso-core issue 10). Every command that talks to a server takes --server <url>, parsed and
3+// - A command that works on a joined folder ("folder") talks only to that folder's server. --server there must
4+// name that same server; another one is refused, never swapped in, so the folder's work and key never go to
5+// a server it wasn't joined on. Outside a joined folder it is refused too, with how to join one there.
6+// - A command that picks a server for itself ("chosen": join, init, login, whoami and the rest about this box)
9+// A value that isn't an http or https URL (a user name, a query or a fragment included) is refused before any
11+
16+
19+
33+
35+const LOCAL: ReadonlySet<string> = new Set(["skill", "check-ignore", "pause", "resume", "fix-eol"]);
36+
41+
43+
50+ `${from} takes an http or https URL with no user name, query or fragment, like ${EXAMPLE} (got ${JSON.stringify(value)})`,
54+
60+
61+/** Whether two servers are the same one: the same scheme, host, port and path, ignoring case and a trailing slash. */
65+
66+/** The server in the .abso/config.json of the folder `cwd` is in, or undefined outside one (or when it can't be read). */
71+ const server = (JSON.parse(readFileSync(configPath(root), "utf8")) as { server?: unknown }).server;
77+
79+ * For a command that works on a joined folder: refuses a --server that isn't the folder's own server, and one
86+ `abso ${command} works on a joined folder, and ${cwd} isn't in one. To work with ${flag}: abso join <project> --server ${flag}, or abso init --server ${flag} for a new project.`,
90+ `this folder is joined on ${own}, not ${flag}, so abso ${command} won't send its work or key there. Run it in a folder joined on ${flag} (abso join <project> --server ${flag}).`,
93+
100+ return "--server <url>: this folder's own server, which it uses anyway. Another server is refused, never swapped in, so the folder's work and key go only to the server it was joined on.";
103+ ? "--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.";
107+
110+ return `abso ${command} works on this machine only and talks to no server, so it takes no --server`;
--- a/client/src/visitor.ts
+++ b/client/src/visitor.ts
@@ -23,8 +23,8 @@
2525
26−/** Flags every command takes. */
27−const EVERY = new Set(["json", "help"]);
26+/** Flags every command takes (--server is checked against the folder's own server before this, in main.ts). */
2828
3030 return `This folder reads ${project} signed out. To work on it: abso login, then abso join ${project} in a new folder.`;
--- /dev/null
+++ b/client/test/server-flag.test.ts
@@ -0,0 +1,218 @@
2+// - every command is sorted: one that works on this machine only takes no --server and says so; every other one
4+// - a missing, empty or malformed value is refused before anything is sent, for every family of command;
5+// - in a joined folder, --server naming the folder's own server reaches it; another server is refused, never
6+// swapped in, and nothing is sent; outside a joined folder a folder command with --server is refused too;
7+// - 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.
9+
20+
23+
29+
30+/** A server that notes each path it is asked for and answers 500, so a command stops after its first call. */
41+
48+
53+
62+
67+
73+
76+
80+
84+
86+ it("sorts every command: local ones take no --server, every other one does, and help says so alike", async () => {
98+ assert.ok(help.stdout.includes(` ${serverHelp(name)}\n`), `abso ${name} --help names --server`);
103+ for (const c of data.commands.filter((c) => c.name in table)) assert.equal(c.server, serverHelp(c.name), c.name);
107+
116+ assert.match(r.stderr, /works on this machine only and talks to no server, so it takes no --server/);
121+
122+ it("refuses a missing, empty or malformed value before anything is sent, in every family", async () => {
142+ assert.match(empty.stderr, /--server needs a server's URL, like https:\/\/api\.abso\.dev/, argv.join(" "));
143+ for (const bad of ["api.abso.dev", "ftp://api.abso.dev", "https://me@api.abso.dev", "https://x.example/?a=1"]) {
146+ assert.match(r.stderr, /--server takes an http or https URL with no user name, query or fragment/);
151+
152+ it("in a joined folder, reaches the folder's own server and refuses another without sending anything", async () => {
154+ for (const argv of [["status"], ["log"], ["issues"], ["issue", "1"], ["news"], ["waiting"], ["ci"]]) {
156+ const same = await run(root, [...argv, "--server", `${home.url.toUpperCase().replace("HTTP", "http")}/`]);
166+ `this folder is joined on ${home.url}, not ${other.url}, so abso ${argv[0]} won't send its work or key there`,
172+
173+ it("outside a joined folder, a folder command with --server says how to join one there", async () => {
175+ for (const argv of [["status"], ["issue", "new", "A title"], ["ask", "bob", "Why?"], ["news"]]) {
182+
183+ it("an explicit --server takes issues to that server's own Issues Worker, past ABSO_ISSUES_SERVER", async () => {
188+ assert.ok(issuesElsewhere.paths.length > 0, "without --server, ABSO_ISSUES_SERVER names the Issues Worker");
199+
200+ it("a command that picks its server uses the one named, even in a folder on another", async () => {
209+ assert.equal(other.paths.filter((p) => p === "/version").length, 0, "doctor didn't swap in the folder's server");
211+
212+ it("counts two spellings of one server as the same, and different ports or paths as different", () => {