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=86&format=json
65 linesFirst import 95% · pinch 3% · speed 2%Last change speed in version 76, 4 versions changed it

You're reading version 86. The newest is 318, and 5 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 /** Where `run` streams the box's stderr; `write` when not given. */
23 readonly writeErr?: (text: string) => void;
24 /** What a box run is for, when a command runs one for its own ends (shot, bisect, publish --check). */
25 readonly runKind?: RunKind;
26 /** What a -file flag of - reads: stdin, unless a test gives it. */
27 readonly readStdin?: () => string;
30export function plural(n: number, word: string): string {
31 return `${n} ${word}${n === 1 ? "" : "s"}`;
34export function open(env: Env): { root: string; config: Config; api: Api } {
35 const root = findRoot(env.cwd);
36 if (root === undefined)
37 throw new UsageError(
38 `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.`,
39 );
40 const config = readConfig(root, env.env);
41 return { root, config, api: new Api(config) };
44/**
45 * News a command took from the server while recording first. main() prints it
46 * after whatever the command says, so every command that takes news shows it
47 * (#37, News Report: sync, run and diff took it, wrote it to .avcs/news.log and
48 * printed nothing; 94 of the game's 613 items, 54 of them announcements).
49 */
50const takenNews: string[] = [];
51export function takeNews(): string[] {
52 return takenNews.splice(0);
55/** News a record answered with: kept in .avcs/news.log, and printed by main(). */
56export function heard(root: string, news: News | undefined): void {
57 const lines = newsLines(news);
58 logNews(root, lines);
59 takenNews.push(...lines);
62export function newsText(news: News): string[] {
63 const lines = newsLines(news);
64 return newsBlockLines(lines.map((n) => newsShown(n)));