@kaynooo/cli-guard 0.9.1 → 0.11.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 (2) hide show
  1. package/dist/cli.js +126 -307
  2. package/package.json +8 -8
package/dist/cli.js CHANGED
@@ -1,294 +1,112 @@
1
- #!/usr/bin/env -S bun --no-env-file
1
+ #!/usr/bin/env -S bun --no-env-file --config=/dev/null
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
5
  import { appendFileSync as appendFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, statSync, writeFileSync } from "fs";
6
6
  import { homedir as homedir2 } from "os";
7
7
  import { dirname as dirname4 } from "path";
8
- import process11 from "process";
8
+ import process12 from "process";
9
9
  // ../kit/src/args.ts
10
- import process5 from "process";
10
+ import process6 from "process";
11
11
  import { parseArgs } from "util";
12
12
 
13
- // ../kit/src/style.ts
13
+ // ../kit/src/mode.ts
14
14
  import process2 from "process";
15
-
16
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
17
- function x(s) {
18
- let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
19
- if (!/^[a-f0-9]+$/.test(r))
20
- return [0, 0, 0];
21
- let t = r.length, n = (c) => Number.parseInt(c, 16);
22
- if (t === 3 || t === 4) {
23
- 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;
24
- return g !== undefined ? [c, u, h, g] : [c, u, h];
25
- }
26
- if (t !== 6 && t !== 8)
27
- throw Error(`Invalid hex color length: ${t}`);
28
- 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;
29
- if ([a, b, o].some(Number.isNaN) || y !== undefined && Number.isNaN(y))
30
- throw Error(`Invalid hex color value: ${s}`);
31
- return y !== undefined ? [a, b, o, y] : [a, b, o];
32
- }
33
- function A(s) {
34
- let [r, t, n, a] = s;
35
- if (a)
36
- return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
37
- return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
38
- }
39
- function R(s, r, t) {
40
- s = (s % 360 + 360) % 360, t /= 100;
41
- let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
42
- let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
43
- return Math.round(255 * y);
44
- };
45
- return [a(0), a(8), a(4)];
46
- }
47
- function k(s) {
48
- let [r, t, n] = s;
49
- r /= 255, t /= 255, n /= 255;
50
- let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
51
- if (a !== b) {
52
- let u = a - b;
53
- if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
54
- o = (t - n) / u + (t < n ? 6 : 0);
55
- else if (a === t)
56
- o = (n - r) / u + 2;
57
- else
58
- o = (r - t) / u + 4;
59
- o /= 6;
60
- }
61
- return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
62
- }
63
- function H(s, r, t) {
64
- s = (s % 360 + 360) % 360, r /= 100, t /= 100;
65
- let n = (a) => {
66
- let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
67
- return Math.round(255 * o);
68
- };
69
- return [n(5), n(3), n(1)];
70
- }
71
- function f(s) {
72
- let [r, t, n] = s;
73
- r /= 255, t /= 255, n /= 255;
74
- 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;
75
- if (o !== 0) {
76
- if (a === r)
77
- y = (t - n) / o + (t < n ? 6 : 0);
78
- else if (a === t)
79
- y = (n - r) / o + 2;
80
- else
81
- y = (r - t) / o + 4;
82
- y /= 6;
83
- }
84
- return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
85
- }
86
- function O(s) {
87
- let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
88
- if (a === 1)
89
- return [0, 0, 0, 100];
90
- let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
91
- return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
92
- }
93
- function v(s, r, t, n) {
94
- 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))];
95
- }
96
- var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
97
- var p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055;
98
- var i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
99
- function T(s) {
100
- 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);
101
- 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)];
102
- }
103
- function M(s, r, t) {
104
- 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)));
105
- return [u(o), u(y), u(c)];
106
- }
107
- function d(s) {
108
- let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
109
- return [i(r, 4), i(a, 4), i(b, 2)];
110
- }
111
- function C(s, r, t) {
112
- let n = t * Math.PI / 180;
113
- return M(s, r * Math.cos(n), r * Math.sin(n));
114
- }
115
- function l(s) {
116
- let r = s / 255;
117
- return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
118
29
  }
119
30
 
120
- class e {
121
- r;
122
- g;
123
- b;
124
- a;
125
- constructor(s, r, t, n = 1) {
126
- this.r = s, this.g = r, this.b = t, this.a = n;
127
- }
128
- static from(s, r) {
129
- if (s === "hex") {
130
- let [t, n, a, b] = x(r);
131
- return new e(t, n, a, b);
132
- }
133
- if (s === "rgb") {
134
- if (Array.isArray(r)) {
135
- let [o, y, c, u] = r;
136
- return new e(o, y, c, u);
137
- }
138
- let { r: t, g: n, b: a, a: b } = r;
139
- return new e(t, n, a, b);
140
- }
141
- if (s === "hsl") {
142
- let t, n, a, b;
143
- if (Array.isArray(r))
144
- [t, n, a, b] = r;
145
- else
146
- ({ h: t, s: n, l: a, a: b } = r);
147
- let [o, y, c] = R(t, n, a);
148
- return new e(o, y, c, b);
149
- }
150
- if (s === "hsv") {
151
- let t, n, a, b;
152
- if (Array.isArray(r))
153
- [t, n, a, b] = r;
154
- else
155
- ({ h: t, s: n, v: a, a: b } = r);
156
- let [o, y, c] = H(t, n, a);
157
- return new e(o, y, c, b);
158
- }
159
- if (s === "cmyk") {
160
- let t, n, a, b, o;
161
- if (Array.isArray(r))
162
- [t, n, a, b, o] = r;
163
- else
164
- ({ c: t, m: n, y: a, k: b, a: o } = r);
165
- let [y, c, u] = v(t, n, a, b);
166
- return new e(y, c, u, o);
167
- }
168
- if (s === "oklch") {
169
- let t, n, a, b;
170
- if (Array.isArray(r))
171
- [t, n, a, b] = r;
172
- else
173
- ({ l: t, c: n, h: a, a: b } = r);
174
- let [o, y, c] = C(t, n, a);
175
- return new e(o, y, c, b);
176
- }
177
- if (s === "oklab") {
178
- let t, n, a, b;
179
- if (Array.isArray(r))
180
- [t, n, a, b] = r;
181
- else
182
- ({ l: t, a: n, b: a, alpha: b } = r);
183
- let [o, y, c] = M(t, n, a);
184
- return new e(o, y, c, b);
185
- }
186
- throw Error("Invalid input");
187
- }
188
- to(s) {
189
- switch (s) {
190
- case "rgb":
191
- return [this.r, this.g, this.b];
192
- case "rgba":
193
- return [this.r, this.g, this.b, this.a];
194
- case "hex":
195
- return A([this.r, this.g, this.b]);
196
- case "hexa":
197
- return A([this.r, this.g, this.b, this.a]);
198
- case "hsl":
199
- return k([this.r, this.g, this.b]);
200
- case "hsla":
201
- return [...k([this.r, this.g, this.b]), this.a];
202
- case "hsv":
203
- return f([this.r, this.g, this.b]);
204
- case "hsva":
205
- return [...f([this.r, this.g, this.b]), this.a];
206
- case "cmyk":
207
- return O([this.r, this.g, this.b]);
208
- case "cmyka":
209
- return [...O([this.r, this.g, this.b]), this.a];
210
- case "oklch":
211
- return d([this.r, this.g, this.b]);
212
- case "oklcha":
213
- return [...d([this.r, this.g, this.b]), this.a];
214
- case "oklab":
215
- return T([this.r, this.g, this.b]);
216
- case "oklaba":
217
- return [...T([this.r, this.g, this.b]), this.a];
218
- default:
219
- return [this.r, this.g, this.b];
220
- }
221
- }
222
- getLuminance() {
223
- let s = l(this.r), r = l(this.g), t = l(this.b);
224
- return 0.2126 * s + 0.7152 * r + 0.0722 * t;
225
- }
226
- contrastRatio(s) {
227
- let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
228
- return (n + 0.05) / (a + 0.05);
229
- }
230
- bestContrastForeground() {
231
- let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
232
- return t >= n ? s : r;
233
- }
234
- }
31
+ // ../kit/src/style.ts
32
+ import process3 from "process";
235
33
 
236
- // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
237
- var r = 39;
238
- var o = 49;
239
- var f2 = "\x1B[";
240
- 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") => {
241
- let [a, l, s] = e.from("hex", i).to("rgb");
242
- return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
243
- }, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
244
- var b = new Set(["", "1", "2", "3", "true"]);
245
- function h(i, n = globalThis.process?.env ?? {}) {
246
- if (n.FORCE_COLOR !== undefined)
247
- return b.has(n.FORCE_COLOR);
248
- if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
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))
39
+ return [0, 0, 0];
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")
249
55
  return false;
250
- return i?.isTTY === true;
251
- }
252
- function d2(i, n, a) {
253
- if (!h(a.stream ?? globalThis.process?.stdout, a.env))
254
- return n;
255
- let l = "", s = "";
256
- for (let g = 0, y = i.length;g < y; g++) {
257
- let [c, p] = i[g];
258
- l += `${f2}${c}m`, s = `${f2}${p}m${s}`;
259
- }
260
- return l + n + s;
261
- }
262
- function u(i, n = []) {
263
- return new Proxy((l) => d2(n, l, i), { get(l, s) {
264
- let g = C2[s];
265
- if (Array.isArray(g))
266
- return u(i, [...n, g]);
267
- if (typeof g === "function")
268
- return (...y) => u(i, [...n, g(...y)]);
269
- throw Error(`Unknown style: ${String(s)}`);
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)}`);
270
82
  } });
271
83
  }
272
- function le(i = {}) {
273
- return u(i);
84
+ function Fe(r = {}) {
85
+ return f(r);
274
86
  }
275
- var t = le();
87
+ var o = Fe();
88
+
89
+ // ../kit/src/theme.ts
90
+ var ENDS = new Map;
91
+ 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"]);
92
+ var MAX_FILE_BYTES = 64 * 1024;
93
+ var warned = new Set;
276
94
 
277
95
  // ../kit/src/style.ts
278
- function takesControlCodes(stream, env = process2.env) {
279
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
280
- }
281
- function paint(stream, env = process2.env) {
282
- return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
283
- }
284
- var STATUSES = {
285
- passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
286
- failed: { symbol: "\u2717", words: ["failed", "failure", "error", "errored"], paint: (colors) => colors.red },
287
- running: { symbol: "\u25CF", words: ["running", "in_progress", "started"], paint: (colors) => colors.cyan },
288
- queued: { symbol: "\u25CB", words: ["queued", "waiting", "pending", "created", "blocked", "scheduled"], paint: (colors) => colors.yellow },
289
- skipped: { symbol: "-", words: ["skipped", "cancelled", "canceled", "manual"], paint: (colors) => colors.dim }
96
+ function takesControlCodes(stream, env = process3.env) {
97
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
98
+ }
99
+ function paint(stream, env = process3.env) {
100
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
101
+ }
102
+ var STATUS_WORDS = {
103
+ passed: ["passed", "success", "succeeded", "ok"],
104
+ failed: ["failed", "failure", "error", "errored"],
105
+ running: ["running", "in_progress", "started", "holding"],
106
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
107
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
290
108
  };
291
- var STATUS_OF = new Map(Object.entries(STATUSES).flatMap(([status, { words }]) => words.map((word) => [word, status])));
109
+ var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
292
110
 
293
111
  // ../kit/src/format.ts
294
112
  function upTo(text, separator) {
@@ -298,27 +116,27 @@ function upTo(text, separator) {
298
116
  var ESCAPE = String.fromCharCode(27);
299
117
 
300
118
  // ../kit/src/help.ts
301
- import process3 from "process";
119
+ import process4 from "process";
302
120
  var OPTIONAL = /\[[^\]]+\]/g;
303
121
  var USAGE_PREFIX = /^usage:\s*/i;
304
122
  var FULL_STOP = /\.$/;
305
- function usageLine(usage, colors = paint(process3.stdout)) {
123
+ function usageLine(usage, colors = paint(process4.stdout)) {
306
124
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
307
125
  }
308
- function helpText(usage, options, colors = paint(process3.stdout), { examples = [], replaces, exits = [] } = {}) {
126
+ function helpText(usage, options, colors = paint(process4.stdout), { examples = [], replaces, exits = [] } = {}) {
309
127
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
310
128
  `);
311
129
  }
312
- function exitRows(exits, colors = paint(process3.stdout)) {
130
+ function exitRows(exits, colors = paint(process4.stdout)) {
313
131
  if (exits.length === 0)
314
132
  return [];
315
133
  const width = Math.max(...exits.map(([code]) => String(code).length));
316
134
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
317
135
  }
318
- function replacesRows(replaces, colors = paint(process3.stdout)) {
319
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
136
+ function replacesRows(replaces, colors = paint(process4.stdout)) {
137
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
320
138
  }
321
- function wantsHelpJson(env = process3.env) {
139
+ function wantsHelpJson(env = process4.env) {
322
140
  return env.KIT_HELP === "json";
323
141
  }
324
142
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -337,12 +155,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
337
155
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
338
156
  };
339
157
  }
340
- function exampleRows(examples, colors = paint(process3.stdout)) {
341
- if (examples.length === 0)
158
+ function exampleRows(examples, colors = paint(process4.stdout)) {
159
+ if (examples.length === 0 || outputMode() === "agent")
342
160
  return [];
343
161
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
344
162
  }
345
- function optionRows(options, colors = paint(process3.stdout)) {
163
+ function optionRows(options, colors = paint(process4.stdout)) {
346
164
  const rows = Object.entries(options).map(([name, option]) => {
347
165
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
348
166
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -374,10 +192,10 @@ function closest(name, names) {
374
192
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
375
193
  }
376
194
  // ../kit/src/input.ts
377
- import process4 from "process";
195
+ import process5 from "process";
378
196
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
379
197
  if (path === "-") {
380
- if (process4.stdin.isTTY)
198
+ if (process5.stdin.isTTY)
381
199
  fail(noStdin);
382
200
  return Bun.stdin.text();
383
201
  }
@@ -392,7 +210,6 @@ var DASHES = /^-+/;
392
210
  function jsonOption(holds) {
393
211
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
394
212
  }
395
-
396
213
  class Exit extends Error {
397
214
  code;
398
215
  hint;
@@ -436,7 +253,7 @@ var OUTPUT_OPTIONS = {
436
253
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
437
254
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
438
255
  };
439
- function applyOutput(color, plain, env = process5.env) {
256
+ function applyOutput(color, plain, env = process6.env) {
440
257
  const when = plain === true ? "never" : color ?? "auto";
441
258
  if (when === "auto")
442
259
  return;
@@ -607,7 +424,7 @@ function nearestOption(message, options, allowNegative) {
607
424
  }
608
425
  // ../kit/src/process.ts
609
426
  import { constants } from "os";
610
- import process6 from "process";
427
+ import process7 from "process";
611
428
  var KILL_GRACE_MS = 2000;
612
429
  function exitCodeOf(code, signal) {
613
430
  if (code !== null)
@@ -627,7 +444,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
627
444
  return;
628
445
  try {
629
446
  if (grouped)
630
- process6.kill(-proc.pid, killing);
447
+ process7.kill(-proc.pid, killing);
631
448
  else
632
449
  proc.kill(killing);
633
450
  } catch {}
@@ -703,13 +520,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
703
520
  // ../kit/src/cli.ts
704
521
  import { readFileSync, realpathSync } from "fs";
705
522
  import { dirname as dirname2, join as join2 } from "path";
706
- import process8 from "process";
523
+ import process9 from "process";
707
524
 
708
525
  // ../kit/src/usage.ts
709
526
  import { appendFileSync, mkdirSync } from "fs";
710
527
  import { homedir } from "os";
711
528
  import { dirname, isAbsolute, join } from "path";
712
- import process7 from "process";
529
+ import process8 from "process";
713
530
 
714
531
  // ../kit/src/logs.ts
715
532
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -723,14 +540,14 @@ var usageError;
723
540
  function noteUsageError(message) {
724
541
  usageError = message;
725
542
  }
726
- function stateHome(env = process7.env) {
543
+ function stateHome(env = process8.env) {
727
544
  const dir = env.XDG_STATE_HOME;
728
545
  return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
729
546
  }
730
- function usagePath(env = process7.env) {
547
+ function usagePath(env = process8.env) {
731
548
  return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
732
549
  }
733
- function usageRecorded(env = process7.env) {
550
+ function usageRecorded(env = process8.env) {
734
551
  const off = env.KAYNOOO_CLI_NO_USAGE;
735
552
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
736
553
  }
@@ -744,7 +561,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
744
561
  usageError = undefined;
745
562
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
746
563
  }
747
- function recordUsage(entry, env = process7.env) {
564
+ function recordUsage(entry, env = process8.env) {
748
565
  if (!usageRecorded(env))
749
566
  return;
750
567
  try {
@@ -835,8 +652,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
835
652
  `);
836
653
  }
837
654
  function printError(prefix, message, hint, cause) {
838
- const colors = paint(process8.stderr);
839
- const styled = takesControlCodes(process8.stderr);
655
+ const colors = paint(process9.stderr);
656
+ const styled = takesControlCodes(process9.stderr);
840
657
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
841
658
  const under = (label, text, tint) => text === undefined ? "" : `
842
659
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -855,7 +672,7 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
855
672
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
856
673
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
857
674
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
858
- if (error instanceof UsageError)
675
+ if (error instanceof Exit && error.code === 2)
859
676
  noteUsageError(error.message);
860
677
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
861
678
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
@@ -879,11 +696,11 @@ async function dispatch(level, typed, { version, redact }) {
879
696
  }
880
697
  }
881
698
  if (name === undefined && level.path.length > 1) {
882
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process8.stderr));
699
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stderr));
883
700
  return 2;
884
701
  }
885
702
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
886
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process8.stdout));
703
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stdout));
887
704
  return 0;
888
705
  }
889
706
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1010,7 +827,7 @@ function packageVersion(entry = Bun.main) {
1010
827
  return "0.0.0";
1011
828
  }
1012
829
  }
1013
- async function runCli(cli, argv = process8.argv.slice(2)) {
830
+ async function runCli(cli, argv = process9.argv.slice(2)) {
1014
831
  const version = cli.version ?? packageVersion();
1015
832
  if (argv[0] === COMPLETE)
1016
833
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1037,6 +854,8 @@ function commandPath(scope, argv) {
1037
854
  }
1038
855
  return path.length === 0 ? undefined : path.join(" ");
1039
856
  }
857
+ // ../kit/src/folders.ts
858
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1040
859
  // ../kit/src/secrets.ts
1041
860
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1042
861
  // ../kit/src/sessions.ts
@@ -2104,7 +1923,7 @@ function printsTrackedEnv(program, args) {
2104
1923
  // ../env/src/files.ts
2105
1924
  var ENV_FILE = /^(?:\.env(?:\..+)?|.+\.env|\.envrc)$/;
2106
1925
  var TEMPLATE = /\.(?:example|sample|template|dist|defaults)$/;
2107
- var SKIPPED = new Set(["node_modules", ".git", "vendor"]);
1926
+ var SKIPPED = new Set([...SKIPPED_FOLDERS, ".git", ".kay"]);
2108
1927
 
2109
1928
  // ../env/src/guard-paths.ts
2110
1929
  var REDIRECT = /^\d*[<>]+&?/;
@@ -2608,7 +2427,7 @@ function wrap(command) {
2608
2427
  // ../pkg/src/added.ts
2609
2428
  import { existsSync, readdirSync, readFileSync as readFileSync2 } from "fs";
2610
2429
  import { dirname as dirname3, join as join3 } from "path";
2611
- import process10 from "process";
2430
+ import process11 from "process";
2612
2431
  var REDIRECT2 = /^\d*[<>]/;
2613
2432
  var BARE_REDIRECT = /^\d*(?:[<>]|>>)$/;
2614
2433
  var ADDS = {
@@ -2640,7 +2459,7 @@ function manifestName(folder) {
2640
2459
  }
2641
2460
  function ownPackages() {
2642
2461
  const names = new Set;
2643
- let folder = process10.cwd();
2462
+ let folder = process11.cwd();
2644
2463
  while (true) {
2645
2464
  const name = manifestName(folder);
2646
2465
  if (name !== undefined)
@@ -3918,7 +3737,7 @@ function readText(path) {
3918
3737
  return null;
3919
3738
  }
3920
3739
  }
3921
- function report(violations) {
3740
+ function report2(violations) {
3922
3741
  for (const { rule, message } of violations)
3923
3742
  console.log(`${rule}: ${message}`);
3924
3743
  }
@@ -3932,7 +3751,7 @@ ${checkUsage}`);
3932
3751
  const given = positionals[0] ?? "-";
3933
3752
  const command = given === "-" ? await readInput("-", { noStdin: "give the command, or pipe it on stdin" }) : given;
3934
3753
  const context = {
3935
- cwd: values.cwd ?? process11.cwd(),
3754
+ cwd: values.cwd ?? process12.cwd(),
3936
3755
  home: homedir2(),
3937
3756
  isPushAsked: values["push-asked"] === true,
3938
3757
  canRewrite: true,
@@ -3945,7 +3764,7 @@ ${checkUsage}`);
3945
3764
  if (values.json === true)
3946
3765
  console.log(JSON.stringify(verdict));
3947
3766
  else
3948
- report(verdict.violations);
3767
+ report2(verdict.violations);
3949
3768
  if (values.json !== true && verdict.command !== command)
3950
3769
  console.log(`runs as: ${verdict.command}${verdict.notes.map((note) => `
3951
3770
  ${note}`).join("")}`);
@@ -3961,7 +3780,7 @@ ${pathUsage}`);
3961
3780
  if (parsed.values.json === true)
3962
3781
  console.log(JSON.stringify({ violations }));
3963
3782
  else
3964
- report(violations);
3783
+ report2(violations);
3965
3784
  return violations.length > 0 ? 1 : 0;
3966
3785
  }
3967
3786
  var rulesUsage = `guard rules [--json]
@@ -4018,7 +3837,7 @@ ${hookUsage}`, 1);
4018
3837
  console.log(JSON.stringify(reply));
4019
3838
  return 0;
4020
3839
  }
4021
- process11.exitCode = await runCli({
3840
+ process12.exitCode = await runCli({
4022
3841
  name: "guard",
4023
3842
  usage: false,
4024
3843
  about: "the safety rules a Claude Code Bash call is held to, each refusal naming the route",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-guard",
3
3
  "type": "module",
4
- "version": "0.9.1",
4
+ "version": "0.11.0",
5
5
  "description": "guard: the safety rules a Claude Code Bash call is held to (git, remote machines, SQL writes, env files, package managers, commit messages), each refusal naming the route.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -36,12 +36,12 @@
36
36
  "guard": "$npm_execpath src/cli.ts"
37
37
  },
38
38
  "devDependencies": {
39
- "@kaynooo/cli-db": "0.10.0",
40
- "@kaynooo/cli-edit": "0.5.1",
41
- "@kaynooo/cli-env": "0.9.1",
42
- "@kaynooo/cli-git": "0.7.1",
43
- "@kaynooo/cli-kit": "0.21.0",
44
- "@kaynooo/cli-out": "0.8.0",
45
- "@kaynooo/cli-pkg": "0.8.0"
39
+ "@kaynooo/cli-db": "0.12.0",
40
+ "@kaynooo/cli-edit": "0.9.0",
41
+ "@kaynooo/cli-env": "0.13.0",
42
+ "@kaynooo/cli-git": "0.13.0",
43
+ "@kaynooo/cli-kit": "0.35.0",
44
+ "@kaynooo/cli-out": "0.13.0",
45
+ "@kaynooo/cli-pkg": "0.12.0"
46
46
  }
47
47
  }