@kaynooo/cli-base 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.js +338 -329
  2. package/dist/proof-cli.js +336 -327
  3. package/package.json +2 -2
package/dist/proof-cli.js CHANGED
@@ -1,14 +1,14 @@
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/proof-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
12
 
13
13
  // ../kit/src/mode.ts
14
14
  import process2 from "process";
@@ -29,280 +29,287 @@ function outputMode(stream = process2.stdout, env = process2.env) {
29
29
  }
30
30
 
31
31
  // ../kit/src/style.ts
32
- import process3 from "process";
32
+ import process6 from "process";
33
33
 
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))
34
+ // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
35
+ var G = /^[a-f0-9]+$/i;
36
+ function b(r) {
37
+ let e = r.startsWith("#") ? r.slice(1) : r;
38
+ if (!G.test(e))
38
39
  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)];
40
+ if (e.length === 3 || e.length === 4)
41
+ return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
42
+ if (e.length !== 6 && e.length !== 8)
43
+ throw Error(`Invalid hex color length: ${e.length}`);
44
+ return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
45
+ }
46
+ var B = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
47
+ let [l, n, c] = b(r);
48
+ return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
49
+ }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
50
+ var h = new Set(["", "1", "2", "3", "true"]);
51
+ function C(r, e = globalThis.process?.env ?? {}) {
52
+ if (e.FORCE_COLOR !== undefined)
53
+ return h.has(e.FORCE_COLOR);
54
+ if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
55
+ return false;
56
+ return r?.isTTY === true;
57
+ }
58
+ function f(r, e = []) {
59
+ let l = "", n = "";
60
+ for (let t = 0, i = e.length;t < i; t++)
61
+ l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
62
+ let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
63
+ return new Proxy(c, { get(t, i) {
64
+ let a = B[i];
65
+ if (Array.isArray(a)) {
66
+ let s = g.get(i);
67
+ if (s === undefined)
68
+ s = f(r, [...e, a]), g.set(i, s);
69
+ return s;
70
+ }
71
+ if (typeof a === "function")
72
+ return (...s) => {
73
+ let y = `${i}:${s.join(",")}`, u = g.get(y);
74
+ if (u === undefined) {
75
+ if (g.size >= 64)
76
+ g.clear();
77
+ u = f(r, [...e, a(...s)]), g.set(y, u);
78
+ }
79
+ return u;
80
+ };
81
+ throw Error(`Unknown style: ${String(i)}`);
82
+ } });
120
83
  }
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)];
84
+ function Fe(r = {}) {
85
+ return f(r);
124
86
  }
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)];
87
+ var o = Fe();
88
+
89
+ // ../kit/src/theme.ts
90
+ import { existsSync as existsSync2, readFileSync, statSync } from "fs";
91
+ import { homedir as homedir2 } from "os";
92
+ import { join as join3, resolve as resolve2 } from "path";
93
+ import process5 from "process";
94
+
95
+ // ../kit/src/config.ts
96
+ import { existsSync } from "fs";
97
+ import { dirname, join, resolve } from "path";
98
+ import process3 from "process";
99
+ function findUp(names, from = process3.cwd(), stop = () => false) {
100
+ const wanted = typeof names === "string" ? [names] : names;
101
+ for (let dir = resolve(from);; dir = dirname(dir)) {
102
+ const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
103
+ if (found !== undefined)
104
+ return found;
105
+ if (stop(dir) || dirname(dir) === dir)
106
+ return;
107
+ }
128
108
  }
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));
109
+
110
+ // ../kit/src/user-config.ts
111
+ import { homedir } from "os";
112
+ import { join as join2 } from "path";
113
+ import process4 from "process";
114
+ function configBase(where = {}) {
115
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
116
+ return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
132
117
  }
133
- function l(s) {
134
- let r = s / 255;
135
- return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
118
+ function userConfigPath(bin, where = {}) {
119
+ return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
136
120
  }
137
121
 
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);
122
+ // ../kit/src/theme.ts
123
+ var ENDS = new Map;
124
+ var DEFAULT = {
125
+ 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" },
126
+ 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" },
127
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
128
+ bins: {},
129
+ gradient: ["#c084fc", "#67e8f9"]
130
+ };
131
+ 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" };
132
+ 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" };
133
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
134
+ var PRESETS = {
135
+ default: {},
136
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
137
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
138
+ ascii: { glyphs: ASCII }
139
+ };
140
+ 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"]);
141
+ var HEX = /^#[0-9a-f]{6}$/i;
142
+ var CONTROL = /\p{Cc}/u;
143
+ var MAX_FILE_BYTES = 64 * 1024;
144
+ var SPACES = /\s+/;
145
+ function isColorSpec(spec) {
146
+ if (typeof spec === "number")
147
+ return Number.isInteger(spec) && spec >= 0 && spec <= 255;
148
+ return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
149
+ }
150
+ var CUBE = [0, 95, 135, 175, 215, 255];
151
+ function cubeLevel(channel) {
152
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
153
+ }
154
+ function nearest256(hex) {
155
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
156
+ const levels = rgb.map(cubeLevel);
157
+ const cube = levels.map((level) => CUBE[level]);
158
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
159
+ const greyValue = 8 + grey * 10;
160
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
161
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
162
+ }
163
+ function hasTrueColor(env) {
164
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
165
+ }
166
+ function tinted(colors, spec, env = process5.env) {
167
+ if (typeof spec === "number")
168
+ return colors.ansi256(spec);
169
+ return spec.trim().split(SPACES).reduce((chain, token) => {
170
+ if (HEX.test(token))
171
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
172
+ return chain[token] ?? chain;
173
+ }, colors);
174
+ }
175
+ function isRecord(value) {
176
+ return typeof value === "object" && value !== null && !Array.isArray(value);
177
+ }
178
+ function readThemeFile(path, warn) {
179
+ try {
180
+ const stat = statSync(path, { throwIfNoEntry: false });
181
+ if (stat === undefined)
182
+ return;
183
+ if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
184
+ warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
185
+ return;
176
186
  }
177
- if (s === "cmyk") {
178
- let t, n, a, b, o;
179
- if (Array.isArray(r))
180
- [t, n, a, b, o] = r;
187
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
188
+ if (isRecord(parsed))
189
+ return parsed;
190
+ warn(`${path} is not a JSON object, theme ignored`);
191
+ } catch (error) {
192
+ warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
193
+ }
194
+ return;
195
+ }
196
+ function applyPreset(theme, name, warn, where) {
197
+ if (name === undefined)
198
+ return;
199
+ if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
200
+ warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
201
+ return;
202
+ }
203
+ const preset = PRESETS[name];
204
+ Object.assign(theme.colors, preset.colors);
205
+ Object.assign(theme.glyphs, preset.glyphs);
206
+ if (preset.accents !== undefined)
207
+ theme.accents = [...preset.accents];
208
+ if (Object.hasOwn(preset, "gradient"))
209
+ theme.gradient = preset.gradient;
210
+ return name;
211
+ }
212
+ function applyFile(theme, file, where, warn) {
213
+ if (isRecord(file.colors)) {
214
+ for (const [key, value] of Object.entries(file.colors)) {
215
+ if (!Object.hasOwn(DEFAULT.colors, key))
216
+ warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
217
+ else if (!isColorSpec(value))
218
+ warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
181
219
  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);
220
+ theme.colors[key] = value;
185
221
  }
186
- if (s === "oklch") {
187
- let t, n, a, b;
188
- if (Array.isArray(r))
189
- [t, n, a, b] = r;
222
+ }
223
+ if (isRecord(file.glyphs)) {
224
+ for (const [key, value] of Object.entries(file.glyphs)) {
225
+ if (!Object.hasOwn(DEFAULT.glyphs, key))
226
+ warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
227
+ else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
228
+ warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
190
229
  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);
230
+ theme.glyphs[key] = value;
194
231
  }
195
- if (s === "oklab") {
196
- let t, n, a, b;
197
- if (Array.isArray(r))
198
- [t, n, a, b] = r;
232
+ }
233
+ if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
234
+ theme.accents = [...file.accents];
235
+ else if (file.accents !== undefined)
236
+ warn(`${where}: accents must be a non-empty list of colours`);
237
+ if (file.gradient === null)
238
+ theme.gradient = undefined;
239
+ else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
240
+ theme.gradient = [file.gradient[0], file.gradient[1]];
241
+ else if (file.gradient !== undefined)
242
+ warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
243
+ if (isRecord(file.bins)) {
244
+ for (const [bin, value] of Object.entries(file.bins)) {
245
+ if (isColorSpec(value))
246
+ theme.bins[bin] = value;
199
247
  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];
248
+ warn(`${where}: bin ${bin} has no valid colour`);
238
249
  }
239
250
  }
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);
251
+ }
252
+ function endsWalk(home) {
253
+ return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
254
+ }
255
+ var warned = new Set;
256
+ function warnOnce(message) {
257
+ if (warned.has(message))
258
+ return;
259
+ warned.add(message);
260
+ console.error(`warning: theme ${message}`);
261
+ }
262
+ function isPath(chosen) {
263
+ return chosen.includes("/") || chosen.endsWith(".json");
264
+ }
265
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
266
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
267
+ const sources = [];
268
+ const chosen = env.KIT_THEME ?? "";
269
+ const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
270
+ if (isPath(chosen))
271
+ wanted.push(resolve2(from, chosen));
272
+ const files = [];
273
+ for (const path of wanted) {
274
+ const file = path === undefined ? undefined : readThemeFile(path, warn);
275
+ if (path !== undefined && file !== undefined)
276
+ files.push({ path, file });
277
+ }
278
+ let preset = "default";
279
+ if (chosen !== "" && !isPath(chosen)) {
280
+ preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
281
+ } else {
282
+ const named = files.findLast(({ file }) => file.preset !== undefined);
283
+ if (named !== undefined)
284
+ preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
247
285
  }
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;
286
+ for (const { path, file } of files) {
287
+ applyFile(theme, file, path, warn);
288
+ sources.push(path);
251
289
  }
290
+ return { theme, sources, preset };
252
291
  }
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")
267
- 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)}`);
288
- } });
289
- }
290
- function le(i = {}) {
291
- return u(i);
292
+ var current;
293
+ var currentKey = "";
294
+ function activeTheme() {
295
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
296
+ if (current === undefined || key !== currentKey) {
297
+ current = loadTheme();
298
+ currentKey = key;
299
+ }
300
+ return current;
292
301
  }
293
- var t = le();
294
-
295
- // ../kit/src/theme.ts
296
- 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"]);
297
- var MAX_FILE_BYTES = 64 * 1024;
298
- var warned = new Set;
299
302
 
300
303
  // ../kit/src/style.ts
301
- function takesControlCodes(stream, env = process3.env) {
304
+ function takesControlCodes(stream, env = process6.env) {
302
305
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
303
306
  }
304
- function paint(stream, env = process3.env) {
305
- return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
307
+ function paint(stream, env = process6.env) {
308
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
309
+ }
310
+ function role(name, stream, env = process6.env) {
311
+ const colors = paint(stream, env);
312
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
306
313
  }
307
314
  var STATUS_WORDS = {
308
315
  passed: ["passed", "success", "succeeded", "ok"],
@@ -319,7 +326,7 @@ function upTo(text, separator) {
319
326
  return end === -1 ? text : text.slice(0, end);
320
327
  }
321
328
  var ESCAPE = String.fromCharCode(27);
322
- function jsonText(value, replacer, { stream = process4.stdout, env = process4.env } = {}) {
329
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
323
330
  return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
324
331
  }
325
332
  function printJson(value) {
@@ -327,27 +334,27 @@ function printJson(value) {
327
334
  }
328
335
 
329
336
  // ../kit/src/help.ts
330
- import process5 from "process";
337
+ import process8 from "process";
331
338
  var OPTIONAL = /\[[^\]]+\]/g;
332
339
  var USAGE_PREFIX = /^usage:\s*/i;
333
340
  var FULL_STOP = /\.$/;
334
- function usageLine(usage, colors = paint(process5.stdout)) {
341
+ function usageLine(usage, colors = paint(process8.stdout)) {
335
342
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
336
343
  }
337
- function helpText(usage, options, colors = paint(process5.stdout), { examples = [], replaces, exits = [] } = {}) {
344
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
338
345
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
339
346
  `);
340
347
  }
341
- function exitRows(exits, colors = paint(process5.stdout)) {
348
+ function exitRows(exits, colors = paint(process8.stdout)) {
342
349
  if (exits.length === 0)
343
350
  return [];
344
351
  const width = Math.max(...exits.map(([code]) => String(code).length));
345
352
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
346
353
  }
347
- function replacesRows(replaces, colors = paint(process5.stdout)) {
354
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
348
355
  return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
349
356
  }
350
- function wantsHelpJson(env = process5.env) {
357
+ function wantsHelpJson(env = process8.env) {
351
358
  return env.KIT_HELP === "json";
352
359
  }
353
360
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -366,12 +373,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
366
373
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
367
374
  };
368
375
  }
369
- function exampleRows(examples, colors = paint(process5.stdout)) {
376
+ function exampleRows(examples, colors = paint(process8.stdout)) {
370
377
  if (examples.length === 0 || outputMode() === "agent")
371
378
  return [];
372
379
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
373
380
  }
374
- function optionRows(options, colors = paint(process5.stdout)) {
381
+ function optionRows(options, colors = paint(process8.stdout)) {
375
382
  const rows = Object.entries(options).map(([name, option]) => {
376
383
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
377
384
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -461,7 +468,7 @@ var OUTPUT_OPTIONS = {
461
468
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
462
469
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
463
470
  };
464
- function applyOutput(color, plain, env = process6.env) {
471
+ function applyOutput(color, plain, env = process9.env) {
465
472
  const when = plain === true ? "never" : color ?? "auto";
466
473
  if (when === "auto")
467
474
  return;
@@ -632,7 +639,7 @@ function nearestOption(message, options, allowNegative) {
632
639
  }
633
640
  // ../kit/src/process.ts
634
641
  import { constants } from "os";
635
- import process7 from "process";
642
+ import process10 from "process";
636
643
  var KILL_GRACE_MS = 2000;
637
644
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
638
645
  function exitCodeOf(code, signal) {
@@ -654,7 +661,7 @@ function holdSignals(cleanup) {
654
661
  },
655
662
  release: () => {
656
663
  for (const signal of SIGNALS)
657
- process7.off(signal, onSignal);
664
+ process10.off(signal, onSignal);
658
665
  }
659
666
  };
660
667
  function onSignal(signal) {
@@ -667,10 +674,10 @@ function holdSignals(cleanup) {
667
674
  return;
668
675
  held.release();
669
676
  cleanup(signal);
670
- process7.kill(process7.pid, signal);
677
+ process10.kill(process10.pid, signal);
671
678
  }
672
679
  for (const signal of SIGNALS)
673
- process7.on(signal, onSignal);
680
+ process10.on(signal, onSignal);
674
681
  return held;
675
682
  }
676
683
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -684,7 +691,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
684
691
  return;
685
692
  try {
686
693
  if (grouped)
687
- process7.kill(-proc.pid, killing);
694
+ process10.kill(-proc.pid, killing);
688
695
  else
689
696
  proc.kill(killing);
690
697
  } catch {}
@@ -758,15 +765,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
758
765
  var RESET_STYLE = `${ESC}[0m`;
759
766
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
760
767
  // ../kit/src/cli.ts
761
- import { readFileSync, realpathSync } from "fs";
762
- import { dirname as dirname2, join as join2 } from "path";
763
- import process9 from "process";
768
+ import { readFileSync as readFileSync2, realpathSync } from "fs";
769
+ import { dirname as dirname3, join as join5 } from "path";
770
+ import process12 from "process";
764
771
 
765
772
  // ../kit/src/usage.ts
766
773
  import { appendFileSync, mkdirSync } from "fs";
767
- import { homedir } from "os";
768
- import { dirname, isAbsolute, join } from "path";
769
- import process8 from "process";
774
+ import { homedir as homedir3 } from "os";
775
+ import { dirname as dirname2, isAbsolute, join as join4 } from "path";
776
+ import process11 from "process";
770
777
 
771
778
  // ../kit/src/logs.ts
772
779
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -780,14 +787,14 @@ var usageError;
780
787
  function noteUsageError(message) {
781
788
  usageError = message;
782
789
  }
783
- function stateHome(env = process8.env) {
790
+ function stateHome(env = process11.env) {
784
791
  const dir = env.XDG_STATE_HOME;
785
- return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
792
+ return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
786
793
  }
787
- function usagePath(env = process8.env) {
788
- return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
794
+ function usagePath(env = process11.env) {
795
+ return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
789
796
  }
790
- function usageRecorded(env = process8.env) {
797
+ function usageRecorded(env = process11.env) {
791
798
  const off = env.KAYNOOO_CLI_NO_USAGE;
792
799
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
793
800
  }
@@ -801,12 +808,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
801
808
  usageError = undefined;
802
809
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
803
810
  }
804
- function recordUsage(entry, env = process8.env) {
811
+ function recordUsage(entry, env = process11.env) {
805
812
  if (!usageRecorded(env))
806
813
  return;
807
814
  try {
808
815
  const path = usagePath(env);
809
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
816
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
810
817
  appendFileSync(path, `${JSON.stringify(entry)}
811
818
  `, { mode: 384 });
812
819
  } catch {}
@@ -892,8 +899,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
892
899
  `);
893
900
  }
894
901
  function printError(prefix, message, hint, cause) {
895
- const colors = paint(process9.stderr);
896
- const styled = takesControlCodes(process9.stderr);
902
+ const colors = paint(process12.stderr);
903
+ const styled = takesControlCodes(process12.stderr);
897
904
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
898
905
  const under = (label, text, tint) => text === undefined ? "" : `
899
906
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -936,11 +943,11 @@ async function dispatch(level, typed, { version, redact }) {
936
943
  }
937
944
  }
938
945
  if (name === undefined && level.path.length > 1) {
939
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stderr));
946
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
940
947
  return 2;
941
948
  }
942
949
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
943
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stdout));
950
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
944
951
  return 0;
945
952
  }
946
953
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1057,17 +1064,17 @@ async function printCandidates(found) {
1057
1064
  return 0;
1058
1065
  }
1059
1066
  function packageVersion(entry = Bun.main) {
1060
- for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1067
+ for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1061
1068
  try {
1062
- const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
1069
+ const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1063
1070
  if (typeof version === "string")
1064
1071
  return version;
1065
1072
  } catch {}
1066
- if (dirname2(dir) === dir)
1073
+ if (dirname3(dir) === dir)
1067
1074
  return "0.0.0";
1068
1075
  }
1069
1076
  }
1070
- async function runCli(cli, argv = process9.argv.slice(2)) {
1077
+ async function runCli(cli, argv = process12.argv.slice(2)) {
1071
1078
  const version = cli.version ?? packageVersion();
1072
1079
  if (argv[0] === COMPLETE)
1073
1080
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1094,7 +1101,7 @@ function commandPath(scope, argv) {
1094
1101
  }
1095
1102
  return path.length === 0 ? undefined : path.join(" ");
1096
1103
  }
1097
- async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
1104
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1098
1105
  if (argv[0] === COMPLETE)
1099
1106
  return printCandidates(leafCandidates(run, argv.slice(1)));
1100
1107
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1114,6 +1121,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process9.ar
1114
1121
  }
1115
1122
  return code;
1116
1123
  }
1124
+ // ../kit/src/folders.ts
1125
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1117
1126
  // ../kit/src/secrets.ts
1118
1127
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1119
1128
  // ../kit/src/sessions.ts
@@ -1121,13 +1130,13 @@ var {Glob } = globalThis.Bun;
1121
1130
  var SESSION_FILES = new Glob("*.json");
1122
1131
  var ACCOUNT_DIRS = new Glob("*/sessions");
1123
1132
  // src/proof.ts
1124
- import process12 from "process";
1133
+ import process15 from "process";
1125
1134
 
1126
1135
  // src/worktree.ts
1127
- import { cpSync, existsSync, lstatSync, mkdirSync as mkdirSync2, mkdtempSync, readdirSync, realpathSync as realpathSync2, rmSync, symlinkSync, unlinkSync } from "fs";
1136
+ import { cpSync, existsSync as existsSync3, lstatSync, mkdirSync as mkdirSync2, mkdtempSync, readdirSync, realpathSync as realpathSync2, rmSync, symlinkSync, unlinkSync } from "fs";
1128
1137
  import { tmpdir } from "os";
1129
- import { basename, dirname as dirname3, isAbsolute as isAbsolute2, join as join3, relative, resolve, sep } from "path";
1130
- import process11 from "process";
1138
+ import { basename, dirname as dirname4, isAbsolute as isAbsolute2, join as join6, relative, resolve as resolve3, sep } from "path";
1139
+ import process14 from "process";
1131
1140
  var WHITESPACE = /\s/;
1132
1141
  var ORIGIN_PREFIX = /^origin\//;
1133
1142
  var ENV_FILE = /^\.env(?:\..+)?$/;
@@ -1175,21 +1184,21 @@ async function defaultProofRef(root) {
1175
1184
  function keptPaths(root, cwd, paths) {
1176
1185
  const realRoot = realpathSync2(root);
1177
1186
  return paths.map((path) => {
1178
- const absolute = resolve(cwd, path);
1179
- if (!existsSync(dirname3(absolute)))
1187
+ const absolute = resolve3(cwd, path);
1188
+ if (!existsSync3(dirname4(absolute)))
1180
1189
  fail(`--keep ${path}: no such file`);
1181
- const inRepo = relative(realRoot, join3(realpathSync2(dirname3(absolute)), basename(absolute)));
1190
+ const inRepo = relative(realRoot, join6(realpathSync2(dirname4(absolute)), basename(absolute)));
1182
1191
  if (inRepo === "" || inRepo === ".." || inRepo.startsWith(PARENT) || isAbsolute2(inRepo))
1183
1192
  fail(`--keep ${path} is outside the repository`);
1184
- if (!existsSync(absolute))
1193
+ if (!existsSync3(absolute))
1185
1194
  fail(`--keep ${path}: no such file`);
1186
1195
  return inRepo;
1187
1196
  });
1188
1197
  }
1189
1198
  function checkNoSymlink(dir, path) {
1190
1199
  let current = dir;
1191
- for (const part of dirname3(path).split(sep)) {
1192
- current = join3(current, part);
1200
+ for (const part of dirname4(path).split(sep)) {
1201
+ current = join6(current, part);
1193
1202
  if (lstatSync(current, { throwIfNoEntry: false })?.isSymbolicLink() === true)
1194
1203
  fail(`--keep ${path} goes through the symlink ${relative(dir, current)} of the ref, which would write outside the worktree`);
1195
1204
  }
@@ -1205,10 +1214,10 @@ async function linkedEntries(root) {
1205
1214
  }).map((entry) => entry.replace(TRAILING_SLASH, ""));
1206
1215
  }
1207
1216
  async function addWorktree(root, sha) {
1208
- const dir = join3(mkdtempSync(join3(tmpdir(), "base-")), basename(root));
1217
+ const dir = join6(mkdtempSync(join6(tmpdir(), "base-")), basename(root));
1209
1218
  const ran = await git2(["worktree", "add", "--detach", dir, sha], root);
1210
1219
  if (ran.code !== 0) {
1211
- rmSync(dirname3(dir), { recursive: true, force: true });
1220
+ rmSync(dirname4(dir), { recursive: true, force: true });
1212
1221
  fail(`git worktree add failed:
1213
1222
  ${ran.text.trim()}`);
1214
1223
  }
@@ -1217,41 +1226,41 @@ ${ran.text.trim()}`);
1217
1226
  function copyKept(root, dir, paths) {
1218
1227
  for (const path of paths) {
1219
1228
  checkNoSymlink(dir, path);
1220
- const target = join3(dir, path);
1229
+ const target = join6(dir, path);
1221
1230
  rmSync(target, { recursive: true, force: true });
1222
- mkdirSync2(dirname3(target), { recursive: true });
1223
- cpSync(join3(root, path), target, { recursive: true });
1231
+ mkdirSync2(dirname4(target), { recursive: true });
1232
+ cpSync(join6(root, path), target, { recursive: true });
1224
1233
  }
1225
1234
  }
1226
1235
  function linkEntries(root, dir, entries) {
1227
1236
  const links = [];
1228
1237
  for (const entry of entries) {
1229
- const link = join3(dir, entry);
1230
- if (existsSync(link))
1238
+ const link = join6(dir, entry);
1239
+ if (existsSync3(link))
1231
1240
  continue;
1232
- mkdirSync2(dirname3(link), { recursive: true });
1241
+ mkdirSync2(dirname4(link), { recursive: true });
1233
1242
  if (basename(entry) === "node_modules" && hasWorkspaceLinks(root, entry)) {
1234
1243
  links.push(...linkModules(root, dir, entry));
1235
1244
  continue;
1236
1245
  }
1237
- symlinkSync(join3(root, entry), link);
1246
+ symlinkSync(join6(root, entry), link);
1238
1247
  links.push(link);
1239
1248
  }
1240
1249
  return links;
1241
1250
  }
1242
1251
  function moduleLinks(root, folder) {
1243
1252
  const found = [];
1244
- for (const entry of readdirSync(join3(root, folder), { withFileTypes: true })) {
1253
+ for (const entry of readdirSync(join6(root, folder), { withFileTypes: true })) {
1245
1254
  if (entry.isSymbolicLink())
1246
- found.push({ path: join3(folder, entry.name), name: entry.name });
1255
+ found.push({ path: join6(folder, entry.name), name: entry.name });
1247
1256
  else if (entry.isDirectory() && entry.name.startsWith("@"))
1248
- found.push(...moduleLinks(root, join3(folder, entry.name)));
1257
+ found.push(...moduleLinks(root, join6(folder, entry.name)));
1249
1258
  }
1250
1259
  return found;
1251
1260
  }
1252
1261
  function workspaceTarget(root, path) {
1253
1262
  try {
1254
- const inRepo = relative(realpathSync2(root), realpathSync2(join3(root, path)));
1263
+ const inRepo = relative(realpathSync2(root), realpathSync2(join6(root, path)));
1255
1264
  return inRepo === "" || inRepo.startsWith(PARENT) || inRepo.split(sep).includes("node_modules") ? undefined : inRepo;
1256
1265
  } catch {
1257
1266
  return;
@@ -1262,16 +1271,16 @@ function hasWorkspaceLinks(root, folder) {
1262
1271
  }
1263
1272
  function linkModules(root, dir, folder) {
1264
1273
  const links = [];
1265
- mkdirSync2(join3(dir, folder), { recursive: true });
1266
- for (const entry of readdirSync(join3(root, folder), { withFileTypes: true })) {
1267
- const path = join3(folder, entry.name);
1268
- const link = join3(dir, path);
1274
+ mkdirSync2(join6(dir, folder), { recursive: true });
1275
+ for (const entry of readdirSync(join6(root, folder), { withFileTypes: true })) {
1276
+ const path = join6(folder, entry.name);
1277
+ const link = join6(dir, path);
1269
1278
  if (entry.isDirectory() && entry.name.startsWith("@")) {
1270
1279
  links.push(...linkModules(root, dir, path));
1271
1280
  continue;
1272
1281
  }
1273
1282
  const workspace = entry.isSymbolicLink() ? workspaceTarget(root, path) : undefined;
1274
- symlinkSync(workspace === undefined ? join3(root, path) : join3(dir, workspace), link);
1283
+ symlinkSync(workspace === undefined ? join6(root, path) : join6(dir, workspace), link);
1275
1284
  links.push(link);
1276
1285
  }
1277
1286
  return links;
@@ -1281,9 +1290,9 @@ async function sweepStale(root) {
1281
1290
  for (const name of readdirSync(tmpdir())) {
1282
1291
  if (!BASE_DIR.test(name))
1283
1292
  continue;
1284
- const path = join3(tmpdir(), name);
1293
+ const path = join6(tmpdir(), name);
1285
1294
  const stat = lstatSync(path, { throwIfNoEntry: false });
1286
- if (stat?.isDirectory() === true && stat.uid === process11.getuid?.() && Date.now() - stat.mtimeMs > STALE_AFTER)
1295
+ if (stat?.isDirectory() === true && stat.uid === process14.getuid?.() && Date.now() - stat.mtimeMs > STALE_AFTER)
1287
1296
  rmSync(path, { recursive: true, force: true });
1288
1297
  }
1289
1298
  await git2(["worktree", "prune"], root);
@@ -1294,7 +1303,7 @@ async function removeWorktree(root, dir, links) {
1294
1303
  unlinkSync(link);
1295
1304
  }
1296
1305
  await git2(["worktree", "remove", "--force", dir], root);
1297
- rmSync(dirname3(dir), { recursive: true, force: true });
1306
+ rmSync(dirname4(dir), { recursive: true, force: true });
1298
1307
  await git2(["worktree", "prune"], root);
1299
1308
  }
1300
1309
  function shellCommand(given) {
@@ -1342,8 +1351,8 @@ async function inWorktree(options, body) {
1342
1351
  try {
1343
1352
  copyKept(root, dir, kept);
1344
1353
  links = link ? linkEntries(root, dir, await linkedEntries(root)) : [];
1345
- const runDir = join3(dir, prefix);
1346
- if (!existsSync(runDir))
1354
+ const runDir = join6(dir, prefix);
1355
+ if (!existsSync3(runDir))
1347
1356
  fail(`${prefix} does not exist at ${ref}`);
1348
1357
  return await body(runDir, signals);
1349
1358
  } finally {
@@ -1403,7 +1412,7 @@ ${USAGE}`);
1403
1412
  if (runsInContainer(given))
1404
1413
  fail("a container of the compose project mounts the main checkout, not the temporary worktree, so the command would not run at the ref: run the tool on the host, or check the ref out by hand");
1405
1414
  const command = shellCommand(given);
1406
- const cwd = process12.cwd();
1415
+ const cwd = process15.cwd();
1407
1416
  const { root, prefix } = await checkout(cwd);
1408
1417
  const runs = wholeNumber(parsed.values.runs, "runs", 1, 1);
1409
1418
  const ref = parsed.values.ref ?? await defaultProofRef(root);
@@ -1438,7 +1447,7 @@ ${folded(run.output)}`}`);
1438
1447
  printJson({ outcome, proved, ref, sha, before: { code: before.code, output: before.output }, now: { code: now.code, output: now.output }, runs: nowRuns.map((run) => ({ code: run.code })) });
1439
1448
  return proved ? 0 : 1;
1440
1449
  }
1441
- console.log(message);
1450
+ console.log(role(proved ? "ok" : "problem", process15.stdout)(message));
1442
1451
  if (runs > 1)
1443
1452
  console.log(`now: ${codes.map((code, i) => `run ${i + 1} ${code === 0 ? "passed" : `failed (exit ${code})`}`).join(", ")}`);
1444
1453
  const shown = side === "before" ? before : now;
@@ -1449,4 +1458,4 @@ ${folded(shown.output)}`);
1449
1458
  }
1450
1459
 
1451
1460
  // src/proof-cli.ts
1452
- process13.exitCode = await runMain({ name: "proof", run: proof });
1461
+ process16.exitCode = await runMain({ name: "proof", run: proof });