@kaynooo/cli-wait 0.12.1 → 0.12.3

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.
Files changed (3) hide show
  1. package/dist/cli.js +378 -151
  2. package/dist/slot-cli.js +382 -155
  3. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -1,21 +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 { existsSync as existsSync6 } from "fs";
6
- import process20 from "process";
7
- // ../kit/src/args.ts
8
- import process9 from "process";
9
- import { parseArgs } from "util";
10
-
11
- // ../kit/src/format.ts
12
- import process7 from "process";
13
-
14
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
15
- var N = new Map;
16
- var Nt = /\s+\S*$/;
17
- var Y = /\s/;
18
- 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 = "...") {
19
17
  let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
20
18
  if (t.length <= e)
21
19
  return t;
@@ -26,13 +24,22 @@ function ko(t, e, r = "...") {
26
24
  c = c.trimEnd();
27
25
  return s ? (c + n).slice(0, l) : c + n;
28
26
  }
29
- 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));
30
- 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
+ });
31
40
 
32
41
  // ../kit/src/mode.ts
33
42
  import process2 from "process";
34
- var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
35
- var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
36
43
  function isSet(value) {
37
44
  return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
38
45
  }
@@ -46,12 +53,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
46
53
  return "terminal";
47
54
  return isSet(env.CI) ? "ci" : "pipe";
48
55
  }
56
+ var MODES, AGENT_VARIABLES;
57
+ var init_mode = __esm(() => {
58
+ MODES = new Set(["terminal", "ci", "agent", "pipe"]);
59
+ AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
60
+ });
49
61
 
50
- // ../kit/src/style.ts
51
- import process6 from "process";
52
-
53
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
54
- var G2 = /^[a-f0-9]+$/i;
62
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
55
63
  function b(r) {
56
64
  let e = r.startsWith("#") ? r.slice(1) : r;
57
65
  if (!G2.test(e))
@@ -62,11 +70,6 @@ function b(r) {
62
70
  throw Error(`Invalid hex color length: ${e.length}`);
63
71
  return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
64
72
  }
65
- 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") => {
66
- let [l, n, c] = b(r);
67
- return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
68
- }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
69
- var h = new Set(["", "1", "2", "3", "true"]);
70
73
  function C(r, e = globalThis.process?.env ?? {}) {
71
74
  if (e.FORCE_COLOR !== undefined)
72
75
  return h.has(e.FORCE_COLOR);
@@ -80,7 +83,7 @@ function f(r, e = []) {
80
83
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
81
84
  let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
82
85
  return new Proxy(c, { get(t, i) {
83
- let a = B2[i];
86
+ let a = B[i];
84
87
  if (Array.isArray(a)) {
85
88
  let s = g.get(i);
86
89
  if (s === undefined)
@@ -103,13 +106,21 @@ function f(r, e = []) {
103
106
  function Fe(r = {}) {
104
107
  return f(r);
105
108
  }
106
- var o = Fe();
109
+ var G2, B, h, o;
110
+ var init_chunk_x450vn3m = __esm(() => {
111
+ G2 = /^[a-f0-9]+$/i;
112
+ 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") => {
113
+ let [l, n, c] = b(r);
114
+ return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
115
+ }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
116
+ h = new Set(["", "1", "2", "3", "true"]);
117
+ o = Fe();
118
+ });
107
119
 
108
- // ../kit/src/theme.ts
109
- import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
110
- import { homedir as homedir2 } from "os";
111
- import { join as join3, resolve as resolve2 } from "path";
112
- import process5 from "process";
120
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
121
+ var init_colors = __esm(() => {
122
+ init_chunk_x450vn3m();
123
+ });
113
124
 
114
125
  // ../kit/src/config.ts
115
126
  import { existsSync } from "fs";
@@ -125,6 +136,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
125
136
  return;
126
137
  }
127
138
  }
139
+ var init_config = __esm(() => {
140
+ init_args();
141
+ });
128
142
 
129
143
  // ../kit/src/user-config.ts
130
144
  import { existsSync as existsSync2, readFileSync } from "fs";
@@ -160,36 +174,18 @@ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
160
174
  const value = readUserConfig(bin, where, legacy)[key];
161
175
  return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
162
176
  }
177
+ var init_user_config = () => {};
163
178
 
164
179
  // ../kit/src/theme.ts
165
- var ENDS = new Map;
166
- var DEFAULT = {
167
- 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" },
168
- 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" },
169
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
170
- bins: {},
171
- gradient: ["#c084fc", "#67e8f9"]
172
- };
173
- 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" };
174
- 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" };
175
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
176
- var PRESETS = {
177
- default: {},
178
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
179
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
180
- ascii: { glyphs: ASCII }
181
- };
182
- 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"]);
183
- var HEX = /^#[0-9a-f]{6}$/i;
184
- var CONTROL = /\p{Cc}/u;
185
- var MAX_FILE_BYTES = 64 * 1024;
186
- var SPACES = /\s+/;
180
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
181
+ import { homedir as homedir2 } from "os";
182
+ import { join as join3, resolve as resolve2 } from "path";
183
+ import process5 from "process";
187
184
  function isColorSpec(spec) {
188
185
  if (typeof spec === "number")
189
186
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
190
187
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
191
188
  }
192
- var CUBE = [0, 95, 135, 175, 215, 255];
193
189
  function cubeLevel(channel) {
194
190
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
195
191
  }
@@ -294,7 +290,6 @@ function applyFile(theme, file, where, warn) {
294
290
  function endsWalk(home) {
295
291
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
296
292
  }
297
- var warned = new Set;
298
293
  function warnOnce(message) {
299
294
  if (warned.has(message))
300
295
  return;
@@ -331,8 +326,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
331
326
  }
332
327
  return { theme, sources, preset };
333
328
  }
334
- var current;
335
- var currentKey = "";
336
329
  function activeTheme() {
337
330
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
338
331
  if (current === undefined || key !== currentKey) {
@@ -341,9 +334,38 @@ function activeTheme() {
341
334
  }
342
335
  return current;
343
336
  }
337
+ var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
338
+ var init_theme = __esm(() => {
339
+ init_config();
340
+ init_user_config();
341
+ ENDS = new Map;
342
+ DEFAULT = {
343
+ 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" },
344
+ 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" },
345
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
346
+ bins: {},
347
+ gradient: ["#c084fc", "#67e8f9"]
348
+ };
349
+ 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" };
350
+ 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" };
351
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
352
+ PRESETS = {
353
+ default: {},
354
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
355
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
356
+ ascii: { glyphs: ASCII }
357
+ };
358
+ 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"]);
359
+ HEX = /^#[0-9a-f]{6}$/i;
360
+ CONTROL = /\p{Cc}/u;
361
+ MAX_FILE_BYTES = 64 * 1024;
362
+ SPACES = /\s+/;
363
+ CUBE = [0, 95, 135, 175, 215, 255];
364
+ warned = new Set;
365
+ });
344
366
 
345
367
  // ../kit/src/style.ts
346
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
368
+ import process6 from "process";
347
369
  function takesControlCodes(stream, env = process6.env) {
348
370
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
349
371
  }
@@ -362,14 +384,6 @@ function marked(mark, text, stream, detail, env = process6.env) {
362
384
  function problem(text, detail) {
363
385
  console.error(marked("problem", text, process6.stderr, detail));
364
386
  }
365
- var STATUS_WORDS = {
366
- passed: ["passed", "success", "succeeded", "ok"],
367
- failed: ["failed", "failure", "error", "errored"],
368
- running: ["running", "in_progress", "started", "holding"],
369
- queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
370
- skipped: ["skipped", "cancelled", "canceled", "manual"]
371
- };
372
- var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
373
387
  function statusOf(word) {
374
388
  return STATUS_OF.get(word.toLowerCase());
375
389
  }
@@ -380,9 +394,24 @@ function badge(word, stream, env = process6.env) {
380
394
  const { theme } = activeTheme();
381
395
  return tinted(paint(stream, env), theme.colors[status], env)(`${theme.glyphs[status]} ${word}`);
382
396
  }
397
+ var MARK_WORDS, STATUS_WORDS, STATUS_OF;
398
+ var init_style = __esm(() => {
399
+ init_colors();
400
+ init_mode();
401
+ init_theme();
402
+ MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
403
+ STATUS_WORDS = {
404
+ passed: ["passed", "success", "succeeded", "ok"],
405
+ failed: ["failed", "failure", "error", "errored"],
406
+ running: ["running", "in_progress", "started", "holding"],
407
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
408
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
409
+ };
410
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
411
+ });
383
412
 
384
413
  // ../kit/src/format.ts
385
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
414
+ import process7 from "process";
386
415
  function formatSeconds(total) {
387
416
  let rest = Math.max(0, Math.round(total));
388
417
  const amounts = UNITS.map(([unit, size]) => {
@@ -414,10 +443,8 @@ function formatAge(date, now = Date.now()) {
414
443
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
415
444
  }
416
445
  function truncate(text, width) {
417
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
446
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
418
447
  }
419
- var LINE_BREAKS = /\s*\n\s*/g;
420
- var ESCAPE = String.fromCharCode(27);
421
448
  function textWidth(text) {
422
449
  return Bun.stringWidth(text);
423
450
  }
@@ -466,14 +493,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
466
493
  function printJson(value) {
467
494
  console.log(jsonText(value));
468
495
  }
496
+ var UNITS, LINE_BREAKS, ESCAPE;
497
+ var init_format = __esm(() => {
498
+ init_text();
499
+ init_mode();
500
+ init_style();
501
+ UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
502
+ LINE_BREAKS = /\s*\n\s*/g;
503
+ ESCAPE = String.fromCharCode(27);
504
+ });
469
505
 
470
506
  // ../kit/src/help.ts
471
507
  import process8 from "process";
472
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
473
- var USAGE_PREFIX = /^usage:\s*/i;
474
- var FULL_STOP = /\.$/;
475
508
  function usageLine(usage, colors = paint(process8.stdout)) {
476
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
509
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
510
+ `);
511
+ const blank = lines.indexOf("");
512
+ const synopses = blank === -1 ? lines : lines.slice(0, blank);
513
+ const details = blank === -1 ? [] : lines.slice(blank + 1);
514
+ const colon = synopses[0].indexOf(": ");
515
+ const inline = synopses[0].slice(colon + 2);
516
+ const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
517
+ if (colon !== -1)
518
+ synopses[0] = synopses[0].slice(0, colon);
519
+ const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
520
+ `)}`;
521
+ const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
522
+ const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
523
+ return [head, ...lead, ...rest].join(`
524
+ `);
525
+ }
526
+ function prose(line, colors) {
527
+ if (colors.cyan("x") === "x")
528
+ return line;
529
+ return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
477
530
  }
478
531
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
479
532
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -508,7 +561,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
508
561
  return [];
509
562
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
510
563
  }
511
- var MAX_INLINE_CHOICES = 24;
512
564
  function optionRows(options, colors = paint(process8.stdout)) {
513
565
  const rows = Object.entries(options).map(([name, option]) => {
514
566
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -523,6 +575,15 @@ function optionRows(options, colors = paint(process8.stdout)) {
523
575
  const width = Math.max(0, ...rows.map((row) => row.width));
524
576
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
525
577
  }
578
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
579
+ var init_help = __esm(() => {
580
+ init_mode();
581
+ init_style();
582
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
583
+ USAGE_PREFIX = /^usage:\s*/i;
584
+ FULL_STOP = /\.$/;
585
+ PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
586
+ });
526
587
 
527
588
  // ../kit/src/text.ts
528
589
  function distance(a, b) {
@@ -550,8 +611,9 @@ function closest(name, names) {
550
611
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
551
612
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
552
613
  }
614
+ var init_text2 = () => {};
615
+
553
616
  // ../kit/src/input.ts
554
- var WHOLE = /^\d+$/;
555
617
  function wholeNumber(value, name, fallback, min = 1) {
556
618
  if (value === undefined)
557
619
  return fallback;
@@ -560,8 +622,6 @@ function wholeNumber(value, name, fallback, min = 1) {
560
622
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
561
623
  return number;
562
624
  }
563
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
564
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
565
625
  function duration(value, name, fallback, unit = "s") {
566
626
  if (value === undefined)
567
627
  return fallback;
@@ -571,40 +631,27 @@ function duration(value, name, fallback, unit = "s") {
571
631
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
572
632
  return ms;
573
633
  }
634
+ var WHOLE, DURATION, UNIT_MS;
635
+ var init_input = __esm(() => {
636
+ init_args();
637
+ WHOLE = /^\d+$/;
638
+ DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
639
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
640
+ });
574
641
 
575
642
  // ../kit/src/args.ts
576
- var DASHES = /^-+/;
643
+ import process9 from "process";
644
+ import { parseArgs } from "util";
577
645
  function jsonOption(holds) {
578
646
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
579
647
  }
580
- class Exit extends Error {
581
- code;
582
- hint;
583
- constructor(message, code, hint) {
584
- super(message);
585
- this.code = code;
586
- this.hint = hint;
587
- }
588
- }
589
648
  function fail(message, code = 2, hint) {
590
649
  throw new Exit(message, code, hint);
591
650
  }
592
-
593
- class UsageError extends Exit {
594
- constructor(message, hint) {
595
- super(message, 2, hint);
596
- }
597
- }
598
651
  function badUsage(message) {
599
652
  throw new UsageError(message);
600
653
  }
601
654
 
602
- class HelpShown extends Exit {
603
- constructor() {
604
- super("help shown", 0);
605
- }
606
- }
607
-
608
655
  class Completing {
609
656
  options;
610
657
  positionals;
@@ -615,11 +662,6 @@ class Completing {
615
662
  this.candidates = candidates;
616
663
  }
617
664
  }
618
- var completion = { active: false };
619
- var OUTPUT_OPTIONS = {
620
- color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
621
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
622
- };
623
665
  function applyOutput(color, plain, env = process9.env) {
624
666
  const when = plain === true ? "never" : color ?? "auto";
625
667
  if (when === "auto")
@@ -773,7 +815,6 @@ function parseError(error) {
773
815
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
774
816
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
775
817
  }
776
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
777
818
  function nearestOption(message, options, allowNegative) {
778
819
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
779
820
  if (typed === undefined)
@@ -789,6 +830,62 @@ function nearestOption(message, options, allowNegative) {
789
830
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
790
831
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
791
832
  }
833
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
834
+ var init_args = __esm(() => {
835
+ init_format();
836
+ init_help();
837
+ init_text2();
838
+ init_help();
839
+ init_input();
840
+ DASHES = /^-+/;
841
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
842
+ Exit = class Exit extends Error {
843
+ code;
844
+ hint;
845
+ [EXIT] = true;
846
+ constructor(message, code, hint) {
847
+ super(message);
848
+ this.code = code;
849
+ this.hint = hint;
850
+ }
851
+ static [Symbol.hasInstance](value) {
852
+ if (this !== Exit)
853
+ return Function.prototype[Symbol.hasInstance].call(this, value);
854
+ return typeof value === "object" && value !== null && value[EXIT] === true;
855
+ }
856
+ };
857
+ UsageError = class UsageError extends Exit {
858
+ constructor(message, hint) {
859
+ super(message, 2, hint);
860
+ }
861
+ };
862
+ HelpShown = class HelpShown extends Exit {
863
+ constructor() {
864
+ super("help shown", 0);
865
+ }
866
+ };
867
+ completion = { active: false };
868
+ OUTPUT_OPTIONS = {
869
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
870
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
871
+ };
872
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
873
+ });
874
+
875
+ // ../kit/src/folders.ts
876
+ var SKIPPED_FOLDERS;
877
+ var init_folders = __esm(() => {
878
+ init_user_config();
879
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
880
+ });
881
+
882
+ // src/cli.ts
883
+ import { existsSync as existsSync6 } from "fs";
884
+ import process21 from "process";
885
+
886
+ // ../kit/src/index.ts
887
+ init_args();
888
+
792
889
  // ../kit/src/argv.ts
793
890
  import { readFileSync as readFileSync3, realpathSync } from "fs";
794
891
  import { resolve as resolve3 } from "path";
@@ -813,7 +910,17 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
813
910
  const after = at === -1 ? [] : cmdline.slice(at + 1);
814
911
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
815
912
  }
913
+ // ../kit/src/chart.ts
914
+ init_format();
915
+ init_mode();
916
+ init_style();
917
+ init_theme();
918
+ // ../kit/src/ci.ts
919
+ init_args();
920
+ init_format();
921
+
816
922
  // ../kit/src/progress.ts
923
+ init_format();
817
924
  import process12 from "process";
818
925
 
819
926
  // ../kit/src/process.ts
@@ -859,10 +966,10 @@ function holdSignals(cleanup) {
859
966
  process11.on(signal, onSignal);
860
967
  return held;
861
968
  }
862
- async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
969
+ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
863
970
  const chunks = [];
864
971
  const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
865
- const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
972
+ 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 } : {} });
866
973
  const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
867
974
  const timers = [];
868
975
  const killGroup = (killing) => {
@@ -939,6 +1046,8 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
939
1046
  }
940
1047
 
941
1048
  // ../kit/src/progress.ts
1049
+ init_style();
1050
+ init_theme();
942
1051
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
943
1052
  var FRAME_MS = 200;
944
1053
  var CLEAR_BELOW = "\r\x1B[J";
@@ -955,10 +1064,14 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
955
1064
  }, print: (text) => void stream.write(`${text}
956
1065
  `), stop: () => {
957
1066
  return;
1067
+ }, pause: () => () => {
1068
+ return;
958
1069
  } };
959
1070
  const write = stream.write.bind(stream);
960
1071
  let frame = 0;
961
1072
  let drawn = false;
1073
+ let paused = false;
1074
+ let stopped = false;
962
1075
  const columns = () => {
963
1076
  const now = stream.getWindowSize?.()[0] ?? stream.columns;
964
1077
  return now === undefined || now === 0 ? 80 : now;
@@ -969,6 +1082,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
969
1082
  drawn = false;
970
1083
  };
971
1084
  const draw = () => {
1085
+ if (paused)
1086
+ return;
972
1087
  const width = columns() - 1;
973
1088
  const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
974
1089
  const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
@@ -980,16 +1095,17 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
980
1095
  `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
981
1096
  drawn = true;
982
1097
  };
983
- const timer = setInterval(draw, FRAME_MS);
1098
+ let timer = setInterval(draw, FRAME_MS);
984
1099
  stream.on?.("resize", draw);
985
- const restore = interceptOutput(clear);
986
- const release = swallowInput();
1100
+ let restore = interceptOutput(clear);
1101
+ let release = swallowInput();
987
1102
  const onExit = () => {
988
1103
  clear();
989
1104
  release();
990
1105
  };
991
1106
  const signals = holdSignals(stop);
992
1107
  function stop() {
1108
+ stopped = true;
993
1109
  clearInterval(timer);
994
1110
  stream.off?.("resize", draw);
995
1111
  clear();
@@ -998,6 +1114,29 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
998
1114
  process12.off("exit", onExit);
999
1115
  signals.release();
1000
1116
  }
1117
+ function pause() {
1118
+ if (paused || stopped)
1119
+ return () => {
1120
+ return;
1121
+ };
1122
+ paused = true;
1123
+ clearInterval(timer);
1124
+ stream.off?.("resize", draw);
1125
+ clear();
1126
+ restore();
1127
+ release();
1128
+ return () => {
1129
+ if (!paused || stopped)
1130
+ return;
1131
+ paused = false;
1132
+ timer = setInterval(draw, FRAME_MS);
1133
+ timer.unref();
1134
+ stream.on?.("resize", draw);
1135
+ restore = interceptOutput(clear);
1136
+ release = swallowInput();
1137
+ draw();
1138
+ };
1139
+ }
1001
1140
  timer.unref();
1002
1141
  process12.on("exit", onExit);
1003
1142
  return {
@@ -1008,7 +1147,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1008
1147
  `);
1009
1148
  draw();
1010
1149
  },
1011
- stop
1150
+ stop,
1151
+ pause
1012
1152
  };
1013
1153
  }
1014
1154
  function cutToWidth(line, width) {
@@ -1078,10 +1218,56 @@ function interceptOutput(clear) {
1078
1218
  }
1079
1219
  };
1080
1220
  }
1221
+
1222
+ // ../kit/src/ci.ts
1223
+ init_style();
1224
+
1225
+ // ../kit/src/tool.ts
1226
+ init_format();
1081
1227
  // ../kit/src/cli.ts
1228
+ init_args();
1082
1229
  import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1083
1230
  import { dirname as dirname3, join as join6 } from "path";
1084
- import process16 from "process";
1231
+ import process17 from "process";
1232
+
1233
+ // ../kit/src/askpass.ts
1234
+ import process13 from "process";
1235
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1236
+ async function askpassClient(argv) {
1237
+ const socketPath = process13.env[SOCKET_VARIABLE];
1238
+ if (socketPath === undefined)
1239
+ return;
1240
+ const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1241
+ const { promise, resolve } = Promise.withResolvers();
1242
+ let received = "";
1243
+ try {
1244
+ await Bun.connect({
1245
+ unix: socketPath,
1246
+ socket: {
1247
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1248
+ `),
1249
+ data: (_, chunk) => {
1250
+ received += chunk.toString();
1251
+ },
1252
+ close: () => resolve(received),
1253
+ error: () => resolve("")
1254
+ }
1255
+ });
1256
+ } catch {
1257
+ return 1;
1258
+ }
1259
+ const reply = await promise;
1260
+ if (reply === "")
1261
+ return 1;
1262
+ const { answer } = JSON.parse(reply);
1263
+ if (request.notice === true)
1264
+ return 0;
1265
+ if (answer === undefined)
1266
+ return 1;
1267
+ process13.stdout.write(`${answer}
1268
+ `);
1269
+ return 0;
1270
+ }
1085
1271
 
1086
1272
  // ../kit/src/completions.ts
1087
1273
  var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
@@ -1144,46 +1330,52 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
1144
1330
  }
1145
1331
 
1146
1332
  // ../kit/src/notify.ts
1147
- import process13 from "process";
1333
+ init_format();
1334
+ init_mode();
1335
+ import process14 from "process";
1148
1336
  var NOTIFY_AFTER_MS = 1e4;
1149
1337
  var CANCELLED = 130;
1150
1338
  function base64(text) {
1151
1339
  return Buffer.from(text).toString("base64");
1152
1340
  }
1153
- function notification(title, body, env = process13.env) {
1154
- const id = `kit${process13.pid}`;
1341
+ function notification(title, body, env = process14.env) {
1342
+ const id = `kit${process14.pid}`;
1155
1343
  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\\`];
1156
1344
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1157
1345
  }
1158
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1346
+ function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
1159
1347
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1160
1348
  return;
1161
1349
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1162
1350
  }
1163
1351
 
1352
+ // ../kit/src/cli.ts
1353
+ init_style();
1354
+ init_text2();
1355
+
1164
1356
  // ../kit/src/usage.ts
1165
1357
  import { appendFileSync, mkdirSync } from "fs";
1166
1358
  import { homedir as homedir4 } from "os";
1167
1359
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1168
- import process15 from "process";
1360
+ import process16 from "process";
1169
1361
 
1170
1362
  // ../kit/src/logs.ts
1171
1363
  import { lstatSync, openSync } from "fs";
1172
1364
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
1173
1365
  import { homedir as homedir3, tmpdir } from "os";
1174
1366
  import { join as join4 } from "path";
1175
- import process14 from "process";
1367
+ import process15 from "process";
1176
1368
  var DAY_MS = 24 * 60 * 60 * 1000;
1177
1369
  var CLI_FOLDER = "kaynooo-cli";
1178
1370
  function isPrivateDirectory(path) {
1179
1371
  try {
1180
1372
  const info = lstatSync(path, { throwIfNoEntry: false });
1181
- return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1373
+ return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1182
1374
  } catch {
1183
1375
  return false;
1184
1376
  }
1185
1377
  }
1186
- async function privateLogDirectory(name, env = process14.env) {
1378
+ async function privateLogDirectory(name, env = process15.env) {
1187
1379
  const runtime = env.XDG_RUNTIME_DIR;
1188
1380
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1189
1381
  const path = join4(base, name);
@@ -1203,14 +1395,14 @@ var usageError;
1203
1395
  function noteUsageError(message) {
1204
1396
  usageError = message;
1205
1397
  }
1206
- function stateHome(env = process15.env) {
1398
+ function stateHome(env = process16.env) {
1207
1399
  const dir = env.XDG_STATE_HOME;
1208
1400
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1209
1401
  }
1210
- function usagePath(env = process15.env) {
1402
+ function usagePath(env = process16.env) {
1211
1403
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1212
1404
  }
1213
- function usageRecorded(env = process15.env) {
1405
+ function usageRecorded(env = process16.env) {
1214
1406
  const off = env.KAYNOOO_CLI_NO_USAGE;
1215
1407
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1216
1408
  }
@@ -1219,12 +1411,12 @@ function flagNames(argv) {
1219
1411
  const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
1220
1412
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1221
1413
  }
1222
- function usageEntry(bin, command, argv, code, now = new Date) {
1414
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1223
1415
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1224
1416
  usageError = undefined;
1225
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1417
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
1226
1418
  }
1227
- function recordUsage(entry, env = process15.env) {
1419
+ function recordUsage(entry, env = process16.env) {
1228
1420
  if (!usageRecorded(env))
1229
1421
  return;
1230
1422
  try {
@@ -1246,8 +1438,8 @@ var TOP_OPTIONS = {
1246
1438
  completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1247
1439
  };
1248
1440
  function printError(prefix, message, hint, cause) {
1249
- const colors = paint(process16.stderr);
1250
- const styled = takesControlCodes(process16.stderr);
1441
+ const colors = paint(process17.stderr);
1442
+ const styled = takesControlCodes(process17.stderr);
1251
1443
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1252
1444
  const under = (label, text, tint) => text === undefined ? "" : `
1253
1445
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1358,6 +1550,9 @@ function packageVersion(entry = Bun.main) {
1358
1550
  }
1359
1551
  }
1360
1552
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1553
+ const answered = await askpassClient(argv);
1554
+ if (answered !== undefined)
1555
+ return answered;
1361
1556
  if (argv[0] === COMPLETE)
1362
1557
  return printCandidates(leafCandidates(run, argv.slice(1)));
1363
1558
  if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
@@ -1376,27 +1571,47 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1376
1571
  notifyEnd(name, code, performance.now() - started);
1377
1572
  if (usage !== false) {
1378
1573
  try {
1379
- recordUsage(usageEntry(name, undefined, argv, code));
1574
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
1380
1575
  } catch {}
1381
1576
  }
1382
1577
  return code;
1383
1578
  }
1384
- // ../kit/src/folders.ts
1385
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1579
+
1580
+ // ../kit/src/index.ts
1581
+ init_config();
1582
+
1583
+ // ../kit/src/excerpt.ts
1584
+ init_text2();
1585
+
1586
+ // ../kit/src/index.ts
1587
+ init_folders();
1588
+ init_format();
1589
+
1590
+ // ../kit/src/git.ts
1591
+ init_args();
1592
+ // ../kit/src/limit.ts
1593
+ init_args();
1594
+
1595
+ // ../kit/src/index.ts
1596
+ init_mode();
1597
+
1598
+ // ../kit/src/report.ts
1599
+ init_style();
1600
+ init_text2();
1386
1601
  // ../kit/src/secrets.ts
1387
1602
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1388
1603
  // ../kit/src/sessions.ts
1389
1604
  import { homedir as homedir5 } from "os";
1390
1605
  import { join as join7 } from "path";
1391
- import process17 from "process";
1606
+ import process18 from "process";
1392
1607
  var {Glob } = globalThis.Bun;
1393
1608
  var SESSION_FILES = new Glob("*.json");
1394
1609
  var ACCOUNT_DIRS = new Glob("*/sessions");
1395
1610
  async function sessionDirs() {
1396
1611
  const home = homedir5();
1397
1612
  const dirs = new Set([join7(home, ".claude", "sessions")]);
1398
- if (process17.env.CLAUDE_CONFIG_DIR !== undefined)
1399
- dirs.add(join7(process17.env.CLAUDE_CONFIG_DIR, "sessions"));
1613
+ if (process18.env.CLAUDE_CONFIG_DIR !== undefined)
1614
+ dirs.add(join7(process18.env.CLAUDE_CONFIG_DIR, "sessions"));
1400
1615
  try {
1401
1616
  for await (const dir of ACCOUNT_DIRS.scan({ cwd: join7(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1402
1617
  dirs.add(dir);
@@ -1442,7 +1657,7 @@ async function liveSessions() {
1442
1657
  }
1443
1658
  async function currentSession(sessions) {
1444
1659
  const byPid = new Map(sessions.map((session) => [session.pid, session]));
1445
- let pid = process17.ppid;
1660
+ let pid = process18.ppid;
1446
1661
  for (let depth = 0;depth < 32 && pid > 1; depth++) {
1447
1662
  const session = byPid.get(pid);
1448
1663
  if (session !== undefined)
@@ -1454,6 +1669,19 @@ async function currentSession(sessions) {
1454
1669
  }
1455
1670
  return;
1456
1671
  }
1672
+
1673
+ // ../kit/src/index.ts
1674
+ init_style();
1675
+ init_text2();
1676
+ init_theme();
1677
+ init_user_config();
1678
+
1679
+ // ../kit/src/watch.ts
1680
+ init_args();
1681
+ init_input();
1682
+ init_style();
1683
+ // ../kit/src/workspace-root.ts
1684
+ init_user_config();
1457
1685
  // src/conditions.ts
1458
1686
  import { existsSync as existsSync4, statSync as statSync2 } from "fs";
1459
1687
  var TAIL = configuredNumber("wait", "tail", 20);
@@ -1628,7 +1856,7 @@ async function urlCheck(url, timeout, expect = {}) {
1628
1856
  // src/task.ts
1629
1857
  import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
1630
1858
  import { join as join8 } from "path";
1631
- import process19 from "process";
1859
+ import process20 from "process";
1632
1860
  var EXITED = /(?:^|\n)\[exited with code (-?\d+)\]\n*$/;
1633
1861
  var FAILURE = /\(fail\)|\berror:/i;
1634
1862
  var TASK_ID = /^[\w-]+$/;
@@ -1636,9 +1864,9 @@ var TAIL_BYTES = 256;
1636
1864
  var LONGEST_FAILURES = 30;
1637
1865
  var CARRIAGE_RETURN2 = /\r$/;
1638
1866
  function tasksRoot(env) {
1639
- return join8(env.CLAUDE_CODE_TMPDIR ?? env.TMPDIR ?? "/tmp", `claude-${process19.getuid?.() ?? 0}`);
1867
+ return join8(env.CLAUDE_CODE_TMPDIR ?? env.TMPDIR ?? "/tmp", `claude-${process20.getuid?.() ?? 0}`);
1640
1868
  }
1641
- function taskFile(task, env = process19.env) {
1869
+ function taskFile(task, env = process20.env) {
1642
1870
  if (task.includes("/") || task.endsWith(".output"))
1643
1871
  return task;
1644
1872
  if (!TASK_ID.test(task))
@@ -1671,7 +1899,7 @@ async function taskEnd(path, lines) {
1671
1899
  }
1672
1900
  function pidAlive(pid) {
1673
1901
  try {
1674
- process19.kill(pid, 0);
1902
+ process20.kill(pid, 0);
1675
1903
  } catch (error) {
1676
1904
  return error.code === "EPERM";
1677
1905
  }
@@ -1690,8 +1918,7 @@ function isZombie(pid) {
1690
1918
  var USAGE = `waitfor [options]: waits until a file shows a line, a port listens, a URL answers 2xx, a process exits or a command exits 0
1691
1919
  waitfor task <task id | file>: waits for a Claude Code background task to end (waitfor task --help)
1692
1920
 
1693
- Every condition given must be met, or with --any the first of them to be; --port and --url may be repeated, and --status and --body then apply to every --url. A --fail line in --file ends the wait at once. A timeout or a --fail line comes with an excerpt of what it saw last.
1694
- --json prints {met, ms, line, conditions} once met or on a --fail line, conditions naming each one met as {name, ms}, line being the last --until line or the --fail one as {number, text} (null when none), and the progress lines go to stderr.`;
1921
+ Every condition given must be met, or with --any the first of them to be; --port and --url may be repeated. A --fail line in --file ends the wait at once, and a timeout or a --fail line comes with an excerpt of what was seen last.`;
1695
1922
  var TASK_USAGE = `waitfor task [options] <task id | file>: waits for a Claude Code background task to end, then prints its exit code, its last lines and the (fail) and error: lines above them
1696
1923
 
1697
1924
  The task is the id a background Bash call returned, or the path of its .output file.
@@ -1719,7 +1946,7 @@ var OPTIONS = {
1719
1946
  interval: { type: "string", description: "how long between two runs of --cmd (1s)" },
1720
1947
  any: { type: "boolean", description: "met by the first condition that is, not all of them (needs two)" },
1721
1948
  timeout: TIMEOUT,
1722
- json: jsonOption("{met, ms, line}"),
1949
+ json: jsonOption("{met, ms, line, conditions: [{name, ms}]}, line being the last --until line or the --fail one as {number, text}; the progress lines go to stderr"),
1723
1950
  quiet: { type: "boolean", short: "q", description: "no live progress line: only what was met and the failure" }
1724
1951
  };
1725
1952
  var POLL = 250;
@@ -1764,7 +1991,7 @@ async function waitTask(args) {
1764
1991
  const lines = wholeNumber(values.lines, "lines", 20);
1765
1992
  const timeout = duration(values.timeout, "timeout", 5 * 60000);
1766
1993
  const started = Date.now();
1767
- const { dim } = paint(process20.stderr);
1994
+ const { dim } = paint(process21.stderr);
1768
1995
  const region = values.quiet === true ? undefined : liveRegion((spinner) => [`${spinner} task ${task}: still running ${dim(formatElapsed(Date.now() - started))}`]);
1769
1996
  let code;
1770
1997
  try {
@@ -1853,7 +2080,7 @@ ${USAGE}`);
1853
2080
  let isPidLeft = pid !== undefined;
1854
2081
  let cmdLeft = values.cmd === undefined ? undefined : "not run yet";
1855
2082
  let cmdRanAt = 0;
1856
- const { dim } = paint(process20.stderr);
2083
+ const { dim } = paint(process21.stderr);
1857
2084
  const region = values.quiet === true ? undefined : liveRegion((spinner) => {
1858
2085
  const waited = dim(formatElapsed(Date.now() - started));
1859
2086
  const left = [
@@ -1969,4 +2196,4 @@ ${numbered(event.excerpt, event.line)}`);
1969
2196
  last lines of ${watch?.path}:
1970
2197
  ${numbered(lines)}`}`);
1971
2198
  }
1972
- process20.exitCode = await runMain({ name: "waitfor", run: main });
2199
+ process21.exitCode = await runMain({ name: "waitfor", run: main });