@kaynooo/cli-git 0.17.0 → 0.17.2

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 +1674 -1141
  3. package/dist/gc.js +1089 -159
  4. package/dist/gcl.js +1124 -174
  5. package/dist/gd.js +1100 -170
  6. package/dist/gf.js +1131 -175
  7. package/dist/gm.js +1686 -1155
  8. package/dist/gp.js +1110 -174
  9. package/dist/gst.js +1108 -178
  10. package/dist/gu.js +1097 -167
  11. package/package.json +2 -2
package/dist/gcl.js CHANGED
@@ -1,23 +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/gcl.ts
5
- import { existsSync as existsSync4, readdirSync, realpathSync as realpathSync3, statSync as statSync2 } from "fs";
6
- import { homedir as homedir5 } from "os";
7
- import { basename, join as join8, resolve as resolve6 } from "path";
8
- import process20 from "process";
9
- // ../kit/src/args.ts
10
- import process9 from "process";
11
- import { parseArgs } from "util";
12
-
13
- // ../kit/src/format.ts
14
- import process7 from "process";
15
-
16
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
17
- var N = new Map;
18
- var Nt = /\s+\S*$/;
19
- var Y = /\s/;
20
- 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 = "...") {
21
17
  let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
22
18
  if (t.length <= e)
23
19
  return t;
@@ -28,13 +24,22 @@ function ko(t, e, r = "...") {
28
24
  c = c.trimEnd();
29
25
  return s ? (c + n).slice(0, l) : c + n;
30
26
  }
31
- 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));
32
- 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
+ });
33
40
 
34
41
  // ../kit/src/mode.ts
35
42
  import process2 from "process";
36
- var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
37
- var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
38
43
  function isSet(value) {
39
44
  return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
40
45
  }
@@ -51,12 +56,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
51
56
  function isInteractive(streams = process2) {
52
57
  return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
53
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
+ });
54
64
 
55
- // ../kit/src/style.ts
56
- import process6 from "process";
57
-
58
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
59
- var G2 = /^[a-f0-9]+$/i;
65
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
60
66
  function b(r) {
61
67
  let e = r.startsWith("#") ? r.slice(1) : r;
62
68
  if (!G2.test(e))
@@ -67,11 +73,6 @@ function b(r) {
67
73
  throw Error(`Invalid hex color length: ${e.length}`);
68
74
  return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
69
75
  }
70
- 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") => {
71
- let [l, n, c] = b(r);
72
- return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
73
- }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
74
- var h = new Set(["", "1", "2", "3", "true"]);
75
76
  function C(r, e = globalThis.process?.env ?? {}) {
76
77
  if (e.FORCE_COLOR !== undefined)
77
78
  return h.has(e.FORCE_COLOR);
@@ -85,7 +86,7 @@ function f(r, e = []) {
85
86
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
86
87
  let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
87
88
  return new Proxy(c, { get(t, i) {
88
- let a = B2[i];
89
+ let a = B[i];
89
90
  if (Array.isArray(a)) {
90
91
  let s = g.get(i);
91
92
  if (s === undefined)
@@ -108,13 +109,21 @@ function f(r, e = []) {
108
109
  function Fe(r = {}) {
109
110
  return f(r);
110
111
  }
111
- 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
+ });
112
122
 
113
- // ../kit/src/theme.ts
114
- import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
115
- import { homedir as homedir2 } from "os";
116
- import { join as join3, resolve as resolve2 } from "path";
117
- 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
+ });
118
127
 
119
128
  // ../kit/src/config.ts
120
129
  import { existsSync } from "fs";
@@ -130,6 +139,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
130
139
  return;
131
140
  }
132
141
  }
142
+ var init_config = __esm(() => {
143
+ init_args();
144
+ });
133
145
 
134
146
  // ../kit/src/user-config.ts
135
147
  import { existsSync as existsSync2, readFileSync } from "fs";
@@ -161,13 +173,17 @@ function readUserConfig(bin, where = {}, legacy = []) {
161
173
  return {};
162
174
  }
163
175
  }
176
+ var init_user_config = () => {};
164
177
 
165
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";
166
183
  function toLinear(channel) {
167
184
  const value = channel / 255;
168
185
  return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
169
186
  }
170
- 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)));
171
187
  function toOklab(hex) {
172
188
  const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
173
189
  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
@@ -182,7 +198,6 @@ function fromOklab([lightness, a, b]) {
182
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];
183
199
  return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
184
200
  }
185
- var ENDS = new Map;
186
201
  function gradientAt(theme, ratio) {
187
202
  if (theme.gradient === undefined)
188
203
  return;
@@ -196,33 +211,11 @@ function gradientAt(theme, ratio) {
196
211
  const [from, to] = ends;
197
212
  return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
198
213
  }
199
- var DEFAULT = {
200
- 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" },
201
- 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" },
202
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
203
- bins: {},
204
- gradient: ["#c084fc", "#67e8f9"]
205
- };
206
- 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" };
207
- 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" };
208
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
209
- var PRESETS = {
210
- default: {},
211
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
212
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
213
- ascii: { glyphs: ASCII }
214
- };
215
- 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"]);
216
- var HEX = /^#[0-9a-f]{6}$/i;
217
- var CONTROL = /\p{Cc}/u;
218
- var MAX_FILE_BYTES = 64 * 1024;
219
- var SPACES = /\s+/;
220
214
  function isColorSpec(spec) {
221
215
  if (typeof spec === "number")
222
216
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
223
217
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
224
218
  }
225
- var CUBE = [0, 95, 135, 175, 215, 255];
226
219
  function cubeLevel(channel) {
227
220
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
228
221
  }
@@ -330,7 +323,6 @@ function applyFile(theme, file, where, warn) {
330
323
  function endsWalk(home) {
331
324
  return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
332
325
  }
333
- var warned = new Set;
334
326
  function warnOnce(message) {
335
327
  if (warned.has(message))
336
328
  return;
@@ -367,8 +359,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
367
359
  }
368
360
  return { theme, sources, preset };
369
361
  }
370
- var current;
371
- var currentKey = "";
372
362
  function activeTheme() {
373
363
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
374
364
  if (current === undefined || key !== currentKey) {
@@ -377,9 +367,38 @@ function activeTheme() {
377
367
  }
378
368
  return current;
379
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
+ });
380
399
 
381
400
  // ../kit/src/style.ts
382
- var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
401
+ import process6 from "process";
383
402
  function takesControlCodes(stream, env = process6.env) {
384
403
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
385
404
  }
@@ -399,17 +418,24 @@ function role(name, stream, env = process6.env) {
399
418
  const colors = paint(stream, env);
400
419
  return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
401
420
  }
402
- var STATUS_WORDS = {
403
- passed: ["passed", "success", "succeeded", "ok"],
404
- failed: ["failed", "failure", "error", "errored"],
405
- running: ["running", "in_progress", "started", "holding"],
406
- queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
407
- skipped: ["skipped", "cancelled", "canceled", "manual"]
408
- };
409
- 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
+ });
410
436
 
411
437
  // ../kit/src/format.ts
412
- var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
438
+ import process7 from "process";
413
439
  function formatSeconds(total) {
414
440
  let rest = Math.max(0, Math.round(total));
415
441
  const amounts = UNITS.map(([unit, size]) => {
@@ -441,10 +467,8 @@ function formatAge(date, now = Date.now()) {
441
467
  return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
442
468
  }
443
469
  function truncate(text, width) {
444
- return ko(text, width, { suffix: "\u2026", includeSuffix: true });
470
+ return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
445
471
  }
446
- var LINE_BREAKS = /\s*\n\s*/g;
447
- var ESCAPE = String.fromCharCode(27);
448
472
  function textWidth(text) {
449
473
  return Bun.stringWidth(text);
450
474
  }
@@ -493,14 +517,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
493
517
  function printJson(value) {
494
518
  console.log(jsonText(value));
495
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
+ });
496
529
 
497
530
  // ../kit/src/help.ts
498
531
  import process8 from "process";
499
- var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
500
- var USAGE_PREFIX = /^usage:\s*/i;
501
- var FULL_STOP = /\.$/;
502
532
  function usageLine(usage, colors = paint(process8.stdout)) {
503
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
533
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
534
+ `);
535
+ const blank = lines.indexOf("");
536
+ const synopses = blank === -1 ? lines : lines.slice(0, blank);
537
+ const details = blank === -1 ? [] : lines.slice(blank + 1);
538
+ const colon = synopses[0].indexOf(": ");
539
+ const inline = synopses[0].slice(colon + 2);
540
+ const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
541
+ if (colon !== -1)
542
+ synopses[0] = synopses[0].slice(0, colon);
543
+ const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
544
+ `)}`;
545
+ const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
546
+ const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
547
+ return [head, ...lead, ...rest].join(`
548
+ `);
549
+ }
550
+ function prose(line, colors) {
551
+ if (colors.cyan("x") === "x")
552
+ return line;
553
+ return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
504
554
  }
505
555
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
506
556
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -535,7 +585,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
535
585
  return [];
536
586
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
537
587
  }
538
- var MAX_INLINE_CHOICES = 24;
539
588
  function optionRows(options, colors = paint(process8.stdout)) {
540
589
  const rows = Object.entries(options).map(([name, option]) => {
541
590
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
@@ -550,9 +599,17 @@ function optionRows(options, colors = paint(process8.stdout)) {
550
599
  const width = Math.max(0, ...rows.map((row) => row.width));
551
600
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
552
601
  }
602
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
603
+ var init_help = __esm(() => {
604
+ init_mode();
605
+ init_style();
606
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
607
+ USAGE_PREFIX = /^usage:\s*/i;
608
+ FULL_STOP = /\.$/;
609
+ PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
610
+ });
553
611
 
554
612
  // ../kit/src/text.ts
555
- var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
556
613
  function distance(a, b) {
557
614
  const left = [...a];
558
615
  const right = [...b];
@@ -578,8 +635,12 @@ function closest(name, names) {
578
635
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
579
636
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
580
637
  }
638
+ var ANSI;
639
+ var init_text2 = __esm(() => {
640
+ ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
641
+ });
642
+
581
643
  // ../kit/src/input.ts
582
- var WHOLE = /^\d+$/;
583
644
  function wholeNumber(value, name, fallback, min = 1) {
584
645
  if (value === undefined)
585
646
  return fallback;
@@ -588,8 +649,6 @@ function wholeNumber(value, name, fallback, min = 1) {
588
649
  badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
589
650
  return number;
590
651
  }
591
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
592
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
593
652
  function duration(value, name, fallback, unit = "s") {
594
653
  if (value === undefined)
595
654
  return fallback;
@@ -599,40 +658,27 @@ function duration(value, name, fallback, unit = "s") {
599
658
  badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
600
659
  return ms;
601
660
  }
661
+ var WHOLE, DURATION, UNIT_MS;
662
+ var init_input = __esm(() => {
663
+ init_args();
664
+ WHOLE = /^\d+$/;
665
+ DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
666
+ UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
667
+ });
602
668
 
603
669
  // ../kit/src/args.ts
604
- var DASHES = /^-+/;
670
+ import process9 from "process";
671
+ import { parseArgs } from "util";
605
672
  function jsonOption(holds) {
606
673
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
607
674
  }
608
- class Exit extends Error {
609
- code;
610
- hint;
611
- constructor(message, code, hint) {
612
- super(message);
613
- this.code = code;
614
- this.hint = hint;
615
- }
616
- }
617
675
  function fail(message, code = 2, hint) {
618
676
  throw new Exit(message, code, hint);
619
677
  }
620
-
621
- class UsageError extends Exit {
622
- constructor(message, hint) {
623
- super(message, 2, hint);
624
- }
625
- }
626
678
  function badUsage(message) {
627
679
  throw new UsageError(message);
628
680
  }
629
681
 
630
- class HelpShown extends Exit {
631
- constructor() {
632
- super("help shown", 0);
633
- }
634
- }
635
-
636
682
  class Completing {
637
683
  options;
638
684
  positionals;
@@ -643,11 +689,6 @@ class Completing {
643
689
  this.candidates = candidates;
644
690
  }
645
691
  }
646
- var completion = { active: false };
647
- var OUTPUT_OPTIONS = {
648
- color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
649
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
650
- };
651
692
  function applyOutput(color, plain, env = process9.env) {
652
693
  const when = plain === true ? "never" : color ?? "auto";
653
694
  if (when === "auto")
@@ -801,7 +842,6 @@ function parseError(error) {
801
842
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
802
843
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
803
844
  }
804
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
805
845
  function nearestOption(message, options, allowNegative) {
806
846
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
807
847
  if (typed === undefined)
@@ -817,6 +857,695 @@ function nearestOption(message, options, allowNegative) {
817
857
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
818
858
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
819
859
  }
860
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
861
+ var init_args = __esm(() => {
862
+ init_format();
863
+ init_help();
864
+ init_text2();
865
+ init_help();
866
+ init_input();
867
+ DASHES = /^-+/;
868
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
869
+ Exit = class Exit extends Error {
870
+ code;
871
+ hint;
872
+ [EXIT] = true;
873
+ constructor(message, code, hint) {
874
+ super(message);
875
+ this.code = code;
876
+ this.hint = hint;
877
+ }
878
+ static [Symbol.hasInstance](value) {
879
+ if (this !== Exit)
880
+ return Function.prototype[Symbol.hasInstance].call(this, value);
881
+ return typeof value === "object" && value !== null && value[EXIT] === true;
882
+ }
883
+ };
884
+ UsageError = class UsageError extends Exit {
885
+ constructor(message, hint) {
886
+ super(message, 2, hint);
887
+ }
888
+ };
889
+ HelpShown = class HelpShown extends Exit {
890
+ constructor() {
891
+ super("help shown", 0);
892
+ }
893
+ };
894
+ completion = { active: false };
895
+ OUTPUT_OPTIONS = {
896
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
897
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
898
+ };
899
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
900
+ });
901
+
902
+ // ../kit/src/folders.ts
903
+ import { homedir as homedir3 } from "os";
904
+ import { join as join4 } from "path";
905
+ import process13 from "process";
906
+ function cacheFolder({ home = homedir3(), env = process13.env } = {}) {
907
+ return env.XDG_CACHE_HOME ?? join4(home, ".cache");
908
+ }
909
+ var SKIPPED_FOLDERS;
910
+ var init_folders = __esm(() => {
911
+ init_user_config();
912
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
913
+ });
914
+
915
+ // ../kit/src/answers.ts
916
+ import { mkdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
917
+ import { dirname as dirname2, join as join5 } from "path";
918
+ function answersFile() {
919
+ return join5(cacheFolder(), "kaynooo-cli", "answers.json");
920
+ }
921
+ function stored() {
922
+ try {
923
+ const parsed = JSON.parse(readFileSync4(answersFile(), "utf-8"));
924
+ if (typeof parsed !== "object" || parsed === null)
925
+ return {};
926
+ return Object.fromEntries(Object.entries(parsed).filter((entry) => Array.isArray(entry[1]) && entry[1].every((answer) => typeof answer === "string")));
927
+ } catch {
928
+ return {};
929
+ }
930
+ }
931
+ function earlierAnswers(key) {
932
+ return stored()[key] ?? [];
933
+ }
934
+ function rememberAnswer(key, answer) {
935
+ const all = stored();
936
+ const file = answersFile();
937
+ all[key] = [answer, ...(all[key] ?? []).filter((earlier) => earlier !== answer)].slice(0, KEPT);
938
+ try {
939
+ mkdirSync(dirname2(file), { recursive: true });
940
+ writeFileSync(file, JSON.stringify(all));
941
+ } catch {}
942
+ }
943
+ var KEPT = 50;
944
+ var init_answers = __esm(() => {
945
+ init_folders();
946
+ });
947
+
948
+ // ../kit/src/job.ts
949
+ import process14 from "process";
950
+ function stopJob() {
951
+ process14.kill(0, "SIGTSTP");
952
+ }
953
+ var init_job = () => {};
954
+
955
+ // ../kit/src/picker/line.ts
956
+ function isEditKey(key) {
957
+ return EDIT_KEYS.has(key);
958
+ }
959
+ function endsKills(key) {
960
+ return typeof key !== "object" && !isEditKey(key);
961
+ }
962
+ function isWord(char) {
963
+ return char !== undefined && WORD_CHARACTER.test(char);
964
+ }
965
+ function wordStart(chars, from) {
966
+ let at = from;
967
+ while (at > 0 && !isWord(chars[at - 1]))
968
+ at--;
969
+ while (at > 0 && isWord(chars[at - 1]))
970
+ at--;
971
+ return at;
972
+ }
973
+ function wordEnd(chars, from) {
974
+ let at = from;
975
+ while (at < chars.length && !isWord(chars[at]))
976
+ at++;
977
+ while (at < chars.length && isWord(chars[at]))
978
+ at++;
979
+ return at;
980
+ }
981
+ function spacedStart(chars, from) {
982
+ let at = from;
983
+ while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
984
+ at--;
985
+ while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
986
+ at--;
987
+ return at;
988
+ }
989
+ function cut(chars, from, to) {
990
+ return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
991
+ }
992
+ function insert(chars, at, text) {
993
+ const typed = [...text];
994
+ return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
995
+ }
996
+ function editLine(line, key) {
997
+ const { killed = "", chained = false } = line;
998
+ const chars = [...line.text];
999
+ const at = Math.min(Math.max(line.caret, 0), chars.length);
1000
+ const edited = edit(chars, at, key, killed);
1001
+ if (typeof key === "object" || !BACKWARD_KILLS.has(key) && !FORWARD_KILLS.has(key))
1002
+ return line.killed === undefined ? edited : { ...edited, killed };
1003
+ const taken = chars.slice(edited.caret, edited.caret + chars.length - [...edited.text].length).join("");
1004
+ if (taken === "")
1005
+ return { ...edited, killed, chained };
1006
+ if (!chained)
1007
+ return { ...edited, killed: taken, chained: true };
1008
+ return { ...edited, killed: BACKWARD_KILLS.has(key) ? taken + killed : killed + taken, chained: true };
1009
+ }
1010
+ function edit(chars, at, key, killed) {
1011
+ const text = chars.join("");
1012
+ if (typeof key === "object")
1013
+ return insert(chars, at, key.text);
1014
+ switch (key) {
1015
+ case "left":
1016
+ return { text, caret: Math.max(at - 1, 0) };
1017
+ case "right":
1018
+ return { text, caret: Math.min(at + 1, chars.length) };
1019
+ case "wordleft":
1020
+ return { text, caret: wordStart(chars, at) };
1021
+ case "wordright":
1022
+ return { text, caret: wordEnd(chars, at) };
1023
+ case "linestart":
1024
+ return { text, caret: 0 };
1025
+ case "lineend":
1026
+ return { text, caret: chars.length };
1027
+ case "erase":
1028
+ return cut(chars, Math.max(at - 1, 0), at);
1029
+ case "delete":
1030
+ return cut(chars, at, Math.min(at + 1, chars.length));
1031
+ case "word":
1032
+ return cut(chars, spacedStart(chars, at), at);
1033
+ case "killword":
1034
+ return cut(chars, wordStart(chars, at), at);
1035
+ case "killnext":
1036
+ return cut(chars, at, wordEnd(chars, at));
1037
+ case "clear":
1038
+ return cut(chars, 0, at);
1039
+ case "killend":
1040
+ return cut(chars, at, chars.length);
1041
+ case "yank":
1042
+ return insert(chars, at, killed);
1043
+ }
1044
+ }
1045
+ function visible({ text, caret }, room) {
1046
+ const chars = [...text];
1047
+ const at = Math.min(Math.max(caret, 0), chars.length);
1048
+ const cells = at === chars.length ? [...chars, " "] : chars;
1049
+ const widths = cells.map((char) => Bun.stringWidth(char));
1050
+ const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
1051
+ const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
1052
+ let start = at;
1053
+ let end = at + 1;
1054
+ while (start > 0 && fits(start - 1, end))
1055
+ start--;
1056
+ while (end < cells.length && fits(start, end + 1))
1057
+ end++;
1058
+ const left = start > 0 ? "\u2026" : "";
1059
+ const right = end < cells.length ? "\u2026" : "";
1060
+ 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) };
1061
+ }
1062
+ var EDIT_KEYS, BACKWARD_KILLS, FORWARD_KILLS, WORD_CHARACTER, SPACE;
1063
+ var init_line = __esm(() => {
1064
+ EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
1065
+ BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
1066
+ FORWARD_KILLS = new Set(["killnext", "killend"]);
1067
+ WORD_CHARACTER = /[\p{L}\p{N}_]/u;
1068
+ SPACE = /\s/;
1069
+ });
1070
+
1071
+ // ../kit/src/picker/score.ts
1072
+ function startsWord(text, index) {
1073
+ if (index === 0)
1074
+ return true;
1075
+ const before = text[index - 1];
1076
+ return BOUNDARY_AFTER.has(before) || LOWER.test(before) && UPPER.test(text[index]);
1077
+ }
1078
+ function fuzzy(query, text) {
1079
+ if (query === "")
1080
+ return { score: 0, positions: [] };
1081
+ const exact = query !== query.toLowerCase();
1082
+ const needle = exact ? query : query.toLowerCase();
1083
+ const haystack = exact ? text : text.toLowerCase();
1084
+ if (haystack.length !== text.length || needle.length > haystack.length)
1085
+ return;
1086
+ const width = haystack.length;
1087
+ const best = Array.from({ length: needle.length }, () => new Array(width).fill(NONE));
1088
+ const from = Array.from({ length: needle.length }, () => new Array(width).fill(-1));
1089
+ for (let j = 0;j < needle.length; j++) {
1090
+ let run = NONE;
1091
+ let runAt = -1;
1092
+ for (let i = j;i < width; i++) {
1093
+ if (j > 0 && i - 2 >= j - 1) {
1094
+ const candidate = best[j - 1][i - 2] + (i - 2) * GAP;
1095
+ if (candidate > run) {
1096
+ run = candidate;
1097
+ runAt = i - 2;
1098
+ }
1099
+ }
1100
+ if (haystack[i] !== needle[j])
1101
+ continue;
1102
+ const here = MATCH + (startsWord(text, i) ? BOUNDARY : 0) + (i === 0 ? PREFIX : 0);
1103
+ if (j === 0) {
1104
+ best[0][i] = here - i * GAP;
1105
+ continue;
1106
+ }
1107
+ const joined = best[j - 1][i - 1] + CONSECUTIVE;
1108
+ const skipped = run - (i - 1) * GAP;
1109
+ if (joined > NONE && joined >= skipped) {
1110
+ best[j][i] = joined + here;
1111
+ from[j][i] = i - 1;
1112
+ } else if (skipped > NONE) {
1113
+ best[j][i] = skipped + here;
1114
+ from[j][i] = runAt;
1115
+ }
1116
+ }
1117
+ }
1118
+ const last = best[needle.length - 1];
1119
+ let end = -1;
1120
+ for (let i = 0;i < width; i++) {
1121
+ if (last[i] > NONE && (end === -1 || last[i] > last[end]))
1122
+ end = i;
1123
+ }
1124
+ if (end === -1)
1125
+ return;
1126
+ const positions = [];
1127
+ for (let j = needle.length - 1, i = end;j >= 0; j--) {
1128
+ positions.unshift(i);
1129
+ i = from[j][i];
1130
+ }
1131
+ return { score: last[end], positions };
1132
+ }
1133
+ function rank(query, lines) {
1134
+ if (query === "")
1135
+ return lines.map((_, index) => ({ index, positions: [] }));
1136
+ const found = [];
1137
+ for (const [index, line] of lines.entries()) {
1138
+ const match = fuzzy(query, line);
1139
+ if (match !== undefined)
1140
+ found.push({ index, positions: match.positions, score: match.score });
1141
+ }
1142
+ return found.sort((a, b) => b.score - a.score || lines[a.index].length - lines[b.index].length || a.index - b.index);
1143
+ }
1144
+ var MATCH = 16, CONSECUTIVE = 12, BOUNDARY = 10, PREFIX = 8, GAP = 1, BOUNDARY_AFTER, UPPER, LOWER, NONE;
1145
+ var init_score = __esm(() => {
1146
+ BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
1147
+ UPPER = /\p{Lu}/u;
1148
+ LOWER = /\p{Ll}/u;
1149
+ NONE = Number.NEGATIVE_INFINITY;
1150
+ });
1151
+
1152
+ // ../kit/src/picker/state.ts
1153
+ function repeat(value, count) {
1154
+ return Array.from({ length: count }).fill(value);
1155
+ }
1156
+ function styled(line) {
1157
+ let text = "";
1158
+ const styles = [];
1159
+ let active = "";
1160
+ let colored = false;
1161
+ let last = 0;
1162
+ function add(chunk) {
1163
+ const flat = chunk.replace(CONTROL2, " ");
1164
+ text += flat;
1165
+ colored ||= active !== "" && flat !== "";
1166
+ styles.push(...repeat(active, flat.length));
1167
+ }
1168
+ for (const found of line.matchAll(ANSI)) {
1169
+ add(line.slice(last, found.index));
1170
+ last = found.index + found[0].length;
1171
+ if (SGR.test(found[0]))
1172
+ active = RESET.test(found[0]) ? "" : active + found[0];
1173
+ }
1174
+ add(line.slice(last));
1175
+ return { text, styles: colored ? styles : undefined };
1176
+ }
1177
+ function lay(rows, searched) {
1178
+ const parsed = rows.map((row) => row.cells.map(styled));
1179
+ const widths = (parsed[0] ?? []).map((_, column) => Math.max(...parsed.map((cells) => Bun.stringWidth(cells[column]?.text ?? ""))));
1180
+ return parsed.map((cells, at) => {
1181
+ let text = "";
1182
+ const styles = [];
1183
+ let colored = false;
1184
+ let searchEnd = 0;
1185
+ for (const [column, cell] of cells.entries()) {
1186
+ const last = column === cells.length - 1;
1187
+ const shown = cells.length > 1 && last ? cell.text.trimEnd() : cell.text;
1188
+ text += shown;
1189
+ colored ||= cell.styles !== undefined;
1190
+ styles.push(...cell.styles?.slice(0, shown.length) ?? repeat("", shown.length));
1191
+ if (column < searched)
1192
+ searchEnd = cells.length > 1 ? text.trimEnd().length : text.length;
1193
+ if (!last) {
1194
+ const pad = widths[column] - Bun.stringWidth(cell.text) + COLUMN_GAP;
1195
+ text += " ".repeat(pad);
1196
+ styles.push(...repeat("", pad));
1197
+ }
1198
+ }
1199
+ return { text, styles: colored ? styles : undefined, searchable: rows[at].search ?? text.slice(0, searchEnd) };
1200
+ });
1201
+ }
1202
+ function parseKeys(input, paste = { active: false }, ctrls = []) {
1203
+ const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
1204
+ return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
1205
+ const wheel = MOUSE.exec(sequence)?.[1];
1206
+ if (wheel !== undefined)
1207
+ return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
1208
+ const named = codes.get(sequence);
1209
+ const key = named === undefined ? KEYS[sequence] : { ctrl: named };
1210
+ if (sequence === PASTE_START || sequence === PASTE_END) {
1211
+ paste.active = sequence === PASTE_START;
1212
+ return [];
1213
+ }
1214
+ if (paste.active && (sequence === "\r" || sequence === `
1215
+ `))
1216
+ return [];
1217
+ if (key !== undefined)
1218
+ return [key];
1219
+ return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
1220
+ });
1221
+ }
1222
+ function createState(rows, { multi = false, prompt = "> ", query = "", header = "", expect = [], searched = Number.POSITIVE_INFINITY } = {}) {
1223
+ 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 };
1224
+ return withRows(state, rows);
1225
+ }
1226
+ function withRows(state, rows, header = state.header) {
1227
+ const cells = rows.map((row) => typeof row === "string" ? { hidden: [], cells: [row] } : row);
1228
+ const laid = lay(cells, state.searched);
1229
+ const searchable = laid.map((row) => row.searchable);
1230
+ const matches = rank(state.query, searchable);
1231
+ 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 };
1232
+ }
1233
+ function withQuery(state, key) {
1234
+ const { text, caret, killed = "", chained = false } = editLine({ text: state.query, caret: state.caret, killed: state.killed, chained: state.chained }, key);
1235
+ return text === state.query ? { ...state, caret, killed, chained } : { ...state, query: text, caret, killed, chained, matches: rank(text, state.searchable), cursor: 0 };
1236
+ }
1237
+ function move(state, by) {
1238
+ return { ...state, cursor: Math.max(0, Math.min(state.matches.length - 1, state.cursor + by)) };
1239
+ }
1240
+ function highlighted(state) {
1241
+ return state.matches[state.cursor]?.index;
1242
+ }
1243
+ function press(state, key) {
1244
+ if (state.done !== undefined)
1245
+ return state;
1246
+ if (state.chained && endsKills(key))
1247
+ state = { ...state, chained: false };
1248
+ if (state.help)
1249
+ return { ...state, help: false };
1250
+ if (typeof key === "object") {
1251
+ if ("text" in key)
1252
+ return withQuery(state, key);
1253
+ return state.expect.includes(key.ctrl) ? { ...state, done: "accept", key: key.ctrl } : state;
1254
+ }
1255
+ if (isEditKey(key))
1256
+ return withQuery(state, key);
1257
+ switch (key) {
1258
+ case "up":
1259
+ return move(state, -1);
1260
+ case "down":
1261
+ return move(state, 1);
1262
+ case "pageup":
1263
+ return move(state, -state.page);
1264
+ case "pagedown":
1265
+ return move(state, state.page);
1266
+ case "home":
1267
+ return move(state, -state.matches.length);
1268
+ case "end":
1269
+ return move(state, state.matches.length);
1270
+ case "cancel":
1271
+ return { ...state, done: "cancel" };
1272
+ case "help":
1273
+ return { ...state, help: true };
1274
+ case "suspend":
1275
+ return state;
1276
+ case "enter":
1277
+ return state.matches.length === 0 && state.marked.size === 0 ? state : { ...state, done: "accept" };
1278
+ case "tab": {
1279
+ const at = highlighted(state);
1280
+ if (!state.multi || at === undefined)
1281
+ return state;
1282
+ const marked = new Set(state.marked);
1283
+ if (!marked.delete(at))
1284
+ marked.add(at);
1285
+ return move({ ...state, marked }, 1);
1286
+ }
1287
+ }
1288
+ }
1289
+ function chosen(state) {
1290
+ if (state.marked.size > 0)
1291
+ return state.rows.filter((_, index) => state.marked.has(index));
1292
+ const at = highlighted(state);
1293
+ return at === undefined ? [] : [state.rows[at]];
1294
+ }
1295
+ 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;
1296
+ var init_state = __esm(() => {
1297
+ init_text2();
1298
+ init_line();
1299
+ init_score();
1300
+ CONTROL2 = /[\x00-\x1F\x7F-\x9F]/g;
1301
+ IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
1302
+ SGR = /^\x1B\[[0-9;]*m$/;
1303
+ RESET = /^\x1B\[0?m$/;
1304
+ KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
1305
+ MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
1306
+ KEYS = {
1307
+ "\x1B[A": "up",
1308
+ "\x1BOA": "up",
1309
+ "\x10": "up",
1310
+ "\x1B[B": "down",
1311
+ "\x1BOB": "down",
1312
+ "\x0E": "down",
1313
+ "\x1B[5~": "pageup",
1314
+ "\x1B[6~": "pagedown",
1315
+ "\x1B[H": "home",
1316
+ "\x1B[1~": "home",
1317
+ "\x1BOH": "home",
1318
+ "\x1B[F": "end",
1319
+ "\x1B[4~": "end",
1320
+ "\x1BOF": "end",
1321
+ "\r": "enter",
1322
+ "\n": "enter",
1323
+ "\x03": "cancel",
1324
+ "\x1B": "cancel",
1325
+ "\x1B[D": "left",
1326
+ "\x1BOD": "left",
1327
+ "\x1B[C": "right",
1328
+ "\x1BOC": "right",
1329
+ "\x1B[1;5D": "wordleft",
1330
+ "\x1B[1;3D": "wordleft",
1331
+ "\x1Bb": "wordleft",
1332
+ "\x1B[1;5C": "wordright",
1333
+ "\x1B[1;3C": "wordright",
1334
+ "\x1Bf": "wordright",
1335
+ "\x01": "linestart",
1336
+ "\x05": "lineend",
1337
+ "\x7F": "erase",
1338
+ "\x1B[3~": "delete",
1339
+ "\b": "killword",
1340
+ "\x1B\x7F": "killword",
1341
+ "\x1B[3;5~": "killnext",
1342
+ "\x1Bd": "killnext",
1343
+ "\x15": "clear",
1344
+ "\v": "killend",
1345
+ "\x17": "word",
1346
+ "\x19": "yank",
1347
+ "\x1A": "suspend",
1348
+ "\t": "tab",
1349
+ "\x1F": "help",
1350
+ "\x1BOP": "help",
1351
+ "\x1B[11~": "help"
1352
+ };
1353
+ CTRL_KEY = /^ctrl-[abd-gkln-z]$/;
1354
+ });
1355
+
1356
+ // ../kit/src/redraw.ts
1357
+ function overwrite(lines, columns) {
1358
+ return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
1359
+ `);
1360
+ }
1361
+ function rowsTaken(lines, columns) {
1362
+ return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
1363
+ }
1364
+ var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
1365
+ var init_redraw = __esm(() => {
1366
+ init_format();
1367
+ });
1368
+
1369
+ // ../kit/src/prompt.ts
1370
+ import process15 from "process";
1371
+ function readKeys(input, paste = { active: false }) {
1372
+ return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
1373
+ }
1374
+ function roomAfter(question, columns) {
1375
+ return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
1376
+ }
1377
+ function withCaret(colors, line, room, dim = false) {
1378
+ const { before, at, after } = visible(line, room);
1379
+ const tone = dim ? colors.dim : (text) => text;
1380
+ return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
1381
+ }
1382
+ function sharedStart(texts) {
1383
+ const [first = [], ...rest] = texts.map((text) => [...text]);
1384
+ let length = first.length;
1385
+ for (const chars of rest) {
1386
+ const differs = chars.findIndex((char, index) => char !== first[index]);
1387
+ length = Math.min(length, differs === -1 ? chars.length : differs);
1388
+ }
1389
+ return first.slice(0, length).join("");
1390
+ }
1391
+ function listed2(colors, found, columns) {
1392
+ const shared = sharedStart(found);
1393
+ const cut = Math.max(shared.lastIndexOf("/"), shared.lastIndexOf(" ")) + 1;
1394
+ const names = found.slice(0, MAX_LISTED).map((each) => each.slice(cut));
1395
+ const more = found.length > MAX_LISTED ? ` \u2026 ${found.length - MAX_LISTED} more` : "";
1396
+ return ` ${colors.dim(truncate(names.join(" ") + more, Math.max(columns - 3, 1)))}`;
1397
+ }
1398
+ async function input2(question, { default: fallback, mask = false, validate, history, complete, ...settings } = {}) {
1399
+ let line = { text: "", caret: 0 };
1400
+ let invalid;
1401
+ let completions = [];
1402
+ const remembered = history === undefined || mask ? undefined : history;
1403
+ const earlier = remembered === undefined ? [] : earlierAnswers(remembered);
1404
+ let recalled = -1;
1405
+ let draft = line;
1406
+ const taken = () => line.text === "" ? fallback ?? "" : line.text;
1407
+ const shown = () => mask ? "*".repeat([...taken()].length) : taken();
1408
+ const accepted = await ask(question, settings, (colors, state, { columns }) => {
1409
+ if (state !== "asking")
1410
+ return [answer(colors, question, state, shown())];
1411
+ const typed = line.text === "" ? { text: shown(), caret: [...shown()].length } : { text: shown(), caret: line.caret };
1412
+ return [`${colors.cyan("?")} ${question} ${withCaret(colors, typed, roomAfter(question, columns), line.text === "")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`], ...completions.length > 1 ? [listed2(colors, completions, columns)] : []];
1413
+ }, (key) => {
1414
+ if (key === "cancel")
1415
+ return "cancel";
1416
+ invalid = undefined;
1417
+ completions = [];
1418
+ if (line.chained === true && endsKills(key))
1419
+ line = { ...line, chained: false };
1420
+ if (key === "tab") {
1421
+ const chars = [...line.text];
1422
+ const before = chars.slice(0, line.caret).join("");
1423
+ const found = complete?.(before) ?? [];
1424
+ const filled = sharedStart(found);
1425
+ if ([...filled].length > [...before].length)
1426
+ line = { ...line, text: filled + chars.slice(line.caret).join(""), caret: [...filled].length };
1427
+ else
1428
+ completions = found;
1429
+ return;
1430
+ }
1431
+ if (key === "enter") {
1432
+ invalid = validate?.(taken());
1433
+ return invalid === undefined ? "enter" : undefined;
1434
+ }
1435
+ if (key === "up" || key === "down") {
1436
+ const to = Math.min(Math.max(recalled + (key === "up" ? 1 : -1), -1), earlier.length - 1);
1437
+ if (recalled === -1)
1438
+ draft = line;
1439
+ recalled = to;
1440
+ const shown = to === -1 ? draft : { text: earlier[to], caret: [...earlier[to]].length };
1441
+ line = { ...shown, killed: line.killed ?? "" };
1442
+ return;
1443
+ }
1444
+ const edit = { home: "linestart", end: "lineend" }[key] ?? key;
1445
+ if (typeof edit === "object" || isEditKey(edit))
1446
+ line = editLine(line, edit);
1447
+ return;
1448
+ });
1449
+ if (!accepted)
1450
+ return;
1451
+ if (remembered !== undefined && taken() !== "")
1452
+ rememberAnswer(remembered, taken());
1453
+ return taken();
1454
+ }
1455
+ function answer(colors, question, state, picked) {
1456
+ return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1457
+ }
1458
+ async function ask(question, { hint, terminal = process15 }, render, press) {
1459
+ const { stdin, stderr } = terminal;
1460
+ if (!isInteractive(terminal))
1461
+ fail(`cannot ask "${question}" off a terminal`, 2, hint);
1462
+ const colors = paint(stderr);
1463
+ let current = "asking";
1464
+ let outcome;
1465
+ const columns = () => stderr.columns || 80;
1466
+ const draw = (state, last = false) => {
1467
+ const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
1468
+ const rows = rowsTaken(frame, columns());
1469
+ stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
1470
+ current = state;
1471
+ };
1472
+ const redraw = () => draw(current);
1473
+ const paste = { active: false };
1474
+ const stop = terminal.stop ?? (terminal === process15 ? stopJob : undefined);
1475
+ const suspend = () => {
1476
+ if (stop === undefined)
1477
+ return;
1478
+ stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
1479
+ stdin.setRawMode(false);
1480
+ stop();
1481
+ stdin.setRawMode(true);
1482
+ stderr.write("\x1B[?25l\x1B[?2004h");
1483
+ };
1484
+ try {
1485
+ stderr.on?.("resize", redraw);
1486
+ stdin.setRawMode(true);
1487
+ stdin.resume();
1488
+ stderr.write("\x1B[?25l\x1B[?2004h");
1489
+ draw("asking");
1490
+ return await new Promise((resolve) => {
1491
+ function onData(data) {
1492
+ for (const key of readKeys(data.toString(), paste)) {
1493
+ if (key === "suspend") {
1494
+ suspend();
1495
+ continue;
1496
+ }
1497
+ const pressed = press(key);
1498
+ if (pressed !== undefined) {
1499
+ settle(pressed);
1500
+ return;
1501
+ }
1502
+ }
1503
+ draw("asking");
1504
+ }
1505
+ function onEnd() {
1506
+ settle("cancel");
1507
+ }
1508
+ function settle(settled) {
1509
+ outcome = settled;
1510
+ stdin.off("data", onData);
1511
+ stdin.off("end", onEnd);
1512
+ resolve(settled === "enter");
1513
+ }
1514
+ stdin.on("data", onData);
1515
+ stdin.on("end", onEnd);
1516
+ });
1517
+ } finally {
1518
+ stderr.off?.("resize", redraw);
1519
+ draw(outcome ?? "cancel", true);
1520
+ stderr.write(`
1521
+ \x1B[?25h\x1B[?2004l`);
1522
+ stdin.setRawMode(false);
1523
+ stdin.pause();
1524
+ }
1525
+ }
1526
+ var PROMPT_KEYS, MAX_LISTED = 12;
1527
+ var init_prompt = __esm(() => {
1528
+ init_answers();
1529
+ init_args();
1530
+ init_format();
1531
+ init_job();
1532
+ init_mode();
1533
+ init_line();
1534
+ init_state();
1535
+ init_redraw();
1536
+ init_style();
1537
+ PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
1538
+ });
1539
+
1540
+ // src/gcl.ts
1541
+ import { existsSync as existsSync4, readdirSync, realpathSync as realpathSync3, statSync as statSync2 } from "fs";
1542
+ import { homedir as homedir6 } from "os";
1543
+ import { basename, join as join11, resolve as resolve6 } from "path";
1544
+ import process24 from "process";
1545
+
1546
+ // ../kit/src/index.ts
1547
+ init_args();
1548
+
820
1549
  // ../kit/src/argv.ts
821
1550
  import { readFileSync as readFileSync3, realpathSync } from "fs";
822
1551
  import { resolve as resolve3 } from "path";
@@ -841,7 +1570,17 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
841
1570
  const after = at === -1 ? [] : cmdline.slice(at + 1);
842
1571
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
843
1572
  }
1573
+ // ../kit/src/chart.ts
1574
+ init_format();
1575
+ init_mode();
1576
+ init_style();
1577
+ init_theme();
1578
+ // ../kit/src/ci.ts
1579
+ init_args();
1580
+ init_format();
1581
+
844
1582
  // ../kit/src/progress.ts
1583
+ init_format();
845
1584
  import process12 from "process";
846
1585
 
847
1586
  // ../kit/src/process.ts
@@ -887,10 +1626,10 @@ function holdSignals(cleanup) {
887
1626
  process11.on(signal, onSignal);
888
1627
  return held;
889
1628
  }
890
- async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
1629
+ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
891
1630
  const chunks = [];
892
1631
  const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
893
- const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
1632
+ const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
894
1633
  const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
895
1634
  const timers = [];
896
1635
  const killGroup = (killing) => {
@@ -967,6 +1706,8 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
967
1706
  }
968
1707
 
969
1708
  // ../kit/src/progress.ts
1709
+ init_style();
1710
+ init_theme();
970
1711
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
971
1712
  var FRAME_MS = 200;
972
1713
  var BAR_WIDTH = 20;
@@ -984,10 +1725,14 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
984
1725
  }, print: (text) => void stream.write(`${text}
985
1726
  `), stop: () => {
986
1727
  return;
1728
+ }, pause: () => () => {
1729
+ return;
987
1730
  } };
988
1731
  const write = stream.write.bind(stream);
989
1732
  let frame = 0;
990
1733
  let drawn = false;
1734
+ let paused = false;
1735
+ let stopped = false;
991
1736
  const columns = () => {
992
1737
  const now = stream.getWindowSize?.()[0] ?? stream.columns;
993
1738
  return now === undefined || now === 0 ? 80 : now;
@@ -998,6 +1743,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
998
1743
  drawn = false;
999
1744
  };
1000
1745
  const draw = () => {
1746
+ if (paused)
1747
+ return;
1001
1748
  const width = columns() - 1;
1002
1749
  const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
1003
1750
  const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
@@ -1009,16 +1756,17 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1009
1756
  `)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
1010
1757
  drawn = true;
1011
1758
  };
1012
- const timer = setInterval(draw, FRAME_MS);
1759
+ let timer = setInterval(draw, FRAME_MS);
1013
1760
  stream.on?.("resize", draw);
1014
- const restore = interceptOutput(clear);
1015
- const release = swallowInput();
1761
+ let restore = interceptOutput(clear);
1762
+ let release = swallowInput();
1016
1763
  const onExit = () => {
1017
1764
  clear();
1018
1765
  release();
1019
1766
  };
1020
1767
  const signals = holdSignals(stop);
1021
1768
  function stop() {
1769
+ stopped = true;
1022
1770
  clearInterval(timer);
1023
1771
  stream.off?.("resize", draw);
1024
1772
  clear();
@@ -1027,6 +1775,29 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1027
1775
  process12.off("exit", onExit);
1028
1776
  signals.release();
1029
1777
  }
1778
+ function pause() {
1779
+ if (paused || stopped)
1780
+ return () => {
1781
+ return;
1782
+ };
1783
+ paused = true;
1784
+ clearInterval(timer);
1785
+ stream.off?.("resize", draw);
1786
+ clear();
1787
+ restore();
1788
+ release();
1789
+ return () => {
1790
+ if (!paused || stopped)
1791
+ return;
1792
+ paused = false;
1793
+ timer = setInterval(draw, FRAME_MS);
1794
+ timer.unref();
1795
+ stream.on?.("resize", draw);
1796
+ restore = interceptOutput(clear);
1797
+ release = swallowInput();
1798
+ draw();
1799
+ };
1800
+ }
1030
1801
  timer.unref();
1031
1802
  process12.on("exit", onExit);
1032
1803
  return {
@@ -1037,7 +1808,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
1037
1808
  `);
1038
1809
  draw();
1039
1810
  },
1040
- stop
1811
+ stop,
1812
+ pause
1041
1813
  };
1042
1814
  }
1043
1815
  function progressLine(stream = process12.stderr, env = process12.env) {
@@ -1062,6 +1834,7 @@ function progressLine(stream = process12.stderr, env = process12.env) {
1062
1834
  }
1063
1835
  },
1064
1836
  stop: region.stop,
1837
+ pause: region.pause,
1065
1838
  done: (text) => end(marked("ok", text, stream, formatDuration(performance.now() - begun), env)),
1066
1839
  failed: (text) => end(marked("problem", text, stream, undefined, env))
1067
1840
  };
@@ -1150,10 +1923,127 @@ function interceptOutput(clear) {
1150
1923
  }
1151
1924
  };
1152
1925
  }
1926
+
1927
+ // ../kit/src/ci.ts
1928
+ init_style();
1929
+
1930
+ // ../kit/src/tool.ts
1931
+ init_format();
1153
1932
  // ../kit/src/cli.ts
1154
- import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1155
- import { dirname as dirname3, join as join5 } from "path";
1156
- import process15 from "process";
1933
+ init_args();
1934
+ import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
1935
+ import { dirname as dirname4, join as join8 } from "path";
1936
+ import process19 from "process";
1937
+
1938
+ // ../kit/src/askpass.ts
1939
+ import { chmodSync, mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
1940
+ import { tmpdir } from "os";
1941
+ import { join as join6 } from "path";
1942
+ import process16 from "process";
1943
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
1944
+ var ECHOED = /username|yes\/no/i;
1945
+ var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
1946
+ function askpass(pause = () => () => {
1947
+ return;
1948
+ }) {
1949
+ if (process16.stdin.isTTY !== true || process16.stderr.isTTY !== true || process16.argv[1] === undefined)
1950
+ return;
1951
+ const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
1952
+ const socketPath = join6(dir, "socket");
1953
+ const script = join6(dir, "askpass");
1954
+ let turn = Promise.resolve();
1955
+ const answer = async ({ prompt, notice }) => {
1956
+ const resume = pause();
1957
+ try {
1958
+ if (notice === true) {
1959
+ process16.stderr.write(`${prompt.trim()}
1960
+ `);
1961
+ return {};
1962
+ }
1963
+ await Promise.resolve().then(() => init_prompt());
1964
+ return { answer: await input2(prompt.trim(), { mask: !ECHOED.test(prompt) }) };
1965
+ } finally {
1966
+ resume();
1967
+ }
1968
+ };
1969
+ const respond = async (socket, request) => {
1970
+ const { promise, resolve } = Promise.withResolvers();
1971
+ const previous = turn;
1972
+ let reply = {};
1973
+ turn = promise;
1974
+ await previous;
1975
+ try {
1976
+ reply = await answer(request);
1977
+ } catch {} finally {
1978
+ socket.end(`${JSON.stringify(reply)}
1979
+ `);
1980
+ resolve();
1981
+ }
1982
+ };
1983
+ const server = Bun.listen({
1984
+ unix: socketPath,
1985
+ socket: {
1986
+ open: (socket) => {
1987
+ socket.data = { buffered: "" };
1988
+ },
1989
+ data: (socket, chunk) => {
1990
+ const before = socket.data.buffered;
1991
+ socket.data.buffered += chunk.toString();
1992
+ if (before.includes(`
1993
+ `) || !socket.data.buffered.includes(`
1994
+ `))
1995
+ return;
1996
+ respond(socket, JSON.parse(socket.data.buffered));
1997
+ }
1998
+ }
1999
+ });
2000
+ writeFileSync2(script, `#!/bin/sh
2001
+ ${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process16.execPath)} --no-env-file --config=/dev/null ${quoted(process16.argv[1])} "$@"
2002
+ `);
2003
+ chmodSync(script, 448);
2004
+ return {
2005
+ env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
2006
+ close: () => {
2007
+ server.stop(true);
2008
+ rmSync(dir, { recursive: true, force: true });
2009
+ }
2010
+ };
2011
+ }
2012
+ async function askpassClient(argv) {
2013
+ const socketPath = process16.env[SOCKET_VARIABLE];
2014
+ if (socketPath === undefined)
2015
+ return;
2016
+ const request = { prompt: argv[0] ?? "", ...process16.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
2017
+ const { promise, resolve } = Promise.withResolvers();
2018
+ let received = "";
2019
+ try {
2020
+ await Bun.connect({
2021
+ unix: socketPath,
2022
+ socket: {
2023
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
2024
+ `),
2025
+ data: (_, chunk) => {
2026
+ received += chunk.toString();
2027
+ },
2028
+ close: () => resolve(received),
2029
+ error: () => resolve("")
2030
+ }
2031
+ });
2032
+ } catch {
2033
+ return 1;
2034
+ }
2035
+ const reply = await promise;
2036
+ if (reply === "")
2037
+ return 1;
2038
+ const { answer } = JSON.parse(reply);
2039
+ if (request.notice === true)
2040
+ return 0;
2041
+ if (answer === undefined)
2042
+ return 1;
2043
+ process16.stdout.write(`${answer}
2044
+ `);
2045
+ return 0;
2046
+ }
1157
2047
 
1158
2048
  // ../kit/src/completions.ts
1159
2049
  var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
@@ -1216,28 +2106,34 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
1216
2106
  }
1217
2107
 
1218
2108
  // ../kit/src/notify.ts
1219
- import process13 from "process";
2109
+ init_format();
2110
+ init_mode();
2111
+ import process17 from "process";
1220
2112
  var NOTIFY_AFTER_MS = 1e4;
1221
2113
  var CANCELLED = 130;
1222
2114
  function base64(text) {
1223
2115
  return Buffer.from(text).toString("base64");
1224
2116
  }
1225
- function notification(title, body, env = process13.env) {
1226
- const id = `kit${process13.pid}`;
2117
+ function notification(title, body, env = process17.env) {
2118
+ const id = `kit${process17.pid}`;
1227
2119
  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\\`];
1228
2120
  return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1229
2121
  }
1230
- function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
2122
+ function notifyEnd(command, code, ms, { stream = process17.stderr, env = process17.env } = {}) {
1231
2123
  if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1232
2124
  return;
1233
2125
  stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1234
2126
  }
1235
2127
 
2128
+ // ../kit/src/cli.ts
2129
+ init_style();
2130
+ init_text2();
2131
+
1236
2132
  // ../kit/src/usage.ts
1237
- import { appendFileSync, mkdirSync } from "fs";
1238
- import { homedir as homedir3 } from "os";
1239
- import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1240
- import process14 from "process";
2133
+ import { appendFileSync, mkdirSync as mkdirSync2 } from "fs";
2134
+ import { homedir as homedir4 } from "os";
2135
+ import { dirname as dirname3, isAbsolute, join as join7 } from "path";
2136
+ import process18 from "process";
1241
2137
 
1242
2138
  // ../kit/src/logs.ts
1243
2139
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -1251,14 +2147,14 @@ var usageError;
1251
2147
  function noteUsageError(message) {
1252
2148
  usageError = message;
1253
2149
  }
1254
- function stateHome(env = process14.env) {
2150
+ function stateHome(env = process18.env) {
1255
2151
  const dir = env.XDG_STATE_HOME;
1256
- return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
2152
+ return dir !== undefined && isAbsolute(dir) ? dir : join7(homedir4(), ".local", "state");
1257
2153
  }
1258
- function usagePath(env = process14.env) {
1259
- return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
2154
+ function usagePath(env = process18.env) {
2155
+ return join7(stateHome(env), CLI_FOLDER, "usage.jsonl");
1260
2156
  }
1261
- function usageRecorded(env = process14.env) {
2157
+ function usageRecorded(env = process18.env) {
1262
2158
  const off = env.KAYNOOO_CLI_NO_USAGE;
1263
2159
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1264
2160
  }
@@ -1267,17 +2163,17 @@ function flagNames(argv) {
1267
2163
  const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
1268
2164
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1269
2165
  }
1270
- function usageEntry(bin, command, argv, code, now = new Date) {
2166
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
1271
2167
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1272
2168
  usageError = undefined;
1273
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
2169
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
1274
2170
  }
1275
- function recordUsage(entry, env = process14.env) {
2171
+ function recordUsage(entry, env = process18.env) {
1276
2172
  if (!usageRecorded(env))
1277
2173
  return;
1278
2174
  try {
1279
2175
  const path = usagePath(env);
1280
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
2176
+ mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
1281
2177
  appendFileSync(path, `${JSON.stringify(entry)}
1282
2178
  `, { mode: 384 });
1283
2179
  } catch {}
@@ -1294,8 +2190,8 @@ var TOP_OPTIONS = {
1294
2190
  completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1295
2191
  };
1296
2192
  function printError(prefix, message, hint, cause) {
1297
- const colors = paint(process15.stderr);
1298
- const styled = takesControlCodes(process15.stderr);
2193
+ const colors = paint(process19.stderr);
2194
+ const styled = takesControlCodes(process19.stderr);
1299
2195
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1300
2196
  const under = (label, text, tint) => text === undefined ? "" : `
1301
2197
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1398,17 +2294,20 @@ function packageVersion(entry = Bun.main) {
1398
2294
  try {
1399
2295
  resolved = realpathSync2(entry);
1400
2296
  } catch {}
1401
- for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
2297
+ for (let dir = dirname4(resolved);; dir = dirname4(dir)) {
1402
2298
  try {
1403
- const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
2299
+ const { version } = JSON.parse(readFileSync5(join8(dir, "package.json"), "utf8"));
1404
2300
  if (typeof version === "string")
1405
2301
  return version;
1406
2302
  } catch {}
1407
- if (dirname3(dir) === dir)
2303
+ if (dirname4(dir) === dir)
1408
2304
  return "0.0.0";
1409
2305
  }
1410
2306
  }
1411
2307
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
2308
+ const answered = await askpassClient(argv);
2309
+ if (answered !== undefined)
2310
+ return answered;
1412
2311
  if (argv[0] === COMPLETE)
1413
2312
  return printCandidates(leafCandidates(run, argv.slice(1)));
1414
2313
  if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
@@ -1427,21 +2326,51 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1427
2326
  notifyEnd(name, code, performance.now() - started);
1428
2327
  if (usage !== false) {
1429
2328
  try {
1430
- recordUsage(usageEntry(name, undefined, argv, code));
2329
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
1431
2330
  } catch {}
1432
2331
  }
1433
2332
  return code;
1434
2333
  }
1435
- // ../kit/src/folders.ts
1436
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
2334
+
2335
+ // ../kit/src/index.ts
2336
+ init_config();
2337
+
2338
+ // ../kit/src/excerpt.ts
2339
+ init_text2();
2340
+
2341
+ // ../kit/src/index.ts
2342
+ init_folders();
2343
+ init_format();
2344
+
2345
+ // ../kit/src/git.ts
2346
+ init_args();
2347
+ // ../kit/src/limit.ts
2348
+ init_args();
2349
+
2350
+ // ../kit/src/index.ts
2351
+ init_mode();
2352
+
2353
+ // ../kit/src/report.ts
2354
+ init_style();
2355
+ init_text2();
1437
2356
  // ../kit/src/secrets.ts
1438
2357
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1439
2358
  // ../kit/src/sessions.ts
1440
2359
  var {Glob } = globalThis.Bun;
1441
2360
  var SESSION_FILES = new Glob("*.json");
1442
2361
  var ACCOUNT_DIRS = new Glob("*/sessions");
2362
+
2363
+ // ../kit/src/index.ts
2364
+ init_style();
2365
+ init_text2();
2366
+ init_theme();
2367
+ init_user_config();
2368
+
1443
2369
  // ../kit/src/watch.ts
1444
- import process16 from "process";
2370
+ init_args();
2371
+ init_input();
2372
+ init_style();
2373
+ import process20 from "process";
1445
2374
  import { format } from "util";
1446
2375
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1447
2376
  var DEFAULT_SECONDS = 2;
@@ -1463,7 +2392,7 @@ function withoutWatch(args) {
1463
2392
  }
1464
2393
  return rest;
1465
2394
  }
1466
- async function watching(value, step, stream = process16.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
2395
+ async function watching(value, step, stream = process20.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1467
2396
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1468
2397
  if (!takesControlCodes(stream))
1469
2398
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1471,12 +2400,12 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1471
2400
  for (let round = 0;round < rounds; round++) {
1472
2401
  const held = [];
1473
2402
  const { log, info } = console;
1474
- const write = process16.stdout.write.bind(process16.stdout);
2403
+ const write = process20.stdout.write.bind(process20.stdout);
1475
2404
  const hold = (...parts) => void held.push(`${format(...parts)}
1476
2405
  `);
1477
2406
  console.log = hold;
1478
2407
  console.info = hold;
1479
- process16.stdout.write = (text) => {
2408
+ process20.stdout.write = (text) => {
1480
2409
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1481
2410
  return true;
1482
2411
  };
@@ -1485,7 +2414,7 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1485
2414
  } finally {
1486
2415
  console.log = log;
1487
2416
  console.info = info;
1488
- process16.stdout.write = write;
2417
+ process20.stdout.write = write;
1489
2418
  }
1490
2419
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1491
2420
  await sleep(interval);
@@ -1493,21 +2422,22 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
1493
2422
  return code;
1494
2423
  }
1495
2424
  // ../kit/src/workspace-root.ts
1496
- import { homedir as homedir4 } from "os";
1497
- import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
1498
- import process17 from "process";
2425
+ init_user_config();
2426
+ import { homedir as homedir5 } from "os";
2427
+ import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
2428
+ import process21 from "process";
1499
2429
  function expandHome(path, home) {
1500
2430
  if (path === "~")
1501
2431
  return home;
1502
- return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
2432
+ return path.startsWith("~/") ? join9(home, path.slice(2)) : path;
1503
2433
  }
1504
2434
  function configured(env, home) {
1505
2435
  const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
1506
2436
  return typeof folder === "string" && folder !== "" ? folder : undefined;
1507
2437
  }
1508
- function workspaceRoot({ given, env = process17.env, home = homedir4() } = {}) {
2438
+ function workspaceRoot({ given, env = process21.env, home = homedir5() } = {}) {
1509
2439
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1510
- return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
2440
+ return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join9(home, "Workspace"), home));
1511
2441
  }
1512
2442
  // src/git.ts
1513
2443
  async function git2(args, env) {
@@ -1518,8 +2448,8 @@ async function git2(args, env) {
1518
2448
 
1519
2449
  // src/repos.ts
1520
2450
  import { readdir } from "fs/promises";
1521
- import { join as join7, relative, resolve as resolve5 } from "path";
1522
- import process19 from "process";
2451
+ import { join as join10, relative, resolve as resolve5 } from "path";
2452
+ import process23 from "process";
1523
2453
 
1524
2454
  // src/status.ts
1525
2455
  var AHEAD_BEHIND = /\+(\d+) -(\d+)/;
@@ -1615,7 +2545,7 @@ async function reposUnder(root, depth = DEPTH) {
1615
2545
  found.push(dir);
1616
2546
  if (left === 0)
1617
2547
  return;
1618
- await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(join7(dir, entry.name), left - 1)));
2548
+ await Promise.all(entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !SKIPPED.has(entry.name)).map(async (entry) => walk(join10(dir, entry.name), left - 1)));
1619
2549
  }
1620
2550
  await walk(resolve5(root), depth);
1621
2551
  return found.sort();
@@ -1625,14 +2555,14 @@ async function toplevelOf(dir) {
1625
2555
  return read.code === 0 ? read.stdout.trim() : undefined;
1626
2556
  }
1627
2557
  async function reposOf(roots) {
1628
- const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process19.cwd()];
2558
+ const starts = roots.length > 0 ? roots : [await toplevelOf(".") ?? process23.cwd()];
1629
2559
  const found = await Promise.all(starts.map(async (root) => reposUnder(root)));
1630
2560
  return [...new Set(found.flat())].sort();
1631
2561
  }
1632
2562
  async function repoState(dir) {
1633
2563
  const [read, log] = await Promise.all([git2(["-C", dir, "status", "--porcelain=v2", "--branch"]), git2(["-C", dir, "log", "-1", "--format=%h%x00%s"])]);
1634
2564
  const [sha, title = ""] = log.code === 0 && log.stdout.trim() !== "" ? log.stdout.trim().split("\x00") : [];
1635
- return { path: relative(process19.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
2565
+ return { path: relative(process23.cwd(), dir) || ".", dir, status: read.code === 0 ? parseStatus(read.stdout) : null, head: sha === undefined ? null : { sha, title } };
1636
2566
  }
1637
2567
  function trackingOf(status) {
1638
2568
  if (status.upstream === null)
@@ -1669,15 +2599,35 @@ async function dirsOf(positionals, all) {
1669
2599
 
1670
2600
  // src/sync.ts
1671
2601
  var GIT_FAILURE = /^(?:error: |fatal: )/;
2602
+ var LISTED = /^\s/;
2603
+ var LOCAL_CHANGES = /local changes .* would be overwritten/;
2604
+ var UNTRACKED = /untracked working tree files would be overwritten/;
1672
2605
  function whyFailed(stderr, fallback) {
1673
2606
  const lines = stderr.split(`
1674
2607
  `).map((line) => line.trimEnd()).filter(Boolean);
1675
- return (lines.find((line) => GIT_FAILURE.test(line)) ?? lines.at(-1) ?? fallback).trim();
1676
- }
1677
- async function sync(repo, { pull }) {
2608
+ const at = lines.findIndex((line) => GIT_FAILURE.test(line));
2609
+ if (at === -1)
2610
+ return (lines.at(-1) ?? fallback).trim();
2611
+ const line = lines[at].trim();
2612
+ const listed = [];
2613
+ for (const next of lines.slice(at + 1)) {
2614
+ if (!LISTED.test(next))
2615
+ break;
2616
+ listed.push(next.trim());
2617
+ }
2618
+ if (listed.length === 0)
2619
+ return line;
2620
+ const paths = listed.join(", ");
2621
+ if (LOCAL_CHANGES.test(line))
2622
+ return `uncommitted changes in files the fast-forward changes (${paths}): commit them first (gc), or set them aside as a patch (gu)`;
2623
+ if (UNTRACKED.test(line))
2624
+ return `untracked files the fast-forward would overwrite (${paths}): move them aside first`;
2625
+ return `${line} ${paths}`;
2626
+ }
2627
+ async function sync(repo, { pull, env }) {
1678
2628
  const { path, dir } = repo;
1679
2629
  const refused = (reason, branch = null, upstream = null) => ({ path, branch, upstream, commits: null, outcome: "refused", reason });
1680
- const fetched = await git2(["-C", dir, "fetch", "--prune"]);
2630
+ const fetched = await git2(["-C", dir, "fetch", "--prune"], env);
1681
2631
  if (fetched.code !== 0)
1682
2632
  return refused(whyFailed(fetched.stderr, "git fetch failed"), repo.status?.branch ?? null);
1683
2633
  const { status } = await repoState(dir);
@@ -1706,8 +2656,8 @@ async function sync(repo, { pull }) {
1706
2656
  var DEFAULT_FORGE = "git.kaynooo.fr";
1707
2657
  var USAGE = `gcl <repo> [dir]: clones a repository into the workspace folder and prints where it landed
1708
2658
 
1709
- <repo> is a URL, an scp-style address (git@host:owner/name.git), a local path or owner/name, which is read as https://${DEFAULT_FORGE}/owner/name.git (the \`forge\` key of ~/.config/kaynooo-cli/config.json names another host). Without <dir> the clone goes to <workspace>/<name>, the workspace being the one \`cli config\` reports.
1710
- When that folder already holds the repository, nothing is cloned: it is fetched and fast-forwarded as gf does. A folder holding anything else is refused.`;
2659
+ <repo> is a URL, an scp-style address, a local path or \`owner/name\`, read as \`https://${DEFAULT_FORGE}/owner/name.git\` (the \`forge\` config key names another host). Without <dir> the clone goes to <workspace>/<name>, the workspace \`cli config\` reports.
2660
+ A folder that already holds the repository is fetched and fast-forwarded as gf does, not cloned again; one holding anything else is refused.`;
1711
2661
  var EXITS = [[0, "it cloned the repository, or found it and brought it up to date"], [1, "git could not clone it, or the folder is taken"], [2, "a usage error"]];
1712
2662
  var OPTIONS = {
1713
2663
  json: jsonOption("{url, path, branch, head, outcome}, outcome being cloned or existing")
@@ -1720,7 +2670,7 @@ var TRAILING_SLASH = /\/+$/;
1720
2670
  var LAST_SEGMENT = /[/:]/;
1721
2671
  function urlOf(repo, forge) {
1722
2672
  if (repo.startsWith("~/"))
1723
- return join8(homedir5(), repo.slice(2));
2673
+ return join11(homedir6(), repo.slice(2));
1724
2674
  if (SCHEME.test(repo) || SCP.test(repo) || repo.startsWith("/") || repo.startsWith("."))
1725
2675
  return repo;
1726
2676
  if (OWNER_NAME.test(repo))
@@ -1743,7 +2693,7 @@ async function main(argv) {
1743
2693
  const name = nameOf(url);
1744
2694
  if (name === "")
1745
2695
  fail(`no folder name can be taken from ${url}, give one: gcl ${repo} <dir>`, 2);
1746
- const path = given === undefined ? join8(workspaceRoot(), name) : resolve6(given);
2696
+ const path = given === undefined ? join11(workspaceRoot(), name) : resolve6(given);
1747
2697
  let outcome = "cloned";
1748
2698
  if (existsSync4(path) && (!statSync2(path).isDirectory() || readdirSync(path).length > 0)) {
1749
2699
  if (!statSync2(path).isDirectory() || await toplevelOf(path) !== realpathSync3(path))
@@ -1772,7 +2722,7 @@ ${cloned.stderr.trim()}`, 1);
1772
2722
  return 0;
1773
2723
  }
1774
2724
  if (import.meta.main)
1775
- process20.exitCode = await runMain({ name: "gcl", run: main });
2725
+ process24.exitCode = await runMain({ name: "gcl", run: main });
1776
2726
  export {
1777
2727
  nameOf,
1778
2728
  urlOf