ostia 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/cli/main.ts CHANGED
@@ -10,9 +10,8 @@ if (first === "--version" || first === "-v") {
10
10
  process.exit(0);
11
11
  }
12
12
  if (first === undefined || first === "--help" || first === "-h") {
13
- const { MAIN_HELP } = await import("./help.ts");
14
- await Bun.write(Bun.stdout, MAIN_HELP);
15
- process.exit(first === undefined ? 2 : 0);
13
+ const { showHelp } = await import("./help.ts");
14
+ process.exit(await showHelp("main", first !== undefined));
16
15
  }
17
16
  const { main } = await import("./run.ts");
18
17
  process.exit(await main());
package/src/cli/output.ts CHANGED
@@ -5,7 +5,11 @@ import {
5
5
  serializeDocument,
6
6
  } from "../ir/document.ts";
7
7
  import type { ProfileDocument } from "../ir/types.ts";
8
- import type { FormatName, RenderResult } from "../renderers/index.ts";
8
+ import type {
9
+ FormatName,
10
+ RenderResult,
11
+ TableOptions,
12
+ } from "../renderers/index.ts";
9
13
  import { renderers } from "../renderers/index.ts";
10
14
  import {
11
15
  MINIMAL_PROTOCOL_VERSION,
@@ -110,14 +114,6 @@ export async function writeCliError(
110
114
  );
111
115
  }
112
116
 
113
- export async function showHelp(
114
- text: string,
115
- requested: boolean,
116
- ): Promise<0 | 2> {
117
- await out(text);
118
- return requested ? 0 : 2;
119
- }
120
-
121
117
  export async function writeRenderResult(
122
118
  result: RenderResult,
123
119
  outDir?: string,
@@ -165,16 +161,20 @@ export async function exportDocument(
165
161
  }
166
162
 
167
163
  // Shared tail of time/bench/ab/compare: `--export-json`, then the report
168
- // unless `--quiet`. `rendererOptions` reaches the renderer verbatim.
164
+ // unless `--quiet`. `rendererOptions` reaches the event renderers
165
+ // verbatim, `tableOptions` the table.
169
166
  export async function emitDocument(
170
167
  doc: ProfileDocument,
171
168
  args: OutputOptions,
172
169
  rendererOptions: MinimalRenderOptions = {},
170
+ tableOptions: TableOptions = {},
173
171
  ): Promise<void> {
174
172
  const jsonText = await exportDocument(doc, args);
175
173
  if (args.quiet) return;
176
174
  if (jsonText !== undefined) await out(jsonText);
177
- else {
175
+ else if (args.format === "table") {
176
+ await writeRenderResult(await renderers.table.render(doc, tableOptions));
177
+ } else {
178
178
  await writeRenderResult(
179
179
  await renderers[args.format].render(doc, rendererOptions),
180
180
  );
package/src/cli/run.ts CHANGED
@@ -8,15 +8,12 @@ import {
8
8
  AbSuiteError,
9
9
  cleanAbTrees,
10
10
  } from "../ab/index.ts";
11
+ import { importsHarnessRelatively, unpairedReason } from "../ab/unpaired.ts";
11
12
  import { listBaselines, saveBaseline } from "../baseline/index.ts";
12
13
  import { bench, resolveBenchOptions } from "../bench/index.ts";
13
- import {
14
- BaselineError,
15
- BaselineNotFoundError,
16
- renderCiReport,
17
- runCi,
18
- } from "../ci/index.ts";
14
+ import { BaselineError, BaselineNotFoundError, runCi } from "../ci/index.ts";
19
15
  import { compareDocuments, DEFAULT_THRESHOLDS } from "../compare/index.ts";
16
+ import { nowMs, processEnv } from "../config/env.ts";
20
17
  import {
21
18
  baselinePath,
22
19
  CONFIG_FILES,
@@ -37,12 +34,27 @@ import type { AbSummary, ProfileDocument } from "../ir/types.ts";
37
34
  import { sideLabel } from "../measure/paired.ts";
38
35
  import { isHarnessFailure } from "../measure/timing.ts";
39
36
  import { formatGit, workloadLabel } from "../renderers/format.ts";
40
- import { type FormatName, renderers } from "../renderers/index.ts";
37
+ import {
38
+ type FormatName,
39
+ renderers,
40
+ type TableOptions,
41
+ } from "../renderers/index.ts";
41
42
  import type { MinimalProtocolContext } from "../renderers/minimal.ts";
42
43
  import type { TimeSource, TimeUnit } from "../spawn/index.ts";
43
- import { withDefaultFormat } from "./agent.ts";
44
+ import {
45
+ createProgress,
46
+ type Paint,
47
+ PLAIN,
48
+ plural,
49
+ type Progress,
50
+ SILENT,
51
+ truncatePath,
52
+ truncateWords,
53
+ } from "../terminal.ts";
54
+ import { agentVariable, withDefaultFormat } from "./agent.ts";
44
55
  import {
45
56
  CliUsageError,
57
+ COLOR_FLAGS,
46
58
  CONFIG_FLAGS,
47
59
  type ConfigArgs,
48
60
  flag,
@@ -60,16 +72,7 @@ import {
60
72
  SUITE_FLAGS,
61
73
  VIZ_FORMATS,
62
74
  } from "./flags.ts";
63
- import {
64
- AB_HELP,
65
- BASELINE_HELP,
66
- BENCH_HELP,
67
- CI_HELP,
68
- COMPARE_HELP,
69
- MAIN_HELP,
70
- REPORT_HELP,
71
- TIME_HELP,
72
- } from "./help.ts";
75
+ import { type HelpTopic, paintFor, showHelp } from "./help.ts";
73
76
  import {
74
77
  CliError,
75
78
  type CliErrorCode,
@@ -77,13 +80,53 @@ import {
77
80
  exportDocument,
78
81
  orFail,
79
82
  out,
80
- showHelp,
81
83
  writeCliError,
82
84
  writeRenderResult,
83
85
  } from "./output.ts";
84
86
 
85
87
  const isHelpArg = (arg: string | undefined) => arg === "--help" || arg === "-h";
86
88
 
89
+ interface Human {
90
+ paint: Paint;
91
+ progress: Progress;
92
+ startNs: number;
93
+ }
94
+
95
+ // Room for a progress step after its 20-cell bar and before its seconds,
96
+ // so the line fits 80 columns.
97
+ const PROGRESS_TEXT_WIDTH = 48;
98
+
99
+ const stepText = (text: string) => truncateWords(text, PROGRESS_TEXT_WIDTH);
100
+
101
+ const elapsedMsSince = (startNs: number) => (Bun.nanoseconds() - startNs) / 1e6;
102
+
103
+ // Color and the progress line only for the table on a terminal no coding
104
+ // agent reads, since every other format is read by a program.
105
+ async function humanFor(args: {
106
+ format: FormatName;
107
+ quiet: boolean;
108
+ color?: boolean;
109
+ }): Promise<Human> {
110
+ const startNs = Bun.nanoseconds();
111
+ if (args.format !== "table") {
112
+ return { paint: PLAIN, progress: SILENT, startNs };
113
+ }
114
+ const { isatty } = await import("node:tty");
115
+ const shown =
116
+ !args.quiet && isatty(2) && agentVariable(processEnv()) === undefined;
117
+ return {
118
+ paint: await paintFor(1, args.color),
119
+ progress: shown
120
+ ? createProgress(
121
+ (text) => writeSync(2, text),
122
+ await paintFor(2, args.color),
123
+ nowMs,
124
+ )
125
+ : SILENT,
126
+ startNs,
127
+ };
128
+ }
129
+
87
130
  // Runs `run` with SIGINT wired to its `AbortSignal`, so Ctrl-C cancels
88
131
  // cleanly with partial results.
89
132
  async function withSigintAbort<T>(
@@ -224,7 +267,7 @@ async function timeCommand(argv: string[]): Promise<number> {
224
267
  ...(parsed.argvCommand.length > 0 ? [parsed.argvCommand] : []),
225
268
  ];
226
269
  if (parsed.help || commandList.length === 0) {
227
- return showHelp(TIME_HELP, parsed.help);
270
+ return showHelp("time", parsed.help);
228
271
  }
229
272
 
230
273
  if (
@@ -273,11 +316,19 @@ async function timeCommand(argv: string[]): Promise<number> {
273
316
  }),
274
317
  }));
275
318
 
319
+ const human = await humanFor(parsed);
276
320
  const { result: doc, aborted } = await withSigintAbort(
277
321
  "Run failed",
278
322
  (signal) =>
279
323
  time({
280
324
  commands,
325
+ ...(human.progress !== SILENT && {
326
+ onProgress: (p) =>
327
+ human.progress.step(
328
+ stepText(`time ${p.command} of ${p.commands} · ${p.label}`),
329
+ p.doneRatio,
330
+ ),
331
+ }),
281
332
  ...definedFields({
282
333
  timeSource,
283
334
  samples: parsed.samples,
@@ -298,10 +349,15 @@ async function timeCommand(argv: string[]): Promise<number> {
298
349
  showOutput: parsed.showOutput,
299
350
  }),
300
351
  signal,
301
- }),
352
+ }).finally(() => human.progress.clear()),
302
353
  );
303
354
 
304
- await emitDocument(doc, parsed);
355
+ await emitDocument(
356
+ doc,
357
+ parsed,
358
+ {},
359
+ { paint: human.paint, elapsedMs: elapsedMsSince(human.startNs) },
360
+ );
305
361
  if (aborted) return 130;
306
362
 
307
363
  // A failing command is exit 2 (couldn't measure), not 1, because 1 is
@@ -386,21 +442,67 @@ function parseBenchArgs(argv: string[]): BenchArgs {
386
442
  });
387
443
  }
388
444
 
445
+ // One suite names itself and several are counted, so the context stays
446
+ // one line.
447
+ async function anyImportsHarnessRelatively(
448
+ suites: readonly string[],
449
+ ): Promise<boolean> {
450
+ for (const suite of suites) {
451
+ const file = Bun.file(suite);
452
+ if ((await file.exists()) && importsHarnessRelatively(await file.text())) {
453
+ return true;
454
+ }
455
+ }
456
+ return false;
457
+ }
458
+
459
+ function suitesRun(suites: readonly string[]): string {
460
+ const [only] = suites;
461
+ return suites.length === 1 && only !== undefined
462
+ ? truncatePath(only, 40)
463
+ : plural(suites.length, "suite");
464
+ }
465
+
389
466
  async function benchCommand(argv: string[]): Promise<number> {
390
467
  const parsed = parseBenchArgs(argv);
391
- if (parsed.help) return showHelp(BENCH_HELP, true);
468
+ if (parsed.help) return showHelp("bench", true);
392
469
 
393
470
  const config = await loadProjectConfig(parsed.config);
394
471
  const resolved = await resolveBenchOptions(parsed, config?.bench);
395
472
 
396
- if (resolved.suites.length === 0) return showHelp(BENCH_HELP, false);
473
+ if (resolved.suites.length === 0) return showHelp("bench", false);
397
474
 
475
+ const human = await humanFor(parsed);
398
476
  const { result: doc, aborted } = await withSigintAbort(
399
477
  "Bench failed",
400
- (signal) => bench({ ...resolved, signal }),
478
+ (signal) =>
479
+ bench({
480
+ ...resolved,
481
+ signal,
482
+ ...(human.progress !== SILENT && {
483
+ onProgress: (p) =>
484
+ human.progress.step(
485
+ stepText(
486
+ p.suites > 1
487
+ ? `bench ${p.file} · ${p.task} of ${p.tasks} · ${p.label}`
488
+ : `bench ${p.task} of ${p.tasks} · ${p.label}`,
489
+ ),
490
+ (p.suite - 1 + (p.task - 1) / p.tasks) / p.suites,
491
+ ),
492
+ }),
493
+ }).finally(() => human.progress.clear()),
401
494
  );
402
495
 
403
- await emitDocument(doc, parsed);
496
+ await emitDocument(
497
+ doc,
498
+ parsed,
499
+ {},
500
+ {
501
+ paint: human.paint,
502
+ ran: suitesRun(resolved.suites),
503
+ elapsedMs: elapsedMsSince(human.startNs),
504
+ },
505
+ );
404
506
  return aborted ? 130 : 0;
405
507
  }
406
508
 
@@ -484,6 +586,50 @@ function progressWriter(tty: boolean): {
484
586
  };
485
587
  }
486
588
 
589
+ // The shared progress line: the step, and how far through every suite's
590
+ // two passes. Confirming and memory runs come after the passes, so they
591
+ // keep the bar where the passes left it.
592
+ function abProgressLine(line: Progress): {
593
+ onProgress: (p: AbProgress) => void;
594
+ done: () => void;
595
+ } {
596
+ let doneRatio = 0;
597
+ return {
598
+ onProgress: (p) => {
599
+ switch (p.phase) {
600
+ case "setup":
601
+ line.step(stepText(`ab base setup · ${p.command}`), 0);
602
+ return;
603
+ case "measure": {
604
+ doneRatio =
605
+ ((p.suite - 1) * p.passes + p.pass - 1 + (p.task - 1) / p.tasks) /
606
+ (p.suites * p.passes);
607
+ const suite = p.suites > 1 ? `${p.file} · ` : "";
608
+ line.step(
609
+ stepText(`ab ${suite}${p.task} of ${p.tasks} · ${p.label}`),
610
+ doneRatio,
611
+ );
612
+ return;
613
+ }
614
+ case "confirm":
615
+ line.step(
616
+ stepText(`ab confirming ${p.repeat} of ${p.repeats} · ${p.label}`),
617
+ doneRatio,
618
+ );
619
+ return;
620
+ case "memory":
621
+ line.step(
622
+ stepText(
623
+ `ab memory ${p.run} of ${p.runs} · ${sideLabel(p.side)} · ${p.label}`,
624
+ ),
625
+ doneRatio,
626
+ );
627
+ }
628
+ },
629
+ done: () => line.clear(),
630
+ };
631
+ }
632
+
487
633
  function parseAbArgs(argv: string[]): AbArgs {
488
634
  const args: AbArgs = {
489
635
  ...RUN_DEFAULTS,
@@ -503,7 +649,7 @@ function parseAbArgs(argv: string[]): AbArgs {
503
649
 
504
650
  async function abCommand(argv: string[]): Promise<number> {
505
651
  const parsed = parseAbArgs(argv);
506
- if (parsed.help) return showHelp(AB_HELP, true);
652
+ if (parsed.help) return showHelp("ab", true);
507
653
 
508
654
  const config = await loadProjectConfig(parsed.config);
509
655
  if (parsed.clean) {
@@ -528,14 +674,20 @@ async function abCommand(argv: string[]): Promise<number> {
528
674
  noiseCheck,
529
675
  noiseBudgetMs,
530
676
  } = await resolveBenchOptions(parsed, config?.bench);
531
- if (suites.length === 0) return showHelp(AB_HELP, false);
677
+ if (suites.length === 0) return showHelp("ab", false);
532
678
 
679
+ const human = await humanFor(parsed);
533
680
  const { isatty } = await import("node:tty");
534
- const tty = isatty(2);
681
+ // The redrawn line where a person watches; the plain lines only when
682
+ // asked for, as for a log.
535
683
  const progress =
536
- (parsed.progress ?? (tty && !parsed.quiet))
537
- ? progressWriter(tty)
538
- : undefined;
684
+ parsed.progress === false
685
+ ? undefined
686
+ : human.progress !== SILENT
687
+ ? abProgressLine(human.progress)
688
+ : parsed.progress
689
+ ? progressWriter(isatty(2))
690
+ : undefined;
539
691
 
540
692
  const { result: doc, aborted } = await withSigintAbort(
541
693
  "A/B run failed",
@@ -602,25 +754,40 @@ async function abCommand(argv: string[]): Promise<number> {
602
754
  const byId = new Map(doc.workloads.map((w) => [w.id, w]));
603
755
  const workloadsFor = (ids: string[] = []) =>
604
756
  ids.flatMap((id) => byId.get(id) ?? []);
605
- await emitDocument(doc, parsed, {
606
- protocol: {
607
- command: "ab",
608
- exitCode,
609
- unmatched: {
610
- baseOnly: workloadsFor(doc.unmatched?.baseOnly),
611
- candOnly: workloadsFor(doc.unmatched?.candOnly),
612
- },
613
- ...(parsed.exportJson && { exportedTo: parsed.exportJson }),
614
- } satisfies MinimalProtocolContext,
615
- });
616
- if (exitCode === 2) {
617
- const allNew = summary.newSuites?.length === suites.length;
618
- await writeCliError(
619
- "no-matches",
620
- allNew
621
- ? `No suite exists at ${summary.base.ref}; nothing was paired. Use "ostia bench" to time new suites.`
622
- : `No task exists both at ${summary.base.ref} and in the working tree; nothing was paired.`,
623
- );
757
+ const paired = summary.matched + summary.threw;
758
+ const unpaired =
759
+ exitCode === 2 && paired === 0
760
+ ? unpairedReason({
761
+ ref: summary.base.ref,
762
+ base: paired + (doc.unmatched?.baseOnly.length ?? 0),
763
+ cand: paired + (doc.unmatched?.candOnly.length ?? 0),
764
+ allNew: summary.newSuites?.length === suites.length,
765
+ relativeHarness: await anyImportsHarnessRelatively(suites),
766
+ })
767
+ : undefined;
768
+ await emitDocument(
769
+ doc,
770
+ parsed,
771
+ {
772
+ protocol: {
773
+ command: "ab",
774
+ exitCode,
775
+ unmatched: {
776
+ baseOnly: workloadsFor(doc.unmatched?.baseOnly),
777
+ candOnly: workloadsFor(doc.unmatched?.candOnly),
778
+ },
779
+ ...(parsed.exportJson && { exportedTo: parsed.exportJson }),
780
+ } satisfies MinimalProtocolContext,
781
+ },
782
+ {
783
+ paint: human.paint,
784
+ ran: suitesRun(suites),
785
+ elapsedMs: elapsedMsSince(human.startNs),
786
+ ...definedFields({ unpaired }),
787
+ },
788
+ );
789
+ if (unpaired) {
790
+ await writeCliError("no-matches", `${unpaired.what}: ${unpaired.next}.`);
624
791
  }
625
792
  return exitCode;
626
793
  }
@@ -648,7 +815,7 @@ function parseCompareArgs(argv: string[]): CompareArgs {
648
815
 
649
816
  async function compareCommand(argv: string[]): Promise<number> {
650
817
  const parsed = parseCompareArgs(argv);
651
- if (parsed.help) return showHelp(COMPARE_HELP, true);
818
+ if (parsed.help) return showHelp("compare", true);
652
819
 
653
820
  const maxPaths = parsed.baseline ? 1 : 2;
654
821
  if (parsed.paths.length > maxPaths) {
@@ -661,7 +828,7 @@ async function compareCommand(argv: string[]): Promise<number> {
661
828
  const [basePath, candPath] = parsed.baseline
662
829
  ? [parsed.baseline, parsed.paths[0]]
663
830
  : parsed.paths;
664
- if (!basePath || !candPath) return showHelp(COMPARE_HELP, false);
831
+ if (!basePath || !candPath) return showHelp("compare", false);
665
832
 
666
833
  const [base, cand] = await orFail(
667
834
  "document-load-failed",
@@ -686,31 +853,41 @@ async function compareCommand(argv: string[]): Promise<number> {
686
853
  compared: result.compared,
687
854
  };
688
855
 
689
- // json/jsonl/minimal stay pure JSON on stdout, so only the human formats
690
- // get prose banners.
691
- const humanFormat =
692
- !parsed.quiet &&
693
- (parsed.format === "table" || parsed.format === "markdown");
694
- if (humanFormat) {
856
+ // json/jsonl/minimal stay pure JSON on stdout, so only markdown gets
857
+ // prose banners; the table puts the same facts in its context line.
858
+ if (!parsed.quiet && parsed.format === "markdown") {
695
859
  await out(`thresholds: ${thresholdsSource}\n`);
696
860
  if (base.git && cand.git) {
697
861
  await out(`base ${formatGit(base.git)} → cand ${formatGit(cand.git)}\n`);
698
862
  }
699
863
  }
864
+ const human = await humanFor(parsed);
700
865
 
701
866
  // Computed before rendering because `minimal`'s trailing `summary` event
702
867
  // carries it.
703
868
  const exitCode = gateExitCode(result.summary);
704
869
 
705
- await emitDocument(outDoc, parsed, {
706
- protocol: {
707
- command: "compare",
708
- exitCode,
709
- unmatched: result.unmatched,
710
- ...definedFields({ baseGit: base.git, candGit: cand.git }),
711
- ...(parsed.exportJson && { exportedTo: parsed.exportJson }),
712
- } satisfies MinimalProtocolContext,
713
- });
870
+ await emitDocument(
871
+ outDoc,
872
+ parsed,
873
+ {
874
+ protocol: {
875
+ command: "compare",
876
+ exitCode,
877
+ unmatched: result.unmatched,
878
+ ...definedFields({ baseGit: base.git, candGit: cand.git }),
879
+ ...(parsed.exportJson && { exportedTo: parsed.exportJson }),
880
+ } satisfies MinimalProtocolContext,
881
+ },
882
+ {
883
+ paint: human.paint,
884
+ compare: {
885
+ thresholds: thresholdsSource ?? "the config",
886
+ baseGit: base.git,
887
+ candGit: cand.git,
888
+ },
889
+ },
890
+ );
714
891
 
715
892
  if (result.summary.matched === 0) {
716
893
  await writeCliError(
@@ -728,10 +905,12 @@ interface ReportArgs extends ConfigArgs {
728
905
  measurementId?: string;
729
906
  outDir?: string;
730
907
  help: boolean;
908
+ color?: boolean;
731
909
  }
732
910
 
733
911
  const REPORT_FLAGS = {
734
912
  ...HELP_FLAGS,
913
+ ...COLOR_FLAGS,
735
914
  "--format": flag.oneOf("format", REPORT_FORMATS, FORMAT_ALIASES),
736
915
  "--measurement": flag.str("measurementId"),
737
916
  "--out-dir": flag.str("outDir"),
@@ -759,7 +938,7 @@ const NO_CPU_EVIDENCE =
759
938
 
760
939
  async function renderReport(
761
940
  path: string,
762
- { format, measurementId, outDir }: ReportArgs,
941
+ { format, measurementId, outDir, color }: ReportArgs,
763
942
  ): Promise<number> {
764
943
  const viz = VIZ_FORMATS.some((f) => f === format);
765
944
  const inapplicable = [
@@ -786,10 +965,12 @@ async function renderReport(
786
965
  throw new CliError("no-cpu-evidence", NO_CPU_EVIDENCE);
787
966
  }
788
967
 
789
- const result = await renderers[format].render(
790
- doc,
791
- definedFields({ measurementId }),
792
- );
968
+ const result =
969
+ format === "table"
970
+ ? await renderers.table.render(doc, {
971
+ paint: await paintFor(1, color),
972
+ })
973
+ : await renderers[format].render(doc, definedFields({ measurementId }));
793
974
  if (!result.text && (!result.files || result.files.length === 0)) {
794
975
  throw new CliError(
795
976
  "no-cpu-evidence",
@@ -804,7 +985,7 @@ async function renderReport(
804
985
 
805
986
  async function reportCommand(argv: string[]): Promise<number> {
806
987
  const parsed = parseReportArgs(argv);
807
- if (parsed.help || !parsed.path) return showHelp(REPORT_HELP, parsed.help);
988
+ if (parsed.help || !parsed.path) return showHelp("report", parsed.help);
808
989
  return renderReport(parsed.path, parsed);
809
990
  }
810
991
 
@@ -844,7 +1025,7 @@ function ciFailure(err: unknown): never {
844
1025
 
845
1026
  async function ciCommand(argv: string[]): Promise<number> {
846
1027
  const parsed = parseCiArgs(argv);
847
- if (parsed.help) return showHelp(CI_HELP, true);
1028
+ if (parsed.help) return showHelp("ci", true);
848
1029
 
849
1030
  const loaded = await requireConfig("ostia ci", parsed.config);
850
1031
  const config: OstiaConfig = parsed.noiseCheck
@@ -853,6 +1034,7 @@ async function ciCommand(argv: string[]): Promise<number> {
853
1034
 
854
1035
  // A saved baseline must be fresh measurements, never a cached run.
855
1036
  const full = parsed.full || parsed.saveBaseline;
1037
+ const human = await humanFor(parsed);
856
1038
  const { result: outcome, aborted } = await withSigintAbort(
857
1039
  "CI run failed",
858
1040
  (signal) =>
@@ -861,12 +1043,18 @@ async function ciCommand(argv: string[]): Promise<number> {
861
1043
  full,
862
1044
  ...definedFields({ baselineName: parsed.baseline }),
863
1045
  signal,
864
- }).catch(ciFailure),
1046
+ ...(human.progress !== SILENT && {
1047
+ onProgress: (step: string, doneRatio: number) =>
1048
+ human.progress.step(stepText(step), doneRatio),
1049
+ }),
1050
+ })
1051
+ .catch(ciFailure)
1052
+ .finally(() => human.progress.clear()),
865
1053
  );
866
1054
  const { document, summary } = outcome;
867
1055
  if (aborted) {
868
1056
  // Partial: no comparison, no gate, never a baseline.
869
- await emitDocument(document, parsed);
1057
+ await emitDocument(document, parsed, {}, { paint: human.paint });
870
1058
  return 130;
871
1059
  }
872
1060
  const baselineName = parsed.baseline ?? config.baseline;
@@ -897,10 +1085,23 @@ async function ciCommand(argv: string[]): Promise<number> {
897
1085
  if (jsonText !== undefined) {
898
1086
  await out(jsonText);
899
1087
  } else if (parsed.format === "table") {
900
- await out(renderCiReport(summary));
901
- if (document.comparisons && document.comparisons.length > 0) {
902
- await writeRenderResult(await renderers.table.render(document, {}));
903
- }
1088
+ const ci: NonNullable<TableOptions["ci"]> = {
1089
+ baseline: baselineName,
1090
+ workloads: summary.total,
1091
+ cached: summary.cached,
1092
+ executed: summary.executed,
1093
+ failed: summary.results
1094
+ .filter((r) => r.harnessFailed)
1095
+ .map((r) => workloadLabel(r.workload)),
1096
+ missingBaseline: summary.missingBaseline,
1097
+ };
1098
+ await writeRenderResult(
1099
+ await renderers.table.render(document, {
1100
+ paint: human.paint,
1101
+ elapsedMs: elapsedMsSince(human.startNs),
1102
+ ci,
1103
+ }),
1104
+ );
904
1105
  } else if (parsed.format === "markdown") {
905
1106
  await out(
906
1107
  `## ostia ci\n\nBaseline: \`${baselineName}\` (\`${baselineFile}\`) · ${summary.cached} cached, ${summary.executed} executed\n\n`,
@@ -994,7 +1195,7 @@ async function baselineSaveCommand(argv: string[]): Promise<number> {
994
1195
  help,
995
1196
  config: configPath,
996
1197
  } = parseBaselineArgs(argv, "baseline save", true);
997
- if (help) return showHelp(BASELINE_HELP, true);
1198
+ if (help) return showHelp("baseline", true);
998
1199
  if (name !== undefined) assertBaselineName(name);
999
1200
 
1000
1201
  const config = await requireConfig("ostia baseline save", configPath);
@@ -1008,7 +1209,7 @@ async function baselineListCommand(argv: string[]): Promise<number> {
1008
1209
  "baseline list",
1009
1210
  false,
1010
1211
  );
1011
- if (help) return showHelp(BASELINE_HELP, true);
1212
+ if (help) return showHelp("baseline", true);
1012
1213
 
1013
1214
  const config = await requireConfig(undefined, configPath);
1014
1215
  const infos = await listBaselines(config);
@@ -1027,7 +1228,7 @@ async function baselineListCommand(argv: string[]): Promise<number> {
1027
1228
 
1028
1229
  async function baselineShowCommand(argv: string[]): Promise<number> {
1029
1230
  const [name, ...rest] = argv;
1030
- if (!name || isHelpArg(name)) return showHelp(BASELINE_HELP, !!name);
1231
+ if (!name || isHelpArg(name)) return showHelp("baseline", !!name);
1031
1232
  assertBaselineName(name);
1032
1233
 
1033
1234
  const parsed = parseFlags<ReportArgs>(rest, {
@@ -1040,7 +1241,7 @@ async function baselineShowCommand(argv: string[]): Promise<number> {
1040
1241
  );
1041
1242
  },
1042
1243
  });
1043
- if (parsed.help) return showHelp(REPORT_HELP, true);
1244
+ if (parsed.help) return showHelp("report", true);
1044
1245
 
1045
1246
  const config = await requireConfig(undefined, parsed.config);
1046
1247
  const path = baselinePath(config, name);
@@ -1058,7 +1259,7 @@ async function dispatchSubcommand(
1058
1259
  sub: string | undefined,
1059
1260
  rest: string[],
1060
1261
  handlers: Record<string, Handler>,
1061
- help: string,
1262
+ help: HelpTopic,
1062
1263
  unknownMessage: (sub: string) => string,
1063
1264
  commandPrefix = "",
1064
1265
  ): Promise<number> {
@@ -1098,7 +1299,7 @@ function baselineCommand(argv: string[]): Promise<number> {
1098
1299
  list: baselineListCommand,
1099
1300
  show: baselineShowCommand,
1100
1301
  },
1101
- BASELINE_HELP,
1302
+ "baseline",
1102
1303
  (s) => `Unknown "ostia baseline ${s}". Run "ostia baseline --help".`,
1103
1304
  "baseline ",
1104
1305
  );
@@ -1128,7 +1329,7 @@ export async function main(): Promise<number> {
1128
1329
  ci: ciCommand,
1129
1330
  baseline: baselineCommand,
1130
1331
  },
1131
- MAIN_HELP,
1332
+ "main",
1132
1333
  (s) => `Unknown subcommand "${s}". Run "ostia --help".`,
1133
1334
  );
1134
1335
  }