@kaynooo/cli-check 0.14.0 → 0.16.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/j-cli.js CHANGED
@@ -2,16 +2,37 @@
2
2
  // @bun
3
3
 
4
4
  // src/j-cli.ts
5
- import process21 from "process";
5
+ import process22 from "process";
6
6
  // ../kit/src/args.ts
7
- import process9 from "process";
7
+ import process10 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
+ }
30
+ function isInteractive(streams = process2) {
31
+ return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
32
+ }
12
33
 
13
34
  // ../kit/src/style.ts
14
- import process5 from "process";
35
+ import process6 from "process";
15
36
 
16
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
17
38
  function x(s) {
@@ -278,13 +299,13 @@ var t = le();
278
299
  import { existsSync as existsSync2, readFileSync, statSync } from "fs";
279
300
  import { homedir as homedir2 } from "os";
280
301
  import { join as join3, resolve as resolve2 } from "path";
281
- import process4 from "process";
302
+ import process5 from "process";
282
303
 
283
304
  // ../kit/src/config.ts
284
305
  import { existsSync } from "fs";
285
306
  import { dirname, join, resolve } from "path";
286
- import process2 from "process";
287
- function findUp(names, from = process2.cwd(), stop = () => false) {
307
+ import process3 from "process";
308
+ function findUp(names, from = process3.cwd(), stop = () => false) {
288
309
  const wanted = typeof names === "string" ? [names] : names;
289
310
  for (let dir = resolve(from);; dir = dirname(dir)) {
290
311
  const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
@@ -298,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
298
319
  // ../kit/src/user-config.ts
299
320
  import { homedir } from "os";
300
321
  import { join as join2 } from "path";
301
- import process3 from "process";
322
+ import process4 from "process";
302
323
  function configBase(where = {}) {
303
- 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);
304
325
  return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
305
326
  }
306
327
  function userConfigPath(bin, where = {}) {
@@ -333,10 +354,30 @@ function isColorSpec(spec) {
333
354
  return Number.isInteger(spec) && spec >= 0 && spec <= 255;
334
355
  return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
335
356
  }
336
- 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) {
337
374
  if (typeof spec === "number")
338
375
  return colors.ansi256(spec);
339
- 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);
340
381
  }
341
382
  function isRecord(value) {
342
383
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -420,7 +461,7 @@ function warnOnce(message) {
420
461
  function isPath(chosen) {
421
462
  return chosen.includes("/") || chosen.endsWith(".json");
422
463
  }
423
- 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 } = {}) {
424
465
  const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
425
466
  const sources = [];
426
467
  const chosen = env.KIT_THEME ?? "";
@@ -450,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
450
491
  var current;
451
492
  var currentKey = "";
452
493
  function activeTheme() {
453
- 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 ?? ""}`;
454
495
  if (current === undefined || key !== currentKey) {
455
496
  current = loadTheme();
456
497
  currentKey = key;
@@ -460,44 +501,44 @@ function activeTheme() {
460
501
 
461
502
  // ../kit/src/style.ts
462
503
  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";
504
+ function takesControlCodes(stream, env = process6.env) {
505
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
465
506
  }
466
- function paint(stream, env = process5.env) {
507
+ function paint(stream, env = process6.env) {
467
508
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
468
509
  }
469
- function marked(mark, text, stream, detail, env = process5.env) {
510
+ function marked(mark, text, stream, detail, env = process6.env) {
470
511
  const colors = paint(stream, env);
471
512
  let head = MARK_WORDS[mark];
472
513
  if (takesControlCodes(stream, env)) {
473
514
  const { theme } = activeTheme();
474
- head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
515
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
475
516
  }
476
517
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
477
518
  }
478
519
  function warn(text, detail) {
479
- console.error(marked("warn", text, process5.stderr, detail));
520
+ console.error(marked("warn", text, process6.stderr, detail));
480
521
  }
481
- function role(name, stream, env = process5.env) {
522
+ function role(name, stream, env = process6.env) {
482
523
  const colors = paint(stream, env);
483
- return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
524
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
484
525
  }
485
526
  var STATUS_WORDS = {
486
527
  passed: ["passed", "success", "succeeded", "ok"],
487
528
  failed: ["failed", "failure", "error", "errored"],
488
- running: ["running", "in_progress", "started"],
529
+ running: ["running", "in_progress", "started", "holding"],
489
530
  queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
490
531
  skipped: ["skipped", "cancelled", "canceled", "manual"]
491
532
  };
492
533
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
493
- function header(bin, context, stream, env = process5.env) {
534
+ function header(bin, context, stream, env = process6.env) {
494
535
  if (!takesControlCodes(stream, env))
495
536
  return "";
496
537
  const colors = paint(stream, env);
497
538
  const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
498
539
  const { theme } = activeTheme();
499
540
  const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
500
- const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec);
541
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
501
542
  return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
502
543
  }
503
544
 
@@ -531,8 +572,11 @@ var ESCAPE = String.fromCharCode(27);
531
572
  function textWidth(text) {
532
573
  return Bun.stringWidth(text);
533
574
  }
534
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
575
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
535
576
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
577
+ if (outputMode(stream, env) === "agent")
578
+ return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
579
+ `);
536
580
  const widths = [];
537
581
  for (const row of cells) {
538
582
  for (const [index, cell] of row.entries())
@@ -567,32 +611,35 @@ function narrow(rows, widths, limit) {
567
611
  }
568
612
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
569
613
  }
614
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
615
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
616
+ }
570
617
  function printJson(value) {
571
- console.log(JSON.stringify(value, undefined, 2));
618
+ console.log(jsonText(value));
572
619
  }
573
620
 
574
621
  // ../kit/src/help.ts
575
- import process7 from "process";
622
+ import process8 from "process";
576
623
  var OPTIONAL = /\[[^\]]+\]/g;
577
624
  var USAGE_PREFIX = /^usage:\s*/i;
578
625
  var FULL_STOP = /\.$/;
579
- function usageLine(usage, colors = paint(process7.stdout)) {
626
+ function usageLine(usage, colors = paint(process8.stdout)) {
580
627
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
581
628
  }
582
- function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
629
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
583
630
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
584
631
  `);
585
632
  }
586
- function exitRows(exits, colors = paint(process7.stdout)) {
633
+ function exitRows(exits, colors = paint(process8.stdout)) {
587
634
  if (exits.length === 0)
588
635
  return [];
589
636
  const width = Math.max(...exits.map(([code]) => String(code).length));
590
637
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
591
638
  }
592
- function replacesRows(replaces, colors = paint(process7.stdout)) {
593
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
639
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
640
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
594
641
  }
595
- function wantsHelpJson(env = process7.env) {
642
+ function wantsHelpJson(env = process8.env) {
596
643
  return env.KIT_HELP === "json";
597
644
  }
598
645
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -611,12 +658,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
611
658
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
612
659
  };
613
660
  }
614
- function exampleRows(examples, colors = paint(process7.stdout)) {
615
- if (examples.length === 0)
661
+ function exampleRows(examples, colors = paint(process8.stdout)) {
662
+ if (examples.length === 0 || outputMode() === "agent")
616
663
  return [];
617
664
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
618
665
  }
619
- function optionRows(options, colors = paint(process7.stdout)) {
666
+ function optionRows(options, colors = paint(process8.stdout)) {
620
667
  const rows = Object.entries(options).map(([name, option]) => {
621
668
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
622
669
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -651,7 +698,7 @@ function closest(name, names) {
651
698
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
652
699
  }
653
700
  // ../kit/src/input.ts
654
- import process8 from "process";
701
+ import process9 from "process";
655
702
  var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
656
703
  var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
657
704
  function duration(value, name, fallback, unit = "s") {
@@ -665,7 +712,7 @@ function duration(value, name, fallback, unit = "s") {
665
712
  }
666
713
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
667
714
  if (path === "-") {
668
- if (process8.stdin.isTTY)
715
+ if (process9.stdin.isTTY)
669
716
  fail(noStdin);
670
717
  return Bun.stdin.text();
671
718
  }
@@ -680,7 +727,6 @@ var DASHES = /^-+/;
680
727
  function jsonOption(holds) {
681
728
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
682
729
  }
683
-
684
730
  class Exit extends Error {
685
731
  code;
686
732
  hint;
@@ -724,7 +770,7 @@ var OUTPUT_OPTIONS = {
724
770
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
725
771
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
726
772
  };
727
- function applyOutput(color, plain, env = process9.env) {
773
+ function applyOutput(color, plain, env = process10.env) {
728
774
  const when = plain === true ? "never" : color ?? "auto";
729
775
  if (when === "auto")
730
776
  return;
@@ -895,7 +941,7 @@ function nearestOption(message, options, allowNegative) {
895
941
  }
896
942
  // ../kit/src/process.ts
897
943
  import { constants } from "os";
898
- import process10 from "process";
944
+ import process11 from "process";
899
945
  var KILL_GRACE_MS = 2000;
900
946
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
901
947
  function exitCodeOf(code, signal) {
@@ -917,7 +963,7 @@ function holdSignals(cleanup) {
917
963
  },
918
964
  release: () => {
919
965
  for (const signal of SIGNALS)
920
- process10.off(signal, onSignal);
966
+ process11.off(signal, onSignal);
921
967
  }
922
968
  };
923
969
  function onSignal(signal) {
@@ -930,10 +976,10 @@ function holdSignals(cleanup) {
930
976
  return;
931
977
  held.release();
932
978
  cleanup(signal);
933
- process10.kill(process10.pid, signal);
979
+ process11.kill(process11.pid, signal);
934
980
  }
935
981
  for (const signal of SIGNALS)
936
- process10.on(signal, onSignal);
982
+ process11.on(signal, onSignal);
937
983
  return held;
938
984
  }
939
985
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -947,7 +993,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
947
993
  return;
948
994
  try {
949
995
  if (grouped)
950
- process10.kill(-proc.pid, killing);
996
+ process11.kill(-proc.pid, killing);
951
997
  else
952
998
  proc.kill(killing);
953
999
  } catch {}
@@ -1023,31 +1069,31 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
1023
1069
  // ../kit/src/cli.ts
1024
1070
  import { readFileSync as readFileSync2, realpathSync } from "fs";
1025
1071
  import { dirname as dirname3, join as join6 } from "path";
1026
- import process13 from "process";
1072
+ import process14 from "process";
1027
1073
 
1028
1074
  // ../kit/src/usage.ts
1029
1075
  import { appendFileSync, mkdirSync } from "fs";
1030
1076
  import { homedir as homedir4 } from "os";
1031
1077
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1032
- import process12 from "process";
1078
+ import process13 from "process";
1033
1079
 
1034
1080
  // ../kit/src/logs.ts
1035
1081
  import { lstatSync, openSync } from "fs";
1036
1082
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
1037
1083
  import { homedir as homedir3, tmpdir } from "os";
1038
1084
  import { join as join4 } from "path";
1039
- import process11 from "process";
1085
+ import process12 from "process";
1040
1086
  var DAY_MS = 24 * 60 * 60 * 1000;
1041
1087
  var CLI_FOLDER = "kaynooo-cli";
1042
1088
  function isPrivateDirectory(path) {
1043
1089
  try {
1044
1090
  const info = lstatSync(path, { throwIfNoEntry: false });
1045
- return info !== undefined && info.isDirectory() && info.uid === (process11.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1091
+ return info !== undefined && info.isDirectory() && info.uid === (process12.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1046
1092
  } catch {
1047
1093
  return false;
1048
1094
  }
1049
1095
  }
1050
- async function privateLogDirectory(name, env = process11.env) {
1096
+ async function privateLogDirectory(name, env = process12.env) {
1051
1097
  const runtime = env.XDG_RUNTIME_DIR;
1052
1098
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1053
1099
  const path = join4(base, name);
@@ -1087,14 +1133,14 @@ var usageError;
1087
1133
  function noteUsageError(message) {
1088
1134
  usageError = message;
1089
1135
  }
1090
- function stateHome(env = process12.env) {
1136
+ function stateHome(env = process13.env) {
1091
1137
  const dir = env.XDG_STATE_HOME;
1092
1138
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1093
1139
  }
1094
- function usagePath(env = process12.env) {
1140
+ function usagePath(env = process13.env) {
1095
1141
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1096
1142
  }
1097
- function usageRecorded(env = process12.env) {
1143
+ function usageRecorded(env = process13.env) {
1098
1144
  const off = env.KAYNOOO_CLI_NO_USAGE;
1099
1145
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1100
1146
  }
@@ -1108,7 +1154,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1108
1154
  usageError = undefined;
1109
1155
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1110
1156
  }
1111
- function recordUsage(entry, env = process12.env) {
1157
+ function recordUsage(entry, env = process13.env) {
1112
1158
  if (!usageRecorded(env))
1113
1159
  return;
1114
1160
  try {
@@ -1126,8 +1172,8 @@ var LEVEL_OPTIONS = {
1126
1172
  };
1127
1173
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1128
1174
  function printError(prefix, message, hint, cause) {
1129
- const colors = paint(process13.stderr);
1130
- const styled = takesControlCodes(process13.stderr);
1175
+ const colors = paint(process14.stderr);
1176
+ const styled = takesControlCodes(process14.stderr);
1131
1177
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1132
1178
  const under = (label, text, tint) => text === undefined ? "" : `
1133
1179
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1220,7 +1266,7 @@ function packageVersion(entry = Bun.main) {
1220
1266
  return "0.0.0";
1221
1267
  }
1222
1268
  }
1223
- async function runMain({ name, version, run, redact, usage }, argv = process13.argv.slice(2)) {
1269
+ async function runMain({ name, version, run, redact, usage }, argv = process14.argv.slice(2)) {
1224
1270
  if (argv[0] === COMPLETE)
1225
1271
  return printCandidates(leafCandidates(run, argv.slice(1)));
1226
1272
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1240,6 +1286,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process13.a
1240
1286
  }
1241
1287
  return code;
1242
1288
  }
1289
+ // ../kit/src/folders.ts
1290
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1243
1291
  // ../kit/src/secrets.ts
1244
1292
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1245
1293
  // ../kit/src/sessions.ts
@@ -1247,16 +1295,16 @@ var {Glob } = globalThis.Bun;
1247
1295
  var SESSION_FILES = new Glob("*.json");
1248
1296
  var ACCOUNT_DIRS = new Glob("*/sessions");
1249
1297
  // package.json
1250
- var version = "0.14.0";
1298
+ var version = "0.16.0";
1251
1299
 
1252
1300
  // src/j.ts
1253
- import process20 from "process";
1301
+ import process21 from "process";
1254
1302
 
1255
1303
  // ../kit/src/picker.ts
1256
1304
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1257
1305
  import { homedir as homedir5 } from "os";
1258
1306
  import { dirname as dirname4, join as join7 } from "path";
1259
- import process17 from "process";
1307
+ import process18 from "process";
1260
1308
 
1261
1309
  // ../kit/src/picker/score.ts
1262
1310
  var MATCH = 16;
@@ -1359,6 +1407,14 @@ var KEYS = {
1359
1407
  "\x1B[B": "down",
1360
1408
  "\x1BOB": "down",
1361
1409
  "\x0E": "down",
1410
+ "\x1B[5~": "pageup",
1411
+ "\x1B[6~": "pagedown",
1412
+ "\x1B[H": "home",
1413
+ "\x1B[1~": "home",
1414
+ "\x1BOH": "home",
1415
+ "\x1B[F": "end",
1416
+ "\x1B[4~": "end",
1417
+ "\x1BOF": "end",
1362
1418
  "\r": "enter",
1363
1419
  "\n": "enter",
1364
1420
  "\x03": "cancel",
@@ -1367,7 +1423,10 @@ var KEYS = {
1367
1423
  "\b": "erase",
1368
1424
  "\x15": "clear",
1369
1425
  "\x17": "word",
1370
- "\t": "tab"
1426
+ "\t": "tab",
1427
+ "\x1F": "help",
1428
+ "\x1BOP": "help",
1429
+ "\x1B[11~": "help"
1371
1430
  };
1372
1431
  var CTRL_KEY = /^ctrl-[abd-gkln-z]$/;
1373
1432
  function repeat(value, count) {
@@ -1437,7 +1496,7 @@ function parseKeys(input, paste = { active: false }, ctrls = []) {
1437
1496
  });
1438
1497
  }
1439
1498
  function createState(rows, { multi = false, prompt = "> ", query = "", header = "", expect = [], searched = Number.POSITIVE_INFINITY } = {}) {
1440
- const state = { rows: [], items: [], styles: [], searchable: [], searched, header, expect, key: "", status: "", query, matches: [], cursor: 0, marked: new Set, multi, prompt, done: undefined };
1499
+ const state = { rows: [], items: [], styles: [], searchable: [], searched, header, expect, key: "", status: "", query, matches: [], cursor: 0, help: false, page: 10, marked: new Set, multi, prompt, done: undefined };
1441
1500
  return withRows(state, rows);
1442
1501
  }
1443
1502
  function withRows(state, rows, header = state.header) {
@@ -1459,6 +1518,8 @@ function highlighted(state) {
1459
1518
  function press(state, key) {
1460
1519
  if (state.done !== undefined)
1461
1520
  return state;
1521
+ if (state.help)
1522
+ return { ...state, help: false };
1462
1523
  if (typeof key === "object") {
1463
1524
  if ("text" in key)
1464
1525
  return withQuery(state, state.query + key.text);
@@ -1469,8 +1530,18 @@ function press(state, key) {
1469
1530
  return move(state, -1);
1470
1531
  case "down":
1471
1532
  return move(state, 1);
1533
+ case "pageup":
1534
+ return move(state, -state.page);
1535
+ case "pagedown":
1536
+ return move(state, state.page);
1537
+ case "home":
1538
+ return move(state, -state.matches.length);
1539
+ case "end":
1540
+ return move(state, state.matches.length);
1472
1541
  case "cancel":
1473
1542
  return { ...state, done: "cancel" };
1543
+ case "help":
1544
+ return { ...state, help: true };
1474
1545
  case "erase":
1475
1546
  return withQuery(state, [...state.query].slice(0, -1).join(""));
1476
1547
  case "clear":
@@ -1499,11 +1570,11 @@ function chosen(state) {
1499
1570
 
1500
1571
  // ../kit/src/picker/terminal.ts
1501
1572
  import { openSync as openSync2 } from "fs";
1502
- import process16 from "process";
1573
+ import process17 from "process";
1503
1574
  import tty from "tty";
1504
1575
 
1505
1576
  // ../kit/src/picker/preview.ts
1506
- import process15 from "process";
1577
+ import process16 from "process";
1507
1578
 
1508
1579
  // ../kit/src/shell.ts
1509
1580
  var SEPARATORS = new Set([`
@@ -1572,7 +1643,7 @@ async function runPreview(template, line, signal, hidden = []) {
1572
1643
  ${previewCommand(template, line, hidden)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
1573
1644
  const stop = () => {
1574
1645
  try {
1575
- process15.kill(-proc.pid, "SIGKILL");
1646
+ process16.kill(-proc.pid, "SIGKILL");
1576
1647
  } catch {
1577
1648
  proc.kill();
1578
1649
  }
@@ -1650,7 +1721,18 @@ function fitStyled(line, width, plain = identity) {
1650
1721
  function caretColumn(state, layout) {
1651
1722
  return Math.min(layout.listWidth, Bun.stringWidth(state.prompt) + Bun.stringWidth(state.query) + 1);
1652
1723
  }
1724
+ function helpLines(state, layout, theme) {
1725
+ const lines = [
1726
+ "type to filter, up, down, ctrl-p, ctrl-n, pgup, pgdn, home, end move",
1727
+ `enter picks${state.multi ? ", tab marks" : ""}, ctrl-u clears the query, ctrl-w a word, esc or ctrl-c cancels`,
1728
+ ...state.expect.length > 0 ? [`${state.expect.join(", ")} end the pick as this command asks`] : []
1729
+ ];
1730
+ const title = "keys, any key closes this help";
1731
+ return [{ text: theme.accent(title), width: title.length }, ...lines.map((line) => fit(` ${line}`, layout.listWidth, theme.label))];
1732
+ }
1653
1733
  function listLines(state, layout, theme) {
1734
+ if (state.help)
1735
+ return helpLines(state, layout, theme);
1654
1736
  const header = state.header === "" ? [] : state.header.split(`
1655
1737
  `).map((line) => fitStyled(line, layout.listWidth, theme.label));
1656
1738
  const rows = Math.max(1, layout.listHeight - 2 - header.length);
@@ -1659,7 +1741,8 @@ function listLines(state, layout, theme) {
1659
1741
  const marks = (state.marked.size > 0 ? ` (${state.marked.size} marked)` : "") + (state.status === "" ? "" : ` ${state.status}`);
1660
1742
  const promptWidth = Bun.stringWidth(state.prompt);
1661
1743
  const query = fit(state.query, Math.max(1, layout.listWidth - promptWidth), identity);
1662
- const count = fit(` ${state.matches.length}/${state.items.length}${marks}`, layout.listWidth, theme.label);
1744
+ const place = state.matches.length > rows ? ` (${state.cursor + 1} of ${state.matches.length})` : "";
1745
+ const count = fit(` ${state.matches.length}/${state.items.length}${place}${marks}`, layout.listWidth, theme.label);
1663
1746
  const lines = [{ text: theme.accent(state.prompt) + query.text, width: promptWidth + query.width }, count, ...header];
1664
1747
  if (state.matches.length === 0)
1665
1748
  lines.push(fit(" no match", layout.listWidth, theme.label));
@@ -1686,6 +1769,7 @@ function render(state, layout, theme, preview = []) {
1686
1769
 
1687
1770
  // ../kit/src/picker/terminal.ts
1688
1771
  var PREVIEW_DELAY_MS = 120;
1772
+ var ESCAPE_WAIT_MS = 30;
1689
1773
  var OPEN = { ctrl: "open" };
1690
1774
  var HIDE_CURSOR = "\x1B[?25l";
1691
1775
  var SHOW_CURSOR = "\x1B[?25h";
@@ -1703,7 +1787,7 @@ function openTerminal() {
1703
1787
  } catch {
1704
1788
  return fail("no terminal to read keys from (/dev/tty)");
1705
1789
  }
1706
- const out = process16.stderr;
1790
+ const out = process17.stderr;
1707
1791
  let resize;
1708
1792
  return {
1709
1793
  get columns() {
@@ -1741,20 +1825,29 @@ async function select(rows, settings, terminal = openTerminal()) {
1741
1825
  let shownLine;
1742
1826
  let finish;
1743
1827
  let restored = false;
1828
+ let escape;
1829
+ let caret;
1744
1830
  function draw(clear = false) {
1745
1831
  if (restored)
1746
1832
  return;
1747
1833
  const layout = layoutFor({ columns: terminal.columns, rows: terminal.rows }, settings.height, settings.preview !== undefined, settings.previewPosition);
1748
1834
  let frame = HIDE_CURSOR;
1749
1835
  if (reserved !== layout.height || clear) {
1836
+ frame += clear && caret !== undefined ? up(Math.floor((caret - 1) / terminal.columns)) : "";
1750
1837
  frame += CLEAR_BELOW + `
1751
1838
  `.repeat(layout.height - 1) + up(layout.height - 1);
1752
1839
  reserved = layout.height;
1753
1840
  }
1841
+ caret = caretColumn(state, layout);
1754
1842
  frame += `\r${render(state, layout, theme, preview).map((line) => `\x1B[2K${line}`).join(`
1755
- `)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${SHOW_CURSOR}`;
1843
+ `)}${up(layout.height - 1)}\r\x1B[${caret}G${SHOW_CURSOR}`;
1756
1844
  terminal.write(frame);
1757
1845
  }
1846
+ function pageSize() {
1847
+ const headerLines = state.header === "" ? 0 : state.header.split(`
1848
+ `).length;
1849
+ return Math.max(1, layoutFor({ columns: terminal.columns, rows: terminal.rows }, settings.height, settings.preview !== undefined, settings.previewPosition).listHeight - 2 - headerLines);
1850
+ }
1758
1851
  function refreshPreview() {
1759
1852
  const at = highlighted(state);
1760
1853
  if (settings.preview === undefined || at === shownLine)
@@ -1784,6 +1877,7 @@ async function select(rows, settings, terminal = openTerminal()) {
1784
1877
  return;
1785
1878
  restored = true;
1786
1879
  clearTimeout(previewTimer);
1880
+ clearTimeout(escape);
1787
1881
  previewing.abort();
1788
1882
  terminal.write(`${CLEAR_BELOW}${PASTE_OFF}${SHOW_CURSOR}`);
1789
1883
  terminal.close();
@@ -1822,7 +1916,7 @@ async function select(rows, settings, terminal = openTerminal()) {
1822
1916
  if (key === OPEN || typeof key === "object" && "ctrl" in key && key.ctrl === reload?.key)
1823
1917
  await reloadRows();
1824
1918
  else
1825
- state = press(state, key);
1919
+ state = press({ ...state, page: pageSize() }, key);
1826
1920
  }
1827
1921
  } finally {
1828
1922
  draining = false;
@@ -1835,6 +1929,20 @@ async function select(rows, settings, terminal = openTerminal()) {
1835
1929
  draw();
1836
1930
  }
1837
1931
  function onChunk(chunk) {
1932
+ if (escape !== undefined) {
1933
+ clearTimeout(escape);
1934
+ escape = undefined;
1935
+ chunk = `\x1B${chunk}`;
1936
+ } else if (chunk === "\x1B") {
1937
+ escape = setTimeout(() => {
1938
+ escape = undefined;
1939
+ takeKeys("\x1B");
1940
+ }, ESCAPE_WAIT_MS);
1941
+ return;
1942
+ }
1943
+ takeKeys(chunk);
1944
+ }
1945
+ function takeKeys(chunk) {
1838
1946
  const keys = parseKeys(chunk, paste, [...settings.expect ?? [], ...reload?.key === undefined ? [] : [reload.key]]);
1839
1947
  if (busy && keys.includes("cancel")) {
1840
1948
  stop();
@@ -1846,9 +1954,9 @@ async function select(rows, settings, terminal = openTerminal()) {
1846
1954
  const ended = new Promise((resolve) => {
1847
1955
  finish = resolve;
1848
1956
  });
1849
- process16.once("exit", restore);
1957
+ process17.once("exit", restore);
1850
1958
  for (const signal of SIGNALS2)
1851
- process16.once(signal, stop);
1959
+ process17.once(signal, stop);
1852
1960
  try {
1853
1961
  terminal.write(PASTE_ON);
1854
1962
  terminal.listen(onChunk, () => draw(true));
@@ -1861,8 +1969,8 @@ async function select(rows, settings, terminal = openTerminal()) {
1861
1969
  await ended;
1862
1970
  } finally {
1863
1971
  for (const signal of SIGNALS2)
1864
- process16.off(signal, stop);
1865
- process16.off("exit", restore);
1972
+ process17.off(signal, stop);
1973
+ process17.off("exit", restore);
1866
1974
  restore();
1867
1975
  }
1868
1976
  return state.done === "accept" ? { rows: chosen(state), key: state.key, query: state.query } : undefined;
@@ -1893,7 +2001,7 @@ function heightFor(count) {
1893
2001
  return String(Math.max(15, Math.ceil((count + 4) / 0.6)));
1894
2002
  }
1895
2003
  function historyFile(name) {
1896
- return join7(process17.env.XDG_CACHE_HOME ?? join7(homedir5(), ".cache"), name, "history.json");
2004
+ return join7(process18.env.XDG_CACHE_HOME ?? join7(homedir5(), ".cache"), name, "history.json");
1897
2005
  }
1898
2006
  function history(name) {
1899
2007
  try {
@@ -1904,12 +2012,12 @@ function history(name) {
1904
2012
  }
1905
2013
  }
1906
2014
  function runs(name) {
1907
- return history(name)[process17.cwd()] ?? [];
2015
+ return history(name)[process18.cwd()] ?? [];
1908
2016
  }
1909
2017
  function record(name, run) {
1910
2018
  const all = history(name);
1911
2019
  const file = historyFile(name);
1912
- all[process17.cwd()] = [run, ...(all[process17.cwd()] ?? []).filter((earlier) => earlier.id !== run.id)].slice(0, REMEMBERED);
2020
+ all[process18.cwd()] = [run, ...(all[process18.cwd()] ?? []).filter((earlier) => earlier.id !== run.id)].slice(0, REMEMBERED);
1913
2021
  mkdirSync2(dirname4(file), { recursive: true });
1914
2022
  writeFileSync(file, JSON.stringify(all));
1915
2023
  }
@@ -1933,12 +2041,10 @@ function list(rows) {
1933
2041
  }
1934
2042
 
1935
2043
  // ../kit/src/prompt.ts
1936
- import process18 from "process";
1937
- var KEY_SEQUENCES2 = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|[\s\S]/giu;
1938
- var CONTROL3 = /^[\x00-\x1F\x7F]/;
1939
- var KEYS2 = { "\x1B[A": "up", "\x1BOA": "up", "\x1B[B": "down", "\x1BOB": "down", "\r": "enter", "\n": "enter", "\x03": "cancel", "\x1B": "cancel", "\x7F": "erase", "\b": "erase" };
1940
- function readKeys(input) {
1941
- return (input.match(KEY_SEQUENCES2) ?? []).flatMap((sequence) => KEYS2[sequence] ?? (CONTROL3.test(sequence) ? [] : [{ text: sequence }]));
2044
+ import process19 from "process";
2045
+ var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
2046
+ function readKeys(input, paste = { active: false }) {
2047
+ return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key));
1942
2048
  }
1943
2049
  async function input2(question, { default: fallback, mask = false, validate, ...settings } = {}) {
1944
2050
  let value = "";
@@ -1972,27 +2078,34 @@ async function input2(question, { default: fallback, mask = false, validate, ...
1972
2078
  function answer(colors, question, state, picked) {
1973
2079
  return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1974
2080
  }
1975
- async function ask(question, { hint, terminal = process18 }, render, press) {
2081
+ async function ask(question, { hint, terminal = process19 }, render, press) {
1976
2082
  const { stdin, stderr } = terminal;
1977
- if (stdin.isTTY !== true || stderr.isTTY !== true)
2083
+ if (!isInteractive(terminal))
1978
2084
  fail(`cannot ask "${question}" off a terminal`, 2, hint);
1979
2085
  const colors = paint(stderr);
1980
- let drawn = 0;
2086
+ let drawn = [];
2087
+ let current = "asking";
1981
2088
  let outcome;
2089
+ const columns = () => stderr.columns || 80;
1982
2090
  const draw = (state) => {
1983
- const frame = render(colors, state, { columns: stderr.columns || 80, rows: stderr.rows || 24 });
1984
- stderr.write(`${drawn > 1 ? `\x1B[${drawn - 1}A` : ""}\r\x1B[0J${frame.join(`
2091
+ const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
2092
+ const rows = drawn.reduce((sum, line) => sum + Math.max(1, Math.ceil(Bun.stringWidth(line) / columns())), 0);
2093
+ stderr.write(`${rows > 1 ? `\x1B[${rows - 1}A` : ""}\r\x1B[0J${frame.join(`
1985
2094
  `)}`);
1986
- drawn = frame.length;
2095
+ drawn = frame;
2096
+ current = state;
1987
2097
  };
2098
+ const redraw = () => draw(current);
2099
+ const paste = { active: false };
1988
2100
  try {
2101
+ stderr.on?.("resize", redraw);
1989
2102
  stdin.setRawMode(true);
1990
2103
  stdin.resume();
1991
- stderr.write("\x1B[?25l");
2104
+ stderr.write("\x1B[?25l\x1B[?2004h");
1992
2105
  draw("asking");
1993
2106
  return await new Promise((resolve) => {
1994
2107
  function onData(data) {
1995
- for (const key of readKeys(data.toString())) {
2108
+ for (const key of readKeys(data.toString(), paste)) {
1996
2109
  const pressed = press(key);
1997
2110
  if (pressed !== undefined) {
1998
2111
  settle(pressed);
@@ -2014,16 +2127,17 @@ async function ask(question, { hint, terminal = process18 }, render, press) {
2014
2127
  stdin.on("end", onEnd);
2015
2128
  });
2016
2129
  } finally {
2130
+ stderr.off?.("resize", redraw);
2017
2131
  draw(outcome ?? "cancel");
2018
2132
  stderr.write(`
2019
- \x1B[?25h`);
2133
+ \x1B[?25h\x1B[?2004l`);
2020
2134
  stdin.setRawMode(false);
2021
2135
  stdin.pause();
2022
2136
  }
2023
2137
  }
2024
2138
 
2025
2139
  // src/job-picker.ts
2026
- import process19 from "process";
2140
+ import process20 from "process";
2027
2141
 
2028
2142
  // src/jobs.ts
2029
2143
  import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync4 } from "fs";
@@ -2040,7 +2154,7 @@ var CS_FIXER_CONFIGS = [".php-cs-fixer.php", ".php-cs-fixer.dist.php"];
2040
2154
  var JUST_TIMEOUT_MS = 1e4;
2041
2155
  var PHPSTAN_CONFIGS = ["phpstan.neon", "phpstan.neon.dist", "phpstan.dist.neon"];
2042
2156
  var PHPUNIT_CONFIGS = ["phpunit.xml", "phpunit.xml.dist", "phpunit.dist.xml"];
2043
- var SKIPPED = new Set(["node_modules", "vendor", "dist", "build", "var", "tmp", "coverage"]);
2157
+ var SKIPPED = new Set([...SKIPPED_FOLDERS, "var", "tmp"]);
2044
2158
  async function readFirst(dir, files) {
2045
2159
  for (const file of files) {
2046
2160
  const handle = Bun.file(join8(dir, file));
@@ -2163,7 +2277,6 @@ var LOCKFILES = [
2163
2277
  ["yarn.lock", "yarn"],
2164
2278
  ["package-lock.json", "npm"]
2165
2279
  ];
2166
- var SKIPPED2 = new Set(["node_modules", "vendor", "dist", "build", "target", "venv", "__pycache__"]);
2167
2280
  var QUALIFIED = /^([a-z]+):(?!:)(.+)$/;
2168
2281
  var BLANKS = /\s+/;
2169
2282
  var TRAILING_SLASHES = /\/+$/;
@@ -2193,7 +2306,7 @@ function locate(dir, here, names) {
2193
2306
  }
2194
2307
  }
2195
2308
  function children(dir = ".") {
2196
- return readdirSync(dir, { withFileTypes: true }).filter((child) => child.isDirectory() && !child.name.startsWith(".") && !SKIPPED2.has(child.name)).map((child) => child.name).toSorted();
2309
+ return readdirSync(dir, { withFileTypes: true }).filter((child) => child.isDirectory() && !child.name.startsWith(".") && !SKIPPED_FOLDERS.has(child.name)).map((child) => child.name).toSorted();
2197
2310
  }
2198
2311
  function build(base, items) {
2199
2312
  return items.map((item) => ({ ...base, doc: null, parameters: [], ...item }));
@@ -2387,7 +2500,7 @@ function workspaces() {
2387
2500
  const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => new Bun.Glob(pattern.slice(1)));
2388
2501
  return patterns.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [...new Bun.Glob(`${pattern.replace(TRAILING_SLASHES, "")}/package.json`).scanSync({ cwd: "." })].map((file) => dirname5(file))).filter((dir) => !dir.split("/").includes("node_modules") && !excluded.some((glob) => glob.match(dir)));
2389
2502
  }
2390
- function folders() {
2503
+ function folders2() {
2391
2504
  return [...new Set([...children(), ...workspaces()])].filter((dir) => dir !== ".");
2392
2505
  }
2393
2506
  function guarded(reader, dir, here, isWarned = false) {
@@ -2401,7 +2514,7 @@ function guarded(reader, dir, here, isWarned = false) {
2401
2514
  }
2402
2515
  function everything() {
2403
2516
  const here = READERS.flatMap((reader) => guarded(reader, ".", true, true));
2404
- const below = folders().flatMap((dir) => READERS.flatMap((reader) => guarded(reader, dir, false, true)));
2517
+ const below = folders2().flatMap((dir) => READERS.flatMap((reader) => guarded(reader, dir, false, true)));
2405
2518
  const seen = new Set;
2406
2519
  return [...here, ...below].filter((entry) => {
2407
2520
  const id = `${entry.kind} ${entry.dir} ${entry.name}`;
@@ -2441,7 +2554,7 @@ function labelled(entries) {
2441
2554
  return new Set(entries.map((entry) => entry.tag)).size > 1;
2442
2555
  }
2443
2556
  function row(entry, labels, signed) {
2444
- const colors = paint(process19.stderr);
2557
+ const colors = paint(process20.stderr);
2445
2558
  const keyed = entry.dir === "." ? entry.name : `${colors.dim(`${entry.dir}/`)}${entry.name}`;
2446
2559
  return {
2447
2560
  hidden: [entry.kind, entry.dir, entry.name, id(entry)],
@@ -2455,7 +2568,7 @@ async function pickJob(entries, narrowed = false) {
2455
2568
  prompt: `${[...new Set(entries.map((entry) => entry.tag))].join("/")}> `,
2456
2569
  searched: labels ? 2 : 1,
2457
2570
  ...narrowed ? { height: heightFor(entries.length) } : {},
2458
- preview: `${process19.execPath} ${process19.argv[1]} --show {1} {2} {3}`
2571
+ preview: `${process20.execPath} ${process20.argv[1]} --show {1} {2} {3}`
2459
2572
  });
2460
2573
  return entries.find((candidate) => id(candidate) === picked?.hidden[3]);
2461
2574
  }
@@ -2477,7 +2590,7 @@ function preview(kind, dir, name) {
2477
2590
  const entry = readKind(kind, dir).find((candidate) => candidate.name === name);
2478
2591
  if (entry === undefined)
2479
2592
  return;
2480
- const colors = paint(process20.stdout);
2593
+ const colors = paint(process21.stdout);
2481
2594
  console.log(`${colors.dim(`$ ${dir === "." ? "" : `env -C ${dir} `}`)}${colors.bold([...entry.runner, entry.name].join(" "))}
2482
2595
  `);
2483
2596
  if (entry.body !== undefined)
@@ -2503,7 +2616,7 @@ function listed2(found) {
2503
2616
  }));
2504
2617
  }
2505
2618
  function table3(found) {
2506
- const colors = paint(process20.stdout);
2619
+ const colors = paint(process21.stdout);
2507
2620
  const labels = labelled(found);
2508
2621
  const rows = found.map((entry) => [...labels ? [entry.tag] : [], key(entry), signature(entry)]);
2509
2622
  const widths = rows[0]?.map((_, column) => Math.max(...rows.map((cells) => cells[column].length))) ?? [];
@@ -2554,7 +2667,7 @@ async function j(argv) {
2554
2667
  if (found.length === 0)
2555
2668
  fail("nothing to run here: no recipe, target, script or task", 1);
2556
2669
  const previous = runs("j");
2557
- const interactive = process20.stdin.isTTY && process20.stderr.isTTY && parsed.values.json !== true;
2670
+ const interactive = isInteractive() && parsed.values.json !== true;
2558
2671
  let entry;
2559
2672
  let words = given;
2560
2673
  if (named === "-") {
@@ -2605,4 +2718,4 @@ async function j(argv) {
2605
2718
  }
2606
2719
 
2607
2720
  // src/j-cli.ts
2608
- process21.exitCode = await runMain({ name: "j", version, run: j });
2721
+ process22.exitCode = await runMain({ name: "j", version, run: j });