@kaynooo/cli-gloss 0.0.2 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/gloss.js +445 -126
  2. package/package.json +5 -5
package/dist/gloss.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env -S bun --no-env-file --config=/dev/null
2
2
  // @bun
3
-
4
- // src/gloss.ts
5
- import process16 from "process";
6
- // ../kit/src/args.ts
7
- import process9 from "process";
8
- import { parseArgs } from "util";
9
-
10
- // ../kit/src/format.ts
11
- import process7 from "process";
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
+ };
12
14
 
13
15
  // ../kit/src/mode.ts
14
16
  import process2 from "process";
15
- var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
- var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
17
  function isSet(value) {
18
18
  return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
19
  }
@@ -27,12 +27,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
27
27
  return "terminal";
28
28
  return isSet(env.CI) ? "ci" : "pipe";
29
29
  }
30
+ var MODES, AGENT_VARIABLES;
31
+ var init_mode = __esm(() => {
32
+ MODES = new Set(["terminal", "ci", "agent", "pipe"]);
33
+ AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
34
+ });
30
35
 
31
- // ../kit/src/style.ts
32
- import process6 from "process";
33
-
34
- // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
35
- var G = /^[a-f0-9]+$/i;
36
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
36
37
  function b(r) {
37
38
  let e = r.startsWith("#") ? r.slice(1) : r;
38
39
  if (!G.test(e))
@@ -43,11 +44,6 @@ function b(r) {
43
44
  throw Error(`Invalid hex color length: ${e.length}`);
44
45
  return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
45
46
  }
46
- var B = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
47
- let [l, n, c] = b(r);
48
- return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
49
- }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
50
- var h = new Set(["", "1", "2", "3", "true"]);
51
47
  function C(r, e = globalThis.process?.env ?? {}) {
52
48
  if (e.FORCE_COLOR !== undefined)
53
49
  return h.has(e.FORCE_COLOR);
@@ -84,13 +80,21 @@ function f(r, e = []) {
84
80
  function Fe(r = {}) {
85
81
  return f(r);
86
82
  }
87
- var o = Fe();
83
+ var G, B, h, o;
84
+ var init_chunk_x450vn3m = __esm(() => {
85
+ G = /^[a-f0-9]+$/i;
86
+ 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") => {
87
+ let [l, n, c] = b(r);
88
+ return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
89
+ }, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
90
+ h = new Set(["", "1", "2", "3", "true"]);
91
+ o = Fe();
92
+ });
88
93
 
89
- // ../kit/src/theme.ts
90
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
91
- import { homedir as homedir2 } from "os";
92
- import { join as join3, resolve as resolve2 } from "path";
93
- import process5 from "process";
94
+ // ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
95
+ var init_colors = __esm(() => {
96
+ init_chunk_x450vn3m();
97
+ });
94
98
 
95
99
  // ../kit/src/config.ts
96
100
  import { existsSync } from "fs";
@@ -106,6 +110,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
106
110
  return;
107
111
  }
108
112
  }
113
+ var init_config = __esm(() => {
114
+ init_args();
115
+ });
109
116
 
110
117
  // ../kit/src/user-config.ts
111
118
  import { homedir } from "os";
@@ -118,36 +125,18 @@ function configBase(where = {}) {
118
125
  function userConfigPath(bin, where = {}) {
119
126
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
120
127
  }
128
+ var init_user_config = () => {};
121
129
 
122
130
  // ../kit/src/theme.ts
123
- var ENDS = new Map;
124
- var DEFAULT = {
125
- 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" },
126
- 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" },
127
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
128
- bins: {},
129
- gradient: ["#c084fc", "#67e8f9"]
130
- };
131
- 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" };
132
- 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" };
133
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
134
- var PRESETS = {
135
- default: {},
136
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
137
- mono: { colors: MONO, accents: ["bold"], gradient: undefined },
138
- ascii: { glyphs: ASCII }
139
- };
140
- 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"]);
141
- var HEX = /^#[0-9a-f]{6}$/i;
142
- var CONTROL = /\p{Cc}/u;
143
- var MAX_FILE_BYTES = 64 * 1024;
144
- var SPACES = /\s+/;
131
+ import { existsSync as existsSync2, readFileSync, statSync } from "fs";
132
+ import { homedir as homedir2 } from "os";
133
+ import { join as join3, resolve as resolve2 } from "path";
134
+ import process5 from "process";
145
135
  function isColorSpec(spec) {
146
136
  if (typeof spec === "number")
147
137
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
148
138
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
149
139
  }
150
- var CUBE = [0, 95, 135, 175, 215, 255];
151
140
  function cubeLevel(channel) {
152
141
  return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
153
142
  }
@@ -252,7 +241,6 @@ function applyFile(theme, file, where, warn) {
252
241
  function endsWalk(home) {
253
242
  return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
254
243
  }
255
- var warned = new Set;
256
244
  function warnOnce(message) {
257
245
  if (warned.has(message))
258
246
  return;
@@ -289,8 +277,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
289
277
  }
290
278
  return { theme, sources, preset };
291
279
  }
292
- var current;
293
- var currentKey = "";
294
280
  function activeTheme() {
295
281
  const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
296
282
  if (current === undefined || key !== currentKey) {
@@ -299,8 +285,38 @@ function activeTheme() {
299
285
  }
300
286
  return current;
301
287
  }
288
+ var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
289
+ var init_theme = __esm(() => {
290
+ init_config();
291
+ init_user_config();
292
+ ENDS = new Map;
293
+ DEFAULT = {
294
+ 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" },
295
+ 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" },
296
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
297
+ bins: {},
298
+ gradient: ["#c084fc", "#67e8f9"]
299
+ };
300
+ 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" };
301
+ 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" };
302
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
303
+ PRESETS = {
304
+ default: {},
305
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
306
+ mono: { colors: MONO, accents: ["bold"], gradient: undefined },
307
+ ascii: { glyphs: ASCII }
308
+ };
309
+ 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"]);
310
+ HEX = /^#[0-9a-f]{6}$/i;
311
+ CONTROL = /\p{Cc}/u;
312
+ MAX_FILE_BYTES = 64 * 1024;
313
+ SPACES = /\s+/;
314
+ CUBE = [0, 95, 135, 175, 215, 255];
315
+ warned = new Set;
316
+ });
302
317
 
303
318
  // ../kit/src/style.ts
319
+ import process6 from "process";
304
320
  function takesControlCodes(stream, env = process6.env) {
305
321
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
306
322
  }
@@ -311,35 +327,81 @@ function role(name, stream, env = process6.env) {
311
327
  const colors = paint(stream, env);
312
328
  return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
313
329
  }
314
- var STATUS_WORDS = {
315
- passed: ["passed", "success", "succeeded", "ok"],
316
- failed: ["failed", "failure", "error", "errored"],
317
- running: ["running", "in_progress", "started", "holding"],
318
- queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
319
- skipped: ["skipped", "cancelled", "canceled", "manual"]
320
- };
321
- var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
330
+ var STATUS_WORDS, STATUS_OF;
331
+ var init_style = __esm(() => {
332
+ init_colors();
333
+ init_mode();
334
+ init_theme();
335
+ STATUS_WORDS = {
336
+ passed: ["passed", "success", "succeeded", "ok"],
337
+ failed: ["failed", "failure", "error", "errored"],
338
+ running: ["running", "in_progress", "started", "holding"],
339
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
340
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
341
+ };
342
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
343
+ });
322
344
 
323
345
  // ../kit/src/format.ts
346
+ import process7 from "process";
347
+ function formatSeconds(total) {
348
+ let rest = Math.max(0, Math.round(total));
349
+ const amounts = UNITS.map(([unit, size]) => {
350
+ const amount = Math.floor(rest / size);
351
+ rest -= amount * size;
352
+ return `${amount}${unit}`;
353
+ });
354
+ const first = amounts.findIndex((amount) => !amount.startsWith("0"));
355
+ if (first === -1)
356
+ return "0s";
357
+ const next = amounts[first + 1];
358
+ return next === undefined || next.startsWith("0") ? amounts[first] ?? "0s" : `${amounts[first]} ${next}`;
359
+ }
360
+ function formatDuration(ms) {
361
+ return ms < 60000 ? `${(Math.max(0, ms) / 1000).toFixed(1)}s` : formatSeconds(ms / 1000);
362
+ }
324
363
  function upTo(text, separator) {
325
364
  const end = text.indexOf(separator);
326
365
  return end === -1 ? text : text.slice(0, end);
327
366
  }
328
- var ESCAPE = String.fromCharCode(27);
329
367
  function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
330
368
  return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
331
369
  }
332
370
  function printJson(value) {
333
371
  console.log(jsonText(value));
334
372
  }
373
+ var UNITS, ESCAPE;
374
+ var init_format = __esm(() => {
375
+ init_mode();
376
+ init_style();
377
+ UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
378
+ ESCAPE = String.fromCharCode(27);
379
+ });
335
380
 
336
381
  // ../kit/src/help.ts
337
382
  import process8 from "process";
338
- var OPTIONAL = /\[[^\]]+\]/g;
339
- var USAGE_PREFIX = /^usage:\s*/i;
340
- var FULL_STOP = /\.$/;
341
383
  function usageLine(usage, colors = paint(process8.stdout)) {
342
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
384
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
385
+ `);
386
+ const blank = lines.indexOf("");
387
+ const synopses = blank === -1 ? lines : lines.slice(0, blank);
388
+ const details = blank === -1 ? [] : lines.slice(blank + 1);
389
+ const colon = synopses[0].indexOf(": ");
390
+ const inline = synopses[0].slice(colon + 2);
391
+ const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
392
+ if (colon !== -1)
393
+ synopses[0] = synopses[0].slice(0, colon);
394
+ const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
395
+ `)}`;
396
+ const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
397
+ const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
398
+ return [head, ...lead, ...rest].join(`
399
+ `);
400
+ }
401
+ function prose(line, colors) {
402
+ if (colors.cyan("x") === "x")
403
+ return line;
404
+ return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
343
405
  }
344
406
  function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
345
407
  return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
@@ -377,29 +439,48 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
377
439
  function optionRows(options, colors = paint(process8.stdout)) {
378
440
  const rows = Object.entries(options).map(([name, option]) => {
379
441
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
380
- const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
442
+ const choices = option.choices?.join("|");
443
+ const inline = choices !== undefined && choices.length <= MAX_INLINE_CHOICES;
444
+ const named = inline ? `<${choices}>` : "<value>";
381
445
  const placeholder = option.optional === undefined ? named : `[${named}]`;
382
446
  const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
383
- return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
447
+ const described = choices === undefined || inline ? option.description ?? "" : [option.description, `one of ${option.choices.join(", ")}`].filter(Boolean).join("; ");
448
+ return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: described };
384
449
  });
385
450
  const width = Math.max(0, ...rows.map((row) => row.width));
386
451
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
387
452
  }
453
+ var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
454
+ var init_help = __esm(() => {
455
+ init_mode();
456
+ init_style();
457
+ OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
458
+ USAGE_PREFIX = /^usage:\s*/i;
459
+ FULL_STOP = /\.$/;
460
+ PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
461
+ });
388
462
 
389
463
  // ../kit/src/text.ts
390
- var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
391
464
  function stripAnsi(text) {
392
465
  return text.replace(ANSI, "");
393
466
  }
394
467
  function distance(a, b) {
395
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
396
- for (const [i, left] of [...a].entries()) {
468
+ const left = [...a];
469
+ const right = [...b];
470
+ let before = [];
471
+ let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
472
+ for (const [i, x] of left.entries()) {
397
473
  const current = [i + 1];
398
- for (const [j, right] of [...b].entries())
399
- current.push(Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (left === right ? 0 : 1)));
474
+ for (const [j, y] of right.entries()) {
475
+ let cost = Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (x === y ? 0 : 1));
476
+ if (i > 0 && j > 0 && x === right[j - 1] && left[i - 1] === y)
477
+ cost = Math.min(cost, (before[j - 1] ?? 0) + 1);
478
+ current.push(cost);
479
+ }
480
+ before = previous;
400
481
  previous = current;
401
482
  }
402
- return previous[b.length] ?? 0;
483
+ return previous[right.length] ?? 0;
403
484
  }
404
485
  function closest(name, names) {
405
486
  const started = names.find((known) => known.startsWith(name));
@@ -408,36 +489,26 @@ function closest(name, names) {
408
489
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
409
490
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
410
491
  }
492
+ var ANSI;
493
+ var init_text = __esm(() => {
494
+ ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
495
+ });
496
+
497
+ // ../kit/src/input.ts
498
+ var init_input = __esm(() => {
499
+ init_args();
500
+ });
411
501
 
412
502
  // ../kit/src/args.ts
413
- var DASHES = /^-+/;
503
+ import process9 from "process";
504
+ import { parseArgs } from "util";
414
505
  function jsonOption(holds) {
415
506
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
416
507
  }
417
- class Exit extends Error {
418
- code;
419
- hint;
420
- constructor(message, code, hint) {
421
- super(message);
422
- this.code = code;
423
- this.hint = hint;
424
- }
425
- }
426
- class UsageError extends Exit {
427
- constructor(message, hint) {
428
- super(message, 2, hint);
429
- }
430
- }
431
508
  function badUsage(message) {
432
509
  throw new UsageError(message);
433
510
  }
434
511
 
435
- class HelpShown extends Exit {
436
- constructor() {
437
- super("help shown", 0);
438
- }
439
- }
440
-
441
512
  class Completing {
442
513
  options;
443
514
  positionals;
@@ -448,11 +519,6 @@ class Completing {
448
519
  this.candidates = candidates;
449
520
  }
450
521
  }
451
- var completion = { active: false };
452
- var OUTPUT_OPTIONS = {
453
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
454
- plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
455
- };
456
522
  function applyOutput(color, plain, env = process9.env) {
457
523
  const when = plain === true ? "never" : color ?? "auto";
458
524
  if (when === "auto")
@@ -606,7 +672,6 @@ function parseError(error) {
606
672
  const message = upTo(error instanceof Error ? error.message : String(error), ". ");
607
673
  return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
608
674
  }
609
- var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
610
675
  function nearestOption(message, options, allowNegative) {
611
676
  const typed = UNKNOWN_OPTION.exec(message)?.[1];
612
677
  if (typed === undefined)
@@ -622,6 +687,61 @@ function nearestOption(message, options, allowNegative) {
622
687
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
623
688
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
624
689
  }
690
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
691
+ var init_args = __esm(() => {
692
+ init_format();
693
+ init_help();
694
+ init_text();
695
+ init_help();
696
+ init_input();
697
+ DASHES = /^-+/;
698
+ EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
699
+ Exit = class Exit extends Error {
700
+ code;
701
+ hint;
702
+ [EXIT] = true;
703
+ constructor(message, code, hint) {
704
+ super(message);
705
+ this.code = code;
706
+ this.hint = hint;
707
+ }
708
+ static [Symbol.hasInstance](value) {
709
+ if (this !== Exit)
710
+ return Function.prototype[Symbol.hasInstance].call(this, value);
711
+ return typeof value === "object" && value !== null && value[EXIT] === true;
712
+ }
713
+ };
714
+ UsageError = class UsageError extends Exit {
715
+ constructor(message, hint) {
716
+ super(message, 2, hint);
717
+ }
718
+ };
719
+ HelpShown = class HelpShown extends Exit {
720
+ constructor() {
721
+ super("help shown", 0);
722
+ }
723
+ };
724
+ completion = { active: false };
725
+ OUTPUT_OPTIONS = {
726
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
727
+ plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
728
+ };
729
+ UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
730
+ });
731
+
732
+ // ../kit/src/folders.ts
733
+ var SKIPPED_FOLDERS;
734
+ var init_folders = __esm(() => {
735
+ init_user_config();
736
+ SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
737
+ });
738
+
739
+ // src/gloss.ts
740
+ import process18 from "process";
741
+
742
+ // ../kit/src/index.ts
743
+ init_args();
744
+
625
745
  // ../kit/src/argv.ts
626
746
  import { readFileSync as readFileSync2, realpathSync } from "fs";
627
747
  import { resolve as resolve3 } from "path";
@@ -646,21 +766,163 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
646
766
  const after = at === -1 ? [] : cmdline.slice(at + 1);
647
767
  return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
648
768
  }
769
+ // ../kit/src/chart.ts
770
+ init_format();
771
+ init_mode();
772
+ init_style();
773
+ init_theme();
774
+ // ../kit/src/ci.ts
775
+ init_args();
776
+ init_format();
777
+
649
778
  // ../kit/src/progress.ts
779
+ init_format();
780
+ init_style();
781
+ init_theme();
650
782
  var ESC = String.fromCharCode(27);
651
783
  var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
652
784
  var RESET_STYLE = `${ESC}[0m`;
653
785
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
786
+
787
+ // ../kit/src/ci.ts
788
+ init_style();
789
+
790
+ // ../kit/src/tool.ts
791
+ init_format();
654
792
  // ../kit/src/cli.ts
793
+ init_args();
655
794
  import { readFileSync as readFileSync3, realpathSync as realpathSync2 } from "fs";
656
795
  import { dirname as dirname3, join as join5 } from "path";
796
+ import process14 from "process";
797
+
798
+ // ../kit/src/askpass.ts
799
+ import process11 from "process";
800
+ var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
801
+ async function askpassClient(argv) {
802
+ const socketPath = process11.env[SOCKET_VARIABLE];
803
+ if (socketPath === undefined)
804
+ return;
805
+ const request = { prompt: argv[0] ?? "", ...process11.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
806
+ const { promise, resolve } = Promise.withResolvers();
807
+ let received = "";
808
+ try {
809
+ await Bun.connect({
810
+ unix: socketPath,
811
+ socket: {
812
+ open: (socket) => void socket.write(`${JSON.stringify(request)}
813
+ `),
814
+ data: (_, chunk) => {
815
+ received += chunk.toString();
816
+ },
817
+ close: () => resolve(received),
818
+ error: () => resolve("")
819
+ }
820
+ });
821
+ } catch {
822
+ return 1;
823
+ }
824
+ const reply = await promise;
825
+ if (reply === "")
826
+ return 1;
827
+ const { answer } = JSON.parse(reply);
828
+ if (request.notice === true)
829
+ return 0;
830
+ if (answer === undefined)
831
+ return 1;
832
+ process11.stdout.write(`${answer}
833
+ `);
834
+ return 0;
835
+ }
836
+
837
+ // ../kit/src/completions.ts
838
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
839
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
840
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
841
+ set -l current (commandline -ct)
842
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
843
+ if test "$line" = __files__
844
+ __fish_complete_path $current
845
+ else
846
+ echo $line
847
+ end
848
+ end
849
+ end`;
850
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
851
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
852
+ local -a lines
853
+ COMPREPLY=()
854
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
855
+ for line in "\${lines[@]}"; do
856
+ if [[ $line == __files__ ]]; then
857
+ COMPREPLY+=($(compgen -f -- "$cur"))
858
+ else
859
+ words+="\${line%%$'\\t'*}"$'\\n'
860
+ fi
861
+ done
862
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
863
+ }`;
864
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
865
+ local line
866
+ local -a described plain
867
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
868
+ if [[ $line == __files__ ]]; then
869
+ _files
870
+ elif [[ $line == *$'\\t'* ]]; then
871
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
872
+ else
873
+ plain+=("$line")
874
+ fi
875
+ done
876
+ (( \${#described} )) && _describe -V value described
877
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
878
+ return 0
879
+ }`;
880
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
881
+ if (shell === "fish")
882
+ return `${header}
883
+ ${FISH_FUNCTION}
884
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
885
+ `).join("")}`;
886
+ if (shell === "bash")
887
+ return `${header}
888
+ ${BASH_FUNCTION}
889
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
890
+ `;
891
+ return `${header}
892
+ ${ZSH_FUNCTION}
893
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
894
+ `;
895
+ }
896
+
897
+ // ../kit/src/notify.ts
898
+ init_format();
899
+ init_mode();
657
900
  import process12 from "process";
901
+ var NOTIFY_AFTER_MS = 1e4;
902
+ var CANCELLED = 130;
903
+ function base64(text) {
904
+ return Buffer.from(text).toString("base64");
905
+ }
906
+ function notification(title, body, env = process12.env) {
907
+ const id = `kit${process12.pid}`;
908
+ 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\\`];
909
+ return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
910
+ }
911
+ function notifyEnd(command, code, ms, { stream = process12.stderr, env = process12.env } = {}) {
912
+ if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
913
+ return;
914
+ stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
915
+ }
916
+
917
+ // ../kit/src/cli.ts
918
+ init_style();
919
+ init_text();
658
920
 
659
921
  // ../kit/src/usage.ts
660
922
  import { appendFileSync, mkdirSync } from "fs";
661
923
  import { homedir as homedir3 } from "os";
662
924
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
663
- import process11 from "process";
925
+ import process13 from "process";
664
926
 
665
927
  // ../kit/src/logs.ts
666
928
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -674,14 +936,14 @@ var usageError;
674
936
  function noteUsageError(message) {
675
937
  usageError = message;
676
938
  }
677
- function stateHome(env = process11.env) {
939
+ function stateHome(env = process13.env) {
678
940
  const dir = env.XDG_STATE_HOME;
679
941
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
680
942
  }
681
- function usagePath(env = process11.env) {
943
+ function usagePath(env = process13.env) {
682
944
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
683
945
  }
684
- function usageRecorded(env = process11.env) {
946
+ function usageRecorded(env = process13.env) {
685
947
  const off = env.KAYNOOO_CLI_NO_USAGE;
686
948
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
687
949
  }
@@ -690,12 +952,12 @@ function flagNames(argv) {
690
952
  const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
691
953
  return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
692
954
  }
693
- function usageEntry(bin, command, argv, code, now = new Date) {
955
+ function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
694
956
  const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
695
957
  usageError = undefined;
696
- return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
958
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
697
959
  }
698
- function recordUsage(entry, env = process11.env) {
960
+ function recordUsage(entry, env = process13.env) {
699
961
  if (!usageRecorded(env))
700
962
  return;
701
963
  try {
@@ -711,10 +973,14 @@ var LEVEL_OPTIONS = {
711
973
  ...OUTPUT_OPTIONS,
712
974
  help: { type: "boolean", short: "h", description: "show this help" }
713
975
  };
714
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
976
+ var TOP_OPTIONS = {
977
+ ...LEVEL_OPTIONS,
978
+ version: { type: "boolean", short: "v", description: "print the version" },
979
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
980
+ };
715
981
  function printError(prefix, message, hint, cause) {
716
- const colors = paint(process12.stderr);
717
- const styled = takesControlCodes(process12.stderr);
982
+ const colors = paint(process14.stderr);
983
+ const styled = takesControlCodes(process14.stderr);
718
984
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
719
985
  const under = (label, text, tint) => text === undefined ? "" : `
720
986
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -791,6 +1057,19 @@ async function leafCandidates(run, words) {
791
1057
  const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
792
1058
  return values === undefined ? [FILES] : values.map(candidateLine);
793
1059
  }
1060
+ var COMPLETIONS = "--completions";
1061
+ function flagValue([flag = "", ...rest]) {
1062
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1063
+ }
1064
+ function printCompletionScript(name, args) {
1065
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1066
+ if (shell === undefined || args.length !== 1) {
1067
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1068
+ return 2;
1069
+ }
1070
+ console.log(completionScript(shell, [name]).trimEnd());
1071
+ return 0;
1072
+ }
794
1073
  async function printCandidates(found) {
795
1074
  for (const line of await found)
796
1075
  console.log(line);
@@ -812,42 +1091,82 @@ function packageVersion(entry = Bun.main) {
812
1091
  }
813
1092
  }
814
1093
  async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1094
+ const answered = await askpassClient(argv);
1095
+ if (answered !== undefined)
1096
+ return answered;
815
1097
  if (argv[0] === COMPLETE)
816
1098
  return printCandidates(leafCandidates(run, argv.slice(1)));
1099
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1100
+ return printCompletionScript(name, flagValue(argv));
817
1101
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
818
1102
  console.log(version ?? packageVersion());
819
1103
  return 0;
820
1104
  }
821
1105
  let code;
1106
+ const started = performance.now();
822
1107
  try {
823
1108
  code = await run(argv);
824
1109
  } catch (error) {
825
1110
  code = reportThrown(name, error, redact, wantsJson(argv));
826
1111
  }
1112
+ notifyEnd(name, code, performance.now() - started);
827
1113
  if (usage !== false) {
828
1114
  try {
829
- recordUsage(usageEntry(name, undefined, argv, code));
1115
+ recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
830
1116
  } catch {}
831
1117
  }
832
1118
  return code;
833
1119
  }
834
- // ../kit/src/folders.ts
835
- var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1120
+
1121
+ // ../kit/src/index.ts
1122
+ init_config();
1123
+
1124
+ // ../kit/src/excerpt.ts
1125
+ init_text();
1126
+
1127
+ // ../kit/src/index.ts
1128
+ init_folders();
1129
+ init_format();
1130
+
1131
+ // ../kit/src/git.ts
1132
+ init_args();
1133
+ // ../kit/src/limit.ts
1134
+ init_args();
1135
+
1136
+ // ../kit/src/index.ts
1137
+ init_mode();
1138
+
1139
+ // ../kit/src/report.ts
1140
+ init_style();
1141
+ init_text();
836
1142
  // ../kit/src/secrets.ts
837
1143
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
838
1144
  // ../kit/src/sessions.ts
839
1145
  var {Glob } = globalThis.Bun;
840
1146
  var SESSION_FILES = new Glob("*.json");
841
1147
  var ACCOUNT_DIRS = new Glob("*/sessions");
1148
+
1149
+ // ../kit/src/index.ts
1150
+ init_style();
1151
+ init_text();
1152
+ init_theme();
1153
+ init_user_config();
1154
+
1155
+ // ../kit/src/watch.ts
1156
+ init_args();
1157
+ init_input();
1158
+ init_style();
1159
+ // ../kit/src/workspace-root.ts
1160
+ init_user_config();
842
1161
  // src/help.ts
843
1162
  import { tmpdir } from "os";
844
- import process15 from "process";
1163
+ import process17 from "process";
845
1164
 
846
1165
  // src/man.ts
847
1166
  import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync4 } from "fs";
848
1167
  import { homedir as homedir4 } from "os";
849
1168
  import { join as join6 } from "path";
850
- import process14 from "process";
1169
+ import process16 from "process";
851
1170
  var SECTIONS = ["1", "8", "6"];
852
1171
  var SAFE_NAME = /^[\w.+-]+$/;
853
1172
  var COMPRESSED_UNSUPPORTED = /\.(?:bz2|xz)$/;
@@ -866,7 +1185,7 @@ function manDirs(env) {
866
1185
  const configured = env.MANPATH?.split(":").filter((dir) => dir !== "") ?? [];
867
1186
  return [...configured, "/usr/share/man", "/usr/local/share/man", join6(homedir4(), ".local/share/man")];
868
1187
  }
869
- function findPage(name, env = process14.env) {
1188
+ function findPage(name, env = process16.env) {
870
1189
  if (!SAFE_NAME.test(name))
871
1190
  return;
872
1191
  for (const section of SECTIONS) {
@@ -900,12 +1219,12 @@ function unOverstrike(text) {
900
1219
  return kept.join("");
901
1220
  }
902
1221
  function render(source) {
903
- const result = Bun.spawnSync(["nroff", "-man", "-Tutf8", "-rLL=200n", "-rLT=200n"], { stdin: source, stdout: "pipe", stderr: "ignore", env: { ...process14.env, GROFF_NO_SGR: "1" } });
1222
+ const result = Bun.spawnSync(["nroff", "-man", "-Tutf8", "-rLL=200n", "-rLT=200n"], { stdin: source, stdout: "pipe", stderr: "ignore", env: { ...process16.env, GROFF_NO_SGR: "1" } });
904
1223
  if (result.exitCode !== 0)
905
1224
  return;
906
1225
  return stripAnsi(unOverstrike(result.stdout.toString())).replaceAll(UNICODE_HYPHENS, "-");
907
1226
  }
908
- function pageText(name, env = process14.env) {
1227
+ function pageText(name, env = process16.env) {
909
1228
  const path = findPage(name, env);
910
1229
  const source = path === undefined ? undefined : readSource(path);
911
1230
  return source === undefined ? undefined : render(source);
@@ -986,7 +1305,7 @@ function summaryOf(text) {
986
1305
  function parsePage(name, text) {
987
1306
  return { name, summary: summaryOf(text), options: parseOptions(text) };
988
1307
  }
989
- function loadPage(name, env = process14.env) {
1308
+ function loadPage(name, env = process16.env) {
990
1309
  const text = pageText(name, env);
991
1310
  return text === undefined ? undefined : parsePage(name, text);
992
1311
  }
@@ -1017,7 +1336,7 @@ function helpOf(path, args, env) {
1017
1336
  ${result.stderr.toString()}`);
1018
1337
  return text.trim() === "" ? undefined : text;
1019
1338
  }
1020
- function loadHelp(name, subcommand, env = process15.env) {
1339
+ function loadHelp(name, subcommand, env = process17.env) {
1021
1340
  if (!SAFE_NAME2.test(name))
1022
1341
  return;
1023
1342
  const path = Bun.which(name, { PATH: env.PATH ?? "" });
@@ -1410,8 +1729,8 @@ function render2(line, stream = process.stdout, depth = 0) {
1410
1729
  // src/gloss.ts
1411
1730
  var USAGE = `gloss [options] <command line>: explains a shell command line, each option matched to what its man page says
1412
1731
 
1413
- Quote the command line or put it after --: gloss -- tar -xzvf a.tgz. Without arguments the command line is read from stdin.
1414
- Pipes, && and ||, redirects, variable assignments and $(...) substitutions are explained too. A command is looked up in the man pages on this machine (a subcommand such as git commit in git-commit); one with no man page is listed with its words unexplained, unless --run-help reads its options from '<command> --help': that runs the command (only a bare name found on PATH, no stdin, 3 seconds), so use it for commands you trust.`;
1732
+ Quote the command line or put it after --: gloss -- tar -xzvf a.tgz. Without arguments it is read from stdin.
1733
+ A command is looked up in the man pages on this machine; one with no man page is listed with its words unexplained, unless --run-help reads its options from '<command> --help', which runs the command (a bare name found on PATH only, 3 seconds), so use it for commands you trust.`;
1415
1734
  var EXITS = [[0, "it explained the line"], [2, "a usage error"]];
1416
1735
  var OPTIONS = {
1417
1736
  "run-help": { type: "boolean", description: "for a command with no man page, run `<command> --help` and read its options (runs the command)" },
@@ -1424,15 +1743,15 @@ function quote(word) {
1424
1743
  async function main(args) {
1425
1744
  const { values, positionals, rest } = parse(args, USAGE, OPTIONS, { rest: true, exits: EXITS, replaces: "explainshell in a browser, reading man pages for each flag", examples: ["gloss 'tar -xzvf a.tgz -C /tmp'", "gloss -- git commit -am fix"] });
1426
1745
  const typed = [...positionals.map(String), ...(rest ?? []).map(quote)].join(" ");
1427
- const line = typed === "" && !process16.stdin.isTTY ? (await Bun.stdin.text()).trim() : typed;
1746
+ const line = typed === "" && !process18.stdin.isTTY ? (await Bun.stdin.text()).trim() : typed;
1428
1747
  if (line === "")
1429
1748
  badUsage("give the command line to explain, quoted or after --");
1430
1749
  const result = analyze(line, { runHelp: values["run-help"] === true });
1431
1750
  if (values.json === true)
1432
1751
  printJson(result);
1433
1752
  else
1434
- console.log(render2(result, process16.stdout).join(`
1753
+ console.log(render2(result, process18.stdout).join(`
1435
1754
  `));
1436
1755
  return 0;
1437
1756
  }
1438
- process16.exitCode = await runMain({ name: "gloss", run: main });
1757
+ process18.exitCode = await runMain({ name: "gloss", run: main });
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-gloss",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.5",
5
5
  "description": "gloss: explains a shell command line, each word matched to what its man page says.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
8
- "homepage": "https://git.kaynooo.fr/kaynooo/cli/src/branch/main/packages/gloss#readme",
8
+ "homepage": "https://github.com/Kayno0o/cli/tree/main/packages/gloss#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://git.kaynooo.fr/kaynooo/cli.git",
11
+ "url": "git+https://github.com/Kayno0o/cli.git",
12
12
  "directory": "packages/gloss"
13
13
  },
14
- "bugs": "https://git.kaynooo.fr/kaynooo/cli/issues",
14
+ "bugs": "https://github.com/Kayno0o/cli/issues",
15
15
  "keywords": [
16
16
  "cli",
17
17
  "explainshell",
@@ -35,6 +35,6 @@
35
35
  "gloss": "$npm_execpath src/gloss.ts"
36
36
  },
37
37
  "devDependencies": {
38
- "@kaynooo/cli-kit": "0.38.3"
38
+ "@kaynooo/cli-kit": "0.45.1"
39
39
  }
40
40
  }