@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/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,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/errs-cli.ts
899
+ import process23 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,37 +1632,54 @@ 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/errs.ts
1364
1675
  import { relative as relative2 } from "path";
1365
- import process21 from "process";
1676
+ import process22 from "process";
1366
1677
 
1367
1678
  // src/compose.ts
1368
1679
  import { existsSync as existsSync4 } from "fs";
1369
1680
  import { homedir as homedir6 } from "os";
1370
1681
  import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
1371
- import process19 from "process";
1682
+ import process20 from "process";
1372
1683
 
1373
1684
  // ../kit/src/shell.ts
1374
1685
  var SEPARATORS = new Set([`
@@ -1379,6 +1690,7 @@ var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
1379
1690
  var SAFE_WORD = /^[\w@%+=:,./-]+$/;
1380
1691
  var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
1381
1692
  var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
1693
+ var FISH_COMBINERS = new Set(["and", "or", "not"]);
1382
1694
  var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
1383
1695
  var SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
1384
1696
  var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
@@ -1390,6 +1702,7 @@ var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
1390
1702
  function wrapper(short = "", long = [], operands = 0, runsString = false) {
1391
1703
  return { short, long, operands, runsString };
1392
1704
  }
1705
+ var RUNNER = { ...wrapper(), afterDashes: true };
1393
1706
  var WRAPPERS = new Map([
1394
1707
  ["command", wrapper()],
1395
1708
  ["builtin", wrapper()],
@@ -1411,7 +1724,23 @@ var WRAPPERS = new Map([
1411
1724
  ["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
1412
1725
  ["unbuffer", wrapper()],
1413
1726
  ["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
1414
- ["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
1727
+ ["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])],
1728
+ ["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"])],
1729
+ ["ltrace", wrapper("aeFlnopsuxX", ["--output", "--user", "--library", "--config", "--align", "--indent"])],
1730
+ ["taskset", wrapper("", [], 1)],
1731
+ ["fakeroot", wrapper("lsib", ["--lib", "--faked"])],
1732
+ ["sshpass", wrapper("pfdP")],
1733
+ ["coproc", wrapper()],
1734
+ ["proxychains", wrapper("f")],
1735
+ ["proxychains4", wrapper("f")],
1736
+ ["torsocks", wrapper("upaP", ["--user", "--pass", "--address", "--port"])],
1737
+ ["chrt", wrapper("TPD", ["--sched-runtime", "--sched-period", "--sched-deadline"], 1)],
1738
+ ["unshare", wrapper("SGRw", ["--setuid", "--setgid", "--root", "--wd", "--map-user", "--map-group", "--map-users", "--map-groups", "--propagation", "--setgroups"])],
1739
+ ["nsenter", wrapper("tSG", ["--target", "--setuid", "--setgid"])],
1740
+ ["out", RUNNER],
1741
+ ["slot", RUNNER],
1742
+ ["waitfor", RUNNER],
1743
+ ["base", RUNNER]
1415
1744
  ]);
1416
1745
  function shellQuote(word) {
1417
1746
  return SAFE_WORD.test(word) && !word.startsWith("=") ? word : `'${word.replaceAll("'", "'\\''")}'`;
@@ -1461,7 +1790,7 @@ async function variables(composeDir) {
1461
1790
  if (match !== null && !line.trimStart().startsWith("#"))
1462
1791
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1463
1792
  }
1464
- for (const [key, value] of Object.entries(process19.env)) {
1793
+ for (const [key, value] of Object.entries(process20.env)) {
1465
1794
  if (value !== undefined)
1466
1795
  env[key] = value;
1467
1796
  }
@@ -1597,7 +1926,7 @@ async function place(dir, program, { service, host } = {}) {
1597
1926
  fail(`--in ${service}: no compose project mounts ${dir}`);
1598
1927
  return;
1599
1928
  }
1600
- if (Bun.which("docker", { PATH: process19.env.PATH ?? "" }) === null) {
1929
+ if (Bun.which("docker", { PATH: process20.env.PATH ?? "" }) === null) {
1601
1930
  if (service !== undefined)
1602
1931
  fail(`--in ${service}: docker not found`);
1603
1932
  if (!noticed.has(found.composeDir)) {
@@ -1649,7 +1978,7 @@ class Stack {
1649
1978
  }
1650
1979
  static async running(composeDir) {
1651
1980
  try {
1652
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process19.env, timeoutMs: PS_TIMEOUT_MS });
1981
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process20.env, timeoutMs: PS_TIMEOUT_MS });
1653
1982
  if (ran.code !== 0)
1654
1983
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1655
1984
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -1938,6 +2267,7 @@ var TSC_PRETTY_ERROR = /^(.+?):(\d+):(\d+) - error (TS\d+): (.*)$/;
1938
2267
  var TSC_SOURCE_LINE = /^\d+ /;
1939
2268
  var ESLINT_FIELDS = /^ +(\d+):(\d+) +(error|warning) +(\S.*)$/;
1940
2269
  var ESLINT_RULE = / {2,}(\S+)$/;
2270
+ var ESLINT_FILE = /^(?:\/|~\/|\.{1,2}[/\\]|[a-z]:\\)|^[^\s/\\]+[/\\]\S*$/i;
1941
2271
  var BUN_TEST_EXPECTED = /^Expected: (.*)$/;
1942
2272
  var BUN_TEST_RECEIVED = /^Received: (.*)$/;
1943
2273
  var BUN_TEST_FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
@@ -1947,6 +2277,7 @@ var GO_LINTER = /^(.*\S)\s+\(([a-z][\w-]*)\)$/;
1947
2277
  var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
1948
2278
  var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
1949
2279
  var CARGO_HEADER = /^(error|warning)(?:\[([\w-]+)\])?: (.*)$/;
2280
+ var LINE_BREAK = /\r?\n/;
1950
2281
  var CONTINUATION = /^\s+\S/;
1951
2282
  var MAX_CONTINUATION = 20;
1952
2283
  var KAY_SUMMARY = /^(?:\d+ errors?(?:, \d+ warnings?)?|\d+ warnings?)(?:, failing under --deny-warnings)?$|^checked with /;
@@ -1960,7 +2291,9 @@ var PYTEST_BANNER = /^={3,} (.*?) ={3,}$/;
1960
2291
  var PYTEST_FAILURES = new Set(["FAILURES", "ERRORS"]);
1961
2292
  var PYTEST_SUMMARY_LINE = /^(?:FAILED|ERROR) \S/;
1962
2293
  var PYTEST_FRAME = /^in \S/;
1963
- var PYTEST_SECTION = /^_{3,} .* _{3,}$/;
2294
+ var PYTEST_SECTION = /^_{3,} (.*) _{3,}$/;
2295
+ var PYTEST_SUMMARY = /^(?:FAILED|ERROR) ([^\s:]+?\.py)(?:::(.*)| - (.*))?$/;
2296
+ var PYTEST_ERROR_SECTION = /^ERROR (?:at (?:setup|teardown) of |collecting )/;
1964
2297
  var PYTEST_EXCEPTION_END = /[\s:]/;
1965
2298
  var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
1966
2299
  var GENERIC_LINE = /^(\S[^:]*):(\d+)(?::(\d+))?: (?:fatal )?(error|warning|note): (.*)$/;
@@ -1989,14 +2322,12 @@ var collectBunCheck = (lines, used) => {
1989
2322
  var collectBunTest = (lines, used) => {
1990
2323
  const errors = [];
1991
2324
  const seen = new Set;
2325
+ const names = new Set;
1992
2326
  for (const [index, line] of lines.entries()) {
1993
2327
  if (!line.startsWith("(fail) "))
1994
2328
  continue;
1995
2329
  used.add(index);
1996
2330
  const test = line.slice("(fail) ".length).replace(DURATION3, "");
1997
- if (seen.has(test))
1998
- continue;
1999
- seen.add(test);
2000
2331
  const start = lines.findLastIndex((text, at) => at < index && BOUNDARY2.test(text)) + 1;
2001
2332
  const block = lines.slice(start, index);
2002
2333
  const failure = block.findIndex((text) => text.startsWith("error:"));
@@ -2004,6 +2335,11 @@ var collectBunTest = (lines, used) => {
2004
2335
  used.add(at);
2005
2336
  const frame = block.slice(Math.max(failure, 0)).map((text) => BUN_TEST_FRAME.exec(text)).find((match) => match !== null);
2006
2337
  const header = lines.slice(0, index).findLast((text) => BUN_TEST_FILE.test(text));
2338
+ const key = `${header ?? ""}\x00${test}`;
2339
+ if (seen.has(key) || failure === -1 && names.has(test))
2340
+ continue;
2341
+ seen.add(key);
2342
+ names.add(test);
2007
2343
  const expected = block.map((text) => BUN_TEST_EXPECTED.exec(text)?.[1]).find((text) => text !== undefined);
2008
2344
  const received = block.map((text) => BUN_TEST_RECEIVED.exec(text)?.[1]).find((text) => text !== undefined);
2009
2345
  const reason = failure === -1 ? "failed" : (block[failure] ?? "").slice("error:".length).trim();
@@ -2058,7 +2394,7 @@ var collectEslint = (lines, used) => {
2058
2394
  errors.push({ tool: "eslint", file: (lines[file] ?? "").trim(), line: Number(match[1]), column: Number(match[2]), rule: rule?.[1], severity: match[3] === "warning" ? "warning" : "error", message: rule === null ? text : text.slice(0, rule.index) });
2059
2395
  used.add(index);
2060
2396
  used.add(file);
2061
- } else if (!isNoise(line)) {
2397
+ } else if (!isNoise(line) && !line.includes(": ") && ESLINT_FILE.test(line.trimEnd())) {
2062
2398
  file = index;
2063
2399
  }
2064
2400
  }
@@ -2118,6 +2454,14 @@ var collectRuff = (lines, used) => {
2118
2454
  };
2119
2455
  var collectPytest = (lines, used) => {
2120
2456
  const errors = [];
2457
+ const silent = new Map;
2458
+ let section;
2459
+ const closeSection = () => {
2460
+ if (section === undefined || errors.length !== section.errors)
2461
+ return;
2462
+ const key = section.title.replace(PYTEST_ERROR_SECTION, "");
2463
+ silent.set(key, (silent.get(key) ?? 0) + 1);
2464
+ };
2121
2465
  const title = (line) => PYTEST_BANNER.exec(line ?? "")?.[1];
2122
2466
  const start = lines.findIndex((line) => PYTEST_FAILURES.has(title(line) ?? ""));
2123
2467
  if (start === -1)
@@ -2145,8 +2489,12 @@ var collectPytest = (lines, used) => {
2145
2489
  const text = first === "" || first.startsWith(exception) ? first || (location[3] ?? "") : `${location[3] ?? ""}: ${first}`;
2146
2490
  errors.push({ tool: "pytest", file: location[1] ?? "", line: Number(location[2]), column: 0, severity: "error", message: text });
2147
2491
  }
2148
- if (PYTEST_SECTION.test(line))
2492
+ const opened = PYTEST_SECTION.exec(line);
2493
+ if (opened !== null) {
2149
2494
  frame = undefined;
2495
+ closeSection();
2496
+ section = { title: opened[1] ?? "", errors: errors.length };
2497
+ }
2150
2498
  if (line.trim() !== "")
2151
2499
  message = [];
2152
2500
  }
@@ -2154,12 +2502,35 @@ var collectPytest = (lines, used) => {
2154
2502
  }
2155
2503
  if (frame !== undefined && message.length > 0)
2156
2504
  errors.push({ tool: "pytest", ...frame, column: 0, severity: "error", message: message[0] ?? "" });
2505
+ closeSection();
2157
2506
  for (let index = stop;index < lines.length; index++) {
2158
- if (PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
2159
- used.add(index);
2507
+ if (!PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
2508
+ continue;
2509
+ used.add(index);
2510
+ const [, file = "", rest, fileReason] = PYTEST_SUMMARY.exec(lines[index] ?? "") ?? [];
2511
+ const parts = summaryParts(file, rest, fileReason, silent);
2512
+ if (parts === undefined)
2513
+ continue;
2514
+ const { key, name, reason } = parts;
2515
+ const left = silent.get(key) ?? 0;
2516
+ silent.set(key, left - 1);
2517
+ errors.push({ tool: "pytest", file, line: 0, column: 0, severity: "error", message: reason ?? "failed", test: name === undefined ? file : `${file}::${name}` });
2160
2518
  }
2161
2519
  return errors;
2162
2520
  };
2521
+ function summaryParts(file, rest, fileReason, silent) {
2522
+ const keyOf = (name) => name === undefined ? file : name.replaceAll("::", ".");
2523
+ const candidates = [];
2524
+ if (rest === undefined) {
2525
+ candidates.push({ name: undefined, reason: fileReason });
2526
+ } else {
2527
+ for (let at = rest.indexOf(" - ");at !== -1; at = rest.indexOf(" - ", at + 1))
2528
+ candidates.push({ name: rest.slice(0, at), reason: rest.slice(at + 3) });
2529
+ candidates.push({ name: rest, reason: undefined });
2530
+ }
2531
+ const found = candidates.find((candidate) => (silent.get(keyOf(candidate.name)) ?? 0) > 0);
2532
+ return found === undefined ? undefined : { key: keyOf(found.name), ...found };
2533
+ }
2163
2534
  var collectGeneric = (lines, used) => {
2164
2535
  const errors = [];
2165
2536
  for (const [index, line] of lines.entries()) {
@@ -2178,8 +2549,7 @@ var collectGeneric = (lines, used) => {
2178
2549
  };
2179
2550
  var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint, collectGeneric];
2180
2551
  function parseErrors(output) {
2181
- const lines = stripAnsi(output).split(`
2182
- `);
2552
+ const lines = stripAnsi(output).split(LINE_BREAK);
2183
2553
  if (BASH_ECHO2.test(lines[0] ?? ""))
2184
2554
  lines.shift();
2185
2555
  const used = new Set;
@@ -2198,14 +2568,14 @@ function parseErrors(output) {
2198
2568
  // src/run.ts
2199
2569
  import { mkdir as mkdir2, readdir as readdir2, stat as stat2, writeFile } from "fs/promises";
2200
2570
  import { basename as basename2, join as join9 } from "path";
2201
- import process20 from "process";
2571
+ import process21 from "process";
2202
2572
  var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
2203
2573
  var RESULTS_FILE = "results.json";
2204
2574
  var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
2205
2575
  async function logDirectory(cwd) {
2206
2576
  const root = await privateLogDirectory("check");
2207
2577
  await sweepLogs(root, LOG_MAX_AGE_MS);
2208
- const path = join9(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process20.pid}`);
2578
+ const path = join9(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process21.pid}`);
2209
2579
  await mkdir2(path, { mode: 448 });
2210
2580
  return path;
2211
2581
  }
@@ -2233,7 +2603,7 @@ async function lastFailed(cwd) {
2233
2603
  async function saveLog(output) {
2234
2604
  const root = await privateLogDirectory("errs");
2235
2605
  await sweepLogs(root);
2236
- const path = join9(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process20.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2606
+ const path = join9(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process21.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2237
2607
  await writeFile(path, output, { mode: 384, flag: "wx" });
2238
2608
  return path;
2239
2609
  }
@@ -2241,7 +2611,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
2241
2611
  const started = Date.now();
2242
2612
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
2243
2613
  cwd,
2244
- env: { ...process20.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2614
+ env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2245
2615
  ...timeoutMs === undefined ? {} : { timeoutMs },
2246
2616
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
2247
2617
  });
@@ -2257,8 +2627,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
2257
2627
  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
2628
  }
2259
2629
  function printOutcome(name, width, command, logFile, outcome) {
2260
- const colors = paint(process20.stdout);
2261
- const path = role("path", process20.stdout);
2630
+ const colors = paint(process21.stdout);
2631
+ const path = role("path", process21.stdout);
2262
2632
  const took = colors.dim(formatDuration(outcome.ms));
2263
2633
  if (outcome.ok) {
2264
2634
  console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
@@ -2278,14 +2648,13 @@ var usage2 = `errs [options] [log]
2278
2648
  errs [options] -- <command> [args...]
2279
2649
  errs --in <service> | --host -- <command> [args...]
2280
2650
 
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.`;
2651
+ 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 --.
2652
+ 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.
2653
+ 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
2654
  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
2655
  var options = {
2287
2656
  ...placeOptions,
2288
- json: jsonOption()
2657
+ json: jsonOption("{errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}")
2289
2658
  };
2290
2659
  function display(file, cwd) {
2291
2660
  const path = file.startsWith("/") ? relative2(cwd, file) : file;
@@ -2315,7 +2684,7 @@ async function readInput2(command, run, settings, cwd) {
2315
2684
  const held = holdSignals();
2316
2685
  let ran;
2317
2686
  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) });
2687
+ 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
2688
  } catch (error) {
2320
2689
  fail(`cannot run ${command[0]}: ${error instanceof Error ? error.message : String(error)}`);
2321
2690
  } finally {
@@ -2323,7 +2692,7 @@ async function readInput2(command, run, settings, cwd) {
2323
2692
  }
2324
2693
  return { text: stripAnsi(ran.text), log: await saveLog(ran.output), code: ran.code };
2325
2694
  }
2326
- async function errs(args, cwd = process21.cwd()) {
2695
+ async function errs(args, cwd = process22.cwd()) {
2327
2696
  const first = args[0];
2328
2697
  const bare = first !== undefined && !first.startsWith("-") && !await Bun.file(first).exists();
2329
2698
  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 +2716,4 @@ ${usage2}`);
2347
2716
  }
2348
2717
 
2349
2718
  // src/errs-cli.ts
2350
- process22.exitCode = await runMain({ name: "errs", version, run: async (args) => errs(args) });
2719
+ process23.exitCode = await runMain({ name: "errs", version, run: async (args) => errs(args) });