- MCP
- blame on this site's /mcp
- CLI
- abso blame client/src/visitor.ts --json
- JSON
- /christopher/abso-core/blame/client/src/visitor.ts?format=json
44 linespinch 95% · speed 5%Last change speed in version 155,
44 lines from 2 changes in 2 versions.
pinch86Read a public project signed out: abso join <project> --reader with no sign-in makes a folder that reads it. The folder holds only its settings (server, project, visitor), sends no sign-in whatever the environment or the box holds, follows no redirect, and runs status, log, show, files, blame, why, where, issues, issue and search; every other command is refused before any call, from an allow-list a new command has to join. join answers a private project and a missing one alike, by the status answer's code alone. Tests in client/test/visitor.test.ts.Compare1// 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.
7import { type Parsed, UsageError } from "./args.ts";
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"];
speed155Every command that talks to a server now takes --server <url>, parsed and checked in one place (client/src/server-choice.ts). A missing, empty or malformed value is refused before anything is sent. In a joined folder, --server must be the folder's own server: another one is refused rather than swapped in, so a folder's work and key go only to the server it was joined on. Commands that pick their own server (join, init, login, whoami, doctor, box, logout, orgs, org, key) use the named one as given; doctor no longer swaps in the folder's server over an explicit one, and an explicit --server takes issues to that server's own Issues Worker instead of ABSO_ISSUES_SERVER. The five local-only commands refuse --server and say why. Help shows the same --server line for every command of a kind. For abso-core issue 10.Compare26/** 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"]);
pinch86Read a public project signed out: abso join <project> --reader with no sign-in makes a folder that reads it. The folder holds only its settings (server, project, visitor), sends no sign-in whatever the environment or the box holds, follows no redirect, and runs status, log, show, files, blame, why, where, issues, issue and search; every other command is refused before any call, from an allow-list a new command has to join. join answers a private project and a missing one alike, by the status answer's code alone. Tests in client/test/visitor.test.ts.Compare28
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.`;
31}
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>.`);
44}