@kaynooo/cli-check 0.20.1 → 0.21.1

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
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env -S bun --no-env-file --config=/dev/null
2
2
  // @bun
3
+ var __esm = (fn, res, err) => () => {
4
+ if (fn)
5
+ try {
6
+ res = fn(fn = 0);
7
+ } catch (e) {
8
+ err = [e];
9
+ }
10
+ if (err)
11
+ throw err[0];
12
+ return res;
13
+ };
3
14
 
4
- // src/cli.ts
5
- import process23 from "process";
6
- // ../kit/src/args.ts
7
- import process10 from "process";
8
- import { parseArgs } from "util";
9
-
10
- // ../kit/src/format.ts
11
- import process7 from "process";
12
-
13
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
14
- var N = new Map;
15
- var Nt = /\s+\S*$/;
16
- var Y = /\s/;
17
- function ko(t, e, r = "...") {
15
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
16
+ function Ao(t, e, r = "...") {
18
17
  let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
19
18
  if (t.length <= e)
20
19
  return t;
@@ -25,13 +24,22 @@ function ko(t, e, r = "...") {
25
24
  c = c.trimEnd();
26
25
  return s ? (c + n).slice(0, l) : c + n;
27
26
  }
28
- var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
29
- var z = new Map;
27
+ var N, Nt, Y, be, W;
28
+ var init_chunk_rkhsft4a = __esm(() => {
29
+ N = new Map;
30
+ Nt = /\s+\S*$/;
31
+ Y = /\s/;
32
+ be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
33
+ W = new Map;
34
+ });
35
+
36
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
37
+ var init_text = __esm(() => {
38
+ init_chunk_rkhsft4a();
39
+ });
30
40
 
31
41
  // ../kit/src/mode.ts
32
42
  import process2 from "process";
33
- var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
34
- var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
35
43
  function isSet(value) {
36
44
  return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
37
45
  }
@@ -48,12 +56,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
48
56
  function isInteractive(streams = process2) {
49
57
  return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
50
58
  }
59
+ var MODES, AGENT_VARIABLES;
60
+ var init_mode = __esm(() => {
61
+ MODES = new Set(["terminal", "ci", "agent", "pipe"]);
62
+ AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
63
+ });
51
64
 
52
- // ../kit/src/style.ts
53
- import process6 from "process";
54
-
55
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
56
- var G2 = /^[a-f0-9]+$/i;
65
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
57
66
  function b(r) {
58
67
  let e = r.startsWith("#") ? r.slice(1) : r;
59
68
  if (!G2.test(e))
@@ -64,11 +73,6 @@ function b(r) {
64
73
  throw Error(`Invalid hex color length: ${e.length}`);
65
74
  return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
66
75
  }
67
- var B2 = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
68
- let [l, n, c] = b(r);
69
- return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
70
- }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
71
- var h = new Set(["", "1", "2", "3", "true"]);
72
76
  function C(r, e = globalThis.process?.env ?? {}) {
73
77
  if (e.FORCE_COLOR !== undefined)
74
78
  return h.has(e.FORCE_COLOR);
@@ -82,7 +86,7 @@ function f(r, e = []) {
82
86
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
83
87
  let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
84
88
  return new Proxy(c, { get(t, i) {
85
- let a = B2[i];
89
+ let a = B[i];
86
90
  if (Array.isArray(a)) {
87
91
  let s = g.get(i);
88
92
  if (s === undefined)
@@ -105,13 +109,21 @@ function f(r, e = []) {
105
109
  function Fe(r = {}) {
106
110
  return f(r);
107
111
  }
108
- var o = Fe();
112
+ var G2, B, h, o;
113
+ var init_chunk_x450vn3m = __esm(() => {
114
+ G2 = /^[a-f0-9]+$/i;
115
+ B = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
116
+ let [l, n, c] = b(r);
117
+ return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
118
+ }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
119
+ h = new Set(["", "1", "2", "3", "true"]);
120
+ o = Fe();
121
+ });
109
122
 
110
- // ../kit/src/theme.ts
111
- import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
112
- import { homedir as homedir2 } from "os";
113
- import { join as join3, resolve as resolve2 } from "path";
114
- import process5 from "process";
123
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
124
+ var init_colors = __esm(() => {
125
+ init_chunk_x450vn3m();
126
+ });
115
127
 
116
128
  // ../kit/src/config.ts
117
129
  import { existsSync } from "fs";
@@ -127,6 +139,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
127
139
  return;
128
140
  }
129
141
  }
142
+ var init_config = __esm(() => {
143
+ init_args();
144
+ });
130
145
 
131
146
  // ../kit/src/user-config.ts
132
147
  import { existsSync as existsSync2, readFileSync } from "fs";
@@ -158,36 +173,18 @@ function readUserConfig(bin, where = {}, legacy = []) {
158
173
  return {};
159
174
  }
160
175
  }
176
+ var init_user_config = () => {};
161
177
 
162
178
  // ../kit/src/theme.ts
163
- var ENDS = new Map;
164
- var DEFAULT = {
165
- colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", plan: "magenta", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
166
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", plan: "\u25C7", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
167
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
168
- bins: {},
169
- gradient: ["#c084fc", "#67e8f9"]
170
- };
171
- var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", plan: "magentaBright", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
172
- var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", plan: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
173
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
174
- var PRESETS = {
175
- default: {},
176
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
177
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
178
- ascii: { glyphs: ASCII }
179
- };
180
- 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"]);
181
- var HEX = /^#[0-9a-f]{6}$/i;
182
- var CONTROL = /\p{Cc}/u;
183
- var MAX_FILE_BYTES = 64 * 1024;
184
- var SPACES = /\s+/;
179
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
180
+ import { homedir as homedir2 } from "os";
181
+ import { join as join3, resolve as resolve2 } from "path";
182
+ import process5 from "process";
185
183
  function isColorSpec(spec) {
186
184
  if (typeof spec === "number")
187
185
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
188
186
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
189
187
  }
190
- var CUBE = [0, 95, 135, 175, 215, 255];
191
188
  function cubeLevel(channel) {
192
189
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
193
190
  }
@@ -292,7 +289,6 @@ function applyFile(theme, file, where, warn) {
292
289
  function endsWalk(home) {
293
290
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
294
291
  }
295
- var warned = new Set;
296
292
  function warnOnce(message) {
297
293
  if (warned.has(message))
298
294
  return;
@@ -329,8 +325,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
329
325
  }
330
326
  return { theme, sources, preset };
331
327
  }
332
- var current;
333
- var currentKey = "";
334
328
  function activeTheme() {
335
329
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
336
330
  if (current === undefined || key !== currentKey) {
@@ -339,9 +333,38 @@ function activeTheme() {
339
333
  }
340
334
  return current;
341
335
  }
336
+ var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
337
+ var init_theme = __esm(() => {
338
+ init_config();
339
+ init_user_config();
340
+ ENDS = new Map;
341
+ DEFAULT = {
342
+ colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", plan: "magenta", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
343
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", plan: "\u25C7", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
344
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
345
+ bins: {},
346
+ gradient: ["#c084fc", "#67e8f9"]
347
+ };
348
+ BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", plan: "magentaBright", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
349
+ MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", plan: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
350
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
351
+ PRESETS = {
352
+ default: {},
353
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
354
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
355
+ ascii: { glyphs: ASCII }
356
+ };
357
+ 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"]);
358
+ HEX = /^#[0-9a-f]{6}$/i;
359
+ CONTROL = /\p{Cc}/u;
360
+ MAX_FILE_BYTES = 64 * 1024;
361
+ SPACES = /\s+/;
362
+ CUBE = [0, 95, 135, 175, 215, 255];
363
+ warned = new Set;
364
+ });
342
365
 
343
366
  // ../kit/src/style.ts
344
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
367
+ import process6 from "process";
345
368
  function takesControlCodes(stream, env = process6.env) {
346
369
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
347
370
  }
@@ -364,14 +387,6 @@ function role(name, stream, env = process6.env) {
364
387
  const colors = paint(stream, env);
365
388
  return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
366
389
  }
367
- var STATUS_WORDS = {
368
- passed: ["passed", "success", "succeeded", "ok"],
369
- failed: ["failed", "failure", "error", "errored"],
370
- running: ["running", "in_progress", "started", "holding"],
371
- queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
372
- skipped: ["skipped", "cancelled", "canceled", "manual"]
373
- };
374
- var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
375
390
  function header(bin, context, stream, env = process6.env) {
376
391
  if (!takesControlCodes(stream, env))
377
392
  return "";
@@ -382,9 +397,24 @@ function header(bin, context, stream, env = process6.env) {
382
397
  const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
383
398
  return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
384
399
  }
400
+ var MARK_WORDS, STATUS_WORDS, STATUS_OF;
401
+ var init_style = __esm(() => {
402
+ init_colors();
403
+ init_mode();
404
+ init_theme();
405
+ MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
406
+ STATUS_WORDS = {
407
+ passed: ["passed", "success", "succeeded", "ok"],
408
+ failed: ["failed", "failure", "error", "errored"],
409
+ running: ["running", "in_progress", "started", "holding"],
410
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
411
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
412
+ };
413
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
414
+ });
385
415
 
386
416
  // ../kit/src/format.ts
387
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
417
+ import process7 from "process";
388
418
  function formatSeconds(total) {
389
419
  let rest = Math.max(0, Math.round(total));
390
420
  const amounts = UNITS.map(([unit, size]) => {
@@ -406,10 +436,8 @@ function upTo(text, separator) {
406
436
  return end === -1 ? text : text.slice(0, end);
407
437
  }
408
438
  function truncate(text, width) {
409
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
439
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
410
440
  }
411
- var LINE_BREAKS = /\s*\n\s*/g;
412
- var ESCAPE = String.fromCharCode(27);
413
441
  function textWidth(text) {
414
442
  return Bun.stringWidth(text);
415
443
  }
@@ -458,14 +486,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
458
486
  function printJson(value) {
459
487
  console.log(jsonText(value));
460
488
  }
489
+ var UNITS, LINE_BREAKS, ESCAPE;
490
+ var init_format = __esm(() => {
491
+ init_text();
492
+ init_mode();
493
+ init_style();
494
+ UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
495
+ LINE_BREAKS = /\s*\n\s*/g;
496
+ ESCAPE = String.fromCharCode(27);
497
+ });
461
498
 
462
499
  // ../kit/src/help.ts
463
500
  import process8 from "process";
464
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
465
- var USAGE_PREFIX = /^usage:\s*/i;
466
- var FULL_STOP = /\.$/;
467
501
  function usageLine(usage, colors = paint(process8.stdout)) {
468
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
502
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
503
+ `);
504
+ const blank = lines.indexOf("");
505
+ const synopses = blank === -1 ? lines : lines.slice(0, blank);
506
+ const details = blank === -1 ? [] : lines.slice(blank + 1);
507
+ const colon = synopses[0].indexOf(": ");
508
+ const inline = synopses[0].slice(colon + 2);
509
+ const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
510
+ if (colon !== -1)
511
+ synopses[0] = synopses[0].slice(0, colon);
512
+ const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
513
+ `)}`;
514
+ const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
515
+ const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
516
+ return [head, ...lead, ...rest].join(`
517
+ `);
518
+ }
519
+ function prose(line, colors) {
520
+ if (colors.cyan("x") === "x")
521
+ return line;
522
+ return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
469
523
  }
470
524
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
471
525
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -500,7 +554,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
500
554
  return [];
501
555
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
502
556
  }
503
- var MAX_INLINE_CHOICES = 24;
504
557
  function optionRows(options, colors = paint(process8.stdout)) {
505
558
  const rows = Object.entries(options).map(([name, option]) => {
506
559
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -515,9 +568,17 @@ function optionRows(options, colors = paint(process8.stdout)) {
515
568
  const width = Math.max(0, ...rows.map((row) => row.width));
516
569
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
517
570
  }
571
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
572
+ var init_help = __esm(() => {
573
+ init_mode();
574
+ init_style();
575
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
576
+ USAGE_PREFIX = /^usage:\s*/i;
577
+ FULL_STOP = /\.$/;
578
+ PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
579
+ });
518
580
 
519
581
  // ../kit/src/text.ts
520
- var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
521
582
  function stripAnsi(text) {
522
583
  return text.replace(ANSI, "");
523
584
  }
@@ -546,10 +607,13 @@ function closest(name, names) {
546
607
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
547
608
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
548
609
  }
610
+ var ANSI;
611
+ var init_text2 = __esm(() => {
612
+ ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
613
+ });
614
+
549
615
  // ../kit/src/input.ts
550
616
  import process9 from "process";
551
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
552
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
553
617
  function duration(value, name, fallback, unit = "s") {
554
618
  if (value === undefined)
555
619
  return fallback;
@@ -570,40 +634,26 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
570
634
  fail(`no file ${path}`);
571
635
  return file.text();
572
636
  }
637
+ var DURATION, UNIT_MS;
638
+ var init_input = __esm(() => {
639
+ init_args();
640
+ DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
641
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
642
+ });
573
643
 
574
644
  // ../kit/src/args.ts
575
- var DASHES = /^-+/;
645
+ import process10 from "process";
646
+ import { parseArgs } from "util";
576
647
  function jsonOption(holds) {
577
648
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
578
649
  }
579
- class Exit extends Error {
580
- code;
581
- hint;
582
- constructor(message, code, hint) {
583
- super(message);
584
- this.code = code;
585
- this.hint = hint;
586
- }
587
- }
588
650
  function fail(message, code = 2, hint) {
589
651
  throw new Exit(message, code, hint);
590
652
  }
591
-
592
- class UsageError extends Exit {
593
- constructor(message, hint) {
594
- super(message, 2, hint);
595
- }
596
- }
597
653
  function badUsage(message) {
598
654
  throw new UsageError(message);
599
655
  }
600
656
 
601
- class HelpShown extends Exit {
602
- constructor() {
603
- super("help shown", 0);
604
- }
605
- }
606
-
607
657
  class Completing {
608
658
  options;
609
659
  positionals;
@@ -614,11 +664,6 @@ class Completing {
614
664
  this.candidates = candidates;
615
665
  }
616
666
  }
617
- var completion = { active: false };
618
- var OUTPUT_OPTIONS = {
619
- color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
620
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
621
- };
622
667
  function applyOutput(color, plain, env = process10.env) {
623
668
  const when = plain === true ? "never" : color ?? "auto";
624
669
  if (when === "auto")
@@ -772,7 +817,6 @@ function parseError(error) {
772
817
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
773
818
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
774
819
  }
775
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
776
820
  function nearestOption(message, options, allowNegative) {
777
821
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
778
822
  if (typed === undefined)
@@ -788,6 +832,72 @@ function nearestOption(message, options, allowNegative) {
788
832
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
789
833
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
790
834
  }
835
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
836
+ var init_args = __esm(() => {
837
+ init_format();
838
+ init_help();
839
+ init_text2();
840
+ init_help();
841
+ init_input();
842
+ DASHES = /^-+/;
843
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
844
+ Exit = class Exit extends Error {
845
+ code;
846
+ hint;
847
+ [EXIT] = true;
848
+ constructor(message, code, hint) {
849
+ super(message);
850
+ this.code = code;
851
+ this.hint = hint;
852
+ }
853
+ static [Symbol.hasInstance](value) {
854
+ if (this !== Exit)
855
+ return Function.prototype[Symbol.hasInstance].call(this, value);
856
+ return typeof value === "object" && value !== null && value[EXIT] === true;
857
+ }
858
+ };
859
+ UsageError = class UsageError extends Exit {
860
+ constructor(message, hint) {
861
+ super(message, 2, hint);
862
+ }
863
+ };
864
+ HelpShown = class HelpShown extends Exit {
865
+ constructor() {
866
+ super("help shown", 0);
867
+ }
868
+ };
869
+ completion = { active: false };
870
+ OUTPUT_OPTIONS = {
871
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
872
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
873
+ };
874
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
875
+ });
876
+
877
+ // ../kit/src/folders.ts
878
+ import { homedir as homedir5 } from "os";
879
+ import { join as join7 } from "path";
880
+ import process18 from "process";
881
+ function ignoredFolders(extra = [], where = {}) {
882
+ const configured = readUserConfig("config", where).ignore;
883
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
884
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
885
+ }
886
+ function cacheFolder({ home = homedir5(), env = process18.env } = {}) {
887
+ return env.XDG_CACHE_HOME ?? join7(home, ".cache");
888
+ }
889
+ var SKIPPED_FOLDERS;
890
+ var init_folders = __esm(() => {
891
+ init_user_config();
892
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
893
+ });
894
+
895
+ // src/cli.ts
896
+ import process24 from "process";
897
+
898
+ // ../kit/src/index.ts
899
+ init_args();
900
+
791
901
  // ../kit/src/argv.ts
792
902
  import { readFileSync as readFileSync3, realpathSync } from "fs";
793
903
  import { resolve as resolve3 } from "path";
@@ -812,6 +922,18 @@ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), scr
812
922
  const after = at === -1 ? [] : cmdline.slice(at + 1);
813
923
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
814
924
  }
925
+ // ../kit/src/chart.ts
926
+ init_format();
927
+ init_mode();
928
+ init_style();
929
+ init_theme();
930
+ // ../kit/src/ci.ts
931
+ init_args();
932
+ init_format();
933
+
934
+ // ../kit/src/progress.ts
935
+ init_format();
936
+
815
937
  // ../kit/src/process.ts
816
938
  import { constants } from "os";
817
939
  import process12 from "process";
@@ -855,10 +977,10 @@ function holdSignals(cleanup) {
855
977
  process12.on(signal, onSignal);
856
978
  return held;
857
979
  }
858
- async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
980
+ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
859
981
  const chunks = [];
860
982
  const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
861
- const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
983
+ const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
862
984
  const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
863
985
  const timers = [];
864
986
  const killGroup = (killing) => {
@@ -935,14 +1057,62 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
935
1057
  }
936
1058
 
937
1059
  // ../kit/src/progress.ts
1060
+ init_style();
1061
+ init_theme();
938
1062
  var ESC = String.fromCharCode(27);
939
1063
  var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
940
1064
  var RESET_STYLE = `${ESC}[0m`;
941
1065
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
1066
+
1067
+ // ../kit/src/ci.ts
1068
+ init_style();
1069
+
1070
+ // ../kit/src/tool.ts
1071
+ init_format();
942
1072
  // ../kit/src/cli.ts
1073
+ init_args();
943
1074
  import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
944
1075
  import { dirname as dirname3, join as join6 } from "path";
945
- import process16 from "process";
1076
+ import process17 from "process";
1077
+
1078
+ // ../kit/src/askpass.ts
1079
+ import process13 from "process";
1080
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1081
+ async function askpassClient(argv) {
1082
+ const socketPath = process13.env[SOCKET_VARIABLE];
1083
+ if (socketPath === undefined)
1084
+ return;
1085
+ const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1086
+ const { promise, resolve } = Promise.withResolvers();
1087
+ let received = "";
1088
+ try {
1089
+ await Bun.connect({
1090
+ unix: socketPath,
1091
+ socket: {
1092
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1093
+ `),
1094
+ data: (_, chunk) => {
1095
+ received += chunk.toString();
1096
+ },
1097
+ close: () => resolve(received),
1098
+ error: () => resolve("")
1099
+ }
1100
+ });
1101
+ } catch {
1102
+ return 1;
1103
+ }
1104
+ const reply = await promise;
1105
+ if (reply === "")
1106
+ return 1;
1107
+ const { answer } = JSON.parse(reply);
1108
+ if (request.notice === true)
1109
+ return 0;
1110
+ if (answer === undefined)
1111
+ return 1;
1112
+ process13.stdout.write(`${answer}
1113
+ `);
1114
+ return 0;
1115
+ }
946
1116
 
947
1117
  // ../kit/src/completions.ts
948
1118
  var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
@@ -1005,46 +1175,52 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
1005
1175
  }
1006
1176
 
1007
1177
  // ../kit/src/notify.ts
1008
- import process13 from "process";
1178
+ init_format();
1179
+ init_mode();
1180
+ import process14 from "process";
1009
1181
  var NOTIFY_AFTER_MS = 1e4;
1010
1182
  var CANCELLED = 130;
1011
1183
  function base64(text) {
1012
1184
  return Buffer.from(text).toString("base64");
1013
1185
  }
1014
- function notification(title, body, env = process13.env) {
1015
- const id = `kit${process13.pid}`;
1186
+ function notification(title, body, env = process14.env) {
1187
+ const id = `kit${process14.pid}`;
1016
1188
  const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
1017
1189
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1018
1190
  }
1019
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1191
+ function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
1020
1192
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1021
1193
  return;
1022
1194
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1023
1195
  }
1024
1196
 
1197
+ // ../kit/src/cli.ts
1198
+ init_style();
1199
+ init_text2();
1200
+
1025
1201
  // ../kit/src/usage.ts
1026
1202
  import { appendFileSync, mkdirSync } from "fs";
1027
1203
  import { homedir as homedir4 } from "os";
1028
1204
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1029
- import process15 from "process";
1205
+ import process16 from "process";
1030
1206
 
1031
1207
  // ../kit/src/logs.ts
1032
1208
  import { lstatSync, openSync } from "fs";
1033
1209
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
1034
1210
  import { homedir as homedir3, tmpdir } from "os";
1035
1211
  import { join as join4 } from "path";
1036
- import process14 from "process";
1212
+ import process15 from "process";
1037
1213
  var DAY_MS = 24 * 60 * 60 * 1000;
1038
1214
  var CLI_FOLDER = "kaynooo-cli";
1039
1215
  function isPrivateDirectory(path) {
1040
1216
  try {
1041
1217
  const info = lstatSync(path, { throwIfNoEntry: false });
1042
- return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1218
+ return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1043
1219
  } catch {
1044
1220
  return false;
1045
1221
  }
1046
1222
  }
1047
- async function privateLogDirectory(name, env = process14.env) {
1223
+ async function privateLogDirectory(name, env = process15.env) {
1048
1224
  const runtime = env.XDG_RUNTIME_DIR;
1049
1225
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1050
1226
  const path = join4(base, name);
@@ -1084,14 +1260,14 @@ var usageError;
1084
1260
  function noteUsageError(message) {
1085
1261
  usageError = message;
1086
1262
  }
1087
- function stateHome(env = process15.env) {
1263
+ function stateHome(env = process16.env) {
1088
1264
  const dir = env.XDG_STATE_HOME;
1089
1265
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1090
1266
  }
1091
- function usagePath(env = process15.env) {
1267
+ function usagePath(env = process16.env) {
1092
1268
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1093
1269
  }
1094
- function usageRecorded(env = process15.env) {
1270
+ function usageRecorded(env = process16.env) {
1095
1271
  const off = env.KAYNOOO_CLI_NO_USAGE;
1096
1272
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1097
1273
  }
@@ -1100,12 +1276,12 @@ function flagNames(argv) {
1100
1276
  const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
1101
1277
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1102
1278
  }
1103
- function usageEntry(bin, command, argv, code, now = new Date) {
1279
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1104
1280
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1105
1281
  usageError = undefined;
1106
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1282
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
1107
1283
  }
1108
- function recordUsage(entry, env = process15.env) {
1284
+ function recordUsage(entry, env = process16.env) {
1109
1285
  if (!usageRecorded(env))
1110
1286
  return;
1111
1287
  try {
@@ -1127,8 +1303,8 @@ var TOP_OPTIONS = {
1127
1303
  completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1128
1304
  };
1129
1305
  function printError(prefix, message, hint, cause) {
1130
- const colors = paint(process16.stderr);
1131
- const styled = takesControlCodes(process16.stderr);
1306
+ const colors = paint(process17.stderr);
1307
+ const styled = takesControlCodes(process17.stderr);
1132
1308
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1133
1309
  const under = (label, text, tint) => text === undefined ? "" : `
1134
1310
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1239,6 +1415,9 @@ function packageVersion(entry = Bun.main) {
1239
1415
  }
1240
1416
  }
1241
1417
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1418
+ const answered = await askpassClient(argv);
1419
+ if (answered !== undefined)
1420
+ return answered;
1242
1421
  if (argv[0] === COMPLETE)
1243
1422
  return printCandidates(leafCandidates(run, argv.slice(1)));
1244
1423
  if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
@@ -1257,12 +1436,17 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1257
1436
  notifyEnd(name, code, performance.now() - started);
1258
1437
  if (usage !== false) {
1259
1438
  try {
1260
- recordUsage(usageEntry(name, undefined, argv, code));
1439
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
1261
1440
  } catch {}
1262
1441
  }
1263
1442
  return code;
1264
1443
  }
1444
+
1445
+ // ../kit/src/index.ts
1446
+ init_config();
1447
+
1265
1448
  // ../kit/src/excerpt.ts
1449
+ init_text2();
1266
1450
  var BASH_ECHO = /^\$ /;
1267
1451
  var DURATION2 = / \[[\d.]+m?s\]$/;
1268
1452
  var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
@@ -1417,32 +1601,48 @@ function failureExcerpt(output) {
1417
1601
  return cut(squeeze(recognised(lines, PARSERS) ?? lines.slice(-TAIL)));
1418
1602
  }
1419
1603
  var LOG_PATTERNS = { BASH_ECHO, DURATION: DURATION2, BOUNDARY, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_CONTINUATION, TSC_FRAME, TSC_SUMMARY, ESLINT_PROBLEM, ESLINT_SUMMARY };
1420
- // ../kit/src/folders.ts
1421
- import { homedir as homedir5 } from "os";
1422
- import { join as join7 } from "path";
1423
- import process17 from "process";
1424
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1425
- function ignoredFolders(extra = [], where = {}) {
1426
- const configured = readUserConfig("config", where).ignore;
1427
- const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1428
- return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1429
- }
1430
- function cacheFolder({ home = homedir5(), env = process17.env } = {}) {
1431
- return env.XDG_CACHE_HOME ?? join7(home, ".cache");
1432
- }
1604
+
1605
+ // ../kit/src/index.ts
1606
+ init_folders();
1607
+ init_format();
1608
+
1609
+ // ../kit/src/git.ts
1610
+ init_args();
1611
+ // ../kit/src/limit.ts
1612
+ init_args();
1613
+
1614
+ // ../kit/src/index.ts
1615
+ init_mode();
1616
+
1617
+ // ../kit/src/report.ts
1618
+ init_style();
1619
+ init_text2();
1433
1620
  // ../kit/src/secrets.ts
1434
1621
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1435
1622
  // ../kit/src/sessions.ts
1436
1623
  var {Glob } = globalThis.Bun;
1437
1624
  var SESSION_FILES = new Glob("*.json");
1438
1625
  var ACCOUNT_DIRS = new Glob("*/sessions");
1626
+
1627
+ // ../kit/src/index.ts
1628
+ init_style();
1629
+ init_text2();
1630
+ init_theme();
1631
+ init_user_config();
1632
+
1633
+ // ../kit/src/watch.ts
1634
+ init_args();
1635
+ init_input();
1636
+ init_style();
1637
+ // ../kit/src/workspace-root.ts
1638
+ init_user_config();
1439
1639
  // package.json
1440
- var version = "0.20.1";
1640
+ var version = "0.21.1";
1441
1641
 
1442
1642
  // src/check.ts
1443
1643
  import { writeFile as writeFile3 } from "fs/promises";
1444
1644
  import { basename as basename4, join as join14 } from "path";
1445
- import process22 from "process";
1645
+ import process23 from "process";
1446
1646
 
1447
1647
  // ../kit/src/shell.ts
1448
1648
  var SEPARATORS = new Set([`
@@ -1495,7 +1695,7 @@ function shellQuote(word) {
1495
1695
  import { existsSync as existsSync4 } from "fs";
1496
1696
  import { homedir as homedir6 } from "os";
1497
1697
  import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
1498
- import process19 from "process";
1698
+ import process20 from "process";
1499
1699
  var COMPOSE_FILES = ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"];
1500
1700
  var OVERRIDE_FILES = ["compose.override.yaml", "compose.override.yml", "docker-compose.override.yaml", "docker-compose.override.yml"];
1501
1701
  var PS_TIMEOUT_MS = 20000;
@@ -1539,7 +1739,7 @@ async function variables(composeDir) {
1539
1739
  if (match !== null && !line.trimStart().startsWith("#"))
1540
1740
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1541
1741
  }
1542
- for (const [key, value] of Object.entries(process19.env)) {
1742
+ for (const [key, value] of Object.entries(process20.env)) {
1543
1743
  if (value !== undefined)
1544
1744
  env[key] = value;
1545
1745
  }
@@ -1675,7 +1875,7 @@ async function place(dir, program, { service, host } = {}) {
1675
1875
  fail(`--in ${service}: no compose project mounts ${dir}`);
1676
1876
  return;
1677
1877
  }
1678
- if (Bun.which("docker", { PATH: process19.env.PATH ?? "" }) === null) {
1878
+ if (Bun.which("docker", { PATH: process20.env.PATH ?? "" }) === null) {
1679
1879
  if (service !== undefined)
1680
1880
  fail(`--in ${service}: docker not found`);
1681
1881
  if (!noticed.has(found.composeDir)) {
@@ -1727,7 +1927,7 @@ class Stack {
1727
1927
  }
1728
1928
  static async running(composeDir) {
1729
1929
  try {
1730
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process19.env, timeoutMs: PS_TIMEOUT_MS });
1930
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process20.env, timeoutMs: PS_TIMEOUT_MS });
1731
1931
  if (ran.code !== 0)
1732
1932
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1733
1933
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -1762,7 +1962,7 @@ function placeSettings(values) {
1762
1962
  import { existsSync as existsSync5, statSync as statSync2 } from "fs";
1763
1963
  import { rename, writeFile as writeFile2 } from "fs/promises";
1764
1964
  import { join as join12 } from "path";
1765
- import process21 from "process";
1965
+ import process22 from "process";
1766
1966
 
1767
1967
  // src/changes.ts
1768
1968
  import { stat as stat2 } from "fs/promises";
@@ -1944,17 +2144,13 @@ async function discover(dir) {
1944
2144
  }
1945
2145
 
1946
2146
  // src/options.ts
1947
- var fixOptions = {
2147
+ var options = {
1948
2148
  list: { type: "boolean", short: "l", description: "print the steps (or, with --fix, the fixers) found, the commands that run them and where (host or service), without running them" },
1949
- only: { type: "string", short: "o", description: `comma separated steps to run, among ${STEP_NAMES.join(", ")}; with --fix the fixers to run, by the names --list prints` },
2149
+ only: { type: "string", short: "o", description: `comma separated steps to run, among ${STEP_NAMES.join(", ")}; with --fix the fixers to run, by the names --list prints`, candidates: () => [...STEP_NAMES] },
1950
2150
  timeout: { type: "string", short: "t", description: "longest a step or fixer may run before it is ended (30s, 5m, 1h), none by default" },
1951
2151
  ...placeOptions,
1952
- json: jsonOption()
1953
- };
1954
- var options = {
1955
- ...fixOptions,
1956
- only: { ...fixOptions.only, candidates: () => [...STEP_NAMES] },
1957
- fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps, as the fix bin does" },
2152
+ json: jsonOption("[{name, command, in?, ok, ms, log, failed?}], with --list [{name, command, source, in?}], with --fix {fixers, changed}"),
2153
+ fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps" },
1958
2154
  quiet: { type: "boolean", short: "q", description: "print nothing for a passing step, and nothing at all when every step passes" },
1959
2155
  failed: { type: "boolean", description: "run only the steps that failed in the last run of this folder, read from the run folder" },
1960
2156
  changed: { type: "boolean", short: "c", description: "narrow lint and test to the files changed against HEAD (a bare linter script, a bare bun test script), every other step runs in full and says so" },
@@ -1978,14 +2174,14 @@ function pick(steps, only, noun = "step") {
1978
2174
  // src/run.ts
1979
2175
  import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
1980
2176
  import { basename as basename2, join as join11 } from "path";
1981
- import process20 from "process";
2177
+ import process21 from "process";
1982
2178
  var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
1983
2179
  var RESULTS_FILE = "results.json";
1984
2180
  var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
1985
2181
  async function logDirectory(cwd) {
1986
2182
  const root = await privateLogDirectory("check");
1987
2183
  await sweepLogs(root, LOG_MAX_AGE_MS);
1988
- const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process20.pid}`);
2184
+ const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process21.pid}`);
1989
2185
  await mkdir2(path, { mode: 448 });
1990
2186
  return path;
1991
2187
  }
@@ -2013,7 +2209,7 @@ async function lastFailed(cwd) {
2013
2209
  async function saveLog(output) {
2014
2210
  const root = await privateLogDirectory("errs");
2015
2211
  await sweepLogs(root);
2016
- const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process20.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2212
+ const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process21.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2017
2213
  await writeFile(path, output, { mode: 384, flag: "wx" });
2018
2214
  return path;
2019
2215
  }
@@ -2021,7 +2217,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
2021
2217
  const started = Date.now();
2022
2218
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
2023
2219
  cwd,
2024
- env: { ...process20.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2220
+ env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2025
2221
  ...timeoutMs === undefined ? {} : { timeoutMs },
2026
2222
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
2027
2223
  });
@@ -2037,8 +2233,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
2037
2233
  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) } };
2038
2234
  }
2039
2235
  function printOutcome(name, width, command, logFile, outcome) {
2040
- const colors = paint(process20.stdout);
2041
- const path = role("path", process20.stdout);
2236
+ const colors = paint(process21.stdout);
2237
+ const path = role("path", process21.stdout);
2042
2238
  const took = colors.dim(formatDuration(outcome.ms));
2043
2239
  if (outcome.ok) {
2044
2240
  console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
@@ -2054,27 +2250,18 @@ function printOutcome(name, width, command, logFile, outcome) {
2054
2250
  }
2055
2251
 
2056
2252
  // src/fix.ts
2057
- var fixUsage = `fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
2058
-
2059
- Alias of \`check --fix\`. Runs the folder's fixers: the project's own \`fix\` script, else its \`lint:fix\` and \`format\` ones (package.json through bun run, composer.json, a Justfile or a Makefile), then the formatters its files call for: php-cs-fixer where configured and composer.json has no fixer, just --fmt, go fmt and go mod tidy, cargo fmt, ruff where configured, and every Makefile target declared .PHONY.
2060
- It looks at the folder itself only, so each package of a monorepo gets its own run.
2061
- A script or php-cs-fixer runs inside the docker compose service that bind-mounts the folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path; a service that is down is never started, the fixer fails naming it. The formatters run on the host. --in picks the service, --host forces the host.
2062
- Prints one line per fixer, what a failing one said, then the files the run changed. Each fixer's full output is saved to the file whose path ends its line.
2063
- A fixer still running after --timeout is ended with everything it started, but not what it started inside a container.
2064
- --json prints {fixers: [{name, command, in?, ok, ms, log, failed?} or {name, command, skipped}], changed} once every fixer ran, changed null outside a git repository.`;
2065
- var EXITS = [[0, "every fixer ran or was skipped for a missing binary"], [1, "one failed"], [2, "bad usage, nothing applies or a fixer timed out"]];
2066
2253
  var RUNNING = "KAYNOOO_CLI_FIX";
2067
2254
  var JUSTFILES2 = ["justfile", "Justfile", ".justfile"];
2068
2255
  var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
2069
2256
  var RUFF_SECTION = /^\[tool\.ruff/m;
2070
2257
  var MAX_CHANGED = 30;
2071
2258
  async function replaceFile(path, content) {
2072
- const temporary = `${path}.${process21.pid}.tmp`;
2259
+ const temporary = `${path}.${process22.pid}.tmp`;
2073
2260
  await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
2074
2261
  await rename(temporary, path);
2075
2262
  }
2076
2263
  async function projectFixers(dir) {
2077
- const found = await candidates(dir, "fix");
2264
+ const found = await candidates(dir, "check");
2078
2265
  const named = (name) => found.find((step) => step.name === name);
2079
2266
  const all = named("fix");
2080
2267
  if (all !== undefined)
@@ -2106,7 +2293,6 @@ async function toolFixers(dir) {
2106
2293
  fixers.push({ name: "python", command: "ruff check --fix . && ruff format .", source: "ruff", requires: "ruff" });
2107
2294
  return fixers;
2108
2295
  }
2109
- var fixParseOptions = { ...fixOptions, only: { ...fixOptions.only, candidates: async () => (await fixers(process21.cwd())).map((fixer) => fixer.name) } };
2110
2296
  async function fixers(dir) {
2111
2297
  const project = await projectFixers(dir);
2112
2298
  const csFixer = await firstFile(dir, CS_FIXER_CONFIGS);
@@ -2142,15 +2328,11 @@ function printChanged(changed) {
2142
2328
  if (changed.length > MAX_CHANGED)
2143
2329
  console.log(` and ${changed.length - MAX_CHANGED} more`);
2144
2330
  }
2145
- async function fix(args, cwd = process21.cwd()) {
2146
- const parsed = parse(args, fixUsage, fixParseOptions, { exits: EXITS, 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"]] });
2147
- return runFixers(parsed.values, cwd);
2148
- }
2149
2331
  async function runFixers(values, cwd) {
2150
2332
  const parsed = { values };
2151
2333
  const settings = placeSettings(values);
2152
- if (process21.env[RUNNING] !== undefined)
2153
- fail("a fixer called fix again, which would recurse: give its script another command");
2334
+ if (process22.env[RUNNING] !== undefined)
2335
+ fail("a fixer called check --fix again, which would recurse: give its script another command");
2154
2336
  const found = await fixers(cwd);
2155
2337
  if (found.length === 0)
2156
2338
  fail("nothing to fix here: no fix, lint:fix or format script, php-cs-fixer config, Makefile, Justfile, go.mod, Cargo.toml nor ruff config");
@@ -2183,7 +2365,7 @@ async function runFixers(values, cwd) {
2183
2365
  break;
2184
2366
  if (missing(fixer)) {
2185
2367
  if (!json)
2186
- console.log(`${paint(process21.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2368
+ console.log(`${paint(process22.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2187
2369
  ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
2188
2370
  continue;
2189
2371
  }
@@ -2293,19 +2475,11 @@ async function scriptText(dir, name) {
2293
2475
  var usage2 = `check [--only <steps>] [--changed] [--failed] [--quiet] [--timeout <duration>] [--slot | --no-slot] [--parallel] [--in <service> | --host] [--list]
2294
2476
  check --fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
2295
2477
 
2296
- Runs the repo's check, typecheck, lint and test steps, from package.json scripts (through bun run), composer.json, a Justfile or a Makefile, and for PHP from phpstan.neon (typecheck), .php-cs-fixer.dist.php (lint, dry-run) and phpunit.xml.dist (test) when composer.json has no such script.
2297
- A folder without steps but with subfolders that have some (api/ and client/) runs each one's, each line naming its subfolder.
2298
- A step runs inside the docker compose service that bind-mounts its folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path; a service that is down is never started, the step fails naming it. --in picks the service, --host forces the host.
2299
- A passing step is one line, a failing one shows only what failed, and each step's full output is saved to the file whose path ends its line.
2300
- With --changed, lint and test run on the files changed against HEAD (staged, unstaged and untracked) when their script is a bare linter (keslint, eslint, oxlint) or a bare \`bun test\`: lint on the changed source files, test on the changed test files and the tests next to the changed sources. Every other step, and a test step finding no test for the diff, runs in full and the line says so.
2301
- Each step queues for one of the machine-wide slots shared by every session (slot, half the CPUs) when the slot bin is installed, so concurrent runs do not overload the machine; --no-slot skips the queue, --slot fails when the bin is missing.
2302
- With --parallel, the steps run at the same time, each one's output held and printed in step order as the earlier ones finish; each still queues for its own slot. Steps writing the same files may trip over each other.
2303
- With --quiet, passing steps print nothing, and a fully passing run prints nothing at all: only the failing steps and the closing summary of a run that failed.
2304
- A step still running after --timeout is ended with everything it started, but not what it started inside a container.
2305
- With --failed, only the steps that failed in the last run of this folder run again, read from that run's folder of logs; when no last run failed, it says so and exits 2.
2306
- With --fix, the folder's fixers and formatters run instead of the steps, exactly as the \`fix\` bin does (it is the alias of \`check --fix\`): its own scripts, php-cs-fixer, just --fmt, go fmt, cargo fmt, ruff and the Makefile's .PHONY targets, then the files the run changed are listed. --only then names fixers, as --list prints them; --changed, --failed, --slot, --no-slot and --parallel do not apply.
2307
- --json prints [{name, command, in?, ok, ms, log, failed?}] once every step ran, --list --json [{name, command, source, in?}], in the compose service the step ran in; with --fix the shape \`fix --json\` prints.`;
2308
- var EXITS2 = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
2478
+ Runs the repo's check, typecheck, lint and test steps, found in package.json scripts, composer.json, a Justfile, a Makefile or the PHP tools' configs; a folder with no steps runs its subfolders' (api/, client/).
2479
+ A step runs inside the running compose service that mounts its folder and never starts one, and queues for a machine-wide slot when \`slot\` is installed.
2480
+ A passing step prints one line, a failing one only what failed, and each step's full log is saved to the file its line ends with.
2481
+ With --fix, the project's fix, lint:fix and format scripts run instead, then the formatters its files call for (php-cs-fixer, \`just --fmt\`, go fmt, cargo fmt, ruff), and the files they changed are listed.`;
2482
+ var EXITS = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
2309
2483
  function slotted(command) {
2310
2484
  return `slot -- sh -c ${shellQuote(command)}`;
2311
2485
  }
@@ -2334,14 +2508,14 @@ function launch(step) {
2334
2508
  return step.placement === undefined ? step.command : shellIn(step.placement, step.command);
2335
2509
  }
2336
2510
  function summaryLine(outcomes) {
2337
- const colors = paint(process22.stdout);
2511
+ const colors = paint(process23.stdout);
2338
2512
  const failed = outcomes.filter((outcome) => !outcome.ok).length;
2339
2513
  const passed = outcomes.length - failed;
2340
2514
  const parts = [colors.green(`${passed} passed`), ...failed === 0 ? [] : [colors.red(`${failed} failed`)], colors.dim(formatDuration(outcomes.reduce((sum, outcome) => sum + outcome.ms, 0)))];
2341
2515
  return parts.join(colors.dim(" \xB7 "));
2342
2516
  }
2343
- async function check(args, cwd = process22.cwd()) {
2344
- const parsed = parse(args, usage2, options, { exits: EXITS2, 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"]] });
2517
+ async function check(args, cwd = process23.cwd()) {
2518
+ const parsed = parse(args, usage2, options, { exits: EXITS, 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, and with --fix each fixer and formatter run by hand", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"], ["check --fix", "the fixers and formatters instead"], ["check --fix --list", "the fixers it would run"]] });
2345
2519
  const settings = placeSettings(parsed.values);
2346
2520
  if (parsed.values.fix === true) {
2347
2521
  for (const flag of ["changed", "failed", "slot", "no-slot", "parallel"]) {
@@ -2353,7 +2527,7 @@ async function check(args, cwd = process22.cwd()) {
2353
2527
  const timeoutMs = parsed.values.timeout === undefined ? undefined : duration(parsed.values.timeout, "timeout", 0);
2354
2528
  if (parsed.values.slot === true && parsed.values["no-slot"] === true)
2355
2529
  fail("--slot and --no-slot exclude each other");
2356
- const hasSlot = Bun.which("slot", { PATH: process22.env.PATH ?? "" }) !== null;
2530
+ const hasSlot = Bun.which("slot", { PATH: process23.env.PATH ?? "" }) !== null;
2357
2531
  if (parsed.values.slot === true && !hasSlot)
2358
2532
  fail("--slot needs the slot bin: bun install -g @kaynooo/cli-wait");
2359
2533
  const slotting = parsed.values["no-slot"] !== true && hasSlot;
@@ -2386,7 +2560,7 @@ async function check(args, cwd = process22.cwd()) {
2386
2560
  const width = Math.max(...steps.map((step) => step.label.length));
2387
2561
  const outcomes = [];
2388
2562
  const quiet = parsed.values.quiet === true;
2389
- const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process22.stdout);
2563
+ const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process23.stdout);
2390
2564
  if (heading !== "")
2391
2565
  console.log(heading);
2392
2566
  const execute = async (step, signals) => {
@@ -2439,4 +2613,4 @@ async function check(args, cwd = process22.cwd()) {
2439
2613
  }
2440
2614
 
2441
2615
  // src/cli.ts
2442
- process23.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });
2616
+ process24.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });