Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 85 to 86

Compare

+46 −11 in 2 places
Lines 128–181 at 86 (were 128–148 at 85)
128128const SITE_OWNER = "christopher";
129129
130130/**
131− * Why a join failed signed out. The client reads only as an agent, which needs a
132− * sign-in; a public project is read signed out on the website. Whether the
133− * project is public is asked of the server with no credentials.
131+ * Whether anyone can read the project: its status answers with no credentials. Only the answer's code
132+ * counts, never its body, and no redirect is followed. A private project and a missing one look the same.
134133 */
135−async function signedOut(server: string, project: string): Promise<string> {
136− let open = false;
134+export async function isPublic(server: string, project: string): Promise<boolean> {
137135 try {
138− const response = await fetch(new URL(`/p/${project}/status`, server), { signal: AbortSignal.timeout(3000) });
139− open = response.ok;
140− } catch {}
141− return open
142− ? `${project} is public: read it at ${siteOf(server)}/${SITE_OWNER}/${project} (every page is also JSON). The client needs a sign-in, even to read: abso login.`
136+ const response = await fetch(new URL(`/p/${encodeURIComponent(project)}/status`, server), {
137+ redirect: "error",
138+ credentials: "omit",
139+ signal: AbortSignal.timeout(3000),
140+ });
141+ return response.status === 200;
142+ } catch {
143+ return false;
144+ }
145+}
147+/**
148+ * Why a join failed signed out. Without --reader, the client reads only as an agent, which needs a
149+ * sign-in; a public project is read signed out on the website, or with abso join --reader.
150+ */
151+async function signedOut(server: string, project: string): Promise<string> {
152+ return (await isPublic(server, project))
153+ ? `${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.`
143154 : `This box isn't signed in to ${server}. abso login signs it in.`;
144155}
145156
157+/** A folder that reads a public project signed out: no agent, no key, no copy of the files. */
158+async function joinAsVisitor(root: string, server: string, project: string, env: Env): Promise<Output> {
159+ writeConfig(root, { server, project, agent: "", visitor: true });
160+ const api = new Api(readConfig(root, env.env));
161+ let version: number;
162+ try {
163+ version = (await api.status()).version;
164+ } catch (error) {
165+ rmSync(stateDir(root), { recursive: true, force: true });
166+ throw error;
167+ }
168+ return {
169+ text: [
170+ `Joined ${project} to read it signed out, at version ${version}, in ${root}. Nothing is sent with a sign-in, and nothing here is recorded.`,
171+ `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.`,
172+ `To work on ${project}: abso login, then abso join ${project} in a new folder.`,
173+ ...(root === resolve(env.cwd) ? [] : [`cd ${relative(env.cwd, root) || root}`]),
174+ ].join("\n"),
175+ json: { project, visitor: true, version, root },
176+ };
177+}
146179export async function runJoin(args: Parsed, env: Env): Promise<Output> {
147180 if (args.positionals.length !== 1) throw new UsageError("join takes the project name: abso join <project>");
148181 const project = args.positionals[0]!;
Lines 196–204 at 86 (were 163–169 at 85)
163196 agent = agentFrom(args);
164197 minted = box && !hasKey ? await mintKey(box, project, agent) : undefined;
165198 } else {
166− // No --agent: the box's name, or the next free -2, -3.
199+ // No --agent: the box's name, or the next free -2, -3. Not signed in, --reader reads a public project signed out.
200+ if (!box && reader && !hasKey && (await isPublic(server, project)))
201+ return joinAsVisitor(root, server, project, env);
167202 if (!box)
168203 throw new UsageError(
169204 `${await signedOut(server, project)} (A folder that already has a key joins with --agent <name>.)`,
MCP
compare on this site's /mcp
CLI
abso diff 85 86 client/src/join-commands.ts --json
JSON
/christopher/abso-core/compare/85..86?file=client%2Fsrc%2Fjoin-commands.ts&format=json