bivium 0.5.1 → 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/README.md CHANGED
@@ -328,7 +328,7 @@ With `--json`, an error is also printed to stdout as JSON,
328
328
  so a pipeline that parses stdout gets an object either way:
329
329
 
330
330
  ```json
331
- { "schemaVersion": 1, "error": { "kind": "git", "message": "bivium: no commit nosuchref here to diff against: fetch it." } }
331
+ { "schemaVersion": 1, "error": { "kind": "git", "code": "BV_GIT_NO_BASE", "message": "bivium: no commit nosuchref here to diff against: fetch it." } }
332
332
  ```
333
333
 
334
334
  `kind` is `usage` (bivium was called wrong),
@@ -337,6 +337,11 @@ so a pipeline that parses stdout gets an object either way:
337
337
  lists every unknown key at once), `git`
338
338
  (the base or its history is missing, or git refused, in its own words)
339
339
  or `other`.
340
+ `code` names the failure, such as `BV_UNKNOWN_OPTION`
341
+ or `BV_CONFIG_INVALID`, and never changes meaning:
342
+ the `BiviumErrorCode` type lists them all, each with what it means.
343
+ From the library, `plan()` throws a `BiviumError` with the same `code`
344
+ and `kind`.
340
345
 
341
346
  ### From an agent
342
347
 
@@ -349,7 +354,7 @@ or `other`.
349
354
  - `bivium check --json` gives `ok` and a `summary` of what widens plans,
350
355
  then each node with a `fix`.
351
356
  - Read the exit status first: 0 done, 1 `check` found problems,
352
- 2 an error, with `error.kind` in the JSON.
357
+ 2 an error, with `error.kind` and `error.code` in the JSON.
353
358
 
354
359
  `why` names each edge by what spells it:
355
360
  `import`, `type`
package/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  version,
4
4
  githubOutputPath,
5
- BiviumError,
5
+ BiviumError2,
6
6
  didYouMean,
7
7
  globToRegExp,
8
8
  inRoot,
@@ -1253,10 +1253,12 @@ function unselected(config, computed, suite, from) {
1253
1253
  }
1254
1254
  async function explain(root, config, computed, test, from, { all = false } = {}) {
1255
1255
  const suite = config.suites.find((candidate) => candidate.isTest(test));
1256
- if (!suite)
1257
- throw new Error(`bivium why: ${test} is no suite's test`);
1258
- if (!computed.graph.has(test))
1259
- throw new Error(`bivium why: no file ${test}`);
1256
+ if (!suite) {
1257
+ throw new BiviumError2("BV_UNKNOWN_TEST", `bivium why: ${test} is no suite's test`);
1258
+ }
1259
+ if (!computed.graph.has(test)) {
1260
+ throw new BiviumError2("BV_UNKNOWN_FILE", `bivium why: no file ${test}`);
1261
+ }
1260
1262
  if (from === undefined && computed.plan.full.includes(suite.name)) {
1261
1263
  return { kind: "full", suite: suite.name, reasons: computed.plan.reasons };
1262
1264
  }
@@ -1542,14 +1544,14 @@ var POSITIONAL = {
1542
1544
  graph: 0
1543
1545
  };
1544
1546
  var SCHEMA_VERSION = 1;
1545
- function usageError(message) {
1546
- return new BiviumError("usage", message);
1547
+ function usageError(code, message) {
1548
+ return new BiviumError2(code, message);
1547
1549
  }
1548
1550
  function unknownOption(command, flag) {
1549
1551
  const known = FLAGS[command] ?? [];
1550
1552
  const others = Object.keys(FLAGS).filter((other) => other !== command && FLAGS[other]?.includes(flag));
1551
1553
  const hint = others.length > 0 ? ` (${others.join(" and ")} ${others.length === 1 ? "takes" : "take"} it)` : didYouMean(flag, known);
1552
- return usageError(`bivium ${command}: unknown option ${flag}${hint}`);
1554
+ return usageError("BV_UNKNOWN_OPTION", `bivium ${command}: unknown option ${flag}${hint}`);
1553
1555
  }
1554
1556
  function parseArgs(command, argv) {
1555
1557
  const known = FLAGS[command] ?? [];
@@ -1570,7 +1572,7 @@ function parseArgs(command, argv) {
1570
1572
  if (!VALUED.has(flag)) {
1571
1573
  const on = equals === -1 ? "true" : arg.slice(equals + 1);
1572
1574
  if (on !== "true" && on !== "false") {
1573
- throw usageError(`bivium ${command}: ${flag} is a switch: give it alone, or as ${flag}=true or ${flag}=false`);
1575
+ throw usageError("BV_BAD_OPTION_VALUE", `bivium ${command}: ${flag} is a switch: give it alone, or as ${flag}=true or ${flag}=false`);
1574
1576
  }
1575
1577
  if (on === "true")
1576
1578
  flags.set(flag, "");
@@ -1578,12 +1580,12 @@ function parseArgs(command, argv) {
1578
1580
  }
1579
1581
  const value = equals === -1 ? argv[++i] : arg.slice(equals + 1);
1580
1582
  if (value === undefined || value === "" || value.startsWith("--")) {
1581
- throw usageError(`bivium: ${flag} needs a value`);
1583
+ throw usageError("BV_BAD_OPTION_VALUE", `bivium: ${flag} needs a value`);
1582
1584
  }
1583
1585
  flags.set(flag, value);
1584
1586
  }
1585
1587
  if (positional.length > (POSITIONAL[command] ?? 0)) {
1586
- throw usageError(`bivium ${command}: unexpected ${positional.at(-1)}`);
1588
+ throw usageError("BV_UNEXPECTED_ARGUMENT", `bivium ${command}: unexpected ${positional.at(-1)}`);
1587
1589
  }
1588
1590
  return { flags, positional };
1589
1591
  }
@@ -1638,7 +1640,7 @@ function logPlan({ plan, narrowed }) {
1638
1640
  function githubOutput() {
1639
1641
  const output = githubOutputPath();
1640
1642
  if (!output) {
1641
- throw usageError("bivium plan: --github writes to $GITHUB_OUTPUT, which is not set (it is in a GitHub Actions step)");
1643
+ throw usageError("BV_NO_GITHUB_OUTPUT", "bivium plan: --github writes to $GITHUB_OUTPUT, which is not set (it is in a GitHub Actions step)");
1642
1644
  }
1643
1645
  return output;
1644
1646
  }
@@ -1646,7 +1648,7 @@ function writeOutputs(output, config, { plan }) {
1646
1648
  const lines = config.suites.map((suite) => {
1647
1649
  const selection = plan.suites[suite.name];
1648
1650
  if (selection === undefined) {
1649
- throw new Error(`bivium: plan: no selection for suite "${suite.name}".`);
1651
+ throw new BiviumError2("BV_INTERNAL", `bivium: plan: no selection for suite "${suite.name}".`);
1650
1652
  }
1651
1653
  return `${suite.output}=${formatSelection(selection)}
1652
1654
  `;
@@ -1663,7 +1665,7 @@ function findSuite(config, name) {
1663
1665
  if (suite)
1664
1666
  return suite;
1665
1667
  const names = config.suites.map((candidate) => candidate.name);
1666
- throw usageError(`bivium: no suite "${name}"${didYouMean(name, names)}; the config has ${names.join(", ")}`);
1668
+ throw usageError("BV_UNKNOWN_SUITE", `bivium: no suite "${name}"${didYouMean(name, names)}; the config has ${names.join(", ")}`);
1667
1669
  }
1668
1670
  function real(path) {
1669
1671
  try {
@@ -1692,16 +1694,16 @@ function repoPath(root, arg, known) {
1692
1694
  async function inspect(command, { flags, positional }) {
1693
1695
  const format = flags.get("--format") ?? "tree";
1694
1696
  if (format !== "json" && !isFormat(format)) {
1695
- throw usageError(`bivium why: --format takes tree, chain, source or json${didYouMean(format, ["tree", "chain", "source", "json"])}`);
1697
+ throw usageError("BV_BAD_OPTION_VALUE", `bivium why: --format takes tree, chain, source or json${didYouMean(format, ["tree", "chain", "source", "json"])}`);
1696
1698
  }
1697
1699
  const maxFlag = flags.get("--max-unknown");
1698
1700
  const max = maxFlag === undefined ? undefined : Number(maxFlag);
1699
1701
  if (max !== undefined && !Number.isInteger(max)) {
1700
- throw usageError("bivium check: --max-unknown takes a whole number");
1702
+ throw usageError("BV_BAD_OPTION_VALUE", "bivium check: --max-unknown takes a whole number");
1701
1703
  }
1702
1704
  const [testArg, fileArg] = positional;
1703
1705
  if (command === "why" && testArg === undefined) {
1704
- throw usageError("bivium why: which test? bivium why <test> [file]");
1706
+ throw usageError("BV_MISSING_ARGUMENT", "bivium why: which test? bivium why <test> [file]");
1705
1707
  }
1706
1708
  const { root, base, config } = await prepare({
1707
1709
  cwd: flags.get("--cwd"),
@@ -1723,10 +1725,10 @@ async function inspect(command, { flags, positional }) {
1723
1725
  const file = fileArg === undefined ? undefined : repoPath(root, fileArg, inGraph);
1724
1726
  if (!isTest(test) || !inGraph(test)) {
1725
1727
  const tests = [...computed.graph.keys()].filter(isTest);
1726
- throw usageError(inGraph(test) ? `bivium why: ${test} is no suite's test: name a test first, as in bivium why <test> ${test}` : `bivium why: no test ${test}${didYouMean(test, tests)}`);
1728
+ throw usageError(inGraph(test) ? "BV_UNKNOWN_TEST" : "BV_UNKNOWN_FILE", inGraph(test) ? `bivium why: ${test} is no suite's test: name a test first, as in bivium why <test> ${test}` : `bivium why: no test ${test}${didYouMean(test, tests)}`);
1727
1729
  }
1728
1730
  if (file !== undefined && !inGraph(file)) {
1729
- throw usageError(`bivium why: no file ${file}${didYouMean(file, computed.graph.keys())}`);
1731
+ throw usageError("BV_UNKNOWN_FILE", `bivium why: no file ${file}${didYouMean(file, computed.graph.keys())}`);
1730
1732
  }
1731
1733
  const explanation = await explain(root, config, computed, test, file, {
1732
1734
  all: flags.has("--all")
@@ -1737,7 +1739,7 @@ async function inspect(command, { flags, positional }) {
1737
1739
  async function graphCommand({ flags }) {
1738
1740
  const top = Number(flags.get("--top") ?? "10");
1739
1741
  if (!Number.isInteger(top) || top < 0) {
1740
- throw usageError("bivium graph: --top takes a whole number");
1742
+ throw usageError("BV_BAD_OPTION_VALUE", "bivium graph: --top takes a whole number");
1741
1743
  }
1742
1744
  const { root, base, config } = await prepare({
1743
1745
  cwd: flags.get("--cwd"),
@@ -1761,10 +1763,11 @@ async function runCommand(command, { flags, positional }) {
1761
1763
  configFile: flags.get("--config")
1762
1764
  });
1763
1765
  const suite = findSuite(config, flags.get("--suite")) ?? config.suites[0];
1764
- if (suite === undefined)
1765
- throw new BiviumError("config", "bivium: no suites");
1766
+ if (suite === undefined) {
1767
+ throw new BiviumError2("BV_CONFIG_INVALID", "bivium config: no suites");
1768
+ }
1766
1769
  if (command === "run" && !suite.run) {
1767
- throw usageError(`bivium run: suite "${suite.name}" has no run command: add suites.${suite.name}.run to the config`);
1770
+ throw usageError("BV_NO_RUN_COMMAND", `bivium run: suite "${suite.name}" has no run command: add suites.${suite.name}.run to the config`);
1768
1771
  }
1769
1772
  const computed = await computePlan(root, base, config, {
1770
1773
  ...flags.has("--no-cache") && { cache: false },
@@ -1807,7 +1810,7 @@ async function runCommand(command, { flags, positional }) {
1807
1810
  }
1808
1811
  const [program, ...args] = commandFor(suite.run ?? "", selection.mode === "some" ? selection.files : []);
1809
1812
  if (program === undefined) {
1810
- throw usageError(`bivium run: suite "${suite.name}" has no run command: add suites.${suite.name}.run to the config`);
1813
+ throw usageError("BV_NO_RUN_COMMAND", `bivium run: suite "${suite.name}" has no run command: add suites.${suite.name}.run to the config`);
1811
1814
  }
1812
1815
  const result = spawnSync(program, args, { cwd: root, stdio: "inherit" });
1813
1816
  return result.status ?? 1;
@@ -1828,10 +1831,12 @@ var COMMANDS = Object.keys(FLAGS);
1828
1831
  function wantsJson(argv) {
1829
1832
  return argv.some((arg, i) => arg === "--json" || arg === "--json=true" || arg === "--format=json" || arg === "--format" && argv[i + 1] === "json");
1830
1833
  }
1831
- function fail(argv, kind, message) {
1832
- console.error(message);
1833
- if (wantsJson(argv))
1834
- console.log(json({ error: { kind, message } }));
1834
+ function fail(argv, error) {
1835
+ console.error(error.message);
1836
+ if (wantsJson(argv)) {
1837
+ const { kind, code, message } = error;
1838
+ console.log(json({ error: { kind, code, message } }));
1839
+ }
1835
1840
  return 2;
1836
1841
  }
1837
1842
  async function main(argv) {
@@ -1850,10 +1855,10 @@ async function main(argv) {
1850
1855
  return 0;
1851
1856
  }
1852
1857
  if (command === undefined) {
1853
- return fail(argv, "usage", `bivium: which command? ${COMMANDS.join(", ")} (bivium --help for usage)`);
1858
+ return fail(argv, usageError("BV_MISSING_ARGUMENT", `bivium: which command? ${COMMANDS.join(", ")} (bivium --help for usage)`));
1854
1859
  }
1855
1860
  if (!(command in FLAGS)) {
1856
- return fail(argv, "usage", `bivium: unknown command "${command}"${didYouMean(command, COMMANDS)}; the commands are ${COMMANDS.join(", ")} (bivium --help for usage)`);
1861
+ return fail(argv, usageError("BV_UNKNOWN_COMMAND", `bivium: unknown command "${command}"${didYouMean(command, COMMANDS)}; the commands are ${COMMANDS.join(", ")} (bivium --help for usage)`));
1857
1862
  }
1858
1863
  const rest = [...argv.slice(0, at), ...argv.slice(at + 1)];
1859
1864
  try {
@@ -1864,11 +1869,10 @@ async function main(argv) {
1864
1869
  return await graphCommand(args);
1865
1870
  return await runCommand(command, args);
1866
1871
  } catch (error) {
1867
- if (error instanceof BiviumError) {
1868
- return fail(argv, error.kind, error.message);
1869
- }
1872
+ if (error instanceof BiviumError2)
1873
+ return fail(argv, error);
1870
1874
  const message = error instanceof Error ? error.message : String(error);
1871
- return fail(argv, "other", message);
1875
+ return fail(argv, new BiviumError2("BV_INTERNAL", message, { cause: error }));
1872
1876
  }
1873
1877
  }
1874
1878
 
package/index.d.ts CHANGED
@@ -278,3 +278,55 @@ export interface FullRunCause<Suite extends string = string> {
278
278
  }
279
279
  /** Types a config. Returns it unchanged. */
280
280
  export declare function defineConfig<Suite extends string>(config: Config<Suite>): Config<Suite>;
281
+ /** An error bivium names: its `code` says which failure, its `kind` what to do. */
282
+ export declare class BiviumError extends Error {
283
+ readonly code: BiviumErrorCode;
284
+ readonly kind: BiviumErrorKind;
285
+ constructor(code: BiviumErrorCode, message: string, options?: ErrorOptions);
286
+ }
287
+ /**
288
+ * Which failure it is, stable across releases: a code is never reused for
289
+ * another meaning, and `--json` prints it as `error.code`.
290
+ */
291
+ export type BiviumErrorCode =
292
+ /** No command, or `why` without a test. */
293
+ "BV_MISSING_ARGUMENT"
294
+ /** A command bivium doesn't have. */
295
+ | "BV_UNKNOWN_COMMAND"
296
+ /** An option the command doesn't take. */
297
+ | "BV_UNKNOWN_OPTION"
298
+ /** An option's value is missing or of the wrong form. */
299
+ | "BV_BAD_OPTION_VALUE"
300
+ /** More arguments than the command takes. */
301
+ | "BV_UNEXPECTED_ARGUMENT"
302
+ /** A suite the config doesn't define. */
303
+ | "BV_UNKNOWN_SUITE"
304
+ /** A path that is no suite's test. */
305
+ | "BV_UNKNOWN_TEST"
306
+ /** A path that names no file of the graph. */
307
+ | "BV_UNKNOWN_FILE"
308
+ /** `run` for a suite with no `run` command. */
309
+ | "BV_NO_RUN_COMMAND"
310
+ /** `plan --github` outside a GitHub Actions step. */
311
+ | "BV_NO_GITHUB_OUTPUT"
312
+ /** No config file where bivium looked. */
313
+ | "BV_CONFIG_NOT_FOUND"
314
+ /** The config file failed to load: a syntax error, or one it throws. */
315
+ | "BV_CONFIG_UNREADABLE"
316
+ /** The config loaded, but a key is unknown or a value is invalid. */
317
+ | "BV_CONFIG_INVALID"
318
+ /** The base to diff against isn't here, or there's no default branch. */
319
+ | "BV_GIT_NO_BASE"
320
+ /** The base and HEAD share no commit here. */
321
+ | "BV_GIT_NO_MERGE_BASE"
322
+ /** A git command failed; the message carries git's own words. */
323
+ | "BV_GIT_FAILED"
324
+ /** A failure bivium didn't anticipate: a bug, or the environment. */
325
+ | "BV_INTERNAL";
326
+ /**
327
+ * What a caller does about an error: `usage`, bivium was called wrong;
328
+ * `config`, the config can't be found, read, or is invalid; `git`, git
329
+ * refused or the history is missing; `other`, a failure bivium didn't
330
+ * name. Every kind exits 2.
331
+ */
332
+ export type BiviumErrorKind = "usage" | "config" | "git" | "other";
package/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import {
2
+ BiviumError2,
2
3
  defineConfig2,
3
4
  plan2
4
5
  } from "./shared.js";
5
6
  export {
7
+ BiviumError2 as BiviumError,
6
8
  defineConfig2 as defineConfig,
7
9
  plan2 as plan
8
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bivium",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Run only the tests a change can affect, and never miss one.",
5
5
  "license": "MIT",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
package/shared.js CHANGED
@@ -8,7 +8,7 @@ import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
8
8
  import { isAbsolute, join } from "node:path";
9
9
 
10
10
  // package.json
11
- var version = "0.5.1";
11
+ var version = "0.6.0";
12
12
 
13
13
  // src/env.ts
14
14
  function githubOutputPath() {
@@ -247,11 +247,33 @@ import { isAbsolute as isAbsolute2, join as join2, relative, resolve } from "nod
247
247
  import { pathToFileURL } from "node:url";
248
248
 
249
249
  // src/errors.ts
250
- class BiviumError extends Error {
250
+ var KINDS = {
251
+ BV_MISSING_ARGUMENT: "usage",
252
+ BV_UNKNOWN_COMMAND: "usage",
253
+ BV_UNKNOWN_OPTION: "usage",
254
+ BV_BAD_OPTION_VALUE: "usage",
255
+ BV_UNEXPECTED_ARGUMENT: "usage",
256
+ BV_UNKNOWN_SUITE: "usage",
257
+ BV_UNKNOWN_TEST: "usage",
258
+ BV_UNKNOWN_FILE: "usage",
259
+ BV_NO_RUN_COMMAND: "usage",
260
+ BV_NO_GITHUB_OUTPUT: "usage",
261
+ BV_CONFIG_NOT_FOUND: "config",
262
+ BV_CONFIG_UNREADABLE: "config",
263
+ BV_CONFIG_INVALID: "config",
264
+ BV_GIT_NO_BASE: "git",
265
+ BV_GIT_NO_MERGE_BASE: "git",
266
+ BV_GIT_FAILED: "git",
267
+ BV_INTERNAL: "other"
268
+ };
269
+
270
+ class BiviumError2 extends Error {
271
+ code;
251
272
  kind;
252
- constructor(kind, message, options) {
273
+ constructor(code, message, options) {
253
274
  super(message, options);
254
- this.kind = kind;
275
+ this.code = code;
276
+ this.kind = KINDS[code];
255
277
  }
256
278
  }
257
279
  function distance(a, b) {
@@ -758,16 +780,25 @@ var CONFIG_PREFIX = /^bivium config: /;
758
780
  async function loadConfig(root, path) {
759
781
  const file = path === undefined ? CONFIG_FILES.map((name) => join2(root, name)).find((f) => existsSync2(f)) : resolve(process.cwd(), path);
760
782
  if (!file || !existsSync2(file)) {
761
- throw new BiviumError("config", path ? `bivium: no config found at ${path}` : `bivium: no config found in ${root}: looked for ${CONFIG_FILES.join(", ")} (--config names another file, --cwd another repository)`);
783
+ throw new BiviumError2("BV_CONFIG_NOT_FOUND", path ? `bivium: no config found at ${path}` : `bivium: no config found in ${root}: looked for ${CONFIG_FILES.join(", ")} (--config names another file, --cwd another repository)`);
762
784
  }
763
785
  const inside = relative(root, file);
764
786
  const shown = inside.startsWith("..") || isAbsolute2(inside) ? file : inside;
787
+ const named = (code, error) => {
788
+ const message = error instanceof Error ? error.message : String(error);
789
+ return new BiviumError2(code, `bivium config: ${shown}: ${message.replace(CONFIG_PREFIX, "")}`, { cause: error });
790
+ };
791
+ let raw;
792
+ try {
793
+ raw = await readConfig(file);
794
+ } catch (error) {
795
+ throw named("BV_CONFIG_UNREADABLE", error);
796
+ }
765
797
  let config;
766
798
  try {
767
- config = resolveConfig(checkConfig(await readConfig(file)));
799
+ config = resolveConfig(checkConfig(raw));
768
800
  } catch (error) {
769
- const message = error instanceof Error ? error.message : String(error);
770
- throw new BiviumError("config", `bivium config: ${shown}: ${message.replace(CONFIG_PREFIX, "")}`, { cause: error });
801
+ throw named("BV_CONFIG_INVALID", error);
771
802
  }
772
803
  return { config, file: shown };
773
804
  }
@@ -810,7 +841,7 @@ async function gitOrThrow(cwd, ...args) {
810
841
  if (result.status !== 0) {
811
842
  const said = result.stderr.trim().split(`
812
843
  `)[0];
813
- throw new BiviumError("git", `bivium: git ${args.join(" ")} failed${said ? `: ${said}` : ""}`);
844
+ throw new BiviumError2("BV_GIT_FAILED", `bivium: git ${args.join(" ")} failed${said ? `: ${said}` : ""}`);
814
845
  }
815
846
  return result.stdout;
816
847
  }
@@ -828,10 +859,10 @@ async function missingHistory(cwd, base) {
828
859
  ]);
829
860
  const fix = shallow.stdout.trim() === "true" ? " The clone is shallow: fetch the history (actions/checkout: `fetch-depth: 0`)." : "";
830
861
  if (known.status !== 0) {
831
- return new BiviumError("git", `bivium: no commit ${base} here to diff against: fetch it.${fix}`);
862
+ return new BiviumError2("BV_GIT_NO_BASE", `bivium: no commit ${base} here to diff against: fetch it.${fix}`);
832
863
  }
833
864
  if (forked.status !== 0) {
834
- return new BiviumError("git", `bivium: ${base} and HEAD share no commit here, so there's no merge base to diff against.${fix}`);
865
+ return new BiviumError2("BV_GIT_NO_MERGE_BASE", `bivium: ${base} and HEAD share no commit here, so there's no merge base to diff against.${fix}`);
835
866
  }
836
867
  return;
837
868
  }
@@ -959,7 +990,7 @@ async function defaultBase(cwd) {
959
990
  const branch = refs[found.findIndex((result) => result.status === 0)];
960
991
  if (branch)
961
992
  return branch;
962
- throw new BiviumError("git", `bivium: no base given and no default branch found (tried origin/HEAD, ${refs.join(", ")}): pass one, as in \`bivium plan origin/main\`, or set base in the config`);
993
+ throw new BiviumError2("BV_GIT_NO_BASE", `bivium: no base given and no default branch found (tried origin/HEAD, ${refs.join(", ")}): pass one, as in \`bivium plan origin/main\`, or set base in the config`);
963
994
  }
964
995
 
965
996
  // src/barrel.ts
@@ -4610,8 +4641,9 @@ function graphView(graph, config) {
4610
4641
  dependents: (from) => affectedBy(graph, from, { includeUnknown: false }),
4611
4642
  tests: (name) => {
4612
4643
  const suite = config.suites.find((candidate) => candidate.name === name);
4613
- if (!suite)
4614
- throw new Error(`bivium: no suite "${name}"`);
4644
+ if (!suite) {
4645
+ throw new BiviumError2("BV_UNKNOWN_SUITE", `bivium: no suite "${name}"`);
4646
+ }
4615
4647
  return nodes.filter(suite.isTest);
4616
4648
  }
4617
4649
  };
@@ -4784,4 +4816,4 @@ async function plan2(options = {}) {
4784
4816
  };
4785
4817
  }
4786
4818
 
4787
- export { version, githubOutputPath, BiviumError, didYouMean, globToRegExp, defineConfig2, inRoot, sorted, QUERY, UNDECLARED_READS, RELATIVE, aliasPath, createResolver, SCANNED, formatOf, extract, stringsOf, finish, gotoPage, walksByTypes, importersOf, affectedBy, formatSelection, orphanOf, plural, computePlan, prepare, plan2 };
4819
+ export { version, githubOutputPath, BiviumError2, didYouMean, globToRegExp, defineConfig2, inRoot, sorted, QUERY, UNDECLARED_READS, RELATIVE, aliasPath, createResolver, SCANNED, formatOf, extract, stringsOf, finish, gotoPage, walksByTypes, importersOf, affectedBy, formatSelection, orphanOf, plural, computePlan, prepare, plan2 };