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=30&format=json
64 linesFirst import 98% · review 2%Last change review in version 17, 2 versions changed it

You're reading version 30. The newest is 318, and 7 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 { logNews } from "./folder.ts";
7
8export const EXIT = { ok: 0, error: 1, refused: 2 } as const;
9
10export interface Output {
11 readonly text: string;
12 readonly json: Record<string, unknown>;
13 readonly exit?: number;
16export interface Env {
17 readonly cwd: string;
18 readonly env: Readonly<Record<string, string | undefined>>;
19 /** Where `run` streams the box's output as it arrives. */
20 readonly write: (text: string) => void;
21 /** Where `run` streams the box's stderr; `write` when not given. */
22 readonly writeErr?: (text: string) => void;
23 /** What a box run is for, when a command runs one for its own ends (shot, bisect, publish --check). */
24 readonly runKind?: RunKind;
25 /** What a -file flag of - reads: stdin, unless a test gives it. */
26 readonly readStdin?: () => string;
29export function plural(n: number, word: string): string {
30 return `${n} ${word}${n === 1 ? "" : "s"}`;
33export function open(env: Env): { root: string; config: Config; api: Api } {
34 const root = findRoot(env.cwd);
35 if (root === undefined)
36 throw new UsageError(
37 `${env.cwd} is not in an abso folder (no .abso/config.json here or above); run abso init or abso join first`,
38 );
39 const config = readConfig(root, env.env);
40 return { root, config, api: new Api(config) };
43/**
44 * News a command took from the server while recording first. main() prints it
45 * after whatever the command says, so every command that takes news shows it
46 * (#37, News Report: sync, run and diff took it, wrote it to .avcs/news.log and
47 * printed nothing; 94 of the game's 613 items, 54 of them announcements).
48 */
49const takenNews: string[] = [];
50export function takeNews(): string[] {
51 return takenNews.splice(0);
54/** News a record answered with: kept in .avcs/news.log, and printed by main(). */
55export function heard(root: string, news: News | undefined): void {
56 const lines = newsLines(news);
57 logNews(root, lines);
58 takenNews.push(...lines);
61export function newsText(news: News): string[] {
62 const lines = newsLines(news);
63 return lines.length === 0 ? [] : ["News:", ...lines.map((n) => ` ${n}`)];