@kaynooo/cli-proc 0.6.0 → 0.7.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/dist/pid-cli.js CHANGED
@@ -1,14 +1,46 @@
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/pid-cli.ts
5
- import process13 from "process";
5
+ import process16 from "process";
6
6
  // ../kit/src/args.ts
7
- import process6 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process4 from "process";
11
+ import process7 from "process";
12
+
13
+ // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-n6z2kk96.js
14
+ var r = new Map;
15
+ var i = new Map;
16
+ var l = new Map;
17
+ function a(e, t, o) {
18
+ return JSON.stringify([e ?? null, t ?? null, o]);
19
+ }
20
+ function y(e, t) {
21
+ let o = a(e, t), n = i.get(o);
22
+ if (!n)
23
+ n = new Intl.NumberFormat(e, t), i.set(o, n);
24
+ return n;
25
+ }
26
+
27
+ // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
28
+ var N = new Map;
29
+ var Nt = /\s+\S*$/;
30
+ var Y = /\s/;
31
+ function ko(t, e, r = "...") {
32
+ let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
33
+ if (t.length <= e)
34
+ return t;
35
+ let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
36
+ if (o && !Y.test(t[c.length] ?? " "))
37
+ c = c.replace(Nt, "") || c;
38
+ if (o)
39
+ c = c.trimEnd();
40
+ return s ? (c + n).slice(0, l) : c + n;
41
+ }
42
+ 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));
43
+ var z = new Map;
12
44
 
13
45
  // ../kit/src/mode.ts
14
46
  import process2 from "process";
@@ -32,280 +64,296 @@ function isInteractive(streams = process2) {
32
64
  }
33
65
 
34
66
  // ../kit/src/style.ts
35
- import process3 from "process";
67
+ import process6 from "process";
36
68
 
37
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
38
- function x(s) {
39
- let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
40
- if (!/^[a-f0-9]+$/.test(r))
69
+ // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
70
+ var G2 = /^[a-f0-9]+$/i;
71
+ function b(r) {
72
+ let e = r.startsWith("#") ? r.slice(1) : r;
73
+ if (!G2.test(e))
41
74
  return [0, 0, 0];
42
- let t = r.length, n = (c) => Number.parseInt(c, 16);
43
- if (t === 3 || t === 4) {
44
- 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;
45
- return g !== undefined ? [c, u, h, g] : [c, u, h];
46
- }
47
- if (t !== 6 && t !== 8)
48
- throw Error(`Invalid hex color length: ${t}`);
49
- 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;
50
- if ([a, b, o].some(Number.isNaN) || y !== undefined && Number.isNaN(y))
51
- throw Error(`Invalid hex color value: ${s}`);
52
- return y !== undefined ? [a, b, o, y] : [a, b, o];
53
- }
54
- function A(s) {
55
- let [r, t, n, a] = s;
56
- if (a)
57
- return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
58
- return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
59
- }
60
- function R(s, r, t) {
61
- s = (s % 360 + 360) % 360, t /= 100;
62
- let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
63
- let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
64
- return Math.round(255 * y);
65
- };
66
- return [a(0), a(8), a(4)];
67
- }
68
- function k(s) {
69
- let [r, t, n] = s;
70
- r /= 255, t /= 255, n /= 255;
71
- let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
72
- if (a !== b) {
73
- let u = a - b;
74
- if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
75
- o = (t - n) / u + (t < n ? 6 : 0);
76
- else if (a === t)
77
- o = (n - r) / u + 2;
78
- else
79
- o = (r - t) / u + 4;
80
- o /= 6;
81
- }
82
- return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
83
- }
84
- function H(s, r, t) {
85
- s = (s % 360 + 360) % 360, r /= 100, t /= 100;
86
- let n = (a) => {
87
- let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
88
- return Math.round(255 * o);
89
- };
90
- return [n(5), n(3), n(1)];
91
- }
92
- function f(s) {
93
- let [r, t, n] = s;
94
- r /= 255, t /= 255, n /= 255;
95
- 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;
96
- if (o !== 0) {
97
- if (a === r)
98
- y = (t - n) / o + (t < n ? 6 : 0);
99
- else if (a === t)
100
- y = (n - r) / o + 2;
101
- else
102
- y = (r - t) / o + 4;
103
- y /= 6;
104
- }
105
- return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
106
- }
107
- function O(s) {
108
- let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
109
- if (a === 1)
110
- return [0, 0, 0, 100];
111
- let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
112
- return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
113
- }
114
- function v(s, r, t, n) {
115
- 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))];
116
- }
117
- var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
118
- var p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055;
119
- var i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
120
- function T(s) {
121
- 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);
122
- 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)];
75
+ if (e.length === 3 || e.length === 4)
76
+ return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
77
+ if (e.length !== 6 && e.length !== 8)
78
+ throw Error(`Invalid hex color length: ${e.length}`);
79
+ return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
80
+ }
81
+ 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") => {
82
+ let [l, n, c] = b(r);
83
+ return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
84
+ }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
85
+ var h = new Set(["", "1", "2", "3", "true"]);
86
+ function C(r, e = globalThis.process?.env ?? {}) {
87
+ if (e.FORCE_COLOR !== undefined)
88
+ return h.has(e.FORCE_COLOR);
89
+ if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
90
+ return false;
91
+ return r?.isTTY === true;
92
+ }
93
+ function f(r, e = []) {
94
+ let l = "", n = "";
95
+ for (let t = 0, i = e.length;t < i; t++)
96
+ l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
97
+ let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
98
+ return new Proxy(c, { get(t, i) {
99
+ let a = B2[i];
100
+ if (Array.isArray(a)) {
101
+ let s = g.get(i);
102
+ if (s === undefined)
103
+ s = f(r, [...e, a]), g.set(i, s);
104
+ return s;
105
+ }
106
+ if (typeof a === "function")
107
+ return (...s) => {
108
+ let y = `${i}:${s.join(",")}`, u = g.get(y);
109
+ if (u === undefined) {
110
+ if (g.size >= 64)
111
+ g.clear();
112
+ u = f(r, [...e, a(...s)]), g.set(y, u);
113
+ }
114
+ return u;
115
+ };
116
+ throw Error(`Unknown style: ${String(i)}`);
117
+ } });
123
118
  }
124
- function M(s, r, t) {
125
- 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)));
126
- return [u(o), u(y), u(c)];
119
+ function Fe(r = {}) {
120
+ return f(r);
127
121
  }
128
- function d(s) {
129
- let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
130
- return [i(r, 4), i(a, 4), i(b, 2)];
122
+ var o = Fe();
123
+
124
+ // ../kit/src/theme.ts
125
+ import { existsSync as existsSync2, readFileSync, statSync } from "fs";
126
+ import { homedir as homedir2 } from "os";
127
+ import { join as join3, resolve as resolve2 } from "path";
128
+ import process5 from "process";
129
+
130
+ // ../kit/src/config.ts
131
+ import { existsSync } from "fs";
132
+ import { dirname, join, resolve } from "path";
133
+ import process3 from "process";
134
+ function findUp(names, from = process3.cwd(), stop = () => false) {
135
+ const wanted = typeof names === "string" ? [names] : names;
136
+ for (let dir = resolve(from);; dir = dirname(dir)) {
137
+ const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
138
+ if (found !== undefined)
139
+ return found;
140
+ if (stop(dir) || dirname(dir) === dir)
141
+ return;
142
+ }
131
143
  }
132
- function C(s, r, t) {
133
- let n = t * Math.PI / 180;
134
- return M(s, r * Math.cos(n), r * Math.sin(n));
144
+
145
+ // ../kit/src/user-config.ts
146
+ import { homedir } from "os";
147
+ import { join as join2 } from "path";
148
+ import process4 from "process";
149
+ function configBase(where = {}) {
150
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
151
+ return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
135
152
  }
136
- function l(s) {
137
- let r = s / 255;
138
- return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
153
+ function userConfigPath(bin, where = {}) {
154
+ return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
139
155
  }
140
156
 
141
- class e {
142
- r;
143
- g;
144
- b;
145
- a;
146
- constructor(s, r, t, n = 1) {
147
- this.r = s, this.g = r, this.b = t, this.a = n;
148
- }
149
- static from(s, r) {
150
- if (s === "hex") {
151
- let [t, n, a, b] = x(r);
152
- return new e(t, n, a, b);
153
- }
154
- if (s === "rgb") {
155
- if (Array.isArray(r)) {
156
- let [o, y, c, u] = r;
157
- return new e(o, y, c, u);
158
- }
159
- let { r: t, g: n, b: a, a: b } = r;
160
- return new e(t, n, a, b);
161
- }
162
- if (s === "hsl") {
163
- let t, n, a, b;
164
- if (Array.isArray(r))
165
- [t, n, a, b] = r;
166
- else
167
- ({ h: t, s: n, l: a, a: b } = r);
168
- let [o, y, c] = R(t, n, a);
169
- return new e(o, y, c, b);
170
- }
171
- if (s === "hsv") {
172
- let t, n, a, b;
173
- if (Array.isArray(r))
174
- [t, n, a, b] = r;
175
- else
176
- ({ h: t, s: n, v: a, a: b } = r);
177
- let [o, y, c] = H(t, n, a);
178
- return new e(o, y, c, b);
157
+ // ../kit/src/theme.ts
158
+ var ENDS = new Map;
159
+ var DEFAULT = {
160
+ 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" },
161
+ 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" },
162
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
163
+ bins: {},
164
+ gradient: ["#c084fc", "#67e8f9"]
165
+ };
166
+ 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" };
167
+ 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" };
168
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
169
+ var PRESETS = {
170
+ default: {},
171
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
172
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
173
+ ascii: { glyphs: ASCII }
174
+ };
175
+ 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"]);
176
+ var HEX = /^#[0-9a-f]{6}$/i;
177
+ var CONTROL = /\p{Cc}/u;
178
+ var MAX_FILE_BYTES = 64 * 1024;
179
+ var SPACES = /\s+/;
180
+ function isColorSpec(spec) {
181
+ if (typeof spec === "number")
182
+ return Number.isInteger(spec) && spec >= 0 && spec <= 255;
183
+ return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
184
+ }
185
+ var CUBE = [0, 95, 135, 175, 215, 255];
186
+ function cubeLevel(channel) {
187
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
188
+ }
189
+ function nearest256(hex) {
190
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
191
+ const levels = rgb.map(cubeLevel);
192
+ const cube = levels.map((level) => CUBE[level]);
193
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
194
+ const greyValue = 8 + grey * 10;
195
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
196
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
197
+ }
198
+ function hasTrueColor(env) {
199
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
200
+ }
201
+ function tinted(colors, spec, env = process5.env) {
202
+ if (typeof spec === "number")
203
+ return colors.ansi256(spec);
204
+ return spec.trim().split(SPACES).reduce((chain, token) => {
205
+ if (HEX.test(token))
206
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
207
+ return chain[token] ?? chain;
208
+ }, colors);
209
+ }
210
+ function isRecord(value) {
211
+ return typeof value === "object" && value !== null && !Array.isArray(value);
212
+ }
213
+ function readThemeFile(path, warn) {
214
+ try {
215
+ const stat = statSync(path, { throwIfNoEntry: false });
216
+ if (stat === undefined)
217
+ return;
218
+ if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
219
+ warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
220
+ return;
179
221
  }
180
- if (s === "cmyk") {
181
- let t, n, a, b, o;
182
- if (Array.isArray(r))
183
- [t, n, a, b, o] = r;
222
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
223
+ if (isRecord(parsed))
224
+ return parsed;
225
+ warn(`${path} is not a JSON object, theme ignored`);
226
+ } catch (error) {
227
+ warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
228
+ }
229
+ return;
230
+ }
231
+ function applyPreset(theme, name, warn, where) {
232
+ if (name === undefined)
233
+ return;
234
+ if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
235
+ warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
236
+ return;
237
+ }
238
+ const preset = PRESETS[name];
239
+ Object.assign(theme.colors, preset.colors);
240
+ Object.assign(theme.glyphs, preset.glyphs);
241
+ if (preset.accents !== undefined)
242
+ theme.accents = [...preset.accents];
243
+ if (Object.hasOwn(preset, "gradient"))
244
+ theme.gradient = preset.gradient;
245
+ return name;
246
+ }
247
+ function applyFile(theme, file, where, warn) {
248
+ if (isRecord(file.colors)) {
249
+ for (const [key, value] of Object.entries(file.colors)) {
250
+ if (!Object.hasOwn(DEFAULT.colors, key))
251
+ warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
252
+ else if (!isColorSpec(value))
253
+ warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
184
254
  else
185
- ({ c: t, m: n, y: a, k: b, a: o } = r);
186
- let [y, c, u] = v(t, n, a, b);
187
- return new e(y, c, u, o);
255
+ theme.colors[key] = value;
188
256
  }
189
- if (s === "oklch") {
190
- let t, n, a, b;
191
- if (Array.isArray(r))
192
- [t, n, a, b] = r;
257
+ }
258
+ if (isRecord(file.glyphs)) {
259
+ for (const [key, value] of Object.entries(file.glyphs)) {
260
+ if (!Object.hasOwn(DEFAULT.glyphs, key))
261
+ warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
262
+ else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
263
+ warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
193
264
  else
194
- ({ l: t, c: n, h: a, a: b } = r);
195
- let [o, y, c] = C(t, n, a);
196
- return new e(o, y, c, b);
265
+ theme.glyphs[key] = value;
197
266
  }
198
- if (s === "oklab") {
199
- let t, n, a, b;
200
- if (Array.isArray(r))
201
- [t, n, a, b] = r;
267
+ }
268
+ if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
269
+ theme.accents = [...file.accents];
270
+ else if (file.accents !== undefined)
271
+ warn(`${where}: accents must be a non-empty list of colours`);
272
+ if (file.gradient === null)
273
+ theme.gradient = undefined;
274
+ else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
275
+ theme.gradient = [file.gradient[0], file.gradient[1]];
276
+ else if (file.gradient !== undefined)
277
+ warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
278
+ if (isRecord(file.bins)) {
279
+ for (const [bin, value] of Object.entries(file.bins)) {
280
+ if (isColorSpec(value))
281
+ theme.bins[bin] = value;
202
282
  else
203
- ({ l: t, a: n, b: a, alpha: b } = r);
204
- let [o, y, c] = M(t, n, a);
205
- return new e(o, y, c, b);
206
- }
207
- throw Error("Invalid input");
208
- }
209
- to(s) {
210
- switch (s) {
211
- case "rgb":
212
- return [this.r, this.g, this.b];
213
- case "rgba":
214
- return [this.r, this.g, this.b, this.a];
215
- case "hex":
216
- return A([this.r, this.g, this.b]);
217
- case "hexa":
218
- return A([this.r, this.g, this.b, this.a]);
219
- case "hsl":
220
- return k([this.r, this.g, this.b]);
221
- case "hsla":
222
- return [...k([this.r, this.g, this.b]), this.a];
223
- case "hsv":
224
- return f([this.r, this.g, this.b]);
225
- case "hsva":
226
- return [...f([this.r, this.g, this.b]), this.a];
227
- case "cmyk":
228
- return O([this.r, this.g, this.b]);
229
- case "cmyka":
230
- return [...O([this.r, this.g, this.b]), this.a];
231
- case "oklch":
232
- return d([this.r, this.g, this.b]);
233
- case "oklcha":
234
- return [...d([this.r, this.g, this.b]), this.a];
235
- case "oklab":
236
- return T([this.r, this.g, this.b]);
237
- case "oklaba":
238
- return [...T([this.r, this.g, this.b]), this.a];
239
- default:
240
- return [this.r, this.g, this.b];
283
+ warn(`${where}: bin ${bin} has no valid colour`);
241
284
  }
242
285
  }
243
- getLuminance() {
244
- let s = l(this.r), r = l(this.g), t = l(this.b);
245
- return 0.2126 * s + 0.7152 * r + 0.0722 * t;
246
- }
247
- contrastRatio(s) {
248
- let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
249
- return (n + 0.05) / (a + 0.05);
286
+ }
287
+ function endsWalk(home) {
288
+ return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
289
+ }
290
+ var warned = new Set;
291
+ function warnOnce(message) {
292
+ if (warned.has(message))
293
+ return;
294
+ warned.add(message);
295
+ console.error(`warning: theme ${message}`);
296
+ }
297
+ function isPath(chosen) {
298
+ return chosen.includes("/") || chosen.endsWith(".json");
299
+ }
300
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
301
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
302
+ const sources = [];
303
+ const chosen = env.KIT_THEME ?? "";
304
+ const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
305
+ if (isPath(chosen))
306
+ wanted.push(resolve2(from, chosen));
307
+ const files = [];
308
+ for (const path of wanted) {
309
+ const file = path === undefined ? undefined : readThemeFile(path, warn);
310
+ if (path !== undefined && file !== undefined)
311
+ files.push({ path, file });
312
+ }
313
+ let preset = "default";
314
+ if (chosen !== "" && !isPath(chosen)) {
315
+ preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
316
+ } else {
317
+ const named = files.findLast(({ file }) => file.preset !== undefined);
318
+ if (named !== undefined)
319
+ preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
250
320
  }
251
- bestContrastForeground() {
252
- let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
253
- return t >= n ? s : r;
321
+ for (const { path, file } of files) {
322
+ applyFile(theme, file, path, warn);
323
+ sources.push(path);
254
324
  }
325
+ return { theme, sources, preset };
255
326
  }
256
-
257
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
258
- var r = 39;
259
- var o = 49;
260
- var f2 = "\x1B[";
261
- 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") => {
262
- let [a, l, s] = e.from("hex", i).to("rgb");
263
- return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
264
- }, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
265
- var b = new Set(["", "1", "2", "3", "true"]);
266
- function h(i, n = globalThis.process?.env ?? {}) {
267
- if (n.FORCE_COLOR !== undefined)
268
- return b.has(n.FORCE_COLOR);
269
- if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
270
- return false;
271
- return i?.isTTY === true;
272
- }
273
- function d2(i, n, a) {
274
- if (!h(a.stream ?? globalThis.process?.stdout, a.env))
275
- return n;
276
- let l = "", s = "";
277
- for (let g = 0, y = i.length;g < y; g++) {
278
- let [c, p] = i[g];
279
- l += `${f2}${c}m`, s = `${f2}${p}m${s}`;
280
- }
281
- return l + n + s;
282
- }
283
- function u(i, n = []) {
284
- return new Proxy((l) => d2(n, l, i), { get(l, s) {
285
- let g = C2[s];
286
- if (Array.isArray(g))
287
- return u(i, [...n, g]);
288
- if (typeof g === "function")
289
- return (...y) => u(i, [...n, g(...y)]);
290
- throw Error(`Unknown style: ${String(s)}`);
291
- } });
292
- }
293
- function le(i = {}) {
294
- return u(i);
327
+ var current;
328
+ var currentKey = "";
329
+ function activeTheme() {
330
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
331
+ if (current === undefined || key !== currentKey) {
332
+ current = loadTheme();
333
+ currentKey = key;
334
+ }
335
+ return current;
295
336
  }
296
- var t = le();
297
-
298
- // ../kit/src/theme.ts
299
- 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"]);
300
- var MAX_FILE_BYTES = 64 * 1024;
301
- var warned = new Set;
302
337
 
303
338
  // ../kit/src/style.ts
304
- function takesControlCodes(stream, env = process3.env) {
339
+ var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
340
+ function takesControlCodes(stream, env = process6.env) {
305
341
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
306
342
  }
307
- function paint(stream, env = process3.env) {
308
- return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
343
+ function paint(stream, env = process6.env) {
344
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
345
+ }
346
+ function marked(mark, text, stream, detail, env = process6.env) {
347
+ const colors = paint(stream, env);
348
+ let head = MARK_WORDS[mark];
349
+ if (takesControlCodes(stream, env)) {
350
+ const { theme } = activeTheme();
351
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
352
+ }
353
+ return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
354
+ }
355
+ function problem(text, detail) {
356
+ console.error(marked("problem", text, process6.stderr, detail));
309
357
  }
310
358
  var STATUS_WORDS = {
311
359
  passed: ["passed", "success", "succeeded", "ok"],
@@ -315,16 +363,16 @@ var STATUS_WORDS = {
315
363
  skipped: ["skipped", "cancelled", "canceled", "manual"]
316
364
  };
317
365
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
318
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-hrsswv1w.js
319
- function $e(t, e = false, i = 1) {
320
- let n = typeof e === "object" ? e : { units: e ? "si" : "iec", dp: i }, { units: s = "iec", dp: u = 1 } = n, r = s === "si" ? 1000 : 1024;
321
- if (Math.abs(t) < r)
322
- return `${t} B`;
323
- let c = s === "iec" ? ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] : ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], o = -1, l = 10 ** u;
366
+ // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-knqbxp56.js
367
+ function tt(i, { units: r = "iec", dp: t = 1, locale: n } = {}) {
368
+ let e = r === "si" ? 1000 : 1024;
369
+ if (Math.abs(i) < e)
370
+ return `${i} B`;
371
+ let s = r === "iec" ? ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] : ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], o = -1, a = 10 ** t;
324
372
  do
325
- t /= r, ++o;
326
- while (Math.round(Math.abs(t) * l) / l >= r && o < c.length - 1);
327
- return `${t.toFixed(u)} ${c[o]}`;
373
+ i /= e, ++o;
374
+ while (Math.round(Math.abs(i) * a) / a >= e && o < s.length - 1);
375
+ return `${n ? y(n, { minimumFractionDigits: t, maximumFractionDigits: t }).format(i) : i.toFixed(t)} ${s[o]}`;
328
376
  }
329
377
 
330
378
  // ../kit/src/format.ts
@@ -347,14 +395,14 @@ function upTo(text, separator) {
347
395
  return end === -1 ? text : text.slice(0, end);
348
396
  }
349
397
  function truncate(text, width) {
350
- return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
398
+ return ko(text, width, { suffix: "\u2026", includeSuffix: true });
351
399
  }
352
400
  var LINE_BREAKS = /\s*\n\s*/g;
353
401
  var ESCAPE = String.fromCharCode(27);
354
402
  function textWidth(text) {
355
403
  return Bun.stringWidth(text);
356
404
  }
357
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process4.stdout, env = process4.env } = {}) {
405
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
358
406
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
359
407
  if (outputMode(stream, env) === "agent")
360
408
  return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
@@ -393,7 +441,7 @@ function narrow(rows, widths, limit) {
393
441
  }
394
442
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
395
443
  }
396
- function jsonText(value, replacer, { stream = process4.stdout, env = process4.env } = {}) {
444
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
397
445
  return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
398
446
  }
399
447
  function printJson(value) {
@@ -401,27 +449,27 @@ function printJson(value) {
401
449
  }
402
450
 
403
451
  // ../kit/src/help.ts
404
- import process5 from "process";
452
+ import process8 from "process";
405
453
  var OPTIONAL = /\[[^\]]+\]/g;
406
454
  var USAGE_PREFIX = /^usage:\s*/i;
407
455
  var FULL_STOP = /\.$/;
408
- function usageLine(usage, colors = paint(process5.stdout)) {
456
+ function usageLine(usage, colors = paint(process8.stdout)) {
409
457
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
410
458
  }
411
- function helpText(usage, options, colors = paint(process5.stdout), { examples = [], replaces, exits = [] } = {}) {
459
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
412
460
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
413
461
  `);
414
462
  }
415
- function exitRows(exits, colors = paint(process5.stdout)) {
463
+ function exitRows(exits, colors = paint(process8.stdout)) {
416
464
  if (exits.length === 0)
417
465
  return [];
418
466
  const width = Math.max(...exits.map(([code]) => String(code).length));
419
467
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
420
468
  }
421
- function replacesRows(replaces, colors = paint(process5.stdout)) {
469
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
422
470
  return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
423
471
  }
424
- function wantsHelpJson(env = process5.env) {
472
+ function wantsHelpJson(env = process8.env) {
425
473
  return env.KIT_HELP === "json";
426
474
  }
427
475
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -440,12 +488,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
440
488
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
441
489
  };
442
490
  }
443
- function exampleRows(examples, colors = paint(process5.stdout)) {
491
+ function exampleRows(examples, colors = paint(process8.stdout)) {
444
492
  if (examples.length === 0 || outputMode() === "agent")
445
493
  return [];
446
494
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
447
495
  }
448
- function optionRows(options, colors = paint(process5.stdout)) {
496
+ function optionRows(options, colors = paint(process8.stdout)) {
449
497
  const rows = Object.entries(options).map(([name, option]) => {
450
498
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
451
499
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -546,7 +594,7 @@ var OUTPUT_OPTIONS = {
546
594
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
547
595
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
548
596
  };
549
- function applyOutput(color, plain, env = process6.env) {
597
+ function applyOutput(color, plain, env = process9.env) {
550
598
  const when = plain === true ? "never" : color ?? "auto";
551
599
  if (when === "auto")
552
600
  return;
@@ -717,7 +765,7 @@ function nearestOption(message, options, allowNegative) {
717
765
  }
718
766
  // ../kit/src/process.ts
719
767
  import { constants } from "os";
720
- import process7 from "process";
768
+ import process10 from "process";
721
769
  var KILL_GRACE_MS = 2000;
722
770
  function exitCodeOf(code, signal) {
723
771
  if (code !== null)
@@ -737,7 +785,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
737
785
  return;
738
786
  try {
739
787
  if (grouped)
740
- process7.kill(-proc.pid, killing);
788
+ process10.kill(-proc.pid, killing);
741
789
  else
742
790
  proc.kill(killing);
743
791
  } catch {}
@@ -811,15 +859,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
811
859
  var RESET_STYLE = `${ESC}[0m`;
812
860
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
813
861
  // ../kit/src/cli.ts
814
- import { readFileSync, realpathSync } from "fs";
815
- import { dirname as dirname2, join as join2 } from "path";
816
- import process9 from "process";
862
+ import { readFileSync as readFileSync2, realpathSync } from "fs";
863
+ import { dirname as dirname3, join as join5 } from "path";
864
+ import process12 from "process";
817
865
 
818
866
  // ../kit/src/usage.ts
819
867
  import { appendFileSync, mkdirSync } from "fs";
820
- import { homedir } from "os";
821
- import { dirname, isAbsolute, join } from "path";
822
- import process8 from "process";
868
+ import { homedir as homedir3 } from "os";
869
+ import { dirname as dirname2, isAbsolute, join as join4 } from "path";
870
+ import process11 from "process";
823
871
 
824
872
  // ../kit/src/logs.ts
825
873
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -833,14 +881,14 @@ var usageError;
833
881
  function noteUsageError(message) {
834
882
  usageError = message;
835
883
  }
836
- function stateHome(env = process8.env) {
884
+ function stateHome(env = process11.env) {
837
885
  const dir = env.XDG_STATE_HOME;
838
- return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
886
+ return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
839
887
  }
840
- function usagePath(env = process8.env) {
841
- return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
888
+ function usagePath(env = process11.env) {
889
+ return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
842
890
  }
843
- function usageRecorded(env = process8.env) {
891
+ function usageRecorded(env = process11.env) {
844
892
  const off = env.KAYNOOO_CLI_NO_USAGE;
845
893
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
846
894
  }
@@ -854,12 +902,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
854
902
  usageError = undefined;
855
903
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
856
904
  }
857
- function recordUsage(entry, env = process8.env) {
905
+ function recordUsage(entry, env = process11.env) {
858
906
  if (!usageRecorded(env))
859
907
  return;
860
908
  try {
861
909
  const path = usagePath(env);
862
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
910
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
863
911
  appendFileSync(path, `${JSON.stringify(entry)}
864
912
  `, { mode: 384 });
865
913
  } catch {}
@@ -945,8 +993,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
945
993
  `);
946
994
  }
947
995
  function printError(prefix, message, hint, cause) {
948
- const colors = paint(process9.stderr);
949
- const styled = takesControlCodes(process9.stderr);
996
+ const colors = paint(process12.stderr);
997
+ const styled = takesControlCodes(process12.stderr);
950
998
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
951
999
  const under = (label, text, tint) => text === undefined ? "" : `
952
1000
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -989,11 +1037,11 @@ async function dispatch(level, typed, { version, redact }) {
989
1037
  }
990
1038
  }
991
1039
  if (name === undefined && level.path.length > 1) {
992
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stderr));
1040
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
993
1041
  return 2;
994
1042
  }
995
1043
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
996
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stdout));
1044
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
997
1045
  return 0;
998
1046
  }
999
1047
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1110,17 +1158,17 @@ async function printCandidates(found) {
1110
1158
  return 0;
1111
1159
  }
1112
1160
  function packageVersion(entry = Bun.main) {
1113
- for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1161
+ for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1114
1162
  try {
1115
- const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
1163
+ const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1116
1164
  if (typeof version === "string")
1117
1165
  return version;
1118
1166
  } catch {}
1119
- if (dirname2(dir) === dir)
1167
+ if (dirname3(dir) === dir)
1120
1168
  return "0.0.0";
1121
1169
  }
1122
1170
  }
1123
- async function runCli(cli, argv = process9.argv.slice(2)) {
1171
+ async function runCli(cli, argv = process12.argv.slice(2)) {
1124
1172
  const version = cli.version ?? packageVersion();
1125
1173
  if (argv[0] === COMPLETE)
1126
1174
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1147,7 +1195,7 @@ function commandPath(scope, argv) {
1147
1195
  }
1148
1196
  return path.length === 0 ? undefined : path.join(" ");
1149
1197
  }
1150
- async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
1198
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1151
1199
  if (argv[0] === COMPLETE)
1152
1200
  return printCandidates(leafCandidates(run, argv.slice(1)));
1153
1201
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1191,7 +1239,7 @@ function parseSize(text, bareUnit = 1) {
1191
1239
  return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
1192
1240
  }
1193
1241
  // ../kit/src/watch.ts
1194
- import process10 from "process";
1242
+ import process13 from "process";
1195
1243
  import { format } from "util";
1196
1244
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1197
1245
  var DEFAULT_SECONDS = 2;
@@ -1213,7 +1261,7 @@ function withoutWatch(args) {
1213
1261
  }
1214
1262
  return rest;
1215
1263
  }
1216
- async function watching(value, step, stream = process10.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1264
+ async function watching(value, step, stream = process13.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1217
1265
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1218
1266
  if (!takesControlCodes(stream))
1219
1267
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1221,12 +1269,12 @@ async function watching(value, step, stream = process10.stdout, sleep = Bun.slee
1221
1269
  for (let round = 0;round < rounds; round++) {
1222
1270
  const held = [];
1223
1271
  const { log, info } = console;
1224
- const write = process10.stdout.write.bind(process10.stdout);
1272
+ const write = process13.stdout.write.bind(process13.stdout);
1225
1273
  const hold = (...parts) => void held.push(`${format(...parts)}
1226
1274
  `);
1227
1275
  console.log = hold;
1228
1276
  console.info = hold;
1229
- process10.stdout.write = (text) => {
1277
+ process13.stdout.write = (text) => {
1230
1278
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1231
1279
  return true;
1232
1280
  };
@@ -1235,7 +1283,7 @@ async function watching(value, step, stream = process10.stdout, sleep = Bun.slee
1235
1283
  } finally {
1236
1284
  console.log = log;
1237
1285
  console.info = info;
1238
- process10.stdout.write = write;
1286
+ process13.stdout.write = write;
1239
1287
  }
1240
1288
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1241
1289
  await sleep(interval);
@@ -1243,7 +1291,7 @@ async function watching(value, step, stream = process10.stdout, sleep = Bun.slee
1243
1291
  return code;
1244
1292
  }
1245
1293
  // src/pid.ts
1246
- import process12 from "process";
1294
+ import process15 from "process";
1247
1295
 
1248
1296
  // src/mask.ts
1249
1297
  import { basename } from "path";
@@ -1582,7 +1630,7 @@ async function parentsOf(proc, boot) {
1582
1630
  }
1583
1631
  return parents;
1584
1632
  }
1585
- async function report(pid, showEnv) {
1633
+ async function report2(pid, showEnv) {
1586
1634
  const boot = await bootMs();
1587
1635
  const proc = await readProc(pid, boot);
1588
1636
  if (proc === undefined)
@@ -1634,9 +1682,9 @@ function limitLine(limits, name) {
1634
1682
  return limit === undefined ? "-" : `soft ${limit.soft}, hard ${limit.hard}`;
1635
1683
  }
1636
1684
  function render(info, showEnv) {
1637
- const colors = paint(process12.stdout);
1685
+ const colors = paint(process15.stdout);
1638
1686
  const memory = info.memory;
1639
- const size = (bytes) => bytes === undefined ? "-" : $e(bytes);
1687
+ const size = (bytes) => bytes === undefined ? "-" : tt(bytes);
1640
1688
  const rows = [
1641
1689
  ["Executable", info.exe ?? "-"],
1642
1690
  ["Directory", info.cwd ?? "-"],
@@ -1675,7 +1723,7 @@ async function pid(args) {
1675
1723
  const [given] = positionals;
1676
1724
  if (!DIGITS2.test(given))
1677
1725
  fail(`the pid takes a number, not ${given}`, 2);
1678
- const info = await report(Number(given), values.env === true);
1726
+ const info = await report2(Number(given), values.env === true);
1679
1727
  if (info === undefined)
1680
1728
  return fail(`no process with pid ${given}`, 1);
1681
1729
  if (values.json === true)
@@ -1686,4 +1734,4 @@ async function pid(args) {
1686
1734
  }
1687
1735
 
1688
1736
  // src/pid-cli.ts
1689
- process13.exitCode = await runMain({ name: "pid", run: pid });
1737
+ process16.exitCode = await runMain({ name: "pid", run: pid });