Versions 68 to 318
Lines 1–55 at 318 (were 1–42 at 68)
22
3−import { existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
4−import { join, relative, resolve } from "node:path";
5−import { Api, ApiError } from "./api.ts";
4+import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
8−import { defaultAgentName, mintFreeName, mintKey, readBox, signedInServers } from "./box.ts";
10−import { CLIENT_DIR } from "./client-version.ts";
12−import { leftOutText, syncFolder, uploadBlobs } from "./commands.ts";
13−import { findRoot, installKey, readConfig, type Settings, tokenFor, writeConfig } from "./config.ts";
14−import { TOKEN_SERVERS } from "./core.ts";
21+import { applyAnswer, leftOutText, pullAnswer, pullWritten, syncFolder, uploadBlobs } from "./commands.ts";
17−import { modInstalled } from "./install.ts";
1939import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from "./project-file.ts";
2243
23−/**
24− * The server to join or start on: --server, then ABSO_SERVER, then the server this box is signed in
25− * to (abso login wrote it), then https://api.abso.dev. A box signed in to more than one server has to say which.
26− */
27−export function serverFrom(args: Parsed, env: Pick<Env, "env">, home?: string): string {
28− const named = str(args, "server") ?? fromEnv(env.env, "SERVER");
29− if (named) return named;
30− const signedIn = signedInServers(home);
31− if (signedIn.length > 1)
32− throw new UsageError(`this box is signed in to ${signedIn.join(" and ")}: say which with --server <url>`);
33− return signedIn[0] ?? TOKEN_SERVERS[0]!;
44+/** The server to join or start on, in the order every command picks one (server-choice.ts chooseServer). */
3548
3750
38−function agentFrom(args: Parsed): string {
39− const agent = str(args, "agent");
4255 throw new UsageError(`agent names are letters, digits, dot, dash and underscore (got ${JSON.stringify(agent)})`);
Lines 60–152 at 318 (were 47–52 at 68)
4962
64+ * A new project has nothing in it yet: say what comes next, since the join itself wrote nothing. Not for a reader, which
67+export function emptyHint(version: number, written: number, kept: number, reader: boolean): string[] {
69+ return ['The project is empty. Put its files in this folder, then abso push -m "why" publishes them.'];
71+
72+/** A credential other than the box's, and how init and join name it when they say what they sign in with. */
77+
79+ * What init and join sign in with when it isn't the box's sign-in. The machine's token file only with --token-file, and
80+ * never into a folder that already has a key; else a token the environment names (ABSO_TOKEN, or a pipeline run's
81+ * ABSO_KEY_FILE); else none. The token file is never read unasked, so a project is never made or joined with a shared
93+ throw new UsageError(`${root} already has a key, so it signs in with that: leave off --token-file`);
95+ if (!token) throw new UsageError("--token-file reads ~/.abso/token, and this machine has none");
101+ if (run) return { token: trustedToken(server, env, run), words: "a pipeline run's key (ABSO_KEY_FILE)" };
104+
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+
149+
Lines 154–214 at 318 (were 54–75 at 68)
57− const config = makeSettings(args, env, project);
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)})`,
162+ if (bool(args, "public") && bool(args, "private")) throw new UsageError("--public or --private, not both");
164+ // A box signed in here, and no other credential asked for: the project is made as the person who approved the box,
165+ // the way the website makes one (abso 663). The token file only with --token-file, never by itself.
177+ `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}`,
182+ ? { server: LOCAL, project, agent: agentFrom(args, str(args, "agent") ?? defaultAgentName()), ...local.settings }
60186 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.
62190 // What the server runs on each new version (#39), guessed from package.json; recorded with the rest.
65− const token = tokenFor(config.server, env.env);
66− const api = new Api({ ...config, ...(token ? { token } : {}) });
67− await uploadBlobs(api, blobs);
68− const answer = await api.init(
69− Object.fromEntries(files),
70− modes,
71− Object.fromEntries([...blobs].map(([rel, b]) => [rel, b.sha])),
72− );
195+ say(`Signing in with ${credential?.words ?? `no credential: nothing here signs in to ${server}`}.
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 85–96 at 68)
86225 ? ["Wrote a starting .absoignore (Claude Code state and operating system files); edit it like .gitignore."]
88− ...startingProjectFileText(wroteProject),
89229 ...(answer.skipped && answer.skipped.length > 0 ? [`The server skipped: ${answer.skipped.join(", ")}.`] : []),
93− hookHint(env.env),
Lines 242–353 at 318 (were 101–111 at 68)
107249
250+/** The most a new project's folder may be from a box: the server takes a body up to 25 MB, base64 and JSON included. */
252+/** The Idempotency-Key of an abso init that didn't finish, so running it again makes the same project (abso 663). */
254+
256+ * abso init from a signed-in box (abso 663): the server makes the project as the person who approved the box, the way the
257+ * website's New project does (owner, visibility, address), with the folder as its first version. This folder then
258+ * joins it like abso join, with its own key from the box, so it works at once with no new approval.
270+ `project names are letters, digits, dot, dash and underscore (got ${JSON.stringify(project)})`,
276+ const wroteIgnore = !asIs && !existsSync(absoignore) && !existsSync(join(root, ".avcsignore"));
297+ `${root} is over 24 MB to send. Make ${project} with abso init on a smaller folder (or on the website), then copy the rest in and push.`,
299+ // One key per folder until it finishes: running the same abso init again is the same project, never a second.
322+ `Created project ${project} (${visibility}, owned by ${owner}) at version ${synced.version} from ${plural(listed.length, "file")} in ${root}.`,
325+ ? ["Wrote a starting .absoignore (Claude Code state and operating system files); edit it like .gitignore."]
328+ `This folder is agent ${minted.agent}, with its own key, ${minted.id}, made from this box's sign-in. Settings are in .abso/config.json.`,
330+ ...(synced.written.length > 0 ? [`Wrote ${plural(synced.written.length, "file")} from shared.`] : []),
349+
109351 * Where abso join writes: --dir, else here when --agent is given (as before, so a folder prepared with
110352 * abso key install --server is joined where its key is). With no --agent: here when this folder is empty, else
111353 * ./<project>, which has to be new or empty so nobody's files are written over. A folder holding only abso's own
Lines 365–431 at 318 (were 123–128 at 68)
125367
368+/** Signed out, the server doesn't say who owns a project, and the website puts every project under this one owner for now. */
370+
372+ * Whether anyone can read the project: its status answers with no credentials. Only the answer's code
373+ * counts, never its body, and no redirect is followed. A private project and a missing one look the same.
386+
388+ * Why a join failed signed out. Without --reader, the client reads only as an agent, which needs a
393+ ? `${project} is public: read it at ${siteOf(server)}/${SITE_OWNER}/${project} (every page is also JSON), or here with abso join ${project} --reader. To work on it: abso login.`
394+ : `This box isn't signed in to ${server}. abso login signs it in.${elsewhereText(server, `abso join ${project}`)}`;
396+
398+async function joinAsVisitor(root: string, server: string, project: string, env: Env): Promise<Output> {
410+ `Joined ${project} to read it signed out, at version ${version}, in ${root}. Nothing is sent with a sign-in, and nothing here is recorded.`,
411+ `This folder holds no copy of the files: abso files lists them, abso show ${version}:<file> prints one, and status, log, blame, why, where, issues, issue and search read the rest.`,
418+
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+
127430 if (args.positionals.length !== 1) throw new UsageError("join takes the project name: abso join <project>");
Lines 437–524 at 318 (were 134–183 at 68)
137− const server = serverFrom(args, env);
138− const box = readBox(server);
139− const hasKey = existsSync(join(stateDir(root), "key"));
440+ // A local project: no box, key or credential, and the agent is --agent or this computer's name.
142− if (str(args, "agent") !== undefined) {
144− minted = box && !hasKey ? await mintKey(box, project, agent) : undefined;
457+ // A pipeline run's key (ABSO_KEY_FILE) belongs to one agent, which the runner names in ABSO_AGENT.
460+ throw new UsageError("a pipeline run's key joins as its own agent: give it with --agent <name> or ABSO_AGENT");
146− // No --agent: the box's name, or the next free -2, -3.
147− if (!box) throw new UsageError("abso login signs this box in first (or give --agent <name>)");
463+ // No --agent: the box's name, or the next free -2, -3. Not signed in, --reader reads a public project signed out.
468+ `${await signedOut(server, project)} (A folder that already has a key joins with --agent <name>.)`,
148470 if (hasKey) throw new UsageError(`${root} already has a key: give its agent's name with --agent <name>`);
153− const config = { server, project, agent, ...(reader ? { reader: true } : {}) };
475+ const config = { server, project, agent, ...(reader ? { reader: true } : {}), ...local?.settings };
157− const settings = readConfig(root, env.env);
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}`)}.
159− let synced: Awaited<ReturnType<typeof syncFolder>>;
163498 // Every file, even when the server has seen this agent sync before: its plain sync answer would hold only what changed since (#37).
164− synced = await syncFolder(root, api, true);
166503 if (!(error instanceof ApiError && error.status === 401 && !box && !settings.token)) throw error;
167− rmSync(stateDir(root), { recursive: true, force: true });
168− throw new UsageError(`This box isn't signed in to ${config.server}. abso login signs it in.`);
505+ throw new UsageError(!tokenFileAsked && tokenFile() !== undefined ? `${why} ${TOKEN_FILE_ASKED}` : why);
172− `Joined ${project} as ${config.agent} at version ${synced.version}: wrote ${plural(synced.written.length, "file")} into ${root}.${reader ? " It is a reader: status, sync, log, show, files and export work, and nothing it does is recorded or published." : ""}${minted ? ` It signs in with its own key, ${minted.id}, made from this box's sign-in.` : ""}`,
511+ `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.` : ""}`,
176515 `These files were already here and differ from shared, so they were left alone: ${synced.kept.join(", ")}. abso record sends them as your changes.`,
180− hookHint(env.env),
Lines 542–559 at 318 (were 201–208 at 68)
201542 : [`Nothing is installed yet. Before building or testing here, run ${projectFileName(root)}'s setup: ${setup}`];
203544
204−function hookHint(env: Readonly<Record<string, string | undefined>>): string {
205− return modInstalled(env)
206− ? "Edits made by Claude Code here are recorded by the abso mod on this machine, signed in as this folder. Anything else: abso record."
207− : `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 68 318 client/src/join-commands.ts --json
- JSON
- /christopher/abso-core/compare/68..318?file=client%2Fsrc%2Fjoin-commands.ts&format=json