@kaynooo/cli-code 0.10.0 → 0.11.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,34 @@
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 process6 from "process";
15
33
 
16
34
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
17
35
  function x(s) {
@@ -278,13 +296,13 @@ var t = le();
278
296
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
279
297
  import { homedir as homedir2 } from "os";
280
298
  import { join as join3, resolve as resolve2 } from "path";
281
- import process4 from "process";
299
+ import process5 from "process";
282
300
 
283
301
  // ../kit/src/config.ts
284
302
  import { existsSync } from "fs";
285
303
  import { dirname, join, resolve } from "path";
286
- import process2 from "process";
287
- function findUp(names, from = process2.cwd(), stop = () => false) {
304
+ import process3 from "process";
305
+ function findUp(names, from = process3.cwd(), stop = () => false) {
288
306
  const wanted = typeof names === "string" ? [names] : names;
289
307
  for (let dir = resolve(from);; dir = dirname(dir)) {
290
308
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -298,9 +316,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
298
316
  // ../kit/src/user-config.ts
299
317
  import { homedir } from "os";
300
318
  import { join as join2 } from "path";
301
- import process3 from "process";
319
+ import process4 from "process";
302
320
  function configBase(where = {}) {
303
- const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
321
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
304
322
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
305
323
  }
306
324
  function userConfigPath(bin, where = {}) {
@@ -333,10 +351,30 @@ function isColorSpec(spec) {
333
351
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
334
352
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
335
353
  }
336
- function tinted(colors, spec) {
354
+ var CUBE = [0, 95, 135, 175, 215, 255];
355
+ function cubeLevel(channel) {
356
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
357
+ }
358
+ function nearest256(hex) {
359
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
360
+ const levels = rgb.map(cubeLevel);
361
+ const cube = levels.map((level) => CUBE[level]);
362
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
363
+ const greyValue = 8 + grey * 10;
364
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
365
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
366
+ }
367
+ function hasTrueColor(env) {
368
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
369
+ }
370
+ function tinted(colors, spec, env = process5.env) {
337
371
  if (typeof spec === "number")
338
372
  return colors.ansi256(spec);
339
- return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
373
+ return spec.trim().split(SPACES).reduce((chain, token) => {
374
+ if (HEX.test(token))
375
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
376
+ return chain[token] ?? chain;
377
+ }, colors);
340
378
  }
341
379
  function isRecord(value) {
342
380
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -420,7 +458,7 @@ function warnOnce(message) {
420
458
  function isPath(chosen) {
421
459
  return chosen.includes("/") || chosen.endsWith(".json");
422
460
  }
423
- function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
461
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
424
462
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
425
463
  const sources = [];
426
464
  const chosen = env.KIT_THEME ?? "";
@@ -450,7 +488,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
450
488
  var current;
451
489
  var currentKey = "";
452
490
  function activeTheme() {
453
- const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
491
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
454
492
  if (current === undefined || key !== currentKey) {
455
493
  current = loadTheme();
456
494
  currentKey = key;
@@ -460,32 +498,32 @@ function activeTheme() {
460
498
 
461
499
  // ../kit/src/style.ts
462
500
  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";
501
+ function takesControlCodes(stream, env = process6.env) {
502
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
465
503
  }
466
- function paint(stream, env = process5.env) {
504
+ function paint(stream, env = process6.env) {
467
505
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
468
506
  }
469
- function marked(mark, text, stream, detail, env = process5.env) {
507
+ function marked(mark, text, stream, detail, env = process6.env) {
470
508
  const colors = paint(stream, env);
471
509
  let head = MARK_WORDS[mark];
472
510
  if (takesControlCodes(stream, env)) {
473
511
  const { theme } = activeTheme();
474
- head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
512
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
475
513
  }
476
514
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
477
515
  }
478
516
  function warn(text, detail) {
479
- console.error(marked("warn", text, process5.stderr, detail));
517
+ console.error(marked("warn", text, process6.stderr, detail));
480
518
  }
481
- function role(name, stream, env = process5.env) {
519
+ function role(name, stream, env = process6.env) {
482
520
  const colors = paint(stream, env);
483
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
521
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
484
522
  }
485
523
  var STATUS_WORDS = {
486
524
  passed: ["passed", "success", "succeeded", "ok"],
487
525
  failed: ["failed", "failure", "error", "errored"],
488
- running: ["running", "in_progress", "started"],
526
+ running: ["running", "in_progress", "started", "holding"],
489
527
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
490
528
  skipped: ["skipped", "cancelled", "canceled", "manual"]
491
529
  };
@@ -504,8 +542,11 @@ var ESCAPE = String.fromCharCode(27);
504
542
  function textWidth(text) {
505
543
  return Bun.stringWidth(text);
506
544
  }
507
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
545
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
508
546
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
547
+ if (outputMode(stream, env) === "agent")
548
+ return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
549
+ `);
509
550
  const widths = [];
510
551
  for (const row of cells) {
511
552
  for (const [index, cell] of row.entries())
@@ -540,32 +581,35 @@ function narrow(rows, widths, limit) {
540
581
  }
541
582
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
542
583
  }
584
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
585
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
586
+ }
543
587
  function printJson(value) {
544
- console.log(JSON.stringify(value, undefined, 2));
588
+ console.log(jsonText(value));
545
589
  }
546
590
 
547
591
  // ../kit/src/help.ts
548
- import process7 from "process";
592
+ import process8 from "process";
549
593
  var OPTIONAL = /\[[^\]]+\]/g;
550
594
  var USAGE_PREFIX = /^usage:\s*/i;
551
595
  var FULL_STOP = /\.$/;
552
- function usageLine(usage, colors = paint(process7.stdout)) {
596
+ function usageLine(usage, colors = paint(process8.stdout)) {
553
597
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
554
598
  }
555
- function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
599
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
556
600
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
557
601
  `);
558
602
  }
559
- function exitRows(exits, colors = paint(process7.stdout)) {
603
+ function exitRows(exits, colors = paint(process8.stdout)) {
560
604
  if (exits.length === 0)
561
605
  return [];
562
606
  const width = Math.max(...exits.map(([code]) => String(code).length));
563
607
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
564
608
  }
565
- function replacesRows(replaces, colors = paint(process7.stdout)) {
566
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
609
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
610
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
567
611
  }
568
- function wantsHelpJson(env = process7.env) {
612
+ function wantsHelpJson(env = process8.env) {
569
613
  return env.KIT_HELP === "json";
570
614
  }
571
615
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -584,12 +628,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
584
628
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
585
629
  };
586
630
  }
587
- function exampleRows(examples, colors = paint(process7.stdout)) {
588
- if (examples.length === 0)
631
+ function exampleRows(examples, colors = paint(process8.stdout)) {
632
+ if (examples.length === 0 || outputMode() === "agent")
589
633
  return [];
590
634
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
591
635
  }
592
- function optionRows(options, colors = paint(process7.stdout)) {
636
+ function optionRows(options, colors = paint(process8.stdout)) {
593
637
  const rows = Object.entries(options).map(([name, option]) => {
594
638
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
595
639
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -652,7 +696,6 @@ var DASHES = /^-+/;
652
696
  function jsonOption(holds) {
653
697
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
654
698
  }
655
-
656
699
  class Exit extends Error {
657
700
  code;
658
701
  hint;
@@ -696,7 +739,7 @@ var OUTPUT_OPTIONS = {
696
739
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
697
740
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
698
741
  };
699
- function applyOutput(color, plain, env = process8.env) {
742
+ function applyOutput(color, plain, env = process9.env) {
700
743
  const when = plain === true ? "never" : color ?? "auto";
701
744
  if (when === "auto")
702
745
  return;
@@ -867,7 +910,7 @@ function nearestOption(message, options, allowNegative) {
867
910
  }
868
911
  // ../kit/src/process.ts
869
912
  import { constants } from "os";
870
- import process9 from "process";
913
+ import process10 from "process";
871
914
  var KILL_GRACE_MS = 2000;
872
915
  function exitCodeOf(code, signal) {
873
916
  if (code !== null)
@@ -887,7 +930,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
887
930
  return;
888
931
  try {
889
932
  if (grouped)
890
- process9.kill(-proc.pid, killing);
933
+ process10.kill(-proc.pid, killing);
891
934
  else
892
935
  proc.kill(killing);
893
936
  } catch {}
@@ -963,13 +1006,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
963
1006
  // ../kit/src/cli.ts
964
1007
  import { readFileSync as readFileSync2, realpathSync } from "fs";
965
1008
  import { dirname as dirname3, join as join5 } from "path";
966
- import process11 from "process";
1009
+ import process12 from "process";
967
1010
 
968
1011
  // ../kit/src/usage.ts
969
1012
  import { appendFileSync, mkdirSync } from "fs";
970
1013
  import { homedir as homedir3 } from "os";
971
1014
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
972
- import process10 from "process";
1015
+ import process11 from "process";
973
1016
 
974
1017
  // ../kit/src/logs.ts
975
1018
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -983,14 +1026,14 @@ var usageError;
983
1026
  function noteUsageError(message) {
984
1027
  usageError = message;
985
1028
  }
986
- function stateHome(env = process10.env) {
1029
+ function stateHome(env = process11.env) {
987
1030
  const dir = env.XDG_STATE_HOME;
988
1031
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
989
1032
  }
990
- function usagePath(env = process10.env) {
1033
+ function usagePath(env = process11.env) {
991
1034
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
992
1035
  }
993
- function usageRecorded(env = process10.env) {
1036
+ function usageRecorded(env = process11.env) {
994
1037
  const off = env.KAYNOOO_CLI_NO_USAGE;
995
1038
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
996
1039
  }
@@ -1004,7 +1047,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1004
1047
  usageError = undefined;
1005
1048
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1006
1049
  }
1007
- function recordUsage(entry, env = process10.env) {
1050
+ function recordUsage(entry, env = process11.env) {
1008
1051
  if (!usageRecorded(env))
1009
1052
  return;
1010
1053
  try {
@@ -1095,8 +1138,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1095
1138
  `);
1096
1139
  }
1097
1140
  function printError(prefix, message, hint, cause) {
1098
- const colors = paint(process11.stderr);
1099
- const styled = takesControlCodes(process11.stderr);
1141
+ const colors = paint(process12.stderr);
1142
+ const styled = takesControlCodes(process12.stderr);
1100
1143
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1101
1144
  const under = (label, text, tint) => text === undefined ? "" : `
1102
1145
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1139,11 +1182,11 @@ async function dispatch(level, typed, { version, redact }) {
1139
1182
  }
1140
1183
  }
1141
1184
  if (name === undefined && level.path.length > 1) {
1142
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stderr));
1185
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
1143
1186
  return 2;
1144
1187
  }
1145
1188
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1146
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stdout));
1189
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
1147
1190
  return 0;
1148
1191
  }
1149
1192
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1270,7 +1313,7 @@ function packageVersion(entry = Bun.main) {
1270
1313
  return "0.0.0";
1271
1314
  }
1272
1315
  }
1273
- async function runCli(cli, argv = process11.argv.slice(2)) {
1316
+ async function runCli(cli, argv = process12.argv.slice(2)) {
1274
1317
  const version = cli.version ?? packageVersion();
1275
1318
  if (argv[0] === COMPLETE)
1276
1319
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1297,7 +1340,7 @@ function commandPath(scope, argv) {
1297
1340
  }
1298
1341
  return path.length === 0 ? undefined : path.join(" ");
1299
1342
  }
1300
- async function runMain({ name, version, run, redact, usage }, argv = process11.argv.slice(2)) {
1343
+ async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1301
1344
  if (argv[0] === COMPLETE)
1302
1345
  return printCandidates(leafCandidates(run, argv.slice(1)));
1303
1346
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1317,6 +1360,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process11.a
1317
1360
  }
1318
1361
  return code;
1319
1362
  }
1363
+ // ../kit/src/folders.ts
1364
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1320
1365
  // ../kit/src/limit.ts
1321
1366
  function limitOptions(fallback) {
1322
1367
  return {
@@ -1346,7 +1391,7 @@ var SESSION_FILES = new Glob("*.json");
1346
1391
  var ACCOUNT_DIRS = new Glob("*/sessions");
1347
1392
  // src/hotspots.ts
1348
1393
  import { join as join7 } from "path";
1349
- import process13 from "process";
1394
+ import process14 from "process";
1350
1395
 
1351
1396
  // src/churn.ts
1352
1397
  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 +1436,6 @@ import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "f
1391
1436
  import { join as join6, relative } from "path";
1392
1437
  var MAX_BYTES = 2000000;
1393
1438
  var SNIFF_BYTES = 8000;
1394
- var SKIPPED = new Set(["node_modules", "dist", "build", "vendor", "target", "coverage"]);
1395
1439
  function walk(dir, found) {
1396
1440
  let entries;
1397
1441
  try {
@@ -1400,7 +1444,7 @@ function walk(dir, found) {
1400
1444
  return found;
1401
1445
  }
1402
1446
  for (const entry of entries) {
1403
- if (entry.name.startsWith(".") || SKIPPED.has(entry.name))
1447
+ if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
1404
1448
  continue;
1405
1449
  if (entry.isDirectory())
1406
1450
  walk(join6(dir, entry.name), found);
@@ -1504,7 +1548,7 @@ async function hotspots(args) {
1504
1548
  if (positionals.length > 1)
1505
1549
  badUsage("give one folder");
1506
1550
  const count = limitOf(values, DEFAULT_COUNT);
1507
- const cwd = process13.cwd();
1551
+ const cwd = process14.cwd();
1508
1552
  const bulk = Number(values.bulk ?? DEFAULT_BULK);
1509
1553
  if (!Number.isInteger(bulk) || bulk < 1)
1510
1554
  badUsage(`--bulk takes a number of files, not ${values.bulk}`);
@@ -1535,8 +1579,8 @@ async function hotspots(args) {
1535
1579
  printJson(shown);
1536
1580
  return 0;
1537
1581
  }
1538
- const colors = paint(process13.stdout);
1539
- const path = role("path", process13.stdout);
1582
+ const colors = paint(process14.stdout);
1583
+ const path = role("path", process14.stdout);
1540
1584
  const top = shown.reduce((highest, row) => Math.max(highest, row.score), 0);
1541
1585
  const heat = (score, text) => {
1542
1586
  if (top > 0 && score >= top * HOT)
@@ -1552,7 +1596,7 @@ async function hotspots(args) {
1552
1596
  // src/peek.ts
1553
1597
  import { realpathSync as realpathSync2 } from "fs";
1554
1598
  import { isAbsolute as isAbsolute2, join as join8, relative as relative2, resolve as resolve3, sep } from "path";
1555
- import process14 from "process";
1599
+ import process15 from "process";
1556
1600
 
1557
1601
  // src/source.ts
1558
1602
  var LOCATION = /^(?:\.\/)?([^\s:()]+)(?::(\d+)(?::\d+)?|\((\d+),\d+\))(?=[:\s)]|$)/;
@@ -1760,13 +1804,13 @@ function cut(text) {
1760
1804
  return text.length > LONGEST_LINE ? `${text.slice(0, LONGEST_LINE - 1)}\u2026` : text;
1761
1805
  }
1762
1806
  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());
1807
+ const ran = await runCommand(["git", "rev-parse", "--show-toplevel"], { cwd: process15.cwd() });
1808
+ return realpathSync2(ran.code === 0 ? ran.text.trim() : process15.cwd());
1765
1809
  }
1766
1810
  async function isOutside(path) {
1767
1811
  let real;
1768
1812
  try {
1769
- real = realpathSync2(resolve3(process14.cwd(), path));
1813
+ real = realpathSync2(resolve3(process15.cwd(), path));
1770
1814
  } catch {
1771
1815
  return false;
1772
1816
  }
@@ -1780,7 +1824,7 @@ async function checkInside(path) {
1780
1824
  async function pipedSpans(text, context) {
1781
1825
  const spans = [];
1782
1826
  for (const [path, numbers] of locations(text)) {
1783
- const source = await isOutside(path) ? undefined : await readText(resolve3(process14.cwd(), path));
1827
+ const source = await isOutside(path) ? undefined : await readText(resolve3(process15.cwd(), path));
1784
1828
  if (source !== undefined)
1785
1829
  spans.push(...spansAround(path, source.replace(TRAILING_NEWLINE2, "").split(`
1786
1830
  `).length, numbers, context));
@@ -1789,7 +1833,7 @@ async function pipedSpans(text, context) {
1789
1833
  }
1790
1834
  async function textOf(path) {
1791
1835
  await checkInside(path);
1792
- const text = await readText(resolve3(process14.cwd(), path));
1836
+ const text = await readText(resolve3(process15.cwd(), path));
1793
1837
  if (text === undefined)
1794
1838
  fail(`cannot read ${path} (missing, binary or too large)`, 1);
1795
1839
  return text;
@@ -1847,8 +1891,8 @@ async function spanOf(target) {
1847
1891
  async function* sources(paths) {
1848
1892
  for (const path of paths)
1849
1893
  await checkInside(path);
1850
- for (const path of await listFiles(paths, process14.cwd())) {
1851
- const text = await readText(join8(process14.cwd(), path));
1894
+ for (const path of await listFiles(paths, process15.cwd())) {
1895
+ const text = await readText(join8(process15.cwd(), path));
1852
1896
  if (text !== undefined)
1853
1897
  yield { path, text };
1854
1898
  }
@@ -1949,7 +1993,7 @@ async function peek(args) {
1949
1993
 
1950
1994
  // src/todo-scan.ts
1951
1995
  import { join as join9 } from "path";
1952
- import process15 from "process";
1996
+ import process16 from "process";
1953
1997
 
1954
1998
  // src/todo.ts
1955
1999
  var COMMENT2 = /(?<![:\w/])\/\/|\/\*|<!--|(?:^|\s)(?:#|--)(?=\s)|^\s*\*(?=\s|$)/;
@@ -2041,7 +2085,7 @@ function printLines(lines, footer) {
2041
2085
  }
2042
2086
  async function todoScan(args) {
2043
2087
  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();
2088
+ const cwd = process16.cwd();
2045
2089
  const limit = limitOf(values, LIST_LIMIT);
2046
2090
  const marks = [];
2047
2091
  for (const path of await listFiles(positionals, cwd)) {
@@ -2072,7 +2116,7 @@ async function todoScan(args) {
2072
2116
  }
2073
2117
 
2074
2118
  // src/cli.ts
2075
- process16.exitCode = await runCli({
2119
+ process17.exitCode = await runCli({
2076
2120
  name: "src",
2077
2121
  about: "reads and ranks the source of a folder: line spans, TODO comments and the files worth splitting",
2078
2122
  replaces: "sed -n N,Mp, grep -n chains and grep -rn TODO",