@kaynooo/cli-git 0.16.1 → 0.17.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.
Files changed (11) hide show
  1. package/README.md +1 -1
  2. package/dist/gb.js +1642 -1139
  3. package/dist/gc.js +1053 -153
  4. package/dist/gcl.js +1086 -166
  5. package/dist/gd.js +1064 -164
  6. package/dist/gf.js +1095 -169
  7. package/dist/gm.js +1667 -1152
  8. package/dist/gp.js +1073 -167
  9. package/dist/gst.js +1072 -172
  10. package/dist/gu.js +1059 -159
  11. package/package.json +5 -5
package/dist/gc.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/gc.ts
5
- import process19 from "process";
6
- // ../kit/src/args.ts
7
- import process9 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,13 +173,17 @@ 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
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";
163
183
  function toLinear(channel) {
164
184
  const value = channel / 255;
165
185
  return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
166
186
  }
167
- var fromLinear = (value) => Math.round(255 * Math.min(1, Math.max(0, value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055)));
168
187
  function toOklab(hex) {
169
188
  const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
170
189
  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
@@ -179,7 +198,6 @@ function fromOklab([lightness, a, b]) {
179
198
  const channels = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
180
199
  return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
181
200
  }
182
- var ENDS = new Map;
183
201
  function gradientAt(theme, ratio) {
184
202
  if (theme.gradient === undefined)
185
203
  return;
@@ -193,33 +211,11 @@ function gradientAt(theme, ratio) {
193
211
  const [from, to] = ends;
194
212
  return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
195
213
  }
196
- var DEFAULT = {
197
- 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" },
198
- 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" },
199
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
200
- bins: {},
201
- gradient: ["#c084fc", "#67e8f9"]
202
- };
203
- 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" };
204
- 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" };
205
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
206
- var PRESETS = {
207
- default: {},
208
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
209
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
210
- ascii: { glyphs: ASCII }
211
- };
212
- 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"]);
213
- var HEX = /^#[0-9a-f]{6}$/i;
214
- var CONTROL = /\p{Cc}/u;
215
- var MAX_FILE_BYTES = 64 * 1024;
216
- var SPACES = /\s+/;
217
214
  function isColorSpec(spec) {
218
215
  if (typeof spec === "number")
219
216
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
220
217
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
221
218
  }
222
- var CUBE = [0, 95, 135, 175, 215, 255];
223
219
  function cubeLevel(channel) {
224
220
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
225
221
  }
@@ -327,7 +323,6 @@ function applyFile(theme, file, where, warn) {
327
323
  function endsWalk(home) {
328
324
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
329
325
  }
330
- var warned = new Set;
331
326
  function warnOnce(message) {
332
327
  if (warned.has(message))
333
328
  return;
@@ -364,8 +359,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
364
359
  }
365
360
  return { theme, sources, preset };
366
361
  }
367
- var current;
368
- var currentKey = "";
369
362
  function activeTheme() {
370
363
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
371
364
  if (current === undefined || key !== currentKey) {
@@ -374,9 +367,38 @@ function activeTheme() {
374
367
  }
375
368
  return current;
376
369
  }
370
+ var fromLinear = (value) => Math.round(255 * Math.min(1, Math.max(0, value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055))), ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
371
+ var init_theme = __esm(() => {
372
+ init_config();
373
+ init_user_config();
374
+ ENDS = new Map;
375
+ DEFAULT = {
376
+ 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" },
377
+ 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" },
378
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
379
+ bins: {},
380
+ gradient: ["#c084fc", "#67e8f9"]
381
+ };
382
+ 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" };
383
+ 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" };
384
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
385
+ PRESETS = {
386
+ default: {},
387
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
388
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
389
+ ascii: { glyphs: ASCII }
390
+ };
391
+ 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"]);
392
+ HEX = /^#[0-9a-f]{6}$/i;
393
+ CONTROL = /\p{Cc}/u;
394
+ MAX_FILE_BYTES = 64 * 1024;
395
+ SPACES = /\s+/;
396
+ CUBE = [0, 95, 135, 175, 215, 255];
397
+ warned = new Set;
398
+ });
377
399
 
378
400
  // ../kit/src/style.ts
379
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
401
+ import process6 from "process";
380
402
  function takesControlCodes(stream, env = process6.env) {
381
403
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
382
404
  }
@@ -396,17 +418,24 @@ function role(name, stream, env = process6.env) {
396
418
  const colors = paint(stream, env);
397
419
  return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
398
420
  }
399
- var 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
- var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
421
+ var MARK_WORDS, STATUS_WORDS, STATUS_OF;
422
+ var init_style = __esm(() => {
423
+ init_colors();
424
+ init_mode();
425
+ init_theme();
426
+ MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
427
+ STATUS_WORDS = {
428
+ passed: ["passed", "success", "succeeded", "ok"],
429
+ failed: ["failed", "failure", "error", "errored"],
430
+ running: ["running", "in_progress", "started", "holding"],
431
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
432
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
433
+ };
434
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
435
+ });
407
436
 
408
437
  // ../kit/src/format.ts
409
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
438
+ import process7 from "process";
410
439
  function formatSeconds(total) {
411
440
  let rest = Math.max(0, Math.round(total));
412
441
  const amounts = UNITS.map(([unit, size]) => {
@@ -438,10 +467,8 @@ function formatAge(date, now = Date.now()) {
438
467
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
439
468
  }
440
469
  function truncate(text, width) {
441
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
470
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
442
471
  }
443
- var LINE_BREAKS = /\s*\n\s*/g;
444
- var ESCAPE = String.fromCharCode(27);
445
472
  function textWidth(text) {
446
473
  return Bun.stringWidth(text);
447
474
  }
@@ -490,12 +517,18 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
490
517
  function printJson(value) {
491
518
  console.log(jsonText(value));
492
519
  }
520
+ var UNITS, LINE_BREAKS, ESCAPE;
521
+ var init_format = __esm(() => {
522
+ init_text();
523
+ init_mode();
524
+ init_style();
525
+ UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
526
+ LINE_BREAKS = /\s*\n\s*/g;
527
+ ESCAPE = String.fromCharCode(27);
528
+ });
493
529
 
494
530
  // ../kit/src/help.ts
495
531
  import process8 from "process";
496
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
497
- var USAGE_PREFIX = /^usage:\s*/i;
498
- var FULL_STOP = /\.$/;
499
532
  function usageLine(usage, colors = paint(process8.stdout)) {
500
533
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
501
534
  }
@@ -532,7 +565,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
532
565
  return [];
533
566
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
534
567
  }
535
- var MAX_INLINE_CHOICES = 24;
536
568
  function optionRows(options, colors = paint(process8.stdout)) {
537
569
  const rows = Object.entries(options).map(([name, option]) => {
538
570
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -547,9 +579,16 @@ function optionRows(options, colors = paint(process8.stdout)) {
547
579
  const width = Math.max(0, ...rows.map((row) => row.width));
548
580
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
549
581
  }
582
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
583
+ var init_help = __esm(() => {
584
+ init_mode();
585
+ init_style();
586
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
587
+ USAGE_PREFIX = /^usage:\s*/i;
588
+ FULL_STOP = /\.$/;
589
+ });
550
590
 
551
591
  // ../kit/src/text.ts
552
- var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
553
592
  function distance(a, b) {
554
593
  const left = [...a];
555
594
  const right = [...b];
@@ -575,8 +614,12 @@ function closest(name, names) {
575
614
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
576
615
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
577
616
  }
617
+ var ANSI;
618
+ var init_text2 = __esm(() => {
619
+ ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
620
+ });
621
+
578
622
  // ../kit/src/input.ts
579
- var WHOLE = /^\d+$/;
580
623
  function wholeNumber(value, name, fallback, min = 1) {
581
624
  if (value === undefined)
582
625
  return fallback;
@@ -585,8 +628,6 @@ function wholeNumber(value, name, fallback, min = 1) {
585
628
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
586
629
  return number;
587
630
  }
588
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
589
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
590
631
  function duration(value, name, fallback, unit = "s") {
591
632
  if (value === undefined)
592
633
  return fallback;
@@ -596,40 +637,27 @@ function duration(value, name, fallback, unit = "s") {
596
637
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
597
638
  return ms;
598
639
  }
640
+ var WHOLE, DURATION, UNIT_MS;
641
+ var init_input = __esm(() => {
642
+ init_args();
643
+ WHOLE = /^\d+$/;
644
+ DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
645
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
646
+ });
599
647
 
600
648
  // ../kit/src/args.ts
601
- var DASHES = /^-+/;
649
+ import process9 from "process";
650
+ import { parseArgs } from "util";
602
651
  function jsonOption(holds) {
603
652
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
604
653
  }
605
- class Exit extends Error {
606
- code;
607
- hint;
608
- constructor(message, code, hint) {
609
- super(message);
610
- this.code = code;
611
- this.hint = hint;
612
- }
613
- }
614
654
  function fail(message, code = 2, hint) {
615
655
  throw new Exit(message, code, hint);
616
656
  }
617
-
618
- class UsageError extends Exit {
619
- constructor(message, hint) {
620
- super(message, 2, hint);
621
- }
622
- }
623
657
  function badUsage(message) {
624
658
  throw new UsageError(message);
625
659
  }
626
660
 
627
- class HelpShown extends Exit {
628
- constructor() {
629
- super("help shown", 0);
630
- }
631
- }
632
-
633
661
  class Completing {
634
662
  options;
635
663
  positionals;
@@ -640,11 +668,6 @@ class Completing {
640
668
  this.candidates = candidates;
641
669
  }
642
670
  }
643
- var completion = { active: false };
644
- var OUTPUT_OPTIONS = {
645
- color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
646
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
647
- };
648
671
  function applyOutput(color, plain, env = process9.env) {
649
672
  const when = plain === true ? "never" : color ?? "auto";
650
673
  if (when === "auto")
@@ -798,7 +821,6 @@ function parseError(error) {
798
821
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
799
822
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
800
823
  }
801
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
802
824
  function nearestOption(message, options, allowNegative) {
803
825
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
804
826
  if (typed === undefined)
@@ -814,6 +836,685 @@ function nearestOption(message, options, allowNegative) {
814
836
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
815
837
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
816
838
  }
839
+ var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
840
+ var init_args = __esm(() => {
841
+ init_format();
842
+ init_help();
843
+ init_text2();
844
+ init_help();
845
+ init_input();
846
+ DASHES = /^-+/;
847
+ Exit = class Exit extends Error {
848
+ code;
849
+ hint;
850
+ constructor(message, code, hint) {
851
+ super(message);
852
+ this.code = code;
853
+ this.hint = hint;
854
+ }
855
+ };
856
+ UsageError = class UsageError extends Exit {
857
+ constructor(message, hint) {
858
+ super(message, 2, hint);
859
+ }
860
+ };
861
+ HelpShown = class HelpShown extends Exit {
862
+ constructor() {
863
+ super("help shown", 0);
864
+ }
865
+ };
866
+ completion = { active: false };
867
+ OUTPUT_OPTIONS = {
868
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
869
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
870
+ };
871
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
872
+ });
873
+
874
+ // ../kit/src/folders.ts
875
+ import { homedir as homedir3 } from "os";
876
+ import { join as join4 } from "path";
877
+ import process13 from "process";
878
+ function cacheFolder({ home = homedir3(), env = process13.env } = {}) {
879
+ return env.XDG_CACHE_HOME ?? join4(home, ".cache");
880
+ }
881
+ var SKIPPED_FOLDERS;
882
+ var init_folders = __esm(() => {
883
+ init_user_config();
884
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
885
+ });
886
+
887
+ // ../kit/src/answers.ts
888
+ import { mkdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
889
+ import { dirname as dirname2, join as join5 } from "path";
890
+ function answersFile() {
891
+ return join5(cacheFolder(), "kaynooo-cli", "answers.json");
892
+ }
893
+ function stored() {
894
+ try {
895
+ const parsed = JSON.parse(readFileSync4(answersFile(), "utf-8"));
896
+ if (typeof parsed !== "object" || parsed === null)
897
+ return {};
898
+ return Object.fromEntries(Object.entries(parsed).filter((entry) => Array.isArray(entry[1]) && entry[1].every((answer) => typeof answer === "string")));
899
+ } catch {
900
+ return {};
901
+ }
902
+ }
903
+ function earlierAnswers(key) {
904
+ return stored()[key] ?? [];
905
+ }
906
+ function rememberAnswer(key, answer) {
907
+ const all = stored();
908
+ const file = answersFile();
909
+ all[key] = [answer, ...(all[key] ?? []).filter((earlier) => earlier !== answer)].slice(0, KEPT);
910
+ try {
911
+ mkdirSync(dirname2(file), { recursive: true });
912
+ writeFileSync(file, JSON.stringify(all));
913
+ } catch {}
914
+ }
915
+ var KEPT = 50;
916
+ var init_answers = __esm(() => {
917
+ init_folders();
918
+ });
919
+
920
+ // ../kit/src/job.ts
921
+ import process14 from "process";
922
+ function stopJob() {
923
+ process14.kill(0, "SIGTSTP");
924
+ }
925
+ var init_job = () => {};
926
+
927
+ // ../kit/src/picker/line.ts
928
+ function isEditKey(key) {
929
+ return EDIT_KEYS.has(key);
930
+ }
931
+ function endsKills(key) {
932
+ return typeof key !== "object" && !isEditKey(key);
933
+ }
934
+ function isWord(char) {
935
+ return char !== undefined && WORD_CHARACTER.test(char);
936
+ }
937
+ function wordStart(chars, from) {
938
+ let at = from;
939
+ while (at > 0 && !isWord(chars[at - 1]))
940
+ at--;
941
+ while (at > 0 && isWord(chars[at - 1]))
942
+ at--;
943
+ return at;
944
+ }
945
+ function wordEnd(chars, from) {
946
+ let at = from;
947
+ while (at < chars.length && !isWord(chars[at]))
948
+ at++;
949
+ while (at < chars.length && isWord(chars[at]))
950
+ at++;
951
+ return at;
952
+ }
953
+ function spacedStart(chars, from) {
954
+ let at = from;
955
+ while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
956
+ at--;
957
+ while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
958
+ at--;
959
+ return at;
960
+ }
961
+ function cut(chars, from, to) {
962
+ return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
963
+ }
964
+ function insert(chars, at, text) {
965
+ const typed = [...text];
966
+ return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
967
+ }
968
+ function editLine(line, key) {
969
+ const { killed = "", chained = false } = line;
970
+ const chars = [...line.text];
971
+ const at = Math.min(Math.max(line.caret, 0), chars.length);
972
+ const edited = edit(chars, at, key, killed);
973
+ if (typeof key === "object" || !BACKWARD_KILLS.has(key) && !FORWARD_KILLS.has(key))
974
+ return line.killed === undefined ? edited : { ...edited, killed };
975
+ const taken = chars.slice(edited.caret, edited.caret + chars.length - [...edited.text].length).join("");
976
+ if (taken === "")
977
+ return { ...edited, killed, chained };
978
+ if (!chained)
979
+ return { ...edited, killed: taken, chained: true };
980
+ return { ...edited, killed: BACKWARD_KILLS.has(key) ? taken + killed : killed + taken, chained: true };
981
+ }
982
+ function edit(chars, at, key, killed) {
983
+ const text = chars.join("");
984
+ if (typeof key === "object")
985
+ return insert(chars, at, key.text);
986
+ switch (key) {
987
+ case "left":
988
+ return { text, caret: Math.max(at - 1, 0) };
989
+ case "right":
990
+ return { text, caret: Math.min(at + 1, chars.length) };
991
+ case "wordleft":
992
+ return { text, caret: wordStart(chars, at) };
993
+ case "wordright":
994
+ return { text, caret: wordEnd(chars, at) };
995
+ case "linestart":
996
+ return { text, caret: 0 };
997
+ case "lineend":
998
+ return { text, caret: chars.length };
999
+ case "erase":
1000
+ return cut(chars, Math.max(at - 1, 0), at);
1001
+ case "delete":
1002
+ return cut(chars, at, Math.min(at + 1, chars.length));
1003
+ case "word":
1004
+ return cut(chars, spacedStart(chars, at), at);
1005
+ case "killword":
1006
+ return cut(chars, wordStart(chars, at), at);
1007
+ case "killnext":
1008
+ return cut(chars, at, wordEnd(chars, at));
1009
+ case "clear":
1010
+ return cut(chars, 0, at);
1011
+ case "killend":
1012
+ return cut(chars, at, chars.length);
1013
+ case "yank":
1014
+ return insert(chars, at, killed);
1015
+ }
1016
+ }
1017
+ function visible({ text, caret }, room) {
1018
+ const chars = [...text];
1019
+ const at = Math.min(Math.max(caret, 0), chars.length);
1020
+ const cells = at === chars.length ? [...chars, " "] : chars;
1021
+ const widths = cells.map((char) => Bun.stringWidth(char));
1022
+ const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
1023
+ const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
1024
+ let start = at;
1025
+ let end = at + 1;
1026
+ while (start > 0 && fits(start - 1, end))
1027
+ start--;
1028
+ while (end < cells.length && fits(start, end + 1))
1029
+ end++;
1030
+ const left = start > 0 ? "\u2026" : "";
1031
+ const right = end < cells.length ? "\u2026" : "";
1032
+ 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) };
1033
+ }
1034
+ var EDIT_KEYS, BACKWARD_KILLS, FORWARD_KILLS, WORD_CHARACTER, SPACE;
1035
+ var init_line = __esm(() => {
1036
+ EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
1037
+ BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
1038
+ FORWARD_KILLS = new Set(["killnext", "killend"]);
1039
+ WORD_CHARACTER = /[\p{L}\p{N}_]/u;
1040
+ SPACE = /\s/;
1041
+ });
1042
+
1043
+ // ../kit/src/picker/score.ts
1044
+ function startsWord(text, index) {
1045
+ if (index === 0)
1046
+ return true;
1047
+ const before = text[index - 1];
1048
+ return BOUNDARY_AFTER.has(before) || LOWER.test(before) && UPPER.test(text[index]);
1049
+ }
1050
+ function fuzzy(query, text) {
1051
+ if (query === "")
1052
+ return { score: 0, positions: [] };
1053
+ const exact = query !== query.toLowerCase();
1054
+ const needle = exact ? query : query.toLowerCase();
1055
+ const haystack = exact ? text : text.toLowerCase();
1056
+ if (haystack.length !== text.length || needle.length > haystack.length)
1057
+ return;
1058
+ const width = haystack.length;
1059
+ const best = Array.from({ length: needle.length }, () => new Array(width).fill(NONE));
1060
+ const from = Array.from({ length: needle.length }, () => new Array(width).fill(-1));
1061
+ for (let j = 0;j < needle.length; j++) {
1062
+ let run = NONE;
1063
+ let runAt = -1;
1064
+ for (let i = j;i < width; i++) {
1065
+ if (j > 0 && i - 2 >= j - 1) {
1066
+ const candidate = best[j - 1][i - 2] + (i - 2) * GAP;
1067
+ if (candidate > run) {
1068
+ run = candidate;
1069
+ runAt = i - 2;
1070
+ }
1071
+ }
1072
+ if (haystack[i] !== needle[j])
1073
+ continue;
1074
+ const here = MATCH + (startsWord(text, i) ? BOUNDARY : 0) + (i === 0 ? PREFIX : 0);
1075
+ if (j === 0) {
1076
+ best[0][i] = here - i * GAP;
1077
+ continue;
1078
+ }
1079
+ const joined = best[j - 1][i - 1] + CONSECUTIVE;
1080
+ const skipped = run - (i - 1) * GAP;
1081
+ if (joined > NONE && joined >= skipped) {
1082
+ best[j][i] = joined + here;
1083
+ from[j][i] = i - 1;
1084
+ } else if (skipped > NONE) {
1085
+ best[j][i] = skipped + here;
1086
+ from[j][i] = runAt;
1087
+ }
1088
+ }
1089
+ }
1090
+ const last = best[needle.length - 1];
1091
+ let end = -1;
1092
+ for (let i = 0;i < width; i++) {
1093
+ if (last[i] > NONE && (end === -1 || last[i] > last[end]))
1094
+ end = i;
1095
+ }
1096
+ if (end === -1)
1097
+ return;
1098
+ const positions = [];
1099
+ for (let j = needle.length - 1, i = end;j >= 0; j--) {
1100
+ positions.unshift(i);
1101
+ i = from[j][i];
1102
+ }
1103
+ return { score: last[end], positions };
1104
+ }
1105
+ function rank(query, lines) {
1106
+ if (query === "")
1107
+ return lines.map((_, index) => ({ index, positions: [] }));
1108
+ const found = [];
1109
+ for (const [index, line] of lines.entries()) {
1110
+ const match = fuzzy(query, line);
1111
+ if (match !== undefined)
1112
+ found.push({ index, positions: match.positions, score: match.score });
1113
+ }
1114
+ return found.sort((a, b) => b.score - a.score || lines[a.index].length - lines[b.index].length || a.index - b.index);
1115
+ }
1116
+ var MATCH = 16, CONSECUTIVE = 12, BOUNDARY = 10, PREFIX = 8, GAP = 1, BOUNDARY_AFTER, UPPER, LOWER, NONE;
1117
+ var init_score = __esm(() => {
1118
+ BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
1119
+ UPPER = /\p{Lu}/u;
1120
+ LOWER = /\p{Ll}/u;
1121
+ NONE = Number.NEGATIVE_INFINITY;
1122
+ });
1123
+
1124
+ // ../kit/src/picker/state.ts
1125
+ function repeat(value, count) {
1126
+ return Array.from({ length: count }).fill(value);
1127
+ }
1128
+ function styled(line) {
1129
+ let text = "";
1130
+ const styles = [];
1131
+ let active = "";
1132
+ let colored = false;
1133
+ let last = 0;
1134
+ function add(chunk) {
1135
+ const flat = chunk.replace(CONTROL2, " ");
1136
+ text += flat;
1137
+ colored ||= active !== "" && flat !== "";
1138
+ styles.push(...repeat(active, flat.length));
1139
+ }
1140
+ for (const found of line.matchAll(ANSI)) {
1141
+ add(line.slice(last, found.index));
1142
+ last = found.index + found[0].length;
1143
+ if (SGR.test(found[0]))
1144
+ active = RESET.test(found[0]) ? "" : active + found[0];
1145
+ }
1146
+ add(line.slice(last));
1147
+ return { text, styles: colored ? styles : undefined };
1148
+ }
1149
+ function lay(rows, searched) {
1150
+ const parsed = rows.map((row) => row.cells.map(styled));
1151
+ const widths = (parsed[0] ?? []).map((_, column) => Math.max(...parsed.map((cells) => Bun.stringWidth(cells[column]?.text ?? ""))));
1152
+ return parsed.map((cells, at) => {
1153
+ let text = "";
1154
+ const styles = [];
1155
+ let colored = false;
1156
+ let searchEnd = 0;
1157
+ for (const [column, cell] of cells.entries()) {
1158
+ const last = column === cells.length - 1;
1159
+ const shown = cells.length > 1 && last ? cell.text.trimEnd() : cell.text;
1160
+ text += shown;
1161
+ colored ||= cell.styles !== undefined;
1162
+ styles.push(...cell.styles?.slice(0, shown.length) ?? repeat("", shown.length));
1163
+ if (column < searched)
1164
+ searchEnd = cells.length > 1 ? text.trimEnd().length : text.length;
1165
+ if (!last) {
1166
+ const pad = widths[column] - Bun.stringWidth(cell.text) + COLUMN_GAP;
1167
+ text += " ".repeat(pad);
1168
+ styles.push(...repeat("", pad));
1169
+ }
1170
+ }
1171
+ return { text, styles: colored ? styles : undefined, searchable: rows[at].search ?? text.slice(0, searchEnd) };
1172
+ });
1173
+ }
1174
+ function parseKeys(input, paste = { active: false }, ctrls = []) {
1175
+ const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
1176
+ return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
1177
+ const wheel = MOUSE.exec(sequence)?.[1];
1178
+ if (wheel !== undefined)
1179
+ return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
1180
+ const named = codes.get(sequence);
1181
+ const key = named === undefined ? KEYS[sequence] : { ctrl: named };
1182
+ if (sequence === PASTE_START || sequence === PASTE_END) {
1183
+ paste.active = sequence === PASTE_START;
1184
+ return [];
1185
+ }
1186
+ if (paste.active && (sequence === "\r" || sequence === `
1187
+ `))
1188
+ return [];
1189
+ if (key !== undefined)
1190
+ return [key];
1191
+ return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
1192
+ });
1193
+ }
1194
+ function createState(rows, { multi = false, prompt = "> ", query = "", header = "", expect = [], searched = Number.POSITIVE_INFINITY } = {}) {
1195
+ const state = { rows: [], items: [], styles: [], searchable: [], searched, header, expect, key: "", status: "", query, caret: [...query].length, killed: "", chained: false, matches: [], cursor: 0, help: false, page: 10, marked: new Set, multi, prompt, done: undefined };
1196
+ return withRows(state, rows);
1197
+ }
1198
+ function withRows(state, rows, header = state.header) {
1199
+ const cells = rows.map((row) => typeof row === "string" ? { hidden: [], cells: [row] } : row);
1200
+ const laid = lay(cells, state.searched);
1201
+ const searchable = laid.map((row) => row.searchable);
1202
+ const matches = rank(state.query, searchable);
1203
+ return { ...state, rows: cells, items: laid.map((row) => row.text), styles: laid.map((row) => row.styles), searchable, header, matches, cursor: Math.max(0, Math.min(matches.length - 1, state.cursor)), marked: new Set };
1204
+ }
1205
+ function withQuery(state, key) {
1206
+ const { text, caret, killed = "", chained = false } = editLine({ text: state.query, caret: state.caret, killed: state.killed, chained: state.chained }, key);
1207
+ return text === state.query ? { ...state, caret, killed, chained } : { ...state, query: text, caret, killed, chained, matches: rank(text, state.searchable), cursor: 0 };
1208
+ }
1209
+ function move(state, by) {
1210
+ return { ...state, cursor: Math.max(0, Math.min(state.matches.length - 1, state.cursor + by)) };
1211
+ }
1212
+ function highlighted(state) {
1213
+ return state.matches[state.cursor]?.index;
1214
+ }
1215
+ function press(state, key) {
1216
+ if (state.done !== undefined)
1217
+ return state;
1218
+ if (state.chained && endsKills(key))
1219
+ state = { ...state, chained: false };
1220
+ if (state.help)
1221
+ return { ...state, help: false };
1222
+ if (typeof key === "object") {
1223
+ if ("text" in key)
1224
+ return withQuery(state, key);
1225
+ return state.expect.includes(key.ctrl) ? { ...state, done: "accept", key: key.ctrl } : state;
1226
+ }
1227
+ if (isEditKey(key))
1228
+ return withQuery(state, key);
1229
+ switch (key) {
1230
+ case "up":
1231
+ return move(state, -1);
1232
+ case "down":
1233
+ return move(state, 1);
1234
+ case "pageup":
1235
+ return move(state, -state.page);
1236
+ case "pagedown":
1237
+ return move(state, state.page);
1238
+ case "home":
1239
+ return move(state, -state.matches.length);
1240
+ case "end":
1241
+ return move(state, state.matches.length);
1242
+ case "cancel":
1243
+ return { ...state, done: "cancel" };
1244
+ case "help":
1245
+ return { ...state, help: true };
1246
+ case "suspend":
1247
+ return state;
1248
+ case "enter":
1249
+ return state.matches.length === 0 && state.marked.size === 0 ? state : { ...state, done: "accept" };
1250
+ case "tab": {
1251
+ const at = highlighted(state);
1252
+ if (!state.multi || at === undefined)
1253
+ return state;
1254
+ const marked = new Set(state.marked);
1255
+ if (!marked.delete(at))
1256
+ marked.add(at);
1257
+ return move({ ...state, marked }, 1);
1258
+ }
1259
+ }
1260
+ }
1261
+ function chosen(state) {
1262
+ if (state.marked.size > 0)
1263
+ return state.rows.filter((_, index) => state.marked.has(index));
1264
+ const at = highlighted(state);
1265
+ return at === undefined ? [] : [state.rows[at]];
1266
+ }
1267
+ var CONTROL2, IS_CONTROL, SGR, RESET, COLUMN_GAP = 2, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, MOUSE, WHEEL_LINES = 3, KEYS, CTRL_KEY;
1268
+ var init_state = __esm(() => {
1269
+ init_text2();
1270
+ init_line();
1271
+ init_score();
1272
+ CONTROL2 = /[\x00-\x1F\x7F-\x9F]/g;
1273
+ IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
1274
+ SGR = /^\x1B\[[0-9;]*m$/;
1275
+ RESET = /^\x1B\[0?m$/;
1276
+ KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
1277
+ MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
1278
+ KEYS = {
1279
+ "\x1B[A": "up",
1280
+ "\x1BOA": "up",
1281
+ "\x10": "up",
1282
+ "\x1B[B": "down",
1283
+ "\x1BOB": "down",
1284
+ "\x0E": "down",
1285
+ "\x1B[5~": "pageup",
1286
+ "\x1B[6~": "pagedown",
1287
+ "\x1B[H": "home",
1288
+ "\x1B[1~": "home",
1289
+ "\x1BOH": "home",
1290
+ "\x1B[F": "end",
1291
+ "\x1B[4~": "end",
1292
+ "\x1BOF": "end",
1293
+ "\r": "enter",
1294
+ "\n": "enter",
1295
+ "\x03": "cancel",
1296
+ "\x1B": "cancel",
1297
+ "\x1B[D": "left",
1298
+ "\x1BOD": "left",
1299
+ "\x1B[C": "right",
1300
+ "\x1BOC": "right",
1301
+ "\x1B[1;5D": "wordleft",
1302
+ "\x1B[1;3D": "wordleft",
1303
+ "\x1Bb": "wordleft",
1304
+ "\x1B[1;5C": "wordright",
1305
+ "\x1B[1;3C": "wordright",
1306
+ "\x1Bf": "wordright",
1307
+ "\x01": "linestart",
1308
+ "\x05": "lineend",
1309
+ "\x7F": "erase",
1310
+ "\x1B[3~": "delete",
1311
+ "\b": "killword",
1312
+ "\x1B\x7F": "killword",
1313
+ "\x1B[3;5~": "killnext",
1314
+ "\x1Bd": "killnext",
1315
+ "\x15": "clear",
1316
+ "\v": "killend",
1317
+ "\x17": "word",
1318
+ "\x19": "yank",
1319
+ "\x1A": "suspend",
1320
+ "\t": "tab",
1321
+ "\x1F": "help",
1322
+ "\x1BOP": "help",
1323
+ "\x1B[11~": "help"
1324
+ };
1325
+ CTRL_KEY = /^ctrl-[abd-gkln-z]$/;
1326
+ });
1327
+
1328
+ // ../kit/src/redraw.ts
1329
+ function overwrite(lines, columns) {
1330
+ return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
1331
+ `);
1332
+ }
1333
+ function rowsTaken(lines, columns) {
1334
+ return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
1335
+ }
1336
+ var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
1337
+ var init_redraw = __esm(() => {
1338
+ init_format();
1339
+ });
1340
+
1341
+ // ../kit/src/prompt.ts
1342
+ import process15 from "process";
1343
+ function readKeys(input, paste = { active: false }) {
1344
+ return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
1345
+ }
1346
+ function roomAfter(question, columns) {
1347
+ return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
1348
+ }
1349
+ function withCaret(colors, line, room, dim = false) {
1350
+ const { before, at, after } = visible(line, room);
1351
+ const tone = dim ? colors.dim : (text) => text;
1352
+ return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
1353
+ }
1354
+ function sharedStart(texts) {
1355
+ const [first = [], ...rest] = texts.map((text) => [...text]);
1356
+ let length = first.length;
1357
+ for (const chars of rest) {
1358
+ const differs = chars.findIndex((char, index) => char !== first[index]);
1359
+ length = Math.min(length, differs === -1 ? chars.length : differs);
1360
+ }
1361
+ return first.slice(0, length).join("");
1362
+ }
1363
+ function listed2(colors, found, columns) {
1364
+ const shared = sharedStart(found);
1365
+ const cut = Math.max(shared.lastIndexOf("/"), shared.lastIndexOf(" ")) + 1;
1366
+ const names = found.slice(0, MAX_LISTED).map((each) => each.slice(cut));
1367
+ const more = found.length > MAX_LISTED ? ` \u2026 ${found.length - MAX_LISTED} more` : "";
1368
+ return ` ${colors.dim(truncate(names.join(" ") + more, Math.max(columns - 3, 1)))}`;
1369
+ }
1370
+ async function input2(question, { default: fallback, mask = false, validate, history, complete, ...settings } = {}) {
1371
+ let line = { text: "", caret: 0 };
1372
+ let invalid;
1373
+ let completions = [];
1374
+ const remembered = history === undefined || mask ? undefined : history;
1375
+ const earlier = remembered === undefined ? [] : earlierAnswers(remembered);
1376
+ let recalled = -1;
1377
+ let draft = line;
1378
+ const taken = () => line.text === "" ? fallback ?? "" : line.text;
1379
+ const shown = () => mask ? "*".repeat([...taken()].length) : taken();
1380
+ const accepted = await ask(question, settings, (colors, state, { columns }) => {
1381
+ if (state !== "asking")
1382
+ return [answer(colors, question, state, shown())];
1383
+ const typed = line.text === "" ? { text: shown(), caret: [...shown()].length } : { text: shown(), caret: line.caret };
1384
+ return [`${colors.cyan("?")} ${question} ${withCaret(colors, typed, roomAfter(question, columns), line.text === "")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`], ...completions.length > 1 ? [listed2(colors, completions, columns)] : []];
1385
+ }, (key) => {
1386
+ if (key === "cancel")
1387
+ return "cancel";
1388
+ invalid = undefined;
1389
+ completions = [];
1390
+ if (line.chained === true && endsKills(key))
1391
+ line = { ...line, chained: false };
1392
+ if (key === "tab") {
1393
+ const chars = [...line.text];
1394
+ const before = chars.slice(0, line.caret).join("");
1395
+ const found = complete?.(before) ?? [];
1396
+ const filled = sharedStart(found);
1397
+ if ([...filled].length > [...before].length)
1398
+ line = { ...line, text: filled + chars.slice(line.caret).join(""), caret: [...filled].length };
1399
+ else
1400
+ completions = found;
1401
+ return;
1402
+ }
1403
+ if (key === "enter") {
1404
+ invalid = validate?.(taken());
1405
+ return invalid === undefined ? "enter" : undefined;
1406
+ }
1407
+ if (key === "up" || key === "down") {
1408
+ const to = Math.min(Math.max(recalled + (key === "up" ? 1 : -1), -1), earlier.length - 1);
1409
+ if (recalled === -1)
1410
+ draft = line;
1411
+ recalled = to;
1412
+ const shown = to === -1 ? draft : { text: earlier[to], caret: [...earlier[to]].length };
1413
+ line = { ...shown, killed: line.killed ?? "" };
1414
+ return;
1415
+ }
1416
+ const edit = { home: "linestart", end: "lineend" }[key] ?? key;
1417
+ if (typeof edit === "object" || isEditKey(edit))
1418
+ line = editLine(line, edit);
1419
+ return;
1420
+ });
1421
+ if (!accepted)
1422
+ return;
1423
+ if (remembered !== undefined && taken() !== "")
1424
+ rememberAnswer(remembered, taken());
1425
+ return taken();
1426
+ }
1427
+ function answer(colors, question, state, picked) {
1428
+ return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1429
+ }
1430
+ async function ask(question, { hint, terminal = process15 }, render, press) {
1431
+ const { stdin, stderr } = terminal;
1432
+ if (!isInteractive(terminal))
1433
+ fail(`cannot ask "${question}" off a terminal`, 2, hint);
1434
+ const colors = paint(stderr);
1435
+ let current = "asking";
1436
+ let outcome;
1437
+ const columns = () => stderr.columns || 80;
1438
+ const draw = (state, last = false) => {
1439
+ const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
1440
+ const rows = rowsTaken(frame, columns());
1441
+ stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
1442
+ current = state;
1443
+ };
1444
+ const redraw = () => draw(current);
1445
+ const paste = { active: false };
1446
+ const stop = terminal.stop ?? (terminal === process15 ? stopJob : undefined);
1447
+ const suspend = () => {
1448
+ if (stop === undefined)
1449
+ return;
1450
+ stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
1451
+ stdin.setRawMode(false);
1452
+ stop();
1453
+ stdin.setRawMode(true);
1454
+ stderr.write("\x1B[?25l\x1B[?2004h");
1455
+ };
1456
+ try {
1457
+ stderr.on?.("resize", redraw);
1458
+ stdin.setRawMode(true);
1459
+ stdin.resume();
1460
+ stderr.write("\x1B[?25l\x1B[?2004h");
1461
+ draw("asking");
1462
+ return await new Promise((resolve) => {
1463
+ function onData(data) {
1464
+ for (const key of readKeys(data.toString(), paste)) {
1465
+ if (key === "suspend") {
1466
+ suspend();
1467
+ continue;
1468
+ }
1469
+ const pressed = press(key);
1470
+ if (pressed !== undefined) {
1471
+ settle(pressed);
1472
+ return;
1473
+ }
1474
+ }
1475
+ draw("asking");
1476
+ }
1477
+ function onEnd() {
1478
+ settle("cancel");
1479
+ }
1480
+ function settle(settled) {
1481
+ outcome = settled;
1482
+ stdin.off("data", onData);
1483
+ stdin.off("end", onEnd);
1484
+ resolve(settled === "enter");
1485
+ }
1486
+ stdin.on("data", onData);
1487
+ stdin.on("end", onEnd);
1488
+ });
1489
+ } finally {
1490
+ stderr.off?.("resize", redraw);
1491
+ draw(outcome ?? "cancel", true);
1492
+ stderr.write(`
1493
+ \x1B[?25h\x1B[?2004l`);
1494
+ stdin.setRawMode(false);
1495
+ stdin.pause();
1496
+ }
1497
+ }
1498
+ var PROMPT_KEYS, MAX_LISTED = 12;
1499
+ var init_prompt = __esm(() => {
1500
+ init_answers();
1501
+ init_args();
1502
+ init_format();
1503
+ init_job();
1504
+ init_mode();
1505
+ init_line();
1506
+ init_state();
1507
+ init_redraw();
1508
+ init_style();
1509
+ PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
1510
+ });
1511
+
1512
+ // src/gc.ts
1513
+ import process23 from "process";
1514
+
1515
+ // ../kit/src/index.ts
1516
+ init_args();
1517
+
817
1518
  // ../kit/src/argv.ts
818
1519
  import { readFileSync as readFileSync3, realpathSync } from "fs";
819
1520
  import { resolve as resolve3 } from "path";
@@ -838,7 +1539,17 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
838
1539
  const after = at === -1 ? [] : cmdline.slice(at + 1);
839
1540
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
840
1541
  }
1542
+ // ../kit/src/chart.ts
1543
+ init_format();
1544
+ init_mode();
1545
+ init_style();
1546
+ init_theme();
1547
+ // ../kit/src/ci.ts
1548
+ init_args();
1549
+ init_format();
1550
+
841
1551
  // ../kit/src/progress.ts
1552
+ init_format();
842
1553
  import process12 from "process";
843
1554
 
844
1555
  // ../kit/src/process.ts
@@ -964,6 +1675,8 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
964
1675
  }
965
1676
 
966
1677
  // ../kit/src/progress.ts
1678
+ init_style();
1679
+ init_theme();
967
1680
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
968
1681
  var FRAME_MS = 200;
969
1682
  var BAR_WIDTH = 20;
@@ -981,10 +1694,14 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
981
1694
  }, print: (text) => void stream.write(`${text}
982
1695
  `), stop: () => {
983
1696
  return;
1697
+ }, pause: () => () => {
1698
+ return;
984
1699
  } };
985
1700
  const write = stream.write.bind(stream);
986
1701
  let frame = 0;
987
1702
  let drawn = false;
1703
+ let paused = false;
1704
+ let stopped = false;
988
1705
  const columns = () => {
989
1706
  const now = stream.getWindowSize?.()[0] ?? stream.columns;
990
1707
  return now === undefined || now === 0 ? 80 : now;
@@ -995,6 +1712,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
995
1712
  drawn = false;
996
1713
  };
997
1714
  const draw = () => {
1715
+ if (paused)
1716
+ return;
998
1717
  const width = columns() - 1;
999
1718
  const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
1000
1719
  const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
@@ -1006,16 +1725,17 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1006
1725
  `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
1007
1726
  drawn = true;
1008
1727
  };
1009
- const timer = setInterval(draw, FRAME_MS);
1728
+ let timer = setInterval(draw, FRAME_MS);
1010
1729
  stream.on?.("resize", draw);
1011
- const restore = interceptOutput(clear);
1012
- const release = swallowInput();
1730
+ let restore = interceptOutput(clear);
1731
+ let release = swallowInput();
1013
1732
  const onExit = () => {
1014
1733
  clear();
1015
1734
  release();
1016
1735
  };
1017
1736
  const signals = holdSignals(stop);
1018
1737
  function stop() {
1738
+ stopped = true;
1019
1739
  clearInterval(timer);
1020
1740
  stream.off?.("resize", draw);
1021
1741
  clear();
@@ -1024,6 +1744,29 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1024
1744
  process12.off("exit", onExit);
1025
1745
  signals.release();
1026
1746
  }
1747
+ function pause() {
1748
+ if (paused || stopped)
1749
+ return () => {
1750
+ return;
1751
+ };
1752
+ paused = true;
1753
+ clearInterval(timer);
1754
+ stream.off?.("resize", draw);
1755
+ clear();
1756
+ restore();
1757
+ release();
1758
+ return () => {
1759
+ if (!paused || stopped)
1760
+ return;
1761
+ paused = false;
1762
+ timer = setInterval(draw, FRAME_MS);
1763
+ timer.unref();
1764
+ stream.on?.("resize", draw);
1765
+ restore = interceptOutput(clear);
1766
+ release = swallowInput();
1767
+ draw();
1768
+ };
1769
+ }
1027
1770
  timer.unref();
1028
1771
  process12.on("exit", onExit);
1029
1772
  return {
@@ -1034,7 +1777,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1034
1777
  `);
1035
1778
  draw();
1036
1779
  },
1037
- stop
1780
+ stop,
1781
+ pause
1038
1782
  };
1039
1783
  }
1040
1784
  function progressLine(stream = process12.stderr, env = process12.env) {
@@ -1059,6 +1803,7 @@ function progressLine(stream = process12.stderr, env = process12.env) {
1059
1803
  }
1060
1804
  },
1061
1805
  stop: region.stop,
1806
+ pause: region.pause,
1062
1807
  done: (text) => end(marked("ok", text, stream, formatDuration(performance.now() - begun), env)),
1063
1808
  failed: (text) => end(marked("problem", text, stream, undefined, env))
1064
1809
  };
@@ -1147,10 +1892,125 @@ function interceptOutput(clear) {
1147
1892
  }
1148
1893
  };
1149
1894
  }
1895
+
1896
+ // ../kit/src/ci.ts
1897
+ init_style();
1898
+
1899
+ // ../kit/src/tool.ts
1900
+ init_format();
1150
1901
  // ../kit/src/cli.ts
1151
- import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1152
- import { dirname as dirname3, join as join5 } from "path";
1153
- import process15 from "process";
1902
+ init_args();
1903
+ import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
1904
+ import { dirname as dirname4, join as join8 } from "path";
1905
+ import process19 from "process";
1906
+
1907
+ // ../kit/src/askpass.ts
1908
+ import { chmodSync, mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
1909
+ import { tmpdir } from "os";
1910
+ import { join as join6 } from "path";
1911
+ import process16 from "process";
1912
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1913
+ var ECHOED = /username|yes\/no/i;
1914
+ var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
1915
+ function askpass(pause) {
1916
+ if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
1917
+ return;
1918
+ const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
1919
+ const socketPath = join6(dir, "socket");
1920
+ const script = join6(dir, "askpass");
1921
+ let turn = Promise.resolve();
1922
+ const answer = async ({ prompt, notice }) => {
1923
+ const resume = pause();
1924
+ try {
1925
+ if (notice === true) {
1926
+ process16.stderr.write(`${prompt.trim()}
1927
+ `);
1928
+ return {};
1929
+ }
1930
+ await Promise.resolve().then(() => init_prompt());
1931
+ return { answer: await input2(prompt.trim(), { mask: !ECHOED.test(prompt) }) };
1932
+ } finally {
1933
+ resume();
1934
+ }
1935
+ };
1936
+ const respond = async (socket, request) => {
1937
+ const { promise, resolve } = Promise.withResolvers();
1938
+ const previous = turn;
1939
+ let reply = {};
1940
+ turn = promise;
1941
+ await previous;
1942
+ try {
1943
+ reply = await answer(request);
1944
+ } catch {} finally {
1945
+ socket.end(`${JSON.stringify(reply)}
1946
+ `);
1947
+ resolve();
1948
+ }
1949
+ };
1950
+ const server = Bun.listen({
1951
+ unix: socketPath,
1952
+ socket: {
1953
+ open: (socket) => {
1954
+ socket.data = { buffered: "" };
1955
+ },
1956
+ data: (socket, chunk) => {
1957
+ const before = socket.data.buffered;
1958
+ socket.data.buffered += chunk.toString();
1959
+ if (before.includes(`
1960
+ `) || !socket.data.buffered.includes(`
1961
+ `))
1962
+ return;
1963
+ respond(socket, JSON.parse(socket.data.buffered));
1964
+ }
1965
+ }
1966
+ });
1967
+ writeFileSync2(script, `#!/bin/sh
1968
+ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no-env-file --config=/dev/null ${quoted(process16.argv[1])} "$@"
1969
+ `);
1970
+ chmodSync(script, 448);
1971
+ return {
1972
+ env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
1973
+ close: () => {
1974
+ server.stop(true);
1975
+ rmSync(dir, { recursive: true, force: true });
1976
+ }
1977
+ };
1978
+ }
1979
+ async function askpassClient(argv) {
1980
+ const socketPath = process16.env[SOCKET_VARIABLE];
1981
+ if (socketPath === undefined)
1982
+ return;
1983
+ const request = { prompt: argv[0] ?? "", ...process16.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1984
+ const { promise, resolve } = Promise.withResolvers();
1985
+ let received = "";
1986
+ try {
1987
+ await Bun.connect({
1988
+ unix: socketPath,
1989
+ socket: {
1990
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1991
+ `),
1992
+ data: (_, chunk) => {
1993
+ received += chunk.toString();
1994
+ },
1995
+ close: () => resolve(received),
1996
+ error: () => resolve("")
1997
+ }
1998
+ });
1999
+ } catch {
2000
+ return 1;
2001
+ }
2002
+ const reply = await promise;
2003
+ if (reply === "")
2004
+ return 1;
2005
+ const { answer } = JSON.parse(reply);
2006
+ if (request.notice === true)
2007
+ return 0;
2008
+ if (answer === undefined)
2009
+ return 1;
2010
+ process16.stdout.write(`${answer}
2011
+ `);
2012
+ return 0;
2013
+ }
1154
2014
 
1155
2015
  // ../kit/src/completions.ts
1156
2016
  var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
@@ -1213,28 +2073,34 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
1213
2073
  }
1214
2074
 
1215
2075
  // ../kit/src/notify.ts
1216
- import process13 from "process";
2076
+ init_format();
2077
+ init_mode();
2078
+ import process17 from "process";
1217
2079
  var NOTIFY_AFTER_MS = 1e4;
1218
2080
  var CANCELLED = 130;
1219
2081
  function base64(text) {
1220
2082
  return Buffer.from(text).toString("base64");
1221
2083
  }
1222
- function notification(title, body, env = process13.env) {
1223
- const id = `kit${process13.pid}`;
2084
+ function notification(title, body, env = process17.env) {
2085
+ const id = `kit${process17.pid}`;
1224
2086
  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\\`];
1225
2087
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1226
2088
  }
1227
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
2089
+ function notifyEnd(command, code, ms, { stream = process17.stderr, env = process17.env } = {}) {
1228
2090
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1229
2091
  return;
1230
2092
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1231
2093
  }
1232
2094
 
2095
+ // ../kit/src/cli.ts
2096
+ init_style();
2097
+ init_text2();
2098
+
1233
2099
  // ../kit/src/usage.ts
1234
- import { appendFileSync, mkdirSync } from "fs";
1235
- import { homedir as homedir3 } from "os";
1236
- import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1237
- import process14 from "process";
2100
+ import { appendFileSync, mkdirSync as mkdirSync2 } from "fs";
2101
+ import { homedir as homedir4 } from "os";
2102
+ import { dirname as dirname3, isAbsolute, join as join7 } from "path";
2103
+ import process18 from "process";
1238
2104
 
1239
2105
  // ../kit/src/logs.ts
1240
2106
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -1248,14 +2114,14 @@ var usageError;
1248
2114
  function noteUsageError(message) {
1249
2115
  usageError = message;
1250
2116
  }
1251
- function stateHome(env = process14.env) {
2117
+ function stateHome(env = process18.env) {
1252
2118
  const dir = env.XDG_STATE_HOME;
1253
- return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
2119
+ return dir !== undefined && isAbsolute(dir) ? dir : join7(homedir4(), ".local", "state");
1254
2120
  }
1255
- function usagePath(env = process14.env) {
1256
- return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
2121
+ function usagePath(env = process18.env) {
2122
+ return join7(stateHome(env), CLI_FOLDER, "usage.jsonl");
1257
2123
  }
1258
- function usageRecorded(env = process14.env) {
2124
+ function usageRecorded(env = process18.env) {
1259
2125
  const off = env.KAYNOOO_CLI_NO_USAGE;
1260
2126
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1261
2127
  }
@@ -1269,12 +2135,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1269
2135
  usageError = undefined;
1270
2136
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1271
2137
  }
1272
- function recordUsage(entry, env = process14.env) {
2138
+ function recordUsage(entry, env = process18.env) {
1273
2139
  if (!usageRecorded(env))
1274
2140
  return;
1275
2141
  try {
1276
2142
  const path = usagePath(env);
1277
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
2143
+ mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
1278
2144
  appendFileSync(path, `${JSON.stringify(entry)}
1279
2145
  `, { mode: 384 });
1280
2146
  } catch {}
@@ -1291,8 +2157,8 @@ var TOP_OPTIONS = {
1291
2157
  completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1292
2158
  };
1293
2159
  function printError(prefix, message, hint, cause) {
1294
- const colors = paint(process15.stderr);
1295
- const styled = takesControlCodes(process15.stderr);
2160
+ const colors = paint(process19.stderr);
2161
+ const styled = takesControlCodes(process19.stderr);
1296
2162
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1297
2163
  const under = (label, text, tint) => text === undefined ? "" : `
1298
2164
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1395,17 +2261,20 @@ function packageVersion(entry = Bun.main) {
1395
2261
  try {
1396
2262
  resolved = realpathSync2(entry);
1397
2263
  } catch {}
1398
- for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
2264
+ for (let dir = dirname4(resolved);; dir = dirname4(dir)) {
1399
2265
  try {
1400
- const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
2266
+ const { version } = JSON.parse(readFileSync5(join8(dir, "package.json"), "utf8"));
1401
2267
  if (typeof version === "string")
1402
2268
  return version;
1403
2269
  } catch {}
1404
- if (dirname3(dir) === dir)
2270
+ if (dirname4(dir) === dir)
1405
2271
  return "0.0.0";
1406
2272
  }
1407
2273
  }
1408
2274
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
2275
+ const answered = await askpassClient(argv);
2276
+ if (answered !== undefined)
2277
+ return answered;
1409
2278
  if (argv[0] === COMPLETE)
1410
2279
  return printCandidates(leafCandidates(run, argv.slice(1)));
1411
2280
  if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
@@ -1429,16 +2298,46 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1429
2298
  }
1430
2299
  return code;
1431
2300
  }
1432
- // ../kit/src/folders.ts
1433
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
2301
+
2302
+ // ../kit/src/index.ts
2303
+ init_config();
2304
+
2305
+ // ../kit/src/excerpt.ts
2306
+ init_text2();
2307
+
2308
+ // ../kit/src/index.ts
2309
+ init_folders();
2310
+ init_format();
2311
+
2312
+ // ../kit/src/git.ts
2313
+ init_args();
2314
+ // ../kit/src/limit.ts
2315
+ init_args();
2316
+
2317
+ // ../kit/src/index.ts
2318
+ init_mode();
2319
+
2320
+ // ../kit/src/report.ts
2321
+ init_style();
2322
+ init_text2();
1434
2323
  // ../kit/src/secrets.ts
1435
2324
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1436
2325
  // ../kit/src/sessions.ts
1437
2326
  var {Glob } = globalThis.Bun;
1438
2327
  var SESSION_FILES = new Glob("*.json");
1439
2328
  var ACCOUNT_DIRS = new Glob("*/sessions");
2329
+
2330
+ // ../kit/src/index.ts
2331
+ init_style();
2332
+ init_text2();
2333
+ init_theme();
2334
+ init_user_config();
2335
+
1440
2336
  // ../kit/src/watch.ts
1441
- import process16 from "process";
2337
+ init_args();
2338
+ init_input();
2339
+ init_style();
2340
+ import process20 from "process";
1442
2341
  import { format } from "util";
1443
2342
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1444
2343
  var DEFAULT_SECONDS = 2;
@@ -1460,7 +2359,7 @@ function withoutWatch(args) {
1460
2359
  }
1461
2360
  return rest;
1462
2361
  }
1463
- async function watching(value, step, stream = process16.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
2362
+ async function watching(value, step, stream = process20.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1464
2363
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1465
2364
  if (!takesControlCodes(stream))
1466
2365
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1468,12 +2367,12 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1468
2367
  for (let round = 0;round < rounds; round++) {
1469
2368
  const held = [];
1470
2369
  const { log, info } = console;
1471
- const write = process16.stdout.write.bind(process16.stdout);
2370
+ const write = process20.stdout.write.bind(process20.stdout);
1472
2371
  const hold = (...parts) => void held.push(`${format(...parts)}
1473
2372
  `);
1474
2373
  console.log = hold;
1475
2374
  console.info = hold;
1476
- process16.stdout.write = (text) => {
2375
+ process20.stdout.write = (text) => {
1477
2376
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1478
2377
  return true;
1479
2378
  };
@@ -1482,7 +2381,7 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1482
2381
  } finally {
1483
2382
  console.log = log;
1484
2383
  console.info = info;
1485
- process16.stdout.write = write;
2384
+ process20.stdout.write = write;
1486
2385
  }
1487
2386
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1488
2387
  await sleep(interval);
@@ -1490,21 +2389,22 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1490
2389
  return code;
1491
2390
  }
1492
2391
  // ../kit/src/workspace-root.ts
1493
- import { homedir as homedir4 } from "os";
1494
- import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
1495
- import process17 from "process";
2392
+ init_user_config();
2393
+ import { homedir as homedir5 } from "os";
2394
+ import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
2395
+ import process21 from "process";
1496
2396
  function expandHome(path, home) {
1497
2397
  if (path === "~")
1498
2398
  return home;
1499
- return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
2399
+ return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
1500
2400
  }
1501
2401
  function configured(env, home) {
1502
2402
  const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
1503
2403
  return typeof folder === "string" && folder !== "" ? folder : undefined;
1504
2404
  }
1505
- function workspaceRoot({ given, env = process17.env, home = homedir4() } = {}) {
2405
+ function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
1506
2406
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1507
- return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
2407
+ return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
1508
2408
  }
1509
2409
  // src/git.ts
1510
2410
  async function git2(args, env) {
@@ -1578,7 +2478,7 @@ var OPTIONS = {
1578
2478
  };
1579
2479
  var RENAME = /^[RC]\d*$/;
1580
2480
  var NOT_A_REPOSITORY = /not a git repository/i;
1581
- var LITERAL = { ...process19.env, GIT_LITERAL_PATHSPECS: "1" };
2481
+ var LITERAL = { ...process23.env, GIT_LITERAL_PATHSPECS: "1" };
1582
2482
  function messageOf(title, lines, tickets) {
1583
2483
  return [title, lines.join(`
1584
2484
  `), tickets.join(`
@@ -1692,4 +2592,4 @@ ${(commit.stderr + commit.stdout).trim()}`;
1692
2592
  signals.release();
1693
2593
  }
1694
2594
  }
1695
- process19.exitCode = await runMain({ name: "gc", run: main });
2595
+ process23.exitCode = await runMain({ name: "gc", run: main });