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
show on this site's /mcp
CLI
abso show 85 --json
JSON
/christopher/abso-core/versions/85?format=json

abso pipeline runs: list a project's pipeline runs, show one run's jobs (state, why each stopped, exit, time, an npm or deploy job's phase), and print a job's log with --log <pipeline.job>

of shared·infra-pipeline··Not checked

Version 84 · Files at version 85

4 files, 171 lines added, 8 removed.

--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -759,6 +759,11 @@
759759 return this.json("GET", version === undefined ? "/ci" : `/ci?${query({ version })}`);
760760 }
761761
762+ /** The project's pipeline runs, newest first; one run with its jobs; or one job's log (`log` is pipeline.job). */
763+ pipelineRuns(run?: number, log?: string): Promise<unknown> {
764+ return this.json("GET", run === undefined ? "/pipelines" : `/pipelines?${query({ run, log })}`);
765+ }
762767 /** Ends every /latest link handed out so far; answers CI's state with the new link. */
763768 ciRevoke(): Promise<CiStatus> {
764769 return this.json("POST", "/ci/revoke", {});
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -768,11 +768,11 @@
768768 run: runCheckIgnore,
769769 },
770770 pipeline: {
771− flags: { on: "string", space: "string", pipeline: "string", every: "string" },
771+ flags: { on: "string", space: "string", pipeline: "string", every: "string", log: "string" },
772772 usage:
773− "abso pipeline check [file] [--on publish|draft|green|land|hand|schedule [--space <name>] [--pipeline <name>] [--every <when>]]",
773+ "abso pipeline check [file] [--on publish|draft|green|land|hand|schedule [--space <name>] [--pipeline <name>] [--every <when>]] | abso pipeline runs [<run>] [--log <pipeline.job>]",
774774 about:
775− "Read the folder's pipeline file (abso.yml, abso.yaml or avcs.json, or the file named) and say what's wrong with it, place by place: a cycle in needs, a job that doesn't exist, secrets a draft could reach, a key it doesn't know. Exits 1 when it has problems. With --on, it says which pipelines that event starts (in shared, or --space), with their jobs in waves that can run side by side, and why each other pipeline doesn't start. It reads only the file.",
775+ "Read the folder's pipeline file (abso.yml, abso.yaml or avcs.json, or the file named) and say what's wrong with it, place by place: a cycle in needs, a job that doesn't exist, secrets a draft could reach, a key it doesn't know. Exits 1 when it has problems. With --on, it says which pipelines that event starts (in shared, or --space), with their jobs in waves that can run side by side, and why each other pipeline doesn't start. It reads only the file. abso pipeline runs asks the server what the project's pipelines did: the runs, newest first; with a run's number, its jobs (state, why, exit, time, an npm or deploy job's phase); with --log <pipeline.job>, that job's output.",
776776 // Loaded only here, so the yaml package it needs can't stop every other command
777777 // when a checkout lacks it (abso issue 168).
778778 run: async (args, env) => {
--- a/client/src/pipeline-commands.ts
+++ b/client/src/pipeline-commands.ts
@@ -1,13 +1,14 @@
1−// `abso pipeline check [file]` (abso issue 147, under 138): reads the folder's
2−// pipeline file and says what's wrong with it, before a publish. Read-only, with
3−// no server: the reading and checking are src/pipeline/pipeline.ts.
1+// `abso pipeline check [file]`: reads the folder's pipeline file and says what's
2+// wrong with it, before a publish. Read-only, with no server: the reading and
3+// checking are src/pipeline/pipeline.ts. `abso pipeline runs` asks the server
4+// what the project's pipelines did: the runs, one run's jobs, a job's log.
45
56import { existsSync, readFileSync } from "node:fs";
67import { basename, join, resolve } from "node:path";
78import { readPipelineFile } from "../../src/pipeline/pipeline.ts";
89import { type PipelineEvent, plan } from "../../src/pipeline/plan.ts";
910import { type Parsed, str, UsageError } from "./args.ts";
10−import { type Env, EXIT, type Output } from "./command-env.ts";
11+import { type Env, EXIT, type Output, open } from "./command-env.ts";
1112import { findRoot } from "./config.ts";
1213
1314/** The names a pipeline file may have, in the order they're looked for. */
@@ -15,7 +16,9 @@
1516
1617export async function runPipeline(args: Parsed, env: Env): Promise<Output> {
1718 const [sub, file, ...rest] = args.positionals;
18− if (sub !== "check" || rest.length > 0) throw new UsageError("abso pipeline check [file]");
19+ if (sub === "runs") return runRuns(file, rest, args, env);
20+ if (sub !== "check" || rest.length > 0)
21+ throw new UsageError("abso pipeline check [file] | abso pipeline runs [<run>] [--log <pipeline.job>]");
1922 const root = findRoot(env.cwd) ?? env.cwd;
2023 let path: string;
2124 if (file !== undefined) {
@@ -90,3 +93,88 @@
9093 }
9194 return { kind: on as "publish" | "draft" | "green" | "land", space };
9295}
97+/** A run as the server's list gives it. */
98+export interface RunSummary {
99+ id: number | null;
100+ version: number;
101+ event: string;
102+ file: string;
103+ started: number;
104+ ended: number | null;
105+ state: string;
106+ pipelines: { name: string; state: string }[];
107+}
109+/** A job of one run, as the server keeps it. */
110+export interface RunJob {
111+ pipeline: string;
112+ job: string;
113+ needs: string[];
114+ run?: string;
115+ uses?: string;
116+ state: string;
117+ why?: string;
118+ exit?: number | null;
119+ seconds?: number;
120+ since?: number;
121+ log?: boolean;
122+ npm?: { phase: string };
123+ deploy?: { phase?: string };
124+}
126+/** A time in ms as HH:MM UTC, with the date when it isn't today. */
127+function at(ms: number, now: number): string {
128+ const t = new Date(ms).toISOString();
129+ return t.slice(0, 10) === new Date(now).toISOString().slice(0, 10)
130+ ? `${t.slice(11, 16)} UTC`
131+ : `${t.slice(0, 16).replace("T", " ")} UTC`;
132+}
134+/** The runs, newest first, one line each. */
135+export function runsText(runs: RunSummary[], now = Date.now()): string {
136+ if (runs.length === 0) return "No pipeline runs yet.\n";
137+ const lines = runs.map(
138+ (r) =>
139+ ` run ${r.id ?? "-"}: version ${r.version} (${r.event}, ${r.file}), ${r.state}, ${at(r.started, now)}${r.ended ? ` to ${at(r.ended, now)}` : ""}: ${r.pipelines.map((p) => `${p.name} ${p.state}`).join(", ")}`,
140+ );
141+ return `${lines.join("\n")}\nabso pipeline runs <run> shows its jobs.\n`;
142+}
144+/** One run with its jobs: each job's state, why, exit, time and phase, and where its log is. */
145+export function runText(run: RunSummary & { jobs: RunJob[] }, now = Date.now()): string {
146+ const lines = run.jobs.map((j) => {
147+ const parts = [
148+ j.state,
149+ j.npm ? `npm ${j.npm.phase}` : "",
150+ j.deploy?.phase ? `deploy ${j.deploy.phase}` : "",
151+ j.why ?? "",
152+ j.exit !== undefined && j.exit !== null ? `exit ${j.exit}` : "",
153+ j.seconds !== undefined ? `${j.seconds} s` : "",
154+ j.state === "running" && j.since ? `since ${at(j.since, now)}` : "",
155+ ].filter(Boolean);
156+ const log = j.log ? `\n log: abso pipeline runs ${run.id} --log ${j.pipeline}.${j.job}` : "";
157+ return ` ${j.pipeline}.${j.job} (${j.uses ? `uses ${j.uses}` : j.run}): ${parts.join(", ")}${log}`;
158+ });
159+ return `Run ${run.id}: version ${run.version} (${run.event}, ${run.file}), ${run.state}, ${at(run.started, now)}${run.ended ? ` to ${at(run.ended, now)}` : ""}.\n${lines.join("\n")}\n`;
160+}
162+async function runRuns(runArg: string | undefined, rest: string[], args: Parsed, env: Env): Promise<Output> {
163+ const usage = "abso pipeline runs [<run>] [--log <pipeline.job>]";
164+ if (rest.length > 0) throw new UsageError(usage);
165+ if (runArg !== undefined && !/^\d+$/.test(runArg))
166+ throw new UsageError(`a run is a number (got ${runArg}): ${usage}`);
167+ const log = str(args, "log");
168+ if (log !== undefined && runArg === undefined) throw new UsageError(`--log needs a run: ${usage}`);
169+ const { api } = open(env);
170+ if (runArg === undefined) {
171+ const { runs } = (await api.pipelineRuns()) as { runs: RunSummary[] };
172+ return { text: runsText(runs), json: { runs } };
173+ }
174+ if (log !== undefined) {
175+ const got = (await api.pipelineRuns(Number(runArg), log)) as { run: number; job: string; log: string };
176+ return { text: got.log.endsWith("\n") ? got.log : `${got.log}\n`, json: got };
177+ }
178+ const got = (await api.pipelineRuns(Number(runArg))) as RunSummary & { jobs: RunJob[] };
179+ return { text: runText(got), json: { ...got } };
180+}
--- a/client/test/pipeline-commands.test.ts
+++ b/client/test/pipeline-commands.test.ts
@@ -7,6 +7,7 @@
77import { join } from "node:path";
88import { after, describe, it } from "node:test";
99import { main } from "../src/main.ts";
10+import { runsText, runText } from "../src/pipeline-commands.ts";
1011
1112const base = mkdtempSync(join(tmpdir(), "abso-pipeline-"));
1213after(() => rmSync(base, { recursive: true, force: true }));
@@ -158,3 +159,72 @@
158159 assert.match((await run(dir, "check", "--on", "schedule")).stderr, /--on schedule takes --every/);
159160 });
160161});
163+describe("abso pipeline runs", () => {
164+ const now = Date.parse("2026-10-10T07:00:00Z");
165+ const t = (hm: string) => Date.parse(`2026-10-10T${hm}:00Z`);
166+ const summary = {
167+ id: 4,
168+ version: 4,
169+ event: "green",
170+ file: "abso.yml",
171+ started: t("06:45"),
172+ ended: t("06:46"),
173+ state: "planned",
174+ pipelines: [{ name: "npm", state: "planned" }],
175+ };
177+ it("lists the runs, newest first, one line each", () => {
178+ assert.equal(
179+ runsText([summary], now),
180+ " run 4: version 4 (green, abso.yml), planned, 06:45 UTC to 06:46 UTC: npm planned\nabso pipeline runs <run> shows its jobs.\n",
181+ );
182+ assert.equal(runsText([], now), "No pipeline runs yet.\n");
183+ });
185+ it("shows a run's jobs with why each one stopped, and where a log is", () => {
186+ const text = runText(
187+ {
188+ ...summary,
189+ jobs: [
190+ { pipeline: "npm", job: "pack", needs: [], run: "npm pack", state: "passed", exit: 0, seconds: 5, log: true },
191+ {
192+ pipeline: "npm",
193+ job: "publish",
194+ needs: ["pack"],
195+ uses: "npm-publish",
196+ state: "planned",
197+ why: "not bound here",
198+ },
199+ {
200+ pipeline: "npm",
201+ job: "wait",
202+ needs: [],
203+ uses: "npm-publish",
204+ state: "running",
205+ npm: { phase: "wait" },
206+ since: t("06:50"),
207+ },
208+ ],
209+ },
210+ now,
211+ );
212+ assert.equal(
213+ text,
214+ [
215+ "Run 4: version 4 (green, abso.yml), planned, 06:45 UTC to 06:46 UTC.",
216+ " npm.pack (npm pack): passed, exit 0, 5 s",
217+ " log: abso pipeline runs 4 --log npm.pack",
218+ " npm.publish (uses npm-publish): planned, not bound here",
219+ " npm.wait (uses npm-publish): running, npm wait, since 06:50 UTC",
220+ "",
221+ ].join("\n"),
222+ );
223+ });
225+ it("takes a run number, and --log only with one", async () => {
226+ const dir = folder({});
227+ assert.match((await run(dir, "runs", "x")).stderr, /a run is a number/);
228+ assert.match((await run(dir, "runs", "--log", "npm.pack")).stderr, /--log needs a run/);
229+ });
230+});