@kaynooo/cli-git 0.17.0 → 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 (10) hide show
  1. package/dist/gb.js +1642 -1139
  2. package/dist/gc.js +1053 -153
  3. package/dist/gcl.js +1086 -166
  4. package/dist/gd.js +1064 -164
  5. package/dist/gf.js +1095 -169
  6. package/dist/gm.js +1648 -1145
  7. package/dist/gp.js +1073 -167
  8. package/dist/gst.js +1072 -172
  9. package/dist/gu.js +1059 -159
  10. package/package.json +2 -2
package/dist/gu.js CHANGED
@@ -1,22 +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/gu.ts
5
- import { mkdirSync as mkdirSync2, writeFileSync } from "fs";
6
- import { join as join7, resolve as resolve5 } from "path";
7
- import process19 from "process";
8
- // ../kit/src/args.ts
9
- import process9 from "process";
10
- import { parseArgs } from "util";
11
-
12
- // ../kit/src/format.ts
13
- import process7 from "process";
14
-
15
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
16
- var N = new Map;
17
- var Nt = /\s+\S*$/;
18
- var Y = /\s/;
19
- 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 = "...") {
20
17
  let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
21
18
  if (t.length <= e)
22
19
  return t;
@@ -27,13 +24,22 @@ function ko(t, e, r = "...") {
27
24
  c = c.trimEnd();
28
25
  return s ? (c + n).slice(0, l) : c + n;
29
26
  }
30
- 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));
31
- 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
+ });
32
40
 
33
41
  // ../kit/src/mode.ts
34
42
  import process2 from "process";
35
- var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
36
- var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
37
43
  function isSet(value) {
38
44
  return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
39
45
  }
@@ -50,12 +56,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
50
56
  function isInteractive(streams = process2) {
51
57
  return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
52
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
+ });
53
64
 
54
- // ../kit/src/style.ts
55
- import process6 from "process";
56
-
57
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
58
- var G2 = /^[a-f0-9]+$/i;
65
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
59
66
  function b(r) {
60
67
  let e = r.startsWith("#") ? r.slice(1) : r;
61
68
  if (!G2.test(e))
@@ -66,11 +73,6 @@ function b(r) {
66
73
  throw Error(`Invalid hex color length: ${e.length}`);
67
74
  return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
68
75
  }
69
- 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") => {
70
- let [l, n, c] = b(r);
71
- return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
72
- }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
73
- var h = new Set(["", "1", "2", "3", "true"]);
74
76
  function C(r, e = globalThis.process?.env ?? {}) {
75
77
  if (e.FORCE_COLOR !== undefined)
76
78
  return h.has(e.FORCE_COLOR);
@@ -84,7 +86,7 @@ function f(r, e = []) {
84
86
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
85
87
  let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
86
88
  return new Proxy(c, { get(t, i) {
87
- let a = B2[i];
89
+ let a = B[i];
88
90
  if (Array.isArray(a)) {
89
91
  let s = g.get(i);
90
92
  if (s === undefined)
@@ -107,13 +109,21 @@ function f(r, e = []) {
107
109
  function Fe(r = {}) {
108
110
  return f(r);
109
111
  }
110
- 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
+ });
111
122
 
112
- // ../kit/src/theme.ts
113
- import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
114
- import { homedir as homedir2 } from "os";
115
- import { join as join3, resolve as resolve2 } from "path";
116
- 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
+ });
117
127
 
118
128
  // ../kit/src/config.ts
119
129
  import { existsSync } from "fs";
@@ -129,6 +139,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
129
139
  return;
130
140
  }
131
141
  }
142
+ var init_config = __esm(() => {
143
+ init_args();
144
+ });
132
145
 
133
146
  // ../kit/src/user-config.ts
134
147
  import { existsSync as existsSync2, readFileSync } from "fs";
@@ -160,13 +173,17 @@ function readUserConfig(bin, where = {}, legacy = []) {
160
173
  return {};
161
174
  }
162
175
  }
176
+ var init_user_config = () => {};
163
177
 
164
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";
165
183
  function toLinear(channel) {
166
184
  const value = channel / 255;
167
185
  return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
168
186
  }
169
- 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)));
170
187
  function toOklab(hex) {
171
188
  const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
172
189
  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
@@ -181,7 +198,6 @@ function fromOklab([lightness, a, b]) {
181
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];
182
199
  return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
183
200
  }
184
- var ENDS = new Map;
185
201
  function gradientAt(theme, ratio) {
186
202
  if (theme.gradient === undefined)
187
203
  return;
@@ -195,33 +211,11 @@ function gradientAt(theme, ratio) {
195
211
  const [from, to] = ends;
196
212
  return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
197
213
  }
198
- var DEFAULT = {
199
- 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" },
200
- 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" },
201
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
202
- bins: {},
203
- gradient: ["#c084fc", "#67e8f9"]
204
- };
205
- 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" };
206
- 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" };
207
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
208
- var PRESETS = {
209
- default: {},
210
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
211
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
212
- ascii: { glyphs: ASCII }
213
- };
214
- 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"]);
215
- var HEX = /^#[0-9a-f]{6}$/i;
216
- var CONTROL = /\p{Cc}/u;
217
- var MAX_FILE_BYTES = 64 * 1024;
218
- var SPACES = /\s+/;
219
214
  function isColorSpec(spec) {
220
215
  if (typeof spec === "number")
221
216
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
222
217
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
223
218
  }
224
- var CUBE = [0, 95, 135, 175, 215, 255];
225
219
  function cubeLevel(channel) {
226
220
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
227
221
  }
@@ -329,7 +323,6 @@ function applyFile(theme, file, where, warn) {
329
323
  function endsWalk(home) {
330
324
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
331
325
  }
332
- var warned = new Set;
333
326
  function warnOnce(message) {
334
327
  if (warned.has(message))
335
328
  return;
@@ -366,8 +359,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
366
359
  }
367
360
  return { theme, sources, preset };
368
361
  }
369
- var current;
370
- var currentKey = "";
371
362
  function activeTheme() {
372
363
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
373
364
  if (current === undefined || key !== currentKey) {
@@ -376,9 +367,38 @@ function activeTheme() {
376
367
  }
377
368
  return current;
378
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
+ });
379
399
 
380
400
  // ../kit/src/style.ts
381
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
401
+ import process6 from "process";
382
402
  function takesControlCodes(stream, env = process6.env) {
383
403
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
384
404
  }
@@ -398,17 +418,24 @@ function role(name, stream, env = process6.env) {
398
418
  const colors = paint(stream, env);
399
419
  return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
400
420
  }
401
- var STATUS_WORDS = {
402
- passed: ["passed", "success", "succeeded", "ok"],
403
- failed: ["failed", "failure", "error", "errored"],
404
- running: ["running", "in_progress", "started", "holding"],
405
- queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
406
- skipped: ["skipped", "cancelled", "canceled", "manual"]
407
- };
408
- 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
+ });
409
436
 
410
437
  // ../kit/src/format.ts
411
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
438
+ import process7 from "process";
412
439
  function formatSeconds(total) {
413
440
  let rest = Math.max(0, Math.round(total));
414
441
  const amounts = UNITS.map(([unit, size]) => {
@@ -440,10 +467,8 @@ function formatAge(date, now = Date.now()) {
440
467
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
441
468
  }
442
469
  function truncate(text, width) {
443
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
470
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
444
471
  }
445
- var LINE_BREAKS = /\s*\n\s*/g;
446
- var ESCAPE = String.fromCharCode(27);
447
472
  function textWidth(text) {
448
473
  return Bun.stringWidth(text);
449
474
  }
@@ -492,12 +517,18 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
492
517
  function printJson(value) {
493
518
  console.log(jsonText(value));
494
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
+ });
495
529
 
496
530
  // ../kit/src/help.ts
497
531
  import process8 from "process";
498
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
499
- var USAGE_PREFIX = /^usage:\s*/i;
500
- var FULL_STOP = /\.$/;
501
532
  function usageLine(usage, colors = paint(process8.stdout)) {
502
533
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
503
534
  }
@@ -534,7 +565,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
534
565
  return [];
535
566
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
536
567
  }
537
- var MAX_INLINE_CHOICES = 24;
538
568
  function optionRows(options, colors = paint(process8.stdout)) {
539
569
  const rows = Object.entries(options).map(([name, option]) => {
540
570
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -549,9 +579,16 @@ function optionRows(options, colors = paint(process8.stdout)) {
549
579
  const width = Math.max(0, ...rows.map((row) => row.width));
550
580
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
551
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
+ });
552
590
 
553
591
  // ../kit/src/text.ts
554
- var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
555
592
  function distance(a, b) {
556
593
  const left = [...a];
557
594
  const right = [...b];
@@ -577,8 +614,12 @@ function closest(name, names) {
577
614
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
578
615
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
579
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
+
580
622
  // ../kit/src/input.ts
581
- var WHOLE = /^\d+$/;
582
623
  function wholeNumber(value, name, fallback, min = 1) {
583
624
  if (value === undefined)
584
625
  return fallback;
@@ -587,8 +628,6 @@ function wholeNumber(value, name, fallback, min = 1) {
587
628
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
588
629
  return number;
589
630
  }
590
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
591
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
592
631
  function duration(value, name, fallback, unit = "s") {
593
632
  if (value === undefined)
594
633
  return fallback;
@@ -598,40 +637,27 @@ function duration(value, name, fallback, unit = "s") {
598
637
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
599
638
  return ms;
600
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
+ });
601
647
 
602
648
  // ../kit/src/args.ts
603
- var DASHES = /^-+/;
649
+ import process9 from "process";
650
+ import { parseArgs } from "util";
604
651
  function jsonOption(holds) {
605
652
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
606
653
  }
607
- class Exit extends Error {
608
- code;
609
- hint;
610
- constructor(message, code, hint) {
611
- super(message);
612
- this.code = code;
613
- this.hint = hint;
614
- }
615
- }
616
654
  function fail(message, code = 2, hint) {
617
655
  throw new Exit(message, code, hint);
618
656
  }
619
-
620
- class UsageError extends Exit {
621
- constructor(message, hint) {
622
- super(message, 2, hint);
623
- }
624
- }
625
657
  function badUsage(message) {
626
658
  throw new UsageError(message);
627
659
  }
628
660
 
629
- class HelpShown extends Exit {
630
- constructor() {
631
- super("help shown", 0);
632
- }
633
- }
634
-
635
661
  class Completing {
636
662
  options;
637
663
  positionals;
@@ -642,11 +668,6 @@ class Completing {
642
668
  this.candidates = candidates;
643
669
  }
644
670
  }
645
- var completion = { active: false };
646
- var OUTPUT_OPTIONS = {
647
- color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
648
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
649
- };
650
671
  function applyOutput(color, plain, env = process9.env) {
651
672
  const when = plain === true ? "never" : color ?? "auto";
652
673
  if (when === "auto")
@@ -800,7 +821,6 @@ function parseError(error) {
800
821
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
801
822
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
802
823
  }
803
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
804
824
  function nearestOption(message, options, allowNegative) {
805
825
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
806
826
  if (typed === undefined)
@@ -816,6 +836,687 @@ function nearestOption(message, options, allowNegative) {
816
836
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
817
837
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
818
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/gu.ts
1513
+ import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
1514
+ import { join as join10, resolve as resolve5 } from "path";
1515
+ import process23 from "process";
1516
+
1517
+ // ../kit/src/index.ts
1518
+ init_args();
1519
+
819
1520
  // ../kit/src/argv.ts
820
1521
  import { readFileSync as readFileSync3, realpathSync } from "fs";
821
1522
  import { resolve as resolve3 } from "path";
@@ -840,7 +1541,17 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
840
1541
  const after = at === -1 ? [] : cmdline.slice(at + 1);
841
1542
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
842
1543
  }
1544
+ // ../kit/src/chart.ts
1545
+ init_format();
1546
+ init_mode();
1547
+ init_style();
1548
+ init_theme();
1549
+ // ../kit/src/ci.ts
1550
+ init_args();
1551
+ init_format();
1552
+
843
1553
  // ../kit/src/progress.ts
1554
+ init_format();
844
1555
  import process12 from "process";
845
1556
 
846
1557
  // ../kit/src/process.ts
@@ -966,6 +1677,8 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
966
1677
  }
967
1678
 
968
1679
  // ../kit/src/progress.ts
1680
+ init_style();
1681
+ init_theme();
969
1682
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
970
1683
  var FRAME_MS = 200;
971
1684
  var BAR_WIDTH = 20;
@@ -983,10 +1696,14 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
983
1696
  }, print: (text) => void stream.write(`${text}
984
1697
  `), stop: () => {
985
1698
  return;
1699
+ }, pause: () => () => {
1700
+ return;
986
1701
  } };
987
1702
  const write = stream.write.bind(stream);
988
1703
  let frame = 0;
989
1704
  let drawn = false;
1705
+ let paused = false;
1706
+ let stopped = false;
990
1707
  const columns = () => {
991
1708
  const now = stream.getWindowSize?.()[0] ?? stream.columns;
992
1709
  return now === undefined || now === 0 ? 80 : now;
@@ -997,6 +1714,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
997
1714
  drawn = false;
998
1715
  };
999
1716
  const draw = () => {
1717
+ if (paused)
1718
+ return;
1000
1719
  const width = columns() - 1;
1001
1720
  const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
1002
1721
  const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
@@ -1008,16 +1727,17 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1008
1727
  `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
1009
1728
  drawn = true;
1010
1729
  };
1011
- const timer = setInterval(draw, FRAME_MS);
1730
+ let timer = setInterval(draw, FRAME_MS);
1012
1731
  stream.on?.("resize", draw);
1013
- const restore = interceptOutput(clear);
1014
- const release = swallowInput();
1732
+ let restore = interceptOutput(clear);
1733
+ let release = swallowInput();
1015
1734
  const onExit = () => {
1016
1735
  clear();
1017
1736
  release();
1018
1737
  };
1019
1738
  const signals = holdSignals(stop);
1020
1739
  function stop() {
1740
+ stopped = true;
1021
1741
  clearInterval(timer);
1022
1742
  stream.off?.("resize", draw);
1023
1743
  clear();
@@ -1026,6 +1746,29 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1026
1746
  process12.off("exit", onExit);
1027
1747
  signals.release();
1028
1748
  }
1749
+ function pause() {
1750
+ if (paused || stopped)
1751
+ return () => {
1752
+ return;
1753
+ };
1754
+ paused = true;
1755
+ clearInterval(timer);
1756
+ stream.off?.("resize", draw);
1757
+ clear();
1758
+ restore();
1759
+ release();
1760
+ return () => {
1761
+ if (!paused || stopped)
1762
+ return;
1763
+ paused = false;
1764
+ timer = setInterval(draw, FRAME_MS);
1765
+ timer.unref();
1766
+ stream.on?.("resize", draw);
1767
+ restore = interceptOutput(clear);
1768
+ release = swallowInput();
1769
+ draw();
1770
+ };
1771
+ }
1029
1772
  timer.unref();
1030
1773
  process12.on("exit", onExit);
1031
1774
  return {
@@ -1036,7 +1779,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1036
1779
  `);
1037
1780
  draw();
1038
1781
  },
1039
- stop
1782
+ stop,
1783
+ pause
1040
1784
  };
1041
1785
  }
1042
1786
  function progressLine(stream = process12.stderr, env = process12.env) {
@@ -1061,6 +1805,7 @@ function progressLine(stream = process12.stderr, env = process12.env) {
1061
1805
  }
1062
1806
  },
1063
1807
  stop: region.stop,
1808
+ pause: region.pause,
1064
1809
  done: (text) => end(marked("ok", text, stream, formatDuration(performance.now() - begun), env)),
1065
1810
  failed: (text) => end(marked("problem", text, stream, undefined, env))
1066
1811
  };
@@ -1149,10 +1894,125 @@ function interceptOutput(clear) {
1149
1894
  }
1150
1895
  };
1151
1896
  }
1897
+
1898
+ // ../kit/src/ci.ts
1899
+ init_style();
1900
+
1901
+ // ../kit/src/tool.ts
1902
+ init_format();
1152
1903
  // ../kit/src/cli.ts
1153
- import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1154
- import { dirname as dirname3, join as join5 } from "path";
1155
- import process15 from "process";
1904
+ init_args();
1905
+ import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
1906
+ import { dirname as dirname4, join as join8 } from "path";
1907
+ import process19 from "process";
1908
+
1909
+ // ../kit/src/askpass.ts
1910
+ import { chmodSync, mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
1911
+ import { tmpdir } from "os";
1912
+ import { join as join6 } from "path";
1913
+ import process16 from "process";
1914
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1915
+ var ECHOED = /username|yes\/no/i;
1916
+ var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
1917
+ function askpass(pause) {
1918
+ if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
1919
+ return;
1920
+ const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
1921
+ const socketPath = join6(dir, "socket");
1922
+ const script = join6(dir, "askpass");
1923
+ let turn = Promise.resolve();
1924
+ const answer = async ({ prompt, notice }) => {
1925
+ const resume = pause();
1926
+ try {
1927
+ if (notice === true) {
1928
+ process16.stderr.write(`${prompt.trim()}
1929
+ `);
1930
+ return {};
1931
+ }
1932
+ await Promise.resolve().then(() => init_prompt());
1933
+ return { answer: await input2(prompt.trim(), { mask: !ECHOED.test(prompt) }) };
1934
+ } finally {
1935
+ resume();
1936
+ }
1937
+ };
1938
+ const respond = async (socket, request) => {
1939
+ const { promise, resolve } = Promise.withResolvers();
1940
+ const previous = turn;
1941
+ let reply = {};
1942
+ turn = promise;
1943
+ await previous;
1944
+ try {
1945
+ reply = await answer(request);
1946
+ } catch {} finally {
1947
+ socket.end(`${JSON.stringify(reply)}
1948
+ `);
1949
+ resolve();
1950
+ }
1951
+ };
1952
+ const server = Bun.listen({
1953
+ unix: socketPath,
1954
+ socket: {
1955
+ open: (socket) => {
1956
+ socket.data = { buffered: "" };
1957
+ },
1958
+ data: (socket, chunk) => {
1959
+ const before = socket.data.buffered;
1960
+ socket.data.buffered += chunk.toString();
1961
+ if (before.includes(`
1962
+ `) || !socket.data.buffered.includes(`
1963
+ `))
1964
+ return;
1965
+ respond(socket, JSON.parse(socket.data.buffered));
1966
+ }
1967
+ }
1968
+ });
1969
+ writeFileSync2(script, `#!/bin/sh
1970
+ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no-env-file --config=/dev/null ${quoted(process16.argv[1])} "$@"
1971
+ `);
1972
+ chmodSync(script, 448);
1973
+ return {
1974
+ env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
1975
+ close: () => {
1976
+ server.stop(true);
1977
+ rmSync(dir, { recursive: true, force: true });
1978
+ }
1979
+ };
1980
+ }
1981
+ async function askpassClient(argv) {
1982
+ const socketPath = process16.env[SOCKET_VARIABLE];
1983
+ if (socketPath === undefined)
1984
+ return;
1985
+ const request = { prompt: argv[0] ?? "", ...process16.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
1986
+ const { promise, resolve } = Promise.withResolvers();
1987
+ let received = "";
1988
+ try {
1989
+ await Bun.connect({
1990
+ unix: socketPath,
1991
+ socket: {
1992
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
1993
+ `),
1994
+ data: (_, chunk) => {
1995
+ received += chunk.toString();
1996
+ },
1997
+ close: () => resolve(received),
1998
+ error: () => resolve("")
1999
+ }
2000
+ });
2001
+ } catch {
2002
+ return 1;
2003
+ }
2004
+ const reply = await promise;
2005
+ if (reply === "")
2006
+ return 1;
2007
+ const { answer } = JSON.parse(reply);
2008
+ if (request.notice === true)
2009
+ return 0;
2010
+ if (answer === undefined)
2011
+ return 1;
2012
+ process16.stdout.write(`${answer}
2013
+ `);
2014
+ return 0;
2015
+ }
1156
2016
 
1157
2017
  // ../kit/src/completions.ts
1158
2018
  var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
@@ -1215,28 +2075,34 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
1215
2075
  }
1216
2076
 
1217
2077
  // ../kit/src/notify.ts
1218
- import process13 from "process";
2078
+ init_format();
2079
+ init_mode();
2080
+ import process17 from "process";
1219
2081
  var NOTIFY_AFTER_MS = 1e4;
1220
2082
  var CANCELLED = 130;
1221
2083
  function base64(text) {
1222
2084
  return Buffer.from(text).toString("base64");
1223
2085
  }
1224
- function notification(title, body, env = process13.env) {
1225
- const id = `kit${process13.pid}`;
2086
+ function notification(title, body, env = process17.env) {
2087
+ const id = `kit${process17.pid}`;
1226
2088
  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\\`];
1227
2089
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1228
2090
  }
1229
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
2091
+ function notifyEnd(command, code, ms, { stream = process17.stderr, env = process17.env } = {}) {
1230
2092
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1231
2093
  return;
1232
2094
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1233
2095
  }
1234
2096
 
2097
+ // ../kit/src/cli.ts
2098
+ init_style();
2099
+ init_text2();
2100
+
1235
2101
  // ../kit/src/usage.ts
1236
- import { appendFileSync, mkdirSync } from "fs";
1237
- import { homedir as homedir3 } from "os";
1238
- import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1239
- import process14 from "process";
2102
+ import { appendFileSync, mkdirSync as mkdirSync2 } from "fs";
2103
+ import { homedir as homedir4 } from "os";
2104
+ import { dirname as dirname3, isAbsolute, join as join7 } from "path";
2105
+ import process18 from "process";
1240
2106
 
1241
2107
  // ../kit/src/logs.ts
1242
2108
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -1250,14 +2116,14 @@ var usageError;
1250
2116
  function noteUsageError(message) {
1251
2117
  usageError = message;
1252
2118
  }
1253
- function stateHome(env = process14.env) {
2119
+ function stateHome(env = process18.env) {
1254
2120
  const dir = env.XDG_STATE_HOME;
1255
- return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
2121
+ return dir !== undefined && isAbsolute(dir) ? dir : join7(homedir4(), ".local", "state");
1256
2122
  }
1257
- function usagePath(env = process14.env) {
1258
- return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
2123
+ function usagePath(env = process18.env) {
2124
+ return join7(stateHome(env), CLI_FOLDER, "usage.jsonl");
1259
2125
  }
1260
- function usageRecorded(env = process14.env) {
2126
+ function usageRecorded(env = process18.env) {
1261
2127
  const off = env.KAYNOOO_CLI_NO_USAGE;
1262
2128
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1263
2129
  }
@@ -1271,12 +2137,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1271
2137
  usageError = undefined;
1272
2138
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1273
2139
  }
1274
- function recordUsage(entry, env = process14.env) {
2140
+ function recordUsage(entry, env = process18.env) {
1275
2141
  if (!usageRecorded(env))
1276
2142
  return;
1277
2143
  try {
1278
2144
  const path = usagePath(env);
1279
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
2145
+ mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
1280
2146
  appendFileSync(path, `${JSON.stringify(entry)}
1281
2147
  `, { mode: 384 });
1282
2148
  } catch {}
@@ -1293,8 +2159,8 @@ var TOP_OPTIONS = {
1293
2159
  completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1294
2160
  };
1295
2161
  function printError(prefix, message, hint, cause) {
1296
- const colors = paint(process15.stderr);
1297
- const styled = takesControlCodes(process15.stderr);
2162
+ const colors = paint(process19.stderr);
2163
+ const styled = takesControlCodes(process19.stderr);
1298
2164
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1299
2165
  const under = (label, text, tint) => text === undefined ? "" : `
1300
2166
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1397,17 +2263,20 @@ function packageVersion(entry = Bun.main) {
1397
2263
  try {
1398
2264
  resolved = realpathSync2(entry);
1399
2265
  } catch {}
1400
- for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
2266
+ for (let dir = dirname4(resolved);; dir = dirname4(dir)) {
1401
2267
  try {
1402
- const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
2268
+ const { version } = JSON.parse(readFileSync5(join8(dir, "package.json"), "utf8"));
1403
2269
  if (typeof version === "string")
1404
2270
  return version;
1405
2271
  } catch {}
1406
- if (dirname3(dir) === dir)
2272
+ if (dirname4(dir) === dir)
1407
2273
  return "0.0.0";
1408
2274
  }
1409
2275
  }
1410
2276
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
2277
+ const answered = await askpassClient(argv);
2278
+ if (answered !== undefined)
2279
+ return answered;
1411
2280
  if (argv[0] === COMPLETE)
1412
2281
  return printCandidates(leafCandidates(run, argv.slice(1)));
1413
2282
  if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
@@ -1431,16 +2300,46 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1431
2300
  }
1432
2301
  return code;
1433
2302
  }
1434
- // ../kit/src/folders.ts
1435
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
2303
+
2304
+ // ../kit/src/index.ts
2305
+ init_config();
2306
+
2307
+ // ../kit/src/excerpt.ts
2308
+ init_text2();
2309
+
2310
+ // ../kit/src/index.ts
2311
+ init_folders();
2312
+ init_format();
2313
+
2314
+ // ../kit/src/git.ts
2315
+ init_args();
2316
+ // ../kit/src/limit.ts
2317
+ init_args();
2318
+
2319
+ // ../kit/src/index.ts
2320
+ init_mode();
2321
+
2322
+ // ../kit/src/report.ts
2323
+ init_style();
2324
+ init_text2();
1436
2325
  // ../kit/src/secrets.ts
1437
2326
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1438
2327
  // ../kit/src/sessions.ts
1439
2328
  var {Glob } = globalThis.Bun;
1440
2329
  var SESSION_FILES = new Glob("*.json");
1441
2330
  var ACCOUNT_DIRS = new Glob("*/sessions");
2331
+
2332
+ // ../kit/src/index.ts
2333
+ init_style();
2334
+ init_text2();
2335
+ init_theme();
2336
+ init_user_config();
2337
+
1442
2338
  // ../kit/src/watch.ts
1443
- import process16 from "process";
2339
+ init_args();
2340
+ init_input();
2341
+ init_style();
2342
+ import process20 from "process";
1444
2343
  import { format } from "util";
1445
2344
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1446
2345
  var DEFAULT_SECONDS = 2;
@@ -1462,7 +2361,7 @@ function withoutWatch(args) {
1462
2361
  }
1463
2362
  return rest;
1464
2363
  }
1465
- async function watching(value, step, stream = process16.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
2364
+ async function watching(value, step, stream = process20.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1466
2365
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1467
2366
  if (!takesControlCodes(stream))
1468
2367
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1470,12 +2369,12 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1470
2369
  for (let round = 0;round < rounds; round++) {
1471
2370
  const held = [];
1472
2371
  const { log, info } = console;
1473
- const write = process16.stdout.write.bind(process16.stdout);
2372
+ const write = process20.stdout.write.bind(process20.stdout);
1474
2373
  const hold = (...parts) => void held.push(`${format(...parts)}
1475
2374
  `);
1476
2375
  console.log = hold;
1477
2376
  console.info = hold;
1478
- process16.stdout.write = (text) => {
2377
+ process20.stdout.write = (text) => {
1479
2378
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1480
2379
  return true;
1481
2380
  };
@@ -1484,7 +2383,7 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1484
2383
  } finally {
1485
2384
  console.log = log;
1486
2385
  console.info = info;
1487
- process16.stdout.write = write;
2386
+ process20.stdout.write = write;
1488
2387
  }
1489
2388
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1490
2389
  await sleep(interval);
@@ -1492,21 +2391,22 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1492
2391
  return code;
1493
2392
  }
1494
2393
  // ../kit/src/workspace-root.ts
1495
- import { homedir as homedir4 } from "os";
1496
- import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
1497
- import process17 from "process";
2394
+ init_user_config();
2395
+ import { homedir as homedir5 } from "os";
2396
+ import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
2397
+ import process21 from "process";
1498
2398
  function expandHome(path, home) {
1499
2399
  if (path === "~")
1500
2400
  return home;
1501
- return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
2401
+ return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
1502
2402
  }
1503
2403
  function configured(env, home) {
1504
2404
  const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
1505
2405
  return typeof folder === "string" && folder !== "" ? folder : undefined;
1506
2406
  }
1507
- function workspaceRoot({ given, env = process17.env, home = homedir4() } = {}) {
2407
+ function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
1508
2408
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1509
- return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
2409
+ return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
1510
2410
  }
1511
2411
  // src/git.ts
1512
2412
  async function git2(args, env) {
@@ -1526,7 +2426,7 @@ var OPTIONS = {
1526
2426
  commit: { type: "boolean", short: "c", description: "undo the last commit, keeping its changes staged" },
1527
2427
  json: jsonOption("{action, paths?, saved?, commit?} of what was undone, saved being the patch of a discard")
1528
2428
  };
1529
- var LITERAL = { ...process19.env, GIT_LITERAL_PATHSPECS: "1" };
2429
+ var LITERAL = { ...process23.env, GIT_LITERAL_PATHSPECS: "1" };
1530
2430
  var PLAIN_PATCH = ["--binary", "--no-ext-diff", "--no-textconv", "--no-color", "--no-relative", "--submodule=short", "--src-prefix=a/", "--dst-prefix=b/"];
1531
2431
  var NOT_A_REPOSITORY = /not a git repository/i;
1532
2432
  async function checked(args) {
@@ -1583,11 +2483,11 @@ async function main(argv) {
1583
2483
  return 0;
1584
2484
  }
1585
2485
  const patch = await checked(["diff", ...PLAIN_PATCH, "--", ...positionals]);
1586
- const folder = join7(resolve5((await checked(["rev-parse", "--git-dir"])).trim()), "gu");
1587
- const saved = join7(folder, `${new Date().toISOString().replaceAll(":", "-")}.patch`);
2486
+ const folder = join10(resolve5((await checked(["rev-parse", "--git-dir"])).trim()), "gu");
2487
+ const saved = join10(folder, `${new Date().toISOString().replaceAll(":", "-")}.patch`);
1588
2488
  const top = (await checked(["rev-parse", "--show-toplevel"])).trim();
1589
- mkdirSync2(folder, { recursive: true });
1590
- writeFileSync(saved, patch);
2489
+ mkdirSync3(folder, { recursive: true });
2490
+ writeFileSync3(saved, patch);
1591
2491
  const reverts = await git2(["-C", top, "apply", "--check", "--reverse", "--whitespace=nowarn", saved]);
1592
2492
  if (reverts.code !== 0)
1593
2493
  fail(`the patch saved to ${saved} would not put the change back, nothing discarded:
@@ -1599,4 +2499,4 @@ ${reverts.stderr.trim()}`, 1);
1599
2499
  console.log(`discarded ${paths.join(", ")}, saved to ${saved} (git apply puts it back)`);
1600
2500
  return 0;
1601
2501
  }
1602
- process19.exitCode = await runMain({ name: "gu", run: main });
2502
+ process23.exitCode = await runMain({ name: "gu", run: main });