@kaynooo/cli-base 0.5.1 → 0.7.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/dist/cli.js CHANGED
@@ -2,13 +2,34 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process10 from "process";
5
+ import process14 from "process";
6
6
  // ../kit/src/args.ts
7
- import process4 from "process";
7
+ import process6 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
- // ../kit/src/style.ts
10
+ // ../kit/src/format.ts
11
+ import process4 from "process";
12
+
13
+ // ../kit/src/mode.ts
11
14
  import process2 from "process";
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
29
+ }
30
+
31
+ // ../kit/src/style.ts
32
+ import process3 from "process";
12
33
 
13
34
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
35
  function x(s) {
@@ -271,21 +292,26 @@ function le(i = {}) {
271
292
  }
272
293
  var t = le();
273
294
 
295
+ // ../kit/src/theme.ts
296
+ var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
297
+ var MAX_FILE_BYTES = 64 * 1024;
298
+ var warned = new Set;
299
+
274
300
  // ../kit/src/style.ts
275
- function takesControlCodes(stream, env = process2.env) {
276
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
301
+ function takesControlCodes(stream, env = process3.env) {
302
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
277
303
  }
278
- function paint(stream, env = process2.env) {
304
+ function paint(stream, env = process3.env) {
279
305
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
280
306
  }
281
- var STATUSES = {
282
- passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
283
- failed: { symbol: "\u2717", words: ["failed", "failure", "error", "errored"], paint: (colors) => colors.red },
284
- running: { symbol: "\u25CF", words: ["running", "in_progress", "started"], paint: (colors) => colors.cyan },
285
- queued: { symbol: "\u25CB", words: ["queued", "waiting", "pending", "created", "blocked", "scheduled"], paint: (colors) => colors.yellow },
286
- skipped: { symbol: "-", words: ["skipped", "cancelled", "canceled", "manual"], paint: (colors) => colors.dim }
307
+ var STATUS_WORDS = {
308
+ passed: ["passed", "success", "succeeded", "ok"],
309
+ failed: ["failed", "failure", "error", "errored"],
310
+ running: ["running", "in_progress", "started", "holding"],
311
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
312
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
287
313
  };
288
- var STATUS_OF = new Map(Object.entries(STATUSES).flatMap(([status, { words }]) => words.map((word) => [word, status])));
314
+ var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
289
315
 
290
316
  // ../kit/src/format.ts
291
317
  function upTo(text, separator) {
@@ -293,32 +319,35 @@ function upTo(text, separator) {
293
319
  return end === -1 ? text : text.slice(0, end);
294
320
  }
295
321
  var ESCAPE = String.fromCharCode(27);
322
+ function jsonText(value, replacer, { stream = process4.stdout, env = process4.env } = {}) {
323
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
324
+ }
296
325
  function printJson(value) {
297
- console.log(JSON.stringify(value, undefined, 2));
326
+ console.log(jsonText(value));
298
327
  }
299
328
 
300
329
  // ../kit/src/help.ts
301
- import process3 from "process";
330
+ import process5 from "process";
302
331
  var OPTIONAL = /\[[^\]]+\]/g;
303
332
  var USAGE_PREFIX = /^usage:\s*/i;
304
333
  var FULL_STOP = /\.$/;
305
- function usageLine(usage, colors = paint(process3.stdout)) {
334
+ function usageLine(usage, colors = paint(process5.stdout)) {
306
335
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
307
336
  }
308
- function helpText(usage, options, colors = paint(process3.stdout), { examples = [], replaces, exits = [] } = {}) {
337
+ function helpText(usage, options, colors = paint(process5.stdout), { examples = [], replaces, exits = [] } = {}) {
309
338
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
310
339
  `);
311
340
  }
312
- function exitRows(exits, colors = paint(process3.stdout)) {
341
+ function exitRows(exits, colors = paint(process5.stdout)) {
313
342
  if (exits.length === 0)
314
343
  return [];
315
344
  const width = Math.max(...exits.map(([code]) => String(code).length));
316
345
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
317
346
  }
318
- function replacesRows(replaces, colors = paint(process3.stdout)) {
319
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
347
+ function replacesRows(replaces, colors = paint(process5.stdout)) {
348
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
320
349
  }
321
- function wantsHelpJson(env = process3.env) {
350
+ function wantsHelpJson(env = process5.env) {
322
351
  return env.KIT_HELP === "json";
323
352
  }
324
353
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -337,12 +366,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
337
366
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
338
367
  };
339
368
  }
340
- function exampleRows(examples, colors = paint(process3.stdout)) {
341
- if (examples.length === 0)
369
+ function exampleRows(examples, colors = paint(process5.stdout)) {
370
+ if (examples.length === 0 || outputMode() === "agent")
342
371
  return [];
343
372
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
344
373
  }
345
- function optionRows(options, colors = paint(process3.stdout)) {
374
+ function optionRows(options, colors = paint(process5.stdout)) {
346
375
  const rows = Object.entries(options).map(([name, option]) => {
347
376
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
348
377
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -389,7 +418,6 @@ var DASHES = /^-+/;
389
418
  function jsonOption(holds) {
390
419
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
391
420
  }
392
-
393
421
  class Exit extends Error {
394
422
  code;
395
423
  hint;
@@ -433,7 +461,7 @@ var OUTPUT_OPTIONS = {
433
461
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
434
462
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
435
463
  };
436
- function applyOutput(color, plain, env = process4.env) {
464
+ function applyOutput(color, plain, env = process6.env) {
437
465
  const when = plain === true ? "never" : color ?? "auto";
438
466
  if (when === "auto")
439
467
  return;
@@ -604,7 +632,7 @@ function nearestOption(message, options, allowNegative) {
604
632
  }
605
633
  // ../kit/src/process.ts
606
634
  import { constants } from "os";
607
- import process5 from "process";
635
+ import process7 from "process";
608
636
  var KILL_GRACE_MS = 2000;
609
637
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
610
638
  function exitCodeOf(code, signal) {
@@ -626,7 +654,7 @@ function holdSignals(cleanup) {
626
654
  },
627
655
  release: () => {
628
656
  for (const signal of SIGNALS)
629
- process5.off(signal, onSignal);
657
+ process7.off(signal, onSignal);
630
658
  }
631
659
  };
632
660
  function onSignal(signal) {
@@ -639,10 +667,10 @@ function holdSignals(cleanup) {
639
667
  return;
640
668
  held.release();
641
669
  cleanup(signal);
642
- process5.kill(process5.pid, signal);
670
+ process7.kill(process7.pid, signal);
643
671
  }
644
672
  for (const signal of SIGNALS)
645
- process5.on(signal, onSignal);
673
+ process7.on(signal, onSignal);
646
674
  return held;
647
675
  }
648
676
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -656,7 +684,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
656
684
  return;
657
685
  try {
658
686
  if (grouped)
659
- process5.kill(-proc.pid, killing);
687
+ process7.kill(-proc.pid, killing);
660
688
  else
661
689
  proc.kill(killing);
662
690
  } catch {}
@@ -732,13 +760,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
732
760
  // ../kit/src/cli.ts
733
761
  import { readFileSync, realpathSync } from "fs";
734
762
  import { dirname as dirname2, join as join2 } from "path";
735
- import process7 from "process";
763
+ import process9 from "process";
736
764
 
737
765
  // ../kit/src/usage.ts
738
766
  import { appendFileSync, mkdirSync } from "fs";
739
767
  import { homedir } from "os";
740
768
  import { dirname, isAbsolute, join } from "path";
741
- import process6 from "process";
769
+ import process8 from "process";
742
770
 
743
771
  // ../kit/src/logs.ts
744
772
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -752,14 +780,14 @@ var usageError;
752
780
  function noteUsageError(message) {
753
781
  usageError = message;
754
782
  }
755
- function stateHome(env = process6.env) {
783
+ function stateHome(env = process8.env) {
756
784
  const dir = env.XDG_STATE_HOME;
757
785
  return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
758
786
  }
759
- function usagePath(env = process6.env) {
787
+ function usagePath(env = process8.env) {
760
788
  return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
761
789
  }
762
- function usageRecorded(env = process6.env) {
790
+ function usageRecorded(env = process8.env) {
763
791
  const off = env.KAYNOOO_CLI_NO_USAGE;
764
792
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
765
793
  }
@@ -773,7 +801,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
773
801
  usageError = undefined;
774
802
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
775
803
  }
776
- function recordUsage(entry, env = process6.env) {
804
+ function recordUsage(entry, env = process8.env) {
777
805
  if (!usageRecorded(env))
778
806
  return;
779
807
  try {
@@ -790,9 +818,82 @@ var LEVEL_OPTIONS = {
790
818
  help: { type: "boolean", short: "h", description: "show this help" }
791
819
  };
792
820
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
821
+ async function commandRows(all, colors) {
822
+ const commands = shown(all);
823
+ const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
824
+ const groups = new Map([["Commands:", []]]);
825
+ const summaries = await Promise.all(Object.values(commands).map(async ({ summary }) => resolveSummary(summary)));
826
+ for (const [index, [name, { group }]] of Object.entries(commands).entries()) {
827
+ const heading = group === undefined ? "Commands:" : `${group}:`;
828
+ const rows = groups.get(heading) ?? [];
829
+ rows.push(` ${colors.cyan(name.padEnd(width))} ${colors.dim(summaries[index])}`);
830
+ groups.set(heading, rows);
831
+ }
832
+ return [...groups].filter(([, rows]) => rows.length > 0).flatMap(([heading, rows], index) => [...index === 0 ? [] : [""], colors.bold(heading), ...rows]);
833
+ }
834
+ function shown(commands) {
835
+ return Object.fromEntries(Object.entries(commands).filter(([, { hidden }]) => hidden !== true));
836
+ }
837
+ function takeOutputFlags(argv) {
838
+ let index = 0;
839
+ for (;index < argv.length; index++) {
840
+ const word = argv[index];
841
+ if (word === "--plain")
842
+ applyOutput(undefined, true);
843
+ else if (word.startsWith("--color="))
844
+ applyOutput(word.slice("--color=".length), undefined);
845
+ else if (word === "--color" && argv[index + 1] !== undefined)
846
+ applyOutput(argv[++index], undefined);
847
+ else
848
+ break;
849
+ }
850
+ return argv.slice(index);
851
+ }
852
+ async function resolveSummary(summary) {
853
+ return typeof summary === "string" ? summary : summary();
854
+ }
855
+ function scopeOf(commands, extra, aliases) {
856
+ return { commands: typeof commands === "function" ? {} : commands, lazy: [...typeof commands === "function" ? [commands] : [], ...extra === undefined ? [] : [extra]], aliases };
857
+ }
858
+ async function expand(scope, words) {
859
+ if (scope.lazy.length === 0)
860
+ return scope;
861
+ const commands = { ...scope.commands };
862
+ for (const added of await Promise.all(scope.lazy.map(async (lazy) => lazy(words)))) {
863
+ for (const [name, command] of Object.entries(added))
864
+ commands[name] ??= command;
865
+ }
866
+ return { ...scope, commands, lazy: [] };
867
+ }
868
+ async function help2({ path, header, summary: lazySummary, commands, defaultCommand, examples, replaces }, stream) {
869
+ const colors = paint(stream);
870
+ const prefix = path.join(" ");
871
+ const summary = await resolveSummary(lazySummary);
872
+ if (wantsHelpJson())
873
+ return JSON.stringify(description(`${prefix} <command> [options]: ${summary}`, { examples, replaces }));
874
+ const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
875
+ const options = fallback !== undefined && "run" in fallback ? await optionsOf(fallback.run) : undefined;
876
+ const own = Object.entries(options ?? {}).filter(([name]) => !(name in TOP_OPTIONS));
877
+ return [
878
+ header(colors, summary),
879
+ "",
880
+ usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
881
+ ...replacesRows(replaces, colors),
882
+ "",
883
+ ...await commandRows(commands, colors),
884
+ ...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
885
+ "",
886
+ colors.bold("Options:"),
887
+ ...optionRows(path.length === 1 ? TOP_OPTIONS : LEVEL_OPTIONS, colors),
888
+ ...exampleRows(examples ?? [], colors),
889
+ "",
890
+ `${colors.dim("Run")} ${prefix} ${colors.cyan("<command>")} --help ${colors.dim("for its options.")}`
891
+ ].join(`
892
+ `);
893
+ }
793
894
  function printError(prefix, message, hint, cause) {
794
- const colors = paint(process7.stderr);
795
- const styled = takesControlCodes(process7.stderr);
895
+ const colors = paint(process9.stderr);
896
+ const styled = takesControlCodes(process9.stderr);
796
897
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
797
898
  const under = (label, text, tint) => text === undefined ? "" : `
798
899
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -811,12 +912,68 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
811
912
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
812
913
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
813
914
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
814
- if (error instanceof UsageError)
915
+ if (error instanceof Exit && error.code === 2)
815
916
  noteUsageError(error.message);
816
917
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
817
918
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
818
919
  return error instanceof Exit ? error.code : 1;
819
920
  }
921
+ async function dispatch(level, typed, { version, redact }) {
922
+ const prefix = level.path.join(" ");
923
+ let argv;
924
+ try {
925
+ argv = takeOutputFlags(typed);
926
+ } catch (error) {
927
+ return reportThrown(prefix, error);
928
+ }
929
+ const [name, ...args] = argv;
930
+ const fallback = level.defaultCommand === undefined ? undefined : level.commands[level.defaultCommand];
931
+ if (name === undefined && level.runBare && fallback !== undefined && "run" in fallback) {
932
+ try {
933
+ return await fallback.run([]);
934
+ } catch (error) {
935
+ return reportThrown(`${prefix} ${level.defaultCommand}`, error, redact, false);
936
+ }
937
+ }
938
+ if (name === undefined && level.path.length > 1) {
939
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stderr));
940
+ return 2;
941
+ }
942
+ if (name === undefined || name === "help" || name === "--help" || name === "-h") {
943
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stdout));
944
+ return 0;
945
+ }
946
+ if (level.path.length === 1 && (name === "--version" || name === "-v")) {
947
+ console.log(version);
948
+ return 0;
949
+ }
950
+ let command = level.commands[level.aliases?.[name] ?? name];
951
+ let rest = args;
952
+ let ran = name;
953
+ if (command === undefined && level.lazy.length > 0) {
954
+ level = await expand(level, [...level.path.slice(1), ...argv]);
955
+ command = level.commands[level.aliases?.[name] ?? name];
956
+ }
957
+ if (command === undefined && level.defaultCommand !== undefined) {
958
+ command = level.commands[level.defaultCommand];
959
+ rest = argv;
960
+ ran = level.defaultCommand;
961
+ }
962
+ if (command === undefined) {
963
+ const meant = closest(name, Object.keys(shown(level.commands)));
964
+ printError(prefix, `no command ${name}`, meant === undefined ? `run ${prefix} --help for its commands` : `did you mean ${meant}?`);
965
+ return 2;
966
+ }
967
+ if ("commands" in command) {
968
+ const { summary } = command;
969
+ return dispatch({ path: [...level.path, name], header: (colors, text) => `${colors.bold(`${prefix} ${name}`)} ${text}`, summary, ...scopeOf(command.commands, command.extraCommands, command.aliases), defaultCommand: undefined, runBare: false, examples: command.examples, replaces: undefined }, rest, { version, redact });
970
+ }
971
+ try {
972
+ return await command.run(rest);
973
+ } catch (error) {
974
+ return reportThrown(`${prefix} ${ran}`, error, redact, wantsJson(rest));
975
+ }
976
+ }
820
977
  var COMPLETE = "__complete";
821
978
  var FILES = "__files__";
822
979
  async function completingOf(run) {
@@ -831,6 +988,9 @@ async function completingOf(run) {
831
988
  }
832
989
  return new Completing({});
833
990
  }
991
+ async function optionsOf(run) {
992
+ return (await completingOf(run)).options;
993
+ }
834
994
  function candidateLine(candidate) {
835
995
  return typeof candidate === "string" ? candidate : candidate.join("\t");
836
996
  }
@@ -869,6 +1029,28 @@ async function leafCandidates(run, words) {
869
1029
  const values = name === undefined ? undefined : await completing.candidates[name]?.();
870
1030
  return values === undefined ? [FILES] : values.map(candidateLine);
871
1031
  }
1032
+ async function candidates(scope, defaultCommand, words, before = []) {
1033
+ const [word = "", ...rest] = words;
1034
+ const listing = rest.length === 0 && !word.startsWith("-");
1035
+ let { commands, aliases } = scope;
1036
+ let command = commands[aliases?.[word] ?? word];
1037
+ if (listing || command === undefined) {
1038
+ ({ commands, aliases } = await expand(scope, [...before, ...words]));
1039
+ command = commands[aliases?.[word] ?? word];
1040
+ }
1041
+ if (listing) {
1042
+ const own = await Promise.all(Object.entries(shown(commands)).map(async ([name, { summary }]) => `${name} ${await resolveSummary(summary)}`));
1043
+ const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
1044
+ const values = fallback !== undefined && "run" in fallback ? await leafCandidates(fallback.run, [word]) : [];
1045
+ const valueOf = (line) => line.slice(0, line.includes("\t") ? line.indexOf("\t") : undefined);
1046
+ return [...own, ...values.filter((line) => line !== FILES && !(valueOf(line) in commands))];
1047
+ }
1048
+ if (command === undefined) {
1049
+ const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
1050
+ return fallback !== undefined && "run" in fallback ? leafCandidates(fallback.run, words) : [];
1051
+ }
1052
+ return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
1053
+ }
872
1054
  async function printCandidates(found) {
873
1055
  for (const line of await found)
874
1056
  console.log(line);
@@ -885,7 +1067,34 @@ function packageVersion(entry = Bun.main) {
885
1067
  return "0.0.0";
886
1068
  }
887
1069
  }
888
- async function runMain({ name, version, run, redact, usage }, argv = process7.argv.slice(2)) {
1070
+ async function runCli(cli, argv = process9.argv.slice(2)) {
1071
+ const version = cli.version ?? packageVersion();
1072
+ if (argv[0] === COMPLETE)
1073
+ return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
1074
+ const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
1075
+ if (cli.usage !== false) {
1076
+ try {
1077
+ recordUsage(usageEntry(cli.name, commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv), argv, code));
1078
+ } catch {}
1079
+ }
1080
+ return code;
1081
+ }
1082
+ function commandPath(scope, argv) {
1083
+ const path = [];
1084
+ let level = scope;
1085
+ for (const word of argv.filter((each) => !each.startsWith("-"))) {
1086
+ const name = level.aliases !== undefined && Object.hasOwn(level.aliases, word) ? level.aliases[word] ?? word : word;
1087
+ const command = Object.hasOwn(level.commands, name) ? level.commands[name] : undefined;
1088
+ if (command === undefined)
1089
+ break;
1090
+ path.push(word);
1091
+ if (!("commands" in command))
1092
+ break;
1093
+ level = scopeOf(command.commands, command.extraCommands, command.aliases);
1094
+ }
1095
+ return path.length === 0 ? undefined : path.join(" ");
1096
+ }
1097
+ async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
889
1098
  if (argv[0] === COMPLETE)
890
1099
  return printCandidates(leafCandidates(run, argv.slice(1)));
891
1100
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -911,12 +1120,16 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
911
1120
  var {Glob } = globalThis.Bun;
912
1121
  var SESSION_FILES = new Glob("*.json");
913
1122
  var ACCOUNT_DIRS = new Glob("*/sessions");
1123
+ // src/base.ts
1124
+ import process12 from "process";
1125
+
914
1126
  // src/worktree.ts
915
1127
  import { cpSync, existsSync, lstatSync, mkdirSync as mkdirSync2, mkdtempSync, readdirSync, realpathSync as realpathSync2, rmSync, symlinkSync, unlinkSync } from "fs";
916
1128
  import { tmpdir } from "os";
917
1129
  import { basename, dirname as dirname3, isAbsolute as isAbsolute2, join as join3, relative, resolve, sep } from "path";
918
- import process9 from "process";
1130
+ import process11 from "process";
919
1131
  var WHITESPACE = /\s/;
1132
+ var ORIGIN_PREFIX = /^origin\//;
920
1133
  var ENV_FILE = /^\.env(?:\..+)?$/;
921
1134
  var DEPENDENCIES = new Set(["node_modules", "vendor", ".venv"]);
922
1135
  var TRAILING_SLASH = /\/$/;
@@ -946,11 +1159,16 @@ async function resolveRef(root, ref) {
946
1159
  fail(`no commit ${ref} in this repository`);
947
1160
  return stdoutOf(ran);
948
1161
  }
1162
+ async function defaultRemoteRef(root) {
1163
+ const head = await git2(["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"], root);
1164
+ return head.code === 0 && stdoutOf(head) !== "" ? stdoutOf(head) : "origin/main";
1165
+ }
949
1166
  async function defaultProofRef(root) {
950
1167
  const branch = await git2(["symbolic-ref", "--quiet", "--short", "HEAD"], root);
951
- if (branch.code !== 0 || stdoutOf(branch) === "main")
1168
+ const remote = await defaultRemoteRef(root);
1169
+ if (branch.code !== 0 || stdoutOf(branch) === remote.replace(ORIGIN_PREFIX, ""))
952
1170
  return "HEAD";
953
- const base = await git2(["merge-base", "HEAD", "origin/main"], root);
1171
+ const base = await git2(["merge-base", "HEAD", remote], root);
954
1172
  const head = await git2(["rev-parse", "HEAD"], root);
955
1173
  return base.code === 0 && stdoutOf(base) !== stdoutOf(head) ? stdoutOf(base) : "HEAD";
956
1174
  }
@@ -1065,7 +1283,7 @@ async function sweepStale(root) {
1065
1283
  continue;
1066
1284
  const path = join3(tmpdir(), name);
1067
1285
  const stat = lstatSync(path, { throwIfNoEntry: false });
1068
- if (stat?.isDirectory() === true && stat.uid === process9.getuid?.() && Date.now() - stat.mtimeMs > STALE_AFTER)
1286
+ if (stat?.isDirectory() === true && stat.uid === process11.getuid?.() && Date.now() - stat.mtimeMs > STALE_AFTER)
1069
1287
  rmSync(path, { recursive: true, force: true });
1070
1288
  }
1071
1289
  await git2(["worktree", "prune"], root);
@@ -1135,7 +1353,7 @@ async function inWorktree(options, body) {
1135
1353
  }
1136
1354
  }
1137
1355
 
1138
- // src/cli.ts
1356
+ // src/base.ts
1139
1357
  var USAGE = `base [--ref <rev>] [--keep <path>...] [--no-link] -- <command> [args...]: runs the command at HEAD or another ref in a temporary worktree, the working tree untouched, exiting with its code
1140
1358
 
1141
1359
  Exits with the code of the command, 127 when it cannot be started, 2 on a usage error, an unknown ref or a refused command.`;
@@ -1144,7 +1362,7 @@ var OPTIONS = {
1144
1362
  keep: { type: "string", short: "k", multiple: true, description: "a working-tree file or folder copied over, such as the new test, repeatable" },
1145
1363
  "no-link": { type: "boolean", description: "do not link the ignored env files, node_modules, vendor and .venv of the checkout" }
1146
1364
  };
1147
- async function main(argv) {
1365
+ async function base(argv) {
1148
1366
  const bare = argv[0] !== undefined && !argv[0].startsWith("-");
1149
1367
  const parsed = parse(bare ? [] : argv, USAGE, OPTIONS, { rest: true, replaces: "git stash, a test run, then git stash pop", examples: [["base -- bun test tests/api.test.ts", "the test at HEAD, the working tree changes left out"], ["base --ref main~3 --keep tests/new.test.ts -- bun test tests/new.test.ts", "a new test against an older commit"]] });
1150
1368
  const given = bare ? argv : parsed.rest ?? [];
@@ -1155,7 +1373,7 @@ ${USAGE}`);
1155
1373
  if (runsInContainer(given))
1156
1374
  fail("a container of the compose project mounts the main checkout, not the temporary worktree, so the command would not run at the ref: run the tool on the host, or check the ref out by hand");
1157
1375
  const command = shellCommand(given);
1158
- const cwd = process10.cwd();
1376
+ const cwd = process12.cwd();
1159
1377
  const { root, prefix } = await checkout(cwd);
1160
1378
  const ref = parsed.values.ref ?? "HEAD";
1161
1379
  const sha = await resolveRef(root, ref);
@@ -1166,4 +1384,112 @@ ${USAGE}`);
1166
1384
  console.error(`base: ran at ${ref} (${sha.slice(0, 7)}), exit ${ran.code}`);
1167
1385
  return ran.code;
1168
1386
  }
1169
- process10.exitCode = await runMain({ name: "base", run: main });
1387
+
1388
+ // src/proof.ts
1389
+ import process13 from "process";
1390
+ var USAGE2 = `proof [--ref <rev>] [--runs <n>] [--keep <path>...] [--no-link] [--json] -- <command> [args...]: runs the command at HEAD or another ref in a temporary worktree, then in the working tree, to show that a test fails before a change and passes after it
1391
+
1392
+ The ref defaults to the merge base with the default branch of origin (origin/main unless origin/HEAD names another) when HEAD is on a branch ahead of it, else HEAD. --runs <n> runs the command n times now, for a flaky test, and every run must pass.`;
1393
+ var EXITS = [[0, "the command fails before and passes in every run now"], [1, "it passes before too, fails in any run now, or passes before and fails now"], [2, "a usage error, an unknown ref, a command that cannot start or ends with exit 126, 127 or a signal"], [130, "interrupted (128 plus the signal)"]];
1394
+ var OPTIONS2 = {
1395
+ ref: { type: "string", short: "r", description: "the commit to run before at (default: the merge base with the default branch of origin on a branch ahead of it, else HEAD)" },
1396
+ runs: { type: "string", short: "n", description: "run the command this many times now, every run must pass (1)" },
1397
+ keep: { type: "string", short: "k", multiple: true, description: "a working-tree file or folder copied over to the ref, such as the new test, repeatable" },
1398
+ "no-link": { type: "boolean", description: "do not link the ignored env files, node_modules, vendor and .venv of the checkout" },
1399
+ json: jsonOption("{outcome, proved, ref, sha, before: {code, output}, now: {code, output}}")
1400
+ };
1401
+ function abnormal(code) {
1402
+ return code === 126 || code === 127 || code > 128 && code < 160;
1403
+ }
1404
+ function outcomeOf(before, now) {
1405
+ const failed = now.filter((code) => code !== 0).length;
1406
+ if (before !== 0 && failed === 0)
1407
+ return "proved";
1408
+ if (before === 0 && failed === 0)
1409
+ return "passes-before";
1410
+ if (before !== 0)
1411
+ return failed < now.length ? "flaky" : "fails-both";
1412
+ return "regressed";
1413
+ }
1414
+ function describe(outcome, at, now) {
1415
+ switch (outcome) {
1416
+ case "proved":
1417
+ return { message: now.length > 1 ? `fails at ${at}, passes now in ${now.length} of ${now.length} runs` : `fails at ${at}, passes now`, side: "before" };
1418
+ case "passes-before":
1419
+ return { message: `passes at ${at} too: it does not fail without the change`, side: "before" };
1420
+ case "fails-both":
1421
+ return { message: `fails at ${at} and fails now too`, side: "now" };
1422
+ case "regressed":
1423
+ return { message: `passes at ${at}, fails now`, side: "now" };
1424
+ case "flaky":
1425
+ return { message: `fails at ${at}, but ${now.filter((code) => code !== 0).length} of ${now.length} runs fail now`, side: "now" };
1426
+ }
1427
+ }
1428
+ async function proof(argv) {
1429
+ const bare = argv[0] !== undefined && !argv[0].startsWith("-");
1430
+ const parsed = parse(bare ? [] : argv, USAGE2, OPTIONS2, { rest: true, exits: EXITS, replaces: "running a test, stashing the change and running it again", examples: [["proof --keep tests/fix.test.ts -- bun test tests/fix.test.ts", "the new test fails at HEAD and passes now"], ["proof --ref v1.2.0 --keep tests/fix.test.ts -- bun test tests/fix.test.ts", "the same against a release"]] });
1431
+ const given = bare ? argv : parsed.rest ?? [];
1432
+ if (given.length === 0 || parsed.positionals.length > 0)
1433
+ fail(`give the command after --
1434
+
1435
+ ${USAGE2}`);
1436
+ if (runsInContainer(given))
1437
+ fail("a container of the compose project mounts the main checkout, not the temporary worktree, so the command would not run at the ref: run the tool on the host, or check the ref out by hand");
1438
+ const command = shellCommand(given);
1439
+ const cwd = process13.cwd();
1440
+ const { root, prefix } = await checkout(cwd);
1441
+ const runs = wholeNumber(parsed.values.runs, "runs", 1, 1);
1442
+ const ref = parsed.values.ref ?? await defaultProofRef(root);
1443
+ const sha = await resolveRef(root, ref);
1444
+ const kept = keptPaths(root, cwd, parsed.values.keep ?? []);
1445
+ const signals = holdSignals();
1446
+ let before;
1447
+ const nowRuns = [];
1448
+ try {
1449
+ before = await inWorktree({ root, prefix, sha, ref, kept, link: parsed.values["no-link"] !== true, signals }, async (runDir, held) => runIn(runDir, command, held, true));
1450
+ for (let i = 0;i < runs && signals.signal === undefined; i++)
1451
+ nowRuns.push(await runIn(cwd, command, signals, true));
1452
+ } finally {
1453
+ signals.release();
1454
+ }
1455
+ if (signals.signal !== undefined || nowRuns.length < runs)
1456
+ return exitCodeOf(null, signals.signal ?? null);
1457
+ for (const [run, where] of [[before, `at ${sha.slice(0, 7)}`], ...nowRuns.map((each, i) => [each, runs > 1 ? `now (run ${i + 1})` : "now"])]) {
1458
+ if (!run.started)
1459
+ fail(run.output);
1460
+ if (abnormal(run.code))
1461
+ fail(`the command did not run properly ${where}: exit ${run.code}, a missing command or a kill, not a test result${run.output.trim() === "" ? "" : `
1462
+
1463
+ ${folded(run.output)}`}`);
1464
+ }
1465
+ const codes = nowRuns.map((run) => run.code);
1466
+ const now = nowRuns.find((run) => run.code !== 0) ?? nowRuns.at(-1) ?? before;
1467
+ const outcome = outcomeOf(before.code, codes);
1468
+ const { message, side } = describe(outcome, sha.slice(0, 7), codes);
1469
+ const proved = outcome === "proved";
1470
+ if (parsed.values.json === true) {
1471
+ printJson({ outcome, proved, ref, sha, before: { code: before.code, output: before.output }, now: { code: now.code, output: now.output }, runs: nowRuns.map((run) => ({ code: run.code })) });
1472
+ return proved ? 0 : 1;
1473
+ }
1474
+ console.log(message);
1475
+ if (runs > 1)
1476
+ console.log(`now: ${codes.map((code, i) => `run ${i + 1} ${code === 0 ? "passed" : `failed (exit ${code})`}`).join(", ")}`);
1477
+ const shown = side === "before" ? before : now;
1478
+ if (shown.code !== 0 && shown.output.trim() !== "")
1479
+ console.log(`
1480
+ ${folded(shown.output)}`);
1481
+ return proved ? 0 : 1;
1482
+ }
1483
+
1484
+ // src/cli.ts
1485
+ process14.exitCode = await runCli({
1486
+ name: "base",
1487
+ about: "runs a command at HEAD or another ref in a temporary worktree, the working tree untouched",
1488
+ replaces: "git stash, a test run, then git stash pop",
1489
+ examples: [["base -- bun test tests/api.test.ts", "the test at HEAD, the working tree changes left out"], ["base proof -- bun test tests/new.test.ts", "it fails at HEAD and passes in the working tree"]],
1490
+ commands: {
1491
+ run: { summary: "the command at HEAD or --ref, exiting with its code (the command when none is named)", run: base },
1492
+ proof: { summary: "the command at HEAD or --ref, then in the working tree: proves a test fails before a change and passes after it", run: proof }
1493
+ },
1494
+ defaultCommand: "run"
1495
+ });
@@ -1,14 +1,35 @@
1
1
  #!/usr/bin/env -S bun --no-env-file
2
2
  // @bun
3
3
 
4
- // src/proof.ts
5
- import process10 from "process";
4
+ // src/proof-cli.ts
5
+ import process13 from "process";
6
6
  // ../kit/src/args.ts
7
- import process4 from "process";
7
+ import process6 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
- // ../kit/src/style.ts
10
+ // ../kit/src/format.ts
11
+ import process4 from "process";
12
+
13
+ // ../kit/src/mode.ts
11
14
  import process2 from "process";
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
29
+ }
30
+
31
+ // ../kit/src/style.ts
32
+ import process3 from "process";
12
33
 
13
34
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
35
  function x(s) {
@@ -271,21 +292,26 @@ function le(i = {}) {
271
292
  }
272
293
  var t = le();
273
294
 
295
+ // ../kit/src/theme.ts
296
+ var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
297
+ var MAX_FILE_BYTES = 64 * 1024;
298
+ var warned = new Set;
299
+
274
300
  // ../kit/src/style.ts
275
- function takesControlCodes(stream, env = process2.env) {
276
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
301
+ function takesControlCodes(stream, env = process3.env) {
302
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
277
303
  }
278
- function paint(stream, env = process2.env) {
304
+ function paint(stream, env = process3.env) {
279
305
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
280
306
  }
281
- var STATUSES = {
282
- passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
283
- failed: { symbol: "\u2717", words: ["failed", "failure", "error", "errored"], paint: (colors) => colors.red },
284
- running: { symbol: "\u25CF", words: ["running", "in_progress", "started"], paint: (colors) => colors.cyan },
285
- queued: { symbol: "\u25CB", words: ["queued", "waiting", "pending", "created", "blocked", "scheduled"], paint: (colors) => colors.yellow },
286
- skipped: { symbol: "-", words: ["skipped", "cancelled", "canceled", "manual"], paint: (colors) => colors.dim }
307
+ var STATUS_WORDS = {
308
+ passed: ["passed", "success", "succeeded", "ok"],
309
+ failed: ["failed", "failure", "error", "errored"],
310
+ running: ["running", "in_progress", "started", "holding"],
311
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
312
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
287
313
  };
288
- var STATUS_OF = new Map(Object.entries(STATUSES).flatMap(([status, { words }]) => words.map((word) => [word, status])));
314
+ var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
289
315
 
290
316
  // ../kit/src/format.ts
291
317
  function upTo(text, separator) {
@@ -293,32 +319,35 @@ function upTo(text, separator) {
293
319
  return end === -1 ? text : text.slice(0, end);
294
320
  }
295
321
  var ESCAPE = String.fromCharCode(27);
322
+ function jsonText(value, replacer, { stream = process4.stdout, env = process4.env } = {}) {
323
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
324
+ }
296
325
  function printJson(value) {
297
- console.log(JSON.stringify(value, undefined, 2));
326
+ console.log(jsonText(value));
298
327
  }
299
328
 
300
329
  // ../kit/src/help.ts
301
- import process3 from "process";
330
+ import process5 from "process";
302
331
  var OPTIONAL = /\[[^\]]+\]/g;
303
332
  var USAGE_PREFIX = /^usage:\s*/i;
304
333
  var FULL_STOP = /\.$/;
305
- function usageLine(usage, colors = paint(process3.stdout)) {
334
+ function usageLine(usage, colors = paint(process5.stdout)) {
306
335
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
307
336
  }
308
- function helpText(usage, options, colors = paint(process3.stdout), { examples = [], replaces, exits = [] } = {}) {
337
+ function helpText(usage, options, colors = paint(process5.stdout), { examples = [], replaces, exits = [] } = {}) {
309
338
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
310
339
  `);
311
340
  }
312
- function exitRows(exits, colors = paint(process3.stdout)) {
341
+ function exitRows(exits, colors = paint(process5.stdout)) {
313
342
  if (exits.length === 0)
314
343
  return [];
315
344
  const width = Math.max(...exits.map(([code]) => String(code).length));
316
345
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
317
346
  }
318
- function replacesRows(replaces, colors = paint(process3.stdout)) {
319
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
347
+ function replacesRows(replaces, colors = paint(process5.stdout)) {
348
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
320
349
  }
321
- function wantsHelpJson(env = process3.env) {
350
+ function wantsHelpJson(env = process5.env) {
322
351
  return env.KIT_HELP === "json";
323
352
  }
324
353
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -337,12 +366,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
337
366
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
338
367
  };
339
368
  }
340
- function exampleRows(examples, colors = paint(process3.stdout)) {
341
- if (examples.length === 0)
369
+ function exampleRows(examples, colors = paint(process5.stdout)) {
370
+ if (examples.length === 0 || outputMode() === "agent")
342
371
  return [];
343
372
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
344
373
  }
345
- function optionRows(options, colors = paint(process3.stdout)) {
374
+ function optionRows(options, colors = paint(process5.stdout)) {
346
375
  const rows = Object.entries(options).map(([name, option]) => {
347
376
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
348
377
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -389,7 +418,6 @@ var DASHES = /^-+/;
389
418
  function jsonOption(holds) {
390
419
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
391
420
  }
392
-
393
421
  class Exit extends Error {
394
422
  code;
395
423
  hint;
@@ -433,7 +461,7 @@ var OUTPUT_OPTIONS = {
433
461
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
434
462
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
435
463
  };
436
- function applyOutput(color, plain, env = process4.env) {
464
+ function applyOutput(color, plain, env = process6.env) {
437
465
  const when = plain === true ? "never" : color ?? "auto";
438
466
  if (when === "auto")
439
467
  return;
@@ -604,7 +632,7 @@ function nearestOption(message, options, allowNegative) {
604
632
  }
605
633
  // ../kit/src/process.ts
606
634
  import { constants } from "os";
607
- import process5 from "process";
635
+ import process7 from "process";
608
636
  var KILL_GRACE_MS = 2000;
609
637
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
610
638
  function exitCodeOf(code, signal) {
@@ -626,7 +654,7 @@ function holdSignals(cleanup) {
626
654
  },
627
655
  release: () => {
628
656
  for (const signal of SIGNALS)
629
- process5.off(signal, onSignal);
657
+ process7.off(signal, onSignal);
630
658
  }
631
659
  };
632
660
  function onSignal(signal) {
@@ -639,10 +667,10 @@ function holdSignals(cleanup) {
639
667
  return;
640
668
  held.release();
641
669
  cleanup(signal);
642
- process5.kill(process5.pid, signal);
670
+ process7.kill(process7.pid, signal);
643
671
  }
644
672
  for (const signal of SIGNALS)
645
- process5.on(signal, onSignal);
673
+ process7.on(signal, onSignal);
646
674
  return held;
647
675
  }
648
676
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -656,7 +684,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
656
684
  return;
657
685
  try {
658
686
  if (grouped)
659
- process5.kill(-proc.pid, killing);
687
+ process7.kill(-proc.pid, killing);
660
688
  else
661
689
  proc.kill(killing);
662
690
  } catch {}
@@ -732,13 +760,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
732
760
  // ../kit/src/cli.ts
733
761
  import { readFileSync, realpathSync } from "fs";
734
762
  import { dirname as dirname2, join as join2 } from "path";
735
- import process7 from "process";
763
+ import process9 from "process";
736
764
 
737
765
  // ../kit/src/usage.ts
738
766
  import { appendFileSync, mkdirSync } from "fs";
739
767
  import { homedir } from "os";
740
768
  import { dirname, isAbsolute, join } from "path";
741
- import process6 from "process";
769
+ import process8 from "process";
742
770
 
743
771
  // ../kit/src/logs.ts
744
772
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -752,14 +780,14 @@ var usageError;
752
780
  function noteUsageError(message) {
753
781
  usageError = message;
754
782
  }
755
- function stateHome(env = process6.env) {
783
+ function stateHome(env = process8.env) {
756
784
  const dir = env.XDG_STATE_HOME;
757
785
  return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
758
786
  }
759
- function usagePath(env = process6.env) {
787
+ function usagePath(env = process8.env) {
760
788
  return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
761
789
  }
762
- function usageRecorded(env = process6.env) {
790
+ function usageRecorded(env = process8.env) {
763
791
  const off = env.KAYNOOO_CLI_NO_USAGE;
764
792
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
765
793
  }
@@ -773,7 +801,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
773
801
  usageError = undefined;
774
802
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
775
803
  }
776
- function recordUsage(entry, env = process6.env) {
804
+ function recordUsage(entry, env = process8.env) {
777
805
  if (!usageRecorded(env))
778
806
  return;
779
807
  try {
@@ -790,9 +818,82 @@ var LEVEL_OPTIONS = {
790
818
  help: { type: "boolean", short: "h", description: "show this help" }
791
819
  };
792
820
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
821
+ async function commandRows(all, colors) {
822
+ const commands = shown(all);
823
+ const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
824
+ const groups = new Map([["Commands:", []]]);
825
+ const summaries = await Promise.all(Object.values(commands).map(async ({ summary }) => resolveSummary(summary)));
826
+ for (const [index, [name, { group }]] of Object.entries(commands).entries()) {
827
+ const heading = group === undefined ? "Commands:" : `${group}:`;
828
+ const rows = groups.get(heading) ?? [];
829
+ rows.push(` ${colors.cyan(name.padEnd(width))} ${colors.dim(summaries[index])}`);
830
+ groups.set(heading, rows);
831
+ }
832
+ return [...groups].filter(([, rows]) => rows.length > 0).flatMap(([heading, rows], index) => [...index === 0 ? [] : [""], colors.bold(heading), ...rows]);
833
+ }
834
+ function shown(commands) {
835
+ return Object.fromEntries(Object.entries(commands).filter(([, { hidden }]) => hidden !== true));
836
+ }
837
+ function takeOutputFlags(argv) {
838
+ let index = 0;
839
+ for (;index < argv.length; index++) {
840
+ const word = argv[index];
841
+ if (word === "--plain")
842
+ applyOutput(undefined, true);
843
+ else if (word.startsWith("--color="))
844
+ applyOutput(word.slice("--color=".length), undefined);
845
+ else if (word === "--color" && argv[index + 1] !== undefined)
846
+ applyOutput(argv[++index], undefined);
847
+ else
848
+ break;
849
+ }
850
+ return argv.slice(index);
851
+ }
852
+ async function resolveSummary(summary) {
853
+ return typeof summary === "string" ? summary : summary();
854
+ }
855
+ function scopeOf(commands, extra, aliases) {
856
+ return { commands: typeof commands === "function" ? {} : commands, lazy: [...typeof commands === "function" ? [commands] : [], ...extra === undefined ? [] : [extra]], aliases };
857
+ }
858
+ async function expand(scope, words) {
859
+ if (scope.lazy.length === 0)
860
+ return scope;
861
+ const commands = { ...scope.commands };
862
+ for (const added of await Promise.all(scope.lazy.map(async (lazy) => lazy(words)))) {
863
+ for (const [name, command] of Object.entries(added))
864
+ commands[name] ??= command;
865
+ }
866
+ return { ...scope, commands, lazy: [] };
867
+ }
868
+ async function help2({ path, header, summary: lazySummary, commands, defaultCommand, examples, replaces }, stream) {
869
+ const colors = paint(stream);
870
+ const prefix = path.join(" ");
871
+ const summary = await resolveSummary(lazySummary);
872
+ if (wantsHelpJson())
873
+ return JSON.stringify(description(`${prefix} <command> [options]: ${summary}`, { examples, replaces }));
874
+ const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
875
+ const options = fallback !== undefined && "run" in fallback ? await optionsOf(fallback.run) : undefined;
876
+ const own = Object.entries(options ?? {}).filter(([name]) => !(name in TOP_OPTIONS));
877
+ return [
878
+ header(colors, summary),
879
+ "",
880
+ usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
881
+ ...replacesRows(replaces, colors),
882
+ "",
883
+ ...await commandRows(commands, colors),
884
+ ...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
885
+ "",
886
+ colors.bold("Options:"),
887
+ ...optionRows(path.length === 1 ? TOP_OPTIONS : LEVEL_OPTIONS, colors),
888
+ ...exampleRows(examples ?? [], colors),
889
+ "",
890
+ `${colors.dim("Run")} ${prefix} ${colors.cyan("<command>")} --help ${colors.dim("for its options.")}`
891
+ ].join(`
892
+ `);
893
+ }
793
894
  function printError(prefix, message, hint, cause) {
794
- const colors = paint(process7.stderr);
795
- const styled = takesControlCodes(process7.stderr);
895
+ const colors = paint(process9.stderr);
896
+ const styled = takesControlCodes(process9.stderr);
796
897
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
797
898
  const under = (label, text, tint) => text === undefined ? "" : `
798
899
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -811,12 +912,68 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
811
912
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
812
913
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
813
914
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
814
- if (error instanceof UsageError)
915
+ if (error instanceof Exit && error.code === 2)
815
916
  noteUsageError(error.message);
816
917
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
817
918
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
818
919
  return error instanceof Exit ? error.code : 1;
819
920
  }
921
+ async function dispatch(level, typed, { version, redact }) {
922
+ const prefix = level.path.join(" ");
923
+ let argv;
924
+ try {
925
+ argv = takeOutputFlags(typed);
926
+ } catch (error) {
927
+ return reportThrown(prefix, error);
928
+ }
929
+ const [name, ...args] = argv;
930
+ const fallback = level.defaultCommand === undefined ? undefined : level.commands[level.defaultCommand];
931
+ if (name === undefined && level.runBare && fallback !== undefined && "run" in fallback) {
932
+ try {
933
+ return await fallback.run([]);
934
+ } catch (error) {
935
+ return reportThrown(`${prefix} ${level.defaultCommand}`, error, redact, false);
936
+ }
937
+ }
938
+ if (name === undefined && level.path.length > 1) {
939
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stderr));
940
+ return 2;
941
+ }
942
+ if (name === undefined || name === "help" || name === "--help" || name === "-h") {
943
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stdout));
944
+ return 0;
945
+ }
946
+ if (level.path.length === 1 && (name === "--version" || name === "-v")) {
947
+ console.log(version);
948
+ return 0;
949
+ }
950
+ let command = level.commands[level.aliases?.[name] ?? name];
951
+ let rest = args;
952
+ let ran = name;
953
+ if (command === undefined && level.lazy.length > 0) {
954
+ level = await expand(level, [...level.path.slice(1), ...argv]);
955
+ command = level.commands[level.aliases?.[name] ?? name];
956
+ }
957
+ if (command === undefined && level.defaultCommand !== undefined) {
958
+ command = level.commands[level.defaultCommand];
959
+ rest = argv;
960
+ ran = level.defaultCommand;
961
+ }
962
+ if (command === undefined) {
963
+ const meant = closest(name, Object.keys(shown(level.commands)));
964
+ printError(prefix, `no command ${name}`, meant === undefined ? `run ${prefix} --help for its commands` : `did you mean ${meant}?`);
965
+ return 2;
966
+ }
967
+ if ("commands" in command) {
968
+ const { summary } = command;
969
+ return dispatch({ path: [...level.path, name], header: (colors, text) => `${colors.bold(`${prefix} ${name}`)} ${text}`, summary, ...scopeOf(command.commands, command.extraCommands, command.aliases), defaultCommand: undefined, runBare: false, examples: command.examples, replaces: undefined }, rest, { version, redact });
970
+ }
971
+ try {
972
+ return await command.run(rest);
973
+ } catch (error) {
974
+ return reportThrown(`${prefix} ${ran}`, error, redact, wantsJson(rest));
975
+ }
976
+ }
820
977
  var COMPLETE = "__complete";
821
978
  var FILES = "__files__";
822
979
  async function completingOf(run) {
@@ -831,6 +988,9 @@ async function completingOf(run) {
831
988
  }
832
989
  return new Completing({});
833
990
  }
991
+ async function optionsOf(run) {
992
+ return (await completingOf(run)).options;
993
+ }
834
994
  function candidateLine(candidate) {
835
995
  return typeof candidate === "string" ? candidate : candidate.join("\t");
836
996
  }
@@ -869,6 +1029,28 @@ async function leafCandidates(run, words) {
869
1029
  const values = name === undefined ? undefined : await completing.candidates[name]?.();
870
1030
  return values === undefined ? [FILES] : values.map(candidateLine);
871
1031
  }
1032
+ async function candidates(scope, defaultCommand, words, before = []) {
1033
+ const [word = "", ...rest] = words;
1034
+ const listing = rest.length === 0 && !word.startsWith("-");
1035
+ let { commands, aliases } = scope;
1036
+ let command = commands[aliases?.[word] ?? word];
1037
+ if (listing || command === undefined) {
1038
+ ({ commands, aliases } = await expand(scope, [...before, ...words]));
1039
+ command = commands[aliases?.[word] ?? word];
1040
+ }
1041
+ if (listing) {
1042
+ const own = await Promise.all(Object.entries(shown(commands)).map(async ([name, { summary }]) => `${name} ${await resolveSummary(summary)}`));
1043
+ const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
1044
+ const values = fallback !== undefined && "run" in fallback ? await leafCandidates(fallback.run, [word]) : [];
1045
+ const valueOf = (line) => line.slice(0, line.includes("\t") ? line.indexOf("\t") : undefined);
1046
+ return [...own, ...values.filter((line) => line !== FILES && !(valueOf(line) in commands))];
1047
+ }
1048
+ if (command === undefined) {
1049
+ const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
1050
+ return fallback !== undefined && "run" in fallback ? leafCandidates(fallback.run, words) : [];
1051
+ }
1052
+ return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
1053
+ }
872
1054
  async function printCandidates(found) {
873
1055
  for (const line of await found)
874
1056
  console.log(line);
@@ -885,7 +1067,34 @@ function packageVersion(entry = Bun.main) {
885
1067
  return "0.0.0";
886
1068
  }
887
1069
  }
888
- async function runMain({ name, version, run, redact, usage }, argv = process7.argv.slice(2)) {
1070
+ async function runCli(cli, argv = process9.argv.slice(2)) {
1071
+ const version = cli.version ?? packageVersion();
1072
+ if (argv[0] === COMPLETE)
1073
+ return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
1074
+ const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
1075
+ if (cli.usage !== false) {
1076
+ try {
1077
+ recordUsage(usageEntry(cli.name, commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv), argv, code));
1078
+ } catch {}
1079
+ }
1080
+ return code;
1081
+ }
1082
+ function commandPath(scope, argv) {
1083
+ const path = [];
1084
+ let level = scope;
1085
+ for (const word of argv.filter((each) => !each.startsWith("-"))) {
1086
+ const name = level.aliases !== undefined && Object.hasOwn(level.aliases, word) ? level.aliases[word] ?? word : word;
1087
+ const command = Object.hasOwn(level.commands, name) ? level.commands[name] : undefined;
1088
+ if (command === undefined)
1089
+ break;
1090
+ path.push(word);
1091
+ if (!("commands" in command))
1092
+ break;
1093
+ level = scopeOf(command.commands, command.extraCommands, command.aliases);
1094
+ }
1095
+ return path.length === 0 ? undefined : path.join(" ");
1096
+ }
1097
+ async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
889
1098
  if (argv[0] === COMPLETE)
890
1099
  return printCandidates(leafCandidates(run, argv.slice(1)));
891
1100
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -911,12 +1120,16 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
911
1120
  var {Glob } = globalThis.Bun;
912
1121
  var SESSION_FILES = new Glob("*.json");
913
1122
  var ACCOUNT_DIRS = new Glob("*/sessions");
1123
+ // src/proof.ts
1124
+ import process12 from "process";
1125
+
914
1126
  // src/worktree.ts
915
1127
  import { cpSync, existsSync, lstatSync, mkdirSync as mkdirSync2, mkdtempSync, readdirSync, realpathSync as realpathSync2, rmSync, symlinkSync, unlinkSync } from "fs";
916
1128
  import { tmpdir } from "os";
917
1129
  import { basename, dirname as dirname3, isAbsolute as isAbsolute2, join as join3, relative, resolve, sep } from "path";
918
- import process9 from "process";
1130
+ import process11 from "process";
919
1131
  var WHITESPACE = /\s/;
1132
+ var ORIGIN_PREFIX = /^origin\//;
920
1133
  var ENV_FILE = /^\.env(?:\..+)?$/;
921
1134
  var DEPENDENCIES = new Set(["node_modules", "vendor", ".venv"]);
922
1135
  var TRAILING_SLASH = /\/$/;
@@ -946,11 +1159,16 @@ async function resolveRef(root, ref) {
946
1159
  fail(`no commit ${ref} in this repository`);
947
1160
  return stdoutOf(ran);
948
1161
  }
1162
+ async function defaultRemoteRef(root) {
1163
+ const head = await git2(["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"], root);
1164
+ return head.code === 0 && stdoutOf(head) !== "" ? stdoutOf(head) : "origin/main";
1165
+ }
949
1166
  async function defaultProofRef(root) {
950
1167
  const branch = await git2(["symbolic-ref", "--quiet", "--short", "HEAD"], root);
951
- if (branch.code !== 0 || stdoutOf(branch) === "main")
1168
+ const remote = await defaultRemoteRef(root);
1169
+ if (branch.code !== 0 || stdoutOf(branch) === remote.replace(ORIGIN_PREFIX, ""))
952
1170
  return "HEAD";
953
- const base = await git2(["merge-base", "HEAD", "origin/main"], root);
1171
+ const base = await git2(["merge-base", "HEAD", remote], root);
954
1172
  const head = await git2(["rev-parse", "HEAD"], root);
955
1173
  return base.code === 0 && stdoutOf(base) !== stdoutOf(head) ? stdoutOf(base) : "HEAD";
956
1174
  }
@@ -1065,7 +1283,7 @@ async function sweepStale(root) {
1065
1283
  continue;
1066
1284
  const path = join3(tmpdir(), name);
1067
1285
  const stat = lstatSync(path, { throwIfNoEntry: false });
1068
- if (stat?.isDirectory() === true && stat.uid === process9.getuid?.() && Date.now() - stat.mtimeMs > STALE_AFTER)
1286
+ if (stat?.isDirectory() === true && stat.uid === process11.getuid?.() && Date.now() - stat.mtimeMs > STALE_AFTER)
1069
1287
  rmSync(path, { recursive: true, force: true });
1070
1288
  }
1071
1289
  await git2(["worktree", "prune"], root);
@@ -1138,10 +1356,10 @@ async function inWorktree(options, body) {
1138
1356
  // src/proof.ts
1139
1357
  var USAGE = `proof [--ref <rev>] [--runs <n>] [--keep <path>...] [--no-link] [--json] -- <command> [args...]: runs the command at HEAD or another ref in a temporary worktree, then in the working tree, to show that a test fails before a change and passes after it
1140
1358
 
1141
- The ref defaults to the merge base with origin/main when HEAD is on a branch ahead of it, else HEAD. --runs <n> runs the command n times now, for a flaky test, and every run must pass.`;
1359
+ The ref defaults to the merge base with the default branch of origin (origin/main unless origin/HEAD names another) when HEAD is on a branch ahead of it, else HEAD. --runs <n> runs the command n times now, for a flaky test, and every run must pass.`;
1142
1360
  var EXITS = [[0, "the command fails before and passes in every run now"], [1, "it passes before too, fails in any run now, or passes before and fails now"], [2, "a usage error, an unknown ref, a command that cannot start or ends with exit 126, 127 or a signal"], [130, "interrupted (128 plus the signal)"]];
1143
1361
  var OPTIONS = {
1144
- ref: { type: "string", short: "r", description: "the commit to run before at (default: the merge base with origin/main on a branch ahead of it, else HEAD)" },
1362
+ ref: { type: "string", short: "r", description: "the commit to run before at (default: the merge base with the default branch of origin on a branch ahead of it, else HEAD)" },
1145
1363
  runs: { type: "string", short: "n", description: "run the command this many times now, every run must pass (1)" },
1146
1364
  keep: { type: "string", short: "k", multiple: true, description: "a working-tree file or folder copied over to the ref, such as the new test, repeatable" },
1147
1365
  "no-link": { type: "boolean", description: "do not link the ignored env files, node_modules, vendor and .venv of the checkout" },
@@ -1174,7 +1392,7 @@ function describe(outcome, at, now) {
1174
1392
  return { message: `fails at ${at}, but ${now.filter((code) => code !== 0).length} of ${now.length} runs fail now`, side: "now" };
1175
1393
  }
1176
1394
  }
1177
- async function main(argv) {
1395
+ async function proof(argv) {
1178
1396
  const bare = argv[0] !== undefined && !argv[0].startsWith("-");
1179
1397
  const parsed = parse(bare ? [] : argv, USAGE, OPTIONS, { rest: true, exits: EXITS, replaces: "running a test, stashing the change and running it again", examples: [["proof --keep tests/fix.test.ts -- bun test tests/fix.test.ts", "the new test fails at HEAD and passes now"], ["proof --ref v1.2.0 --keep tests/fix.test.ts -- bun test tests/fix.test.ts", "the same against a release"]] });
1180
1398
  const given = bare ? argv : parsed.rest ?? [];
@@ -1185,7 +1403,7 @@ ${USAGE}`);
1185
1403
  if (runsInContainer(given))
1186
1404
  fail("a container of the compose project mounts the main checkout, not the temporary worktree, so the command would not run at the ref: run the tool on the host, or check the ref out by hand");
1187
1405
  const command = shellCommand(given);
1188
- const cwd = process10.cwd();
1406
+ const cwd = process12.cwd();
1189
1407
  const { root, prefix } = await checkout(cwd);
1190
1408
  const runs = wholeNumber(parsed.values.runs, "runs", 1, 1);
1191
1409
  const ref = parsed.values.ref ?? await defaultProofRef(root);
@@ -1229,4 +1447,6 @@ ${folded(run.output)}`}`);
1229
1447
  ${folded(shown.output)}`);
1230
1448
  return proved ? 0 : 1;
1231
1449
  }
1232
- process10.exitCode = await runMain({ name: "proof", run: main });
1450
+
1451
+ // src/proof-cli.ts
1452
+ process13.exitCode = await runMain({ name: "proof", run: proof });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-base",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.7.0",
5
5
  "description": "base: a command run at HEAD or another ref in a temporary worktree, the working tree left untouched.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "bin": {
23
23
  "base": "./dist/cli.js",
24
- "proof": "./dist/proof.js"
24
+ "proof": "./dist/proof-cli.js"
25
25
  },
26
26
  "files": [
27
27
  "dist"
@@ -33,11 +33,11 @@
33
33
  "registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
34
34
  },
35
35
  "scripts": {
36
- "build": "$npm_execpath build src/cli.ts src/proof.ts --target bun --outdir dist",
36
+ "build": "$npm_execpath build src/cli.ts src/proof-cli.ts --target bun --outdir dist",
37
37
  "base": "$npm_execpath src/cli.ts",
38
- "proof": "$npm_execpath src/proof.ts"
38
+ "proof": "$npm_execpath src/proof-cli.ts"
39
39
  },
40
40
  "devDependencies": {
41
- "@kaynooo/cli-kit": "0.21.0"
41
+ "@kaynooo/cli-kit": "0.24.0"
42
42
  }
43
43
  }