@kaynooo/cli-git 0.8.0 → 0.9.0

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 (4) hide show
  1. package/dist/gb.js +103 -56
  2. package/dist/gc.js +93 -46
  3. package/dist/gst.js +98 -51
  4. package/package.json +2 -2
package/dist/gb.js CHANGED
@@ -2,13 +2,37 @@
2
2
  // @bun
3
3
 
4
4
  // src/gb.ts
5
- import process15 from "process";
5
+ import process17 from "process";
6
6
  // ../kit/src/args.ts
7
- import process7 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
+ // ../kit/src/format.ts
11
+ import process7 from "process";
12
+
13
+ // ../kit/src/mode.ts
14
+ import process2 from "process";
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
29
+ }
30
+ function isInteractive(streams = process2) {
31
+ return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
32
+ }
33
+
10
34
  // ../kit/src/style.ts
11
- import process5 from "process";
35
+ import process6 from "process";
12
36
 
13
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
38
  function x(s) {
@@ -275,13 +299,13 @@ var t = le();
275
299
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
276
300
  import { homedir as homedir2 } from "os";
277
301
  import { join as join3, resolve as resolve2 } from "path";
278
- import process4 from "process";
302
+ import process5 from "process";
279
303
 
280
304
  // ../kit/src/config.ts
281
305
  import { existsSync } from "fs";
282
306
  import { dirname, join, resolve } from "path";
283
- import process2 from "process";
284
- function findUp(names, from = process2.cwd(), stop = () => false) {
307
+ import process3 from "process";
308
+ function findUp(names, from = process3.cwd(), stop = () => false) {
285
309
  const wanted = typeof names === "string" ? [names] : names;
286
310
  for (let dir = resolve(from);; dir = dirname(dir)) {
287
311
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -295,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
295
319
  // ../kit/src/user-config.ts
296
320
  import { homedir } from "os";
297
321
  import { join as join2 } from "path";
298
- import process3 from "process";
322
+ import process4 from "process";
299
323
  function configBase(where = {}) {
300
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
324
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
301
325
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
302
326
  }
303
327
  function userConfigPath(bin, where = {}) {
@@ -330,10 +354,30 @@ function isColorSpec(spec) {
330
354
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
331
355
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
332
356
  }
333
- function tinted(colors, spec) {
357
+ var CUBE = [0, 95, 135, 175, 215, 255];
358
+ function cubeLevel(channel) {
359
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
360
+ }
361
+ function nearest256(hex) {
362
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
363
+ const levels = rgb.map(cubeLevel);
364
+ const cube = levels.map((level) => CUBE[level]);
365
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
366
+ const greyValue = 8 + grey * 10;
367
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
368
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
369
+ }
370
+ function hasTrueColor(env) {
371
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
372
+ }
373
+ function tinted(colors, spec, env = process5.env) {
334
374
  if (typeof spec === "number")
335
375
  return colors.ansi256(spec);
336
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
376
+ return spec.trim().split(SPACES).reduce((chain, token) => {
377
+ if (HEX.test(token))
378
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
379
+ return chain[token] ?? chain;
380
+ }, colors);
337
381
  }
338
382
  function isRecord(value) {
339
383
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -417,7 +461,7 @@ function warnOnce(message) {
417
461
  function isPath(chosen) {
418
462
  return chosen.includes("/") || chosen.endsWith(".json");
419
463
  }
420
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
464
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
421
465
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
422
466
  const sources = [];
423
467
  const chosen = env.KIT_THEME ?? "";
@@ -447,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
447
491
  var current;
448
492
  var currentKey = "";
449
493
  function activeTheme() {
450
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
494
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
451
495
  if (current === undefined || key !== currentKey) {
452
496
  current = loadTheme();
453
497
  currentKey = key;
@@ -456,20 +500,20 @@ function activeTheme() {
456
500
  }
457
501
 
458
502
  // ../kit/src/style.ts
459
- function takesControlCodes(stream, env = process5.env) {
460
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
503
+ function takesControlCodes(stream, env = process6.env) {
504
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
461
505
  }
462
- function paint(stream, env = process5.env) {
506
+ function paint(stream, env = process6.env) {
463
507
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
464
508
  }
465
- function role(name, stream, env = process5.env) {
509
+ function role(name, stream, env = process6.env) {
466
510
  const colors = paint(stream, env);
467
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
511
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
468
512
  }
469
513
  var STATUS_WORDS = {
470
514
  passed: ["passed", "success", "succeeded", "ok"],
471
515
  failed: ["failed", "failure", "error", "errored"],
472
- running: ["running", "in_progress", "started"],
516
+ running: ["running", "in_progress", "started", "holding"],
473
517
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
474
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
475
519
  };
@@ -481,32 +525,35 @@ function upTo(text, separator) {
481
525
  return end === -1 ? text : text.slice(0, end);
482
526
  }
483
527
  var ESCAPE = String.fromCharCode(27);
528
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
529
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
530
+ }
484
531
  function printJson(value) {
485
- console.log(JSON.stringify(value, undefined, 2));
532
+ console.log(jsonText(value));
486
533
  }
487
534
 
488
535
  // ../kit/src/help.ts
489
- import process6 from "process";
536
+ import process8 from "process";
490
537
  var OPTIONAL = /\[[^\]]+\]/g;
491
538
  var USAGE_PREFIX = /^usage:\s*/i;
492
539
  var FULL_STOP = /\.$/;
493
- function usageLine(usage, colors = paint(process6.stdout)) {
540
+ function usageLine(usage, colors = paint(process8.stdout)) {
494
541
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
495
542
  }
496
- function helpText(usage, options, colors = paint(process6.stdout), { examples = [], replaces, exits = [] } = {}) {
543
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
497
544
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
498
545
  `);
499
546
  }
500
- function exitRows(exits, colors = paint(process6.stdout)) {
547
+ function exitRows(exits, colors = paint(process8.stdout)) {
501
548
  if (exits.length === 0)
502
549
  return [];
503
550
  const width = Math.max(...exits.map(([code]) => String(code).length));
504
551
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
505
552
  }
506
- function replacesRows(replaces, colors = paint(process6.stdout)) {
507
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
553
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
554
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
508
555
  }
509
- function wantsHelpJson(env = process6.env) {
556
+ function wantsHelpJson(env = process8.env) {
510
557
  return env.KIT_HELP === "json";
511
558
  }
512
559
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -525,12 +572,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
525
572
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
526
573
  };
527
574
  }
528
- function exampleRows(examples, colors = paint(process6.stdout)) {
529
- if (examples.length === 0)
575
+ function exampleRows(examples, colors = paint(process8.stdout)) {
576
+ if (examples.length === 0 || outputMode() === "agent")
530
577
  return [];
531
578
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
532
579
  }
533
- function optionRows(options, colors = paint(process6.stdout)) {
580
+ function optionRows(options, colors = paint(process8.stdout)) {
534
581
  const rows = Object.entries(options).map(([name, option]) => {
535
582
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
536
583
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -621,7 +668,7 @@ var OUTPUT_OPTIONS = {
621
668
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
622
669
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
623
670
  };
624
- function applyOutput(color, plain, env = process7.env) {
671
+ function applyOutput(color, plain, env = process9.env) {
625
672
  const when = plain === true ? "never" : color ?? "auto";
626
673
  if (when === "auto")
627
674
  return;
@@ -792,7 +839,7 @@ function nearestOption(message, options, allowNegative) {
792
839
  }
793
840
  // ../kit/src/process.ts
794
841
  import { constants } from "os";
795
- import process8 from "process";
842
+ import process10 from "process";
796
843
  var KILL_GRACE_MS = 2000;
797
844
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
798
845
  function exitCodeOf(code, signal) {
@@ -814,7 +861,7 @@ function holdSignals(cleanup) {
814
861
  },
815
862
  release: () => {
816
863
  for (const signal of SIGNALS)
817
- process8.off(signal, onSignal);
864
+ process10.off(signal, onSignal);
818
865
  }
819
866
  };
820
867
  function onSignal(signal) {
@@ -827,10 +874,10 @@ function holdSignals(cleanup) {
827
874
  return;
828
875
  held.release();
829
876
  cleanup(signal);
830
- process8.kill(process8.pid, signal);
877
+ process10.kill(process10.pid, signal);
831
878
  }
832
879
  for (const signal of SIGNALS)
833
- process8.on(signal, onSignal);
880
+ process10.on(signal, onSignal);
834
881
  return held;
835
882
  }
836
883
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -844,7 +891,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
844
891
  return;
845
892
  try {
846
893
  if (grouped)
847
- process8.kill(-proc.pid, killing);
894
+ process10.kill(-proc.pid, killing);
848
895
  else
849
896
  proc.kill(killing);
850
897
  } catch {}
@@ -920,13 +967,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
920
967
  // ../kit/src/cli.ts
921
968
  import { readFileSync as readFileSync2, realpathSync } from "fs";
922
969
  import { dirname as dirname3, join as join5 } from "path";
923
- import process10 from "process";
970
+ import process12 from "process";
924
971
 
925
972
  // ../kit/src/usage.ts
926
973
  import { appendFileSync, mkdirSync } from "fs";
927
974
  import { homedir as homedir3 } from "os";
928
975
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
929
- import process9 from "process";
976
+ import process11 from "process";
930
977
 
931
978
  // ../kit/src/logs.ts
932
979
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -940,14 +987,14 @@ var usageError;
940
987
  function noteUsageError(message) {
941
988
  usageError = message;
942
989
  }
943
- function stateHome(env = process9.env) {
990
+ function stateHome(env = process11.env) {
944
991
  const dir = env.XDG_STATE_HOME;
945
992
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
946
993
  }
947
- function usagePath(env = process9.env) {
994
+ function usagePath(env = process11.env) {
948
995
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
949
996
  }
950
- function usageRecorded(env = process9.env) {
997
+ function usageRecorded(env = process11.env) {
951
998
  const off = env.KAYNOOO_CLI_NO_USAGE;
952
999
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
953
1000
  }
@@ -961,7 +1008,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
961
1008
  usageError = undefined;
962
1009
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
963
1010
  }
964
- function recordUsage(entry, env = process9.env) {
1011
+ function recordUsage(entry, env = process11.env) {
965
1012
  if (!usageRecorded(env))
966
1013
  return;
967
1014
  try {
@@ -979,8 +1026,8 @@ var LEVEL_OPTIONS = {
979
1026
  };
980
1027
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
981
1028
  function printError(prefix, message, hint, cause) {
982
- const colors = paint(process10.stderr);
983
- const styled = takesControlCodes(process10.stderr);
1029
+ const colors = paint(process12.stderr);
1030
+ const styled = takesControlCodes(process12.stderr);
984
1031
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
985
1032
  const under = (label, text, tint) => text === undefined ? "" : `
986
1033
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1076,7 +1123,7 @@ function packageVersion(entry = Bun.main) {
1076
1123
  return "0.0.0";
1077
1124
  }
1078
1125
  }
1079
- async function runMain({ name, version, run, redact, usage }, argv = process10.argv.slice(2)) {
1126
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1080
1127
  if (argv[0] === COMPLETE)
1081
1128
  return printCandidates(leafCandidates(run, argv.slice(1)));
1082
1129
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1104,7 +1151,7 @@ var SESSION_FILES = new Glob("*.json");
1104
1151
  var ACCOUNT_DIRS = new Glob("*/sessions");
1105
1152
  // src/branch.ts
1106
1153
  import { basename } from "path";
1107
- import process14 from "process";
1154
+ import process16 from "process";
1108
1155
 
1109
1156
  // ../kit/src/picker/score.ts
1110
1157
  var MATCH = 16;
@@ -1347,11 +1394,11 @@ function chosen(state) {
1347
1394
 
1348
1395
  // ../kit/src/picker/terminal.ts
1349
1396
  import { openSync } from "fs";
1350
- import process13 from "process";
1397
+ import process15 from "process";
1351
1398
  import tty from "tty";
1352
1399
 
1353
1400
  // ../kit/src/picker/preview.ts
1354
- import process12 from "process";
1401
+ import process14 from "process";
1355
1402
 
1356
1403
  // ../kit/src/shell.ts
1357
1404
  var SEPARATORS = new Set([`
@@ -1420,7 +1467,7 @@ async function runPreview(template, line, signal, hidden = []) {
1420
1467
  ${previewCommand(template, line, hidden)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
1421
1468
  const stop = () => {
1422
1469
  try {
1423
- process12.kill(-proc.pid, "SIGKILL");
1470
+ process14.kill(-proc.pid, "SIGKILL");
1424
1471
  } catch {
1425
1472
  proc.kill();
1426
1473
  }
@@ -1551,7 +1598,7 @@ function openTerminal() {
1551
1598
  } catch {
1552
1599
  return fail("no terminal to read keys from (/dev/tty)");
1553
1600
  }
1554
- const out = process13.stderr;
1601
+ const out = process15.stderr;
1555
1602
  let resize;
1556
1603
  return {
1557
1604
  get columns() {
@@ -1694,9 +1741,9 @@ async function select(rows, settings, terminal = openTerminal()) {
1694
1741
  const ended = new Promise((resolve) => {
1695
1742
  finish = resolve;
1696
1743
  });
1697
- process13.once("exit", restore);
1744
+ process15.once("exit", restore);
1698
1745
  for (const signal of SIGNALS2)
1699
- process13.once(signal, stop);
1746
+ process15.once(signal, stop);
1700
1747
  try {
1701
1748
  terminal.write(PASTE_ON);
1702
1749
  terminal.listen(onChunk, () => draw(true));
@@ -1709,8 +1756,8 @@ async function select(rows, settings, terminal = openTerminal()) {
1709
1756
  await ended;
1710
1757
  } finally {
1711
1758
  for (const signal of SIGNALS2)
1712
- process13.off(signal, stop);
1713
- process13.off("exit", restore);
1759
+ process15.off(signal, stop);
1760
+ process15.off("exit", restore);
1714
1761
  restore();
1715
1762
  }
1716
1763
  return state.done === "accept" ? { rows: chosen(state), key: state.key, query: state.query } : undefined;
@@ -1974,14 +2021,14 @@ async function gb(args) {
1974
2021
  let branch;
1975
2022
  let key = "";
1976
2023
  if (named === undefined) {
1977
- const interactive = process14.stdin.isTTY && process14.stderr.isTTY && parsed.values.json !== true;
2024
+ const interactive = isInteractive() && parsed.values.json !== true;
1978
2025
  if (!interactive) {
1979
2026
  if (emitting)
1980
2027
  fail("the picker needs a terminal", 1);
1981
2028
  if (parsed.values.json === true)
1982
2029
  printJson(all);
1983
2030
  else
1984
- console.log(table(all.map(row)).map((line) => takesControlCodes(process14.stdout) ? line : Bun.stripANSI(line)).join(`
2031
+ console.log(table(all.map(row)).map((line) => takesControlCodes(process16.stdout) ? line : Bun.stripANSI(line)).join(`
1985
2032
  `));
1986
2033
  return 0;
1987
2034
  }
@@ -2038,4 +2085,4 @@ async function finish(command, typed, emitting) {
2038
2085
  }
2039
2086
 
2040
2087
  // src/gb.ts
2041
- process15.exitCode = await runMain({ name: "gb", run: gb });
2088
+ process17.exitCode = await runMain({ name: "gb", run: gb });
package/dist/gc.js CHANGED
@@ -2,13 +2,37 @@
2
2
  // @bun
3
3
 
4
4
  // src/gc.ts
5
- import process12 from "process";
5
+ import process14 from "process";
6
6
  // ../kit/src/args.ts
7
- import process7 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
+ // ../kit/src/format.ts
11
+ import process7 from "process";
12
+
13
+ // ../kit/src/mode.ts
14
+ import process2 from "process";
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
29
+ }
30
+ function isInteractive(streams = process2) {
31
+ return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
32
+ }
33
+
10
34
  // ../kit/src/style.ts
11
- import process5 from "process";
35
+ import process6 from "process";
12
36
 
13
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
38
  function x(s) {
@@ -275,13 +299,13 @@ var t = le();
275
299
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
276
300
  import { homedir as homedir2 } from "os";
277
301
  import { join as join3, resolve as resolve2 } from "path";
278
- import process4 from "process";
302
+ import process5 from "process";
279
303
 
280
304
  // ../kit/src/config.ts
281
305
  import { existsSync } from "fs";
282
306
  import { dirname, join, resolve } from "path";
283
- import process2 from "process";
284
- function findUp(names, from = process2.cwd(), stop = () => false) {
307
+ import process3 from "process";
308
+ function findUp(names, from = process3.cwd(), stop = () => false) {
285
309
  const wanted = typeof names === "string" ? [names] : names;
286
310
  for (let dir = resolve(from);; dir = dirname(dir)) {
287
311
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -295,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
295
319
  // ../kit/src/user-config.ts
296
320
  import { homedir } from "os";
297
321
  import { join as join2 } from "path";
298
- import process3 from "process";
322
+ import process4 from "process";
299
323
  function configBase(where = {}) {
300
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
324
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
301
325
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
302
326
  }
303
327
  function userConfigPath(bin, where = {}) {
@@ -330,10 +354,30 @@ function isColorSpec(spec) {
330
354
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
331
355
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
332
356
  }
333
- function tinted(colors, spec) {
357
+ var CUBE = [0, 95, 135, 175, 215, 255];
358
+ function cubeLevel(channel) {
359
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
360
+ }
361
+ function nearest256(hex) {
362
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
363
+ const levels = rgb.map(cubeLevel);
364
+ const cube = levels.map((level) => CUBE[level]);
365
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
366
+ const greyValue = 8 + grey * 10;
367
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
368
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
369
+ }
370
+ function hasTrueColor(env) {
371
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
372
+ }
373
+ function tinted(colors, spec, env = process5.env) {
334
374
  if (typeof spec === "number")
335
375
  return colors.ansi256(spec);
336
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
376
+ return spec.trim().split(SPACES).reduce((chain, token) => {
377
+ if (HEX.test(token))
378
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
379
+ return chain[token] ?? chain;
380
+ }, colors);
337
381
  }
338
382
  function isRecord(value) {
339
383
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -417,7 +461,7 @@ function warnOnce(message) {
417
461
  function isPath(chosen) {
418
462
  return chosen.includes("/") || chosen.endsWith(".json");
419
463
  }
420
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
464
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
421
465
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
422
466
  const sources = [];
423
467
  const chosen = env.KIT_THEME ?? "";
@@ -447,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
447
491
  var current;
448
492
  var currentKey = "";
449
493
  function activeTheme() {
450
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
494
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
451
495
  if (current === undefined || key !== currentKey) {
452
496
  current = loadTheme();
453
497
  currentKey = key;
@@ -456,20 +500,20 @@ function activeTheme() {
456
500
  }
457
501
 
458
502
  // ../kit/src/style.ts
459
- function takesControlCodes(stream, env = process5.env) {
460
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
503
+ function takesControlCodes(stream, env = process6.env) {
504
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
461
505
  }
462
- function paint(stream, env = process5.env) {
506
+ function paint(stream, env = process6.env) {
463
507
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
464
508
  }
465
- function role(name, stream, env = process5.env) {
509
+ function role(name, stream, env = process6.env) {
466
510
  const colors = paint(stream, env);
467
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
511
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
468
512
  }
469
513
  var STATUS_WORDS = {
470
514
  passed: ["passed", "success", "succeeded", "ok"],
471
515
  failed: ["failed", "failure", "error", "errored"],
472
- running: ["running", "in_progress", "started"],
516
+ running: ["running", "in_progress", "started", "holding"],
473
517
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
474
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
475
519
  };
@@ -481,32 +525,35 @@ function upTo(text, separator) {
481
525
  return end === -1 ? text : text.slice(0, end);
482
526
  }
483
527
  var ESCAPE = String.fromCharCode(27);
528
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
529
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
530
+ }
484
531
  function printJson(value) {
485
- console.log(JSON.stringify(value, undefined, 2));
532
+ console.log(jsonText(value));
486
533
  }
487
534
 
488
535
  // ../kit/src/help.ts
489
- import process6 from "process";
536
+ import process8 from "process";
490
537
  var OPTIONAL = /\[[^\]]+\]/g;
491
538
  var USAGE_PREFIX = /^usage:\s*/i;
492
539
  var FULL_STOP = /\.$/;
493
- function usageLine(usage, colors = paint(process6.stdout)) {
540
+ function usageLine(usage, colors = paint(process8.stdout)) {
494
541
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
495
542
  }
496
- function helpText(usage, options, colors = paint(process6.stdout), { examples = [], replaces, exits = [] } = {}) {
543
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
497
544
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
498
545
  `);
499
546
  }
500
- function exitRows(exits, colors = paint(process6.stdout)) {
547
+ function exitRows(exits, colors = paint(process8.stdout)) {
501
548
  if (exits.length === 0)
502
549
  return [];
503
550
  const width = Math.max(...exits.map(([code]) => String(code).length));
504
551
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
505
552
  }
506
- function replacesRows(replaces, colors = paint(process6.stdout)) {
507
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
553
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
554
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
508
555
  }
509
- function wantsHelpJson(env = process6.env) {
556
+ function wantsHelpJson(env = process8.env) {
510
557
  return env.KIT_HELP === "json";
511
558
  }
512
559
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -525,12 +572,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
525
572
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
526
573
  };
527
574
  }
528
- function exampleRows(examples, colors = paint(process6.stdout)) {
529
- if (examples.length === 0)
575
+ function exampleRows(examples, colors = paint(process8.stdout)) {
576
+ if (examples.length === 0 || outputMode() === "agent")
530
577
  return [];
531
578
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
532
579
  }
533
- function optionRows(options, colors = paint(process6.stdout)) {
580
+ function optionRows(options, colors = paint(process8.stdout)) {
534
581
  const rows = Object.entries(options).map(([name, option]) => {
535
582
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
536
583
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -621,7 +668,7 @@ var OUTPUT_OPTIONS = {
621
668
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
622
669
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
623
670
  };
624
- function applyOutput(color, plain, env = process7.env) {
671
+ function applyOutput(color, plain, env = process9.env) {
625
672
  const when = plain === true ? "never" : color ?? "auto";
626
673
  if (when === "auto")
627
674
  return;
@@ -792,7 +839,7 @@ function nearestOption(message, options, allowNegative) {
792
839
  }
793
840
  // ../kit/src/process.ts
794
841
  import { constants } from "os";
795
- import process8 from "process";
842
+ import process10 from "process";
796
843
  var KILL_GRACE_MS = 2000;
797
844
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
798
845
  function exitCodeOf(code, signal) {
@@ -814,7 +861,7 @@ function holdSignals(cleanup) {
814
861
  },
815
862
  release: () => {
816
863
  for (const signal of SIGNALS)
817
- process8.off(signal, onSignal);
864
+ process10.off(signal, onSignal);
818
865
  }
819
866
  };
820
867
  function onSignal(signal) {
@@ -827,10 +874,10 @@ function holdSignals(cleanup) {
827
874
  return;
828
875
  held.release();
829
876
  cleanup(signal);
830
- process8.kill(process8.pid, signal);
877
+ process10.kill(process10.pid, signal);
831
878
  }
832
879
  for (const signal of SIGNALS)
833
- process8.on(signal, onSignal);
880
+ process10.on(signal, onSignal);
834
881
  return held;
835
882
  }
836
883
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -844,7 +891,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
844
891
  return;
845
892
  try {
846
893
  if (grouped)
847
- process8.kill(-proc.pid, killing);
894
+ process10.kill(-proc.pid, killing);
848
895
  else
849
896
  proc.kill(killing);
850
897
  } catch {}
@@ -920,13 +967,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
920
967
  // ../kit/src/cli.ts
921
968
  import { readFileSync as readFileSync2, realpathSync } from "fs";
922
969
  import { dirname as dirname3, join as join5 } from "path";
923
- import process10 from "process";
970
+ import process12 from "process";
924
971
 
925
972
  // ../kit/src/usage.ts
926
973
  import { appendFileSync, mkdirSync } from "fs";
927
974
  import { homedir as homedir3 } from "os";
928
975
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
929
- import process9 from "process";
976
+ import process11 from "process";
930
977
 
931
978
  // ../kit/src/logs.ts
932
979
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -940,14 +987,14 @@ var usageError;
940
987
  function noteUsageError(message) {
941
988
  usageError = message;
942
989
  }
943
- function stateHome(env = process9.env) {
990
+ function stateHome(env = process11.env) {
944
991
  const dir = env.XDG_STATE_HOME;
945
992
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
946
993
  }
947
- function usagePath(env = process9.env) {
994
+ function usagePath(env = process11.env) {
948
995
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
949
996
  }
950
- function usageRecorded(env = process9.env) {
997
+ function usageRecorded(env = process11.env) {
951
998
  const off = env.KAYNOOO_CLI_NO_USAGE;
952
999
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
953
1000
  }
@@ -961,7 +1008,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
961
1008
  usageError = undefined;
962
1009
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
963
1010
  }
964
- function recordUsage(entry, env = process9.env) {
1011
+ function recordUsage(entry, env = process11.env) {
965
1012
  if (!usageRecorded(env))
966
1013
  return;
967
1014
  try {
@@ -979,8 +1026,8 @@ var LEVEL_OPTIONS = {
979
1026
  };
980
1027
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
981
1028
  function printError(prefix, message, hint, cause) {
982
- const colors = paint(process10.stderr);
983
- const styled = takesControlCodes(process10.stderr);
1029
+ const colors = paint(process12.stderr);
1030
+ const styled = takesControlCodes(process12.stderr);
984
1031
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
985
1032
  const under = (label, text, tint) => text === undefined ? "" : `
986
1033
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1076,7 +1123,7 @@ function packageVersion(entry = Bun.main) {
1076
1123
  return "0.0.0";
1077
1124
  }
1078
1125
  }
1079
- async function runMain({ name, version, run, redact, usage }, argv = process10.argv.slice(2)) {
1126
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1080
1127
  if (argv[0] === COMPLETE)
1081
1128
  return printCandidates(leafCandidates(run, argv.slice(1)));
1082
1129
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1173,7 +1220,7 @@ var OPTIONS = {
1173
1220
  };
1174
1221
  var RENAME = /^[RC]\d*$/;
1175
1222
  var NOT_A_REPOSITORY = /not a git repository/i;
1176
- var LITERAL = { ...process12.env, GIT_LITERAL_PATHSPECS: "1" };
1223
+ var LITERAL = { ...process14.env, GIT_LITERAL_PATHSPECS: "1" };
1177
1224
  function messageOf(title, lines, tickets) {
1178
1225
  return [title, lines.join(`
1179
1226
  `), tickets.join(`
@@ -1271,4 +1318,4 @@ ${(commit.stderr + commit.stdout).trim()}`;
1271
1318
  signals.release();
1272
1319
  }
1273
1320
  }
1274
- process12.exitCode = await runMain({ name: "gc", run: main });
1321
+ process14.exitCode = await runMain({ name: "gc", run: main });
package/dist/gst.js CHANGED
@@ -2,13 +2,37 @@
2
2
  // @bun
3
3
 
4
4
  // src/gst.ts
5
- import process13 from "process";
5
+ import process15 from "process";
6
6
  // ../kit/src/args.ts
7
- import process7 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
+ // ../kit/src/format.ts
11
+ import process7 from "process";
12
+
13
+ // ../kit/src/mode.ts
14
+ import process2 from "process";
15
+ var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
16
+ var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
17
+ function isSet(value) {
18
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
19
+ }
20
+ function outputMode(stream = process2.stdout, env = process2.env) {
21
+ const chosen = env.KIT_MODE;
22
+ if (chosen !== undefined && MODES.has(chosen))
23
+ return chosen;
24
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
25
+ return "agent";
26
+ if (stream.isTTY === true)
27
+ return "terminal";
28
+ return isSet(env.CI) ? "ci" : "pipe";
29
+ }
30
+ function isInteractive(streams = process2) {
31
+ return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
32
+ }
33
+
10
34
  // ../kit/src/style.ts
11
- import process5 from "process";
35
+ import process6 from "process";
12
36
 
13
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
38
  function x(s) {
@@ -275,13 +299,13 @@ var t = le();
275
299
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
276
300
  import { homedir as homedir2 } from "os";
277
301
  import { join as join3, resolve as resolve2 } from "path";
278
- import process4 from "process";
302
+ import process5 from "process";
279
303
 
280
304
  // ../kit/src/config.ts
281
305
  import { existsSync } from "fs";
282
306
  import { dirname, join, resolve } from "path";
283
- import process2 from "process";
284
- function findUp(names, from = process2.cwd(), stop = () => false) {
307
+ import process3 from "process";
308
+ function findUp(names, from = process3.cwd(), stop = () => false) {
285
309
  const wanted = typeof names === "string" ? [names] : names;
286
310
  for (let dir = resolve(from);; dir = dirname(dir)) {
287
311
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -295,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
295
319
  // ../kit/src/user-config.ts
296
320
  import { homedir } from "os";
297
321
  import { join as join2 } from "path";
298
- import process3 from "process";
322
+ import process4 from "process";
299
323
  function configBase(where = {}) {
300
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
324
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
301
325
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
302
326
  }
303
327
  function userConfigPath(bin, where = {}) {
@@ -330,10 +354,30 @@ function isColorSpec(spec) {
330
354
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
331
355
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
332
356
  }
333
- function tinted(colors, spec) {
357
+ var CUBE = [0, 95, 135, 175, 215, 255];
358
+ function cubeLevel(channel) {
359
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
360
+ }
361
+ function nearest256(hex) {
362
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
363
+ const levels = rgb.map(cubeLevel);
364
+ const cube = levels.map((level) => CUBE[level]);
365
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
366
+ const greyValue = 8 + grey * 10;
367
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
368
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
369
+ }
370
+ function hasTrueColor(env) {
371
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
372
+ }
373
+ function tinted(colors, spec, env = process5.env) {
334
374
  if (typeof spec === "number")
335
375
  return colors.ansi256(spec);
336
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
376
+ return spec.trim().split(SPACES).reduce((chain, token) => {
377
+ if (HEX.test(token))
378
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
379
+ return chain[token] ?? chain;
380
+ }, colors);
337
381
  }
338
382
  function isRecord(value) {
339
383
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -417,7 +461,7 @@ function warnOnce(message) {
417
461
  function isPath(chosen) {
418
462
  return chosen.includes("/") || chosen.endsWith(".json");
419
463
  }
420
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
464
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
421
465
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
422
466
  const sources = [];
423
467
  const chosen = env.KIT_THEME ?? "";
@@ -447,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
447
491
  var current;
448
492
  var currentKey = "";
449
493
  function activeTheme() {
450
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
494
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
451
495
  if (current === undefined || key !== currentKey) {
452
496
  current = loadTheme();
453
497
  currentKey = key;
@@ -456,20 +500,20 @@ function activeTheme() {
456
500
  }
457
501
 
458
502
  // ../kit/src/style.ts
459
- function takesControlCodes(stream, env = process5.env) {
460
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
503
+ function takesControlCodes(stream, env = process6.env) {
504
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
461
505
  }
462
- function paint(stream, env = process5.env) {
506
+ function paint(stream, env = process6.env) {
463
507
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
464
508
  }
465
- function role(name, stream, env = process5.env) {
509
+ function role(name, stream, env = process6.env) {
466
510
  const colors = paint(stream, env);
467
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
511
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
468
512
  }
469
513
  var STATUS_WORDS = {
470
514
  passed: ["passed", "success", "succeeded", "ok"],
471
515
  failed: ["failed", "failure", "error", "errored"],
472
- running: ["running", "in_progress", "started"],
516
+ running: ["running", "in_progress", "started", "holding"],
473
517
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
474
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
475
519
  };
@@ -481,32 +525,35 @@ function upTo(text, separator) {
481
525
  return end === -1 ? text : text.slice(0, end);
482
526
  }
483
527
  var ESCAPE = String.fromCharCode(27);
528
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
529
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
530
+ }
484
531
  function printJson(value) {
485
- console.log(JSON.stringify(value, undefined, 2));
532
+ console.log(jsonText(value));
486
533
  }
487
534
 
488
535
  // ../kit/src/help.ts
489
- import process6 from "process";
536
+ import process8 from "process";
490
537
  var OPTIONAL = /\[[^\]]+\]/g;
491
538
  var USAGE_PREFIX = /^usage:\s*/i;
492
539
  var FULL_STOP = /\.$/;
493
- function usageLine(usage, colors = paint(process6.stdout)) {
540
+ function usageLine(usage, colors = paint(process8.stdout)) {
494
541
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
495
542
  }
496
- function helpText(usage, options, colors = paint(process6.stdout), { examples = [], replaces, exits = [] } = {}) {
543
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
497
544
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
498
545
  `);
499
546
  }
500
- function exitRows(exits, colors = paint(process6.stdout)) {
547
+ function exitRows(exits, colors = paint(process8.stdout)) {
501
548
  if (exits.length === 0)
502
549
  return [];
503
550
  const width = Math.max(...exits.map(([code]) => String(code).length));
504
551
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
505
552
  }
506
- function replacesRows(replaces, colors = paint(process6.stdout)) {
507
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
553
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
554
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
508
555
  }
509
- function wantsHelpJson(env = process6.env) {
556
+ function wantsHelpJson(env = process8.env) {
510
557
  return env.KIT_HELP === "json";
511
558
  }
512
559
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -525,12 +572,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
525
572
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
526
573
  };
527
574
  }
528
- function exampleRows(examples, colors = paint(process6.stdout)) {
529
- if (examples.length === 0)
575
+ function exampleRows(examples, colors = paint(process8.stdout)) {
576
+ if (examples.length === 0 || outputMode() === "agent")
530
577
  return [];
531
578
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
532
579
  }
533
- function optionRows(options, colors = paint(process6.stdout)) {
580
+ function optionRows(options, colors = paint(process8.stdout)) {
534
581
  const rows = Object.entries(options).map(([name, option]) => {
535
582
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
536
583
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -621,7 +668,7 @@ var OUTPUT_OPTIONS = {
621
668
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
622
669
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
623
670
  };
624
- function applyOutput(color, plain, env = process7.env) {
671
+ function applyOutput(color, plain, env = process9.env) {
625
672
  const when = plain === true ? "never" : color ?? "auto";
626
673
  if (when === "auto")
627
674
  return;
@@ -792,7 +839,7 @@ function nearestOption(message, options, allowNegative) {
792
839
  }
793
840
  // ../kit/src/process.ts
794
841
  import { constants } from "os";
795
- import process8 from "process";
842
+ import process10 from "process";
796
843
  var KILL_GRACE_MS = 2000;
797
844
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
798
845
  function exitCodeOf(code, signal) {
@@ -814,7 +861,7 @@ function holdSignals(cleanup) {
814
861
  },
815
862
  release: () => {
816
863
  for (const signal of SIGNALS)
817
- process8.off(signal, onSignal);
864
+ process10.off(signal, onSignal);
818
865
  }
819
866
  };
820
867
  function onSignal(signal) {
@@ -827,10 +874,10 @@ function holdSignals(cleanup) {
827
874
  return;
828
875
  held.release();
829
876
  cleanup(signal);
830
- process8.kill(process8.pid, signal);
877
+ process10.kill(process10.pid, signal);
831
878
  }
832
879
  for (const signal of SIGNALS)
833
- process8.on(signal, onSignal);
880
+ process10.on(signal, onSignal);
834
881
  return held;
835
882
  }
836
883
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -844,7 +891,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
844
891
  return;
845
892
  try {
846
893
  if (grouped)
847
- process8.kill(-proc.pid, killing);
894
+ process10.kill(-proc.pid, killing);
848
895
  else
849
896
  proc.kill(killing);
850
897
  } catch {}
@@ -920,13 +967,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
920
967
  // ../kit/src/cli.ts
921
968
  import { readFileSync as readFileSync2, realpathSync } from "fs";
922
969
  import { dirname as dirname3, join as join5 } from "path";
923
- import process10 from "process";
970
+ import process12 from "process";
924
971
 
925
972
  // ../kit/src/usage.ts
926
973
  import { appendFileSync, mkdirSync } from "fs";
927
974
  import { homedir as homedir3 } from "os";
928
975
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
929
- import process9 from "process";
976
+ import process11 from "process";
930
977
 
931
978
  // ../kit/src/logs.ts
932
979
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -940,14 +987,14 @@ var usageError;
940
987
  function noteUsageError(message) {
941
988
  usageError = message;
942
989
  }
943
- function stateHome(env = process9.env) {
990
+ function stateHome(env = process11.env) {
944
991
  const dir = env.XDG_STATE_HOME;
945
992
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
946
993
  }
947
- function usagePath(env = process9.env) {
994
+ function usagePath(env = process11.env) {
948
995
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
949
996
  }
950
- function usageRecorded(env = process9.env) {
997
+ function usageRecorded(env = process11.env) {
951
998
  const off = env.KAYNOOO_CLI_NO_USAGE;
952
999
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
953
1000
  }
@@ -961,7 +1008,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
961
1008
  usageError = undefined;
962
1009
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
963
1010
  }
964
- function recordUsage(entry, env = process9.env) {
1011
+ function recordUsage(entry, env = process11.env) {
965
1012
  if (!usageRecorded(env))
966
1013
  return;
967
1014
  try {
@@ -979,8 +1026,8 @@ var LEVEL_OPTIONS = {
979
1026
  };
980
1027
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
981
1028
  function printError(prefix, message, hint, cause) {
982
- const colors = paint(process10.stderr);
983
- const styled = takesControlCodes(process10.stderr);
1029
+ const colors = paint(process12.stderr);
1030
+ const styled = takesControlCodes(process12.stderr);
984
1031
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
985
1032
  const under = (label, text, tint) => text === undefined ? "" : `
986
1033
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1076,7 +1123,7 @@ function packageVersion(entry = Bun.main) {
1076
1123
  return "0.0.0";
1077
1124
  }
1078
1125
  }
1079
- async function runMain({ name, version, run, redact, usage }, argv = process10.argv.slice(2)) {
1126
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1080
1127
  if (argv[0] === COMPLETE)
1081
1128
  return printCandidates(leafCandidates(run, argv.slice(1)));
1082
1129
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1103,8 +1150,8 @@ var {Glob } = globalThis.Bun;
1103
1150
  var SESSION_FILES = new Glob("*.json");
1104
1151
  var ACCOUNT_DIRS = new Glob("*/sessions");
1105
1152
  // src/colour.ts
1106
- import process12 from "process";
1107
- function letter(status, stream = process12.stdout) {
1153
+ import process14 from "process";
1154
+ function letter(status, stream = process14.stdout) {
1108
1155
  const colors = paint(stream);
1109
1156
  const tint = { A: colors.green, M: colors.yellow, D: colors.red, U: colors.red, R: colors.cyan, C: colors.cyan }[status] ?? colors.dim;
1110
1157
  return tint(status);
@@ -1198,7 +1245,7 @@ var OPTIONS = {
1198
1245
  json: jsonOption("{branch, oid, upstream, ahead, behind, head, staged, unstaged, untracked, conflicted, commits}")
1199
1246
  };
1200
1247
  function group(title, lines) {
1201
- return lines.length === 0 ? [] : [paint(process13.stdout).bold(`${title}:`), ...lines.map((line) => ` ${line}`)];
1248
+ return lines.length === 0 ? [] : [paint(process15.stdout).bold(`${title}:`), ...lines.map((line) => ` ${line}`)];
1202
1249
  }
1203
1250
  function staged({ index, from, path }) {
1204
1251
  return `${letter(index)} ${from === undefined ? "" : `${from} -> `}${path}`;
@@ -1241,12 +1288,12 @@ ${USAGE}`);
1241
1288
  summary(status, head.code === 0 ? head.stdout : ""),
1242
1289
  ...group("staged", status.changes.filter((change) => change.index !== ".").map(staged)),
1243
1290
  ...group("unstaged", status.changes.filter((change) => change.worktree !== ".").map((change) => `${letter(change.worktree)} ${change.path}`)),
1244
- ...group("untracked", status.untracked.map((file) => paint(process13.stdout).dim(file))),
1245
- ...group("conflicted", status.conflicted.map((file) => paint(process13.stdout).red(file))),
1246
- ...group("commits", commits.map(([commitSha = "", commitTitle = ""]) => `${role("id", process13.stdout)(commitSha)} ${commitTitle}`))
1291
+ ...group("untracked", status.untracked.map((file) => paint(process15.stdout).dim(file))),
1292
+ ...group("conflicted", status.conflicted.map((file) => paint(process15.stdout).red(file))),
1293
+ ...group("commits", commits.map(([commitSha = "", commitTitle = ""]) => `${role("id", process15.stdout)(commitSha)} ${commitTitle}`))
1247
1294
  ];
1248
1295
  console.log(lines.join(`
1249
1296
  `));
1250
1297
  return 0;
1251
1298
  }
1252
- process13.exitCode = await runMain({ name: "gst", run: main });
1299
+ process15.exitCode = await runMain({ name: "gst", run: main });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-git",
3
3
  "type": "module",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "description": "gst, gc and gb: a repository's state in one call, a commit of exactly the paths given, its message checked before anything is staged, and a branch picked.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -44,6 +44,6 @@
44
44
  "gb": "$npm_execpath src/gb.ts"
45
45
  },
46
46
  "devDependencies": {
47
- "@kaynooo/cli-kit": "0.21.1"
47
+ "@kaynooo/cli-kit": "0.22.0"
48
48
  }
49
49
  }