@kaynooo/cli-code 0.10.0 → 0.12.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.
package/dist/cli.js CHANGED
@@ -2,16 +2,36 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process16 from "process";
5
+ import process17 from "process";
6
6
  // ../kit/src/args.ts
7
- import process8 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process6 from "process";
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
+ }
12
30
 
13
31
  // ../kit/src/style.ts
14
- import process5 from "process";
32
+ import { resolve as resolve3 } from "path";
33
+ import process6 from "process";
34
+ import { pathToFileURL } from "url";
15
35
 
16
36
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
17
37
  function x(s) {
@@ -278,13 +298,13 @@ var t = le();
278
298
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
279
299
  import { homedir as homedir2 } from "os";
280
300
  import { join as join3, resolve as resolve2 } from "path";
281
- import process4 from "process";
301
+ import process5 from "process";
282
302
 
283
303
  // ../kit/src/config.ts
284
304
  import { existsSync } from "fs";
285
305
  import { dirname, join, resolve } from "path";
286
- import process2 from "process";
287
- function findUp(names, from = process2.cwd(), stop = () => false) {
306
+ import process3 from "process";
307
+ function findUp(names, from = process3.cwd(), stop = () => false) {
288
308
  const wanted = typeof names === "string" ? [names] : names;
289
309
  for (let dir = resolve(from);; dir = dirname(dir)) {
290
310
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -298,9 +318,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
298
318
  // ../kit/src/user-config.ts
299
319
  import { homedir } from "os";
300
320
  import { join as join2 } from "path";
301
- import process3 from "process";
321
+ import process4 from "process";
302
322
  function configBase(where = {}) {
303
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
323
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
304
324
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
305
325
  }
306
326
  function userConfigPath(bin, where = {}) {
@@ -310,13 +330,13 @@ function userConfigPath(bin, where = {}) {
310
330
  // ../kit/src/theme.ts
311
331
  var DEFAULT = {
312
332
  colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
313
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
333
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
314
334
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
315
335
  bins: {}
316
336
  };
317
337
  var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
318
338
  var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
319
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
339
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
320
340
  var PRESETS = {
321
341
  default: {},
322
342
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -333,10 +353,30 @@ function isColorSpec(spec) {
333
353
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
334
354
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
335
355
  }
336
- function tinted(colors, spec) {
356
+ var CUBE = [0, 95, 135, 175, 215, 255];
357
+ function cubeLevel(channel) {
358
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
359
+ }
360
+ function nearest256(hex) {
361
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
362
+ const levels = rgb.map(cubeLevel);
363
+ const cube = levels.map((level) => CUBE[level]);
364
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
365
+ const greyValue = 8 + grey * 10;
366
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
367
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
368
+ }
369
+ function hasTrueColor(env) {
370
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
371
+ }
372
+ function tinted(colors, spec, env = process5.env) {
337
373
  if (typeof spec === "number")
338
374
  return colors.ansi256(spec);
339
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
375
+ return spec.trim().split(SPACES).reduce((chain, token) => {
376
+ if (HEX.test(token))
377
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
378
+ return chain[token] ?? chain;
379
+ }, colors);
340
380
  }
341
381
  function isRecord(value) {
342
382
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -420,7 +460,7 @@ function warnOnce(message) {
420
460
  function isPath(chosen) {
421
461
  return chosen.includes("/") || chosen.endsWith(".json");
422
462
  }
423
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
463
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
424
464
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
425
465
  const sources = [];
426
466
  const chosen = env.KIT_THEME ?? "";
@@ -450,7 +490,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
450
490
  var current;
451
491
  var currentKey = "";
452
492
  function activeTheme() {
453
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
493
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
454
494
  if (current === undefined || key !== currentKey) {
455
495
  current = loadTheme();
456
496
  currentKey = key;
@@ -460,36 +500,62 @@ function activeTheme() {
460
500
 
461
501
  // ../kit/src/style.ts
462
502
  var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
463
- function takesControlCodes(stream, env = process5.env) {
464
- 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";
465
505
  }
466
- function paint(stream, env = process5.env) {
506
+ function paint(stream, env = process6.env) {
467
507
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
468
508
  }
469
- function marked(mark, text, stream, detail, env = process5.env) {
509
+ function marked(mark, text, stream, detail, env = process6.env) {
470
510
  const colors = paint(stream, env);
471
511
  let head = MARK_WORDS[mark];
472
512
  if (takesControlCodes(stream, env)) {
473
513
  const { theme } = activeTheme();
474
- head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
514
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
475
515
  }
476
516
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
477
517
  }
478
518
  function warn(text, detail) {
479
- console.error(marked("warn", text, process5.stderr, detail));
519
+ console.error(marked("warn", text, process6.stderr, detail));
480
520
  }
481
- function role(name, stream, env = process5.env) {
521
+ function role(name, stream, env = process6.env) {
482
522
  const colors = paint(stream, env);
483
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
523
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
484
524
  }
485
525
  var STATUS_WORDS = {
486
526
  passed: ["passed", "success", "succeeded", "ok"],
487
527
  failed: ["failed", "failure", "error", "errored"],
488
- running: ["running", "in_progress", "started"],
528
+ running: ["running", "in_progress", "started", "holding"],
489
529
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
490
530
  skipped: ["skipped", "cancelled", "canceled", "manual"]
491
531
  };
492
532
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
533
+ function header(bin, context, stream, env = process6.env) {
534
+ if (!takesControlCodes(stream, env))
535
+ return "";
536
+ const colors = paint(stream, env);
537
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
538
+ const { theme } = activeTheme();
539
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
540
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
541
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
542
+ }
543
+ function link(text, url, stream, env = process6.env) {
544
+ if (takesControlCodes(stream, env))
545
+ return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
546
+ return text === url ? text : `${text} (${url})`;
547
+ }
548
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
549
+ const line = header(bin, context, stream, env);
550
+ if (line !== "")
551
+ console.log(line);
552
+ }
553
+ function hyperlink(text, url, stream, env = process6.env) {
554
+ return takesControlCodes(stream, env) ? link(text, url, stream, env) : text;
555
+ }
556
+ function fileLink(text, path, stream, from = process6.cwd(), env = process6.env) {
557
+ return hyperlink(text, pathToFileURL(resolve3(from, path)).href, stream, env);
558
+ }
493
559
 
494
560
  // ../kit/src/format.ts
495
561
  function upTo(text, separator) {
@@ -504,8 +570,11 @@ var ESCAPE = String.fromCharCode(27);
504
570
  function textWidth(text) {
505
571
  return Bun.stringWidth(text);
506
572
  }
507
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
573
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
508
574
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
575
+ if (outputMode(stream, env) === "agent")
576
+ return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
577
+ `);
509
578
  const widths = [];
510
579
  for (const row of cells) {
511
580
  for (const [index, cell] of row.entries())
@@ -540,32 +609,35 @@ function narrow(rows, widths, limit) {
540
609
  }
541
610
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
542
611
  }
612
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
613
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
614
+ }
543
615
  function printJson(value) {
544
- console.log(JSON.stringify(value, undefined, 2));
616
+ console.log(jsonText(value));
545
617
  }
546
618
 
547
619
  // ../kit/src/help.ts
548
- import process7 from "process";
620
+ import process8 from "process";
549
621
  var OPTIONAL = /\[[^\]]+\]/g;
550
622
  var USAGE_PREFIX = /^usage:\s*/i;
551
623
  var FULL_STOP = /\.$/;
552
- function usageLine(usage, colors = paint(process7.stdout)) {
624
+ function usageLine(usage, colors = paint(process8.stdout)) {
553
625
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
554
626
  }
555
- function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
627
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
556
628
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
557
629
  `);
558
630
  }
559
- function exitRows(exits, colors = paint(process7.stdout)) {
631
+ function exitRows(exits, colors = paint(process8.stdout)) {
560
632
  if (exits.length === 0)
561
633
  return [];
562
634
  const width = Math.max(...exits.map(([code]) => String(code).length));
563
635
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
564
636
  }
565
- function replacesRows(replaces, colors = paint(process7.stdout)) {
566
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
637
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
638
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
567
639
  }
568
- function wantsHelpJson(env = process7.env) {
640
+ function wantsHelpJson(env = process8.env) {
569
641
  return env.KIT_HELP === "json";
570
642
  }
571
643
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -584,12 +656,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
584
656
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
585
657
  };
586
658
  }
587
- function exampleRows(examples, colors = paint(process7.stdout)) {
588
- if (examples.length === 0)
659
+ function exampleRows(examples, colors = paint(process8.stdout)) {
660
+ if (examples.length === 0 || outputMode() === "agent")
589
661
  return [];
590
662
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
591
663
  }
592
- function optionRows(options, colors = paint(process7.stdout)) {
664
+ function optionRows(options, colors = paint(process8.stdout)) {
593
665
  const rows = Object.entries(options).map(([name, option]) => {
594
666
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
595
667
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -652,7 +724,6 @@ var DASHES = /^-+/;
652
724
  function jsonOption(holds) {
653
725
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
654
726
  }
655
-
656
727
  class Exit extends Error {
657
728
  code;
658
729
  hint;
@@ -696,7 +767,7 @@ var OUTPUT_OPTIONS = {
696
767
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
697
768
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
698
769
  };
699
- function applyOutput(color, plain, env = process8.env) {
770
+ function applyOutput(color, plain, env = process9.env) {
700
771
  const when = plain === true ? "never" : color ?? "auto";
701
772
  if (when === "auto")
702
773
  return;
@@ -867,7 +938,7 @@ function nearestOption(message, options, allowNegative) {
867
938
  }
868
939
  // ../kit/src/process.ts
869
940
  import { constants } from "os";
870
- import process9 from "process";
941
+ import process10 from "process";
871
942
  var KILL_GRACE_MS = 2000;
872
943
  function exitCodeOf(code, signal) {
873
944
  if (code !== null)
@@ -887,7 +958,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
887
958
  return;
888
959
  try {
889
960
  if (grouped)
890
- process9.kill(-proc.pid, killing);
961
+ process10.kill(-proc.pid, killing);
891
962
  else
892
963
  proc.kill(killing);
893
964
  } catch {}
@@ -963,13 +1034,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
963
1034
  // ../kit/src/cli.ts
964
1035
  import { readFileSync as readFileSync2, realpathSync } from "fs";
965
1036
  import { dirname as dirname3, join as join5 } from "path";
966
- import process11 from "process";
1037
+ import process12 from "process";
967
1038
 
968
1039
  // ../kit/src/usage.ts
969
1040
  import { appendFileSync, mkdirSync } from "fs";
970
1041
  import { homedir as homedir3 } from "os";
971
1042
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
972
- import process10 from "process";
1043
+ import process11 from "process";
973
1044
 
974
1045
  // ../kit/src/logs.ts
975
1046
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -983,14 +1054,14 @@ var usageError;
983
1054
  function noteUsageError(message) {
984
1055
  usageError = message;
985
1056
  }
986
- function stateHome(env = process10.env) {
1057
+ function stateHome(env = process11.env) {
987
1058
  const dir = env.XDG_STATE_HOME;
988
1059
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
989
1060
  }
990
- function usagePath(env = process10.env) {
1061
+ function usagePath(env = process11.env) {
991
1062
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
992
1063
  }
993
- function usageRecorded(env = process10.env) {
1064
+ function usageRecorded(env = process11.env) {
994
1065
  const off = env.KAYNOOO_CLI_NO_USAGE;
995
1066
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
996
1067
  }
@@ -1004,7 +1075,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1004
1075
  usageError = undefined;
1005
1076
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1006
1077
  }
1007
- function recordUsage(entry, env = process10.env) {
1078
+ function recordUsage(entry, env = process11.env) {
1008
1079
  if (!usageRecorded(env))
1009
1080
  return;
1010
1081
  try {
@@ -1095,8 +1166,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1095
1166
  `);
1096
1167
  }
1097
1168
  function printError(prefix, message, hint, cause) {
1098
- const colors = paint(process11.stderr);
1099
- const styled = takesControlCodes(process11.stderr);
1169
+ const colors = paint(process12.stderr);
1170
+ const styled = takesControlCodes(process12.stderr);
1100
1171
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1101
1172
  const under = (label, text, tint) => text === undefined ? "" : `
1102
1173
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1139,11 +1210,11 @@ async function dispatch(level, typed, { version, redact }) {
1139
1210
  }
1140
1211
  }
1141
1212
  if (name === undefined && level.path.length > 1) {
1142
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stderr));
1213
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
1143
1214
  return 2;
1144
1215
  }
1145
1216
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1146
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stdout));
1217
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
1147
1218
  return 0;
1148
1219
  }
1149
1220
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1270,7 +1341,7 @@ function packageVersion(entry = Bun.main) {
1270
1341
  return "0.0.0";
1271
1342
  }
1272
1343
  }
1273
- async function runCli(cli, argv = process11.argv.slice(2)) {
1344
+ async function runCli(cli, argv = process12.argv.slice(2)) {
1274
1345
  const version = cli.version ?? packageVersion();
1275
1346
  if (argv[0] === COMPLETE)
1276
1347
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1297,7 +1368,7 @@ function commandPath(scope, argv) {
1297
1368
  }
1298
1369
  return path.length === 0 ? undefined : path.join(" ");
1299
1370
  }
1300
- async function runMain({ name, version, run, redact, usage }, argv = process11.argv.slice(2)) {
1371
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1301
1372
  if (argv[0] === COMPLETE)
1302
1373
  return printCandidates(leafCandidates(run, argv.slice(1)));
1303
1374
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1317,6 +1388,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process11.a
1317
1388
  }
1318
1389
  return code;
1319
1390
  }
1391
+ // ../kit/src/folders.ts
1392
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1320
1393
  // ../kit/src/limit.ts
1321
1394
  function limitOptions(fallback) {
1322
1395
  return {
@@ -1346,7 +1419,7 @@ var SESSION_FILES = new Glob("*.json");
1346
1419
  var ACCOUNT_DIRS = new Glob("*/sessions");
1347
1420
  // src/hotspots.ts
1348
1421
  import { join as join7 } from "path";
1349
- import process13 from "process";
1422
+ import process14 from "process";
1350
1423
 
1351
1424
  // src/churn.ts
1352
1425
  var SOURCE = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|kay|py|go|rs|rb|php|java|kt|swift|cs|c|cc|cpp|h|hpp|scala|dart|lua|sh|zsh|fish)$/;
@@ -1391,7 +1464,6 @@ import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "f
1391
1464
  import { join as join6, relative } from "path";
1392
1465
  var MAX_BYTES = 2000000;
1393
1466
  var SNIFF_BYTES = 8000;
1394
- var SKIPPED = new Set(["node_modules", "dist", "build", "vendor", "target", "coverage"]);
1395
1467
  function walk(dir, found) {
1396
1468
  let entries;
1397
1469
  try {
@@ -1400,7 +1472,7 @@ function walk(dir, found) {
1400
1472
  return found;
1401
1473
  }
1402
1474
  for (const entry of entries) {
1403
- if (entry.name.startsWith(".") || SKIPPED.has(entry.name))
1475
+ if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
1404
1476
  continue;
1405
1477
  if (entry.isDirectory())
1406
1478
  walk(join6(dir, entry.name), found);
@@ -1504,7 +1576,7 @@ async function hotspots(args) {
1504
1576
  if (positionals.length > 1)
1505
1577
  badUsage("give one folder");
1506
1578
  const count = limitOf(values, DEFAULT_COUNT);
1507
- const cwd = process13.cwd();
1579
+ const cwd = process14.cwd();
1508
1580
  const bulk = Number(values.bulk ?? DEFAULT_BULK);
1509
1581
  if (!Number.isInteger(bulk) || bulk < 1)
1510
1582
  badUsage(`--bulk takes a number of files, not ${values.bulk}`);
@@ -1535,15 +1607,16 @@ async function hotspots(args) {
1535
1607
  printJson(shown);
1536
1608
  return 0;
1537
1609
  }
1538
- const colors = paint(process13.stdout);
1539
- const path = role("path", process13.stdout);
1610
+ const colors = paint(process14.stdout);
1611
+ const path = role("path", process14.stdout);
1540
1612
  const top = shown.reduce((highest, row) => Math.max(highest, row.score), 0);
1541
1613
  const heat = (score, text) => {
1542
1614
  if (top > 0 && score >= top * HOT)
1543
1615
  return colors.red(text);
1544
1616
  return top > 0 && score >= top * WARM ? colors.yellow(text) : text;
1545
1617
  };
1546
- console.log(table([["rank", "score", "churn", "recent", "complexity", "lines", "file", "most complex declaration"], ...shown.map((row) => [colors.dim(String(row.rank)), heat(row.score, String(row.score)), ...[row.churn, row.recent, row.complexity, row.lines].map(String), path(row.path), row.worst === undefined ? "" : `${row.worst.name} (${row.worst.complexity}, line ${row.worst.line})`])], { header: true, align: ["right", "right", "right", "right", "right", "right", "left", "left"] }));
1618
+ printHeader("hotspots");
1619
+ console.log(table([["rank", "score", "churn", "recent", "complexity", "lines", "file", "most complex declaration"], ...shown.map((row) => [colors.dim(String(row.rank)), heat(row.score, String(row.score)), ...[row.churn, row.recent, row.complexity, row.lines].map(String), fileLink(path(row.path), row.path, process14.stdout, cwd), row.worst === undefined ? "" : `${row.worst.name} (${row.worst.complexity}, line ${row.worst.line})`])], { header: true, align: ["right", "right", "right", "right", "right", "right", "left", "left"] }));
1547
1620
  if (footer !== undefined)
1548
1621
  console.log(footer);
1549
1622
  return 0;
@@ -1551,8 +1624,8 @@ async function hotspots(args) {
1551
1624
 
1552
1625
  // src/peek.ts
1553
1626
  import { realpathSync as realpathSync2 } from "fs";
1554
- import { isAbsolute as isAbsolute2, join as join8, relative as relative2, resolve as resolve3, sep } from "path";
1555
- import process14 from "process";
1627
+ import { isAbsolute as isAbsolute2, join as join8, relative as relative2, resolve as resolve4, sep } from "path";
1628
+ import process15 from "process";
1556
1629
 
1557
1630
  // src/source.ts
1558
1631
  var LOCATION = /^(?:\.\/)?([^\s:()]+)(?::(\d+)(?::\d+)?|\((\d+),\d+\))(?=[:\s)]|$)/;
@@ -1760,13 +1833,13 @@ function cut(text) {
1760
1833
  return text.length > LONGEST_LINE ? `${text.slice(0, LONGEST_LINE - 1)}\u2026` : text;
1761
1834
  }
1762
1835
  async function readableRoot() {
1763
- const ran = await runCommand(["git", "rev-parse", "--show-toplevel"], { cwd: process14.cwd() });
1764
- return realpathSync2(ran.code === 0 ? ran.text.trim() : process14.cwd());
1836
+ const ran = await runCommand(["git", "rev-parse", "--show-toplevel"], { cwd: process15.cwd() });
1837
+ return realpathSync2(ran.code === 0 ? ran.text.trim() : process15.cwd());
1765
1838
  }
1766
1839
  async function isOutside(path) {
1767
1840
  let real;
1768
1841
  try {
1769
- real = realpathSync2(resolve3(process14.cwd(), path));
1842
+ real = realpathSync2(resolve4(process15.cwd(), path));
1770
1843
  } catch {
1771
1844
  return false;
1772
1845
  }
@@ -1780,7 +1853,7 @@ async function checkInside(path) {
1780
1853
  async function pipedSpans(text, context) {
1781
1854
  const spans = [];
1782
1855
  for (const [path, numbers] of locations(text)) {
1783
- const source = await isOutside(path) ? undefined : await readText(resolve3(process14.cwd(), path));
1856
+ const source = await isOutside(path) ? undefined : await readText(resolve4(process15.cwd(), path));
1784
1857
  if (source !== undefined)
1785
1858
  spans.push(...spansAround(path, source.replace(TRAILING_NEWLINE2, "").split(`
1786
1859
  `).length, numbers, context));
@@ -1789,7 +1862,7 @@ async function pipedSpans(text, context) {
1789
1862
  }
1790
1863
  async function textOf(path) {
1791
1864
  await checkInside(path);
1792
- const text = await readText(resolve3(process14.cwd(), path));
1865
+ const text = await readText(resolve4(process15.cwd(), path));
1793
1866
  if (text === undefined)
1794
1867
  fail(`cannot read ${path} (missing, binary or too large)`, 1);
1795
1868
  return text;
@@ -1847,8 +1920,8 @@ async function spanOf(target) {
1847
1920
  async function* sources(paths) {
1848
1921
  for (const path of paths)
1849
1922
  await checkInside(path);
1850
- for (const path of await listFiles(paths, process14.cwd())) {
1851
- const text = await readText(join8(process14.cwd(), path));
1923
+ for (const path of await listFiles(paths, process15.cwd())) {
1924
+ const text = await readText(join8(process15.cwd(), path));
1852
1925
  if (text !== undefined)
1853
1926
  yield { path, text };
1854
1927
  }
@@ -1949,7 +2022,7 @@ async function peek(args) {
1949
2022
 
1950
2023
  // src/todo-scan.ts
1951
2024
  import { join as join9 } from "path";
1952
- import process15 from "process";
2025
+ import process16 from "process";
1953
2026
 
1954
2027
  // src/todo.ts
1955
2028
  var COMMENT2 = /(?<![:\w/])\/\/|\/\*|<!--|(?:^|\s)(?:#|--)(?=\s)|^\s*\*(?=\s|$)/;
@@ -2041,7 +2114,7 @@ function printLines(lines, footer) {
2041
2114
  }
2042
2115
  async function todoScan(args) {
2043
2116
  const { values, positionals } = parse(args, USAGE3, OPTIONS3, { positionals: ["[path...]"], replaces: "grep -rn TODO, then opening each issue it names", examples: ["todo-scan src", ["todo-scan --stale", "only the comments naming a closed issue"]] });
2044
- const cwd = process15.cwd();
2117
+ const cwd = process16.cwd();
2045
2118
  const limit = limitOf(values, LIST_LIMIT);
2046
2119
  const marks = [];
2047
2120
  for (const path of await listFiles(positionals, cwd)) {
@@ -2072,7 +2145,7 @@ async function todoScan(args) {
2072
2145
  }
2073
2146
 
2074
2147
  // src/cli.ts
2075
- process16.exitCode = await runCli({
2148
+ process17.exitCode = await runCli({
2076
2149
  name: "src",
2077
2150
  about: "reads and ranks the source of a folder: line spans, TODO comments and the files worth splitting",
2078
2151
  replaces: "sed -n N,Mp, grep -n chains and grep -rn TODO",