@kaynooo/cli-wait 0.12.1 → 0.12.5

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 +457 -173
  2. package/dist/slot-cli.js +460 -178
  3. package/package.json +5 -5
package/dist/slot-cli.js CHANGED
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env -S bun --no-env-file --config=/dev/null
2
2
  // @bun
3
+ var __esm = (fn, res, err) => () => {
4
+ if (fn)
5
+ try {
6
+ res = fn(fn = 0);
7
+ } catch (e) {
8
+ err = [e];
9
+ }
10
+ if (err)
11
+ throw err[0];
12
+ return res;
13
+ };
3
14
 
4
- // src/slot-cli.ts
5
- import process21 from "process";
6
- // ../kit/src/args.ts
7
- import process9 from "process";
8
- import { parseArgs } from "util";
9
-
10
- // ../kit/src/format.ts
11
- import process7 from "process";
12
-
13
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
14
- var N = new Map;
15
- var Nt = /\s+\S*$/;
16
- var Y = /\s/;
17
- function ko(t, e, r = "...") {
15
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
16
+ function Ao(t, e, r = "...") {
18
17
  let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
19
18
  if (t.length <= e)
20
19
  return t;
@@ -25,13 +24,22 @@ function ko(t, e, r = "...") {
25
24
  c = c.trimEnd();
26
25
  return s ? (c + n).slice(0, l) : c + n;
27
26
  }
28
- var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
29
- var z = new Map;
27
+ var N, Nt, Y, be, W;
28
+ var init_chunk_rkhsft4a = __esm(() => {
29
+ N = new Map;
30
+ Nt = /\s+\S*$/;
31
+ Y = /\s/;
32
+ be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
33
+ W = new Map;
34
+ });
35
+
36
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
37
+ var init_text = __esm(() => {
38
+ init_chunk_rkhsft4a();
39
+ });
30
40
 
31
41
  // ../kit/src/mode.ts
32
42
  import process2 from "process";
33
- var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
34
- var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
35
43
  function isSet(value) {
36
44
  return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
37
45
  }
@@ -45,12 +53,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
45
53
  return "terminal";
46
54
  return isSet(env.CI) ? "ci" : "pipe";
47
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
+ });
48
61
 
49
- // ../kit/src/style.ts
50
- import process6 from "process";
51
-
52
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
53
- var G2 = /^[a-f0-9]+$/i;
62
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
54
63
  function b(r) {
55
64
  let e = r.startsWith("#") ? r.slice(1) : r;
56
65
  if (!G2.test(e))
@@ -61,11 +70,6 @@ function b(r) {
61
70
  throw Error(`Invalid hex color length: ${e.length}`);
62
71
  return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
63
72
  }
64
- 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") => {
65
- let [l, n, c] = b(r);
66
- return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
67
- }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
68
- var h = new Set(["", "1", "2", "3", "true"]);
69
73
  function C(r, e = globalThis.process?.env ?? {}) {
70
74
  if (e.FORCE_COLOR !== undefined)
71
75
  return h.has(e.FORCE_COLOR);
@@ -79,7 +83,7 @@ function f(r, e = []) {
79
83
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
80
84
  let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
81
85
  return new Proxy(c, { get(t, i) {
82
- let a = B2[i];
86
+ let a = B[i];
83
87
  if (Array.isArray(a)) {
84
88
  let s = g.get(i);
85
89
  if (s === undefined)
@@ -102,13 +106,21 @@ function f(r, e = []) {
102
106
  function Fe(r = {}) {
103
107
  return f(r);
104
108
  }
105
- 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
+ });
106
119
 
107
- // ../kit/src/theme.ts
108
- import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
109
- import { homedir as homedir2 } from "os";
110
- import { join as join3, resolve as resolve2 } from "path";
111
- 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
+ });
112
124
 
113
125
  // ../kit/src/config.ts
114
126
  import { existsSync } from "fs";
@@ -124,15 +136,21 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
124
136
  return;
125
137
  }
126
138
  }
139
+ var init_config = __esm(() => {
140
+ init_args();
141
+ });
127
142
 
128
143
  // ../kit/src/user-config.ts
129
144
  import { existsSync as existsSync2, readFileSync } from "fs";
130
145
  import { homedir } from "os";
131
- import { join as join2 } from "path";
146
+ import { isAbsolute, join as join2 } from "path";
132
147
  import process4 from "process";
148
+ function xdgFolder(value, fallback) {
149
+ return value !== undefined && isAbsolute(value) ? value : fallback;
150
+ }
133
151
  function configBase(where = {}) {
134
152
  const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
135
- return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
153
+ return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
136
154
  }
137
155
  function userConfigPath(bin, where = {}) {
138
156
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
@@ -159,36 +177,18 @@ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
159
177
  const value = readUserConfig(bin, where, legacy)[key];
160
178
  return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
161
179
  }
180
+ var init_user_config = () => {};
162
181
 
163
182
  // ../kit/src/theme.ts
164
- var ENDS = new Map;
165
- var DEFAULT = {
166
- 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" },
167
- 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" },
168
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
169
- bins: {},
170
- gradient: ["#c084fc", "#67e8f9"]
171
- };
172
- 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" };
173
- 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" };
174
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
175
- var PRESETS = {
176
- default: {},
177
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
178
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
179
- ascii: { glyphs: ASCII }
180
- };
181
- 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"]);
182
- var HEX = /^#[0-9a-f]{6}$/i;
183
- var CONTROL = /\p{Cc}/u;
184
- var MAX_FILE_BYTES = 64 * 1024;
185
- 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";
186
187
  function isColorSpec(spec) {
187
188
  if (typeof spec === "number")
188
189
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
189
190
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
190
191
  }
191
- var CUBE = [0, 95, 135, 175, 215, 255];
192
192
  function cubeLevel(channel) {
193
193
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
194
194
  }
@@ -293,7 +293,6 @@ function applyFile(theme, file, where, warn) {
293
293
  function endsWalk(home) {
294
294
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
295
295
  }
296
- var warned = new Set;
297
296
  function warnOnce(message) {
298
297
  if (warned.has(message))
299
298
  return;
@@ -330,8 +329,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
330
329
  }
331
330
  return { theme, sources, preset };
332
331
  }
333
- var current;
334
- var currentKey = "";
335
332
  function activeTheme() {
336
333
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
337
334
  if (current === undefined || key !== currentKey) {
@@ -340,9 +337,38 @@ function activeTheme() {
340
337
  }
341
338
  return current;
342
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
+ });
343
369
 
344
370
  // ../kit/src/style.ts
345
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
371
+ import process6 from "process";
346
372
  function takesControlCodes(stream, env = process6.env) {
347
373
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
348
374
  }
@@ -361,14 +387,6 @@ function marked(mark, text, stream, detail, env = process6.env) {
361
387
  function problem(text, detail) {
362
388
  console.error(marked("problem", text, process6.stderr, detail));
363
389
  }
364
- var STATUS_WORDS = {
365
- passed: ["passed", "success", "succeeded", "ok"],
366
- failed: ["failed", "failure", "error", "errored"],
367
- running: ["running", "in_progress", "started", "holding"],
368
- queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
369
- skipped: ["skipped", "cancelled", "canceled", "manual"]
370
- };
371
- var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
372
390
  function statusOf(word) {
373
391
  return STATUS_OF.get(word.toLowerCase());
374
392
  }
@@ -379,9 +397,24 @@ function badge(word, stream, env = process6.env) {
379
397
  const { theme } = activeTheme();
380
398
  return tinted(paint(stream, env), theme.colors[status], env)(`${theme.glyphs[status]} ${word}`);
381
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
+ });
382
415
 
383
416
  // ../kit/src/format.ts
384
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
417
+ import process7 from "process";
385
418
  function formatSeconds(total) {
386
419
  let rest = Math.max(0, Math.round(total));
387
420
  const amounts = UNITS.map(([unit, size]) => {
@@ -413,10 +446,8 @@ function formatAge(date, now = Date.now()) {
413
446
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
414
447
  }
415
448
  function truncate(text, width) {
416
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
449
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
417
450
  }
418
- var LINE_BREAKS = /\s*\n\s*/g;
419
- var ESCAPE = String.fromCharCode(27);
420
451
  function textWidth(text) {
421
452
  return Bun.stringWidth(text);
422
453
  }
@@ -465,14 +496,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
465
496
  function printJson(value) {
466
497
  console.log(jsonText(value));
467
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
+ });
468
508
 
469
509
  // ../kit/src/help.ts
470
510
  import process8 from "process";
471
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
472
- var USAGE_PREFIX = /^usage:\s*/i;
473
- var FULL_STOP = /\.$/;
474
511
  function usageLine(usage, colors = paint(process8.stdout)) {
475
- 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));
476
533
  }
477
534
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
478
535
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -507,7 +564,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
507
564
  return [];
508
565
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
509
566
  }
510
- var MAX_INLINE_CHOICES = 24;
511
567
  function optionRows(options, colors = paint(process8.stdout)) {
512
568
  const rows = Object.entries(options).map(([name, option]) => {
513
569
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -522,6 +578,15 @@ function optionRows(options, colors = paint(process8.stdout)) {
522
578
  const width = Math.max(0, ...rows.map((row) => row.width));
523
579
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
524
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
+ });
525
590
 
526
591
  // ../kit/src/text.ts
527
592
  function distance(a, b) {
@@ -549,8 +614,9 @@ function closest(name, names) {
549
614
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
550
615
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
551
616
  }
617
+ var init_text2 = () => {};
618
+
552
619
  // ../kit/src/input.ts
553
- var WHOLE = /^\d+$/;
554
620
  function wholeNumber(value, name, fallback, min = 1) {
555
621
  if (value === undefined)
556
622
  return fallback;
@@ -559,51 +625,47 @@ function wholeNumber(value, name, fallback, min = 1) {
559
625
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
560
626
  return number;
561
627
  }
562
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
563
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
628
+ function durationMs(text, unit) {
629
+ if (BARE_DURATION.test(text))
630
+ return Number(text) * UNIT_MS[unit];
631
+ if (!DURATION.test(text))
632
+ return 0;
633
+ let ms = 0;
634
+ for (const [, amount, part] of text.matchAll(DURATION_PART))
635
+ ms += Number(amount) * UNIT_MS[part];
636
+ return ms;
637
+ }
564
638
  function duration(value, name, fallback, unit = "s") {
565
639
  if (value === undefined)
566
640
  return fallback;
567
- const match = DURATION.exec(value.trim());
568
- const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
641
+ const ms = durationMs(value.trim(), unit);
569
642
  if (ms < 1)
570
643
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
571
644
  return ms;
572
645
  }
646
+ var WHOLE, BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
647
+ var init_input = __esm(() => {
648
+ init_args();
649
+ WHOLE = /^\d+$/;
650
+ BARE_DURATION = /^\d+(?:\.\d+)?$/;
651
+ DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
652
+ DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
653
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
654
+ });
573
655
 
574
656
  // ../kit/src/args.ts
575
- var DASHES = /^-+/;
657
+ import process9 from "process";
658
+ import { parseArgs } from "util";
576
659
  function jsonOption(holds) {
577
660
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
578
661
  }
579
- class Exit extends Error {
580
- code;
581
- hint;
582
- constructor(message, code, hint) {
583
- super(message);
584
- this.code = code;
585
- this.hint = hint;
586
- }
587
- }
588
662
  function fail(message, code = 2, hint) {
589
663
  throw new Exit(message, code, hint);
590
664
  }
591
-
592
- class UsageError extends Exit {
593
- constructor(message, hint) {
594
- super(message, 2, hint);
595
- }
596
- }
597
665
  function badUsage(message) {
598
666
  throw new UsageError(message);
599
667
  }
600
668
 
601
- class HelpShown extends Exit {
602
- constructor() {
603
- super("help shown", 0);
604
- }
605
- }
606
-
607
669
  class Completing {
608
670
  options;
609
671
  positionals;
@@ -614,11 +676,6 @@ class Completing {
614
676
  this.candidates = candidates;
615
677
  }
616
678
  }
617
- var completion = { active: false };
618
- var OUTPUT_OPTIONS = {
619
- color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
620
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
621
- };
622
679
  function applyOutput(color, plain, env = process9.env) {
623
680
  const when = plain === true ? "never" : color ?? "auto";
624
681
  if (when === "auto")
@@ -772,7 +829,6 @@ function parseError(error) {
772
829
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
773
830
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
774
831
  }
775
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
776
832
  function nearestOption(message, options, allowNegative) {
777
833
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
778
834
  if (typed === undefined)
@@ -788,6 +844,61 @@ function nearestOption(message, options, allowNegative) {
788
844
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
789
845
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
790
846
  }
847
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
848
+ var init_args = __esm(() => {
849
+ init_format();
850
+ init_help();
851
+ init_text2();
852
+ init_help();
853
+ init_input();
854
+ DASHES = /^-+/;
855
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
856
+ Exit = class Exit extends Error {
857
+ code;
858
+ hint;
859
+ [EXIT] = true;
860
+ constructor(message, code, hint) {
861
+ super(message);
862
+ this.code = code;
863
+ this.hint = hint;
864
+ }
865
+ static [Symbol.hasInstance](value) {
866
+ if (this !== Exit)
867
+ return Function.prototype[Symbol.hasInstance].call(this, value);
868
+ return typeof value === "object" && value !== null && value[EXIT] === true;
869
+ }
870
+ };
871
+ UsageError = class UsageError extends Exit {
872
+ constructor(message, hint) {
873
+ super(message, 2, hint);
874
+ }
875
+ };
876
+ HelpShown = class HelpShown extends Exit {
877
+ constructor() {
878
+ super("help shown", 0);
879
+ }
880
+ };
881
+ completion = { active: false };
882
+ OUTPUT_OPTIONS = {
883
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
884
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
885
+ };
886
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
887
+ });
888
+
889
+ // ../kit/src/folders.ts
890
+ var SKIPPED_FOLDERS;
891
+ var init_folders = __esm(() => {
892
+ init_user_config();
893
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
894
+ });
895
+
896
+ // src/slot-cli.ts
897
+ import process22 from "process";
898
+
899
+ // ../kit/src/index.ts
900
+ init_args();
901
+
791
902
  // ../kit/src/argv.ts
792
903
  import { readFileSync as readFileSync3, realpathSync } from "fs";
793
904
  import { resolve as resolve3 } from "path";
@@ -812,14 +923,26 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
812
923
  const after = at === -1 ? [] : cmdline.slice(at + 1);
813
924
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
814
925
  }
926
+ // ../kit/src/chart.ts
927
+ init_format();
928
+ init_mode();
929
+ init_style();
930
+ init_theme();
931
+ // ../kit/src/ci.ts
932
+ init_args();
933
+ init_format();
934
+
815
935
  // ../kit/src/progress.ts
936
+ init_format();
816
937
  import process12 from "process";
817
938
 
818
939
  // ../kit/src/process.ts
940
+ import { readFileSync as readFileSync4 } from "fs";
819
941
  import { constants } from "os";
820
942
  import process11 from "process";
821
943
  var KILL_GRACE_MS = 2000;
822
944
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
945
+ var GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
823
946
  function exitCodeOf(code, signal) {
824
947
  if (code !== null)
825
948
  return code;
@@ -827,6 +950,21 @@ function exitCodeOf(code, signal) {
827
950
  return 128 + signal;
828
951
  return signal === null ? 129 : 128 + constants.signals[signal];
829
952
  }
953
+ function groupsOf(pid) {
954
+ try {
955
+ const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
956
+ const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
957
+ return { group: Number(fields[2]), foreground: Number(fields[5]) };
958
+ } catch {
959
+ return;
960
+ }
961
+ }
962
+ function heardTheTerminal(child) {
963
+ if (child.pid === undefined)
964
+ return false;
965
+ const own = groupsOf("self");
966
+ return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
967
+ }
830
968
  function holdSignals(cleanup) {
831
969
  let received;
832
970
  let child;
@@ -845,7 +983,8 @@ function holdSignals(cleanup) {
845
983
  function onSignal(signal) {
846
984
  received = signal;
847
985
  if (child !== undefined) {
848
- child.kill(signal);
986
+ if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
987
+ child.kill(signal);
849
988
  return;
850
989
  }
851
990
  if (cleanup === undefined)
@@ -858,10 +997,10 @@ function holdSignals(cleanup) {
858
997
  process11.on(signal, onSignal);
859
998
  return held;
860
999
  }
861
- async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
1000
+ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
862
1001
  const chunks = [];
863
1002
  const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
864
- const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
1003
+ 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 } : {} });
865
1004
  const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
866
1005
  const timers = [];
867
1006
  const killGroup = (killing) => {
@@ -901,12 +1040,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
901
1040
  stop();
902
1041
  continue;
903
1042
  }
1043
+ if (state.truncated)
1044
+ continue;
1045
+ let kept = data;
904
1046
  if (state.kept + data.length > maxBytes) {
1047
+ let cut = maxBytes - state.kept;
1048
+ while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
1049
+ cut--;
1050
+ kept = data.subarray(0, cut);
905
1051
  state.truncated = true;
906
- continue;
907
1052
  }
908
- state.kept += data.length;
909
- chunks.push({ stream: name, data });
1053
+ state.kept += kept.length;
1054
+ if (kept.length > 0)
1055
+ chunks.push({ stream: name, data: kept });
910
1056
  }
911
1057
  };
912
1058
  try {
@@ -923,6 +1069,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
923
1069
  const joined = () => Buffer.concat(chunks.map(({ data }) => data));
924
1070
  let output;
925
1071
  let text;
1072
+ let stdout;
926
1073
  return {
927
1074
  code: exitCodeOf(proc.exitCode, proc.signalCode),
928
1075
  chunks,
@@ -933,11 +1080,16 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
933
1080
  },
934
1081
  get text() {
935
1082
  return text ??= (output ??= joined()).toString();
1083
+ },
1084
+ get stdout() {
1085
+ return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
936
1086
  }
937
1087
  };
938
1088
  }
939
1089
 
940
1090
  // ../kit/src/progress.ts
1091
+ init_style();
1092
+ init_theme();
941
1093
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
942
1094
  var FRAME_MS = 200;
943
1095
  var CLEAR_BELOW = "\r\x1B[J";
@@ -954,10 +1106,14 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
954
1106
  }, print: (text) => void stream.write(`${text}
955
1107
  `), stop: () => {
956
1108
  return;
1109
+ }, pause: () => () => {
1110
+ return;
957
1111
  } };
958
1112
  const write = stream.write.bind(stream);
959
1113
  let frame = 0;
960
1114
  let drawn = false;
1115
+ let paused = false;
1116
+ let stopped = false;
961
1117
  const columns = () => {
962
1118
  const now = stream.getWindowSize?.()[0] ?? stream.columns;
963
1119
  return now === undefined || now === 0 ? 80 : now;
@@ -968,6 +1124,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
968
1124
  drawn = false;
969
1125
  };
970
1126
  const draw = () => {
1127
+ if (paused)
1128
+ return;
971
1129
  const width = columns() - 1;
972
1130
  const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
973
1131
  const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
@@ -979,16 +1137,17 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
979
1137
  `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
980
1138
  drawn = true;
981
1139
  };
982
- const timer = setInterval(draw, FRAME_MS);
1140
+ let timer = setInterval(draw, FRAME_MS);
983
1141
  stream.on?.("resize", draw);
984
- const restore = interceptOutput(clear);
985
- const release = swallowInput();
1142
+ let restore = interceptOutput(clear);
1143
+ let release = swallowInput();
986
1144
  const onExit = () => {
987
1145
  clear();
988
1146
  release();
989
1147
  };
990
1148
  const signals = holdSignals(stop);
991
1149
  function stop() {
1150
+ stopped = true;
992
1151
  clearInterval(timer);
993
1152
  stream.off?.("resize", draw);
994
1153
  clear();
@@ -997,6 +1156,29 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
997
1156
  process12.off("exit", onExit);
998
1157
  signals.release();
999
1158
  }
1159
+ function pause() {
1160
+ if (paused || stopped)
1161
+ return () => {
1162
+ return;
1163
+ };
1164
+ paused = true;
1165
+ clearInterval(timer);
1166
+ stream.off?.("resize", draw);
1167
+ clear();
1168
+ restore();
1169
+ release();
1170
+ return () => {
1171
+ if (!paused || stopped)
1172
+ return;
1173
+ paused = false;
1174
+ timer = setInterval(draw, FRAME_MS);
1175
+ timer.unref();
1176
+ stream.on?.("resize", draw);
1177
+ restore = interceptOutput(clear);
1178
+ release = swallowInput();
1179
+ draw();
1180
+ };
1181
+ }
1000
1182
  timer.unref();
1001
1183
  process12.on("exit", onExit);
1002
1184
  return {
@@ -1007,7 +1189,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1007
1189
  `);
1008
1190
  draw();
1009
1191
  },
1010
- stop
1192
+ stop,
1193
+ pause
1011
1194
  };
1012
1195
  }
1013
1196
  function cutToWidth(line, width) {
@@ -1077,10 +1260,56 @@ function interceptOutput(clear) {
1077
1260
  }
1078
1261
  };
1079
1262
  }
1263
+
1264
+ // ../kit/src/ci.ts
1265
+ init_style();
1266
+
1267
+ // ../kit/src/tool.ts
1268
+ init_format();
1080
1269
  // ../kit/src/cli.ts
1081
- import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1270
+ init_args();
1271
+ import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
1082
1272
  import { dirname as dirname3, join as join6 } from "path";
1083
- import process16 from "process";
1273
+ import process17 from "process";
1274
+
1275
+ // ../kit/src/askpass.ts
1276
+ import process13 from "process";
1277
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1278
+ async function askpassClient(argv) {
1279
+ const socketPath = process13.env[SOCKET_VARIABLE];
1280
+ if (socketPath === undefined)
1281
+ return;
1282
+ const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1283
+ const { promise, resolve } = Promise.withResolvers();
1284
+ let received = "";
1285
+ try {
1286
+ await Bun.connect({
1287
+ unix: socketPath,
1288
+ socket: {
1289
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1290
+ `),
1291
+ data: (_, chunk) => {
1292
+ received += chunk.toString();
1293
+ },
1294
+ close: () => resolve(received),
1295
+ error: () => resolve("")
1296
+ }
1297
+ });
1298
+ } catch {
1299
+ return 1;
1300
+ }
1301
+ const reply = await promise;
1302
+ if (reply === "")
1303
+ return 1;
1304
+ const { answer } = JSON.parse(reply);
1305
+ if (request.notice === true)
1306
+ return 0;
1307
+ if (answer === undefined)
1308
+ return 1;
1309
+ process13.stdout.write(`${answer}
1310
+ `);
1311
+ return 0;
1312
+ }
1084
1313
 
1085
1314
  // ../kit/src/completions.ts
1086
1315
  var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
@@ -1143,49 +1372,54 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
1143
1372
  }
1144
1373
 
1145
1374
  // ../kit/src/notify.ts
1146
- import process13 from "process";
1375
+ init_format();
1376
+ init_mode();
1377
+ import process14 from "process";
1147
1378
  var NOTIFY_AFTER_MS = 1e4;
1148
1379
  var CANCELLED = 130;
1149
1380
  function base64(text) {
1150
1381
  return Buffer.from(text).toString("base64");
1151
1382
  }
1152
- function notification(title, body, env = process13.env) {
1153
- const id = `kit${process13.pid}`;
1383
+ function notification(title, body, env = process14.env) {
1384
+ const id = `kit${process14.pid}`;
1154
1385
  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\\`];
1155
1386
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1156
1387
  }
1157
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1388
+ function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
1158
1389
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1159
1390
  return;
1160
1391
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1161
1392
  }
1162
1393
 
1394
+ // ../kit/src/cli.ts
1395
+ init_style();
1396
+ init_text2();
1397
+
1163
1398
  // ../kit/src/usage.ts
1164
1399
  import { appendFileSync, mkdirSync } from "fs";
1165
1400
  import { homedir as homedir4 } from "os";
1166
- import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1167
- import process15 from "process";
1401
+ import { dirname as dirname2, join as join5 } from "path";
1402
+ import process16 from "process";
1168
1403
 
1169
1404
  // ../kit/src/logs.ts
1405
+ init_user_config();
1170
1406
  import { lstatSync, openSync } from "fs";
1171
1407
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
1172
1408
  import { homedir as homedir3, tmpdir } from "os";
1173
1409
  import { join as join4 } from "path";
1174
- import process14 from "process";
1410
+ import process15 from "process";
1175
1411
  var DAY_MS = 24 * 60 * 60 * 1000;
1176
1412
  var CLI_FOLDER = "kaynooo-cli";
1177
1413
  function isPrivateDirectory(path) {
1178
1414
  try {
1179
1415
  const info = lstatSync(path, { throwIfNoEntry: false });
1180
- return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1416
+ return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1181
1417
  } catch {
1182
1418
  return false;
1183
1419
  }
1184
1420
  }
1185
- async function privateLogDirectory(name, env = process14.env) {
1186
- const runtime = env.XDG_RUNTIME_DIR;
1187
- const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1188
- const path = join4(base, name);
1421
+ async function privateLogDirectory(name, env = process15.env) {
1422
+ const path = join4(xdgFolder(env.XDG_RUNTIME_DIR, join4(homedir3(), ".cache")), CLI_FOLDER, name);
1189
1423
  try {
1190
1424
  await mkdir(path, { recursive: true, mode: 448 });
1191
1425
  if (isPrivateDirectory(path))
@@ -1195,6 +1429,7 @@ async function privateLogDirectory(name, env = process14.env) {
1195
1429
  }
1196
1430
 
1197
1431
  // ../kit/src/usage.ts
1432
+ init_user_config();
1198
1433
  var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
1199
1434
  var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
1200
1435
  var LONGEST_NAME = 40;
@@ -1202,14 +1437,13 @@ var usageError;
1202
1437
  function noteUsageError(message) {
1203
1438
  usageError = message;
1204
1439
  }
1205
- function stateHome(env = process15.env) {
1206
- const dir = env.XDG_STATE_HOME;
1207
- return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1440
+ function stateHome(env = process16.env) {
1441
+ return xdgFolder(env.XDG_STATE_HOME, join5(homedir4(), ".local", "state"));
1208
1442
  }
1209
- function usagePath(env = process15.env) {
1443
+ function usagePath(env = process16.env) {
1210
1444
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1211
1445
  }
1212
- function usageRecorded(env = process15.env) {
1446
+ function usageRecorded(env = process16.env) {
1213
1447
  const off = env.KAYNOOO_CLI_NO_USAGE;
1214
1448
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1215
1449
  }
@@ -1218,12 +1452,12 @@ function flagNames(argv) {
1218
1452
  const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
1219
1453
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1220
1454
  }
1221
- function usageEntry(bin, command, argv, code, now = new Date) {
1455
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1222
1456
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1223
1457
  usageError = undefined;
1224
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1458
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
1225
1459
  }
1226
- function recordUsage(entry, env = process15.env) {
1460
+ function recordUsage(entry, env = process16.env) {
1227
1461
  if (!usageRecorded(env))
1228
1462
  return;
1229
1463
  try {
@@ -1245,8 +1479,8 @@ var TOP_OPTIONS = {
1245
1479
  completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1246
1480
  };
1247
1481
  function printError(prefix, message, hint, cause) {
1248
- const colors = paint(process16.stderr);
1249
- const styled = takesControlCodes(process16.stderr);
1482
+ const colors = paint(process17.stderr);
1483
+ const styled = takesControlCodes(process17.stderr);
1250
1484
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1251
1485
  const under = (label, text, tint) => text === undefined ? "" : `
1252
1486
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1348,7 +1582,7 @@ function packageVersion(entry = Bun.main) {
1348
1582
  } catch {}
1349
1583
  for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
1350
1584
  try {
1351
- const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
1585
+ const { version } = JSON.parse(readFileSync5(join6(dir, "package.json"), "utf8"));
1352
1586
  if (typeof version === "string")
1353
1587
  return version;
1354
1588
  } catch {}
@@ -1357,6 +1591,9 @@ function packageVersion(entry = Bun.main) {
1357
1591
  }
1358
1592
  }
1359
1593
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1594
+ const answered = await askpassClient(argv);
1595
+ if (answered !== undefined)
1596
+ return answered;
1360
1597
  if (argv[0] === COMPLETE)
1361
1598
  return printCandidates(leafCandidates(run, argv.slice(1)));
1362
1599
  if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
@@ -1375,27 +1612,48 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1375
1612
  notifyEnd(name, code, performance.now() - started);
1376
1613
  if (usage !== false) {
1377
1614
  try {
1378
- recordUsage(usageEntry(name, undefined, argv, code));
1615
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
1379
1616
  } catch {}
1380
1617
  }
1381
1618
  return code;
1382
1619
  }
1383
- // ../kit/src/folders.ts
1384
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1620
+
1621
+ // ../kit/src/index.ts
1622
+ init_config();
1623
+
1624
+ // ../kit/src/excerpt.ts
1625
+ init_text2();
1626
+
1627
+ // ../kit/src/index.ts
1628
+ init_folders();
1629
+ init_format();
1630
+
1631
+ // ../kit/src/git.ts
1632
+ init_args();
1633
+ // ../kit/src/limit.ts
1634
+ init_args();
1635
+
1636
+ // ../kit/src/index.ts
1637
+ init_mode();
1638
+
1639
+ // ../kit/src/report.ts
1640
+ init_style();
1641
+ init_text2();
1385
1642
  // ../kit/src/secrets.ts
1386
1643
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1644
+ var NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
1387
1645
  // ../kit/src/sessions.ts
1388
1646
  import { homedir as homedir5 } from "os";
1389
1647
  import { join as join7 } from "path";
1390
- import process17 from "process";
1648
+ import process18 from "process";
1391
1649
  var {Glob } = globalThis.Bun;
1392
1650
  var SESSION_FILES = new Glob("*.json");
1393
1651
  var ACCOUNT_DIRS = new Glob("*/sessions");
1394
1652
  async function sessionDirs() {
1395
1653
  const home = homedir5();
1396
1654
  const dirs = new Set([join7(home, ".claude", "sessions")]);
1397
- if (process17.env.CLAUDE_CONFIG_DIR !== undefined)
1398
- dirs.add(join7(process17.env.CLAUDE_CONFIG_DIR, "sessions"));
1655
+ if (process18.env.CLAUDE_CONFIG_DIR !== undefined)
1656
+ dirs.add(join7(process18.env.CLAUDE_CONFIG_DIR, "sessions"));
1399
1657
  try {
1400
1658
  for await (const dir of ACCOUNT_DIRS.scan({ cwd: join7(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1401
1659
  dirs.add(dir);
@@ -1441,7 +1699,7 @@ async function liveSessions() {
1441
1699
  }
1442
1700
  async function currentSession(sessions) {
1443
1701
  const byPid = new Map(sessions.map((session) => [session.pid, session]));
1444
- let pid = process17.ppid;
1702
+ let pid = process18.ppid;
1445
1703
  for (let depth = 0;depth < 32 && pid > 1; depth++) {
1446
1704
  const session = byPid.get(pid);
1447
1705
  if (session !== undefined)
@@ -1453,21 +1711,34 @@ async function currentSession(sessions) {
1453
1711
  }
1454
1712
  return;
1455
1713
  }
1714
+
1715
+ // ../kit/src/index.ts
1716
+ init_style();
1717
+ init_text2();
1718
+ init_theme();
1719
+ init_user_config();
1720
+
1721
+ // ../kit/src/watch.ts
1722
+ init_args();
1723
+ init_input();
1724
+ init_style();
1725
+ // ../kit/src/workspace-root.ts
1726
+ init_user_config();
1456
1727
  // src/slot.ts
1457
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync5, rmSync } from "fs";
1728
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync6, rmSync } from "fs";
1458
1729
  import { availableParallelism } from "os";
1459
1730
  import { join as join8 } from "path";
1460
- import process20 from "process";
1731
+ import process21 from "process";
1461
1732
 
1462
1733
  // src/flock.ts
1463
1734
  import { closeSync, constants as constants2, ftruncateSync, openSync as openSync2, writeSync } from "fs";
1464
- import process19 from "process";
1735
+ import process20 from "process";
1465
1736
  import { dlopen, FFIType } from "bun:ffi";
1466
1737
  var LOCK_EX = 2;
1467
1738
  var LOCK_NB = 4;
1468
1739
  var flock;
1469
1740
  function native() {
1470
- flock ??= dlopen(process19.platform === "darwin" ? "libSystem.B.dylib" : "libc.so.6", { flock: { args: [FFIType.i32, FFIType.i32], returns: FFIType.i32 } }).symbols.flock;
1741
+ flock ??= dlopen(process20.platform === "darwin" ? "libSystem.B.dylib" : "libc.so.6", { flock: { args: [FFIType.i32, FFIType.i32], returns: FFIType.i32 } }).symbols.flock;
1471
1742
  return flock;
1472
1743
  }
1473
1744
  function tryLock(path) {
@@ -1487,10 +1758,9 @@ function writeHeld(held, text) {
1487
1758
  var RUN_USAGE = `slot [options] -- <cmd>...: waits for a free machine-wide slot, then runs the command and exits with its code
1488
1759
  slot ls [--json]: lists who holds a slot or a lock and who waits for one (slot ls --help)
1489
1760
 
1490
- The slots and locks are shared by every session, worktree and shell of this user, so heavy jobs (phpunit, playwright, vue-tsc, eslint) queue instead of overloading the machine.
1491
- A slot or lock is freed the moment its holder ends, SIGKILL included, since the kernel drops it with the process.
1492
- A slotted command that runs slot again does not wait for a second slot, so wrapping both a script and the commands inside it cannot deadlock.
1493
- A first word \`ls\` always means the listing, so run the ls command as \`slot -n 4 -- ls\` or by its path.`;
1761
+ The slots and locks are shared by every session, worktree and shell of this user, so heavy jobs (phpunit, playwright, vue-tsc, eslint) queue instead of overloading the machine; one is freed the moment its holder ends, SIGKILL included.
1762
+ A slotted command that runs slot again does not wait for a second slot, so wrapping a script and the commands inside it cannot deadlock.
1763
+ A first word \`ls\` always means the listing: run the ls command as \`slot -n 4 -- ls\`.`;
1494
1764
  var RUN_EXITS = [[0, "the command did"], ["its own", "the code of a command that failed"], [2, "it timed out waiting for the slot or a usage error"], [127, "the command cannot be started"]];
1495
1765
  var LS_USAGE = `slot ls [options]: lists the slots and locks held, with the session, the command and how long ago it started, then who waits for one
1496
1766
 
@@ -1511,14 +1781,14 @@ function defaultSlots() {
1511
1781
  return Math.max(1, Math.floor(availableParallelism() / 2));
1512
1782
  }
1513
1783
  async function stateDir() {
1514
- const dir = process20.env.SLOT_DIR ?? await privateLogDirectory("slot");
1784
+ const dir = process21.env.SLOT_DIR ?? await privateLogDirectory("slot");
1515
1785
  for (const sub of ["slots", "locks", "waiters"])
1516
1786
  mkdirSync2(join8(dir, sub), { recursive: true, mode: 448 });
1517
1787
  return dir;
1518
1788
  }
1519
1789
  function readHolder(path) {
1520
1790
  try {
1521
- const holder = JSON.parse(readFileSync5(path, "utf8"));
1791
+ const holder = JSON.parse(readFileSync6(path, "utf8"));
1522
1792
  return typeof holder.pid === "number" && typeof holder.command === "string" ? { pid: holder.pid, command: holder.command, cwd: holder.cwd ?? "", since: holder.since ?? 0, ...holder.session === undefined ? {} : { session: holder.session }, ...holder.resource === undefined ? {} : { resource: holder.resource } } : undefined;
1523
1793
  } catch {
1524
1794
  return;
@@ -1553,7 +1823,7 @@ function waitingLine(dir, wanted) {
1553
1823
  }
1554
1824
  async function holderOf(command) {
1555
1825
  const session = await currentSession(await liveSessions());
1556
- return { pid: process20.pid, command: command.join(" "), cwd: process20.cwd(), since: Date.now(), ...session === undefined ? {} : { session: session.name } };
1826
+ return { pid: process21.pid, command: command.join(" "), cwd: process21.cwd(), since: Date.now(), ...session === undefined ? {} : { session: session.name } };
1557
1827
  }
1558
1828
  var waiterCount = 0;
1559
1829
  async function acquire(dir, resources, holder, deadline, timeoutMs) {
@@ -1579,7 +1849,7 @@ async function acquire(dir, resources, holder, deadline, timeoutMs) {
1579
1849
  held.release();
1580
1850
  const resource = busy.kind === "lock" ? `lock ${busy.name}` : "slot";
1581
1851
  if (waiter === undefined) {
1582
- const path = join8(dir, "waiters", `${process20.pid}-${waiterCount++}`);
1852
+ const path = join8(dir, "waiters", `${process21.pid}-${waiterCount++}`);
1583
1853
  const held = tryLock(path);
1584
1854
  if (held !== undefined) {
1585
1855
  writeHeld(held, JSON.stringify({ ...holder, resource }));
@@ -1601,11 +1871,23 @@ async function acquire(dir, resources, holder, deadline, timeoutMs) {
1601
1871
  }
1602
1872
  }
1603
1873
  }
1604
- async function runSlotted(args) {
1605
- const bare = args[0] !== undefined && !args[0].startsWith("-");
1606
- const parsed = parse(bare ? [] : args, RUN_USAGE, RUN_OPTIONS, { rest: true, exits: RUN_EXITS, replaces: "flock wrappers, hand-written heavy.sh queues and parallel runs fighting over one test database", examples: [["slot -- bunx vue-tsc", "wait for a free slot, then type-check"], ["slot --lock booki-test-db -- vendor/bin/phpunit", "one phpunit at a time on the shared test database"], "slot ls"] });
1607
- const { values } = parsed;
1608
- const rest = bare ? args : parsed.rest;
1874
+ function withSeparator(args) {
1875
+ const takesValue = (word) => Object.entries(RUN_OPTIONS).some(([name, option]) => option.type === "string" && (word === `--${name}` || ("short" in option) && word === `-${option.short}`));
1876
+ for (let at = 0;at < args.length; at++) {
1877
+ const word = args[at];
1878
+ if (word === "--")
1879
+ return args;
1880
+ if (!word.startsWith("-"))
1881
+ return [...args.slice(0, at), "--", ...args.slice(at)];
1882
+ if (takesValue(word))
1883
+ at++;
1884
+ }
1885
+ return args;
1886
+ }
1887
+ async function runSlotted(given) {
1888
+ const args = withSeparator(given);
1889
+ const parsed = parse(args, RUN_USAGE, RUN_OPTIONS, { rest: true, exits: RUN_EXITS, replaces: "flock wrappers, hand-written heavy.sh queues and parallel runs fighting over one test database", examples: [["slot -- bunx vue-tsc", "wait for a free slot, then type-check"], ["slot --lock booki-test-db -- vendor/bin/phpunit", "one phpunit at a time on the shared test database"], "slot ls"] });
1890
+ const { values, rest } = parsed;
1609
1891
  if (rest === undefined || rest.length === 0)
1610
1892
  fail(`give the command after --
1611
1893
 
@@ -1620,7 +1902,7 @@ ${RUN_USAGE}`);
1620
1902
  const count = wholeNumber(values.slots, "slots", defaultSlots());
1621
1903
  const timeoutMs = duration(values.timeout, "timeout", Number.POSITIVE_INFINITY);
1622
1904
  const deadline = Date.now() + timeoutMs;
1623
- const holding = new Set((process20.env[HOLDING] ?? "").split(",").filter((token) => token !== ""));
1905
+ const holding = new Set((process21.env[HOLDING] ?? "").split(",").filter((token) => token !== ""));
1624
1906
  const wanted = [...locks.filter((name) => !holding.has(`lock:${name}`)).map((name) => ({ kind: "lock", name, count })), ...values["no-slot"] === true || holding.has("slot") ? [] : [{ kind: "slot", name: "", count }]];
1625
1907
  const signals = holdSignals(() => {
1626
1908
  return;
@@ -1635,7 +1917,7 @@ ${RUN_USAGE}`);
1635
1917
  const tokens = new Set([...holding, ...locks.map((name) => `lock:${name}`), ...wanted.some((resource) => resource.kind === "slot") ? ["slot"] : []]);
1636
1918
  let child;
1637
1919
  try {
1638
- child = Bun.spawn(rest, { stdio: ["inherit", "inherit", "inherit"], env: { ...process20.env, [HOLDING]: [...tokens].join(",") } });
1920
+ child = Bun.spawn(rest, { stdio: ["inherit", "inherit", "inherit"], env: { ...process21.env, [HOLDING]: [...tokens].join(",") } });
1639
1921
  } catch (error) {
1640
1922
  fail(`cannot run ${rest[0]}: ${error instanceof Error ? error.message : String(error)}`, 127);
1641
1923
  }
@@ -1678,11 +1960,11 @@ async function listSlots(args) {
1678
1960
  printJson({ slots: count, busy, entries });
1679
1961
  return 0;
1680
1962
  }
1681
- console.log(paint(process20.stdout).bold(`slots: ${busy} of ${count} busy`));
1963
+ console.log(paint(process21.stdout).bold(`slots: ${busy} of ${count} busy`));
1682
1964
  if (entries.length > 0)
1683
- console.log(table(entries.map((entry) => [badge(entry.state, process20.stdout), entry.resource, entry.session ?? `pid ${entry.pid}`, truncate(entry.command, COMMAND_WIDTH), entry.since === 0 ? "?" : formatAge(entry.since)])));
1965
+ console.log(table(entries.map((entry) => [badge(entry.state, process21.stdout), entry.resource, entry.session ?? `pid ${entry.pid}`, truncate(entry.command, COMMAND_WIDTH), entry.since === 0 ? "?" : formatAge(entry.since)])));
1684
1966
  return 0;
1685
1967
  }
1686
1968
 
1687
1969
  // src/slot-cli.ts
1688
- process21.exitCode = await runMain({ name: "slot", run: async (args) => args[0] === "ls" ? listSlots(args.slice(1)) : runSlotted(args) });
1970
+ process22.exitCode = await runMain({ name: "slot", run: async (args) => args[0] === "ls" ? listSlots(args.slice(1)) : runSlotted(args) });