@kaynooo/cli-code 0.14.1 → 0.14.3

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.
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/hotspots-cli.ts
5
- import process15 from "process";
5
+ import process16 from "process";
6
6
  // ../kit/src/args.ts
7
7
  import process9 from "process";
8
8
  import { parseArgs } from "util";
@@ -126,7 +126,7 @@ function Fe(r = {}) {
126
126
  var o = Fe();
127
127
 
128
128
  // ../kit/src/theme.ts
129
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
129
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
130
130
  import { homedir as homedir2 } from "os";
131
131
  import { join as join3, resolve as resolve2 } from "path";
132
132
  import process5 from "process";
@@ -147,6 +147,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
147
147
  }
148
148
 
149
149
  // ../kit/src/user-config.ts
150
+ import { existsSync as existsSync2, readFileSync } from "fs";
150
151
  import { homedir } from "os";
151
152
  import { join as join2 } from "path";
152
153
  import process4 from "process";
@@ -157,6 +158,28 @@ function configBase(where = {}) {
157
158
  function userConfigPath(bin, where = {}) {
158
159
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
159
160
  }
161
+ function userConfigReadPath(bin, legacy = [], where = {}) {
162
+ const current = userConfigPath(bin, where);
163
+ if (existsSync2(current))
164
+ return current;
165
+ const base = configBase(where);
166
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
167
+ }
168
+ function readUserConfig(bin, where = {}, legacy = []) {
169
+ const path = userConfigReadPath(bin, legacy, where);
170
+ if (!existsSync2(path))
171
+ return {};
172
+ try {
173
+ const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
174
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
175
+ } catch {
176
+ return {};
177
+ }
178
+ }
179
+ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
180
+ const value = readUserConfig(bin, where, legacy)[key];
181
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
182
+ }
160
183
 
161
184
  // ../kit/src/theme.ts
162
185
  var ENDS = new Map;
@@ -223,7 +246,7 @@ function readThemeFile(path, warn) {
223
246
  warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
224
247
  return;
225
248
  }
226
- const parsed = JSON.parse(readFileSync(path, "utf8"));
249
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
227
250
  if (isRecord(parsed))
228
251
  return parsed;
229
252
  warn(`${path} is not a JSON object, theme ignored`);
@@ -289,7 +312,7 @@ function applyFile(theme, file, where, warn) {
289
312
  }
290
313
  }
291
314
  function endsWalk(home) {
292
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
315
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
293
316
  }
294
317
  var warned = new Set;
295
318
  function warnOnce(message) {
@@ -465,18 +488,14 @@ var FULL_STOP = /\.$/;
465
488
  function usageLine(usage, colors = paint(process8.stdout)) {
466
489
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
467
490
  }
468
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
469
- return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
491
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
492
+ return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
470
493
  `);
471
494
  }
472
495
  function exitRows(exits, colors = paint(process8.stdout)) {
473
496
  if (exits.length === 0)
474
497
  return [];
475
- const width = Math.max(...exits.map(([code]) => String(code).length));
476
- return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
477
- }
478
- function replacesRows(replaces, colors = paint(process8.stdout)) {
479
- return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
498
+ return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
480
499
  }
481
500
  function wantsHelpJson(env = process8.env) {
482
501
  return env.KIT_HELP === "json";
@@ -777,9 +796,33 @@ function nearestOption(message, options, allowNegative) {
777
796
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
778
797
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
779
798
  }
799
+ // ../kit/src/argv.ts
800
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
801
+ import { resolve as resolve4 } from "path";
802
+ import process10 from "process";
803
+ function commandLine() {
804
+ try {
805
+ return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
806
+ } catch {
807
+ return;
808
+ }
809
+ }
810
+ function realPath(word) {
811
+ try {
812
+ return realpathSync(resolve4(word));
813
+ } catch {
814
+ return;
815
+ }
816
+ }
817
+ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), script = process10.argv[1]) {
818
+ const target = script === undefined ? undefined : realPath(script) ?? script;
819
+ const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve4(word) === script || realPath(word) === target));
820
+ const after = at === -1 ? [] : cmdline.slice(at + 1);
821
+ return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
822
+ }
780
823
  // ../kit/src/process.ts
781
824
  import { constants } from "os";
782
- import process10 from "process";
825
+ import process11 from "process";
783
826
  var KILL_GRACE_MS = 2000;
784
827
  function exitCodeOf(code, signal) {
785
828
  if (code !== null)
@@ -799,7 +842,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
799
842
  return;
800
843
  try {
801
844
  if (grouped)
802
- process10.kill(-proc.pid, killing);
845
+ process11.kill(-proc.pid, killing);
803
846
  else
804
847
  proc.kill(killing);
805
848
  } catch {}
@@ -873,15 +916,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
873
916
  var RESET_STYLE = `${ESC}[0m`;
874
917
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
875
918
  // ../kit/src/cli.ts
876
- import { readFileSync as readFileSync2, realpathSync } from "fs";
919
+ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
877
920
  import { dirname as dirname3, join as join5 } from "path";
878
- import process12 from "process";
921
+ import process13 from "process";
879
922
 
880
923
  // ../kit/src/usage.ts
881
924
  import { appendFileSync, mkdirSync } from "fs";
882
925
  import { homedir as homedir3 } from "os";
883
926
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
884
- import process11 from "process";
927
+ import process12 from "process";
885
928
 
886
929
  // ../kit/src/logs.ts
887
930
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -895,14 +938,14 @@ var usageError;
895
938
  function noteUsageError(message) {
896
939
  usageError = message;
897
940
  }
898
- function stateHome(env = process11.env) {
941
+ function stateHome(env = process12.env) {
899
942
  const dir = env.XDG_STATE_HOME;
900
943
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
901
944
  }
902
- function usagePath(env = process11.env) {
945
+ function usagePath(env = process12.env) {
903
946
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
904
947
  }
905
- function usageRecorded(env = process11.env) {
948
+ function usageRecorded(env = process12.env) {
906
949
  const off = env.KAYNOOO_CLI_NO_USAGE;
907
950
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
908
951
  }
@@ -916,7 +959,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
916
959
  usageError = undefined;
917
960
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
918
961
  }
919
- function recordUsage(entry, env = process11.env) {
962
+ function recordUsage(entry, env = process12.env) {
920
963
  if (!usageRecorded(env))
921
964
  return;
922
965
  try {
@@ -993,7 +1036,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
993
1036
  header(colors, summary),
994
1037
  "",
995
1038
  usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
996
- ...replacesRows(replaces, colors),
997
1039
  "",
998
1040
  ...await commandRows(commands, colors),
999
1041
  ...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
@@ -1007,8 +1049,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1007
1049
  `);
1008
1050
  }
1009
1051
  function printError(prefix, message, hint, cause) {
1010
- const colors = paint(process12.stderr);
1011
- const styled = takesControlCodes(process12.stderr);
1052
+ const colors = paint(process13.stderr);
1053
+ const styled = takesControlCodes(process13.stderr);
1012
1054
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1013
1055
  const under = (label, text, tint) => text === undefined ? "" : `
1014
1056
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1051,11 +1093,11 @@ async function dispatch(level, typed, { version, redact }) {
1051
1093
  }
1052
1094
  }
1053
1095
  if (name === undefined && level.path.length > 1) {
1054
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
1096
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process13.stderr));
1055
1097
  return 2;
1056
1098
  }
1057
1099
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1058
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
1100
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process13.stdout));
1059
1101
  return 0;
1060
1102
  }
1061
1103
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1111,24 +1153,24 @@ function candidateLine(candidate) {
1111
1153
  }
1112
1154
  function positionalBeingTyped(before, { options, positionals }) {
1113
1155
  const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
1114
- let index = 0;
1156
+ const typed = [];
1115
1157
  let at = 0;
1116
1158
  while (at < before.length) {
1117
1159
  const word = before[at];
1118
1160
  if (word === "--") {
1119
- index += before.length - at - 1;
1161
+ typed.push(...before.slice(at + 1));
1120
1162
  break;
1121
1163
  }
1122
1164
  if (!word.startsWith("-"))
1123
- index++;
1165
+ typed.push(word);
1124
1166
  else if (takesValue(word))
1125
1167
  at++;
1126
1168
  at++;
1127
1169
  }
1128
1170
  const last = positionals.at(-1);
1129
- if (index < positionals.length)
1130
- return positionals[index];
1131
- return last?.replace("]", "").endsWith("...") === true ? last : undefined;
1171
+ if (typed.length < positionals.length)
1172
+ return { name: positionals[typed.length], typed };
1173
+ return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
1132
1174
  }
1133
1175
  async function leafCandidates(run, words) {
1134
1176
  const completing = await completingOf(run);
@@ -1136,12 +1178,12 @@ async function leafCandidates(run, words) {
1136
1178
  return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
1137
1179
  const flag = words.at(-2);
1138
1180
  const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
1181
+ const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
1139
1182
  if (option?.type === "string") {
1140
- const values = option.choices === undefined ? await option.candidates?.() : option.choices;
1183
+ const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
1141
1184
  return values === undefined ? [FILES] : values.map(candidateLine);
1142
1185
  }
1143
- const name = positionalBeingTyped(words.slice(0, -1), completing);
1144
- const values = name === undefined ? undefined : await completing.candidates[name]?.();
1186
+ const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1145
1187
  return values === undefined ? [FILES] : values.map(candidateLine);
1146
1188
  }
1147
1189
  async function candidates(scope, defaultCommand, words, before = []) {
@@ -1172,9 +1214,13 @@ async function printCandidates(found) {
1172
1214
  return 0;
1173
1215
  }
1174
1216
  function packageVersion(entry = Bun.main) {
1175
- for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1217
+ let resolved = entry;
1218
+ try {
1219
+ resolved = realpathSync2(entry);
1220
+ } catch {}
1221
+ for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
1176
1222
  try {
1177
- const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1223
+ const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
1178
1224
  if (typeof version === "string")
1179
1225
  return version;
1180
1226
  } catch {}
@@ -1182,7 +1228,7 @@ function packageVersion(entry = Bun.main) {
1182
1228
  return "0.0.0";
1183
1229
  }
1184
1230
  }
1185
- async function runCli(cli, argv = process12.argv.slice(2)) {
1231
+ async function runCli(cli, argv = scriptArgs()) {
1186
1232
  const version = cli.version ?? packageVersion();
1187
1233
  if (argv[0] === COMPLETE)
1188
1234
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1209,7 +1255,7 @@ function commandPath(scope, argv) {
1209
1255
  }
1210
1256
  return path.length === 0 ? undefined : path.join(" ");
1211
1257
  }
1212
- async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1258
+ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1213
1259
  if (argv[0] === COMPLETE)
1214
1260
  return printCandidates(leafCandidates(run, argv.slice(1)));
1215
1261
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1231,6 +1277,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
1231
1277
  }
1232
1278
  // ../kit/src/folders.ts
1233
1279
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1280
+ function ignoredFolders(extra = [], where = {}) {
1281
+ const configured = readUserConfig("config", where).ignore;
1282
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1283
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1284
+ }
1234
1285
  // ../kit/src/limit.ts
1235
1286
  function limitOptions(fallback) {
1236
1287
  return {
@@ -1260,7 +1311,7 @@ var SESSION_FILES = new Glob("*.json");
1260
1311
  var ACCOUNT_DIRS = new Glob("*/sessions");
1261
1312
  // src/hotspots.ts
1262
1313
  import { basename, join as join7 } from "path";
1263
- import process14 from "process";
1314
+ import process15 from "process";
1264
1315
 
1265
1316
  // src/churn.ts
1266
1317
  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)$/;
@@ -1301,11 +1352,11 @@ async function churnSince(cwd, since, { bulk, halfLifeMs, now = Date.now() }) {
1301
1352
  }
1302
1353
 
1303
1354
  // src/files.ts
1304
- import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "fs";
1355
+ import { existsSync as existsSync4, readdirSync, statSync as statSync2 } from "fs";
1305
1356
  import { join as join6, relative } from "path";
1306
1357
  var MAX_BYTES = 2000000;
1307
1358
  var SNIFF_BYTES = 8000;
1308
- function walk(dir, found) {
1359
+ function walk(dir, found, ignored) {
1309
1360
  let entries;
1310
1361
  try {
1311
1362
  entries = readdirSync(dir, { withFileTypes: true });
@@ -1313,10 +1364,10 @@ function walk(dir, found) {
1313
1364
  return found;
1314
1365
  }
1315
1366
  for (const entry of entries) {
1316
- if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
1367
+ if (entry.name.startsWith(".") || ignored.has(entry.name))
1317
1368
  continue;
1318
1369
  if (entry.isDirectory())
1319
- walk(join6(dir, entry.name), found);
1370
+ walk(join6(dir, entry.name), found, ignored);
1320
1371
  else if (entry.isFile())
1321
1372
  found.push(join6(dir, entry.name));
1322
1373
  }
@@ -1325,9 +1376,10 @@ function walk(dir, found) {
1325
1376
  async function listFiles(paths, cwd) {
1326
1377
  const listed = await runCommand(["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", ...paths], { cwd });
1327
1378
  if (listed.code === 0)
1328
- return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync3(join6(cwd, path))).sort();
1379
+ return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync4(join6(cwd, path))).sort();
1329
1380
  const roots = paths.length === 0 ? [cwd] : paths.map((path) => join6(cwd, path));
1330
- return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [])).map((path) => relative(cwd, path)).sort();
1381
+ const ignored = ignoredFolders();
1382
+ return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [], ignored)).map((path) => relative(cwd, path)).sort();
1331
1383
  }
1332
1384
  async function readText(path) {
1333
1385
  const file = Bun.file(path);
@@ -1390,18 +1442,18 @@ ${blanked(template)}`) : text.replace(MARKUP_BLOCK, blanked);
1390
1442
  }
1391
1443
 
1392
1444
  // src/hotspots.ts
1393
- var DEFAULT_SINCE = "6 months ago";
1394
- var DEFAULT_BULK = 25;
1445
+ var SETTINGS = readUserConfig("hotspots");
1446
+ var DEFAULT_SINCE = typeof SETTINGS.since === "string" && SETTINGS.since !== "" ? SETTINGS.since : "6 months ago";
1447
+ var DEFAULT_BULK = configuredNumber("hotspots", "bulk", 25);
1395
1448
  var DAY_MS2 = 86400000;
1396
1449
  var DEFAULT_HALF_LIFE = "90d";
1397
- var DEFAULT_COUNT = 20;
1450
+ var DEFAULT_COUNT = configuredNumber("hotspots", "limit", 20);
1398
1451
  var USAGE = `hotspots [options] [dir]: ranks the source files under dir (here by default) by complexity times churn, the ones both hard to read and often edited first, honouring .gitignore
1399
1452
 
1400
1453
  Complexity is the count of decision points in the file (branches, loops, cases, catches, boolean operators, ternaries) plus one, churn the commits touching it since --since (${DEFAULT_SINCE}), score their product. A commit counts for less the older it is (half as much every --half-life, 0 for all alike) and a commit touching more than --bulk files, a format or rename sweep, is left out. Each file also shows its most complex declaration, found by indentation. Test files and generated or built files are left out unless --all.
1401
1454
 
1402
- Lists at most ${DEFAULT_COUNT} files, the count of the rest after them (--limit <n>, --full for all); --json is never cut unless --limit is given.
1403
-
1404
- Exits 0 when it ranked the files, 1 when no file has commits in the window, 2 on a usage error or outside a git repository.`;
1455
+ Lists at most ${DEFAULT_COUNT} files, the count of the rest after them (--limit <n>, --full for all); --json is never cut unless --limit is given.`;
1456
+ var EXITS = [[0, "it ranked the files"], [1, "no file has commits in the window"], [2, "a usage error or outside a git repository"]];
1405
1457
  var OPTIONS = {
1406
1458
  since: { type: "string", short: "s", description: `only count the commits since this date, as git reads it (${DEFAULT_SINCE})` },
1407
1459
  "half-life": { type: "string", description: `how long until a commit counts half as much (${DEFAULT_HALF_LIFE}), 0 for no decay` },
@@ -1413,11 +1465,11 @@ var OPTIONS = {
1413
1465
  var HOT = 0.66;
1414
1466
  var WARM = 0.33;
1415
1467
  async function hotspots(args) {
1416
- const { values, positionals } = parse(args, USAGE, OPTIONS, { positionals: ["[dir]"], replaces: "guessing which files are worth splitting first", examples: ["hotspots", 'hotspots src --since "3 months ago" --limit 10'] });
1468
+ const { values, positionals } = parse(args, USAGE, OPTIONS, { exits: EXITS, positionals: ["[dir]"], replaces: "guessing which files are worth splitting first", examples: ["hotspots", 'hotspots src --since "3 months ago" --limit 10'] });
1417
1469
  if (positionals.length > 1)
1418
1470
  badUsage("give one folder");
1419
1471
  const count = limitOf(values, DEFAULT_COUNT);
1420
- const cwd = process14.cwd();
1472
+ const cwd = process15.cwd();
1421
1473
  const bulk = Number(values.bulk ?? DEFAULT_BULK);
1422
1474
  if (!Number.isInteger(bulk) || bulk < 1)
1423
1475
  badUsage(`--bulk takes a number of files, not ${values.bulk}`);
@@ -1448,8 +1500,8 @@ async function hotspots(args) {
1448
1500
  printJson(shown);
1449
1501
  return 0;
1450
1502
  }
1451
- const colors = paint(process14.stdout);
1452
- const path = role("path", process14.stdout);
1503
+ const colors = paint(process15.stdout);
1504
+ const path = role("path", process15.stdout);
1453
1505
  const top = shown.reduce((highest, row) => Math.max(highest, row.score), 0);
1454
1506
  const heat = (score, text) => {
1455
1507
  if (top > 0 && score >= top * HOT)
@@ -1457,11 +1509,11 @@ async function hotspots(args) {
1457
1509
  return top > 0 && score >= top * WARM ? colors.yellow(text) : text;
1458
1510
  };
1459
1511
  printHeader("hotspots", `${basename(cwd)} \xB7 since ${values.since ?? DEFAULT_SINCE}`);
1460
- 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"] }));
1512
+ 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, process15.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"] }));
1461
1513
  if (footer !== undefined)
1462
1514
  console.log(footer);
1463
1515
  return 0;
1464
1516
  }
1465
1517
 
1466
1518
  // src/hotspots-cli.ts
1467
- process15.exitCode = await runMain({ name: "hotspots", run: hotspots });
1519
+ process16.exitCode = await runMain({ name: "hotspots", run: hotspots });