@kaynooo/cli-wait 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,3 +55,7 @@ check --slot
55
55
  - `slot ls` is the listing even as a first word, `slot -- ls` being read as `slot ls` because Bun drops a leading `--`: write `slot -n 4 -- ls` for the command.
56
56
  - State lives in `$XDG_RUNTIME_DIR/kaynooo-cli/slot` (`~/.cache/kaynooo-cli/slot` without it), only the user can enter it; `$SLOT_DIR` points elsewhere.
57
57
  - Exit codes: the command's, 2 on a timeout or a usage error.
58
+
59
+ ## Config
60
+
61
+ `~/.config/kaynooo-cli/wait.json` (`$XDG_CONFIG_HOME/kaynooo-cli/` when set) takes positive whole numbers: `tail` (20, the lines of a file kept for a timeout excerpt), `around` (5, the lines kept on each side of a failure line) and `portTimeoutMs` (3000, how long one port probe waits).
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env -S bun --no-env-file
1
+ #!/usr/bin/env -S bun --no-env-file --config=/dev/null
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import { existsSync as existsSync5 } from "fs";
5
+ import { existsSync as existsSync6 } from "fs";
6
6
  import process18 from "process";
7
7
  // ../kit/src/args.ts
8
8
  import process9 from "process";
@@ -11,6 +11,24 @@ import { parseArgs } from "util";
11
11
  // ../kit/src/format.ts
12
12
  import process7 from "process";
13
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 = "...") {
19
+ let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
20
+ if (t.length <= e)
21
+ return t;
22
+ let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
23
+ if (o && !Y.test(t[c.length] ?? " "))
24
+ c = c.replace(Nt, "") || c;
25
+ if (o)
26
+ c = c.trimEnd();
27
+ return s ? (c + n).slice(0, l) : c + n;
28
+ }
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;
31
+
14
32
  // ../kit/src/mode.ts
15
33
  import process2 from "process";
16
34
  var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
@@ -32,269 +50,63 @@ function outputMode(stream = process2.stdout, env = process2.env) {
32
50
  // ../kit/src/style.ts
33
51
  import process6 from "process";
34
52
 
35
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
36
- function x(s) {
37
- let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
38
- if (!/^[a-f0-9]+$/.test(r))
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;
55
+ function b(r) {
56
+ let e = r.startsWith("#") ? r.slice(1) : r;
57
+ if (!G2.test(e))
39
58
  return [0, 0, 0];
40
- let t = r.length, n = (c) => Number.parseInt(c, 16);
41
- if (t === 3 || t === 4) {
42
- let c = n(r[0] + r[0]), u = n(r[1] + r[1]), h = n(r[2] + r[2]), g = t === 4 ? n(r[3] + r[3]) : undefined;
43
- return g !== undefined ? [c, u, h, g] : [c, u, h];
44
- }
45
- if (t !== 6 && t !== 8)
46
- throw Error(`Invalid hex color length: ${t}`);
47
- let a = n(r.slice(0, 2)), b = n(r.slice(2, 4)), o = n(r.slice(4, 6)), y = t === 8 ? n(r.slice(6, 8)) : undefined;
48
- if ([a, b, o].some(Number.isNaN) || y !== undefined && Number.isNaN(y))
49
- throw Error(`Invalid hex color value: ${s}`);
50
- return y !== undefined ? [a, b, o, y] : [a, b, o];
51
- }
52
- function A(s) {
53
- let [r, t, n, a] = s;
54
- if (a)
55
- return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
56
- return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
57
- }
58
- function R(s, r, t) {
59
- s = (s % 360 + 360) % 360, t /= 100;
60
- let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
61
- let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
62
- return Math.round(255 * y);
63
- };
64
- return [a(0), a(8), a(4)];
65
- }
66
- function k(s) {
67
- let [r, t, n] = s;
68
- r /= 255, t /= 255, n /= 255;
69
- let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
70
- if (a !== b) {
71
- let u = a - b;
72
- if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
73
- o = (t - n) / u + (t < n ? 6 : 0);
74
- else if (a === t)
75
- o = (n - r) / u + 2;
76
- else
77
- o = (r - t) / u + 4;
78
- o /= 6;
79
- }
80
- return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
81
- }
82
- function H(s, r, t) {
83
- s = (s % 360 + 360) % 360, r /= 100, t /= 100;
84
- let n = (a) => {
85
- let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
86
- return Math.round(255 * o);
87
- };
88
- return [n(5), n(3), n(1)];
89
- }
90
- function f(s) {
91
- let [r, t, n] = s;
92
- r /= 255, t /= 255, n /= 255;
93
- let a = Math.max(r, t, n), b = Math.min(r, t, n), o = a - b, y = 0, c = a === 0 ? 0 : o / a, u = a;
94
- if (o !== 0) {
95
- if (a === r)
96
- y = (t - n) / o + (t < n ? 6 : 0);
97
- else if (a === t)
98
- y = (n - r) / o + 2;
99
- else
100
- y = (r - t) / o + 4;
101
- y /= 6;
102
- }
103
- return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
104
- }
105
- function O(s) {
106
- let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
107
- if (a === 1)
108
- return [0, 0, 0, 100];
109
- let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
110
- return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
111
- }
112
- function v(s, r, t, n) {
113
- return s /= 100, r /= 100, t /= 100, n /= 100, [Math.round(255 * (1 - s) * (1 - n)), Math.round(255 * (1 - r) * (1 - n)), Math.round(255 * (1 - t) * (1 - n))];
114
- }
115
- var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
116
- var p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055;
117
- var i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
118
- function T(s) {
119
- let r = m(s[0] / 255), t = m(s[1] / 255), n = m(s[2] / 255), a = Math.cbrt(0.4122214708 * r + 0.5363325363 * t + 0.0514459929 * n), b = Math.cbrt(0.2119034982 * r + 0.6806995451 * t + 0.1073969566 * n), o = Math.cbrt(0.0883024619 * r + 0.2817188376 * t + 0.6299787005 * n);
120
- return [i(0.2104542553 * a + 0.793617785 * b - 0.0040720468 * o, 4), i(1.9779984951 * a - 2.428592205 * b + 0.4505937099 * o, 4), i(0.0259040371 * a + 0.7827717662 * b - 0.808675766 * o, 4)];
121
- }
122
- function M(s, r, t) {
123
- let n = (s + 0.3963377774 * r + 0.2158037573 * t) ** 3, a = (s - 0.1055613458 * r - 0.0638541728 * t) ** 3, b = (s - 0.0894841775 * r - 1.291485548 * t) ** 3, o = p(4.0767416621 * n - 3.3077115913 * a + 0.2309699292 * b), y = p(-1.2684380046 * n + 2.6097574011 * a - 0.3413193965 * b), c = p(-0.0041960863 * n - 0.7034186147 * a + 1.707614701 * b), u = (h) => Math.min(255, Math.max(0, Math.round(h * 255)));
124
- return [u(o), u(y), u(c)];
125
- }
126
- function d(s) {
127
- let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
128
- return [i(r, 4), i(a, 4), i(b, 2)];
129
- }
130
- function C(s, r, t) {
131
- let n = t * Math.PI / 180;
132
- return M(s, r * Math.cos(n), r * Math.sin(n));
133
- }
134
- function l(s) {
135
- let r = s / 255;
136
- return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
137
- }
138
-
139
- class e {
140
- r;
141
- g;
142
- b;
143
- a;
144
- constructor(s, r, t, n = 1) {
145
- this.r = s, this.g = r, this.b = t, this.a = n;
146
- }
147
- static from(s, r) {
148
- if (s === "hex") {
149
- let [t, n, a, b] = x(r);
150
- return new e(t, n, a, b);
151
- }
152
- if (s === "rgb") {
153
- if (Array.isArray(r)) {
154
- let [o, y, c, u] = r;
155
- return new e(o, y, c, u);
156
- }
157
- let { r: t, g: n, b: a, a: b } = r;
158
- return new e(t, n, a, b);
159
- }
160
- if (s === "hsl") {
161
- let t, n, a, b;
162
- if (Array.isArray(r))
163
- [t, n, a, b] = r;
164
- else
165
- ({ h: t, s: n, l: a, a: b } = r);
166
- let [o, y, c] = R(t, n, a);
167
- return new e(o, y, c, b);
168
- }
169
- if (s === "hsv") {
170
- let t, n, a, b;
171
- if (Array.isArray(r))
172
- [t, n, a, b] = r;
173
- else
174
- ({ h: t, s: n, v: a, a: b } = r);
175
- let [o, y, c] = H(t, n, a);
176
- return new e(o, y, c, b);
177
- }
178
- if (s === "cmyk") {
179
- let t, n, a, b, o;
180
- if (Array.isArray(r))
181
- [t, n, a, b, o] = r;
182
- else
183
- ({ c: t, m: n, y: a, k: b, a: o } = r);
184
- let [y, c, u] = v(t, n, a, b);
185
- return new e(y, c, u, o);
186
- }
187
- if (s === "oklch") {
188
- let t, n, a, b;
189
- if (Array.isArray(r))
190
- [t, n, a, b] = r;
191
- else
192
- ({ l: t, c: n, h: a, a: b } = r);
193
- let [o, y, c] = C(t, n, a);
194
- return new e(o, y, c, b);
195
- }
196
- if (s === "oklab") {
197
- let t, n, a, b;
198
- if (Array.isArray(r))
199
- [t, n, a, b] = r;
200
- else
201
- ({ l: t, a: n, b: a, alpha: b } = r);
202
- let [o, y, c] = M(t, n, a);
203
- return new e(o, y, c, b);
204
- }
205
- throw Error("Invalid input");
206
- }
207
- to(s) {
208
- switch (s) {
209
- case "rgb":
210
- return [this.r, this.g, this.b];
211
- case "rgba":
212
- return [this.r, this.g, this.b, this.a];
213
- case "hex":
214
- return A([this.r, this.g, this.b]);
215
- case "hexa":
216
- return A([this.r, this.g, this.b, this.a]);
217
- case "hsl":
218
- return k([this.r, this.g, this.b]);
219
- case "hsla":
220
- return [...k([this.r, this.g, this.b]), this.a];
221
- case "hsv":
222
- return f([this.r, this.g, this.b]);
223
- case "hsva":
224
- return [...f([this.r, this.g, this.b]), this.a];
225
- case "cmyk":
226
- return O([this.r, this.g, this.b]);
227
- case "cmyka":
228
- return [...O([this.r, this.g, this.b]), this.a];
229
- case "oklch":
230
- return d([this.r, this.g, this.b]);
231
- case "oklcha":
232
- return [...d([this.r, this.g, this.b]), this.a];
233
- case "oklab":
234
- return T([this.r, this.g, this.b]);
235
- case "oklaba":
236
- return [...T([this.r, this.g, this.b]), this.a];
237
- default:
238
- return [this.r, this.g, this.b];
239
- }
240
- }
241
- getLuminance() {
242
- let s = l(this.r), r = l(this.g), t = l(this.b);
243
- return 0.2126 * s + 0.7152 * r + 0.0722 * t;
244
- }
245
- contrastRatio(s) {
246
- let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
247
- return (n + 0.05) / (a + 0.05);
248
- }
249
- bestContrastForeground() {
250
- let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
251
- return t >= n ? s : r;
252
- }
253
- }
254
-
255
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
256
- var r = 39;
257
- var o = 49;
258
- var f2 = "\x1B[";
259
- var C2 = { 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, r], red: [31, r], green: [32, r], yellow: [33, r], blue: [34, r], magenta: [35, r], cyan: [36, r], white: [37, r], gray: [90, r], grey: [90, r], blackBright: [90, r], redBright: [91, r], greenBright: [92, r], yellowBright: [93, r], blueBright: [94, r], magentaBright: [95, r], cyanBright: [96, r], whiteBright: [97, r], bgBlack: [40, o], bgRed: [41, o], bgGreen: [42, o], bgYellow: [43, o], bgBlue: [44, o], bgMagenta: [45, o], bgCyan: [46, o], bgWhite: [47, o], bgBlackBright: [100, o], bgRedBright: [101, o], bgGreenBright: [102, o], bgYellowBright: [103, o], bgBlueBright: [104, o], bgMagentaBright: [105, o], bgCyanBright: [106, o], bgWhiteBright: [107, o], rgb: (i, n, a, l = "fg") => [`${l === "fg" ? 38 : 48};2;${i};${n};${a}`, l === "fg" ? r : o], hex: (i, n = "fg") => {
260
- let [a, l, s] = e.from("hex", i).to("rgb");
261
- return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
262
- }, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
263
- var b = new Set(["", "1", "2", "3", "true"]);
264
- function h(i, n = globalThis.process?.env ?? {}) {
265
- if (n.FORCE_COLOR !== undefined)
266
- return b.has(n.FORCE_COLOR);
267
- if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
59
+ if (e.length === 3 || e.length === 4)
60
+ return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
61
+ if (e.length !== 6 && e.length !== 8)
62
+ throw Error(`Invalid hex color length: ${e.length}`);
63
+ return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
64
+ }
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
+ function C(r, e = globalThis.process?.env ?? {}) {
71
+ if (e.FORCE_COLOR !== undefined)
72
+ return h.has(e.FORCE_COLOR);
73
+ if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
268
74
  return false;
269
- return i?.isTTY === true;
270
- }
271
- function d2(i, n, a) {
272
- if (!h(a.stream ?? globalThis.process?.stdout, a.env))
273
- return n;
274
- let l = "", s = "";
275
- for (let g = 0, y = i.length;g < y; g++) {
276
- let [c, p] = i[g];
277
- l += `${f2}${c}m`, s = `${f2}${p}m${s}`;
278
- }
279
- return l + n + s;
280
- }
281
- function u(i, n = []) {
282
- return new Proxy((l) => d2(n, l, i), { get(l, s) {
283
- let g = C2[s];
284
- if (Array.isArray(g))
285
- return u(i, [...n, g]);
286
- if (typeof g === "function")
287
- return (...y) => u(i, [...n, g(...y)]);
288
- throw Error(`Unknown style: ${String(s)}`);
75
+ return r?.isTTY === true;
76
+ }
77
+ function f(r, e = []) {
78
+ let l = "", n = "";
79
+ for (let t = 0, i = e.length;t < i; t++)
80
+ l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
81
+ let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
82
+ return new Proxy(c, { get(t, i) {
83
+ let a = B2[i];
84
+ if (Array.isArray(a)) {
85
+ let s = g.get(i);
86
+ if (s === undefined)
87
+ s = f(r, [...e, a]), g.set(i, s);
88
+ return s;
89
+ }
90
+ if (typeof a === "function")
91
+ return (...s) => {
92
+ let y = `${i}:${s.join(",")}`, u = g.get(y);
93
+ if (u === undefined) {
94
+ if (g.size >= 64)
95
+ g.clear();
96
+ u = f(r, [...e, a(...s)]), g.set(y, u);
97
+ }
98
+ return u;
99
+ };
100
+ throw Error(`Unknown style: ${String(i)}`);
289
101
  } });
290
102
  }
291
- function le(i = {}) {
292
- return u(i);
103
+ function Fe(r = {}) {
104
+ return f(r);
293
105
  }
294
- var t = le();
106
+ var o = Fe();
295
107
 
296
108
  // ../kit/src/theme.ts
297
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
109
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
298
110
  import { homedir as homedir2 } from "os";
299
111
  import { join as join3, resolve as resolve2 } from "path";
300
112
  import process5 from "process";
@@ -315,6 +127,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
315
127
  }
316
128
 
317
129
  // ../kit/src/user-config.ts
130
+ import { existsSync as existsSync2, readFileSync } from "fs";
318
131
  import { homedir } from "os";
319
132
  import { join as join2 } from "path";
320
133
  import process4 from "process";
@@ -325,21 +138,45 @@ function configBase(where = {}) {
325
138
  function userConfigPath(bin, where = {}) {
326
139
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
327
140
  }
141
+ function userConfigReadPath(bin, legacy = [], where = {}) {
142
+ const current = userConfigPath(bin, where);
143
+ if (existsSync2(current))
144
+ return current;
145
+ const base = configBase(where);
146
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
147
+ }
148
+ function readUserConfig(bin, where = {}, legacy = []) {
149
+ const path = userConfigReadPath(bin, legacy, where);
150
+ if (!existsSync2(path))
151
+ return {};
152
+ try {
153
+ const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
154
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
155
+ } catch {
156
+ return {};
157
+ }
158
+ }
159
+ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
160
+ const value = readUserConfig(bin, where, legacy)[key];
161
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
162
+ }
328
163
 
329
164
  // ../kit/src/theme.ts
165
+ var ENDS = new Map;
330
166
  var DEFAULT = {
331
- colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
332
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
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" },
333
169
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
334
- bins: {}
170
+ bins: {},
171
+ gradient: ["#c084fc", "#67e8f9"]
335
172
  };
336
- var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
337
- var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
338
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
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: "|" };
339
176
  var PRESETS = {
340
177
  default: {},
341
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
342
- mono: { colors: MONO, accents: ["bold"] },
178
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
179
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
343
180
  ascii: { glyphs: ASCII }
344
181
  };
345
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"]);
@@ -389,7 +226,7 @@ function readThemeFile(path, warn) {
389
226
  warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
390
227
  return;
391
228
  }
392
- const parsed = JSON.parse(readFileSync(path, "utf8"));
229
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
393
230
  if (isRecord(parsed))
394
231
  return parsed;
395
232
  warn(`${path} is not a JSON object, theme ignored`);
@@ -410,6 +247,8 @@ function applyPreset(theme, name, warn, where) {
410
247
  Object.assign(theme.glyphs, preset.glyphs);
411
248
  if (preset.accents !== undefined)
412
249
  theme.accents = [...preset.accents];
250
+ if (Object.hasOwn(preset, "gradient"))
251
+ theme.gradient = preset.gradient;
413
252
  return name;
414
253
  }
415
254
  function applyFile(theme, file, where, warn) {
@@ -437,6 +276,12 @@ function applyFile(theme, file, where, warn) {
437
276
  theme.accents = [...file.accents];
438
277
  else if (file.accents !== undefined)
439
278
  warn(`${where}: accents must be a non-empty list of colours`);
279
+ if (file.gradient === null)
280
+ theme.gradient = undefined;
281
+ else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
282
+ theme.gradient = [file.gradient[0], file.gradient[1]];
283
+ else if (file.gradient !== undefined)
284
+ warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
440
285
  if (isRecord(file.bins)) {
441
286
  for (const [bin, value] of Object.entries(file.bins)) {
442
287
  if (isColorSpec(value))
@@ -447,7 +292,7 @@ function applyFile(theme, file, where, warn) {
447
292
  }
448
293
  }
449
294
  function endsWalk(home) {
450
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
295
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
451
296
  }
452
297
  var warned = new Set;
453
298
  function warnOnce(message) {
@@ -460,7 +305,7 @@ function isPath(chosen) {
460
305
  return chosen.includes("/") || chosen.endsWith(".json");
461
306
  }
462
307
  function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
463
- const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
308
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
464
309
  const sources = [];
465
310
  const chosen = env.KIT_THEME ?? "";
466
311
  const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
@@ -498,11 +343,24 @@ function activeTheme() {
498
343
  }
499
344
 
500
345
  // ../kit/src/style.ts
346
+ var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
501
347
  function takesControlCodes(stream, env = process6.env) {
502
348
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
503
349
  }
504
350
  function paint(stream, env = process6.env) {
505
- return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
351
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
352
+ }
353
+ function marked(mark, text, stream, detail, env = process6.env) {
354
+ const colors = paint(stream, env);
355
+ let head = MARK_WORDS[mark];
356
+ if (takesControlCodes(stream, env)) {
357
+ const { theme } = activeTheme();
358
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
359
+ }
360
+ return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
361
+ }
362
+ function problem(text, detail) {
363
+ console.error(marked("problem", text, process6.stderr, detail));
506
364
  }
507
365
  var STATUS_WORDS = {
508
366
  passed: ["passed", "success", "succeeded", "ok"],
@@ -556,7 +414,7 @@ function formatAge(date, now = Date.now()) {
556
414
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
557
415
  }
558
416
  function truncate(text, width) {
559
- return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
417
+ return ko(text, width, { suffix: "\u2026", includeSuffix: true });
560
418
  }
561
419
  var LINE_BREAKS = /\s*\n\s*/g;
562
420
  var ESCAPE = String.fromCharCode(27);
@@ -1052,8 +910,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
1052
910
  // ../kit/src/progress.ts
1053
911
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
1054
912
  var FRAME_MS = 200;
1055
- var CLEAR_LINE = "\r\x1B[2K";
1056
- var LINE_UP = "\x1B[1A\x1B[2K";
913
+ var CLEAR_BELOW = "\r\x1B[J";
1057
914
  var ESC = String.fromCharCode(27);
1058
915
  var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
1059
916
  var RESET_STYLE = `${ESC}[0m`;
@@ -1070,13 +927,15 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
1070
927
  } };
1071
928
  const write = stream.write.bind(stream);
1072
929
  let frame = 0;
1073
- let drawn = [];
1074
- const columns = () => stream.columns === undefined || stream.columns === 0 ? 80 : stream.columns;
1075
- const rowsDrawn = () => drawn.reduce((sum, width) => sum + Math.max(1, Math.ceil(width / columns())), 0);
930
+ let drawn = false;
931
+ const columns = () => {
932
+ const now = stream.getWindowSize?.()[0] ?? stream.columns;
933
+ return now === undefined || now === 0 ? 80 : now;
934
+ };
1076
935
  const clear = () => {
1077
- if (drawn.length > 0)
1078
- write(`${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}`);
1079
- drawn = [];
936
+ if (drawn)
937
+ write(CLEAR_BELOW);
938
+ drawn = false;
1080
939
  };
1081
940
  const draw = () => {
1082
941
  const width = columns() - 1;
@@ -1086,9 +945,9 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
1086
945
  clear();
1087
946
  return;
1088
947
  }
1089
- write(`${drawn.length > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}` : CLEAR_LINE}${lines.join(`
1090
- `)}`);
1091
- drawn = lines.map((line) => Bun.stringWidth(line));
948
+ write(`${CLEAR_BELOW}${lines.join(`
949
+ `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
950
+ drawn = true;
1092
951
  };
1093
952
  const timer = setInterval(draw, FRAME_MS);
1094
953
  stream.on?.("resize", draw);
@@ -1189,7 +1048,7 @@ function interceptOutput(clear) {
1189
1048
  };
1190
1049
  }
1191
1050
  // ../kit/src/cli.ts
1192
- import { readFileSync as readFileSync2, realpathSync } from "fs";
1051
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
1193
1052
  import { dirname as dirname3, join as join6 } from "path";
1194
1053
  import process14 from "process";
1195
1054
 
@@ -1360,7 +1219,7 @@ async function printCandidates(found) {
1360
1219
  function packageVersion(entry = Bun.main) {
1361
1220
  for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1362
1221
  try {
1363
- const { version } = JSON.parse(readFileSync2(join6(dir, "package.json"), "utf8"));
1222
+ const { version } = JSON.parse(readFileSync3(join6(dir, "package.json"), "utf8"));
1364
1223
  if (typeof version === "string")
1365
1224
  return version;
1366
1225
  } catch {}
@@ -1462,13 +1321,13 @@ async function currentSession(sessions) {
1462
1321
  return;
1463
1322
  }
1464
1323
  // src/conditions.ts
1465
- import { existsSync as existsSync3, statSync as statSync2 } from "fs";
1466
- var TAIL = 20;
1467
- var AROUND = 5;
1324
+ import { existsSync as existsSync4, statSync as statSync2 } from "fs";
1325
+ var TAIL = configuredNumber("wait", "tail", 20);
1326
+ var AROUND = configuredNumber("wait", "around", 5);
1468
1327
  var CARRIAGE_RETURN = /\r$/;
1469
1328
  var SLICE_BYTES = 1024 * 1024;
1470
1329
  var MAX_LINE = 1e4;
1471
- var PORT_TIMEOUT_MS = 3000;
1330
+ var PORT_TIMEOUT_MS = configuredNumber("wait", "portTimeoutMs", 3000);
1472
1331
 
1473
1332
  class FileWatch {
1474
1333
  path;
@@ -1494,7 +1353,7 @@ class FileWatch {
1494
1353
  return this.failure !== undefined;
1495
1354
  }
1496
1355
  get exists() {
1497
- return existsSync3(this.path);
1356
+ return existsSync4(this.path);
1498
1357
  }
1499
1358
  async poll() {
1500
1359
  const events = [];
@@ -1528,7 +1387,7 @@ class FileWatch {
1528
1387
  return this.recent;
1529
1388
  }
1530
1389
  async nextLines() {
1531
- if (!existsSync3(this.path))
1390
+ if (!existsSync4(this.path))
1532
1391
  return;
1533
1392
  const { size, dev, ino } = statSync2(this.path);
1534
1393
  const replaced = this.identity !== undefined && (this.identity.dev !== dev || this.identity.ino !== ino);
@@ -1586,7 +1445,7 @@ async function urlCheck(url, timeout) {
1586
1445
  }
1587
1446
 
1588
1447
  // src/task.ts
1589
- import { existsSync as existsSync4, lstatSync as lstatSync2, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
1448
+ import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync4, statSync as statSync3 } from "fs";
1590
1449
  import { join as join8 } from "path";
1591
1450
  import process17 from "process";
1592
1451
  var EXITED = /(?:^|\n)\[exited with code (-?\d+)\]\n*$/;
@@ -1604,21 +1463,21 @@ function taskFile(task, env = process17.env) {
1604
1463
  if (!TASK_ID.test(task))
1605
1464
  return;
1606
1465
  const root = tasksRoot(env);
1607
- const found = existsSync4(root) ? [...new Bun.Glob(`*/*/tasks/${task}.output`).scanSync({ cwd: root, onlyFiles: false })] : [];
1466
+ const found = existsSync5(root) ? [...new Bun.Glob(`*/*/tasks/${task}.output`).scanSync({ cwd: root, onlyFiles: false })] : [];
1608
1467
  return found.length === 0 ? undefined : join8(root, found[0] ?? "");
1609
1468
  }
1610
1469
  function isTranscript(path) {
1611
- return existsSync4(path) && lstatSync2(path).isSymbolicLink() && path.endsWith(".output");
1470
+ return existsSync5(path) && lstatSync2(path).isSymbolicLink() && path.endsWith(".output");
1612
1471
  }
1613
1472
  async function exitCode(path) {
1614
- if (!existsSync4(path))
1473
+ if (!existsSync5(path))
1615
1474
  return;
1616
1475
  const size = statSync3(path).size;
1617
1476
  const found = EXITED.exec(await Bun.file(path).slice(Math.max(0, size - TAIL_BYTES), size).text());
1618
1477
  return found === null ? undefined : Number(found[1]);
1619
1478
  }
1620
1479
  async function taskEnd(path, lines) {
1621
- if (!existsSync4(path))
1480
+ if (!existsSync5(path))
1622
1481
  return { failures: [], tail: [] };
1623
1482
  const text = (await Bun.file(path).text()).replace(EXITED, "");
1624
1483
  const all = text.split(`
@@ -1639,7 +1498,7 @@ function pidAlive(pid) {
1639
1498
  }
1640
1499
  function isZombie(pid) {
1641
1500
  try {
1642
- const stat = readFileSync3(`/proc/${pid}/stat`, "utf8");
1501
+ const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
1643
1502
  return stat.slice(stat.lastIndexOf(")") + 2, stat.lastIndexOf(")") + 3) === "Z";
1644
1503
  } catch {
1645
1504
  return false;
@@ -1715,7 +1574,7 @@ async function waitTask(args) {
1715
1574
  const path = taskFile(task);
1716
1575
  if (path === undefined)
1717
1576
  fail(`no background task ${task}: give the id a background Bash call returned, or the path of its .output file`);
1718
- if (!existsSync5(path))
1577
+ if (!existsSync6(path))
1719
1578
  fail(`no output file ${path}: ${task} is no background task of this machine`);
1720
1579
  if (isTranscript(path))
1721
1580
  fail(`${task} is a subagent, whose end its notification reports: waitfor task waits on a background Bash task`);
@@ -1814,7 +1673,7 @@ ${USAGE}`);
1814
1673
  matched = { number: event.line.number, text: event.line.text };
1815
1674
  continue;
1816
1675
  }
1817
- console.error(`waitfor: ${watch.path}:${event.line.number} matched --fail after ${formatDuration(Date.now() - started)}
1676
+ problem(`waitfor: ${watch.path}:${event.line.number} matched --fail after ${formatDuration(Date.now() - started)}
1818
1677
  ${numbered(event.excerpt, event.line)}`);
1819
1678
  if (json)
1820
1679
  printJson({ met: false, ms: Date.now() - started, line: { number: event.line.number, text: event.line.text } });
package/dist/slot-cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env -S bun --no-env-file
1
+ #!/usr/bin/env -S bun --no-env-file --config=/dev/null
2
2
  // @bun
3
3
 
4
4
  // src/slot-cli.ts
@@ -10,6 +10,24 @@ import { parseArgs } from "util";
10
10
  // ../kit/src/format.ts
11
11
  import process7 from "process";
12
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 = "...") {
18
+ let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
19
+ if (t.length <= e)
20
+ return t;
21
+ let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
22
+ if (o && !Y.test(t[c.length] ?? " "))
23
+ c = c.replace(Nt, "") || c;
24
+ if (o)
25
+ c = c.trimEnd();
26
+ return s ? (c + n).slice(0, l) : c + n;
27
+ }
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;
30
+
13
31
  // ../kit/src/mode.ts
14
32
  import process2 from "process";
15
33
  var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
@@ -31,269 +49,63 @@ function outputMode(stream = process2.stdout, env = process2.env) {
31
49
  // ../kit/src/style.ts
32
50
  import process6 from "process";
33
51
 
34
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
35
- function x(s) {
36
- let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
37
- if (!/^[a-f0-9]+$/.test(r))
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;
54
+ function b(r) {
55
+ let e = r.startsWith("#") ? r.slice(1) : r;
56
+ if (!G2.test(e))
38
57
  return [0, 0, 0];
39
- let t = r.length, n = (c) => Number.parseInt(c, 16);
40
- if (t === 3 || t === 4) {
41
- let c = n(r[0] + r[0]), u = n(r[1] + r[1]), h = n(r[2] + r[2]), g = t === 4 ? n(r[3] + r[3]) : undefined;
42
- return g !== undefined ? [c, u, h, g] : [c, u, h];
43
- }
44
- if (t !== 6 && t !== 8)
45
- throw Error(`Invalid hex color length: ${t}`);
46
- let a = n(r.slice(0, 2)), b = n(r.slice(2, 4)), o = n(r.slice(4, 6)), y = t === 8 ? n(r.slice(6, 8)) : undefined;
47
- if ([a, b, o].some(Number.isNaN) || y !== undefined && Number.isNaN(y))
48
- throw Error(`Invalid hex color value: ${s}`);
49
- return y !== undefined ? [a, b, o, y] : [a, b, o];
50
- }
51
- function A(s) {
52
- let [r, t, n, a] = s;
53
- if (a)
54
- return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
55
- return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
56
- }
57
- function R(s, r, t) {
58
- s = (s % 360 + 360) % 360, t /= 100;
59
- let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
60
- let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
61
- return Math.round(255 * y);
62
- };
63
- return [a(0), a(8), a(4)];
64
- }
65
- function k(s) {
66
- let [r, t, n] = s;
67
- r /= 255, t /= 255, n /= 255;
68
- let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
69
- if (a !== b) {
70
- let u = a - b;
71
- if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
72
- o = (t - n) / u + (t < n ? 6 : 0);
73
- else if (a === t)
74
- o = (n - r) / u + 2;
75
- else
76
- o = (r - t) / u + 4;
77
- o /= 6;
78
- }
79
- return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
80
- }
81
- function H(s, r, t) {
82
- s = (s % 360 + 360) % 360, r /= 100, t /= 100;
83
- let n = (a) => {
84
- let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
85
- return Math.round(255 * o);
86
- };
87
- return [n(5), n(3), n(1)];
88
- }
89
- function f(s) {
90
- let [r, t, n] = s;
91
- r /= 255, t /= 255, n /= 255;
92
- let a = Math.max(r, t, n), b = Math.min(r, t, n), o = a - b, y = 0, c = a === 0 ? 0 : o / a, u = a;
93
- if (o !== 0) {
94
- if (a === r)
95
- y = (t - n) / o + (t < n ? 6 : 0);
96
- else if (a === t)
97
- y = (n - r) / o + 2;
98
- else
99
- y = (r - t) / o + 4;
100
- y /= 6;
101
- }
102
- return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
103
- }
104
- function O(s) {
105
- let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
106
- if (a === 1)
107
- return [0, 0, 0, 100];
108
- let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
109
- return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
110
- }
111
- function v(s, r, t, n) {
112
- return s /= 100, r /= 100, t /= 100, n /= 100, [Math.round(255 * (1 - s) * (1 - n)), Math.round(255 * (1 - r) * (1 - n)), Math.round(255 * (1 - t) * (1 - n))];
113
- }
114
- var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
115
- var p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055;
116
- var i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
117
- function T(s) {
118
- let r = m(s[0] / 255), t = m(s[1] / 255), n = m(s[2] / 255), a = Math.cbrt(0.4122214708 * r + 0.5363325363 * t + 0.0514459929 * n), b = Math.cbrt(0.2119034982 * r + 0.6806995451 * t + 0.1073969566 * n), o = Math.cbrt(0.0883024619 * r + 0.2817188376 * t + 0.6299787005 * n);
119
- return [i(0.2104542553 * a + 0.793617785 * b - 0.0040720468 * o, 4), i(1.9779984951 * a - 2.428592205 * b + 0.4505937099 * o, 4), i(0.0259040371 * a + 0.7827717662 * b - 0.808675766 * o, 4)];
120
- }
121
- function M(s, r, t) {
122
- let n = (s + 0.3963377774 * r + 0.2158037573 * t) ** 3, a = (s - 0.1055613458 * r - 0.0638541728 * t) ** 3, b = (s - 0.0894841775 * r - 1.291485548 * t) ** 3, o = p(4.0767416621 * n - 3.3077115913 * a + 0.2309699292 * b), y = p(-1.2684380046 * n + 2.6097574011 * a - 0.3413193965 * b), c = p(-0.0041960863 * n - 0.7034186147 * a + 1.707614701 * b), u = (h) => Math.min(255, Math.max(0, Math.round(h * 255)));
123
- return [u(o), u(y), u(c)];
124
- }
125
- function d(s) {
126
- let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
127
- return [i(r, 4), i(a, 4), i(b, 2)];
128
- }
129
- function C(s, r, t) {
130
- let n = t * Math.PI / 180;
131
- return M(s, r * Math.cos(n), r * Math.sin(n));
132
- }
133
- function l(s) {
134
- let r = s / 255;
135
- return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
136
- }
137
-
138
- class e {
139
- r;
140
- g;
141
- b;
142
- a;
143
- constructor(s, r, t, n = 1) {
144
- this.r = s, this.g = r, this.b = t, this.a = n;
145
- }
146
- static from(s, r) {
147
- if (s === "hex") {
148
- let [t, n, a, b] = x(r);
149
- return new e(t, n, a, b);
150
- }
151
- if (s === "rgb") {
152
- if (Array.isArray(r)) {
153
- let [o, y, c, u] = r;
154
- return new e(o, y, c, u);
155
- }
156
- let { r: t, g: n, b: a, a: b } = r;
157
- return new e(t, n, a, b);
158
- }
159
- if (s === "hsl") {
160
- let t, n, a, b;
161
- if (Array.isArray(r))
162
- [t, n, a, b] = r;
163
- else
164
- ({ h: t, s: n, l: a, a: b } = r);
165
- let [o, y, c] = R(t, n, a);
166
- return new e(o, y, c, b);
167
- }
168
- if (s === "hsv") {
169
- let t, n, a, b;
170
- if (Array.isArray(r))
171
- [t, n, a, b] = r;
172
- else
173
- ({ h: t, s: n, v: a, a: b } = r);
174
- let [o, y, c] = H(t, n, a);
175
- return new e(o, y, c, b);
176
- }
177
- if (s === "cmyk") {
178
- let t, n, a, b, o;
179
- if (Array.isArray(r))
180
- [t, n, a, b, o] = r;
181
- else
182
- ({ c: t, m: n, y: a, k: b, a: o } = r);
183
- let [y, c, u] = v(t, n, a, b);
184
- return new e(y, c, u, o);
185
- }
186
- if (s === "oklch") {
187
- let t, n, a, b;
188
- if (Array.isArray(r))
189
- [t, n, a, b] = r;
190
- else
191
- ({ l: t, c: n, h: a, a: b } = r);
192
- let [o, y, c] = C(t, n, a);
193
- return new e(o, y, c, b);
194
- }
195
- if (s === "oklab") {
196
- let t, n, a, b;
197
- if (Array.isArray(r))
198
- [t, n, a, b] = r;
199
- else
200
- ({ l: t, a: n, b: a, alpha: b } = r);
201
- let [o, y, c] = M(t, n, a);
202
- return new e(o, y, c, b);
203
- }
204
- throw Error("Invalid input");
205
- }
206
- to(s) {
207
- switch (s) {
208
- case "rgb":
209
- return [this.r, this.g, this.b];
210
- case "rgba":
211
- return [this.r, this.g, this.b, this.a];
212
- case "hex":
213
- return A([this.r, this.g, this.b]);
214
- case "hexa":
215
- return A([this.r, this.g, this.b, this.a]);
216
- case "hsl":
217
- return k([this.r, this.g, this.b]);
218
- case "hsla":
219
- return [...k([this.r, this.g, this.b]), this.a];
220
- case "hsv":
221
- return f([this.r, this.g, this.b]);
222
- case "hsva":
223
- return [...f([this.r, this.g, this.b]), this.a];
224
- case "cmyk":
225
- return O([this.r, this.g, this.b]);
226
- case "cmyka":
227
- return [...O([this.r, this.g, this.b]), this.a];
228
- case "oklch":
229
- return d([this.r, this.g, this.b]);
230
- case "oklcha":
231
- return [...d([this.r, this.g, this.b]), this.a];
232
- case "oklab":
233
- return T([this.r, this.g, this.b]);
234
- case "oklaba":
235
- return [...T([this.r, this.g, this.b]), this.a];
236
- default:
237
- return [this.r, this.g, this.b];
238
- }
239
- }
240
- getLuminance() {
241
- let s = l(this.r), r = l(this.g), t = l(this.b);
242
- return 0.2126 * s + 0.7152 * r + 0.0722 * t;
243
- }
244
- contrastRatio(s) {
245
- let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
246
- return (n + 0.05) / (a + 0.05);
247
- }
248
- bestContrastForeground() {
249
- let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
250
- return t >= n ? s : r;
251
- }
252
- }
253
-
254
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
255
- var r = 39;
256
- var o = 49;
257
- var f2 = "\x1B[";
258
- var C2 = { 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, r], red: [31, r], green: [32, r], yellow: [33, r], blue: [34, r], magenta: [35, r], cyan: [36, r], white: [37, r], gray: [90, r], grey: [90, r], blackBright: [90, r], redBright: [91, r], greenBright: [92, r], yellowBright: [93, r], blueBright: [94, r], magentaBright: [95, r], cyanBright: [96, r], whiteBright: [97, r], bgBlack: [40, o], bgRed: [41, o], bgGreen: [42, o], bgYellow: [43, o], bgBlue: [44, o], bgMagenta: [45, o], bgCyan: [46, o], bgWhite: [47, o], bgBlackBright: [100, o], bgRedBright: [101, o], bgGreenBright: [102, o], bgYellowBright: [103, o], bgBlueBright: [104, o], bgMagentaBright: [105, o], bgCyanBright: [106, o], bgWhiteBright: [107, o], rgb: (i, n, a, l = "fg") => [`${l === "fg" ? 38 : 48};2;${i};${n};${a}`, l === "fg" ? r : o], hex: (i, n = "fg") => {
259
- let [a, l, s] = e.from("hex", i).to("rgb");
260
- return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
261
- }, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
262
- var b = new Set(["", "1", "2", "3", "true"]);
263
- function h(i, n = globalThis.process?.env ?? {}) {
264
- if (n.FORCE_COLOR !== undefined)
265
- return b.has(n.FORCE_COLOR);
266
- if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
58
+ if (e.length === 3 || e.length === 4)
59
+ return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
60
+ if (e.length !== 6 && e.length !== 8)
61
+ throw Error(`Invalid hex color length: ${e.length}`);
62
+ return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
63
+ }
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
+ function C(r, e = globalThis.process?.env ?? {}) {
70
+ if (e.FORCE_COLOR !== undefined)
71
+ return h.has(e.FORCE_COLOR);
72
+ if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
267
73
  return false;
268
- return i?.isTTY === true;
269
- }
270
- function d2(i, n, a) {
271
- if (!h(a.stream ?? globalThis.process?.stdout, a.env))
272
- return n;
273
- let l = "", s = "";
274
- for (let g = 0, y = i.length;g < y; g++) {
275
- let [c, p] = i[g];
276
- l += `${f2}${c}m`, s = `${f2}${p}m${s}`;
277
- }
278
- return l + n + s;
279
- }
280
- function u(i, n = []) {
281
- return new Proxy((l) => d2(n, l, i), { get(l, s) {
282
- let g = C2[s];
283
- if (Array.isArray(g))
284
- return u(i, [...n, g]);
285
- if (typeof g === "function")
286
- return (...y) => u(i, [...n, g(...y)]);
287
- throw Error(`Unknown style: ${String(s)}`);
74
+ return r?.isTTY === true;
75
+ }
76
+ function f(r, e = []) {
77
+ let l = "", n = "";
78
+ for (let t = 0, i = e.length;t < i; t++)
79
+ l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
80
+ let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
81
+ return new Proxy(c, { get(t, i) {
82
+ let a = B2[i];
83
+ if (Array.isArray(a)) {
84
+ let s = g.get(i);
85
+ if (s === undefined)
86
+ s = f(r, [...e, a]), g.set(i, s);
87
+ return s;
88
+ }
89
+ if (typeof a === "function")
90
+ return (...s) => {
91
+ let y = `${i}:${s.join(",")}`, u = g.get(y);
92
+ if (u === undefined) {
93
+ if (g.size >= 64)
94
+ g.clear();
95
+ u = f(r, [...e, a(...s)]), g.set(y, u);
96
+ }
97
+ return u;
98
+ };
99
+ throw Error(`Unknown style: ${String(i)}`);
288
100
  } });
289
101
  }
290
- function le(i = {}) {
291
- return u(i);
102
+ function Fe(r = {}) {
103
+ return f(r);
292
104
  }
293
- var t = le();
105
+ var o = Fe();
294
106
 
295
107
  // ../kit/src/theme.ts
296
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
108
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
297
109
  import { homedir as homedir2 } from "os";
298
110
  import { join as join3, resolve as resolve2 } from "path";
299
111
  import process5 from "process";
@@ -314,6 +126,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
314
126
  }
315
127
 
316
128
  // ../kit/src/user-config.ts
129
+ import { existsSync as existsSync2, readFileSync } from "fs";
317
130
  import { homedir } from "os";
318
131
  import { join as join2 } from "path";
319
132
  import process4 from "process";
@@ -324,21 +137,45 @@ function configBase(where = {}) {
324
137
  function userConfigPath(bin, where = {}) {
325
138
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
326
139
  }
140
+ function userConfigReadPath(bin, legacy = [], where = {}) {
141
+ const current = userConfigPath(bin, where);
142
+ if (existsSync2(current))
143
+ return current;
144
+ const base = configBase(where);
145
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
146
+ }
147
+ function readUserConfig(bin, where = {}, legacy = []) {
148
+ const path = userConfigReadPath(bin, legacy, where);
149
+ if (!existsSync2(path))
150
+ return {};
151
+ try {
152
+ const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
153
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
154
+ } catch {
155
+ return {};
156
+ }
157
+ }
158
+ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
159
+ const value = readUserConfig(bin, where, legacy)[key];
160
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
161
+ }
327
162
 
328
163
  // ../kit/src/theme.ts
164
+ var ENDS = new Map;
329
165
  var DEFAULT = {
330
- colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
331
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
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" },
332
168
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
333
- bins: {}
169
+ bins: {},
170
+ gradient: ["#c084fc", "#67e8f9"]
334
171
  };
335
- var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
336
- var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
337
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
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: "|" };
338
175
  var PRESETS = {
339
176
  default: {},
340
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
341
- mono: { colors: MONO, accents: ["bold"] },
177
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
178
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
342
179
  ascii: { glyphs: ASCII }
343
180
  };
344
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"]);
@@ -388,7 +225,7 @@ function readThemeFile(path, warn) {
388
225
  warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
389
226
  return;
390
227
  }
391
- const parsed = JSON.parse(readFileSync(path, "utf8"));
228
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
392
229
  if (isRecord(parsed))
393
230
  return parsed;
394
231
  warn(`${path} is not a JSON object, theme ignored`);
@@ -409,6 +246,8 @@ function applyPreset(theme, name, warn, where) {
409
246
  Object.assign(theme.glyphs, preset.glyphs);
410
247
  if (preset.accents !== undefined)
411
248
  theme.accents = [...preset.accents];
249
+ if (Object.hasOwn(preset, "gradient"))
250
+ theme.gradient = preset.gradient;
412
251
  return name;
413
252
  }
414
253
  function applyFile(theme, file, where, warn) {
@@ -436,6 +275,12 @@ function applyFile(theme, file, where, warn) {
436
275
  theme.accents = [...file.accents];
437
276
  else if (file.accents !== undefined)
438
277
  warn(`${where}: accents must be a non-empty list of colours`);
278
+ if (file.gradient === null)
279
+ theme.gradient = undefined;
280
+ else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
281
+ theme.gradient = [file.gradient[0], file.gradient[1]];
282
+ else if (file.gradient !== undefined)
283
+ warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
439
284
  if (isRecord(file.bins)) {
440
285
  for (const [bin, value] of Object.entries(file.bins)) {
441
286
  if (isColorSpec(value))
@@ -446,7 +291,7 @@ function applyFile(theme, file, where, warn) {
446
291
  }
447
292
  }
448
293
  function endsWalk(home) {
449
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
294
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
450
295
  }
451
296
  var warned = new Set;
452
297
  function warnOnce(message) {
@@ -459,7 +304,7 @@ function isPath(chosen) {
459
304
  return chosen.includes("/") || chosen.endsWith(".json");
460
305
  }
461
306
  function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
462
- const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
307
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
463
308
  const sources = [];
464
309
  const chosen = env.KIT_THEME ?? "";
465
310
  const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
@@ -497,11 +342,24 @@ function activeTheme() {
497
342
  }
498
343
 
499
344
  // ../kit/src/style.ts
345
+ var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
500
346
  function takesControlCodes(stream, env = process6.env) {
501
347
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
502
348
  }
503
349
  function paint(stream, env = process6.env) {
504
- return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
350
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
351
+ }
352
+ function marked(mark, text, stream, detail, env = process6.env) {
353
+ const colors = paint(stream, env);
354
+ let head = MARK_WORDS[mark];
355
+ if (takesControlCodes(stream, env)) {
356
+ const { theme } = activeTheme();
357
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
358
+ }
359
+ return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
360
+ }
361
+ function problem(text, detail) {
362
+ console.error(marked("problem", text, process6.stderr, detail));
505
363
  }
506
364
  var STATUS_WORDS = {
507
365
  passed: ["passed", "success", "succeeded", "ok"],
@@ -555,7 +413,7 @@ function formatAge(date, now = Date.now()) {
555
413
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
556
414
  }
557
415
  function truncate(text, width) {
558
- return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
416
+ return ko(text, width, { suffix: "\u2026", includeSuffix: true });
559
417
  }
560
418
  var LINE_BREAKS = /\s*\n\s*/g;
561
419
  var ESCAPE = String.fromCharCode(27);
@@ -1051,8 +909,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
1051
909
  // ../kit/src/progress.ts
1052
910
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
1053
911
  var FRAME_MS = 200;
1054
- var CLEAR_LINE = "\r\x1B[2K";
1055
- var LINE_UP = "\x1B[1A\x1B[2K";
912
+ var CLEAR_BELOW = "\r\x1B[J";
1056
913
  var ESC = String.fromCharCode(27);
1057
914
  var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
1058
915
  var RESET_STYLE = `${ESC}[0m`;
@@ -1069,13 +926,15 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
1069
926
  } };
1070
927
  const write = stream.write.bind(stream);
1071
928
  let frame = 0;
1072
- let drawn = [];
1073
- const columns = () => stream.columns === undefined || stream.columns === 0 ? 80 : stream.columns;
1074
- const rowsDrawn = () => drawn.reduce((sum, width) => sum + Math.max(1, Math.ceil(width / columns())), 0);
929
+ let drawn = false;
930
+ const columns = () => {
931
+ const now = stream.getWindowSize?.()[0] ?? stream.columns;
932
+ return now === undefined || now === 0 ? 80 : now;
933
+ };
1075
934
  const clear = () => {
1076
- if (drawn.length > 0)
1077
- write(`${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}`);
1078
- drawn = [];
935
+ if (drawn)
936
+ write(CLEAR_BELOW);
937
+ drawn = false;
1079
938
  };
1080
939
  const draw = () => {
1081
940
  const width = columns() - 1;
@@ -1085,9 +944,9 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
1085
944
  clear();
1086
945
  return;
1087
946
  }
1088
- write(`${drawn.length > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}` : CLEAR_LINE}${lines.join(`
1089
- `)}`);
1090
- drawn = lines.map((line) => Bun.stringWidth(line));
947
+ write(`${CLEAR_BELOW}${lines.join(`
948
+ `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
949
+ drawn = true;
1091
950
  };
1092
951
  const timer = setInterval(draw, FRAME_MS);
1093
952
  stream.on?.("resize", draw);
@@ -1188,7 +1047,7 @@ function interceptOutput(clear) {
1188
1047
  };
1189
1048
  }
1190
1049
  // ../kit/src/cli.ts
1191
- import { readFileSync as readFileSync2, realpathSync } from "fs";
1050
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
1192
1051
  import { dirname as dirname3, join as join6 } from "path";
1193
1052
  import process14 from "process";
1194
1053
 
@@ -1359,7 +1218,7 @@ async function printCandidates(found) {
1359
1218
  function packageVersion(entry = Bun.main) {
1360
1219
  for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1361
1220
  try {
1362
- const { version } = JSON.parse(readFileSync2(join6(dir, "package.json"), "utf8"));
1221
+ const { version } = JSON.parse(readFileSync3(join6(dir, "package.json"), "utf8"));
1363
1222
  if (typeof version === "string")
1364
1223
  return version;
1365
1224
  } catch {}
@@ -1461,7 +1320,7 @@ async function currentSession(sessions) {
1461
1320
  return;
1462
1321
  }
1463
1322
  // src/slot.ts
1464
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync3, rmSync } from "fs";
1323
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync4, rmSync } from "fs";
1465
1324
  import { availableParallelism } from "os";
1466
1325
  import { join as join8 } from "path";
1467
1326
  import process18 from "process";
@@ -1525,7 +1384,7 @@ async function stateDir() {
1525
1384
  }
1526
1385
  function readHolder(path) {
1527
1386
  try {
1528
- const holder = JSON.parse(readFileSync3(path, "utf8"));
1387
+ const holder = JSON.parse(readFileSync4(path, "utf8"));
1529
1388
  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;
1530
1389
  } catch {
1531
1390
  return;
@@ -1658,7 +1517,7 @@ ${RUN_USAGE}`);
1658
1517
  function scan(dir, state, kind) {
1659
1518
  const folder = join8(dir, kind);
1660
1519
  const entries = [];
1661
- for (const name of existsSync3(folder) ? readdirSync(folder) : []) {
1520
+ for (const name of existsSync4(folder) ? readdirSync(folder) : []) {
1662
1521
  const path = join8(folder, name);
1663
1522
  const probe = tryLock(path);
1664
1523
  if (probe !== undefined) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-wait",
3
3
  "type": "module",
4
- "version": "0.9.0",
4
+ "version": "0.10.1",
5
5
  "description": "waitfor and slot: waits for a log line, a listening port or a URL answering, and queues heavy commands behind machine-wide slots and named locks, for Claude Code, instead of sleep and polling loops.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -38,6 +38,6 @@
38
38
  "waitfor": "$npm_execpath src/cli.ts"
39
39
  },
40
40
  "devDependencies": {
41
- "@kaynooo/cli-kit": "0.30.0"
41
+ "@kaynooo/cli-kit": "0.37.0"
42
42
  }
43
43
  }