@kaynooo/cli-check 0.20.0 → 0.21.2

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,15 +139,21 @@ 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";
133
148
  import { homedir } from "os";
134
- import { join as join2 } from "path";
149
+ import { isAbsolute, join as join2 } from "path";
135
150
  import process4 from "process";
151
+ function xdgFolder(value, fallback) {
152
+ return value !== undefined && isAbsolute(value) ? value : fallback;
153
+ }
136
154
  function configBase(where = {}) {
137
155
  const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
138
- return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
156
+ return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
139
157
  }
140
158
  function userConfigPath(bin, where = {}) {
141
159
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
@@ -158,36 +176,18 @@ function readUserConfig(bin, where = {}, legacy = []) {
158
176
  return {};
159
177
  }
160
178
  }
179
+ var init_user_config = () => {};
161
180
 
162
181
  // ../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+/;
182
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
183
+ import { homedir as homedir2 } from "os";
184
+ import { join as join3, resolve as resolve2 } from "path";
185
+ import process5 from "process";
185
186
  function isColorSpec(spec) {
186
187
  if (typeof spec === "number")
187
188
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
188
189
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
189
190
  }
190
- var CUBE = [0, 95, 135, 175, 215, 255];
191
191
  function cubeLevel(channel) {
192
192
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
193
193
  }
@@ -292,7 +292,6 @@ function applyFile(theme, file, where, warn) {
292
292
  function endsWalk(home) {
293
293
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
294
294
  }
295
- var warned = new Set;
296
295
  function warnOnce(message) {
297
296
  if (warned.has(message))
298
297
  return;
@@ -329,8 +328,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
329
328
  }
330
329
  return { theme, sources, preset };
331
330
  }
332
- var current;
333
- var currentKey = "";
334
331
  function activeTheme() {
335
332
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
336
333
  if (current === undefined || key !== currentKey) {
@@ -339,9 +336,38 @@ function activeTheme() {
339
336
  }
340
337
  return current;
341
338
  }
339
+ var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
340
+ var init_theme = __esm(() => {
341
+ init_config();
342
+ init_user_config();
343
+ ENDS = new Map;
344
+ DEFAULT = {
345
+ 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" },
346
+ 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" },
347
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
348
+ bins: {},
349
+ gradient: ["#c084fc", "#67e8f9"]
350
+ };
351
+ 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" };
352
+ 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" };
353
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
354
+ PRESETS = {
355
+ default: {},
356
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
357
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
358
+ ascii: { glyphs: ASCII }
359
+ };
360
+ 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"]);
361
+ HEX = /^#[0-9a-f]{6}$/i;
362
+ CONTROL = /\p{Cc}/u;
363
+ MAX_FILE_BYTES = 64 * 1024;
364
+ SPACES = /\s+/;
365
+ CUBE = [0, 95, 135, 175, 215, 255];
366
+ warned = new Set;
367
+ });
342
368
 
343
369
  // ../kit/src/style.ts
344
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
370
+ import process6 from "process";
345
371
  function takesControlCodes(stream, env = process6.env) {
346
372
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
347
373
  }
@@ -364,14 +390,6 @@ function role(name, stream, env = process6.env) {
364
390
  const colors = paint(stream, env);
365
391
  return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
366
392
  }
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
393
  function header(bin, context, stream, env = process6.env) {
376
394
  if (!takesControlCodes(stream, env))
377
395
  return "";
@@ -382,9 +400,24 @@ function header(bin, context, stream, env = process6.env) {
382
400
  const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
383
401
  return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
384
402
  }
403
+ var MARK_WORDS, STATUS_WORDS, STATUS_OF;
404
+ var init_style = __esm(() => {
405
+ init_colors();
406
+ init_mode();
407
+ init_theme();
408
+ MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
409
+ STATUS_WORDS = {
410
+ passed: ["passed", "success", "succeeded", "ok"],
411
+ failed: ["failed", "failure", "error", "errored"],
412
+ running: ["running", "in_progress", "started", "holding"],
413
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
414
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
415
+ };
416
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
417
+ });
385
418
 
386
419
  // ../kit/src/format.ts
387
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
420
+ import process7 from "process";
388
421
  function formatSeconds(total) {
389
422
  let rest = Math.max(0, Math.round(total));
390
423
  const amounts = UNITS.map(([unit, size]) => {
@@ -406,10 +439,8 @@ function upTo(text, separator) {
406
439
  return end === -1 ? text : text.slice(0, end);
407
440
  }
408
441
  function truncate(text, width) {
409
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
442
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
410
443
  }
411
- var LINE_BREAKS = /\s*\n\s*/g;
412
- var ESCAPE = String.fromCharCode(27);
413
444
  function textWidth(text) {
414
445
  return Bun.stringWidth(text);
415
446
  }
@@ -458,14 +489,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
458
489
  function printJson(value) {
459
490
  console.log(jsonText(value));
460
491
  }
492
+ var UNITS, LINE_BREAKS, ESCAPE;
493
+ var init_format = __esm(() => {
494
+ init_text();
495
+ init_mode();
496
+ init_style();
497
+ UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
498
+ LINE_BREAKS = /\s*\n\s*/g;
499
+ ESCAPE = String.fromCharCode(27);
500
+ });
461
501
 
462
502
  // ../kit/src/help.ts
463
503
  import process8 from "process";
464
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
465
- var USAGE_PREFIX = /^usage:\s*/i;
466
- var FULL_STOP = /\.$/;
467
504
  function usageLine(usage, colors = paint(process8.stdout)) {
468
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
505
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
506
+ `);
507
+ const blank = lines.indexOf("");
508
+ const synopses = blank === -1 ? lines : lines.slice(0, blank);
509
+ const details = blank === -1 ? [] : lines.slice(blank + 1);
510
+ const colon = synopses[0].indexOf(": ");
511
+ const inline = synopses[0].slice(colon + 2);
512
+ const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
513
+ if (colon !== -1)
514
+ synopses[0] = synopses[0].slice(0, colon);
515
+ const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
516
+ `)}`;
517
+ const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
518
+ const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
519
+ return [head, ...lead, ...rest].join(`
520
+ `);
521
+ }
522
+ function prose(line, colors) {
523
+ if (colors.cyan("x") === "x")
524
+ return line;
525
+ return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
469
526
  }
470
527
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
471
528
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -500,7 +557,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
500
557
  return [];
501
558
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
502
559
  }
503
- var MAX_INLINE_CHOICES = 24;
504
560
  function optionRows(options, colors = paint(process8.stdout)) {
505
561
  const rows = Object.entries(options).map(([name, option]) => {
506
562
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -515,9 +571,17 @@ function optionRows(options, colors = paint(process8.stdout)) {
515
571
  const width = Math.max(0, ...rows.map((row) => row.width));
516
572
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
517
573
  }
574
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
575
+ var init_help = __esm(() => {
576
+ init_mode();
577
+ init_style();
578
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
579
+ USAGE_PREFIX = /^usage:\s*/i;
580
+ FULL_STOP = /\.$/;
581
+ PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
582
+ });
518
583
 
519
584
  // ../kit/src/text.ts
520
- var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
521
585
  function stripAnsi(text) {
522
586
  return text.replace(ANSI, "");
523
587
  }
@@ -546,10 +610,13 @@ function closest(name, names) {
546
610
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
547
611
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
548
612
  }
613
+ var ANSI;
614
+ var init_text2 = __esm(() => {
615
+ ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
616
+ });
617
+
549
618
  // ../kit/src/input.ts
550
619
  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
620
  function duration(value, name, fallback, unit = "s") {
554
621
  if (value === undefined)
555
622
  return fallback;
@@ -570,40 +637,26 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
570
637
  fail(`no file ${path}`);
571
638
  return file.text();
572
639
  }
640
+ var DURATION, UNIT_MS;
641
+ var init_input = __esm(() => {
642
+ init_args();
643
+ DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
644
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
645
+ });
573
646
 
574
647
  // ../kit/src/args.ts
575
- var DASHES = /^-+/;
648
+ import process10 from "process";
649
+ import { parseArgs } from "util";
576
650
  function jsonOption(holds) {
577
651
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
578
652
  }
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
653
  function fail(message, code = 2, hint) {
589
654
  throw new Exit(message, code, hint);
590
655
  }
591
-
592
- class UsageError extends Exit {
593
- constructor(message, hint) {
594
- super(message, 2, hint);
595
- }
596
- }
597
656
  function badUsage(message) {
598
657
  throw new UsageError(message);
599
658
  }
600
659
 
601
- class HelpShown extends Exit {
602
- constructor() {
603
- super("help shown", 0);
604
- }
605
- }
606
-
607
660
  class Completing {
608
661
  options;
609
662
  positionals;
@@ -614,11 +667,6 @@ class Completing {
614
667
  this.candidates = candidates;
615
668
  }
616
669
  }
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
670
  function applyOutput(color, plain, env = process10.env) {
623
671
  const when = plain === true ? "never" : color ?? "auto";
624
672
  if (when === "auto")
@@ -772,7 +820,6 @@ function parseError(error) {
772
820
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
773
821
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
774
822
  }
775
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
776
823
  function nearestOption(message, options, allowNegative) {
777
824
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
778
825
  if (typed === undefined)
@@ -788,6 +835,72 @@ function nearestOption(message, options, allowNegative) {
788
835
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
789
836
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
790
837
  }
838
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
839
+ var init_args = __esm(() => {
840
+ init_format();
841
+ init_help();
842
+ init_text2();
843
+ init_help();
844
+ init_input();
845
+ DASHES = /^-+/;
846
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
847
+ Exit = class Exit extends Error {
848
+ code;
849
+ hint;
850
+ [EXIT] = true;
851
+ constructor(message, code, hint) {
852
+ super(message);
853
+ this.code = code;
854
+ this.hint = hint;
855
+ }
856
+ static [Symbol.hasInstance](value) {
857
+ if (this !== Exit)
858
+ return Function.prototype[Symbol.hasInstance].call(this, value);
859
+ return typeof value === "object" && value !== null && value[EXIT] === true;
860
+ }
861
+ };
862
+ UsageError = class UsageError extends Exit {
863
+ constructor(message, hint) {
864
+ super(message, 2, hint);
865
+ }
866
+ };
867
+ HelpShown = class HelpShown extends Exit {
868
+ constructor() {
869
+ super("help shown", 0);
870
+ }
871
+ };
872
+ completion = { active: false };
873
+ OUTPUT_OPTIONS = {
874
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
875
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
876
+ };
877
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
878
+ });
879
+
880
+ // ../kit/src/folders.ts
881
+ import { homedir as homedir5 } from "os";
882
+ import { join as join7 } from "path";
883
+ import process18 from "process";
884
+ function ignoredFolders(extra = [], where = {}) {
885
+ const configured = readUserConfig("config", where).ignore;
886
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
887
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
888
+ }
889
+ function cacheFolder({ home = homedir5(), env = process18.env } = {}) {
890
+ return xdgFolder(env.XDG_CACHE_HOME, join7(home, ".cache"));
891
+ }
892
+ var SKIPPED_FOLDERS;
893
+ var init_folders = __esm(() => {
894
+ init_user_config();
895
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
896
+ });
897
+
898
+ // src/cli.ts
899
+ import process24 from "process";
900
+
901
+ // ../kit/src/index.ts
902
+ init_args();
903
+
791
904
  // ../kit/src/argv.ts
792
905
  import { readFileSync as readFileSync3, realpathSync } from "fs";
793
906
  import { resolve as resolve3 } from "path";
@@ -812,11 +925,25 @@ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), scr
812
925
  const after = at === -1 ? [] : cmdline.slice(at + 1);
813
926
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
814
927
  }
928
+ // ../kit/src/chart.ts
929
+ init_format();
930
+ init_mode();
931
+ init_style();
932
+ init_theme();
933
+ // ../kit/src/ci.ts
934
+ init_args();
935
+ init_format();
936
+
937
+ // ../kit/src/progress.ts
938
+ init_format();
939
+
815
940
  // ../kit/src/process.ts
941
+ import { readFileSync as readFileSync4 } from "fs";
816
942
  import { constants } from "os";
817
943
  import process12 from "process";
818
944
  var KILL_GRACE_MS = 2000;
819
945
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
946
+ var GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
820
947
  function exitCodeOf(code, signal) {
821
948
  if (code !== null)
822
949
  return code;
@@ -824,6 +951,21 @@ function exitCodeOf(code, signal) {
824
951
  return 128 + signal;
825
952
  return signal === null ? 129 : 128 + constants.signals[signal];
826
953
  }
954
+ function groupsOf(pid) {
955
+ try {
956
+ const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
957
+ const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
958
+ return { group: Number(fields[2]), foreground: Number(fields[5]) };
959
+ } catch {
960
+ return;
961
+ }
962
+ }
963
+ function heardTheTerminal(child) {
964
+ if (child.pid === undefined)
965
+ return false;
966
+ const own = groupsOf("self");
967
+ return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
968
+ }
827
969
  function holdSignals(cleanup) {
828
970
  let received;
829
971
  let child;
@@ -842,7 +984,8 @@ function holdSignals(cleanup) {
842
984
  function onSignal(signal) {
843
985
  received = signal;
844
986
  if (child !== undefined) {
845
- child.kill(signal);
987
+ if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
988
+ child.kill(signal);
846
989
  return;
847
990
  }
848
991
  if (cleanup === undefined)
@@ -855,10 +998,10 @@ function holdSignals(cleanup) {
855
998
  process12.on(signal, onSignal);
856
999
  return held;
857
1000
  }
858
- async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
1001
+ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
859
1002
  const chunks = [];
860
1003
  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 } : {} });
1004
+ 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
1005
  const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
863
1006
  const timers = [];
864
1007
  const killGroup = (killing) => {
@@ -898,12 +1041,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
898
1041
  stop();
899
1042
  continue;
900
1043
  }
1044
+ if (state.truncated)
1045
+ continue;
1046
+ let kept = data;
901
1047
  if (state.kept + data.length > maxBytes) {
1048
+ let cut = maxBytes - state.kept;
1049
+ while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
1050
+ cut--;
1051
+ kept = data.subarray(0, cut);
902
1052
  state.truncated = true;
903
- continue;
904
1053
  }
905
- state.kept += data.length;
906
- chunks.push({ stream: name, data });
1054
+ state.kept += kept.length;
1055
+ if (kept.length > 0)
1056
+ chunks.push({ stream: name, data: kept });
907
1057
  }
908
1058
  };
909
1059
  try {
@@ -920,6 +1070,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
920
1070
  const joined = () => Buffer.concat(chunks.map(({ data }) => data));
921
1071
  let output;
922
1072
  let text;
1073
+ let stdout;
923
1074
  return {
924
1075
  code: exitCodeOf(proc.exitCode, proc.signalCode),
925
1076
  chunks,
@@ -930,64 +1081,180 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
930
1081
  },
931
1082
  get text() {
932
1083
  return text ??= (output ??= joined()).toString();
1084
+ },
1085
+ get stdout() {
1086
+ return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
933
1087
  }
934
1088
  };
935
1089
  }
936
1090
 
937
1091
  // ../kit/src/progress.ts
1092
+ init_style();
1093
+ init_theme();
938
1094
  var ESC = String.fromCharCode(27);
939
1095
  var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
940
1096
  var RESET_STYLE = `${ESC}[0m`;
941
1097
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
1098
+
1099
+ // ../kit/src/ci.ts
1100
+ init_style();
1101
+
1102
+ // ../kit/src/tool.ts
1103
+ init_format();
942
1104
  // ../kit/src/cli.ts
943
- import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1105
+ init_args();
1106
+ import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
944
1107
  import { dirname as dirname3, join as join6 } from "path";
945
- import process16 from "process";
1108
+ import process17 from "process";
946
1109
 
947
- // ../kit/src/notify.ts
1110
+ // ../kit/src/askpass.ts
948
1111
  import process13 from "process";
1112
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1113
+ async function askpassClient(argv) {
1114
+ const socketPath = process13.env[SOCKET_VARIABLE];
1115
+ if (socketPath === undefined)
1116
+ return;
1117
+ const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1118
+ const { promise, resolve } = Promise.withResolvers();
1119
+ let received = "";
1120
+ try {
1121
+ await Bun.connect({
1122
+ unix: socketPath,
1123
+ socket: {
1124
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1125
+ `),
1126
+ data: (_, chunk) => {
1127
+ received += chunk.toString();
1128
+ },
1129
+ close: () => resolve(received),
1130
+ error: () => resolve("")
1131
+ }
1132
+ });
1133
+ } catch {
1134
+ return 1;
1135
+ }
1136
+ const reply = await promise;
1137
+ if (reply === "")
1138
+ return 1;
1139
+ const { answer } = JSON.parse(reply);
1140
+ if (request.notice === true)
1141
+ return 0;
1142
+ if (answer === undefined)
1143
+ return 1;
1144
+ process13.stdout.write(`${answer}
1145
+ `);
1146
+ return 0;
1147
+ }
1148
+
1149
+ // ../kit/src/completions.ts
1150
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
1151
+ 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'
1152
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
1153
+ set -l current (commandline -ct)
1154
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
1155
+ if test "$line" = __files__
1156
+ __fish_complete_path $current
1157
+ else
1158
+ echo $line
1159
+ end
1160
+ end
1161
+ end`;
1162
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
1163
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
1164
+ local -a lines
1165
+ COMPREPLY=()
1166
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
1167
+ for line in "\${lines[@]}"; do
1168
+ if [[ $line == __files__ ]]; then
1169
+ COMPREPLY+=($(compgen -f -- "$cur"))
1170
+ else
1171
+ words+="\${line%%$'\\t'*}"$'\\n'
1172
+ fi
1173
+ done
1174
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
1175
+ }`;
1176
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1177
+ local line
1178
+ local -a described plain
1179
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
1180
+ if [[ $line == __files__ ]]; then
1181
+ _files
1182
+ elif [[ $line == *$'\\t'* ]]; then
1183
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
1184
+ else
1185
+ plain+=("$line")
1186
+ fi
1187
+ done
1188
+ (( \${#described} )) && _describe -V value described
1189
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
1190
+ return 0
1191
+ }`;
1192
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1193
+ if (shell === "fish")
1194
+ return `${header}
1195
+ ${FISH_FUNCTION}
1196
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
1197
+ `).join("")}`;
1198
+ if (shell === "bash")
1199
+ return `${header}
1200
+ ${BASH_FUNCTION}
1201
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1202
+ `;
1203
+ return `${header}
1204
+ ${ZSH_FUNCTION}
1205
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1206
+ `;
1207
+ }
1208
+
1209
+ // ../kit/src/notify.ts
1210
+ init_format();
1211
+ init_mode();
1212
+ import process14 from "process";
949
1213
  var NOTIFY_AFTER_MS = 1e4;
950
1214
  var CANCELLED = 130;
951
1215
  function base64(text) {
952
1216
  return Buffer.from(text).toString("base64");
953
1217
  }
954
- function notification(title, body, env = process13.env) {
955
- const id = `kit${process13.pid}`;
1218
+ function notification(title, body, env = process14.env) {
1219
+ const id = `kit${process14.pid}`;
956
1220
  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
1221
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
958
1222
  }
959
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1223
+ function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
960
1224
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
961
1225
  return;
962
1226
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
963
1227
  }
964
1228
 
1229
+ // ../kit/src/cli.ts
1230
+ init_style();
1231
+ init_text2();
1232
+
965
1233
  // ../kit/src/usage.ts
966
1234
  import { appendFileSync, mkdirSync } from "fs";
967
1235
  import { homedir as homedir4 } from "os";
968
- import { dirname as dirname2, isAbsolute, join as join5 } from "path";
969
- import process15 from "process";
1236
+ import { dirname as dirname2, join as join5 } from "path";
1237
+ import process16 from "process";
970
1238
 
971
1239
  // ../kit/src/logs.ts
1240
+ init_user_config();
972
1241
  import { lstatSync, openSync } from "fs";
973
1242
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
974
1243
  import { homedir as homedir3, tmpdir } from "os";
975
1244
  import { join as join4 } from "path";
976
- import process14 from "process";
1245
+ import process15 from "process";
977
1246
  var DAY_MS = 24 * 60 * 60 * 1000;
978
1247
  var CLI_FOLDER = "kaynooo-cli";
979
1248
  function isPrivateDirectory(path) {
980
1249
  try {
981
1250
  const info = lstatSync(path, { throwIfNoEntry: false });
982
- return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1251
+ return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
983
1252
  } catch {
984
1253
  return false;
985
1254
  }
986
1255
  }
987
- async function privateLogDirectory(name, env = process14.env) {
988
- const runtime = env.XDG_RUNTIME_DIR;
989
- const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
990
- const path = join4(base, name);
1256
+ async function privateLogDirectory(name, env = process15.env) {
1257
+ const path = join4(xdgFolder(env.XDG_RUNTIME_DIR, join4(homedir3(), ".cache")), CLI_FOLDER, name);
991
1258
  try {
992
1259
  await mkdir(path, { recursive: true, mode: 448 });
993
1260
  if (isPrivateDirectory(path))
@@ -1017,6 +1284,7 @@ async function sweepLogs(dir, maxAgeMs = DAY_MS, now = Date.now()) {
1017
1284
  }
1018
1285
 
1019
1286
  // ../kit/src/usage.ts
1287
+ init_user_config();
1020
1288
  var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
1021
1289
  var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
1022
1290
  var LONGEST_NAME = 40;
@@ -1024,14 +1292,13 @@ var usageError;
1024
1292
  function noteUsageError(message) {
1025
1293
  usageError = message;
1026
1294
  }
1027
- function stateHome(env = process15.env) {
1028
- const dir = env.XDG_STATE_HOME;
1029
- return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1295
+ function stateHome(env = process16.env) {
1296
+ return xdgFolder(env.XDG_STATE_HOME, join5(homedir4(), ".local", "state"));
1030
1297
  }
1031
- function usagePath(env = process15.env) {
1298
+ function usagePath(env = process16.env) {
1032
1299
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1033
1300
  }
1034
- function usageRecorded(env = process15.env) {
1301
+ function usageRecorded(env = process16.env) {
1035
1302
  const off = env.KAYNOOO_CLI_NO_USAGE;
1036
1303
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1037
1304
  }
@@ -1040,12 +1307,12 @@ function flagNames(argv) {
1040
1307
  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
1308
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1042
1309
  }
1043
- function usageEntry(bin, command, argv, code, now = new Date) {
1310
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1044
1311
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1045
1312
  usageError = undefined;
1046
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1313
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
1047
1314
  }
1048
- function recordUsage(entry, env = process15.env) {
1315
+ function recordUsage(entry, env = process16.env) {
1049
1316
  if (!usageRecorded(env))
1050
1317
  return;
1051
1318
  try {
@@ -1061,10 +1328,14 @@ var LEVEL_OPTIONS = {
1061
1328
  ...OUTPUT_OPTIONS,
1062
1329
  help: { type: "boolean", short: "h", description: "show this help" }
1063
1330
  };
1064
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1331
+ var TOP_OPTIONS = {
1332
+ ...LEVEL_OPTIONS,
1333
+ version: { type: "boolean", short: "v", description: "print the version" },
1334
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1335
+ };
1065
1336
  function printError(prefix, message, hint, cause) {
1066
- const colors = paint(process16.stderr);
1067
- const styled = takesControlCodes(process16.stderr);
1337
+ const colors = paint(process17.stderr);
1338
+ const styled = takesControlCodes(process17.stderr);
1068
1339
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1069
1340
  const under = (label, text, tint) => text === undefined ? "" : `
1070
1341
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1141,6 +1412,19 @@ async function leafCandidates(run, words) {
1141
1412
  const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1142
1413
  return values === undefined ? [FILES] : values.map(candidateLine);
1143
1414
  }
1415
+ var COMPLETIONS = "--completions";
1416
+ function flagValue([flag = "", ...rest]) {
1417
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1418
+ }
1419
+ function printCompletionScript(name, args) {
1420
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1421
+ if (shell === undefined || args.length !== 1) {
1422
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1423
+ return 2;
1424
+ }
1425
+ console.log(completionScript(shell, [name]).trimEnd());
1426
+ return 0;
1427
+ }
1144
1428
  async function printCandidates(found) {
1145
1429
  for (const line of await found)
1146
1430
  console.log(line);
@@ -1153,7 +1437,7 @@ function packageVersion(entry = Bun.main) {
1153
1437
  } catch {}
1154
1438
  for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
1155
1439
  try {
1156
- const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
1440
+ const { version } = JSON.parse(readFileSync5(join6(dir, "package.json"), "utf8"));
1157
1441
  if (typeof version === "string")
1158
1442
  return version;
1159
1443
  } catch {}
@@ -1162,8 +1446,13 @@ function packageVersion(entry = Bun.main) {
1162
1446
  }
1163
1447
  }
1164
1448
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1449
+ const answered = await askpassClient(argv);
1450
+ if (answered !== undefined)
1451
+ return answered;
1165
1452
  if (argv[0] === COMPLETE)
1166
1453
  return printCandidates(leafCandidates(run, argv.slice(1)));
1454
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1455
+ return printCompletionScript(name, flagValue(argv));
1167
1456
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1168
1457
  console.log(version ?? packageVersion());
1169
1458
  return 0;
@@ -1178,12 +1467,17 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1178
1467
  notifyEnd(name, code, performance.now() - started);
1179
1468
  if (usage !== false) {
1180
1469
  try {
1181
- recordUsage(usageEntry(name, undefined, argv, code));
1470
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
1182
1471
  } catch {}
1183
1472
  }
1184
1473
  return code;
1185
1474
  }
1475
+
1476
+ // ../kit/src/index.ts
1477
+ init_config();
1478
+
1186
1479
  // ../kit/src/excerpt.ts
1480
+ init_text2();
1187
1481
  var BASH_ECHO = /^\$ /;
1188
1482
  var DURATION2 = / \[[\d.]+m?s\]$/;
1189
1483
  var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
@@ -1338,32 +1632,49 @@ function failureExcerpt(output) {
1338
1632
  return cut(squeeze(recognised(lines, PARSERS) ?? lines.slice(-TAIL)));
1339
1633
  }
1340
1634
  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
- }
1635
+
1636
+ // ../kit/src/index.ts
1637
+ init_folders();
1638
+ init_format();
1639
+
1640
+ // ../kit/src/git.ts
1641
+ init_args();
1642
+ // ../kit/src/limit.ts
1643
+ init_args();
1644
+
1645
+ // ../kit/src/index.ts
1646
+ init_mode();
1647
+
1648
+ // ../kit/src/report.ts
1649
+ init_style();
1650
+ init_text2();
1354
1651
  // ../kit/src/secrets.ts
1355
1652
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1653
+ var NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
1356
1654
  // ../kit/src/sessions.ts
1357
1655
  var {Glob } = globalThis.Bun;
1358
1656
  var SESSION_FILES = new Glob("*.json");
1359
1657
  var ACCOUNT_DIRS = new Glob("*/sessions");
1658
+
1659
+ // ../kit/src/index.ts
1660
+ init_style();
1661
+ init_text2();
1662
+ init_theme();
1663
+ init_user_config();
1664
+
1665
+ // ../kit/src/watch.ts
1666
+ init_args();
1667
+ init_input();
1668
+ init_style();
1669
+ // ../kit/src/workspace-root.ts
1670
+ init_user_config();
1360
1671
  // package.json
1361
- var version = "0.20.0";
1672
+ var version = "0.21.2";
1362
1673
 
1363
1674
  // src/check.ts
1364
1675
  import { writeFile as writeFile3 } from "fs/promises";
1365
1676
  import { basename as basename4, join as join14 } from "path";
1366
- import process22 from "process";
1677
+ import process23 from "process";
1367
1678
 
1368
1679
  // ../kit/src/shell.ts
1369
1680
  var SEPARATORS = new Set([`
@@ -1374,6 +1685,7 @@ var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
1374
1685
  var SAFE_WORD = /^[\w@%+=:,./-]+$/;
1375
1686
  var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
1376
1687
  var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
1688
+ var FISH_COMBINERS = new Set(["and", "or", "not"]);
1377
1689
  var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
1378
1690
  var SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
1379
1691
  var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
@@ -1385,6 +1697,7 @@ var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
1385
1697
  function wrapper(short = "", long = [], operands = 0, runsString = false) {
1386
1698
  return { short, long, operands, runsString };
1387
1699
  }
1700
+ var RUNNER = { ...wrapper(), afterDashes: true };
1388
1701
  var WRAPPERS = new Map([
1389
1702
  ["command", wrapper()],
1390
1703
  ["builtin", wrapper()],
@@ -1406,7 +1719,23 @@ var WRAPPERS = new Map([
1406
1719
  ["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
1407
1720
  ["unbuffer", wrapper()],
1408
1721
  ["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
1409
- ["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
1722
+ ["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])],
1723
+ ["strace", wrapper("abeEIoOpPsSuUX", ["--trace", "--output", "--attach", "--string-limit", "--user", "--env", "--columns", "--trace-path", "--signal", "--status", "--summary-sort-by", "--summary-columns", "--const-print-style", "--interruptible", "--detach-on"])],
1724
+ ["ltrace", wrapper("aeFlnopsuxX", ["--output", "--user", "--library", "--config", "--align", "--indent"])],
1725
+ ["taskset", wrapper("", [], 1)],
1726
+ ["fakeroot", wrapper("lsib", ["--lib", "--faked"])],
1727
+ ["sshpass", wrapper("pfdP")],
1728
+ ["coproc", wrapper()],
1729
+ ["proxychains", wrapper("f")],
1730
+ ["proxychains4", wrapper("f")],
1731
+ ["torsocks", wrapper("upaP", ["--user", "--pass", "--address", "--port"])],
1732
+ ["chrt", wrapper("TPD", ["--sched-runtime", "--sched-period", "--sched-deadline"], 1)],
1733
+ ["unshare", wrapper("SGRw", ["--setuid", "--setgid", "--root", "--wd", "--map-user", "--map-group", "--map-users", "--map-groups", "--propagation", "--setgroups"])],
1734
+ ["nsenter", wrapper("tSG", ["--target", "--setuid", "--setgid"])],
1735
+ ["out", RUNNER],
1736
+ ["slot", RUNNER],
1737
+ ["waitfor", RUNNER],
1738
+ ["base", RUNNER]
1410
1739
  ]);
1411
1740
  function shellQuote(word) {
1412
1741
  return SAFE_WORD.test(word) && !word.startsWith("=") ? word : `'${word.replaceAll("'", "'\\''")}'`;
@@ -1416,7 +1745,7 @@ function shellQuote(word) {
1416
1745
  import { existsSync as existsSync4 } from "fs";
1417
1746
  import { homedir as homedir6 } from "os";
1418
1747
  import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
1419
- import process19 from "process";
1748
+ import process20 from "process";
1420
1749
  var COMPOSE_FILES = ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"];
1421
1750
  var OVERRIDE_FILES = ["compose.override.yaml", "compose.override.yml", "docker-compose.override.yaml", "docker-compose.override.yml"];
1422
1751
  var PS_TIMEOUT_MS = 20000;
@@ -1460,7 +1789,7 @@ async function variables(composeDir) {
1460
1789
  if (match !== null && !line.trimStart().startsWith("#"))
1461
1790
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1462
1791
  }
1463
- for (const [key, value] of Object.entries(process19.env)) {
1792
+ for (const [key, value] of Object.entries(process20.env)) {
1464
1793
  if (value !== undefined)
1465
1794
  env[key] = value;
1466
1795
  }
@@ -1596,7 +1925,7 @@ async function place(dir, program, { service, host } = {}) {
1596
1925
  fail(`--in ${service}: no compose project mounts ${dir}`);
1597
1926
  return;
1598
1927
  }
1599
- if (Bun.which("docker", { PATH: process19.env.PATH ?? "" }) === null) {
1928
+ if (Bun.which("docker", { PATH: process20.env.PATH ?? "" }) === null) {
1600
1929
  if (service !== undefined)
1601
1930
  fail(`--in ${service}: docker not found`);
1602
1931
  if (!noticed.has(found.composeDir)) {
@@ -1648,7 +1977,7 @@ class Stack {
1648
1977
  }
1649
1978
  static async running(composeDir) {
1650
1979
  try {
1651
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process19.env, timeoutMs: PS_TIMEOUT_MS });
1980
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process20.env, timeoutMs: PS_TIMEOUT_MS });
1652
1981
  if (ran.code !== 0)
1653
1982
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1654
1983
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -1683,7 +2012,7 @@ function placeSettings(values) {
1683
2012
  import { existsSync as existsSync5, statSync as statSync2 } from "fs";
1684
2013
  import { rename, writeFile as writeFile2 } from "fs/promises";
1685
2014
  import { join as join12 } from "path";
1686
- import process21 from "process";
2015
+ import process22 from "process";
1687
2016
 
1688
2017
  // src/changes.ts
1689
2018
  import { stat as stat2 } from "fs/promises";
@@ -1865,16 +2194,13 @@ async function discover(dir) {
1865
2194
  }
1866
2195
 
1867
2196
  // src/options.ts
1868
- var fixOptions = {
2197
+ var options = {
1869
2198
  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" },
1870
- 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` },
2199
+ 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] },
1871
2200
  timeout: { type: "string", short: "t", description: "longest a step or fixer may run before it is ended (30s, 5m, 1h), none by default" },
1872
2201
  ...placeOptions,
1873
- json: jsonOption()
1874
- };
1875
- var options = {
1876
- ...fixOptions,
1877
- fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps, as the fix bin does" },
2202
+ json: jsonOption("[{name, command, in?, ok, ms, log, failed?}], with --list [{name, command, source, in?}], with --fix {fixers, changed}"),
2203
+ fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps" },
1878
2204
  quiet: { type: "boolean", short: "q", description: "print nothing for a passing step, and nothing at all when every step passes" },
1879
2205
  failed: { type: "boolean", description: "run only the steps that failed in the last run of this folder, read from the run folder" },
1880
2206
  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" },
@@ -1898,14 +2224,14 @@ function pick(steps, only, noun = "step") {
1898
2224
  // src/run.ts
1899
2225
  import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
1900
2226
  import { basename as basename2, join as join11 } from "path";
1901
- import process20 from "process";
2227
+ import process21 from "process";
1902
2228
  var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
1903
2229
  var RESULTS_FILE = "results.json";
1904
2230
  var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
1905
2231
  async function logDirectory(cwd) {
1906
2232
  const root = await privateLogDirectory("check");
1907
2233
  await sweepLogs(root, LOG_MAX_AGE_MS);
1908
- const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process20.pid}`);
2234
+ const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process21.pid}`);
1909
2235
  await mkdir2(path, { mode: 448 });
1910
2236
  return path;
1911
2237
  }
@@ -1933,7 +2259,7 @@ async function lastFailed(cwd) {
1933
2259
  async function saveLog(output) {
1934
2260
  const root = await privateLogDirectory("errs");
1935
2261
  await sweepLogs(root);
1936
- const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process20.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2262
+ const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process21.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
1937
2263
  await writeFile(path, output, { mode: 384, flag: "wx" });
1938
2264
  return path;
1939
2265
  }
@@ -1941,7 +2267,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
1941
2267
  const started = Date.now();
1942
2268
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
1943
2269
  cwd,
1944
- env: { ...process20.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2270
+ env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
1945
2271
  ...timeoutMs === undefined ? {} : { timeoutMs },
1946
2272
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
1947
2273
  });
@@ -1957,8 +2283,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
1957
2283
  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) } };
1958
2284
  }
1959
2285
  function printOutcome(name, width, command, logFile, outcome) {
1960
- const colors = paint(process20.stdout);
1961
- const path = role("path", process20.stdout);
2286
+ const colors = paint(process21.stdout);
2287
+ const path = role("path", process21.stdout);
1962
2288
  const took = colors.dim(formatDuration(outcome.ms));
1963
2289
  if (outcome.ok) {
1964
2290
  console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
@@ -1974,27 +2300,18 @@ function printOutcome(name, width, command, logFile, outcome) {
1974
2300
  }
1975
2301
 
1976
2302
  // src/fix.ts
1977
- var fixUsage = `fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
1978
-
1979
- 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.
1980
- It looks at the folder itself only, so each package of a monorepo gets its own run.
1981
- 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.
1982
- 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.
1983
- A fixer still running after --timeout is ended with everything it started, but not what it started inside a container.
1984
- --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.`;
1985
- 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"]];
1986
2303
  var RUNNING = "KAYNOOO_CLI_FIX";
1987
2304
  var JUSTFILES2 = ["justfile", "Justfile", ".justfile"];
1988
2305
  var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
1989
2306
  var RUFF_SECTION = /^\[tool\.ruff/m;
1990
2307
  var MAX_CHANGED = 30;
1991
2308
  async function replaceFile(path, content) {
1992
- const temporary = `${path}.${process21.pid}.tmp`;
2309
+ const temporary = `${path}.${process22.pid}.tmp`;
1993
2310
  await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
1994
2311
  await rename(temporary, path);
1995
2312
  }
1996
2313
  async function projectFixers(dir) {
1997
- const found = await candidates(dir, "fix");
2314
+ const found = await candidates(dir, "check");
1998
2315
  const named = (name) => found.find((step) => step.name === name);
1999
2316
  const all = named("fix");
2000
2317
  if (all !== undefined)
@@ -2061,15 +2378,11 @@ function printChanged(changed) {
2061
2378
  if (changed.length > MAX_CHANGED)
2062
2379
  console.log(` and ${changed.length - MAX_CHANGED} more`);
2063
2380
  }
2064
- async function fix(args, cwd = process21.cwd()) {
2065
- const parsed = parse(args, fixUsage, fixOptions, { 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"]] });
2066
- return runFixers(parsed.values, cwd);
2067
- }
2068
2381
  async function runFixers(values, cwd) {
2069
2382
  const parsed = { values };
2070
2383
  const settings = placeSettings(values);
2071
- if (process21.env[RUNNING] !== undefined)
2072
- fail("a fixer called fix again, which would recurse: give its script another command");
2384
+ if (process22.env[RUNNING] !== undefined)
2385
+ fail("a fixer called check --fix again, which would recurse: give its script another command");
2073
2386
  const found = await fixers(cwd);
2074
2387
  if (found.length === 0)
2075
2388
  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");
@@ -2102,7 +2415,7 @@ async function runFixers(values, cwd) {
2102
2415
  break;
2103
2416
  if (missing(fixer)) {
2104
2417
  if (!json)
2105
- console.log(`${paint(process21.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2418
+ console.log(`${paint(process22.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2106
2419
  ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
2107
2420
  continue;
2108
2421
  }
@@ -2212,19 +2525,11 @@ async function scriptText(dir, name) {
2212
2525
  var usage2 = `check [--only <steps>] [--changed] [--failed] [--quiet] [--timeout <duration>] [--slot | --no-slot] [--parallel] [--in <service> | --host] [--list]
2213
2526
  check --fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
2214
2527
 
2215
- 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.
2216
- A folder without steps but with subfolders that have some (api/ and client/) runs each one's, each line naming its subfolder.
2217
- 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.
2218
- 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.
2219
- 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.
2220
- 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.
2221
- 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.
2222
- 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.
2223
- A step still running after --timeout is ended with everything it started, but not what it started inside a container.
2224
- 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.
2225
- 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.
2226
- --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.`;
2227
- var EXITS2 = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
2528
+ 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/).
2529
+ 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.
2530
+ 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.
2531
+ 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.`;
2532
+ var EXITS = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
2228
2533
  function slotted(command) {
2229
2534
  return `slot -- sh -c ${shellQuote(command)}`;
2230
2535
  }
@@ -2253,14 +2558,14 @@ function launch(step) {
2253
2558
  return step.placement === undefined ? step.command : shellIn(step.placement, step.command);
2254
2559
  }
2255
2560
  function summaryLine(outcomes) {
2256
- const colors = paint(process22.stdout);
2561
+ const colors = paint(process23.stdout);
2257
2562
  const failed = outcomes.filter((outcome) => !outcome.ok).length;
2258
2563
  const passed = outcomes.length - failed;
2259
2564
  const parts = [colors.green(`${passed} passed`), ...failed === 0 ? [] : [colors.red(`${failed} failed`)], colors.dim(formatDuration(outcomes.reduce((sum, outcome) => sum + outcome.ms, 0)))];
2260
2565
  return parts.join(colors.dim(" \xB7 "));
2261
2566
  }
2262
- async function check(args, cwd = process22.cwd()) {
2263
- 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"]] });
2567
+ async function check(args, cwd = process23.cwd()) {
2568
+ 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"]] });
2264
2569
  const settings = placeSettings(parsed.values);
2265
2570
  if (parsed.values.fix === true) {
2266
2571
  for (const flag of ["changed", "failed", "slot", "no-slot", "parallel"]) {
@@ -2272,7 +2577,7 @@ async function check(args, cwd = process22.cwd()) {
2272
2577
  const timeoutMs = parsed.values.timeout === undefined ? undefined : duration(parsed.values.timeout, "timeout", 0);
2273
2578
  if (parsed.values.slot === true && parsed.values["no-slot"] === true)
2274
2579
  fail("--slot and --no-slot exclude each other");
2275
- const hasSlot = Bun.which("slot", { PATH: process22.env.PATH ?? "" }) !== null;
2580
+ const hasSlot = Bun.which("slot", { PATH: process23.env.PATH ?? "" }) !== null;
2276
2581
  if (parsed.values.slot === true && !hasSlot)
2277
2582
  fail("--slot needs the slot bin: bun install -g @kaynooo/cli-wait");
2278
2583
  const slotting = parsed.values["no-slot"] !== true && hasSlot;
@@ -2305,7 +2610,7 @@ async function check(args, cwd = process22.cwd()) {
2305
2610
  const width = Math.max(...steps.map((step) => step.label.length));
2306
2611
  const outcomes = [];
2307
2612
  const quiet = parsed.values.quiet === true;
2308
- const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process22.stdout);
2613
+ const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process23.stdout);
2309
2614
  if (heading !== "")
2310
2615
  console.log(heading);
2311
2616
  const execute = async (step, signals) => {
@@ -2358,4 +2663,4 @@ async function check(args, cwd = process22.cwd()) {
2358
2663
  }
2359
2664
 
2360
2665
  // src/cli.ts
2361
- process23.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });
2666
+ process24.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });