- --agent keeps 'here' as the default, as before 63, so scripts that join into a prepared folder still do. The ./<project> rule is only for a join with no --agent.
- A folder holding only abso's own state folder (.abso, or the older .avcs) counts as empty.
- New tests: joinFolder's rule (empty, only .abso, files here, --agent, --dir, a taken ./<project>), and a runJoin test that installs a key with --server and joins with --agent and no --dir: it joins here and sends that key (the shared token is wrong, so only the key gets through). The git line-endings test is back to joining without --dir.
- Issue numbers taken out of the new code comments and test names.
- MCP
- show on this site's /mcp
- CLI
- abso show 64 --json
- JSON
- /christopher/abso-core/versions/64?format=json
join: a folder prepared with abso key install --server is joined where it is again (Pinch's catch on 63).
of shared·trials··Not checked
Version 63 · Files at version 64
4 files, 60 lines added, 31 removed.
--- a/client/src/box.ts
+++ b/client/src/box.ts
@@ -277,13 +277,13 @@
279279
280−/** The agent name abso join takes when none is given (abso issue 351): the box's name, lower-cased. */
284284
286− * abso join with no --agent (abso issue 351): mints a key under `base`, else `base`-2, -3 and so on. Names this
287287 * box already holds in the project are skipped without asking, since minting one again would replace that agent's
288288 * key and cut off its folder. A name the server says is taken (409) moves on to the next; any other refusal, the
--- a/client/src/join-commands.ts
+++ b/client/src/join-commands.ts
@@ -18,10 +18,10 @@
1919import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from "./project-file.ts";
21−import { stateDir } from "./state-dir.ts";
2222
24− * The server to join or start on (abso issue 349): --server, then ABSO_SERVER, then the server this box is signed in
24+ * The server to join or start on: --server, then ABSO_SERVER, then the server this box is signed in
2525 * to (abso login wrote it), then https://api.abso.dev. A box signed in to more than one server has to say which.
@@ -106,13 +106,16 @@
107107
109− * Where abso join writes (abso issue 351): --dir, else here when this folder is empty, else ./<project>, which has
110− * to be new or empty so nobody's files are written over.
109+ * Where abso join writes: --dir, else here when --agent is given (as before, so a folder prepared with
110+ * abso key install --server is joined where its key is). With no --agent: here when this folder is empty, else
111+ * ./<project>, which has to be new or empty so nobody's files are written over. A folder holding only abso's own
112−function joinFolder(args: Parsed, env: Env, project: string): string {
115− const empty = (path: string) => readdirSync(path).length === 0;
118+ const empty = (path: string) => readdirSync(path).every((name) => name === STATE_DIR || name === OLD_STATE_DIR);
@@ -140,7 +143,7 @@
143− // abso issue 351: no --agent takes the box's name, or the next free -2, -3.
144147 if (!box) throw new UsageError("abso login signs this box in first (or give --agent <name>)");
145148 if (hasKey) throw new UsageError(`${root} already has a key: give its agent's name with --agent <name>`);
--- a/client/test/box.test.ts
+++ b/client/test/box.test.ts
@@ -284,7 +284,7 @@
286286
287−test("join and init pick the server: --server, ABSO_SERVER, the box's sign-in, then api.abso.dev (abso issue 349)", () => {
287+test("join and init pick the server: --server, ABSO_SERVER, the box's sign-in, then api.abso.dev", () => {
289289 const args = (server?: string) => ({ positionals: [], flags: new Map(server ? [["server", server]] : []) });
@@ -307,7 +307,7 @@
309309
310−test("join with no --agent takes the box's name, skips names this box holds, and moves past a taken one (abso issue 351)", async () => {
310+test("join with no --agent takes the box's name, skips names this box holds, and moves past a taken one", async () => {
--- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -23,7 +23,7 @@
26−import { dirname, join, relative, sep } from "node:path";
@@ -33,6 +33,7 @@
3535import { collisionText, parallelScript, runCommand, sameVersionHint, undoGitBashPaths } from "../src/commands.ts";
@@ -48,6 +49,7 @@
@@ -525,7 +527,7 @@
528− assert.equal((await avcs(bob, "join", name, "--agent", "bob", "--server", fake.url, "--dir", ".")).exit, 0);
@@ -2542,29 +2544,53 @@
25442546
2545− it("join writes here when this folder is empty, else into ./<project>, never over someone's files (abso issue 351)", async () => {
2546− const { name } = await project({ "a.ts": "one\n" }, "alice");
2547− const run = (cwd: string, agent: string) =>
2548− main(["join", name, "--agent", agent, "--server", fake.url], { cwd, env: ENV, write: () => {} });
2547+ it("join with no --agent writes here when this folder is empty, else into ./<project>, never over someone's files", () => {
2548+ const args = (...words: string[]) => parseArgs("join", ["p", ...words], { agent: "string", dir: "string" });
2550− const here = await run(empty, "bob");
2551− assert.equal(here.exit, 0, here.stderr);
2552− assert.equal(read(empty, "a.ts"), "one\n", "an empty folder: here");
2553− assert.doesNotMatch(here.stdout, /^cd /m);
2553+ assert.equal(joinFolder(args(), { cwd: prepared }, "p"), resolve(prepared), "only abso's own folder: still empty");
2556− const sub = await run(busy, "carol");
2557− assert.equal(sub.exit, 0, sub.stderr);
2558− assert.equal(read(join(busy, name), "a.ts"), "one\n", "a folder with files in it: ./<project>");
2559− assert.equal(read(busy, "notes.md"), "mine\n");
2560− assert.match(sub.stdout, new RegExp(`^cd ${name}$`, "m"));
2561− const taken = temp();
2562− write(taken, { "notes.md": "mine\n", [`${name}/other.md`]: "theirs\n" });
2563− const refused = await run(taken, "dave");
2564− assert.notEqual(refused.exit, 0);
2565− assert.match(refused.stderr, /already has files in it: say where to join with --dir <folder>/);
2556+ assert.equal(joinFolder(args(), { cwd: busy }, "p"), resolve(busy, "p"), "files here: ./<project>");
2557+ assert.equal(joinFolder(args("--agent", "bob"), { cwd: busy }, "p"), resolve(busy), "--agent: here, as before");
25672565
2566+ it("join --agent joins a folder prepared with abso key install --server where it is, and sends that key", async () => {
2573+ const init = await main(["init", "--server", keyed.url, "--project", "prep", "--agent", "alice"], {
2593+
25682594 it("gives a call more time by what it sends: 1 s per 100 KB over the base (abso issue 34)", () => {