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
MCP
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/client/src/visitor.ts?format=json
44 linespinch 95% · speed 5%Last change speed in version 155, 2 versions changed it
1// A visitor folder: abso join <project> --reader with no sign-in, for a public project. It reads the
2// project through the routes anyone can read, and sends no credential, whatever the environment holds
3// (config.ts reads no token for it, and Api sends none and follows no redirect). Which commands it runs
4// is a list of reads: anything not on it is refused here, before any call, so a new command stays
5// refused until someone adds it. The server refuses writes from it too; this is so the refusal is plain.
6
7import { type Parsed, UsageError } from "./args.ts";
8
9/** The commands a visitor folder runs, each with the flags it takes there. */
10export const VISITOR_READS: Readonly<Record<string, readonly string[]>> = {
11 status: [],
12 log: ["limit", "before", "draft", "since", "by", "count"],
13 show: ["draft"],
14 files: ["draft", "version"],
15 blame: ["from", "to", "version", "draft"],
16 why: ["draft"],
17 where: [],
18 issues: ["open", "status", "agent", "parent", "label", "labels"],
19 issue: [],
20 search: ["limit"],
21};
23/** Commands about this box, not the folder: they work from anywhere, a visitor folder too. */
24export const VISITOR_ELSEWHERE: readonly string[] = ["login", "logout"];
26/** Flags every command takes (--server is checked against the folder's own server before this, in main.ts). */
27const EVERY = new Set(["json", "help", "server"]);
29export function visitorRefusal(project: string): string {
30 return `This folder reads ${project} signed out. To work on it: abso login, then abso join ${project} in a new folder.`;
33/** Refuses, before any call, a command or a flag a visitor folder doesn't run. */
34export function checkVisitor(command: string, args: Parsed, project: string): void {
35 if (VISITOR_ELSEWHERE.includes(command)) return;
36 const flags = VISITOR_READS[command];
37 if (flags === undefined) throw new UsageError(visitorRefusal(project));
38 for (const name of args.flags.keys())
39 if (!EVERY.has(name) && !flags.includes(name))
40 throw new UsageError(`${visitorRefusal(project)} Here, ${command} reads only; --${name} isn't one of its reads.`);
41 // abso issue new and abso issue draft write: here, issue takes only a number.
42 if (command === "issue" && !(args.positionals.length === 1 && /^#?\d+$/.test(args.positionals[0]!)))
43 throw new UsageError(`${visitorRefusal(project)} Here, issue reads one issue: abso issue <N>.`);