@kaynooo/cli-env 0.14.0 → 0.15.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/ev.js CHANGED
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env -S bun --no-env-file --config=/dev/null
2
2
  // @bun
3
+ var __esm = (fn, res, err) => () => {
4
+ if (fn)
5
+ try {
6
+ res = fn(fn = 0);
7
+ } catch (e) {
8
+ err = [e];
9
+ }
10
+ if (err)
11
+ throw err[0];
12
+ return res;
13
+ };
3
14
 
4
- // src/ev.ts
5
- import process22 from "process";
6
- // ../kit/src/args.ts
7
- import process10 from "process";
8
- import { parseArgs } from "util";
9
-
10
- // ../kit/src/format.ts
11
- import process7 from "process";
12
-
13
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
14
- var N = new Map;
15
- var Nt = /\s+\S*$/;
16
- var Y = /\s/;
17
- function ko(t, e, r = "...") {
15
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
16
+ function Ao(t, e, r = "...") {
18
17
  let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
19
18
  if (t.length <= e)
20
19
  return t;
@@ -25,13 +24,22 @@ function ko(t, e, r = "...") {
25
24
  c = c.trimEnd();
26
25
  return s ? (c + n).slice(0, l) : c + n;
27
26
  }
28
- var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
29
- var z = new Map;
27
+ var N, Nt, Y, be, W;
28
+ var init_chunk_rkhsft4a = __esm(() => {
29
+ N = new Map;
30
+ Nt = /\s+\S*$/;
31
+ Y = /\s/;
32
+ be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
33
+ W = new Map;
34
+ });
35
+
36
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
37
+ var init_text = __esm(() => {
38
+ init_chunk_rkhsft4a();
39
+ });
30
40
 
31
41
  // ../kit/src/mode.ts
32
42
  import process2 from "process";
33
- var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
34
- var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
35
43
  function isSet(value) {
36
44
  return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
37
45
  }
@@ -48,12 +56,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
48
56
  function isInteractive(streams = process2) {
49
57
  return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
50
58
  }
59
+ var MODES, AGENT_VARIABLES;
60
+ var init_mode = __esm(() => {
61
+ MODES = new Set(["terminal", "ci", "agent", "pipe"]);
62
+ AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
63
+ });
51
64
 
52
- // ../kit/src/style.ts
53
- import process6 from "process";
54
-
55
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
56
- var G2 = /^[a-f0-9]+$/i;
65
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
57
66
  function b(r) {
58
67
  let e = r.startsWith("#") ? r.slice(1) : r;
59
68
  if (!G2.test(e))
@@ -64,11 +73,6 @@ function b(r) {
64
73
  throw Error(`Invalid hex color length: ${e.length}`);
65
74
  return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
66
75
  }
67
- 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") => {
68
- let [l, n, c] = b(r);
69
- return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
70
- }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
71
- var h = new Set(["", "1", "2", "3", "true"]);
72
76
  function C(r, e = globalThis.process?.env ?? {}) {
73
77
  if (e.FORCE_COLOR !== undefined)
74
78
  return h.has(e.FORCE_COLOR);
@@ -82,7 +86,7 @@ function f(r, e = []) {
82
86
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
83
87
  let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
84
88
  return new Proxy(c, { get(t, i) {
85
- let a = B2[i];
89
+ let a = B[i];
86
90
  if (Array.isArray(a)) {
87
91
  let s = g.get(i);
88
92
  if (s === undefined)
@@ -105,13 +109,21 @@ function f(r, e = []) {
105
109
  function Fe(r = {}) {
106
110
  return f(r);
107
111
  }
108
- var o = Fe();
112
+ var G2, B, h, o;
113
+ var init_chunk_x450vn3m = __esm(() => {
114
+ G2 = /^[a-f0-9]+$/i;
115
+ 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") => {
116
+ let [l, n, c] = b(r);
117
+ return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
118
+ }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
119
+ h = new Set(["", "1", "2", "3", "true"]);
120
+ o = Fe();
121
+ });
109
122
 
110
- // ../kit/src/theme.ts
111
- import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
112
- import { homedir as homedir2 } from "os";
113
- import { join as join3, resolve as resolve2 } from "path";
114
- import process5 from "process";
123
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
124
+ var init_colors = __esm(() => {
125
+ init_chunk_x450vn3m();
126
+ });
115
127
 
116
128
  // ../kit/src/config.ts
117
129
  import { existsSync } from "fs";
@@ -127,6 +139,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
127
139
  return;
128
140
  }
129
141
  }
142
+ var init_config = __esm(() => {
143
+ init_args();
144
+ });
130
145
 
131
146
  // ../kit/src/user-config.ts
132
147
  import { existsSync as existsSync2, readFileSync } from "fs";
@@ -158,36 +173,18 @@ function readUserConfig(bin, where = {}, legacy = []) {
158
173
  return {};
159
174
  }
160
175
  }
176
+ var init_user_config = () => {};
161
177
 
162
178
  // ../kit/src/theme.ts
163
- var ENDS = new Map;
164
- var DEFAULT = {
165
- 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" },
166
- 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" },
167
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
168
- bins: {},
169
- gradient: ["#c084fc", "#67e8f9"]
170
- };
171
- 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" };
172
- 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" };
173
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
174
- var PRESETS = {
175
- default: {},
176
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
177
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
178
- ascii: { glyphs: ASCII }
179
- };
180
- 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"]);
181
- var HEX = /^#[0-9a-f]{6}$/i;
182
- var CONTROL = /\p{Cc}/u;
183
- var MAX_FILE_BYTES = 64 * 1024;
184
- var SPACES = /\s+/;
179
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
180
+ import { homedir as homedir2 } from "os";
181
+ import { join as join3, resolve as resolve2 } from "path";
182
+ import process5 from "process";
185
183
  function isColorSpec(spec) {
186
184
  if (typeof spec === "number")
187
185
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
188
186
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
189
187
  }
190
- var CUBE = [0, 95, 135, 175, 215, 255];
191
188
  function cubeLevel(channel) {
192
189
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
193
190
  }
@@ -292,7 +289,6 @@ function applyFile(theme, file, where, warn) {
292
289
  function endsWalk(home) {
293
290
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
294
291
  }
295
- var warned = new Set;
296
292
  function warnOnce(message) {
297
293
  if (warned.has(message))
298
294
  return;
@@ -329,8 +325,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
329
325
  }
330
326
  return { theme, sources, preset };
331
327
  }
332
- var current;
333
- var currentKey = "";
334
328
  function activeTheme() {
335
329
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
336
330
  if (current === undefined || key !== currentKey) {
@@ -339,9 +333,38 @@ function activeTheme() {
339
333
  }
340
334
  return current;
341
335
  }
336
+ var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
337
+ var init_theme = __esm(() => {
338
+ init_config();
339
+ init_user_config();
340
+ ENDS = new Map;
341
+ DEFAULT = {
342
+ 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" },
343
+ 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" },
344
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
345
+ bins: {},
346
+ gradient: ["#c084fc", "#67e8f9"]
347
+ };
348
+ 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" };
349
+ 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" };
350
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
351
+ PRESETS = {
352
+ default: {},
353
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
354
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
355
+ ascii: { glyphs: ASCII }
356
+ };
357
+ 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"]);
358
+ HEX = /^#[0-9a-f]{6}$/i;
359
+ CONTROL = /\p{Cc}/u;
360
+ MAX_FILE_BYTES = 64 * 1024;
361
+ SPACES = /\s+/;
362
+ CUBE = [0, 95, 135, 175, 215, 255];
363
+ warned = new Set;
364
+ });
342
365
 
343
366
  // ../kit/src/style.ts
344
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
367
+ import process6 from "process";
345
368
  function takesControlCodes(stream, env = process6.env) {
346
369
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
347
370
  }
@@ -367,17 +390,24 @@ function role(name, stream, env = process6.env) {
367
390
  const colors = paint(stream, env);
368
391
  return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
369
392
  }
370
- var STATUS_WORDS = {
371
- passed: ["passed", "success", "succeeded", "ok"],
372
- failed: ["failed", "failure", "error", "errored"],
373
- running: ["running", "in_progress", "started", "holding"],
374
- queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
375
- skipped: ["skipped", "cancelled", "canceled", "manual"]
376
- };
377
- var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
393
+ var MARK_WORDS, STATUS_WORDS, STATUS_OF;
394
+ var init_style = __esm(() => {
395
+ init_colors();
396
+ init_mode();
397
+ init_theme();
398
+ MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
399
+ STATUS_WORDS = {
400
+ passed: ["passed", "success", "succeeded", "ok"],
401
+ failed: ["failed", "failure", "error", "errored"],
402
+ running: ["running", "in_progress", "started", "holding"],
403
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
404
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
405
+ };
406
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
407
+ });
378
408
 
379
409
  // ../kit/src/format.ts
380
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
410
+ import process7 from "process";
381
411
  function formatSeconds(total) {
382
412
  let rest = Math.max(0, Math.round(total));
383
413
  const amounts = UNITS.map(([unit, size]) => {
@@ -399,10 +429,8 @@ function upTo(text, separator) {
399
429
  return end === -1 ? text : text.slice(0, end);
400
430
  }
401
431
  function truncate(text, width) {
402
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
432
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
403
433
  }
404
- var LINE_BREAKS = /\s*\n\s*/g;
405
- var ESCAPE = String.fromCharCode(27);
406
434
  function textWidth(text) {
407
435
  return Bun.stringWidth(text);
408
436
  }
@@ -451,14 +479,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
451
479
  function printJson(value) {
452
480
  console.log(jsonText(value));
453
481
  }
482
+ var UNITS, LINE_BREAKS, ESCAPE;
483
+ var init_format = __esm(() => {
484
+ init_text();
485
+ init_mode();
486
+ init_style();
487
+ UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
488
+ LINE_BREAKS = /\s*\n\s*/g;
489
+ ESCAPE = String.fromCharCode(27);
490
+ });
454
491
 
455
492
  // ../kit/src/help.ts
456
493
  import process8 from "process";
457
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
458
- var USAGE_PREFIX = /^usage:\s*/i;
459
- var FULL_STOP = /\.$/;
460
494
  function usageLine(usage, colors = paint(process8.stdout)) {
461
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
495
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
496
+ `);
497
+ const blank = lines.indexOf("");
498
+ const synopses = blank === -1 ? lines : lines.slice(0, blank);
499
+ const details = blank === -1 ? [] : lines.slice(blank + 1);
500
+ const colon = synopses[0].indexOf(": ");
501
+ const inline = synopses[0].slice(colon + 2);
502
+ const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
503
+ if (colon !== -1)
504
+ synopses[0] = synopses[0].slice(0, colon);
505
+ const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
506
+ `)}`;
507
+ const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
508
+ const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
509
+ return [head, ...lead, ...rest].join(`
510
+ `);
511
+ }
512
+ function prose(line, colors) {
513
+ if (colors.cyan("x") === "x")
514
+ return line;
515
+ return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
462
516
  }
463
517
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
464
518
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -493,7 +547,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
493
547
  return [];
494
548
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
495
549
  }
496
- var MAX_INLINE_CHOICES = 24;
497
550
  function optionRows(options, colors = paint(process8.stdout)) {
498
551
  const rows = Object.entries(options).map(([name, option]) => {
499
552
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -508,6 +561,15 @@ function optionRows(options, colors = paint(process8.stdout)) {
508
561
  const width = Math.max(0, ...rows.map((row) => row.width));
509
562
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
510
563
  }
564
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
565
+ var init_help = __esm(() => {
566
+ init_mode();
567
+ init_style();
568
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
569
+ USAGE_PREFIX = /^usage:\s*/i;
570
+ FULL_STOP = /\.$/;
571
+ PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
572
+ });
511
573
 
512
574
  // ../kit/src/text.ts
513
575
  function distance(a, b) {
@@ -535,6 +597,8 @@ function closest(name, names) {
535
597
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
536
598
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
537
599
  }
600
+ var init_text2 = () => {};
601
+
538
602
  // ../kit/src/input.ts
539
603
  import process9 from "process";
540
604
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
@@ -548,40 +612,23 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
548
612
  fail(`no file ${path}`);
549
613
  return file.text();
550
614
  }
615
+ var init_input = __esm(() => {
616
+ init_args();
617
+ });
551
618
 
552
619
  // ../kit/src/args.ts
553
- var DASHES = /^-+/;
620
+ import process10 from "process";
621
+ import { parseArgs } from "util";
554
622
  function jsonOption(holds) {
555
623
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
556
624
  }
557
- class Exit extends Error {
558
- code;
559
- hint;
560
- constructor(message, code, hint) {
561
- super(message);
562
- this.code = code;
563
- this.hint = hint;
564
- }
565
- }
566
625
  function fail(message, code = 2, hint) {
567
626
  throw new Exit(message, code, hint);
568
627
  }
569
-
570
- class UsageError extends Exit {
571
- constructor(message, hint) {
572
- super(message, 2, hint);
573
- }
574
- }
575
628
  function badUsage(message) {
576
629
  throw new UsageError(message);
577
630
  }
578
631
 
579
- class HelpShown extends Exit {
580
- constructor() {
581
- super("help shown", 0);
582
- }
583
- }
584
-
585
632
  class Completing {
586
633
  options;
587
634
  positionals;
@@ -592,11 +639,6 @@ class Completing {
592
639
  this.candidates = candidates;
593
640
  }
594
641
  }
595
- var completion = { active: false };
596
- var OUTPUT_OPTIONS = {
597
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
598
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
599
- };
600
642
  function applyOutput(color, plain, env = process10.env) {
601
643
  const when = plain === true ? "never" : color ?? "auto";
602
644
  if (when === "auto")
@@ -750,7 +792,6 @@ function parseError(error) {
750
792
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
751
793
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
752
794
  }
753
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
754
795
  function nearestOption(message, options, allowNegative) {
755
796
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
756
797
  if (typed === undefined)
@@ -766,135 +807,757 @@ function nearestOption(message, options, allowNegative) {
766
807
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
767
808
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
768
809
  }
769
- // ../kit/src/argv.ts
770
- import { readFileSync as readFileSync3, realpathSync } from "fs";
771
- import { resolve as resolve3 } from "path";
772
- import process11 from "process";
773
- function commandLine() {
774
- try {
775
- return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
776
- } catch {
777
- return;
778
- }
810
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
811
+ var init_args = __esm(() => {
812
+ init_format();
813
+ init_help();
814
+ init_text2();
815
+ init_help();
816
+ init_input();
817
+ DASHES = /^-+/;
818
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
819
+ Exit = class Exit extends Error {
820
+ code;
821
+ hint;
822
+ [EXIT] = true;
823
+ constructor(message, code, hint) {
824
+ super(message);
825
+ this.code = code;
826
+ this.hint = hint;
827
+ }
828
+ static [Symbol.hasInstance](value) {
829
+ if (this !== Exit)
830
+ return Function.prototype[Symbol.hasInstance].call(this, value);
831
+ return typeof value === "object" && value !== null && value[EXIT] === true;
832
+ }
833
+ };
834
+ UsageError = class UsageError extends Exit {
835
+ constructor(message, hint) {
836
+ super(message, 2, hint);
837
+ }
838
+ };
839
+ HelpShown = class HelpShown extends Exit {
840
+ constructor() {
841
+ super("help shown", 0);
842
+ }
843
+ };
844
+ completion = { active: false };
845
+ OUTPUT_OPTIONS = {
846
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
847
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
848
+ };
849
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
850
+ });
851
+
852
+ // ../kit/src/folders.ts
853
+ import { homedir as homedir4 } from "os";
854
+ import { join as join6 } from "path";
855
+ import process16 from "process";
856
+ function ignoredFolders(extra = [], where = {}) {
857
+ const configured = readUserConfig("config", where).ignore;
858
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
859
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
779
860
  }
780
- function realPath(word) {
861
+ function cacheFolder({ home = homedir4(), env = process16.env } = {}) {
862
+ return env.XDG_CACHE_HOME ?? join6(home, ".cache");
863
+ }
864
+ var SKIPPED_FOLDERS;
865
+ var init_folders = __esm(() => {
866
+ init_user_config();
867
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
868
+ });
869
+
870
+ // ../kit/src/answers.ts
871
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "fs";
872
+ import { dirname as dirname7, join as join10 } from "path";
873
+ function answersFile() {
874
+ return join10(cacheFolder(), "kaynooo-cli", "answers.json");
875
+ }
876
+ function stored() {
781
877
  try {
782
- return realpathSync(resolve3(word));
878
+ const parsed = JSON.parse(readFileSync5(answersFile(), "utf-8"));
879
+ if (typeof parsed !== "object" || parsed === null)
880
+ return {};
881
+ return Object.fromEntries(Object.entries(parsed).filter((entry) => Array.isArray(entry[1]) && entry[1].every((answer) => typeof answer === "string")));
783
882
  } catch {
784
- return;
883
+ return {};
785
884
  }
786
885
  }
787
- function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), script = process11.argv[1]) {
788
- const target = script === undefined ? undefined : realPath(script) ?? script;
789
- const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
790
- const after = at === -1 ? [] : cmdline.slice(at + 1);
791
- return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
792
- }
793
- // ../kit/src/progress.ts
794
- var ESC = String.fromCharCode(27);
795
- var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
796
- var RESET_STYLE = `${ESC}[0m`;
797
- var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
798
- // ../kit/src/cli.ts
799
- import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
800
- import { dirname as dirname3, join as join5 } from "path";
801
- import process14 from "process";
802
-
803
- // ../kit/src/notify.ts
804
- import process12 from "process";
805
- var NOTIFY_AFTER_MS = 1e4;
806
- var CANCELLED = 130;
807
- function base64(text) {
808
- return Buffer.from(text).toString("base64");
809
- }
810
- function notification(title, body, env = process12.env) {
811
- const id = `kit${process12.pid}`;
812
- const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
813
- return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
886
+ function earlierAnswers(key) {
887
+ return stored()[key] ?? [];
814
888
  }
815
- function notifyEnd(command, code, ms, { stream = process12.stderr, env = process12.env } = {}) {
816
- if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
817
- return;
818
- stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
889
+ function rememberAnswer(key, answer) {
890
+ const all = stored();
891
+ const file = answersFile();
892
+ all[key] = [answer, ...(all[key] ?? []).filter((earlier) => earlier !== answer)].slice(0, KEPT);
893
+ try {
894
+ mkdirSync2(dirname7(file), { recursive: true });
895
+ writeFileSync(file, JSON.stringify(all));
896
+ } catch {}
819
897
  }
898
+ var KEPT = 50;
899
+ var init_answers = __esm(() => {
900
+ init_folders();
901
+ });
820
902
 
821
- // ../kit/src/usage.ts
822
- import { appendFileSync, mkdirSync } from "fs";
823
- import { homedir as homedir3 } from "os";
824
- import { dirname as dirname2, isAbsolute, join as join4 } from "path";
825
- import process13 from "process";
826
-
827
- // ../kit/src/logs.ts
828
- var DAY_MS = 24 * 60 * 60 * 1000;
829
- var CLI_FOLDER = "kaynooo-cli";
903
+ // ../kit/src/job.ts
904
+ import process20 from "process";
905
+ function stopJob() {
906
+ process20.kill(0, "SIGTSTP");
907
+ }
908
+ var init_job = () => {};
830
909
 
831
- // ../kit/src/usage.ts
832
- var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
833
- var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
834
- var LONGEST_NAME = 40;
835
- var usageError;
836
- function noteUsageError(message) {
837
- usageError = message;
910
+ // ../kit/src/picker/line.ts
911
+ function isEditKey(key) {
912
+ return EDIT_KEYS.has(key);
838
913
  }
839
- function stateHome(env = process13.env) {
840
- const dir = env.XDG_STATE_HOME;
841
- return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
914
+ function endsKills(key) {
915
+ return typeof key !== "object" && !isEditKey(key);
842
916
  }
843
- function usagePath(env = process13.env) {
844
- return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
917
+ function isWord(char) {
918
+ return char !== undefined && WORD_CHARACTER.test(char);
845
919
  }
846
- function usageRecorded(env = process13.env) {
847
- const off = env.KAYNOOO_CLI_NO_USAGE;
848
- return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
920
+ function wordStart(chars, from) {
921
+ let at = from;
922
+ while (at > 0 && !isWord(chars[at - 1]))
923
+ at--;
924
+ while (at > 0 && isWord(chars[at - 1]))
925
+ at--;
926
+ return at;
849
927
  }
850
- function flagNames(argv) {
851
- const end = argv.indexOf("--");
852
- const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
853
- return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
928
+ function wordEnd(chars, from) {
929
+ let at = from;
930
+ while (at < chars.length && !isWord(chars[at]))
931
+ at++;
932
+ while (at < chars.length && isWord(chars[at]))
933
+ at++;
934
+ return at;
854
935
  }
855
- function usageEntry(bin, command, argv, code, now = new Date) {
856
- const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
857
- usageError = undefined;
858
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
936
+ function spacedStart(chars, from) {
937
+ let at = from;
938
+ while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
939
+ at--;
940
+ while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
941
+ at--;
942
+ return at;
859
943
  }
860
- function recordUsage(entry, env = process13.env) {
861
- if (!usageRecorded(env))
862
- return;
863
- try {
864
- const path = usagePath(env);
865
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
866
- appendFileSync(path, `${JSON.stringify(entry)}
867
- `, { mode: 384 });
868
- } catch {}
944
+ function cut(chars, from, to) {
945
+ return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
869
946
  }
870
-
871
- // ../kit/src/cli.ts
872
- var LEVEL_OPTIONS = {
873
- ...OUTPUT_OPTIONS,
874
- help: { type: "boolean", short: "h", description: "show this help" }
875
- };
876
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
877
- async function commandRows(all, colors) {
878
- const commands = shown(all);
879
- const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
880
- const groups = new Map([["Commands:", []]]);
881
- const summaries = await Promise.all(Object.values(commands).map(async ({ summary }) => resolveSummary(summary)));
882
- for (const [index, [name, { group }]] of Object.entries(commands).entries()) {
883
- const heading = group === undefined ? "Commands:" : `${group}:`;
884
- const rows = groups.get(heading) ?? [];
885
- rows.push(` ${colors.cyan(name.padEnd(width))} ${colors.dim(summaries[index])}`);
886
- groups.set(heading, rows);
887
- }
888
- return [...groups].filter(([, rows]) => rows.length > 0).flatMap(([heading, rows], index) => [...index === 0 ? [] : [""], colors.bold(heading), ...rows]);
947
+ function insert(chars, at, text) {
948
+ const typed = [...text];
949
+ return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
889
950
  }
890
- function shown(commands) {
891
- return Object.fromEntries(Object.entries(commands).filter(([, { hidden }]) => hidden !== true));
951
+ function editLine(line, key) {
952
+ const { killed = "", chained = false } = line;
953
+ const chars = [...line.text];
954
+ const at = Math.min(Math.max(line.caret, 0), chars.length);
955
+ const edited = edit(chars, at, key, killed);
956
+ if (typeof key === "object" || !BACKWARD_KILLS.has(key) && !FORWARD_KILLS.has(key))
957
+ return line.killed === undefined ? edited : { ...edited, killed };
958
+ const taken = chars.slice(edited.caret, edited.caret + chars.length - [...edited.text].length).join("");
959
+ if (taken === "")
960
+ return { ...edited, killed, chained };
961
+ if (!chained)
962
+ return { ...edited, killed: taken, chained: true };
963
+ return { ...edited, killed: BACKWARD_KILLS.has(key) ? taken + killed : killed + taken, chained: true };
892
964
  }
893
- function takeOutputFlags(argv) {
894
- let index = 0;
895
- for (;index < argv.length; index++) {
896
- const word = argv[index];
897
- if (word === "--plain")
965
+ function edit(chars, at, key, killed) {
966
+ const text = chars.join("");
967
+ if (typeof key === "object")
968
+ return insert(chars, at, key.text);
969
+ switch (key) {
970
+ case "left":
971
+ return { text, caret: Math.max(at - 1, 0) };
972
+ case "right":
973
+ return { text, caret: Math.min(at + 1, chars.length) };
974
+ case "wordleft":
975
+ return { text, caret: wordStart(chars, at) };
976
+ case "wordright":
977
+ return { text, caret: wordEnd(chars, at) };
978
+ case "linestart":
979
+ return { text, caret: 0 };
980
+ case "lineend":
981
+ return { text, caret: chars.length };
982
+ case "erase":
983
+ return cut(chars, Math.max(at - 1, 0), at);
984
+ case "delete":
985
+ return cut(chars, at, Math.min(at + 1, chars.length));
986
+ case "word":
987
+ return cut(chars, spacedStart(chars, at), at);
988
+ case "killword":
989
+ return cut(chars, wordStart(chars, at), at);
990
+ case "killnext":
991
+ return cut(chars, at, wordEnd(chars, at));
992
+ case "clear":
993
+ return cut(chars, 0, at);
994
+ case "killend":
995
+ return cut(chars, at, chars.length);
996
+ case "yank":
997
+ return insert(chars, at, killed);
998
+ }
999
+ }
1000
+ function visible({ text, caret }, room) {
1001
+ const chars = [...text];
1002
+ const at = Math.min(Math.max(caret, 0), chars.length);
1003
+ const cells = at === chars.length ? [...chars, " "] : chars;
1004
+ const widths = cells.map((char) => Bun.stringWidth(char));
1005
+ const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
1006
+ const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
1007
+ let start = at;
1008
+ let end = at + 1;
1009
+ while (start > 0 && fits(start - 1, end))
1010
+ start--;
1011
+ while (end < cells.length && fits(start, end + 1))
1012
+ end++;
1013
+ const left = start > 0 ? "\u2026" : "";
1014
+ const right = end < cells.length ? "\u2026" : "";
1015
+ return { before: left + chars.slice(start, at).join(""), at: chars[at], after: chars.slice(at + 1, end).join("") + right, column: left.length + width(start, at) };
1016
+ }
1017
+ var EDIT_KEYS, BACKWARD_KILLS, FORWARD_KILLS, WORD_CHARACTER, SPACE;
1018
+ var init_line = __esm(() => {
1019
+ EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
1020
+ BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
1021
+ FORWARD_KILLS = new Set(["killnext", "killend"]);
1022
+ WORD_CHARACTER = /[\p{L}\p{N}_]/u;
1023
+ SPACE = /\s/;
1024
+ });
1025
+
1026
+ // ../kit/src/picker/score.ts
1027
+ var BOUNDARY_AFTER, NONE;
1028
+ var init_score = __esm(() => {
1029
+ BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
1030
+ NONE = Number.NEGATIVE_INFINITY;
1031
+ });
1032
+
1033
+ // ../kit/src/picker/state.ts
1034
+ function repeat(value, count) {
1035
+ return Array.from({ length: count }).fill(value);
1036
+ }
1037
+ function parseKeys(input, paste = { active: false }, ctrls = []) {
1038
+ const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
1039
+ return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
1040
+ const wheel = MOUSE.exec(sequence)?.[1];
1041
+ if (wheel !== undefined)
1042
+ return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
1043
+ const named = codes.get(sequence);
1044
+ const key = named === undefined ? KEYS[sequence] : { ctrl: named };
1045
+ if (sequence === PASTE_START || sequence === PASTE_END) {
1046
+ paste.active = sequence === PASTE_START;
1047
+ return [];
1048
+ }
1049
+ if (paste.active && (sequence === "\r" || sequence === `
1050
+ `))
1051
+ return [];
1052
+ if (key !== undefined)
1053
+ return [key];
1054
+ return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
1055
+ });
1056
+ }
1057
+ var IS_CONTROL, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, MOUSE, WHEEL_LINES = 3, KEYS;
1058
+ var init_state = __esm(() => {
1059
+ init_text2();
1060
+ init_line();
1061
+ init_score();
1062
+ IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
1063
+ KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
1064
+ MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
1065
+ KEYS = {
1066
+ "\x1B[A": "up",
1067
+ "\x1BOA": "up",
1068
+ "\x10": "up",
1069
+ "\x1B[B": "down",
1070
+ "\x1BOB": "down",
1071
+ "\x0E": "down",
1072
+ "\x1B[5~": "pageup",
1073
+ "\x1B[6~": "pagedown",
1074
+ "\x1B[H": "home",
1075
+ "\x1B[1~": "home",
1076
+ "\x1BOH": "home",
1077
+ "\x1B[F": "end",
1078
+ "\x1B[4~": "end",
1079
+ "\x1BOF": "end",
1080
+ "\r": "enter",
1081
+ "\n": "enter",
1082
+ "\x03": "cancel",
1083
+ "\x1B": "cancel",
1084
+ "\x1B[D": "left",
1085
+ "\x1BOD": "left",
1086
+ "\x1B[C": "right",
1087
+ "\x1BOC": "right",
1088
+ "\x1B[1;5D": "wordleft",
1089
+ "\x1B[1;3D": "wordleft",
1090
+ "\x1Bb": "wordleft",
1091
+ "\x1B[1;5C": "wordright",
1092
+ "\x1B[1;3C": "wordright",
1093
+ "\x1Bf": "wordright",
1094
+ "\x01": "linestart",
1095
+ "\x05": "lineend",
1096
+ "\x7F": "erase",
1097
+ "\x1B[3~": "delete",
1098
+ "\b": "killword",
1099
+ "\x1B\x7F": "killword",
1100
+ "\x1B[3;5~": "killnext",
1101
+ "\x1Bd": "killnext",
1102
+ "\x15": "clear",
1103
+ "\v": "killend",
1104
+ "\x17": "word",
1105
+ "\x19": "yank",
1106
+ "\x1A": "suspend",
1107
+ "\t": "tab",
1108
+ "\x1F": "help",
1109
+ "\x1BOP": "help",
1110
+ "\x1B[11~": "help"
1111
+ };
1112
+ });
1113
+
1114
+ // ../kit/src/redraw.ts
1115
+ function overwrite(lines, columns) {
1116
+ return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
1117
+ `);
1118
+ }
1119
+ function rowsTaken(lines, columns) {
1120
+ return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
1121
+ }
1122
+ var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
1123
+ var init_redraw = __esm(() => {
1124
+ init_format();
1125
+ });
1126
+
1127
+ // ../kit/src/prompt.ts
1128
+ import process21 from "process";
1129
+ function readKeys(input, paste = { active: false }) {
1130
+ return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
1131
+ }
1132
+ function roomAfter(question, columns) {
1133
+ return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
1134
+ }
1135
+ function withCaret(colors, line, room, dim = false) {
1136
+ const { before, at, after } = visible(line, room);
1137
+ const tone = dim ? colors.dim : (text) => text;
1138
+ return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
1139
+ }
1140
+ function sharedStart(texts) {
1141
+ const [first = [], ...rest] = texts.map((text) => [...text]);
1142
+ let length = first.length;
1143
+ for (const chars of rest) {
1144
+ const differs = chars.findIndex((char, index) => char !== first[index]);
1145
+ length = Math.min(length, differs === -1 ? chars.length : differs);
1146
+ }
1147
+ return first.slice(0, length).join("");
1148
+ }
1149
+ function listed2(colors, found, columns) {
1150
+ const shared = sharedStart(found);
1151
+ const cut = Math.max(shared.lastIndexOf("/"), shared.lastIndexOf(" ")) + 1;
1152
+ const names = found.slice(0, MAX_LISTED).map((each) => each.slice(cut));
1153
+ const more = found.length > MAX_LISTED ? ` \u2026 ${found.length - MAX_LISTED} more` : "";
1154
+ return ` ${colors.dim(truncate(names.join(" ") + more, Math.max(columns - 3, 1)))}`;
1155
+ }
1156
+ async function input2(question, { default: fallback, mask = false, validate, history, complete, ...settings } = {}) {
1157
+ let line = { text: "", caret: 0 };
1158
+ let invalid;
1159
+ let completions = [];
1160
+ const remembered = history === undefined || mask ? undefined : history;
1161
+ const earlier = remembered === undefined ? [] : earlierAnswers(remembered);
1162
+ let recalled = -1;
1163
+ let draft = line;
1164
+ const taken = () => line.text === "" ? fallback ?? "" : line.text;
1165
+ const shown = () => mask ? "*".repeat([...taken()].length) : taken();
1166
+ const accepted = await ask(question, settings, (colors, state, { columns }) => {
1167
+ if (state !== "asking")
1168
+ return [answer(colors, question, state, shown())];
1169
+ const typed = line.text === "" ? { text: shown(), caret: [...shown()].length } : { text: shown(), caret: line.caret };
1170
+ return [`${colors.cyan("?")} ${question} ${withCaret(colors, typed, roomAfter(question, columns), line.text === "")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`], ...completions.length > 1 ? [listed2(colors, completions, columns)] : []];
1171
+ }, (key) => {
1172
+ if (key === "cancel")
1173
+ return "cancel";
1174
+ invalid = undefined;
1175
+ completions = [];
1176
+ if (line.chained === true && endsKills(key))
1177
+ line = { ...line, chained: false };
1178
+ if (key === "tab") {
1179
+ const chars = [...line.text];
1180
+ const before = chars.slice(0, line.caret).join("");
1181
+ const found = complete?.(before) ?? [];
1182
+ const filled = sharedStart(found);
1183
+ if ([...filled].length > [...before].length)
1184
+ line = { ...line, text: filled + chars.slice(line.caret).join(""), caret: [...filled].length };
1185
+ else
1186
+ completions = found;
1187
+ return;
1188
+ }
1189
+ if (key === "enter") {
1190
+ invalid = validate?.(taken());
1191
+ return invalid === undefined ? "enter" : undefined;
1192
+ }
1193
+ if (key === "up" || key === "down") {
1194
+ const to = Math.min(Math.max(recalled + (key === "up" ? 1 : -1), -1), earlier.length - 1);
1195
+ if (recalled === -1)
1196
+ draft = line;
1197
+ recalled = to;
1198
+ const shown = to === -1 ? draft : { text: earlier[to], caret: [...earlier[to]].length };
1199
+ line = { ...shown, killed: line.killed ?? "" };
1200
+ return;
1201
+ }
1202
+ const edit = { home: "linestart", end: "lineend" }[key] ?? key;
1203
+ if (typeof edit === "object" || isEditKey(edit))
1204
+ line = editLine(line, edit);
1205
+ return;
1206
+ });
1207
+ if (!accepted)
1208
+ return;
1209
+ if (remembered !== undefined && taken() !== "")
1210
+ rememberAnswer(remembered, taken());
1211
+ return taken();
1212
+ }
1213
+ function answer(colors, question, state, picked) {
1214
+ return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1215
+ }
1216
+ async function ask(question, { hint, terminal = process21 }, render, press) {
1217
+ const { stdin, stderr } = terminal;
1218
+ if (!isInteractive(terminal))
1219
+ fail(`cannot ask "${question}" off a terminal`, 2, hint);
1220
+ const colors = paint(stderr);
1221
+ let current = "asking";
1222
+ let outcome;
1223
+ const columns = () => stderr.columns || 80;
1224
+ const draw = (state, last = false) => {
1225
+ const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
1226
+ const rows = rowsTaken(frame, columns());
1227
+ stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
1228
+ current = state;
1229
+ };
1230
+ const redraw = () => draw(current);
1231
+ const paste = { active: false };
1232
+ const stop = terminal.stop ?? (terminal === process21 ? stopJob : undefined);
1233
+ const suspend = () => {
1234
+ if (stop === undefined)
1235
+ return;
1236
+ stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
1237
+ stdin.setRawMode(false);
1238
+ stop();
1239
+ stdin.setRawMode(true);
1240
+ stderr.write("\x1B[?25l\x1B[?2004h");
1241
+ };
1242
+ try {
1243
+ stderr.on?.("resize", redraw);
1244
+ stdin.setRawMode(true);
1245
+ stdin.resume();
1246
+ stderr.write("\x1B[?25l\x1B[?2004h");
1247
+ draw("asking");
1248
+ return await new Promise((resolve) => {
1249
+ function onData(data) {
1250
+ for (const key of readKeys(data.toString(), paste)) {
1251
+ if (key === "suspend") {
1252
+ suspend();
1253
+ continue;
1254
+ }
1255
+ const pressed = press(key);
1256
+ if (pressed !== undefined) {
1257
+ settle(pressed);
1258
+ return;
1259
+ }
1260
+ }
1261
+ draw("asking");
1262
+ }
1263
+ function onEnd() {
1264
+ settle("cancel");
1265
+ }
1266
+ function settle(settled) {
1267
+ outcome = settled;
1268
+ stdin.off("data", onData);
1269
+ stdin.off("end", onEnd);
1270
+ resolve(settled === "enter");
1271
+ }
1272
+ stdin.on("data", onData);
1273
+ stdin.on("end", onEnd);
1274
+ });
1275
+ } finally {
1276
+ stderr.off?.("resize", redraw);
1277
+ draw(outcome ?? "cancel", true);
1278
+ stderr.write(`
1279
+ \x1B[?25h\x1B[?2004l`);
1280
+ stdin.setRawMode(false);
1281
+ stdin.pause();
1282
+ }
1283
+ }
1284
+ var PROMPT_KEYS, MAX_LISTED = 12;
1285
+ var init_prompt = __esm(() => {
1286
+ init_answers();
1287
+ init_args();
1288
+ init_format();
1289
+ init_job();
1290
+ init_mode();
1291
+ init_line();
1292
+ init_state();
1293
+ init_redraw();
1294
+ init_style();
1295
+ PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
1296
+ });
1297
+
1298
+ // src/ev.ts
1299
+ import process23 from "process";
1300
+
1301
+ // ../kit/src/index.ts
1302
+ init_args();
1303
+
1304
+ // ../kit/src/argv.ts
1305
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
1306
+ import { resolve as resolve3 } from "path";
1307
+ import process11 from "process";
1308
+ function commandLine() {
1309
+ try {
1310
+ return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
1311
+ } catch {
1312
+ return;
1313
+ }
1314
+ }
1315
+ function realPath(word) {
1316
+ try {
1317
+ return realpathSync(resolve3(word));
1318
+ } catch {
1319
+ return;
1320
+ }
1321
+ }
1322
+ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), script = process11.argv[1]) {
1323
+ const target = script === undefined ? undefined : realPath(script) ?? script;
1324
+ const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
1325
+ const after = at === -1 ? [] : cmdline.slice(at + 1);
1326
+ return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
1327
+ }
1328
+ // ../kit/src/chart.ts
1329
+ init_format();
1330
+ init_mode();
1331
+ init_style();
1332
+ init_theme();
1333
+ // ../kit/src/ci.ts
1334
+ init_args();
1335
+ init_format();
1336
+
1337
+ // ../kit/src/progress.ts
1338
+ init_format();
1339
+ init_style();
1340
+ init_theme();
1341
+ var ESC = String.fromCharCode(27);
1342
+ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
1343
+ var RESET_STYLE = `${ESC}[0m`;
1344
+ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
1345
+
1346
+ // ../kit/src/ci.ts
1347
+ init_style();
1348
+
1349
+ // ../kit/src/tool.ts
1350
+ init_format();
1351
+ // ../kit/src/cli.ts
1352
+ init_args();
1353
+ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1354
+ import { dirname as dirname3, join as join5 } from "path";
1355
+ import process15 from "process";
1356
+
1357
+ // ../kit/src/askpass.ts
1358
+ import process12 from "process";
1359
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1360
+ async function askpassClient(argv) {
1361
+ const socketPath = process12.env[SOCKET_VARIABLE];
1362
+ if (socketPath === undefined)
1363
+ return;
1364
+ const request = { prompt: argv[0] ?? "", ...process12.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1365
+ const { promise, resolve } = Promise.withResolvers();
1366
+ let received = "";
1367
+ try {
1368
+ await Bun.connect({
1369
+ unix: socketPath,
1370
+ socket: {
1371
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1372
+ `),
1373
+ data: (_, chunk) => {
1374
+ received += chunk.toString();
1375
+ },
1376
+ close: () => resolve(received),
1377
+ error: () => resolve("")
1378
+ }
1379
+ });
1380
+ } catch {
1381
+ return 1;
1382
+ }
1383
+ const reply = await promise;
1384
+ if (reply === "")
1385
+ return 1;
1386
+ const { answer } = JSON.parse(reply);
1387
+ if (request.notice === true)
1388
+ return 0;
1389
+ if (answer === undefined)
1390
+ return 1;
1391
+ process12.stdout.write(`${answer}
1392
+ `);
1393
+ return 0;
1394
+ }
1395
+
1396
+ // ../kit/src/completions.ts
1397
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
1398
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
1399
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
1400
+ set -l current (commandline -ct)
1401
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
1402
+ if test "$line" = __files__
1403
+ __fish_complete_path $current
1404
+ else
1405
+ echo $line
1406
+ end
1407
+ end
1408
+ end`;
1409
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
1410
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
1411
+ local -a lines
1412
+ COMPREPLY=()
1413
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
1414
+ for line in "\${lines[@]}"; do
1415
+ if [[ $line == __files__ ]]; then
1416
+ COMPREPLY+=($(compgen -f -- "$cur"))
1417
+ else
1418
+ words+="\${line%%$'\\t'*}"$'\\n'
1419
+ fi
1420
+ done
1421
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
1422
+ }`;
1423
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1424
+ local line
1425
+ local -a described plain
1426
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
1427
+ if [[ $line == __files__ ]]; then
1428
+ _files
1429
+ elif [[ $line == *$'\\t'* ]]; then
1430
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
1431
+ else
1432
+ plain+=("$line")
1433
+ fi
1434
+ done
1435
+ (( \${#described} )) && _describe -V value described
1436
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
1437
+ return 0
1438
+ }`;
1439
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1440
+ if (shell === "fish")
1441
+ return `${header}
1442
+ ${FISH_FUNCTION}
1443
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
1444
+ `).join("")}`;
1445
+ if (shell === "bash")
1446
+ return `${header}
1447
+ ${BASH_FUNCTION}
1448
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1449
+ `;
1450
+ return `${header}
1451
+ ${ZSH_FUNCTION}
1452
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1453
+ `;
1454
+ }
1455
+
1456
+ // ../kit/src/notify.ts
1457
+ init_format();
1458
+ init_mode();
1459
+ import process13 from "process";
1460
+ var NOTIFY_AFTER_MS = 1e4;
1461
+ var CANCELLED = 130;
1462
+ function base64(text) {
1463
+ return Buffer.from(text).toString("base64");
1464
+ }
1465
+ function notification(title, body, env = process13.env) {
1466
+ const id = `kit${process13.pid}`;
1467
+ const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
1468
+ return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1469
+ }
1470
+ function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1471
+ if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1472
+ return;
1473
+ stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1474
+ }
1475
+
1476
+ // ../kit/src/cli.ts
1477
+ init_style();
1478
+ init_text2();
1479
+
1480
+ // ../kit/src/usage.ts
1481
+ import { appendFileSync, mkdirSync } from "fs";
1482
+ import { homedir as homedir3 } from "os";
1483
+ import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1484
+ import process14 from "process";
1485
+
1486
+ // ../kit/src/logs.ts
1487
+ var DAY_MS = 24 * 60 * 60 * 1000;
1488
+ var CLI_FOLDER = "kaynooo-cli";
1489
+
1490
+ // ../kit/src/usage.ts
1491
+ var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
1492
+ var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
1493
+ var LONGEST_NAME = 40;
1494
+ var usageError;
1495
+ function noteUsageError(message) {
1496
+ usageError = message;
1497
+ }
1498
+ function stateHome(env = process14.env) {
1499
+ const dir = env.XDG_STATE_HOME;
1500
+ return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
1501
+ }
1502
+ function usagePath(env = process14.env) {
1503
+ return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
1504
+ }
1505
+ function usageRecorded(env = process14.env) {
1506
+ const off = env.KAYNOOO_CLI_NO_USAGE;
1507
+ return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1508
+ }
1509
+ function flagNames(argv) {
1510
+ const end = argv.indexOf("--");
1511
+ const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
1512
+ return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1513
+ }
1514
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1515
+ const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1516
+ usageError = undefined;
1517
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
1518
+ }
1519
+ function recordUsage(entry, env = process14.env) {
1520
+ if (!usageRecorded(env))
1521
+ return;
1522
+ try {
1523
+ const path = usagePath(env);
1524
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
1525
+ appendFileSync(path, `${JSON.stringify(entry)}
1526
+ `, { mode: 384 });
1527
+ } catch {}
1528
+ }
1529
+
1530
+ // ../kit/src/cli.ts
1531
+ var LEVEL_OPTIONS = {
1532
+ ...OUTPUT_OPTIONS,
1533
+ help: { type: "boolean", short: "h", description: "show this help" }
1534
+ };
1535
+ var TOP_OPTIONS = {
1536
+ ...LEVEL_OPTIONS,
1537
+ version: { type: "boolean", short: "v", description: "print the version" },
1538
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1539
+ };
1540
+ async function commandRows(all, colors) {
1541
+ const commands = shown(all);
1542
+ const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
1543
+ const groups = new Map([["Commands:", []]]);
1544
+ const summaries = await Promise.all(Object.values(commands).map(async ({ summary }) => resolveSummary(summary)));
1545
+ for (const [index, [name, { group }]] of Object.entries(commands).entries()) {
1546
+ const heading = group === undefined ? "Commands:" : `${group}:`;
1547
+ const rows = groups.get(heading) ?? [];
1548
+ rows.push(` ${colors.cyan(name.padEnd(width))} ${colors.dim(summaries[index])}`);
1549
+ groups.set(heading, rows);
1550
+ }
1551
+ return [...groups].filter(([, rows]) => rows.length > 0).flatMap(([heading, rows], index) => [...index === 0 ? [] : [""], colors.bold(heading), ...rows]);
1552
+ }
1553
+ function shown(commands) {
1554
+ return Object.fromEntries(Object.entries(commands).filter(([, { hidden }]) => hidden !== true));
1555
+ }
1556
+ function takeOutputFlags(argv) {
1557
+ let index = 0;
1558
+ for (;index < argv.length; index++) {
1559
+ const word = argv[index];
1560
+ if (word === "--plain")
898
1561
  applyOutput(undefined, true);
899
1562
  else if (word.startsWith("--color="))
900
1563
  applyOutput(word.slice("--color=".length), undefined);
@@ -947,8 +1610,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
947
1610
  `);
948
1611
  }
949
1612
  function printError(prefix, message, hint, cause) {
950
- const colors = paint(process14.stderr);
951
- const styled = takesControlCodes(process14.stderr);
1613
+ const colors = paint(process15.stderr);
1614
+ const styled = takesControlCodes(process15.stderr);
952
1615
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
953
1616
  const under = (label, text, tint) => text === undefined ? "" : `
954
1617
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -991,11 +1654,11 @@ async function dispatch(level, typed, { version, redact }) {
991
1654
  }
992
1655
  }
993
1656
  if (name === undefined && level.path.length > 1) {
994
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stderr));
1657
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process15.stderr));
995
1658
  return 2;
996
1659
  }
997
1660
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
998
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stdout));
1661
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process15.stdout));
999
1662
  return 0;
1000
1663
  }
1001
1664
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1106,6 +1769,19 @@ async function candidates(scope, defaultCommand, words, before = []) {
1106
1769
  }
1107
1770
  return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
1108
1771
  }
1772
+ var COMPLETIONS = "--completions";
1773
+ function flagValue([flag = "", ...rest]) {
1774
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1775
+ }
1776
+ function printCompletionScript(name, args) {
1777
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1778
+ if (shell === undefined || args.length !== 1) {
1779
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1780
+ return 2;
1781
+ }
1782
+ console.log(completionScript(shell, [name]).trimEnd());
1783
+ return 0;
1784
+ }
1109
1785
  async function printCandidates(found) {
1110
1786
  for (const line of await found)
1111
1787
  console.log(line);
@@ -1128,15 +1804,20 @@ function packageVersion(entry = Bun.main) {
1128
1804
  }
1129
1805
  async function runCli(cli, argv = scriptArgs()) {
1130
1806
  const version = cli.version ?? packageVersion();
1807
+ const answered = await askpassClient(argv);
1808
+ if (answered !== undefined)
1809
+ return answered;
1131
1810
  if (argv[0] === COMPLETE)
1132
1811
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
1812
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1813
+ return printCompletionScript(cli.name, flagValue(argv));
1133
1814
  const started = performance.now();
1134
1815
  const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
1135
1816
  const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
1136
1817
  notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
1137
1818
  if (cli.usage !== false) {
1138
1819
  try {
1139
- recordUsage(usageEntry(cli.name, command, argv, code));
1820
+ recordUsage(usageEntry(cli.name, command, argv, code, { ms: performance.now() - started }));
1140
1821
  } catch {}
1141
1822
  }
1142
1823
  return code;
@@ -1156,28 +1837,6 @@ function commandPath(scope, argv) {
1156
1837
  }
1157
1838
  return path.length === 0 ? undefined : path.join(" ");
1158
1839
  }
1159
- async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1160
- if (argv[0] === COMPLETE)
1161
- return printCandidates(leafCandidates(run, argv.slice(1)));
1162
- if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1163
- console.log(version ?? packageVersion());
1164
- return 0;
1165
- }
1166
- let code;
1167
- const started = performance.now();
1168
- try {
1169
- code = await run(argv);
1170
- } catch (error) {
1171
- code = reportThrown(name, error, redact, wantsJson(argv));
1172
- }
1173
- notifyEnd(name, code, performance.now() - started);
1174
- if (usage !== false) {
1175
- try {
1176
- recordUsage(usageEntry(name, undefined, argv, code));
1177
- } catch {}
1178
- }
1179
- return code;
1180
- }
1181
1840
  // ../kit/src/compose.ts
1182
1841
  async function captureOutput(argv, { cwd, env } = {}) {
1183
1842
  const run = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, env: { ...process.env, ...env }, stdin: "ignore", stdout: "pipe", stderr: "pipe" });
@@ -1187,19 +1846,28 @@ async function captureOutput(argv, { cwd, env } = {}) {
1187
1846
  async function compose(args, { flags = [], ...options } = {}) {
1188
1847
  return captureOutput(["docker", "compose", ...flags, ...args], options);
1189
1848
  }
1190
- // ../kit/src/folders.ts
1191
- import { homedir as homedir4 } from "os";
1192
- import { join as join6 } from "path";
1193
- import process15 from "process";
1194
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1195
- function ignoredFolders(extra = [], where = {}) {
1196
- const configured = readUserConfig("config", where).ignore;
1197
- const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1198
- return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1199
- }
1200
- function cacheFolder({ home = homedir4(), env = process15.env } = {}) {
1201
- return env.XDG_CACHE_HOME ?? join6(home, ".cache");
1202
- }
1849
+
1850
+ // ../kit/src/index.ts
1851
+ init_config();
1852
+
1853
+ // ../kit/src/excerpt.ts
1854
+ init_text2();
1855
+
1856
+ // ../kit/src/index.ts
1857
+ init_folders();
1858
+ init_format();
1859
+
1860
+ // ../kit/src/git.ts
1861
+ init_args();
1862
+ // ../kit/src/limit.ts
1863
+ init_args();
1864
+
1865
+ // ../kit/src/index.ts
1866
+ init_mode();
1867
+
1868
+ // ../kit/src/report.ts
1869
+ init_style();
1870
+ init_text2();
1203
1871
  // ../kit/src/secrets.ts
1204
1872
  var SECRET_PART = /token|secret|passw|credential|private|dsn|apikey|accesskey|key$/i;
1205
1873
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
@@ -1211,10 +1879,23 @@ function isSecretName(name) {
1211
1879
  var {Glob } = globalThis.Bun;
1212
1880
  var SESSION_FILES = new Glob("*.json");
1213
1881
  var ACCOUNT_DIRS = new Glob("*/sessions");
1882
+
1883
+ // ../kit/src/index.ts
1884
+ init_style();
1885
+ init_text2();
1886
+ init_theme();
1887
+ init_user_config();
1888
+
1889
+ // ../kit/src/watch.ts
1890
+ init_args();
1891
+ init_input();
1892
+ init_style();
1893
+ // ../kit/src/workspace-root.ts
1894
+ init_user_config();
1214
1895
  // src/commands/audit.ts
1215
1896
  import { stat as stat4 } from "fs/promises";
1216
1897
  import { relative, resolve as resolve4 } from "path";
1217
- import process17 from "process";
1898
+ import process18 from "process";
1218
1899
 
1219
1900
  // ../kit/src/shell.ts
1220
1901
  var SEPARATORS = new Set([`
@@ -1270,7 +1951,7 @@ var {$ } = globalThis.Bun;
1270
1951
 
1271
1952
  // src/files.ts
1272
1953
  import { chmod, chown, readdir, realpath, rename, rm, stat, writeFile } from "fs/promises";
1273
- import { basename, dirname as dirname4, join as join7 } from "path";
1954
+ import { basename, dirname as dirname4, extname, join as join7 } from "path";
1274
1955
 
1275
1956
  // src/dotenv.ts
1276
1957
  var ASSIGNMENT = /^\s*(?:export\s+)?([A-Z_][\w.-]*)\s*=(.*)$/i;
@@ -1616,11 +2297,30 @@ async function envFiles(folder = process.cwd()) {
1616
2297
  }
1617
2298
  return names.sort();
1618
2299
  }
1619
- async function readEnv(path) {
2300
+ var OTHER_FORMATS = { ".json": "JSON", ".jsonc": "JSON", ".json5": "JSON", ".yaml": "YAML", ".yml": "YAML", ".toml": "TOML", ".ini": "INI", ".xml": "XML" };
2301
+ var BLANK_OR_COMMENT = /^\s*(?:#.*)?$/;
2302
+ function notDotenv(why, redact) {
2303
+ fail(`${why}, and ev reads dotenv files (KEY=value lines)`, 2, `\`${redact}\` masks the secrets of any text`);
2304
+ }
2305
+ function assertDotenvName(path, redact = `ev redact < ${path}`) {
2306
+ const format = OTHER_FORMATS[extname(path).toLowerCase()];
2307
+ if (format !== undefined)
2308
+ notDotenv(`${path} is ${format}`, redact);
2309
+ }
2310
+ function assertDotenvText(path, dotenv, redact = `ev redact < ${path}`) {
2311
+ if (dotenv.lines.every((line) => line.key === undefined) && !dotenv.lines.every((line) => BLANK_OR_COMMENT.test(line.raw)))
2312
+ notDotenv(`${path} holds no KEY=value line, so it is not a dotenv file`, redact);
2313
+ }
2314
+ async function readEnv(path, { scanned = false } = {}) {
1620
2315
  const file = Bun.file(path);
2316
+ if (!scanned)
2317
+ assertDotenvName(path);
1621
2318
  if (!await file.exists())
1622
2319
  fail(`${path} does not exist`);
1623
- return parseDotenv(await file.text());
2320
+ const dotenv = parseDotenv(await file.text());
2321
+ if (!scanned)
2322
+ assertDotenvText(path, dotenv);
2323
+ return dotenv;
1624
2324
  }
1625
2325
  async function writeAtomic(path, text) {
1626
2326
  let target = path;
@@ -2035,11 +2735,10 @@ async function move(fix, compose, composeAfter, envBefore, envAfter) {
2035
2735
  }
2036
2736
 
2037
2737
  // src/commands/audit.ts
2038
- var usage2 = `ev audit [dir...] [--fix]
2738
+ var usage2 = `ev audit [dir...] [--fix]: lists the .env files any account can read or git tracks and the compose files writing a secret out, never printing a value
2039
2739
 
2040
- Lists the .env files any account on the machine can read or git tracks, and the compose files any account can read that write a secret out (a secret-named value or a URL password) instead of reading it from a .env, never printing a value.
2041
- Looks under each folder (the current one by default) down to 5 levels, skipping node_modules, vendor and .git, and leaves .example, .sample, .template and .dist files out. A folder it cannot read is named on stderr.
2042
- With --fix, moves each secret a listed compose file writes out into the .env beside it as \${KEY}, puts it back when \`docker compose config\` resolves differently after, and shuts other accounts out of both files and of every listed .env; a key the .env already sets to another value stays put.`;
2740
+ It looks under each folder (the current one by default) down to 5 levels, skipping \`node_modules\`, \`vendor\` and \`.git\`, and leaves \`.example\`, \`.sample\`, \`.template\` and \`.dist\` files out.
2741
+ With --fix, each secret a listed compose file writes out moves into the .env beside it as \`\${KEY}\` and goes back when \`docker compose config\` resolves differently after; a key the .env already sets to another value stays put.`;
2043
2742
  var EXITS = [[0, "it finds none (with --fix, when none is left)"], [1, "it finds one"], [2, "a usage error"]];
2044
2743
  var options = {
2045
2744
  json: jsonOption("the findings and the folders it could not read"),
@@ -2060,12 +2759,12 @@ async function isFolder(path) {
2060
2759
  }
2061
2760
  }
2062
2761
  function shown2(path) {
2063
- return path.startsWith(`${process17.cwd()}/`) ? relative(process17.cwd(), path) : path;
2762
+ return path.startsWith(`${process18.cwd()}/`) ? relative(process18.cwd(), path) : path;
2064
2763
  }
2065
2764
  async function fixAll(exposed, json) {
2066
2765
  const fixed = [];
2067
2766
  let left = false;
2068
- const tint = role("path", process17.stdout);
2767
+ const tint = role("path", process18.stdout);
2069
2768
  for (const { path, readable, group, tracked, secrets } of exposed) {
2070
2769
  const fix = secrets === undefined ? undefined : await fixCompose(path, group === true);
2071
2770
  const open = fix?.open ?? (readable && !await shutOthersOut(path, group === true) ? [path] : []);
@@ -2117,489 +2816,86 @@ async function audit2(args) {
2117
2816
  console.log("no exposed .env file nor compose file writing a secret out");
2118
2817
  return 0;
2119
2818
  }
2120
- const uid = process17.getuid?.();
2121
- const tint = role("path", process17.stdout);
2819
+ const uid = process18.getuid?.();
2820
+ const tint = role("path", process18.stdout);
2122
2821
  for (const { path, readable, group, tracked, secrets } of exposed) {
2123
2822
  const sudo = uid !== undefined && uid !== 0 && (await stat4(path)).uid !== uid ? "sudo " : "";
2124
2823
  const problems = [
2125
2824
  ...secrets === undefined ? [] : [`writes out ${secrets.join(", ")}: ev audit --fix moves the values into a .env beside it`],
2126
2825
  ...readable ? [group === true ? `readable by its group or an ACL: ${sudo}chmod go-rwx ${shellQuote(shown2(path))}` : `readable by any account: ${sudo}chmod o-rwx ${shellQuote(shown2(path))}`] : [],
2127
2826
  ...tracked ? [`tracked by git: git rm --cached ${shellQuote(shown2(path))}, then ignore it`] : []
2128
- ];
2129
- console.log(`${tint(shown2(path))}
2130
- ${problems.join(`
2131
- `)}`);
2132
- }
2133
- return 1;
2134
- }
2135
-
2136
- // src/commands/compare.ts
2137
- import process18 from "process";
2138
- var diffUsage = `ev diff <a> <b>
2139
-
2140
- Names the keys set in one file and not the other, never their values.
2141
-
2142
- --json prints {a, b, onlyA, onlyB}.`;
2143
- var DIFF_EXITS = [[0, "both set the same keys"], [1, "they differ"], [2, "a usage error"]];
2144
- var missingUsage = `ev missing [file]
2145
-
2146
- Names the keys the reference file sets that the file (.env by default) does not.
2147
-
2148
- --json prints {a, b, onlyA, onlyB} with the reference as a, so onlyA is what is missing.`;
2149
- var MISSING_EXITS = [[0, "none is missing"], [1, "some are"], [2, "a usage error"]];
2150
- var jsonFlag = { json: jsonOption() };
2151
- async function keys(path) {
2152
- return new Set(entries(await readEnv(path)).keys());
2153
- }
2154
- async function diff(args) {
2155
- const parsed = parse(args, diffUsage, jsonFlag, { exits: DIFF_EXITS });
2156
- const [a, b] = parsed.positionals;
2157
- if (a === undefined || b === undefined)
2158
- fail(`needs two files
2159
-
2160
- ${diffUsage}`);
2161
- const left = await keys(a);
2162
- const right = await keys(b);
2163
- const onlyA = [...left].filter((key) => !right.has(key));
2164
- const onlyB = [...right].filter((key) => !left.has(key));
2165
- if (parsed.values.json === true) {
2166
- printJson({ a, b, onlyA, onlyB });
2167
- return onlyA.length + onlyB.length === 0 ? 0 : 1;
2168
- }
2169
- const path = role("path", process18.stdout);
2170
- const value = role("value", process18.stdout);
2171
- const lines = [...onlyA.map((key) => `only in ${path(a)}: ${value(key)}`), ...onlyB.map((key) => `only in ${path(b)}: ${value(key)}`)];
2172
- if (lines.length === 0)
2173
- return 0;
2174
- console.log(lines.join(`
2175
- `));
2176
- return 1;
2177
- }
2178
- async function missing(args) {
2179
- const parsed = parse(args, missingUsage, { against: { type: "string", description: "the reference file (.env.example by default)" }, ...jsonFlag }, { exits: MISSING_EXITS });
2180
- const [file = ".env"] = parsed.positionals;
2181
- const against = parsed.values.against ?? ".env.example";
2182
- const have = await keys(file);
2183
- const reference = await keys(against);
2184
- const absent = [...reference].filter((key) => !have.has(key));
2185
- if (parsed.values.json === true) {
2186
- printJson({ a: against, b: file, onlyA: absent, onlyB: [...have].filter((key) => !reference.has(key)) });
2187
- return absent.length === 0 ? 0 : 1;
2188
- }
2189
- if (absent.length === 0)
2190
- return 0;
2191
- const path = role("path", process18.stdout);
2192
- const value = role("value", process18.stdout);
2193
- console.log(absent.map((key) => `${value(key)} (set in ${path(against)}, not in ${path(file)})`).join(`
2194
- `));
2195
- return 1;
2196
- }
2197
-
2198
- // ../kit/src/prompt.ts
2199
- import process20 from "process";
2200
-
2201
- // ../kit/src/answers.ts
2202
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "fs";
2203
- import { dirname as dirname7, join as join10 } from "path";
2204
- var KEPT = 50;
2205
- function answersFile() {
2206
- return join10(cacheFolder(), "kaynooo-cli", "answers.json");
2207
- }
2208
- function stored() {
2209
- try {
2210
- const parsed = JSON.parse(readFileSync5(answersFile(), "utf-8"));
2211
- if (typeof parsed !== "object" || parsed === null)
2212
- return {};
2213
- return Object.fromEntries(Object.entries(parsed).filter((entry) => Array.isArray(entry[1]) && entry[1].every((answer) => typeof answer === "string")));
2214
- } catch {
2215
- return {};
2216
- }
2217
- }
2218
- function earlierAnswers(key) {
2219
- return stored()[key] ?? [];
2220
- }
2221
- function rememberAnswer(key, answer) {
2222
- const all = stored();
2223
- const file = answersFile();
2224
- all[key] = [answer, ...(all[key] ?? []).filter((earlier) => earlier !== answer)].slice(0, KEPT);
2225
- try {
2226
- mkdirSync2(dirname7(file), { recursive: true });
2227
- writeFileSync(file, JSON.stringify(all));
2228
- } catch {}
2229
- }
2230
-
2231
- // ../kit/src/job.ts
2232
- import process19 from "process";
2233
- function stopJob() {
2234
- process19.kill(0, "SIGTSTP");
2235
- }
2236
-
2237
- // ../kit/src/picker/line.ts
2238
- var EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
2239
- var BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
2240
- var FORWARD_KILLS = new Set(["killnext", "killend"]);
2241
- function isEditKey(key) {
2242
- return EDIT_KEYS.has(key);
2243
- }
2244
- function endsKills(key) {
2245
- return typeof key !== "object" && !isEditKey(key);
2246
- }
2247
- var WORD_CHARACTER = /[\p{L}\p{N}_]/u;
2248
- var SPACE = /\s/;
2249
- function isWord(char) {
2250
- return char !== undefined && WORD_CHARACTER.test(char);
2251
- }
2252
- function wordStart(chars, from) {
2253
- let at = from;
2254
- while (at > 0 && !isWord(chars[at - 1]))
2255
- at--;
2256
- while (at > 0 && isWord(chars[at - 1]))
2257
- at--;
2258
- return at;
2259
- }
2260
- function wordEnd(chars, from) {
2261
- let at = from;
2262
- while (at < chars.length && !isWord(chars[at]))
2263
- at++;
2264
- while (at < chars.length && isWord(chars[at]))
2265
- at++;
2266
- return at;
2267
- }
2268
- function spacedStart(chars, from) {
2269
- let at = from;
2270
- while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
2271
- at--;
2272
- while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
2273
- at--;
2274
- return at;
2275
- }
2276
- function cut(chars, from, to) {
2277
- return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
2278
- }
2279
- function insert(chars, at, text) {
2280
- const typed = [...text];
2281
- return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
2282
- }
2283
- function editLine(line, key) {
2284
- const { killed = "", chained = false } = line;
2285
- const chars = [...line.text];
2286
- const at = Math.min(Math.max(line.caret, 0), chars.length);
2287
- const edited = edit(chars, at, key, killed);
2288
- if (typeof key === "object" || !BACKWARD_KILLS.has(key) && !FORWARD_KILLS.has(key))
2289
- return line.killed === undefined ? edited : { ...edited, killed };
2290
- const taken = chars.slice(edited.caret, edited.caret + chars.length - [...edited.text].length).join("");
2291
- if (taken === "")
2292
- return { ...edited, killed, chained };
2293
- if (!chained)
2294
- return { ...edited, killed: taken, chained: true };
2295
- return { ...edited, killed: BACKWARD_KILLS.has(key) ? taken + killed : killed + taken, chained: true };
2296
- }
2297
- function edit(chars, at, key, killed) {
2298
- const text = chars.join("");
2299
- if (typeof key === "object")
2300
- return insert(chars, at, key.text);
2301
- switch (key) {
2302
- case "left":
2303
- return { text, caret: Math.max(at - 1, 0) };
2304
- case "right":
2305
- return { text, caret: Math.min(at + 1, chars.length) };
2306
- case "wordleft":
2307
- return { text, caret: wordStart(chars, at) };
2308
- case "wordright":
2309
- return { text, caret: wordEnd(chars, at) };
2310
- case "linestart":
2311
- return { text, caret: 0 };
2312
- case "lineend":
2313
- return { text, caret: chars.length };
2314
- case "erase":
2315
- return cut(chars, Math.max(at - 1, 0), at);
2316
- case "delete":
2317
- return cut(chars, at, Math.min(at + 1, chars.length));
2318
- case "word":
2319
- return cut(chars, spacedStart(chars, at), at);
2320
- case "killword":
2321
- return cut(chars, wordStart(chars, at), at);
2322
- case "killnext":
2323
- return cut(chars, at, wordEnd(chars, at));
2324
- case "clear":
2325
- return cut(chars, 0, at);
2326
- case "killend":
2327
- return cut(chars, at, chars.length);
2328
- case "yank":
2329
- return insert(chars, at, killed);
2827
+ ];
2828
+ console.log(`${tint(shown2(path))}
2829
+ ${problems.join(`
2830
+ `)}`);
2330
2831
  }
2331
- }
2332
- function visible({ text, caret }, room) {
2333
- const chars = [...text];
2334
- const at = Math.min(Math.max(caret, 0), chars.length);
2335
- const cells = at === chars.length ? [...chars, " "] : chars;
2336
- const widths = cells.map((char) => Bun.stringWidth(char));
2337
- const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
2338
- const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
2339
- let start = at;
2340
- let end = at + 1;
2341
- while (start > 0 && fits(start - 1, end))
2342
- start--;
2343
- while (end < cells.length && fits(start, end + 1))
2344
- end++;
2345
- const left = start > 0 ? "\u2026" : "";
2346
- const right = end < cells.length ? "\u2026" : "";
2347
- return { before: left + chars.slice(start, at).join(""), at: chars[at], after: chars.slice(at + 1, end).join("") + right, column: left.length + width(start, at) };
2832
+ return 1;
2348
2833
  }
2349
2834
 
2350
- // ../kit/src/picker/score.ts
2351
- var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
2352
- var NONE = Number.NEGATIVE_INFINITY;
2835
+ // src/commands/compare.ts
2836
+ import process19 from "process";
2837
+ var diffUsage = `ev diff <a> <b>
2353
2838
 
2354
- // ../kit/src/picker/state.ts
2355
- var IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
2356
- var PASTE_START = "\x1B[200~";
2357
- var PASTE_END = "\x1B[201~";
2358
- var KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
2359
- var MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
2360
- var WHEEL_LINES = 3;
2361
- var KEYS = {
2362
- "\x1B[A": "up",
2363
- "\x1BOA": "up",
2364
- "\x10": "up",
2365
- "\x1B[B": "down",
2366
- "\x1BOB": "down",
2367
- "\x0E": "down",
2368
- "\x1B[5~": "pageup",
2369
- "\x1B[6~": "pagedown",
2370
- "\x1B[H": "home",
2371
- "\x1B[1~": "home",
2372
- "\x1BOH": "home",
2373
- "\x1B[F": "end",
2374
- "\x1B[4~": "end",
2375
- "\x1BOF": "end",
2376
- "\r": "enter",
2377
- "\n": "enter",
2378
- "\x03": "cancel",
2379
- "\x1B": "cancel",
2380
- "\x1B[D": "left",
2381
- "\x1BOD": "left",
2382
- "\x1B[C": "right",
2383
- "\x1BOC": "right",
2384
- "\x1B[1;5D": "wordleft",
2385
- "\x1B[1;3D": "wordleft",
2386
- "\x1Bb": "wordleft",
2387
- "\x1B[1;5C": "wordright",
2388
- "\x1B[1;3C": "wordright",
2389
- "\x1Bf": "wordright",
2390
- "\x01": "linestart",
2391
- "\x05": "lineend",
2392
- "\x7F": "erase",
2393
- "\x1B[3~": "delete",
2394
- "\b": "killword",
2395
- "\x1B\x7F": "killword",
2396
- "\x1B[3;5~": "killnext",
2397
- "\x1Bd": "killnext",
2398
- "\x15": "clear",
2399
- "\v": "killend",
2400
- "\x17": "word",
2401
- "\x19": "yank",
2402
- "\x1A": "suspend",
2403
- "\t": "tab",
2404
- "\x1F": "help",
2405
- "\x1BOP": "help",
2406
- "\x1B[11~": "help"
2407
- };
2408
- function repeat(value, count) {
2409
- return Array.from({ length: count }).fill(value);
2410
- }
2411
- function parseKeys(input, paste = { active: false }, ctrls = []) {
2412
- const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
2413
- return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
2414
- const wheel = MOUSE.exec(sequence)?.[1];
2415
- if (wheel !== undefined)
2416
- return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
2417
- const named = codes.get(sequence);
2418
- const key = named === undefined ? KEYS[sequence] : { ctrl: named };
2419
- if (sequence === PASTE_START || sequence === PASTE_END) {
2420
- paste.active = sequence === PASTE_START;
2421
- return [];
2422
- }
2423
- if (paste.active && (sequence === "\r" || sequence === `
2424
- `))
2425
- return [];
2426
- if (key !== undefined)
2427
- return [key];
2428
- return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
2429
- });
2430
- }
2839
+ Names the keys set in one file and not the other, never their values.
2431
2840
 
2432
- // ../kit/src/redraw.ts
2433
- var SYNC_START = "\x1B[?2026h";
2434
- var SYNC_END = "\x1B[?2026l";
2435
- function overwrite(lines, columns) {
2436
- return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
2437
- `);
2438
- }
2439
- function rowsTaken(lines, columns) {
2440
- return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
2441
- }
2841
+ --json prints {a, b, onlyA, onlyB}.`;
2842
+ var DIFF_EXITS = [[0, "both set the same keys"], [1, "they differ"], [2, "a usage error"]];
2843
+ var missingUsage = `ev missing [file]
2442
2844
 
2443
- // ../kit/src/prompt.ts
2444
- var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
2445
- var MAX_LISTED = 12;
2446
- function readKeys(input, paste = { active: false }) {
2447
- return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
2448
- }
2449
- function roomAfter(question, columns) {
2450
- return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
2451
- }
2452
- function withCaret(colors, line, room, dim = false) {
2453
- const { before, at, after } = visible(line, room);
2454
- const tone = dim ? colors.dim : (text) => text;
2455
- return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
2845
+ Names the keys the reference file sets that the file (.env by default) does not.
2846
+
2847
+ --json prints {a, b, onlyA, onlyB} with the reference as a, so onlyA is what is missing.`;
2848
+ var MISSING_EXITS = [[0, "none is missing"], [1, "some are"], [2, "a usage error"]];
2849
+ var jsonFlag = { json: jsonOption() };
2850
+ async function keys(path) {
2851
+ return new Set(entries(await readEnv(path)).keys());
2456
2852
  }
2457
- function sharedStart(texts) {
2458
- const [first = [], ...rest] = texts.map((text) => [...text]);
2459
- let length = first.length;
2460
- for (const chars of rest) {
2461
- const differs = chars.findIndex((char, index) => char !== first[index]);
2462
- length = Math.min(length, differs === -1 ? chars.length : differs);
2853
+ async function diff(args) {
2854
+ const parsed = parse(args, diffUsage, jsonFlag, { exits: DIFF_EXITS });
2855
+ const [a, b] = parsed.positionals;
2856
+ if (a === undefined || b === undefined)
2857
+ fail(`needs two files
2858
+
2859
+ ${diffUsage}`);
2860
+ const left = await keys(a);
2861
+ const right = await keys(b);
2862
+ const onlyA = [...left].filter((key) => !right.has(key));
2863
+ const onlyB = [...right].filter((key) => !left.has(key));
2864
+ if (parsed.values.json === true) {
2865
+ printJson({ a, b, onlyA, onlyB });
2866
+ return onlyA.length + onlyB.length === 0 ? 0 : 1;
2463
2867
  }
2464
- return first.slice(0, length).join("");
2465
- }
2466
- function listed2(colors, found, columns) {
2467
- const shared = sharedStart(found);
2468
- const cut = Math.max(shared.lastIndexOf("/"), shared.lastIndexOf(" ")) + 1;
2469
- const names = found.slice(0, MAX_LISTED).map((each) => each.slice(cut));
2470
- const more = found.length > MAX_LISTED ? ` \u2026 ${found.length - MAX_LISTED} more` : "";
2471
- return ` ${colors.dim(truncate(names.join(" ") + more, Math.max(columns - 3, 1)))}`;
2472
- }
2473
- async function input2(question, { default: fallback, mask = false, validate, history, complete, ...settings } = {}) {
2474
- let line = { text: "", caret: 0 };
2475
- let invalid;
2476
- let completions = [];
2477
- const remembered = history === undefined || mask ? undefined : history;
2478
- const earlier = remembered === undefined ? [] : earlierAnswers(remembered);
2479
- let recalled = -1;
2480
- let draft = line;
2481
- const taken = () => line.text === "" ? fallback ?? "" : line.text;
2482
- const shown = () => mask ? "*".repeat([...taken()].length) : taken();
2483
- const accepted = await ask(question, settings, (colors, state, { columns }) => {
2484
- if (state !== "asking")
2485
- return [answer(colors, question, state, shown())];
2486
- const typed = line.text === "" ? { text: shown(), caret: [...shown()].length } : { text: shown(), caret: line.caret };
2487
- return [`${colors.cyan("?")} ${question} ${withCaret(colors, typed, roomAfter(question, columns), line.text === "")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`], ...completions.length > 1 ? [listed2(colors, completions, columns)] : []];
2488
- }, (key) => {
2489
- if (key === "cancel")
2490
- return "cancel";
2491
- invalid = undefined;
2492
- completions = [];
2493
- if (line.chained === true && endsKills(key))
2494
- line = { ...line, chained: false };
2495
- if (key === "tab") {
2496
- const chars = [...line.text];
2497
- const before = chars.slice(0, line.caret).join("");
2498
- const found = complete?.(before) ?? [];
2499
- const filled = sharedStart(found);
2500
- if ([...filled].length > [...before].length)
2501
- line = { ...line, text: filled + chars.slice(line.caret).join(""), caret: [...filled].length };
2502
- else
2503
- completions = found;
2504
- return;
2505
- }
2506
- if (key === "enter") {
2507
- invalid = validate?.(taken());
2508
- return invalid === undefined ? "enter" : undefined;
2509
- }
2510
- if (key === "up" || key === "down") {
2511
- const to = Math.min(Math.max(recalled + (key === "up" ? 1 : -1), -1), earlier.length - 1);
2512
- if (recalled === -1)
2513
- draft = line;
2514
- recalled = to;
2515
- const shown = to === -1 ? draft : { text: earlier[to], caret: [...earlier[to]].length };
2516
- line = { ...shown, killed: line.killed ?? "" };
2517
- return;
2518
- }
2519
- const edit = { home: "linestart", end: "lineend" }[key] ?? key;
2520
- if (typeof edit === "object" || isEditKey(edit))
2521
- line = editLine(line, edit);
2522
- return;
2523
- });
2524
- if (!accepted)
2525
- return;
2526
- if (remembered !== undefined && taken() !== "")
2527
- rememberAnswer(remembered, taken());
2528
- return taken();
2529
- }
2530
- function answer(colors, question, state, picked) {
2531
- return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
2868
+ const path = role("path", process19.stdout);
2869
+ const value = role("value", process19.stdout);
2870
+ const lines = [...onlyA.map((key) => `only in ${path(a)}: ${value(key)}`), ...onlyB.map((key) => `only in ${path(b)}: ${value(key)}`)];
2871
+ if (lines.length === 0)
2872
+ return 0;
2873
+ console.log(lines.join(`
2874
+ `));
2875
+ return 1;
2532
2876
  }
2533
- async function ask(question, { hint, terminal = process20 }, render, press) {
2534
- const { stdin, stderr } = terminal;
2535
- if (!isInteractive(terminal))
2536
- fail(`cannot ask "${question}" off a terminal`, 2, hint);
2537
- const colors = paint(stderr);
2538
- let current = "asking";
2539
- let outcome;
2540
- const columns = () => stderr.columns || 80;
2541
- const draw = (state, last = false) => {
2542
- const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
2543
- const rows = rowsTaken(frame, columns());
2544
- stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
2545
- current = state;
2546
- };
2547
- const redraw = () => draw(current);
2548
- const paste = { active: false };
2549
- const stop = terminal.stop ?? (terminal === process20 ? stopJob : undefined);
2550
- const suspend = () => {
2551
- if (stop === undefined)
2552
- return;
2553
- stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
2554
- stdin.setRawMode(false);
2555
- stop();
2556
- stdin.setRawMode(true);
2557
- stderr.write("\x1B[?25l\x1B[?2004h");
2558
- };
2559
- try {
2560
- stderr.on?.("resize", redraw);
2561
- stdin.setRawMode(true);
2562
- stdin.resume();
2563
- stderr.write("\x1B[?25l\x1B[?2004h");
2564
- draw("asking");
2565
- return await new Promise((resolve) => {
2566
- function onData(data) {
2567
- for (const key of readKeys(data.toString(), paste)) {
2568
- if (key === "suspend") {
2569
- suspend();
2570
- continue;
2571
- }
2572
- const pressed = press(key);
2573
- if (pressed !== undefined) {
2574
- settle(pressed);
2575
- return;
2576
- }
2577
- }
2578
- draw("asking");
2579
- }
2580
- function onEnd() {
2581
- settle("cancel");
2582
- }
2583
- function settle(settled) {
2584
- outcome = settled;
2585
- stdin.off("data", onData);
2586
- stdin.off("end", onEnd);
2587
- resolve(settled === "enter");
2588
- }
2589
- stdin.on("data", onData);
2590
- stdin.on("end", onEnd);
2591
- });
2592
- } finally {
2593
- stderr.off?.("resize", redraw);
2594
- draw(outcome ?? "cancel", true);
2595
- stderr.write(`
2596
- \x1B[?25h\x1B[?2004l`);
2597
- stdin.setRawMode(false);
2598
- stdin.pause();
2877
+ async function missing(args) {
2878
+ const parsed = parse(args, missingUsage, { against: { type: "string", description: "the reference file (.env.example by default)" }, ...jsonFlag }, { exits: MISSING_EXITS });
2879
+ const [file = ".env"] = parsed.positionals;
2880
+ const against = parsed.values.against ?? ".env.example";
2881
+ const have = await keys(file);
2882
+ const reference = await keys(against);
2883
+ const absent = [...reference].filter((key) => !have.has(key));
2884
+ if (parsed.values.json === true) {
2885
+ printJson({ a: against, b: file, onlyA: absent, onlyB: [...have].filter((key) => !reference.has(key)) });
2886
+ return absent.length === 0 ? 0 : 1;
2599
2887
  }
2888
+ if (absent.length === 0)
2889
+ return 0;
2890
+ const path = role("path", process19.stdout);
2891
+ const value = role("value", process19.stdout);
2892
+ console.log(absent.map((key) => `${value(key)} (set in ${path(against)}, not in ${path(file)})`).join(`
2893
+ `));
2894
+ return 1;
2600
2895
  }
2601
2896
 
2602
2897
  // src/commands/edit.ts
2898
+ init_prompt();
2603
2899
  var DEFAULT_FILE = ".env";
2604
2900
  var TRAILING_NEWLINE = /\r?\n$/;
2605
2901
  var KEY_NAME = /^[A-Z_][\w.-]*$/i;
@@ -2631,6 +2927,7 @@ function checkKey(key) {
2631
2927
  badUsage(`${JSON.stringify(key)} is not a valid key: letters, digits, _, . and - only, not starting with a digit`);
2632
2928
  }
2633
2929
  async function readOrEmpty(path) {
2930
+ assertDotenvName(path);
2634
2931
  return await Bun.file(path).exists() ? readEnv(path) : { lines: [] };
2635
2932
  }
2636
2933
  async function set(args) {
@@ -2919,10 +3216,8 @@ async function checkApp(folder, except = new Set) {
2919
3216
  var usage3 = `ev pins [dir] [--except NAME,...]
2920
3217
 
2921
3218
  Checks that an app's tests pin the env that reaches outside.
2922
- Reads the app's env schema (the file calling defineEnv, src/env.ts) and lists its optional URL, key, token, secret, password and host variables, then the ones no \`.env.test\` entry, test-level overrideEnv or local bunfig preload dropping what .env sets pins, and each test file that calls testSite or proxyKeyTests without pinning them all.
2923
- A file whose pages reach none of them says so with a \`// ev pins: none reached, <why>\` comment.
2924
- The dir is an app, or a monorepo holding apps one level down (the current folder by default).
2925
- Reads variable names only, never a value.`;
3219
+ Lists the optional URL, key, token, secret, password and host variables of the app's \`defineEnv\` schema that no \`.env.test\` entry, \`overrideEnv\` or bunfig preload pins, and each test file calling \`testSite\` or \`proxyKeyTests\` without pinning them all; a file reaching none says so with a \`// ev pins: none reached, <why>\` comment.
3220
+ The dir is an app, or a monorepo holding apps one level down (the current folder by default). It reads variable names only, never a value.`;
2926
3221
  var EXITS2 = [[0, "everything is pinned"], [1, "something is not"], [2, "a usage error"]];
2927
3222
  var options2 = {
2928
3223
  json: jsonOption("each app with its reaching, unpinned variables and flagged test files"),
@@ -2988,7 +3283,7 @@ async function pins(args) {
2988
3283
  var {$: $2 } = globalThis.Bun;
2989
3284
  var listUsage = `ev list [file]
2990
3285
 
2991
- Prints every key of the folder's .env* files, or of one file, with secret values masked: a few leading characters and the length under a key named like TOKEN, SECRET, PASSWORD, PASS, PWD, KEY, PRIVATE, DSN, AUTH, SALT or COOKIE, any value equal to a secret of the folder's .env* files, and the password and tokens of any URL.
3286
+ Prints every key of the folder's .env* files, or of one file, with secret values masked to a few leading characters and the length.
2992
3287
 
2993
3288
  --json prints [{file, key, value, secret}], value masked and secret true when a value was.`;
2994
3289
  var LIST_EXITS = [[0, "it printed them"], [1, "there is no .env* file"], [2, "a usage error"]];
@@ -3023,10 +3318,10 @@ function printRows(rows, json, plain) {
3023
3318
  else
3024
3319
  plain();
3025
3320
  }
3026
- async function readAll(names) {
3321
+ async function readAll(names, scanned) {
3027
3322
  const files = [];
3028
3323
  for (const name of names)
3029
- files.push([name, await readEnv(name)]);
3324
+ files.push([name, await readEnv(name, { scanned })]);
3030
3325
  return { files, known: await loadKnown(process.cwd(), files.map(([, file]) => file)) };
3031
3326
  }
3032
3327
  async function list(args) {
@@ -3036,7 +3331,7 @@ async function list(args) {
3036
3331
  if (names.length === 0)
3037
3332
  fail("no .env* file in this folder", 1);
3038
3333
  const rows = [];
3039
- const { files, known } = await readAll(names);
3334
+ const { files, known } = await readAll(names, file === undefined);
3040
3335
  for (const [name, file] of files) {
3041
3336
  for (const [key, value] of entries(file))
3042
3337
  rows.push(row(name, key, value, known));
@@ -3056,7 +3351,7 @@ async function get(args) {
3056
3351
  ${getUsage}`);
3057
3352
  const names = file === undefined ? await envFiles() : [file];
3058
3353
  const rows = [];
3059
- const { files, known } = await readAll(names);
3354
+ const { files, known } = await readAll(names, file === undefined);
3060
3355
  for (const [name, file] of files) {
3061
3356
  const value = entries(file).get(key);
3062
3357
  if (value !== undefined)
@@ -3095,7 +3390,7 @@ ${grepUsage}`);
3095
3390
  }
3096
3391
  const names = given.length === 0 ? await envFiles() : given;
3097
3392
  const rows = [];
3098
- const { files, known } = await readAll(names);
3393
+ const { files, known } = await readAll(names, given.length === 0);
3099
3394
  for (const [name, file] of files) {
3100
3395
  for (const [key, value] of entries(file)) {
3101
3396
  if (pattern.test(key))
@@ -3117,10 +3412,13 @@ async function show(args) {
3117
3412
  ${showUsage}`);
3118
3413
  if (revision.startsWith("-"))
3119
3414
  fail(`${revision} is not a revision: it reads as a git option`);
3415
+ const redact = `git show ${revision}:${path} | ev redact`;
3416
+ assertDotenvName(path, redact);
3120
3417
  const shown = await $2`git show --end-of-options ${`${revision}:${path}`}`.quiet().nothrow();
3121
3418
  if (shown.exitCode !== 0)
3122
3419
  fail(`git show ${revision}:${path} failed: ${shown.stderr.toString().trim()}`, 1);
3123
3420
  const file = parseDotenv(shown.stdout.toString());
3421
+ assertDotenvText(target ?? "", file, redact);
3124
3422
  const known = await loadKnown(process.cwd(), [file]);
3125
3423
  const rows = [...entries(file)].map(([key, value]) => row(target ?? "", key, value, known));
3126
3424
  printRows(rows, parsed.values.json === true, () => {
@@ -3131,7 +3429,7 @@ ${showUsage}`);
3131
3429
  }
3132
3430
 
3133
3431
  // src/commands/redact.ts
3134
- import process21 from "process";
3432
+ import process22 from "process";
3135
3433
 
3136
3434
  // src/redactor.ts
3137
3435
  var DIFF_START = /^(?:diff --git |@@ )/;
@@ -3249,17 +3547,17 @@ function check(text, known) {
3249
3547
  }
3250
3548
 
3251
3549
  // src/commands/redact.ts
3252
- var usage4 = `redact [--check]
3550
+ var usage4 = `ev redact [--check]
3253
3551
 
3254
- Copies stdin to stdout line by line with secrets masked: known token formats (GitHub, GitLab, Slack, AWS, npm, Stripe, Google and SendGrid keys, sk-, JWTs, Authorization headers, password= and secret= pairs), private key blocks, the password and the tokens of any URL and the values of secret-looking keys in this folder's .env* files.
3255
- --check prints nothing of the input and lists the file and line of each secret found, exiting 1 when there is any: \`git diff --cached | redact --check\`.`;
3552
+ Copies stdin to stdout line by line with secrets masked: known token formats, private key blocks, the password and tokens of any URL and the values of secret-looking keys in this folder's .env* files.
3553
+ --check prints nothing of the input and lists the file and line of each secret found, exiting 1 when there is any: \`git diff --cached | ev redact --check\`.`;
3256
3554
  var EXITS3 = [[0, "it copied the input or found no secret"], [1, "--check finds one"], [2, "a usage error"]];
3257
3555
  var options3 = {
3258
3556
  check: { type: "boolean", description: "list where secrets are instead of masking them, exit 1 when found" },
3259
3557
  "no-env": { type: "boolean", description: "do not search for the values of the .env* files" }
3260
3558
  };
3261
3559
  async function redact(args) {
3262
- const parsed = parse(args, usage4, options3, { exits: EXITS3, replaces: "printing a command's secrets into a log or a transcript", examples: [["docker compose config | redact", "the resolved compose file, secrets masked"], ["git diff --cached | redact --check", "refuse a commit carrying a secret"]] });
3560
+ const parsed = parse(args, usage4, options3, { exits: EXITS3, replaces: "printing a command's secrets into a log or a transcript", examples: [["docker compose config | ev redact", "the resolved compose file, secrets masked"], ["git diff --cached | ev redact --check", "refuse a commit carrying a secret"]] });
3263
3561
  const known = parsed.values["no-env"] === true ? undefined : await loadKnown();
3264
3562
  if (parsed.values.check === true) {
3265
3563
  const findings = check(await readInput("-"), known);
@@ -3270,13 +3568,13 @@ async function redact(args) {
3270
3568
  const redactor = new Redactor(known);
3271
3569
  const decoder = new TextDecoder;
3272
3570
  for await (const chunk of Bun.stdin.stream())
3273
- process21.stdout.write(redactor.push(decoder.decode(chunk, { stream: true })));
3274
- process21.stdout.write(redactor.push(decoder.decode()) + redactor.end());
3571
+ process22.stdout.write(redactor.push(decoder.decode(chunk, { stream: true })));
3572
+ process22.stdout.write(redactor.push(decoder.decode()) + redactor.end());
3275
3573
  return 0;
3276
3574
  }
3277
3575
 
3278
3576
  // src/ev.ts
3279
- process22.exitCode = await runCli({
3577
+ process23.exitCode = await runCli({
3280
3578
  name: "ev",
3281
3579
  about: ".env files listed and edited with secrets masked",
3282
3580
  replaces: "cat .env, grep on env files and editing them by hand",