{"draft":null,"from":63,"to":64,"files":[{"path":"client/src/join-commands.ts","added":10,"removed":7,"diff":"--- a/client/src/join-commands.ts\n+++ b/client/src/join-commands.ts\n@@ -18,10 +18,10 @@\n import { type FullMode, foldModes, writeKnownModes } from \"./modes.ts\";\n import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from \"./project-file.ts\";\n import { refusedText } from \"./safety.ts\";\n-import { stateDir } from \"./state-dir.ts\";\n+import { OLD_STATE_DIR, STATE_DIR, stateDir } from \"./state-dir.ts\";\n \n /**\n- * The server to join or start on (abso issue 349): --server, then ABSO_SERVER, then the server this box is signed in\n+ * The server to join or start on: --server, then ABSO_SERVER, then the server this box is signed in\n  * to (abso login wrote it), then https://api.abso.dev. A box signed in to more than one server has to say which.\n  */\n export function serverFrom(args: Parsed, env: Pick<Env, \"env\">, home?: string): string {\n@@ -106,13 +106,16 @@\n }\n \n /**\n- * Where abso join writes (abso issue 351): --dir, else here when this folder is empty, else ./<project>, which has\n- * to be new or empty so nobody's files are written over.\n+ * Where abso join writes: --dir, else here when --agent is given (as before, so a folder prepared with\n+ * abso key install --server is joined where its key is). With no --agent: here when this folder is empty, else\n+ * ./<project>, which has to be new or empty so nobody's files are written over. A folder holding only abso's own\n+ * state folder counts as empty.\n  */\n-function joinFolder(args: Parsed, env: Env, project: string): string {\n+export function joinFolder(args: Parsed, env: Pick<Env, \"cwd\">, project: string): string {\n \tconst dir = str(args, \"dir\");\n \tif (dir !== undefined) return resolve(env.cwd, dir);\n-\tconst empty = (path: string) => readdirSync(path).length === 0;\n+\tif (str(args, \"agent\") !== undefined) return resolve(env.cwd);\n+\tconst empty = (path: string) => readdirSync(path).every((name) => name === STATE_DIR || name === OLD_STATE_DIR);\n \tif (empty(env.cwd)) return resolve(env.cwd);\n \tconst sub = resolve(env.cwd, project);\n \tif (existsSync(sub) && (!statSync(sub).isDirectory() || !empty(sub)))\n@@ -140,7 +143,7 @@\n \t\tagent = agentFrom(args);\n \t\tminted = box && !hasKey ? await mintKey(box, project, agent) : undefined;\n \t} else {\n-\t\t// abso issue 351: no --agent takes the box's name, or the next free -2, -3.\n+\t\t// No --agent: the box's name, or the next free -2, -3.\n \t\tif (!box) throw new UsageError(\"abso login signs this box in first (or give --agent <name>)\");\n \t\tif (hasKey) throw new UsageError(`${root} already has a key: give its agent's name with --agent <name>`);\n \t\tconst free = await mintFreeName(box, project, defaultAgentName());"}],"unmatched":[]}