@kaynooo/cli-check 0.20.0 → 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/errs-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/errs-cli.ts
5
- import process22 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", description: "auto (on a terminal alone), always or never" },
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/errs-cli.ts
896
+ import process23 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,56 +1057,170 @@ 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";
946
1077
 
947
- // ../kit/src/notify.ts
1078
+ // ../kit/src/askpass.ts
948
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
+ }
1116
+
1117
+ // ../kit/src/completions.ts
1118
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
1119
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
1120
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
1121
+ set -l current (commandline -ct)
1122
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
1123
+ if test "$line" = __files__
1124
+ __fish_complete_path $current
1125
+ else
1126
+ echo $line
1127
+ end
1128
+ end
1129
+ end`;
1130
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
1131
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
1132
+ local -a lines
1133
+ COMPREPLY=()
1134
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
1135
+ for line in "\${lines[@]}"; do
1136
+ if [[ $line == __files__ ]]; then
1137
+ COMPREPLY+=($(compgen -f -- "$cur"))
1138
+ else
1139
+ words+="\${line%%$'\\t'*}"$'\\n'
1140
+ fi
1141
+ done
1142
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
1143
+ }`;
1144
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1145
+ local line
1146
+ local -a described plain
1147
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
1148
+ if [[ $line == __files__ ]]; then
1149
+ _files
1150
+ elif [[ $line == *$'\\t'* ]]; then
1151
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
1152
+ else
1153
+ plain+=("$line")
1154
+ fi
1155
+ done
1156
+ (( \${#described} )) && _describe -V value described
1157
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
1158
+ return 0
1159
+ }`;
1160
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1161
+ if (shell === "fish")
1162
+ return `${header}
1163
+ ${FISH_FUNCTION}
1164
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
1165
+ `).join("")}`;
1166
+ if (shell === "bash")
1167
+ return `${header}
1168
+ ${BASH_FUNCTION}
1169
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1170
+ `;
1171
+ return `${header}
1172
+ ${ZSH_FUNCTION}
1173
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1174
+ `;
1175
+ }
1176
+
1177
+ // ../kit/src/notify.ts
1178
+ init_format();
1179
+ init_mode();
1180
+ import process14 from "process";
949
1181
  var NOTIFY_AFTER_MS = 1e4;
950
1182
  var CANCELLED = 130;
951
1183
  function base64(text) {
952
1184
  return Buffer.from(text).toString("base64");
953
1185
  }
954
- function notification(title, body, env = process13.env) {
955
- const id = `kit${process13.pid}`;
1186
+ function notification(title, body, env = process14.env) {
1187
+ const id = `kit${process14.pid}`;
956
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\\`];
957
1189
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
958
1190
  }
959
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1191
+ function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
960
1192
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
961
1193
  return;
962
1194
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
963
1195
  }
964
1196
 
1197
+ // ../kit/src/cli.ts
1198
+ init_style();
1199
+ init_text2();
1200
+
965
1201
  // ../kit/src/usage.ts
966
1202
  import { appendFileSync, mkdirSync } from "fs";
967
1203
  import { homedir as homedir4 } from "os";
968
1204
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
969
- import process15 from "process";
1205
+ import process16 from "process";
970
1206
 
971
1207
  // ../kit/src/logs.ts
972
1208
  import { lstatSync, openSync } from "fs";
973
1209
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
974
1210
  import { homedir as homedir3, tmpdir } from "os";
975
1211
  import { join as join4 } from "path";
976
- import process14 from "process";
1212
+ import process15 from "process";
977
1213
  var DAY_MS = 24 * 60 * 60 * 1000;
978
1214
  var CLI_FOLDER = "kaynooo-cli";
979
1215
  function isPrivateDirectory(path) {
980
1216
  try {
981
1217
  const info = lstatSync(path, { throwIfNoEntry: false });
982
- 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;
983
1219
  } catch {
984
1220
  return false;
985
1221
  }
986
1222
  }
987
- async function privateLogDirectory(name, env = process14.env) {
1223
+ async function privateLogDirectory(name, env = process15.env) {
988
1224
  const runtime = env.XDG_RUNTIME_DIR;
989
1225
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
990
1226
  const path = join4(base, name);
@@ -1024,14 +1260,14 @@ var usageError;
1024
1260
  function noteUsageError(message) {
1025
1261
  usageError = message;
1026
1262
  }
1027
- function stateHome(env = process15.env) {
1263
+ function stateHome(env = process16.env) {
1028
1264
  const dir = env.XDG_STATE_HOME;
1029
1265
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1030
1266
  }
1031
- function usagePath(env = process15.env) {
1267
+ function usagePath(env = process16.env) {
1032
1268
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1033
1269
  }
1034
- function usageRecorded(env = process15.env) {
1270
+ function usageRecorded(env = process16.env) {
1035
1271
  const off = env.KAYNOOO_CLI_NO_USAGE;
1036
1272
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1037
1273
  }
@@ -1040,12 +1276,12 @@ function flagNames(argv) {
1040
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);
1041
1277
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1042
1278
  }
1043
- function usageEntry(bin, command, argv, code, now = new Date) {
1279
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1044
1280
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1045
1281
  usageError = undefined;
1046
- 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) } };
1047
1283
  }
1048
- function recordUsage(entry, env = process15.env) {
1284
+ function recordUsage(entry, env = process16.env) {
1049
1285
  if (!usageRecorded(env))
1050
1286
  return;
1051
1287
  try {
@@ -1061,10 +1297,14 @@ var LEVEL_OPTIONS = {
1061
1297
  ...OUTPUT_OPTIONS,
1062
1298
  help: { type: "boolean", short: "h", description: "show this help" }
1063
1299
  };
1064
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1300
+ var TOP_OPTIONS = {
1301
+ ...LEVEL_OPTIONS,
1302
+ version: { type: "boolean", short: "v", description: "print the version" },
1303
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1304
+ };
1065
1305
  function printError(prefix, message, hint, cause) {
1066
- const colors = paint(process16.stderr);
1067
- const styled = takesControlCodes(process16.stderr);
1306
+ const colors = paint(process17.stderr);
1307
+ const styled = takesControlCodes(process17.stderr);
1068
1308
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1069
1309
  const under = (label, text, tint) => text === undefined ? "" : `
1070
1310
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1141,6 +1381,19 @@ async function leafCandidates(run, words) {
1141
1381
  const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1142
1382
  return values === undefined ? [FILES] : values.map(candidateLine);
1143
1383
  }
1384
+ var COMPLETIONS = "--completions";
1385
+ function flagValue([flag = "", ...rest]) {
1386
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1387
+ }
1388
+ function printCompletionScript(name, args) {
1389
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1390
+ if (shell === undefined || args.length !== 1) {
1391
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1392
+ return 2;
1393
+ }
1394
+ console.log(completionScript(shell, [name]).trimEnd());
1395
+ return 0;
1396
+ }
1144
1397
  async function printCandidates(found) {
1145
1398
  for (const line of await found)
1146
1399
  console.log(line);
@@ -1162,8 +1415,13 @@ function packageVersion(entry = Bun.main) {
1162
1415
  }
1163
1416
  }
1164
1417
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1418
+ const answered = await askpassClient(argv);
1419
+ if (answered !== undefined)
1420
+ return answered;
1165
1421
  if (argv[0] === COMPLETE)
1166
1422
  return printCandidates(leafCandidates(run, argv.slice(1)));
1423
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1424
+ return printCompletionScript(name, flagValue(argv));
1167
1425
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1168
1426
  console.log(version ?? packageVersion());
1169
1427
  return 0;
@@ -1178,12 +1436,17 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1178
1436
  notifyEnd(name, code, performance.now() - started);
1179
1437
  if (usage !== false) {
1180
1438
  try {
1181
- recordUsage(usageEntry(name, undefined, argv, code));
1439
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
1182
1440
  } catch {}
1183
1441
  }
1184
1442
  return code;
1185
1443
  }
1444
+
1445
+ // ../kit/src/index.ts
1446
+ init_config();
1447
+
1186
1448
  // ../kit/src/excerpt.ts
1449
+ init_text2();
1187
1450
  var BASH_ECHO = /^\$ /;
1188
1451
  var DURATION2 = / \[[\d.]+m?s\]$/;
1189
1452
  var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
@@ -1338,37 +1601,53 @@ function failureExcerpt(output) {
1338
1601
  return cut(squeeze(recognised(lines, PARSERS) ?? lines.slice(-TAIL)));
1339
1602
  }
1340
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 };
1341
- // ../kit/src/folders.ts
1342
- import { homedir as homedir5 } from "os";
1343
- import { join as join7 } from "path";
1344
- import process17 from "process";
1345
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1346
- function ignoredFolders(extra = [], where = {}) {
1347
- const configured = readUserConfig("config", where).ignore;
1348
- const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1349
- return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1350
- }
1351
- function cacheFolder({ home = homedir5(), env = process17.env } = {}) {
1352
- return env.XDG_CACHE_HOME ?? join7(home, ".cache");
1353
- }
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();
1354
1620
  // ../kit/src/secrets.ts
1355
1621
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1356
1622
  // ../kit/src/sessions.ts
1357
1623
  var {Glob } = globalThis.Bun;
1358
1624
  var SESSION_FILES = new Glob("*.json");
1359
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();
1360
1639
  // package.json
1361
- var version = "0.20.0";
1640
+ var version = "0.21.1";
1362
1641
 
1363
1642
  // src/errs.ts
1364
1643
  import { relative as relative2 } from "path";
1365
- import process21 from "process";
1644
+ import process22 from "process";
1366
1645
 
1367
1646
  // src/compose.ts
1368
1647
  import { existsSync as existsSync4 } from "fs";
1369
1648
  import { homedir as homedir6 } from "os";
1370
1649
  import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
1371
- import process19 from "process";
1650
+ import process20 from "process";
1372
1651
 
1373
1652
  // ../kit/src/shell.ts
1374
1653
  var SEPARATORS = new Set([`
@@ -1461,7 +1740,7 @@ async function variables(composeDir) {
1461
1740
  if (match !== null && !line.trimStart().startsWith("#"))
1462
1741
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1463
1742
  }
1464
- for (const [key, value] of Object.entries(process19.env)) {
1743
+ for (const [key, value] of Object.entries(process20.env)) {
1465
1744
  if (value !== undefined)
1466
1745
  env[key] = value;
1467
1746
  }
@@ -1597,7 +1876,7 @@ async function place(dir, program, { service, host } = {}) {
1597
1876
  fail(`--in ${service}: no compose project mounts ${dir}`);
1598
1877
  return;
1599
1878
  }
1600
- if (Bun.which("docker", { PATH: process19.env.PATH ?? "" }) === null) {
1879
+ if (Bun.which("docker", { PATH: process20.env.PATH ?? "" }) === null) {
1601
1880
  if (service !== undefined)
1602
1881
  fail(`--in ${service}: docker not found`);
1603
1882
  if (!noticed.has(found.composeDir)) {
@@ -1649,7 +1928,7 @@ class Stack {
1649
1928
  }
1650
1929
  static async running(composeDir) {
1651
1930
  try {
1652
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process19.env, timeoutMs: PS_TIMEOUT_MS });
1931
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process20.env, timeoutMs: PS_TIMEOUT_MS });
1653
1932
  if (ran.code !== 0)
1654
1933
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1655
1934
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -2198,14 +2477,14 @@ function parseErrors(output) {
2198
2477
  // src/run.ts
2199
2478
  import { mkdir as mkdir2, readdir as readdir2, stat as stat2, writeFile } from "fs/promises";
2200
2479
  import { basename as basename2, join as join9 } from "path";
2201
- import process20 from "process";
2480
+ import process21 from "process";
2202
2481
  var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
2203
2482
  var RESULTS_FILE = "results.json";
2204
2483
  var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
2205
2484
  async function logDirectory(cwd) {
2206
2485
  const root = await privateLogDirectory("check");
2207
2486
  await sweepLogs(root, LOG_MAX_AGE_MS);
2208
- const path = join9(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process20.pid}`);
2487
+ const path = join9(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process21.pid}`);
2209
2488
  await mkdir2(path, { mode: 448 });
2210
2489
  return path;
2211
2490
  }
@@ -2233,7 +2512,7 @@ async function lastFailed(cwd) {
2233
2512
  async function saveLog(output) {
2234
2513
  const root = await privateLogDirectory("errs");
2235
2514
  await sweepLogs(root);
2236
- const path = join9(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process20.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2515
+ const path = join9(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process21.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2237
2516
  await writeFile(path, output, { mode: 384, flag: "wx" });
2238
2517
  return path;
2239
2518
  }
@@ -2241,7 +2520,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
2241
2520
  const started = Date.now();
2242
2521
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
2243
2522
  cwd,
2244
- env: { ...process20.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2523
+ env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2245
2524
  ...timeoutMs === undefined ? {} : { timeoutMs },
2246
2525
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
2247
2526
  });
@@ -2257,8 +2536,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
2257
2536
  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) } };
2258
2537
  }
2259
2538
  function printOutcome(name, width, command, logFile, outcome) {
2260
- const colors = paint(process20.stdout);
2261
- const path = role("path", process20.stdout);
2539
+ const colors = paint(process21.stdout);
2540
+ const path = role("path", process21.stdout);
2262
2541
  const took = colors.dim(formatDuration(outcome.ms));
2263
2542
  if (outcome.ok) {
2264
2543
  console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
@@ -2278,14 +2557,13 @@ var usage2 = `errs [options] [log]
2278
2557
  errs [options] -- <command> [args...]
2279
2558
  errs --in <service> | --host -- <command> [args...]
2280
2559
 
2281
- Prints one \`file:line:col: message (rule)\` line per error found in a tsc, tsgo, vue-tsc, bun check, kay check, eslint, keslint, bun test, vitest, playwright (list and line reporters), phpunit, paratest, phpstan (table, raw and json), php-cs-fixer, go (build, vet), cargo (rustc), ruff (concise and full) or pytest log, or any line shaped \`file:line[:col]: error|warning: message\` (mypy, gcc, clang, \`shellcheck -f gcc\`, golangci-lint), read from the file given, from stdin (no argument or -), or from the output of the command run after --.
2282
- The lines no format recognised are counted on stderr, never dropped silently, and a command's full output is saved to a log file whose path is printed with that count.
2283
- A command runs inside the docker compose service that bind-mounts the current folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path, with its output read here; a service that is down is never started, the call fails naming it. --in picks the service, --host forces the host.
2284
- --json prints {errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}, tool one of tsc, eslint, bun check, kay check, bun test, vitest, playwright, phpunit, phpstan, php-cs-fixer, go, cargo, ruff, pytest, generic. An error repeated with the same file, position and message is printed once.`;
2560
+ Prints one \`file:line:col: message (rule)\` line per error found in a tsc, eslint, bun test, vitest, playwright, phpunit, phpstan, php-cs-fixer, go, cargo, ruff or pytest log, or any \`file:line[:col]: error|warning: message\` line, read from a file, from stdin or from the output of the command run after --.
2561
+ The lines no format recognised are counted on stderr, never dropped, and a command's full output is saved to a log file whose path is printed with that count.
2562
+ A command runs inside the running compose service that bind-mounts the current folder and never starts one; --in picks the service, --host forces the host.`;
2285
2563
  var EXITS = [[0, "no error was found and the command, if any, passed"], [1, "errors were found or the command failed"], [2, "a usage error"]];
2286
2564
  var options = {
2287
2565
  ...placeOptions,
2288
- json: jsonOption()
2566
+ json: jsonOption("{errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}")
2289
2567
  };
2290
2568
  function display(file, cwd) {
2291
2569
  const path = file.startsWith("/") ? relative2(cwd, file) : file;
@@ -2315,7 +2593,7 @@ async function readInput2(command, run, settings, cwd) {
2315
2593
  const held = holdSignals();
2316
2594
  let ran;
2317
2595
  try {
2318
- ran = await runCommand(placement === undefined ? command : argvIn(placement, command), { ...placement === undefined ? {} : { cwd: placement.composeDir }, env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0" }, onStart: (child) => held.forward(child) });
2596
+ ran = await runCommand(placement === undefined ? command : argvIn(placement, command), { ...placement === undefined ? {} : { cwd: placement.composeDir }, env: { ...process22.env, NO_COLOR: "1", FORCE_COLOR: "0" }, onStart: (child) => held.forward(child) });
2319
2597
  } catch (error) {
2320
2598
  fail(`cannot run ${command[0]}: ${error instanceof Error ? error.message : String(error)}`);
2321
2599
  } finally {
@@ -2323,7 +2601,7 @@ async function readInput2(command, run, settings, cwd) {
2323
2601
  }
2324
2602
  return { text: stripAnsi(ran.text), log: await saveLog(ran.output), code: ran.code };
2325
2603
  }
2326
- async function errs(args, cwd = process21.cwd()) {
2604
+ async function errs(args, cwd = process22.cwd()) {
2327
2605
  const first = args[0];
2328
2606
  const bare = first !== undefined && !first.startsWith("-") && !await Bun.file(first).exists();
2329
2607
  const parsed = parse(bare ? [] : args, usage2, options, { exits: EXITS, rest: true, replaces: "reading raw tsc, eslint, phpunit, phpstan or playwright logs, or grepping a test summary out of them", examples: [["errs -- bun run check", "the type errors of a run"], ["bun test 2>&1 | errs", "the failed tests from stdin"], ["errs -- vendor/bin/phpunit", "each failed PHP test with its file and line"]] });
@@ -2347,4 +2625,4 @@ ${usage2}`);
2347
2625
  }
2348
2626
 
2349
2627
  // src/errs-cli.ts
2350
- process22.exitCode = await runMain({ name: "errs", version, run: async (args) => errs(args) });
2628
+ process23.exitCode = await runMain({ name: "errs", version, run: async (args) => errs(args) });