- MCP
- blame on this site's /mcp
- CLI
- abso blame client/src/command-env.ts --version 28 --json
- JSON
- /christopher/abso-core/blame/client/src/command-env.ts?version=28&format=json
64 linesFirst import 98% · review 2%Last change review in version 17,
64 lines from 2 changes in 2 versions.
init0Start the project1// What every abso command shares: its output, its environment, the folder it opens, and the news it took.
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";
8export const EXIT = { ok: 0, error: 1, refused: 2 } as const;
10export interface Output {
11 readonly text: string;
12 readonly json: Record<string, unknown>;
13 readonly exit?: number;
14}
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;
27}
29export function plural(n: number, word: string): string {
30 return `${n} ${word}${n === 1 ? "" : "s"}`;
31}
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(
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare37 `${env.cwd} is not in an abso folder (no .abso/config.json here or above); run abso init or abso join first`,
39 const config = readConfig(root, env.env);
40 return { root, config, api: new Api(config) };
41}
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);
52}
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);
59}
61export function newsText(news: News): string[] {
62 const lines = newsLines(news);
63 return lines.length === 0 ? [] : ["News:", ...lines.map((n) => ` ${n}`)];
64}