@kaynooo/cli-check 0.14.0 → 0.15.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,16 +2,37 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process19 from "process";
5
+ import process20 from "process";
6
6
  // ../kit/src/args.ts
7
- import process9 from "process";
7
+ import process10 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process6 from "process";
11
+ import process7 from "process";
12
+
13
+ // ../kit/src/mode.ts
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
+ function isInteractive(streams = process2) {
31
+ return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
32
+ }
12
33
 
13
34
  // ../kit/src/style.ts
14
- import process5 from "process";
35
+ import process6 from "process";
15
36
 
16
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
17
38
  function x(s) {
@@ -278,13 +299,13 @@ var t = le();
278
299
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
279
300
  import { homedir as homedir2 } from "os";
280
301
  import { join as join3, resolve as resolve2 } from "path";
281
- import process4 from "process";
302
+ import process5 from "process";
282
303
 
283
304
  // ../kit/src/config.ts
284
305
  import { existsSync } from "fs";
285
306
  import { dirname, join, resolve } from "path";
286
- import process2 from "process";
287
- function findUp(names, from = process2.cwd(), stop = () => false) {
307
+ import process3 from "process";
308
+ function findUp(names, from = process3.cwd(), stop = () => false) {
288
309
  const wanted = typeof names === "string" ? [names] : names;
289
310
  for (let dir = resolve(from);; dir = dirname(dir)) {
290
311
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -298,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
298
319
  // ../kit/src/user-config.ts
299
320
  import { homedir } from "os";
300
321
  import { join as join2 } from "path";
301
- import process3 from "process";
322
+ import process4 from "process";
302
323
  function configBase(where = {}) {
303
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
324
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
304
325
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
305
326
  }
306
327
  function userConfigPath(bin, where = {}) {
@@ -333,10 +354,30 @@ function isColorSpec(spec) {
333
354
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
334
355
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
335
356
  }
336
- function tinted(colors, spec) {
357
+ var CUBE = [0, 95, 135, 175, 215, 255];
358
+ function cubeLevel(channel) {
359
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
360
+ }
361
+ function nearest256(hex) {
362
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
363
+ const levels = rgb.map(cubeLevel);
364
+ const cube = levels.map((level) => CUBE[level]);
365
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
366
+ const greyValue = 8 + grey * 10;
367
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
368
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
369
+ }
370
+ function hasTrueColor(env) {
371
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
372
+ }
373
+ function tinted(colors, spec, env = process5.env) {
337
374
  if (typeof spec === "number")
338
375
  return colors.ansi256(spec);
339
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
376
+ return spec.trim().split(SPACES).reduce((chain, token) => {
377
+ if (HEX.test(token))
378
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
379
+ return chain[token] ?? chain;
380
+ }, colors);
340
381
  }
341
382
  function isRecord(value) {
342
383
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -420,7 +461,7 @@ function warnOnce(message) {
420
461
  function isPath(chosen) {
421
462
  return chosen.includes("/") || chosen.endsWith(".json");
422
463
  }
423
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
464
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
424
465
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
425
466
  const sources = [];
426
467
  const chosen = env.KIT_THEME ?? "";
@@ -450,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
450
491
  var current;
451
492
  var currentKey = "";
452
493
  function activeTheme() {
453
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
494
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
454
495
  if (current === undefined || key !== currentKey) {
455
496
  current = loadTheme();
456
497
  currentKey = key;
@@ -460,44 +501,44 @@ function activeTheme() {
460
501
 
461
502
  // ../kit/src/style.ts
462
503
  var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
463
- function takesControlCodes(stream, env = process5.env) {
464
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
504
+ function takesControlCodes(stream, env = process6.env) {
505
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
465
506
  }
466
- function paint(stream, env = process5.env) {
507
+ function paint(stream, env = process6.env) {
467
508
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
468
509
  }
469
- function marked(mark, text, stream, detail, env = process5.env) {
510
+ function marked(mark, text, stream, detail, env = process6.env) {
470
511
  const colors = paint(stream, env);
471
512
  let head = MARK_WORDS[mark];
472
513
  if (takesControlCodes(stream, env)) {
473
514
  const { theme } = activeTheme();
474
- head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
515
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
475
516
  }
476
517
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
477
518
  }
478
519
  function warn(text, detail) {
479
- console.error(marked("warn", text, process5.stderr, detail));
520
+ console.error(marked("warn", text, process6.stderr, detail));
480
521
  }
481
- function role(name, stream, env = process5.env) {
522
+ function role(name, stream, env = process6.env) {
482
523
  const colors = paint(stream, env);
483
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
524
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
484
525
  }
485
526
  var STATUS_WORDS = {
486
527
  passed: ["passed", "success", "succeeded", "ok"],
487
528
  failed: ["failed", "failure", "error", "errored"],
488
- running: ["running", "in_progress", "started"],
529
+ running: ["running", "in_progress", "started", "holding"],
489
530
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
490
531
  skipped: ["skipped", "cancelled", "canceled", "manual"]
491
532
  };
492
533
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
493
- function header(bin, context, stream, env = process5.env) {
534
+ function header(bin, context, stream, env = process6.env) {
494
535
  if (!takesControlCodes(stream, env))
495
536
  return "";
496
537
  const colors = paint(stream, env);
497
538
  const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
498
539
  const { theme } = activeTheme();
499
540
  const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
500
- const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec);
541
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
501
542
  return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
502
543
  }
503
544
 
@@ -531,8 +572,11 @@ var ESCAPE = String.fromCharCode(27);
531
572
  function textWidth(text) {
532
573
  return Bun.stringWidth(text);
533
574
  }
534
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
575
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
535
576
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
577
+ if (outputMode(stream, env) === "agent")
578
+ return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
579
+ `);
536
580
  const widths = [];
537
581
  for (const row of cells) {
538
582
  for (const [index, cell] of row.entries())
@@ -567,32 +611,35 @@ function narrow(rows, widths, limit) {
567
611
  }
568
612
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
569
613
  }
614
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
615
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
616
+ }
570
617
  function printJson(value) {
571
- console.log(JSON.stringify(value, undefined, 2));
618
+ console.log(jsonText(value));
572
619
  }
573
620
 
574
621
  // ../kit/src/help.ts
575
- import process7 from "process";
622
+ import process8 from "process";
576
623
  var OPTIONAL = /\[[^\]]+\]/g;
577
624
  var USAGE_PREFIX = /^usage:\s*/i;
578
625
  var FULL_STOP = /\.$/;
579
- function usageLine(usage, colors = paint(process7.stdout)) {
626
+ function usageLine(usage, colors = paint(process8.stdout)) {
580
627
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
581
628
  }
582
- function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
629
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
583
630
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
584
631
  `);
585
632
  }
586
- function exitRows(exits, colors = paint(process7.stdout)) {
633
+ function exitRows(exits, colors = paint(process8.stdout)) {
587
634
  if (exits.length === 0)
588
635
  return [];
589
636
  const width = Math.max(...exits.map(([code]) => String(code).length));
590
637
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
591
638
  }
592
- function replacesRows(replaces, colors = paint(process7.stdout)) {
593
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
639
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
640
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
594
641
  }
595
- function wantsHelpJson(env = process7.env) {
642
+ function wantsHelpJson(env = process8.env) {
596
643
  return env.KIT_HELP === "json";
597
644
  }
598
645
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -611,12 +658,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
611
658
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
612
659
  };
613
660
  }
614
- function exampleRows(examples, colors = paint(process7.stdout)) {
615
- if (examples.length === 0)
661
+ function exampleRows(examples, colors = paint(process8.stdout)) {
662
+ if (examples.length === 0 || outputMode() === "agent")
616
663
  return [];
617
664
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
618
665
  }
619
- function optionRows(options, colors = paint(process7.stdout)) {
666
+ function optionRows(options, colors = paint(process8.stdout)) {
620
667
  const rows = Object.entries(options).map(([name, option]) => {
621
668
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
622
669
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -651,7 +698,7 @@ function closest(name, names) {
651
698
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
652
699
  }
653
700
  // ../kit/src/input.ts
654
- import process8 from "process";
701
+ import process9 from "process";
655
702
  var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
656
703
  var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
657
704
  function duration(value, name, fallback, unit = "s") {
@@ -665,7 +712,7 @@ function duration(value, name, fallback, unit = "s") {
665
712
  }
666
713
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
667
714
  if (path === "-") {
668
- if (process8.stdin.isTTY)
715
+ if (process9.stdin.isTTY)
669
716
  fail(noStdin);
670
717
  return Bun.stdin.text();
671
718
  }
@@ -724,7 +771,7 @@ var OUTPUT_OPTIONS = {
724
771
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
725
772
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
726
773
  };
727
- function applyOutput(color, plain, env = process9.env) {
774
+ function applyOutput(color, plain, env = process10.env) {
728
775
  const when = plain === true ? "never" : color ?? "auto";
729
776
  if (when === "auto")
730
777
  return;
@@ -895,7 +942,7 @@ function nearestOption(message, options, allowNegative) {
895
942
  }
896
943
  // ../kit/src/process.ts
897
944
  import { constants } from "os";
898
- import process10 from "process";
945
+ import process11 from "process";
899
946
  var KILL_GRACE_MS = 2000;
900
947
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
901
948
  function exitCodeOf(code, signal) {
@@ -917,7 +964,7 @@ function holdSignals(cleanup) {
917
964
  },
918
965
  release: () => {
919
966
  for (const signal of SIGNALS)
920
- process10.off(signal, onSignal);
967
+ process11.off(signal, onSignal);
921
968
  }
922
969
  };
923
970
  function onSignal(signal) {
@@ -930,10 +977,10 @@ function holdSignals(cleanup) {
930
977
  return;
931
978
  held.release();
932
979
  cleanup(signal);
933
- process10.kill(process10.pid, signal);
980
+ process11.kill(process11.pid, signal);
934
981
  }
935
982
  for (const signal of SIGNALS)
936
- process10.on(signal, onSignal);
983
+ process11.on(signal, onSignal);
937
984
  return held;
938
985
  }
939
986
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -947,7 +994,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
947
994
  return;
948
995
  try {
949
996
  if (grouped)
950
- process10.kill(-proc.pid, killing);
997
+ process11.kill(-proc.pid, killing);
951
998
  else
952
999
  proc.kill(killing);
953
1000
  } catch {}
@@ -1023,31 +1070,31 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
1023
1070
  // ../kit/src/cli.ts
1024
1071
  import { readFileSync as readFileSync2, realpathSync } from "fs";
1025
1072
  import { dirname as dirname3, join as join6 } from "path";
1026
- import process13 from "process";
1073
+ import process14 from "process";
1027
1074
 
1028
1075
  // ../kit/src/usage.ts
1029
1076
  import { appendFileSync, mkdirSync } from "fs";
1030
1077
  import { homedir as homedir4 } from "os";
1031
1078
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1032
- import process12 from "process";
1079
+ import process13 from "process";
1033
1080
 
1034
1081
  // ../kit/src/logs.ts
1035
1082
  import { lstatSync, openSync } from "fs";
1036
1083
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
1037
1084
  import { homedir as homedir3, tmpdir } from "os";
1038
1085
  import { join as join4 } from "path";
1039
- import process11 from "process";
1086
+ import process12 from "process";
1040
1087
  var DAY_MS = 24 * 60 * 60 * 1000;
1041
1088
  var CLI_FOLDER = "kaynooo-cli";
1042
1089
  function isPrivateDirectory(path) {
1043
1090
  try {
1044
1091
  const info = lstatSync(path, { throwIfNoEntry: false });
1045
- return info !== undefined && info.isDirectory() && info.uid === (process11.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1092
+ return info !== undefined && info.isDirectory() && info.uid === (process12.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1046
1093
  } catch {
1047
1094
  return false;
1048
1095
  }
1049
1096
  }
1050
- async function privateLogDirectory(name, env = process11.env) {
1097
+ async function privateLogDirectory(name, env = process12.env) {
1051
1098
  const runtime = env.XDG_RUNTIME_DIR;
1052
1099
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1053
1100
  const path = join4(base, name);
@@ -1087,14 +1134,14 @@ var usageError;
1087
1134
  function noteUsageError(message) {
1088
1135
  usageError = message;
1089
1136
  }
1090
- function stateHome(env = process12.env) {
1137
+ function stateHome(env = process13.env) {
1091
1138
  const dir = env.XDG_STATE_HOME;
1092
1139
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1093
1140
  }
1094
- function usagePath(env = process12.env) {
1141
+ function usagePath(env = process13.env) {
1095
1142
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1096
1143
  }
1097
- function usageRecorded(env = process12.env) {
1144
+ function usageRecorded(env = process13.env) {
1098
1145
  const off = env.KAYNOOO_CLI_NO_USAGE;
1099
1146
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1100
1147
  }
@@ -1108,7 +1155,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1108
1155
  usageError = undefined;
1109
1156
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1110
1157
  }
1111
- function recordUsage(entry, env = process12.env) {
1158
+ function recordUsage(entry, env = process13.env) {
1112
1159
  if (!usageRecorded(env))
1113
1160
  return;
1114
1161
  try {
@@ -1126,8 +1173,8 @@ var LEVEL_OPTIONS = {
1126
1173
  };
1127
1174
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1128
1175
  function printError(prefix, message, hint, cause) {
1129
- const colors = paint(process13.stderr);
1130
- const styled = takesControlCodes(process13.stderr);
1176
+ const colors = paint(process14.stderr);
1177
+ const styled = takesControlCodes(process14.stderr);
1131
1178
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1132
1179
  const under = (label, text, tint) => text === undefined ? "" : `
1133
1180
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1220,7 +1267,7 @@ function packageVersion(entry = Bun.main) {
1220
1267
  return "0.0.0";
1221
1268
  }
1222
1269
  }
1223
- async function runMain({ name, version, run, redact, usage }, argv = process13.argv.slice(2)) {
1270
+ async function runMain({ name, version, run, redact, usage }, argv = process14.argv.slice(2)) {
1224
1271
  if (argv[0] === COMPLETE)
1225
1272
  return printCandidates(leafCandidates(run, argv.slice(1)));
1226
1273
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1247,12 +1294,12 @@ var {Glob } = globalThis.Bun;
1247
1294
  var SESSION_FILES = new Glob("*.json");
1248
1295
  var ACCOUNT_DIRS = new Glob("*/sessions");
1249
1296
  // package.json
1250
- var version = "0.14.0";
1297
+ var version = "0.15.0";
1251
1298
 
1252
1299
  // src/check.ts
1253
1300
  import { writeFile as writeFile3 } from "fs/promises";
1254
1301
  import { basename as basename4, join as join13 } from "path";
1255
- import process18 from "process";
1302
+ import process19 from "process";
1256
1303
 
1257
1304
  // ../kit/src/shell.ts
1258
1305
  var SEPARATORS = new Set([`
@@ -1305,7 +1352,7 @@ function shellQuote(word) {
1305
1352
  import { existsSync as existsSync3 } from "fs";
1306
1353
  import { homedir as homedir5 } from "os";
1307
1354
  import { basename, dirname as dirname4, join as join7, relative, resolve as resolve3 } from "path";
1308
- import process15 from "process";
1355
+ import process16 from "process";
1309
1356
  var COMPOSE_FILES = ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"];
1310
1357
  var OVERRIDE_FILES = ["compose.override.yaml", "compose.override.yml", "docker-compose.override.yaml", "docker-compose.override.yml"];
1311
1358
  var PS_TIMEOUT_MS = 20000;
@@ -1349,7 +1396,7 @@ async function variables(composeDir) {
1349
1396
  if (match !== null && !line.trimStart().startsWith("#"))
1350
1397
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1351
1398
  }
1352
- for (const [key, value] of Object.entries(process15.env)) {
1399
+ for (const [key, value] of Object.entries(process16.env)) {
1353
1400
  if (value !== undefined)
1354
1401
  env[key] = value;
1355
1402
  }
@@ -1485,7 +1532,7 @@ async function place(dir, program, { service, host } = {}) {
1485
1532
  fail(`--in ${service}: no compose project mounts ${dir}`);
1486
1533
  return;
1487
1534
  }
1488
- if (Bun.which("docker", { PATH: process15.env.PATH ?? "" }) === null) {
1535
+ if (Bun.which("docker", { PATH: process16.env.PATH ?? "" }) === null) {
1489
1536
  if (service !== undefined)
1490
1537
  fail(`--in ${service}: docker not found`);
1491
1538
  if (!noticed.has(found.composeDir)) {
@@ -1537,7 +1584,7 @@ class Stack {
1537
1584
  }
1538
1585
  static async running(composeDir) {
1539
1586
  try {
1540
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process15.env, timeoutMs: PS_TIMEOUT_MS });
1587
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process16.env, timeoutMs: PS_TIMEOUT_MS });
1541
1588
  if (ran.code !== 0)
1542
1589
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1543
1590
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -1572,7 +1619,7 @@ function placeSettings(values) {
1572
1619
  import { existsSync as existsSync4, statSync as statSync2 } from "fs";
1573
1620
  import { rename, writeFile as writeFile2 } from "fs/promises";
1574
1621
  import { join as join11 } from "path";
1575
- import process17 from "process";
1622
+ import process18 from "process";
1576
1623
 
1577
1624
  // src/changes.ts
1578
1625
  import { stat as stat2 } from "fs/promises";
@@ -1782,7 +1829,7 @@ function pick(steps, only, noun = "step") {
1782
1829
  // src/run.ts
1783
1830
  import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
1784
1831
  import { basename as basename2, join as join10 } from "path";
1785
- import process16 from "process";
1832
+ import process17 from "process";
1786
1833
 
1787
1834
  // src/e2e.ts
1788
1835
  var E2E_NOISE = [
@@ -2417,7 +2464,7 @@ var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
2417
2464
  async function logDirectory(cwd) {
2418
2465
  const root = await privateLogDirectory("check");
2419
2466
  await sweepLogs(root, LOG_MAX_AGE_MS);
2420
- const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process16.pid}`);
2467
+ const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process17.pid}`);
2421
2468
  await mkdir2(path, { mode: 448 });
2422
2469
  return path;
2423
2470
  }
@@ -2443,7 +2490,7 @@ async function lastFailed(cwd) {
2443
2490
  async function saveLog(output) {
2444
2491
  const root = await privateLogDirectory("errs");
2445
2492
  await sweepLogs(root);
2446
- const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process16.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2493
+ const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process17.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2447
2494
  await writeFile(path, output, { mode: 384, flag: "wx" });
2448
2495
  return path;
2449
2496
  }
@@ -2451,7 +2498,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
2451
2498
  const started = Date.now();
2452
2499
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
2453
2500
  cwd,
2454
- env: { ...process16.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2501
+ env: { ...process17.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2455
2502
  ...timeoutMs === undefined ? {} : { timeoutMs },
2456
2503
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
2457
2504
  });
@@ -2467,8 +2514,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
2467
2514
  return { name, command, ...service === undefined ? {} : { in: service }, ok: outcome.ok, ms: outcome.ms, log: logFile, ...outcome.timedOut === true ? { timedOut: true } : {}, ...outcome.ok ? {} : { failed: failureExcerpt(outcome.output) } };
2468
2515
  }
2469
2516
  function printOutcome(name, width, command, logFile, outcome) {
2470
- const colors = paint(process16.stdout);
2471
- const path = role("path", process16.stdout);
2517
+ const colors = paint(process17.stdout);
2518
+ const path = role("path", process17.stdout);
2472
2519
  const took = colors.dim(formatDuration(outcome.ms));
2473
2520
  if (outcome.ok) {
2474
2521
  console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
@@ -2499,7 +2546,7 @@ var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
2499
2546
  var RUFF_SECTION = /^\[tool\.ruff/m;
2500
2547
  var MAX_CHANGED = 30;
2501
2548
  async function replaceFile(path, content) {
2502
- const temporary = `${path}.${process17.pid}.tmp`;
2549
+ const temporary = `${path}.${process18.pid}.tmp`;
2503
2550
  await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
2504
2551
  await rename(temporary, path);
2505
2552
  }
@@ -2571,14 +2618,14 @@ function printChanged(changed) {
2571
2618
  if (changed.length > MAX_CHANGED)
2572
2619
  console.log(` and ${changed.length - MAX_CHANGED} more`);
2573
2620
  }
2574
- async function fix(args, cwd = process17.cwd()) {
2621
+ async function fix(args, cwd = process18.cwd()) {
2575
2622
  const parsed = parse(args, fixUsage, fixOptions, { replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
2576
2623
  return runFixers(parsed.values, cwd);
2577
2624
  }
2578
2625
  async function runFixers(values, cwd) {
2579
2626
  const parsed = { values };
2580
2627
  const settings = placeSettings(values);
2581
- if (process17.env[RUNNING] !== undefined)
2628
+ if (process18.env[RUNNING] !== undefined)
2582
2629
  fail("a fixer called fix again, which would recurse: give its script another command");
2583
2630
  const found = await fixers(cwd);
2584
2631
  if (found.length === 0)
@@ -2612,7 +2659,7 @@ async function runFixers(values, cwd) {
2612
2659
  break;
2613
2660
  if (missing(fixer)) {
2614
2661
  if (!json)
2615
- console.log(`${paint(process17.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2662
+ console.log(`${paint(process18.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2616
2663
  ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
2617
2664
  continue;
2618
2665
  }
@@ -2760,13 +2807,13 @@ function launch(step) {
2760
2807
  return step.placement === undefined ? step.command : shellIn(step.placement, step.command);
2761
2808
  }
2762
2809
  function summaryLine(outcomes) {
2763
- const colors = paint(process18.stdout);
2810
+ const colors = paint(process19.stdout);
2764
2811
  const failed = outcomes.filter((outcome) => !outcome.ok).length;
2765
2812
  const passed = outcomes.length - failed;
2766
2813
  const parts = [colors.green(`${passed} passed`), ...failed === 0 ? [] : [colors.red(`${failed} failed`)], colors.dim(formatDuration(outcomes.reduce((sum, outcome) => sum + outcome.ms, 0)))];
2767
2814
  return parts.join(colors.dim(" \xB7 "));
2768
2815
  }
2769
- async function check(args, cwd = process18.cwd()) {
2816
+ async function check(args, cwd = process19.cwd()) {
2770
2817
  const parsed = parse(args, usage2, options, { replaces: "chaining docker compose exec <service> bun run check | tail, lint and test by hand, or bun run check && bun run lint && bun run test read through tail", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"]] });
2771
2818
  const settings = placeSettings(parsed.values);
2772
2819
  if (parsed.values.fix === true) {
@@ -2777,7 +2824,7 @@ async function check(args, cwd = process18.cwd()) {
2777
2824
  return runFixers(parsed.values, cwd);
2778
2825
  }
2779
2826
  const timeoutMs = parsed.values.timeout === undefined ? undefined : duration(parsed.values.timeout, "timeout", 0);
2780
- if (parsed.values.slot === true && Bun.which("slot", { PATH: process18.env.PATH ?? "" }) === null)
2827
+ if (parsed.values.slot === true && Bun.which("slot", { PATH: process19.env.PATH ?? "" }) === null)
2781
2828
  fail("--slot needs the slot bin: bun install -g @kaynooo/cli-wait");
2782
2829
  const projects = await discoverProjects(cwd);
2783
2830
  const found = projects.flatMap((project) => project.steps.map((step) => ({ ...step, project })));
@@ -2807,7 +2854,7 @@ async function check(args, cwd = process18.cwd()) {
2807
2854
  const stack = new Stack;
2808
2855
  const width = Math.max(...steps.map((step) => step.label.length));
2809
2856
  const outcomes = [];
2810
- const heading = json ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process18.stdout);
2857
+ const heading = json ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process19.stdout);
2811
2858
  if (heading !== "")
2812
2859
  console.log(heading);
2813
2860
  try {
@@ -2838,4 +2885,4 @@ async function check(args, cwd = process18.cwd()) {
2838
2885
  }
2839
2886
 
2840
2887
  // src/cli.ts
2841
- process19.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });
2888
+ process20.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });