@kaynooo/cli-wait 0.12.1 → 0.12.4

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 +444 -171
  2. package/dist/slot-cli.js +430 -171
  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,15 +136,21 @@ 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";
131
145
  import { homedir } from "os";
132
- import { join as join2 } from "path";
146
+ import { isAbsolute, join as join2 } from "path";
133
147
  import process4 from "process";
148
+ function xdgFolder(value, fallback) {
149
+ return value !== undefined && isAbsolute(value) ? value : fallback;
150
+ }
134
151
  function configBase(where = {}) {
135
152
  const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
136
- return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
153
+ return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
137
154
  }
138
155
  function userConfigPath(bin, where = {}) {
139
156
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
@@ -160,36 +177,18 @@ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
160
177
  const value = readUserConfig(bin, where, legacy)[key];
161
178
  return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
162
179
  }
180
+ var init_user_config = () => {};
163
181
 
164
182
  // ../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+/;
183
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
184
+ import { homedir as homedir2 } from "os";
185
+ import { join as join3, resolve as resolve2 } from "path";
186
+ import process5 from "process";
187
187
  function isColorSpec(spec) {
188
188
  if (typeof spec === "number")
189
189
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
190
190
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
191
191
  }
192
- var CUBE = [0, 95, 135, 175, 215, 255];
193
192
  function cubeLevel(channel) {
194
193
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
195
194
  }
@@ -294,7 +293,6 @@ function applyFile(theme, file, where, warn) {
294
293
  function endsWalk(home) {
295
294
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
296
295
  }
297
- var warned = new Set;
298
296
  function warnOnce(message) {
299
297
  if (warned.has(message))
300
298
  return;
@@ -331,8 +329,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
331
329
  }
332
330
  return { theme, sources, preset };
333
331
  }
334
- var current;
335
- var currentKey = "";
336
332
  function activeTheme() {
337
333
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
338
334
  if (current === undefined || key !== currentKey) {
@@ -341,9 +337,38 @@ function activeTheme() {
341
337
  }
342
338
  return current;
343
339
  }
340
+ var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
341
+ var init_theme = __esm(() => {
342
+ init_config();
343
+ init_user_config();
344
+ ENDS = new Map;
345
+ DEFAULT = {
346
+ 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" },
347
+ 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" },
348
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
349
+ bins: {},
350
+ gradient: ["#c084fc", "#67e8f9"]
351
+ };
352
+ 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" };
353
+ 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" };
354
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
355
+ PRESETS = {
356
+ default: {},
357
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
358
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
359
+ ascii: { glyphs: ASCII }
360
+ };
361
+ 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"]);
362
+ HEX = /^#[0-9a-f]{6}$/i;
363
+ CONTROL = /\p{Cc}/u;
364
+ MAX_FILE_BYTES = 64 * 1024;
365
+ SPACES = /\s+/;
366
+ CUBE = [0, 95, 135, 175, 215, 255];
367
+ warned = new Set;
368
+ });
344
369
 
345
370
  // ../kit/src/style.ts
346
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
371
+ import process6 from "process";
347
372
  function takesControlCodes(stream, env = process6.env) {
348
373
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
349
374
  }
@@ -362,14 +387,6 @@ function marked(mark, text, stream, detail, env = process6.env) {
362
387
  function problem(text, detail) {
363
388
  console.error(marked("problem", text, process6.stderr, detail));
364
389
  }
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
390
  function statusOf(word) {
374
391
  return STATUS_OF.get(word.toLowerCase());
375
392
  }
@@ -380,9 +397,24 @@ function badge(word, stream, env = process6.env) {
380
397
  const { theme } = activeTheme();
381
398
  return tinted(paint(stream, env), theme.colors[status], env)(`${theme.glyphs[status]} ${word}`);
382
399
  }
400
+ var MARK_WORDS, STATUS_WORDS, STATUS_OF;
401
+ var init_style = __esm(() => {
402
+ init_colors();
403
+ init_mode();
404
+ init_theme();
405
+ MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
406
+ STATUS_WORDS = {
407
+ passed: ["passed", "success", "succeeded", "ok"],
408
+ failed: ["failed", "failure", "error", "errored"],
409
+ running: ["running", "in_progress", "started", "holding"],
410
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
411
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
412
+ };
413
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
414
+ });
383
415
 
384
416
  // ../kit/src/format.ts
385
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
417
+ import process7 from "process";
386
418
  function formatSeconds(total) {
387
419
  let rest = Math.max(0, Math.round(total));
388
420
  const amounts = UNITS.map(([unit, size]) => {
@@ -414,10 +446,8 @@ function formatAge(date, now = Date.now()) {
414
446
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
415
447
  }
416
448
  function truncate(text, width) {
417
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
449
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
418
450
  }
419
- var LINE_BREAKS = /\s*\n\s*/g;
420
- var ESCAPE = String.fromCharCode(27);
421
451
  function textWidth(text) {
422
452
  return Bun.stringWidth(text);
423
453
  }
@@ -466,14 +496,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
466
496
  function printJson(value) {
467
497
  console.log(jsonText(value));
468
498
  }
499
+ var UNITS, LINE_BREAKS, ESCAPE;
500
+ var init_format = __esm(() => {
501
+ init_text();
502
+ init_mode();
503
+ init_style();
504
+ UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
505
+ LINE_BREAKS = /\s*\n\s*/g;
506
+ ESCAPE = String.fromCharCode(27);
507
+ });
469
508
 
470
509
  // ../kit/src/help.ts
471
510
  import process8 from "process";
472
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
473
- var USAGE_PREFIX = /^usage:\s*/i;
474
- var FULL_STOP = /\.$/;
475
511
  function usageLine(usage, colors = paint(process8.stdout)) {
476
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
512
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
513
+ `);
514
+ const blank = lines.indexOf("");
515
+ const synopses = blank === -1 ? lines : lines.slice(0, blank);
516
+ const details = blank === -1 ? [] : lines.slice(blank + 1);
517
+ const colon = synopses[0].indexOf(": ");
518
+ const inline = synopses[0].slice(colon + 2);
519
+ const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
520
+ if (colon !== -1)
521
+ synopses[0] = synopses[0].slice(0, colon);
522
+ const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
523
+ `)}`;
524
+ const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
525
+ const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
526
+ return [head, ...lead, ...rest].join(`
527
+ `);
528
+ }
529
+ function prose(line, colors) {
530
+ if (colors.cyan("x") === "x")
531
+ return line;
532
+ return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
477
533
  }
478
534
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
479
535
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -508,7 +564,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
508
564
  return [];
509
565
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
510
566
  }
511
- var MAX_INLINE_CHOICES = 24;
512
567
  function optionRows(options, colors = paint(process8.stdout)) {
513
568
  const rows = Object.entries(options).map(([name, option]) => {
514
569
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -523,6 +578,15 @@ function optionRows(options, colors = paint(process8.stdout)) {
523
578
  const width = Math.max(0, ...rows.map((row) => row.width));
524
579
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
525
580
  }
581
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
582
+ var init_help = __esm(() => {
583
+ init_mode();
584
+ init_style();
585
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
586
+ USAGE_PREFIX = /^usage:\s*/i;
587
+ FULL_STOP = /\.$/;
588
+ PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
589
+ });
526
590
 
527
591
  // ../kit/src/text.ts
528
592
  function distance(a, b) {
@@ -550,8 +614,9 @@ function closest(name, names) {
550
614
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
551
615
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
552
616
  }
617
+ var init_text2 = () => {};
618
+
553
619
  // ../kit/src/input.ts
554
- var WHOLE = /^\d+$/;
555
620
  function wholeNumber(value, name, fallback, min = 1) {
556
621
  if (value === undefined)
557
622
  return fallback;
@@ -560,8 +625,6 @@ function wholeNumber(value, name, fallback, min = 1) {
560
625
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
561
626
  return number;
562
627
  }
563
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
564
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
565
628
  function duration(value, name, fallback, unit = "s") {
566
629
  if (value === undefined)
567
630
  return fallback;
@@ -571,40 +634,27 @@ function duration(value, name, fallback, unit = "s") {
571
634
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
572
635
  return ms;
573
636
  }
637
+ var WHOLE, DURATION, UNIT_MS;
638
+ var init_input = __esm(() => {
639
+ init_args();
640
+ WHOLE = /^\d+$/;
641
+ DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
642
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
643
+ });
574
644
 
575
645
  // ../kit/src/args.ts
576
- var DASHES = /^-+/;
646
+ import process9 from "process";
647
+ import { parseArgs } from "util";
577
648
  function jsonOption(holds) {
578
649
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
579
650
  }
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
651
  function fail(message, code = 2, hint) {
590
652
  throw new Exit(message, code, hint);
591
653
  }
592
-
593
- class UsageError extends Exit {
594
- constructor(message, hint) {
595
- super(message, 2, hint);
596
- }
597
- }
598
654
  function badUsage(message) {
599
655
  throw new UsageError(message);
600
656
  }
601
657
 
602
- class HelpShown extends Exit {
603
- constructor() {
604
- super("help shown", 0);
605
- }
606
- }
607
-
608
658
  class Completing {
609
659
  options;
610
660
  positionals;
@@ -615,11 +665,6 @@ class Completing {
615
665
  this.candidates = candidates;
616
666
  }
617
667
  }
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
668
  function applyOutput(color, plain, env = process9.env) {
624
669
  const when = plain === true ? "never" : color ?? "auto";
625
670
  if (when === "auto")
@@ -773,7 +818,6 @@ function parseError(error) {
773
818
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
774
819
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
775
820
  }
776
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
777
821
  function nearestOption(message, options, allowNegative) {
778
822
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
779
823
  if (typed === undefined)
@@ -789,6 +833,62 @@ function nearestOption(message, options, allowNegative) {
789
833
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
790
834
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
791
835
  }
836
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
837
+ var init_args = __esm(() => {
838
+ init_format();
839
+ init_help();
840
+ init_text2();
841
+ init_help();
842
+ init_input();
843
+ DASHES = /^-+/;
844
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
845
+ Exit = class Exit extends Error {
846
+ code;
847
+ hint;
848
+ [EXIT] = true;
849
+ constructor(message, code, hint) {
850
+ super(message);
851
+ this.code = code;
852
+ this.hint = hint;
853
+ }
854
+ static [Symbol.hasInstance](value) {
855
+ if (this !== Exit)
856
+ return Function.prototype[Symbol.hasInstance].call(this, value);
857
+ return typeof value === "object" && value !== null && value[EXIT] === true;
858
+ }
859
+ };
860
+ UsageError = class UsageError extends Exit {
861
+ constructor(message, hint) {
862
+ super(message, 2, hint);
863
+ }
864
+ };
865
+ HelpShown = class HelpShown extends Exit {
866
+ constructor() {
867
+ super("help shown", 0);
868
+ }
869
+ };
870
+ completion = { active: false };
871
+ OUTPUT_OPTIONS = {
872
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
873
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
874
+ };
875
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
876
+ });
877
+
878
+ // ../kit/src/folders.ts
879
+ var SKIPPED_FOLDERS;
880
+ var init_folders = __esm(() => {
881
+ init_user_config();
882
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
883
+ });
884
+
885
+ // src/cli.ts
886
+ import { existsSync as existsSync6 } from "fs";
887
+ import process21 from "process";
888
+
889
+ // ../kit/src/index.ts
890
+ init_args();
891
+
792
892
  // ../kit/src/argv.ts
793
893
  import { readFileSync as readFileSync3, realpathSync } from "fs";
794
894
  import { resolve as resolve3 } from "path";
@@ -813,14 +913,26 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
813
913
  const after = at === -1 ? [] : cmdline.slice(at + 1);
814
914
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
815
915
  }
916
+ // ../kit/src/chart.ts
917
+ init_format();
918
+ init_mode();
919
+ init_style();
920
+ init_theme();
921
+ // ../kit/src/ci.ts
922
+ init_args();
923
+ init_format();
924
+
816
925
  // ../kit/src/progress.ts
926
+ init_format();
817
927
  import process12 from "process";
818
928
 
819
929
  // ../kit/src/process.ts
930
+ import { readFileSync as readFileSync4 } from "fs";
820
931
  import { constants } from "os";
821
932
  import process11 from "process";
822
933
  var KILL_GRACE_MS = 2000;
823
934
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
935
+ var GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
824
936
  function exitCodeOf(code, signal) {
825
937
  if (code !== null)
826
938
  return code;
@@ -828,6 +940,21 @@ function exitCodeOf(code, signal) {
828
940
  return 128 + signal;
829
941
  return signal === null ? 129 : 128 + constants.signals[signal];
830
942
  }
943
+ function groupsOf(pid) {
944
+ try {
945
+ const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
946
+ const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
947
+ return { group: Number(fields[2]), foreground: Number(fields[5]) };
948
+ } catch {
949
+ return;
950
+ }
951
+ }
952
+ function heardTheTerminal(child) {
953
+ if (child.pid === undefined)
954
+ return false;
955
+ const own = groupsOf("self");
956
+ return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
957
+ }
831
958
  function holdSignals(cleanup) {
832
959
  let received;
833
960
  let child;
@@ -846,7 +973,8 @@ function holdSignals(cleanup) {
846
973
  function onSignal(signal) {
847
974
  received = signal;
848
975
  if (child !== undefined) {
849
- child.kill(signal);
976
+ if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
977
+ child.kill(signal);
850
978
  return;
851
979
  }
852
980
  if (cleanup === undefined)
@@ -859,10 +987,10 @@ function holdSignals(cleanup) {
859
987
  process11.on(signal, onSignal);
860
988
  return held;
861
989
  }
862
- async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
990
+ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
863
991
  const chunks = [];
864
992
  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 } : {} });
993
+ 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
994
  const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
867
995
  const timers = [];
868
996
  const killGroup = (killing) => {
@@ -902,12 +1030,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
902
1030
  stop();
903
1031
  continue;
904
1032
  }
1033
+ if (state.truncated)
1034
+ continue;
1035
+ let kept = data;
905
1036
  if (state.kept + data.length > maxBytes) {
1037
+ let cut = maxBytes - state.kept;
1038
+ while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
1039
+ cut--;
1040
+ kept = data.subarray(0, cut);
906
1041
  state.truncated = true;
907
- continue;
908
1042
  }
909
- state.kept += data.length;
910
- chunks.push({ stream: name, data });
1043
+ state.kept += kept.length;
1044
+ if (kept.length > 0)
1045
+ chunks.push({ stream: name, data: kept });
911
1046
  }
912
1047
  };
913
1048
  try {
@@ -924,6 +1059,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
924
1059
  const joined = () => Buffer.concat(chunks.map(({ data }) => data));
925
1060
  let output;
926
1061
  let text;
1062
+ let stdout;
927
1063
  return {
928
1064
  code: exitCodeOf(proc.exitCode, proc.signalCode),
929
1065
  chunks,
@@ -934,11 +1070,16 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
934
1070
  },
935
1071
  get text() {
936
1072
  return text ??= (output ??= joined()).toString();
1073
+ },
1074
+ get stdout() {
1075
+ return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
937
1076
  }
938
1077
  };
939
1078
  }
940
1079
 
941
1080
  // ../kit/src/progress.ts
1081
+ init_style();
1082
+ init_theme();
942
1083
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
943
1084
  var FRAME_MS = 200;
944
1085
  var CLEAR_BELOW = "\r\x1B[J";
@@ -955,10 +1096,14 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
955
1096
  }, print: (text) => void stream.write(`${text}
956
1097
  `), stop: () => {
957
1098
  return;
1099
+ }, pause: () => () => {
1100
+ return;
958
1101
  } };
959
1102
  const write = stream.write.bind(stream);
960
1103
  let frame = 0;
961
1104
  let drawn = false;
1105
+ let paused = false;
1106
+ let stopped = false;
962
1107
  const columns = () => {
963
1108
  const now = stream.getWindowSize?.()[0] ?? stream.columns;
964
1109
  return now === undefined || now === 0 ? 80 : now;
@@ -969,6 +1114,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
969
1114
  drawn = false;
970
1115
  };
971
1116
  const draw = () => {
1117
+ if (paused)
1118
+ return;
972
1119
  const width = columns() - 1;
973
1120
  const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
974
1121
  const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
@@ -980,16 +1127,17 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
980
1127
  `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
981
1128
  drawn = true;
982
1129
  };
983
- const timer = setInterval(draw, FRAME_MS);
1130
+ let timer = setInterval(draw, FRAME_MS);
984
1131
  stream.on?.("resize", draw);
985
- const restore = interceptOutput(clear);
986
- const release = swallowInput();
1132
+ let restore = interceptOutput(clear);
1133
+ let release = swallowInput();
987
1134
  const onExit = () => {
988
1135
  clear();
989
1136
  release();
990
1137
  };
991
1138
  const signals = holdSignals(stop);
992
1139
  function stop() {
1140
+ stopped = true;
993
1141
  clearInterval(timer);
994
1142
  stream.off?.("resize", draw);
995
1143
  clear();
@@ -998,6 +1146,29 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
998
1146
  process12.off("exit", onExit);
999
1147
  signals.release();
1000
1148
  }
1149
+ function pause() {
1150
+ if (paused || stopped)
1151
+ return () => {
1152
+ return;
1153
+ };
1154
+ paused = true;
1155
+ clearInterval(timer);
1156
+ stream.off?.("resize", draw);
1157
+ clear();
1158
+ restore();
1159
+ release();
1160
+ return () => {
1161
+ if (!paused || stopped)
1162
+ return;
1163
+ paused = false;
1164
+ timer = setInterval(draw, FRAME_MS);
1165
+ timer.unref();
1166
+ stream.on?.("resize", draw);
1167
+ restore = interceptOutput(clear);
1168
+ release = swallowInput();
1169
+ draw();
1170
+ };
1171
+ }
1001
1172
  timer.unref();
1002
1173
  process12.on("exit", onExit);
1003
1174
  return {
@@ -1008,7 +1179,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1008
1179
  `);
1009
1180
  draw();
1010
1181
  },
1011
- stop
1182
+ stop,
1183
+ pause
1012
1184
  };
1013
1185
  }
1014
1186
  function cutToWidth(line, width) {
@@ -1078,10 +1250,56 @@ function interceptOutput(clear) {
1078
1250
  }
1079
1251
  };
1080
1252
  }
1253
+
1254
+ // ../kit/src/ci.ts
1255
+ init_style();
1256
+
1257
+ // ../kit/src/tool.ts
1258
+ init_format();
1081
1259
  // ../kit/src/cli.ts
1082
- import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1260
+ init_args();
1261
+ import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
1083
1262
  import { dirname as dirname3, join as join6 } from "path";
1084
- import process16 from "process";
1263
+ import process17 from "process";
1264
+
1265
+ // ../kit/src/askpass.ts
1266
+ import process13 from "process";
1267
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1268
+ async function askpassClient(argv) {
1269
+ const socketPath = process13.env[SOCKET_VARIABLE];
1270
+ if (socketPath === undefined)
1271
+ return;
1272
+ const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1273
+ const { promise, resolve } = Promise.withResolvers();
1274
+ let received = "";
1275
+ try {
1276
+ await Bun.connect({
1277
+ unix: socketPath,
1278
+ socket: {
1279
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1280
+ `),
1281
+ data: (_, chunk) => {
1282
+ received += chunk.toString();
1283
+ },
1284
+ close: () => resolve(received),
1285
+ error: () => resolve("")
1286
+ }
1287
+ });
1288
+ } catch {
1289
+ return 1;
1290
+ }
1291
+ const reply = await promise;
1292
+ if (reply === "")
1293
+ return 1;
1294
+ const { answer } = JSON.parse(reply);
1295
+ if (request.notice === true)
1296
+ return 0;
1297
+ if (answer === undefined)
1298
+ return 1;
1299
+ process13.stdout.write(`${answer}
1300
+ `);
1301
+ return 0;
1302
+ }
1085
1303
 
1086
1304
  // ../kit/src/completions.ts
1087
1305
  var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
@@ -1144,49 +1362,54 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
1144
1362
  }
1145
1363
 
1146
1364
  // ../kit/src/notify.ts
1147
- import process13 from "process";
1365
+ init_format();
1366
+ init_mode();
1367
+ import process14 from "process";
1148
1368
  var NOTIFY_AFTER_MS = 1e4;
1149
1369
  var CANCELLED = 130;
1150
1370
  function base64(text) {
1151
1371
  return Buffer.from(text).toString("base64");
1152
1372
  }
1153
- function notification(title, body, env = process13.env) {
1154
- const id = `kit${process13.pid}`;
1373
+ function notification(title, body, env = process14.env) {
1374
+ const id = `kit${process14.pid}`;
1155
1375
  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
1376
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1157
1377
  }
1158
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1378
+ function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
1159
1379
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1160
1380
  return;
1161
1381
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1162
1382
  }
1163
1383
 
1384
+ // ../kit/src/cli.ts
1385
+ init_style();
1386
+ init_text2();
1387
+
1164
1388
  // ../kit/src/usage.ts
1165
1389
  import { appendFileSync, mkdirSync } from "fs";
1166
1390
  import { homedir as homedir4 } from "os";
1167
- import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1168
- import process15 from "process";
1391
+ import { dirname as dirname2, join as join5 } from "path";
1392
+ import process16 from "process";
1169
1393
 
1170
1394
  // ../kit/src/logs.ts
1395
+ init_user_config();
1171
1396
  import { lstatSync, openSync } from "fs";
1172
1397
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
1173
1398
  import { homedir as homedir3, tmpdir } from "os";
1174
1399
  import { join as join4 } from "path";
1175
- import process14 from "process";
1400
+ import process15 from "process";
1176
1401
  var DAY_MS = 24 * 60 * 60 * 1000;
1177
1402
  var CLI_FOLDER = "kaynooo-cli";
1178
1403
  function isPrivateDirectory(path) {
1179
1404
  try {
1180
1405
  const info = lstatSync(path, { throwIfNoEntry: false });
1181
- return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1406
+ return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1182
1407
  } catch {
1183
1408
  return false;
1184
1409
  }
1185
1410
  }
1186
- async function privateLogDirectory(name, env = process14.env) {
1187
- const runtime = env.XDG_RUNTIME_DIR;
1188
- const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1189
- const path = join4(base, name);
1411
+ async function privateLogDirectory(name, env = process15.env) {
1412
+ const path = join4(xdgFolder(env.XDG_RUNTIME_DIR, join4(homedir3(), ".cache")), CLI_FOLDER, name);
1190
1413
  try {
1191
1414
  await mkdir(path, { recursive: true, mode: 448 });
1192
1415
  if (isPrivateDirectory(path))
@@ -1196,6 +1419,7 @@ async function privateLogDirectory(name, env = process14.env) {
1196
1419
  }
1197
1420
 
1198
1421
  // ../kit/src/usage.ts
1422
+ init_user_config();
1199
1423
  var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
1200
1424
  var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
1201
1425
  var LONGEST_NAME = 40;
@@ -1203,14 +1427,13 @@ var usageError;
1203
1427
  function noteUsageError(message) {
1204
1428
  usageError = message;
1205
1429
  }
1206
- function stateHome(env = process15.env) {
1207
- const dir = env.XDG_STATE_HOME;
1208
- return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1430
+ function stateHome(env = process16.env) {
1431
+ return xdgFolder(env.XDG_STATE_HOME, join5(homedir4(), ".local", "state"));
1209
1432
  }
1210
- function usagePath(env = process15.env) {
1433
+ function usagePath(env = process16.env) {
1211
1434
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1212
1435
  }
1213
- function usageRecorded(env = process15.env) {
1436
+ function usageRecorded(env = process16.env) {
1214
1437
  const off = env.KAYNOOO_CLI_NO_USAGE;
1215
1438
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1216
1439
  }
@@ -1219,12 +1442,12 @@ function flagNames(argv) {
1219
1442
  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
1443
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1221
1444
  }
1222
- function usageEntry(bin, command, argv, code, now = new Date) {
1445
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1223
1446
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1224
1447
  usageError = undefined;
1225
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1448
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
1226
1449
  }
1227
- function recordUsage(entry, env = process15.env) {
1450
+ function recordUsage(entry, env = process16.env) {
1228
1451
  if (!usageRecorded(env))
1229
1452
  return;
1230
1453
  try {
@@ -1246,8 +1469,8 @@ var TOP_OPTIONS = {
1246
1469
  completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1247
1470
  };
1248
1471
  function printError(prefix, message, hint, cause) {
1249
- const colors = paint(process16.stderr);
1250
- const styled = takesControlCodes(process16.stderr);
1472
+ const colors = paint(process17.stderr);
1473
+ const styled = takesControlCodes(process17.stderr);
1251
1474
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1252
1475
  const under = (label, text, tint) => text === undefined ? "" : `
1253
1476
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1349,7 +1572,7 @@ function packageVersion(entry = Bun.main) {
1349
1572
  } catch {}
1350
1573
  for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
1351
1574
  try {
1352
- const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
1575
+ const { version } = JSON.parse(readFileSync5(join6(dir, "package.json"), "utf8"));
1353
1576
  if (typeof version === "string")
1354
1577
  return version;
1355
1578
  } catch {}
@@ -1358,6 +1581,9 @@ function packageVersion(entry = Bun.main) {
1358
1581
  }
1359
1582
  }
1360
1583
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1584
+ const answered = await askpassClient(argv);
1585
+ if (answered !== undefined)
1586
+ return answered;
1361
1587
  if (argv[0] === COMPLETE)
1362
1588
  return printCandidates(leafCandidates(run, argv.slice(1)));
1363
1589
  if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
@@ -1376,27 +1602,48 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1376
1602
  notifyEnd(name, code, performance.now() - started);
1377
1603
  if (usage !== false) {
1378
1604
  try {
1379
- recordUsage(usageEntry(name, undefined, argv, code));
1605
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
1380
1606
  } catch {}
1381
1607
  }
1382
1608
  return code;
1383
1609
  }
1384
- // ../kit/src/folders.ts
1385
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1610
+
1611
+ // ../kit/src/index.ts
1612
+ init_config();
1613
+
1614
+ // ../kit/src/excerpt.ts
1615
+ init_text2();
1616
+
1617
+ // ../kit/src/index.ts
1618
+ init_folders();
1619
+ init_format();
1620
+
1621
+ // ../kit/src/git.ts
1622
+ init_args();
1623
+ // ../kit/src/limit.ts
1624
+ init_args();
1625
+
1626
+ // ../kit/src/index.ts
1627
+ init_mode();
1628
+
1629
+ // ../kit/src/report.ts
1630
+ init_style();
1631
+ init_text2();
1386
1632
  // ../kit/src/secrets.ts
1387
1633
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1634
+ var NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
1388
1635
  // ../kit/src/sessions.ts
1389
1636
  import { homedir as homedir5 } from "os";
1390
1637
  import { join as join7 } from "path";
1391
- import process17 from "process";
1638
+ import process18 from "process";
1392
1639
  var {Glob } = globalThis.Bun;
1393
1640
  var SESSION_FILES = new Glob("*.json");
1394
1641
  var ACCOUNT_DIRS = new Glob("*/sessions");
1395
1642
  async function sessionDirs() {
1396
1643
  const home = homedir5();
1397
1644
  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"));
1645
+ if (process18.env.CLAUDE_CONFIG_DIR !== undefined)
1646
+ dirs.add(join7(process18.env.CLAUDE_CONFIG_DIR, "sessions"));
1400
1647
  try {
1401
1648
  for await (const dir of ACCOUNT_DIRS.scan({ cwd: join7(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1402
1649
  dirs.add(dir);
@@ -1442,7 +1689,7 @@ async function liveSessions() {
1442
1689
  }
1443
1690
  async function currentSession(sessions) {
1444
1691
  const byPid = new Map(sessions.map((session) => [session.pid, session]));
1445
- let pid = process17.ppid;
1692
+ let pid = process18.ppid;
1446
1693
  for (let depth = 0;depth < 32 && pid > 1; depth++) {
1447
1694
  const session = byPid.get(pid);
1448
1695
  if (session !== undefined)
@@ -1454,6 +1701,19 @@ async function currentSession(sessions) {
1454
1701
  }
1455
1702
  return;
1456
1703
  }
1704
+
1705
+ // ../kit/src/index.ts
1706
+ init_style();
1707
+ init_text2();
1708
+ init_theme();
1709
+ init_user_config();
1710
+
1711
+ // ../kit/src/watch.ts
1712
+ init_args();
1713
+ init_input();
1714
+ init_style();
1715
+ // ../kit/src/workspace-root.ts
1716
+ init_user_config();
1457
1717
  // src/conditions.ts
1458
1718
  import { existsSync as existsSync4, statSync as statSync2 } from "fs";
1459
1719
  var TAIL = configuredNumber("wait", "tail", 20);
@@ -1486,6 +1746,9 @@ class FileWatch {
1486
1746
  get failing() {
1487
1747
  return this.failure !== undefined;
1488
1748
  }
1749
+ get failsFirst() {
1750
+ return this.failure?.isFirst === true;
1751
+ }
1489
1752
  get exists() {
1490
1753
  return existsSync4(this.path);
1491
1754
  }
@@ -1499,7 +1762,7 @@ class FileWatch {
1499
1762
  continue;
1500
1763
  }
1501
1764
  if (this.failOn?.test(line.text) === true) {
1502
- this.failure = { before: this.recent.slice(-AROUND), line, after: [], waited: false };
1765
+ this.failure = { before: this.recent.slice(-AROUND), line, after: [], waited: false, isFirst: !this.matched };
1503
1766
  continue;
1504
1767
  }
1505
1768
  this.recent.push(line);
@@ -1523,7 +1786,10 @@ class FileWatch {
1523
1786
  async nextLines() {
1524
1787
  if (!existsSync4(this.path))
1525
1788
  return;
1526
- const { size, dev, ino } = statSync2(this.path);
1789
+ const stats = statSync2(this.path);
1790
+ if (stats.isDirectory())
1791
+ badUsage(`--file ${this.path} is a folder, not a log file`);
1792
+ const { size, dev, ino } = stats;
1527
1793
  const replaced = this.identity !== undefined && (this.identity.dev !== dev || this.identity.ino !== ino);
1528
1794
  this.identity = { dev, ino };
1529
1795
  if (size < this.offset || replaced) {
@@ -1536,13 +1802,20 @@ class FileWatch {
1536
1802
  if (size === this.offset)
1537
1803
  return;
1538
1804
  const end = Math.min(size, this.offset + SLICE_BYTES);
1539
- const chunk = this.decoder.decode(await Bun.file(this.path).slice(this.offset, end).bytes(), { stream: true });
1805
+ const chunk = this.decoder.decode(await this.slice(end), { stream: true });
1540
1806
  this.offset = end;
1541
1807
  const pieces = (this.partial + chunk).split(`
1542
1808
  `);
1543
1809
  this.partial = (pieces.pop() ?? "").slice(0, MAX_LINE);
1544
1810
  return pieces.map((text) => ({ number: ++this.number, text: Bun.stripANSI(text.slice(0, MAX_LINE).replace(CARRIAGE_RETURN, "")) }));
1545
1811
  }
1812
+ async slice(end) {
1813
+ try {
1814
+ return await Bun.file(this.path).slice(this.offset, end).bytes();
1815
+ } catch (error) {
1816
+ return badUsage(`--file ${this.path} cannot be read (${error.code ?? String(error)})`);
1817
+ }
1818
+ }
1546
1819
  }
1547
1820
  async function portProblem(host, port, timeoutMs = PORT_TIMEOUT_MS) {
1548
1821
  const attempt = Bun.connect({ hostname: host, port, socket: { data: (socket) => void socket.end() } });
@@ -1626,9 +1899,9 @@ async function urlCheck(url, timeout, expect = {}) {
1626
1899
  }
1627
1900
 
1628
1901
  // src/task.ts
1629
- import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
1902
+ import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync6, statSync as statSync3 } from "fs";
1630
1903
  import { join as join8 } from "path";
1631
- import process19 from "process";
1904
+ import process20 from "process";
1632
1905
  var EXITED = /(?:^|\n)\[exited with code (-?\d+)\]\n*$/;
1633
1906
  var FAILURE = /\(fail\)|\berror:/i;
1634
1907
  var TASK_ID = /^[\w-]+$/;
@@ -1636,9 +1909,9 @@ var TAIL_BYTES = 256;
1636
1909
  var LONGEST_FAILURES = 30;
1637
1910
  var CARRIAGE_RETURN2 = /\r$/;
1638
1911
  function tasksRoot(env) {
1639
- return join8(env.CLAUDE_CODE_TMPDIR ?? env.TMPDIR ?? "/tmp", `claude-${process19.getuid?.() ?? 0}`);
1912
+ return join8(env.CLAUDE_CODE_TMPDIR ?? env.TMPDIR ?? "/tmp", `claude-${process20.getuid?.() ?? 0}`);
1640
1913
  }
1641
- function taskFile(task, env = process19.env) {
1914
+ function taskFile(task, env = process20.env) {
1642
1915
  if (task.includes("/") || task.endsWith(".output"))
1643
1916
  return task;
1644
1917
  if (!TASK_ID.test(task))
@@ -1671,7 +1944,7 @@ async function taskEnd(path, lines) {
1671
1944
  }
1672
1945
  function pidAlive(pid) {
1673
1946
  try {
1674
- process19.kill(pid, 0);
1947
+ process20.kill(pid, 0);
1675
1948
  } catch (error) {
1676
1949
  return error.code === "EPERM";
1677
1950
  }
@@ -1679,7 +1952,7 @@ function pidAlive(pid) {
1679
1952
  }
1680
1953
  function isZombie(pid) {
1681
1954
  try {
1682
- const stat = readFileSync5(`/proc/${pid}/stat`, "utf8");
1955
+ const stat = readFileSync6(`/proc/${pid}/stat`, "utf8");
1683
1956
  return stat.slice(stat.lastIndexOf(")") + 2, stat.lastIndexOf(")") + 3) === "Z";
1684
1957
  } catch {
1685
1958
  return false;
@@ -1690,8 +1963,7 @@ function isZombie(pid) {
1690
1963
  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
1964
  waitfor task <task id | file>: waits for a Claude Code background task to end (waitfor task --help)
1692
1965
 
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.`;
1966
+ 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
1967
  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
1968
 
1697
1969
  The task is the id a background Bash call returned, or the path of its .output file.
@@ -1719,7 +1991,7 @@ var OPTIONS = {
1719
1991
  interval: { type: "string", description: "how long between two runs of --cmd (1s)" },
1720
1992
  any: { type: "boolean", description: "met by the first condition that is, not all of them (needs two)" },
1721
1993
  timeout: TIMEOUT,
1722
- json: jsonOption("{met, ms, line}"),
1994
+ 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
1995
  quiet: { type: "boolean", short: "q", description: "no live progress line: only what was met and the failure" }
1724
1996
  };
1725
1997
  var POLL = 250;
@@ -1764,7 +2036,7 @@ async function waitTask(args) {
1764
2036
  const lines = wholeNumber(values.lines, "lines", 20);
1765
2037
  const timeout = duration(values.timeout, "timeout", 5 * 60000);
1766
2038
  const started = Date.now();
1767
- const { dim } = paint(process20.stderr);
2039
+ const { dim } = paint(process21.stderr);
1768
2040
  const region = values.quiet === true ? undefined : liveRegion((spinner) => [`${spinner} task ${task}: still running ${dim(formatElapsed(Date.now() - started))}`]);
1769
2041
  let code;
1770
2042
  try {
@@ -1853,7 +2125,7 @@ ${USAGE}`);
1853
2125
  let isPidLeft = pid !== undefined;
1854
2126
  let cmdLeft = values.cmd === undefined ? undefined : "not run yet";
1855
2127
  let cmdRanAt = 0;
1856
- const { dim } = paint(process20.stderr);
2128
+ const { dim } = paint(process21.stderr);
1857
2129
  const region = values.quiet === true ? undefined : liveRegion((spinner) => {
1858
2130
  const waited = dim(formatElapsed(Date.now() - started));
1859
2131
  const left = [
@@ -1937,7 +2209,8 @@ ${numbered(event.excerpt, event.line)}`);
1937
2209
  pid !== undefined && !isPidLeft,
1938
2210
  values.cmd !== undefined && cmdLeft === undefined
1939
2211
  ];
1940
- if (isAny ? isMet.includes(true) : (watch?.done ?? true) && ports.every((probe) => probe.left === undefined) && urls.every((probe) => probe.left === undefined) && !isPidLeft && cmdLeft === undefined) {
2212
+ const isAllMet = (watch?.done ?? true) && ports.every((probe) => probe.left === undefined) && urls.every((probe) => probe.left === undefined) && !isPidLeft && cmdLeft === undefined;
2213
+ if ((isAny ? isMet.includes(true) : isAllMet) && !(watch?.failsFirst ?? false)) {
1941
2214
  if (json)
1942
2215
  printJson({ met: true, ms: Date.now() - started, line: matched ?? null, conditions: metAt });
1943
2216
  return 0;
@@ -1969,4 +2242,4 @@ ${numbered(event.excerpt, event.line)}`);
1969
2242
  last lines of ${watch?.path}:
1970
2243
  ${numbered(lines)}`}`);
1971
2244
  }
1972
- process20.exitCode = await runMain({ name: "waitfor", run: main });
2245
+ process21.exitCode = await runMain({ name: "waitfor", run: main });