Versions 269 to 318
Lines 2–9 at 318 (were 2–9 at 269)
22
44import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
5−import { join, relative, resolve } from "node:path";
6−import { Api, ApiError } from "./api.ts";
Lines 16–24 at 318 (were 16–24 at 269)
19−import { CLIENT_DIR } from "./client-version.ts";
21−import { leftOutText, syncFolder, uploadBlobs } from "./commands.ts";
21+import { applyAnswer, leftOutText, pullAnswer, pullWritten, syncFolder, uploadBlobs } from "./commands.ts";
Lines 32–39 at 318 (were 32–38 at 269)
35−import { modInstalled } from "./install.ts";
3839import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from "./project-file.ts";
Lines 102–149 at 318 (were 101–106 at 269)
103104
106+ * --local (abso init, abso join): the project's history is in a store on this machine, not on a server. The store is
107+ * --store, else ABSO_STORE, else the OS's data folder; one given with --store is kept in the folder's config.
109+function localFrom(args: Parsed, env: Env, command: string): { dir: string; settings: { store?: string } } | undefined {
118+ if (str(args, "org") !== undefined || bool(args, "public") || bool(args, "private") || bool(args, "reader"))
120+ `abso ${command} --local takes --project, --agent, --store and --as-is; a local project has no server to share it`,
126+
127+/** A store inside the project folder is left out of its files: a line in .absoignore. Its relative path, if so. */
141+
144+ return `It's a local project: its history is in ${join(dir, project)}, on this machine, and no server is needed.${ignored === undefined ? "" : ` .absoignore leaves the store, ${ignored}, out of the project's files.`}`;
146+
106149
Lines 154–214 at 318 (were 111–152 at 269)
157+ // Checked before any call: a name like ".." would otherwise go out as part of the request's path.
160+ `project names are letters, digits, dot, dash and underscore (got ${JSON.stringify(project)})`,
114162 if (bool(args, "public") && bool(args, "private")) throw new UsageError("--public or --private, not both");
115164 // A box signed in here, and no other credential asked for: the project is made as the person who approved the box,
116165 // the way the website makes one (abso 663). The token file only with --token-file, never by itself.
117− const server = serverFrom(args, env);
118− const box = readBox(server);
119− const credential = tokenCredential(args, env.env, server, root);
126− if (credential === undefined && tokenFile() !== undefined)
128177 `abso init signs in with this box's sign-in, and this box isn't signed in to ${server}: abso login signs it in. ${TOKEN_FILE_ASKED}`,
132− const config = makeSettings(args, env, project);
182+ ? { server: LOCAL, project, agent: agentFrom(args, str(args, "agent") ?? defaultAgentName()), ...local.settings }
135186 const wroteIgnore = !asIs && !existsSync(absoignore) && !existsSync(join(root, ".avcsignore"));
188+ // A store kept inside the project folder, like a virtual environment, isn't the project's files.
137190 // What the server runs on each new version (#39), guessed from package.json; recorded with the rest.
141− say(`Signing in with ${credential?.words ?? `no credential: nothing here signs in to ${server}`}.
195+ say(`Signing in with ${credential?.words ?? `no credential: nothing here signs in to ${server}`}.
143− const api = new Api({ ...config, ...(token ? { token } : {}) });
144− await uploadBlobs(api, blobs);
145− const answer = await api.init(
146− Object.fromEntries(files),
147− modes,
148− Object.fromEntries([...blobs].map(([rel, b]) => [rel, b.sha])),
149− );
197+ const api = new Api({ ...config, ...(token ? { token } : {}), ...(local ? { localStore: local.dir } : {}) });
209+ if (typeof wroteProject !== "string") rmSync(join(root, projectFileName(root)), { force: true });
Lines 224–237 at 318 (were 162–173 at 269)
163225 ? ["Wrote a starting .absoignore (Claude Code state and operating system files); edit it like .gitignore."]
165− ...startingProjectFileText(wroteProject),
166229 ...(answer.skipped && answer.skipped.length > 0 ? [`The server skipped: ${answer.skipped.join(", ")}.`] : []),
170− hookHint(env.env),
Lines 242–248 at 318 (were 178–183 at 269)
Lines 416–431 at 318 (were 351–356 at 269)
353418
419+/** A join that failed before writing files: its state goes, but a key (already here, or made for it) stays for the next try. */
426+ for (const entry of readdirSync(dir)) if (entry !== "key") rmSync(join(dir, entry), { recursive: true, force: true });
428+
355430 if (args.positionals.length !== 1) throw new UsageError("join takes the project name: abso join <project>");
Lines 437–453 at 318 (were 362–375 at 269)
365− const server = serverFrom(args, env);
366− const box = readBox(server);
367− const hasKey = existsSync(join(stateDir(root), "key"));
368− const credential = tokenCredential(args, env.env, server, root);
440+ // A local project: no box, key or credential, and the agent is --agent or this computer's name.
372− if (str(args, "agent") !== undefined) {
Lines 472–511 at 318 (were 394–423 at 269)
397− const config = { server, project, agent, ...(reader ? { reader: true } : {}) };
475+ const config = { server, project, agent, ...(reader ? { reader: true } : {}), ...local?.settings };
402− const read = readConfig(root, env.env, false);
404− (env.writeErr ?? env.write)(
405− `Signing in with ${minted && box ? `a new key from this box's sign-in, ${box.id}` : hasKey ? "this folder's key" : (credential?.words ?? `no credential: nothing here signs in to ${server}`)}.
490+ `Signing in with ${minted && box ? `a new key from this box's sign-in, ${box.id}` : hasKey ? "this folder's key" : (credential?.words ?? `no credential: nothing here signs in to ${server}`)}.
407− );
409− let synced: Awaited<ReturnType<typeof syncFolder>>;
413498 // Every file, even when the server has seen this agent sync before: its plain sync answer would hold only what changed since (#37).
414− synced = await syncFolder(root, api, true);
416503 if (!(error instanceof ApiError && error.status === 401 && !box && !settings.token)) throw error;
417− rmSync(stateDir(root), { recursive: true, force: true });
419505 throw new UsageError(!tokenFileAsked && tokenFile() !== undefined ? `${why} ${TOKEN_FILE_ASKED}` : why);
423511 `Joined ${project} as ${config.agent} at version ${synced.version}: wrote ${plural(synced.written.length, "file")} into ${root}.${reader ? " It is a reader: status, pull, log, show, files and export work, and nothing it does is recorded or pushed." : ""}${minted ? ` It signs in with its own key, ${minted.id}, made from this box's sign-in.` : ""}`,
Lines 515–524 at 318 (were 427–435 at 269)
427515 `These files were already here and differ from shared, so they were left alone: ${synced.kept.join(", ")}. abso record sends them as your changes.`,
432− hookHint(env.env),
Lines 542–559 at 318 (were 453–460 at 269)
453542 : [`Nothing is installed yet. Before building or testing here, run ${projectFileName(root)}'s setup: ${setup}`];
455544
456−function hookHint(env: Readonly<Record<string, string | undefined>>): string {
457− return modInstalled(env)
458− ? "Edits made by Claude Code here are recorded by the abso mod on this machine, signed in as this folder. Anything else: abso record."
459− : `Edits made by Claude Code reach the server through the abso mod, which isn't on this machine yet: node ${join(CLIENT_DIR, "install-mod.ts")} installs it, and new chats load it. Anything else: abso record.`;
546+ // A local project has no server: the mod hands its edits to abso hook, when it was installed with one to hand them to.
549+ return "Edits made by Claude Code here are recorded by the abso mod on this machine, through abso hook. Anything else: abso record.";
551+ return `abso record sends the edits made here: the abso mod on this machine is older than local projects. ${installerCommand("install-mod.ts")} updates it, and new chats load it.`;
555+ return "Edits made by Claude Code here are recorded by the abso mod on this machine, signed in as this folder. Anything else: abso record.";
558+ return `Edits made by Claude Code reach the server through the abso mod, which isn't on this machine yet: ${installerCommand("install-mod.ts")} installs it, and new chats load it. Anything else: abso record.`;
- MCP
- compare on this site's /mcp
- CLI
- abso diff 269 318 client/src/join-commands.ts --json
- JSON
- /christopher/abso-core/compare/269..318?file=client%2Fsrc%2Fjoin-commands.ts&format=json