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/command-env.ts?version=271&format=json
72 linesFirst import 85% · speed 8% · readspeed 4% · pinch 3%Last change readspeed in version 271, 6 versions changed it

You're reading version 271. The newest is 318, and 3 versions since then changed this file. Go to the newestCompare with 318

1// What every abso command shares: its output, its environment, the folder it opens, and the news it took.
2
3import { Api, type News, newsLines, type RunKind } from "./api.ts";
4import { UsageError } from "./args.ts";
5import { type Config, findRoot, readConfig } from "./config.ts";
6import { newsBlockLines, newsShown } from "./core.ts";
7import { logNews } from "./folder.ts";
8
9export const EXIT = { ok: 0, error: 1, refused: 2 } as const;
11export interface Output {
12 readonly text: string;
13 readonly json: Record<string, unknown>;
14 readonly exit?: number;
17export interface Env {
18 readonly cwd: string;
19 readonly env: Readonly<Record<string, string | undefined>>;
20 /** Where `run` streams the box's output as it arrives. */
21 readonly write: (text: string) => void;
22 /** --token-file: this machine's ~/.abso/token may sign in, where nothing else does. Never read otherwise. */
23 readonly tokenFile?: boolean;
24 /** Where `run` streams the box's stderr; `write` when not given. */
25 readonly writeErr?: (text: string) => void;
26 /** What a box run is for, when a command runs one for its own ends (shot, bisect, publish --check). */
27 readonly runKind?: RunKind;
28 /** What a -file flag of - reads: stdin, unless a test gives it. */
29 readonly readStdin?: () => string;
30 /**
31 * The server --server named, checked (server-choice.ts), when the command was given one. It is used as given,
32 * so no environment setting redirects it (ABSO_ISSUES_SERVER included).
33 */
34 readonly server?: string;
37export function plural(n: number, word: string): string {
38 return `${n} ${word}${n === 1 ? "" : "s"}`;
41export function open(env: Env): { root: string; config: Config; api: Api } {
42 const root = findRoot(env.cwd);
43 if (root === undefined)
44 throw new UsageError(
45 `You're not in an abso folder: ${env.cwd} has no .abso/config.json, nor does any folder above it. abso join <project> makes one, or abso init a new project.`,
46 );
47 const config = readConfig(root, env.env, env.tokenFile === true);
48 return { root, config, api: new Api(config) };
51/**
52 * News a command took from the server while recording first. main() prints it
53 * after whatever the command says, so every command that takes news shows it
54 * (#37, News Report: sync, run and diff took it, wrote it to .avcs/news.log and
55 * printed nothing; 94 of the game's 613 items, 54 of them announcements).
56 */
57const takenNews: string[] = [];
58export function takeNews(): string[] {
59 return takenNews.splice(0);
62/** News a record answered with: kept in .avcs/news.log, and printed by main(). */
63export function heard(root: string, news: News | undefined): void {
64 const lines = newsLines(news);
65 logNews(root, lines);
66 takenNews.push(...lines);
69export function newsText(news: News): string[] {
70 const lines = newsLines(news);
71 return newsBlockLines(lines.map((n) => newsShown(n)));