@kaynooo/cli-proc 0.5.0 → 0.6.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/proc-cli.js CHANGED
@@ -2,13 +2,13 @@
2
2
  // @bun
3
3
 
4
4
  // src/proc-cli.ts
5
- import process19 from "process";
5
+ import process16 from "process";
6
6
  // ../kit/src/args.ts
7
- import process9 from "process";
7
+ import process6 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process7 from "process";
11
+ import process4 from "process";
12
12
 
13
13
  // ../kit/src/mode.ts
14
14
  import process2 from "process";
@@ -32,7 +32,7 @@ function isInteractive(streams = process2) {
32
32
  }
33
33
 
34
34
  // ../kit/src/style.ts
35
- import process6 from "process";
35
+ import process3 from "process";
36
36
 
37
37
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
38
38
  function x(s) {
@@ -296,214 +296,15 @@ function le(i = {}) {
296
296
  var t = le();
297
297
 
298
298
  // ../kit/src/theme.ts
299
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
300
- import { homedir as homedir2 } from "os";
301
- import { join as join3, resolve as resolve2 } from "path";
302
- import process5 from "process";
303
-
304
- // ../kit/src/config.ts
305
- import { existsSync } from "fs";
306
- import { dirname, join, resolve } from "path";
307
- import process3 from "process";
308
- function findUp(names, from = process3.cwd(), stop = () => false) {
309
- const wanted = typeof names === "string" ? [names] : names;
310
- for (let dir = resolve(from);; dir = dirname(dir)) {
311
- const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
312
- if (found !== undefined)
313
- return found;
314
- if (stop(dir) || dirname(dir) === dir)
315
- return;
316
- }
317
- }
318
-
319
- // ../kit/src/user-config.ts
320
- import { homedir } from "os";
321
- import { join as join2 } from "path";
322
- import process4 from "process";
323
- function configBase(where = {}) {
324
- const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
325
- return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
326
- }
327
- function userConfigPath(bin, where = {}) {
328
- return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
329
- }
330
-
331
- // ../kit/src/theme.ts
332
- var DEFAULT = {
333
- colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
334
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
335
- accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
336
- bins: {}
337
- };
338
- var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
339
- var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
340
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
341
- var PRESETS = {
342
- default: {},
343
- "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
344
- mono: { colors: MONO, accents: ["bold"] },
345
- ascii: { glyphs: ASCII }
346
- };
347
299
  var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
348
- var HEX = /^#[0-9a-f]{6}$/i;
349
- var CONTROL = /\p{Cc}/u;
350
300
  var MAX_FILE_BYTES = 64 * 1024;
351
- var SPACES = /\s+/;
352
- function isColorSpec(spec) {
353
- if (typeof spec === "number")
354
- return Number.isInteger(spec) && spec >= 0 && spec <= 255;
355
- return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
356
- }
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) {
374
- if (typeof spec === "number")
375
- return colors.ansi256(spec);
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);
381
- }
382
- function isRecord(value) {
383
- return typeof value === "object" && value !== null && !Array.isArray(value);
384
- }
385
- function readThemeFile(path, warn) {
386
- try {
387
- const stat = statSync(path, { throwIfNoEntry: false });
388
- if (stat === undefined)
389
- return;
390
- if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
391
- warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
392
- return;
393
- }
394
- const parsed = JSON.parse(readFileSync(path, "utf8"));
395
- if (isRecord(parsed))
396
- return parsed;
397
- warn(`${path} is not a JSON object, theme ignored`);
398
- } catch (error) {
399
- warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
400
- }
401
- return;
402
- }
403
- function applyPreset(theme, name, warn, where) {
404
- if (name === undefined)
405
- return;
406
- if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
407
- warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
408
- return;
409
- }
410
- const preset = PRESETS[name];
411
- Object.assign(theme.colors, preset.colors);
412
- Object.assign(theme.glyphs, preset.glyphs);
413
- if (preset.accents !== undefined)
414
- theme.accents = [...preset.accents];
415
- return name;
416
- }
417
- function applyFile(theme, file, where, warn) {
418
- if (isRecord(file.colors)) {
419
- for (const [key, value] of Object.entries(file.colors)) {
420
- if (!Object.hasOwn(DEFAULT.colors, key))
421
- warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
422
- else if (!isColorSpec(value))
423
- warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
424
- else
425
- theme.colors[key] = value;
426
- }
427
- }
428
- if (isRecord(file.glyphs)) {
429
- for (const [key, value] of Object.entries(file.glyphs)) {
430
- if (!Object.hasOwn(DEFAULT.glyphs, key))
431
- warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
432
- else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
433
- warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
434
- else
435
- theme.glyphs[key] = value;
436
- }
437
- }
438
- if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
439
- theme.accents = [...file.accents];
440
- else if (file.accents !== undefined)
441
- warn(`${where}: accents must be a non-empty list of colours`);
442
- if (isRecord(file.bins)) {
443
- for (const [bin, value] of Object.entries(file.bins)) {
444
- if (isColorSpec(value))
445
- theme.bins[bin] = value;
446
- else
447
- warn(`${where}: bin ${bin} has no valid colour`);
448
- }
449
- }
450
- }
451
- function endsWalk(home) {
452
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
453
- }
454
301
  var warned = new Set;
455
- function warnOnce(message) {
456
- if (warned.has(message))
457
- return;
458
- warned.add(message);
459
- console.error(`warning: theme ${message}`);
460
- }
461
- function isPath(chosen) {
462
- return chosen.includes("/") || chosen.endsWith(".json");
463
- }
464
- function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
465
- const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
466
- const sources = [];
467
- const chosen = env.KIT_THEME ?? "";
468
- const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
469
- if (isPath(chosen))
470
- wanted.push(resolve2(from, chosen));
471
- const files = [];
472
- for (const path of wanted) {
473
- const file = path === undefined ? undefined : readThemeFile(path, warn);
474
- if (path !== undefined && file !== undefined)
475
- files.push({ path, file });
476
- }
477
- let preset = "default";
478
- if (chosen !== "" && !isPath(chosen)) {
479
- preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
480
- } else {
481
- const named = files.findLast(({ file }) => file.preset !== undefined);
482
- if (named !== undefined)
483
- preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
484
- }
485
- for (const { path, file } of files) {
486
- applyFile(theme, file, path, warn);
487
- sources.push(path);
488
- }
489
- return { theme, sources, preset };
490
- }
491
- var current;
492
- var currentKey = "";
493
- function activeTheme() {
494
- const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
495
- if (current === undefined || key !== currentKey) {
496
- current = loadTheme();
497
- currentKey = key;
498
- }
499
- return current;
500
- }
501
302
 
502
303
  // ../kit/src/style.ts
503
- function takesControlCodes(stream, env = process6.env) {
304
+ function takesControlCodes(stream, env = process3.env) {
504
305
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
505
306
  }
506
- function paint(stream, env = process6.env) {
307
+ function paint(stream, env = process3.env) {
507
308
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
508
309
  }
509
310
  var STATUS_WORDS = {
@@ -514,21 +315,6 @@ var STATUS_WORDS = {
514
315
  skipped: ["skipped", "cancelled", "canceled", "manual"]
515
316
  };
516
317
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
517
- function header(bin, context, stream, env = process6.env) {
518
- if (!takesControlCodes(stream, env))
519
- return "";
520
- const colors = paint(stream, env);
521
- const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
522
- const { theme } = activeTheme();
523
- const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
524
- const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
525
- return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
526
- }
527
- function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
528
- const line = header(bin, context, stream, env);
529
- if (line !== "")
530
- console.log(line);
531
- }
532
318
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-hrsswv1w.js
533
319
  function $e(t, e = false, i = 1) {
534
320
  let n = typeof e === "object" ? e : { units: e ? "si" : "iec", dp: i }, { units: s = "iec", dp: u = 1 } = n, r = s === "si" ? 1000 : 1024;
@@ -568,7 +354,7 @@ var ESCAPE = String.fromCharCode(27);
568
354
  function textWidth(text) {
569
355
  return Bun.stringWidth(text);
570
356
  }
571
- function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
357
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process4.stdout, env = process4.env } = {}) {
572
358
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
573
359
  if (outputMode(stream, env) === "agent")
574
360
  return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
@@ -607,7 +393,7 @@ function narrow(rows, widths, limit) {
607
393
  }
608
394
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
609
395
  }
610
- function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
396
+ function jsonText(value, replacer, { stream = process4.stdout, env = process4.env } = {}) {
611
397
  return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
612
398
  }
613
399
  function printJson(value) {
@@ -615,27 +401,27 @@ function printJson(value) {
615
401
  }
616
402
 
617
403
  // ../kit/src/help.ts
618
- import process8 from "process";
404
+ import process5 from "process";
619
405
  var OPTIONAL = /\[[^\]]+\]/g;
620
406
  var USAGE_PREFIX = /^usage:\s*/i;
621
407
  var FULL_STOP = /\.$/;
622
- function usageLine(usage, colors = paint(process8.stdout)) {
408
+ function usageLine(usage, colors = paint(process5.stdout)) {
623
409
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
624
410
  }
625
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
411
+ function helpText(usage, options, colors = paint(process5.stdout), { examples = [], replaces, exits = [] } = {}) {
626
412
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
627
413
  `);
628
414
  }
629
- function exitRows(exits, colors = paint(process8.stdout)) {
415
+ function exitRows(exits, colors = paint(process5.stdout)) {
630
416
  if (exits.length === 0)
631
417
  return [];
632
418
  const width = Math.max(...exits.map(([code]) => String(code).length));
633
419
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
634
420
  }
635
- function replacesRows(replaces, colors = paint(process8.stdout)) {
421
+ function replacesRows(replaces, colors = paint(process5.stdout)) {
636
422
  return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
637
423
  }
638
- function wantsHelpJson(env = process8.env) {
424
+ function wantsHelpJson(env = process5.env) {
639
425
  return env.KIT_HELP === "json";
640
426
  }
641
427
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -654,12 +440,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
654
440
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
655
441
  };
656
442
  }
657
- function exampleRows(examples, colors = paint(process8.stdout)) {
443
+ function exampleRows(examples, colors = paint(process5.stdout)) {
658
444
  if (examples.length === 0 || outputMode() === "agent")
659
445
  return [];
660
446
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
661
447
  }
662
- function optionRows(options, colors = paint(process8.stdout)) {
448
+ function optionRows(options, colors = paint(process5.stdout)) {
663
449
  const rows = Object.entries(options).map(([name, option]) => {
664
450
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
665
451
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -760,7 +546,7 @@ var OUTPUT_OPTIONS = {
760
546
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
761
547
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
762
548
  };
763
- function applyOutput(color, plain, env = process9.env) {
549
+ function applyOutput(color, plain, env = process6.env) {
764
550
  const when = plain === true ? "never" : color ?? "auto";
765
551
  if (when === "auto")
766
552
  return;
@@ -931,7 +717,7 @@ function nearestOption(message, options, allowNegative) {
931
717
  }
932
718
  // ../kit/src/process.ts
933
719
  import { constants } from "os";
934
- import process10 from "process";
720
+ import process7 from "process";
935
721
  var KILL_GRACE_MS = 2000;
936
722
  function exitCodeOf(code, signal) {
937
723
  if (code !== null)
@@ -951,7 +737,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
951
737
  return;
952
738
  try {
953
739
  if (grouped)
954
- process10.kill(-proc.pid, killing);
740
+ process7.kill(-proc.pid, killing);
955
741
  else
956
742
  proc.kill(killing);
957
743
  } catch {}
@@ -1025,15 +811,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
1025
811
  var RESET_STYLE = `${ESC}[0m`;
1026
812
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
1027
813
  // ../kit/src/cli.ts
1028
- import { readFileSync as readFileSync2, realpathSync } from "fs";
1029
- import { dirname as dirname3, join as join5 } from "path";
1030
- import process12 from "process";
814
+ import { readFileSync, realpathSync } from "fs";
815
+ import { dirname as dirname2, join as join2 } from "path";
816
+ import process9 from "process";
1031
817
 
1032
818
  // ../kit/src/usage.ts
1033
819
  import { appendFileSync, mkdirSync } from "fs";
1034
- import { homedir as homedir3 } from "os";
1035
- import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1036
- import process11 from "process";
820
+ import { homedir } from "os";
821
+ import { dirname, isAbsolute, join } from "path";
822
+ import process8 from "process";
1037
823
 
1038
824
  // ../kit/src/logs.ts
1039
825
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -1047,14 +833,14 @@ var usageError;
1047
833
  function noteUsageError(message) {
1048
834
  usageError = message;
1049
835
  }
1050
- function stateHome(env = process11.env) {
836
+ function stateHome(env = process8.env) {
1051
837
  const dir = env.XDG_STATE_HOME;
1052
- return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
838
+ return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
1053
839
  }
1054
- function usagePath(env = process11.env) {
1055
- return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
840
+ function usagePath(env = process8.env) {
841
+ return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
1056
842
  }
1057
- function usageRecorded(env = process11.env) {
843
+ function usageRecorded(env = process8.env) {
1058
844
  const off = env.KAYNOOO_CLI_NO_USAGE;
1059
845
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1060
846
  }
@@ -1068,12 +854,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1068
854
  usageError = undefined;
1069
855
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1070
856
  }
1071
- function recordUsage(entry, env = process11.env) {
857
+ function recordUsage(entry, env = process8.env) {
1072
858
  if (!usageRecorded(env))
1073
859
  return;
1074
860
  try {
1075
861
  const path = usagePath(env);
1076
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
862
+ mkdirSync(dirname(path), { recursive: true, mode: 448 });
1077
863
  appendFileSync(path, `${JSON.stringify(entry)}
1078
864
  `, { mode: 384 });
1079
865
  } catch {}
@@ -1159,8 +945,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1159
945
  `);
1160
946
  }
1161
947
  function printError(prefix, message, hint, cause) {
1162
- const colors = paint(process12.stderr);
1163
- const styled = takesControlCodes(process12.stderr);
948
+ const colors = paint(process9.stderr);
949
+ const styled = takesControlCodes(process9.stderr);
1164
950
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1165
951
  const under = (label, text, tint) => text === undefined ? "" : `
1166
952
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1203,11 +989,11 @@ async function dispatch(level, typed, { version, redact }) {
1203
989
  }
1204
990
  }
1205
991
  if (name === undefined && level.path.length > 1) {
1206
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
992
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stderr));
1207
993
  return 2;
1208
994
  }
1209
995
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1210
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
996
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process9.stdout));
1211
997
  return 0;
1212
998
  }
1213
999
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1324,17 +1110,17 @@ async function printCandidates(found) {
1324
1110
  return 0;
1325
1111
  }
1326
1112
  function packageVersion(entry = Bun.main) {
1327
- for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1113
+ for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1328
1114
  try {
1329
- const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1115
+ const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
1330
1116
  if (typeof version === "string")
1331
1117
  return version;
1332
1118
  } catch {}
1333
- if (dirname3(dir) === dir)
1119
+ if (dirname2(dir) === dir)
1334
1120
  return "0.0.0";
1335
1121
  }
1336
1122
  }
1337
- async function runCli(cli, argv = process12.argv.slice(2)) {
1123
+ async function runCli(cli, argv = process9.argv.slice(2)) {
1338
1124
  const version = cli.version ?? packageVersion();
1339
1125
  if (argv[0] === COMPLETE)
1340
1126
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1361,7 +1147,7 @@ function commandPath(scope, argv) {
1361
1147
  }
1362
1148
  return path.length === 0 ? undefined : path.join(" ");
1363
1149
  }
1364
- async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
1150
+ async function runMain({ name, version, run, redact, usage }, argv = process9.argv.slice(2)) {
1365
1151
  if (argv[0] === COMPLETE)
1366
1152
  return printCandidates(leafCandidates(run, argv.slice(1)));
1367
1153
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1405,7 +1191,7 @@ function parseSize(text, bareUnit = 1) {
1405
1191
  return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
1406
1192
  }
1407
1193
  // ../kit/src/watch.ts
1408
- import process13 from "process";
1194
+ import process10 from "process";
1409
1195
  import { format } from "util";
1410
1196
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1411
1197
  var DEFAULT_SECONDS = 2;
@@ -1427,7 +1213,7 @@ function withoutWatch(args) {
1427
1213
  }
1428
1214
  return rest;
1429
1215
  }
1430
- async function watching(value, step, stream = process13.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1216
+ async function watching(value, step, stream = process10.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1431
1217
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1432
1218
  if (!takesControlCodes(stream))
1433
1219
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1435,12 +1221,12 @@ async function watching(value, step, stream = process13.stdout, sleep = Bun.slee
1435
1221
  for (let round = 0;round < rounds; round++) {
1436
1222
  const held = [];
1437
1223
  const { log, info } = console;
1438
- const write = process13.stdout.write.bind(process13.stdout);
1224
+ const write = process10.stdout.write.bind(process10.stdout);
1439
1225
  const hold = (...parts) => void held.push(`${format(...parts)}
1440
1226
  `);
1441
1227
  console.log = hold;
1442
1228
  console.info = hold;
1443
- process13.stdout.write = (text) => {
1229
+ process10.stdout.write = (text) => {
1444
1230
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1445
1231
  return true;
1446
1232
  };
@@ -1449,7 +1235,7 @@ async function watching(value, step, stream = process13.stdout, sleep = Bun.slee
1449
1235
  } finally {
1450
1236
  console.log = log;
1451
1237
  console.info = info;
1452
- process13.stdout.write = write;
1238
+ process10.stdout.write = write;
1453
1239
  }
1454
1240
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1455
1241
  await sleep(interval);
@@ -1457,7 +1243,7 @@ async function watching(value, step, stream = process13.stdout, sleep = Bun.slee
1457
1243
  return code;
1458
1244
  }
1459
1245
  // src/pid.ts
1460
- import process15 from "process";
1246
+ import process12 from "process";
1461
1247
 
1462
1248
  // src/mask.ts
1463
1249
  import { basename } from "path";
@@ -1848,7 +1634,7 @@ function limitLine(limits, name) {
1848
1634
  return limit === undefined ? "-" : `soft ${limit.soft}, hard ${limit.hard}`;
1849
1635
  }
1850
1636
  function render(info, showEnv) {
1851
- const colors = paint(process15.stdout);
1637
+ const colors = paint(process12.stdout);
1852
1638
  const memory = info.memory;
1853
1639
  const size = (bytes) => bytes === undefined ? "-" : $e(bytes);
1854
1640
  const rows = [
@@ -1901,10 +1687,10 @@ async function pid(args) {
1901
1687
 
1902
1688
  // src/ports.ts
1903
1689
  import { basename as basename2 } from "path";
1904
- import process17 from "process";
1690
+ import process14 from "process";
1905
1691
 
1906
1692
  // ../kit/src/prompt.ts
1907
- import process16 from "process";
1693
+ import process13 from "process";
1908
1694
 
1909
1695
  // ../kit/src/picker/score.ts
1910
1696
  var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
@@ -1988,7 +1774,7 @@ function asking(colors, question, typed, keys) {
1988
1774
  function answer(colors, question, state, picked) {
1989
1775
  return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1990
1776
  }
1991
- async function ask(question, { hint, terminal = process16 }, render, press) {
1777
+ async function ask(question, { hint, terminal = process13 }, render, press) {
1992
1778
  const { stdin, stderr } = terminal;
1993
1779
  if (!isInteractive(terminal))
1994
1780
  fail(`cannot ask "${question}" off a terminal`, 2, hint);
@@ -2176,7 +1962,7 @@ function refusal(row, proc, guard) {
2176
1962
  return reason === undefined ? undefined : `pid ${row.pid} is ${reason}`;
2177
1963
  }
2178
1964
  function render2(rows) {
2179
- const colors = paint(process17.stdout);
1965
+ const colors = paint(process14.stdout);
2180
1966
  const cells = rows.map((row) => [
2181
1967
  colors.cyan(String(row.port)),
2182
1968
  row.protocol,
@@ -2188,7 +1974,7 @@ function render2(rows) {
2188
1974
  return table([["PORT", "PROTO", "ADDRESS", "PID", "COMMAND", "CWD"], ...cells], { header: true });
2189
1975
  }
2190
1976
  async function stop(port, rows, procs, values) {
2191
- const guard = { uid: process17.getuid?.() ?? -1, mine: new Set(ancestry(process17.pid, procs)) };
1977
+ const guard = { uid: process14.getuid?.() ?? -1, mine: new Set(ancestry(process14.pid, procs)) };
2192
1978
  const targets = new Map;
2193
1979
  for (const row of rows) {
2194
1980
  const reason = refusal(row, row.pid === undefined ? undefined : procs.get(row.pid), guard);
@@ -2201,7 +1987,7 @@ async function stop(port, rows, procs, values) {
2201
1987
  return 1;
2202
1988
  const names = [...targets].map(([pid, row]) => `${pid} (${truncate(row.command ?? "", 40)})`).join(", ");
2203
1989
  if (values.yes !== true) {
2204
- if (!process17.stdin.isTTY)
1990
+ if (!process14.stdin.isTTY)
2205
1991
  fail(`stopping ${names} needs a terminal to ask on: pass --yes`, 2);
2206
1992
  if (await confirm(`Stop ${names}?`, { default: false }) !== true)
2207
1993
  return 1;
@@ -2232,7 +2018,7 @@ async function ports(args) {
2232
2018
  badUsage(`<port> takes a whole number from 1 to 65535, not ${given}`);
2233
2019
  if (values.kill === true && port === undefined)
2234
2020
  badUsage("--kill takes the port to free: ports <port> --kill");
2235
- const [sockets, owners, procs] = await Promise.all([readSockets(), socketOwners(), snapshot("/proc", (uid) => uid === process17.getuid?.())]);
2021
+ const [sockets, owners, procs] = await Promise.all([readSockets(), socketOwners(), snapshot("/proc", (uid) => uid === process14.getuid?.())]);
2236
2022
  const byPid = new Map(procs.map((proc) => [proc.pid, proc]));
2237
2023
  const wanted = sockets.filter((socket) => port === undefined || socket.port === port);
2238
2024
  const needsDocker = wanted.some((socket) => {
@@ -2250,21 +2036,20 @@ async function ports(args) {
2250
2036
  printJson(rows);
2251
2037
  return 0;
2252
2038
  }
2253
- printHeader("ports");
2254
2039
  console.log(render2(rows));
2255
2040
  const unknown = rows.filter((row) => row.pid === undefined && row.container === undefined).length;
2256
2041
  if (unknown > 0)
2257
- console.error(paint(process17.stderr).dim(`${unknown} ${unknown === 1 ? "port has" : "ports have"} an owner this user cannot read, shown as -`));
2042
+ console.error(paint(process14.stderr).dim(`${unknown} ${unknown === 1 ? "port has" : "ports have"} an owner this user cannot read, shown as -`));
2258
2043
  return 0;
2259
2044
  }
2260
2045
 
2261
2046
  // src/procs.ts
2262
- import { existsSync as existsSync3 } from "fs";
2263
- import { homedir as homedir4 } from "os";
2264
- import process18 from "process";
2047
+ import { existsSync } from "fs";
2048
+ import { homedir as homedir2 } from "os";
2049
+ import process15 from "process";
2265
2050
 
2266
2051
  // src/select.ts
2267
- import { basename as basename3, join as join6, relative } from "path";
2052
+ import { basename as basename3, join as join3, relative } from "path";
2268
2053
  var BROWSERS = /^(?:chrom(?:e|ium)(?:-browser)?|google-chrome(?:-stable|-beta|-unstable)?|chrome_crashpad_handler|chrome-headless-shell|headless_shell|chromium-headless-shell|brave|brave-browser|msedge|microsoft-edge|webkitwebprocess|webkitnetworkprocess|webkitgpuprocess|minibrowser|webkitwebdriver|wpewebprocess|wpenetworkprocess|bun-webview.*)$/i;
2269
2054
  var NATIVE = new Set(["rust-analyzer", "gopls", "clangd", "lua-language-server", "pyright-langserver", "pylsp", "intelephense", "phpactor", "tsgo", "esbuild", "biome", "ruff", "phpunit", "pytest", "vitest", "jest"]);
2270
2055
  var RUNTIMES = new Set(["node", "bun", "bunx", "deno", "nodejs"]);
@@ -2301,9 +2086,9 @@ function projectOf(cwd, exists, home) {
2301
2086
  if (cwd === undefined || !cwd.startsWith(`${home}/`))
2302
2087
  return;
2303
2088
  const folders = [];
2304
- for (let dir = cwd;dir.startsWith(`${home}/`); dir = join6(dir, ".."))
2089
+ for (let dir = cwd;dir.startsWith(`${home}/`); dir = join3(dir, ".."))
2305
2090
  folders.push(dir);
2306
- return folders.find((dir) => exists(join6(dir, ".git"))) ?? folders.find((dir) => MARKERS.some((marker) => exists(join6(dir, marker))));
2091
+ return folders.find((dir) => exists(join3(dir, ".git"))) ?? folders.find((dir) => MARKERS.some((marker) => exists(join3(dir, marker))));
2307
2092
  }
2308
2093
  function isOrphan(proc, byPid) {
2309
2094
  if (proc.unit?.endsWith(".service") === true)
@@ -2410,7 +2195,7 @@ function summary(group) {
2410
2195
  };
2411
2196
  }
2412
2197
  function render3(groups) {
2413
- const colors = paint(process18.stdout);
2198
+ const colors = paint(process15.stdout);
2414
2199
  const rows = groups.map((group) => [
2415
2200
  group.origin,
2416
2201
  String(group.members.length),
@@ -2437,23 +2222,22 @@ async function procs(args) {
2437
2222
  if (values.watch !== undefined)
2438
2223
  return watching(values.watch, async () => procs(withoutWatch(args)));
2439
2224
  const olderMs = values.older === undefined ? undefined : duration(values.older, "older", 0, "m");
2440
- const uid = process18.getuid?.() ?? -1;
2225
+ const uid = process15.getuid?.() ?? -1;
2441
2226
  const all = await snapshot("/proc", (owner) => owner === uid);
2442
- const mine = new Set(ancestry(process18.pid, new Map(all.map((proc) => [proc.pid, proc]))));
2443
- const { groups, protectedCount } = selectGroups(all, { guard: { uid, mine }, now: Date.now(), home: homedir4(), exists: existsSync3, minMem, olderMs });
2227
+ const mine = new Set(ancestry(process15.pid, new Map(all.map((proc) => [proc.pid, proc]))));
2228
+ const { groups, protectedCount } = selectGroups(all, { guard: { uid, mine }, now: Date.now(), home: homedir2(), exists: existsSync, minMem, olderMs });
2444
2229
  const pids = groups.flatMap((group) => group.members.map(({ proc }) => proc.pid));
2445
2230
  const show = (extra = {}) => {
2446
2231
  if (values.json === true) {
2447
2232
  printJson({ groups: groups.map(summary), skipped: protectedCount, ...extra });
2448
2233
  } else {
2449
- printHeader("procs");
2450
2234
  console.log(groups.length === 0 ? "nothing to clean" : render3(groups));
2451
2235
  }
2452
2236
  };
2453
2237
  if (values.kill !== true || pids.length === 0 || values.yes !== true) {
2454
2238
  show();
2455
2239
  if (values.json !== true && protectedCount > 0)
2456
- console.error(paint(process18.stderr).dim(`${protectedCount} more left out: shells, terminals and this command's ancestors are never touched`));
2240
+ console.error(paint(process15.stderr).dim(`${protectedCount} more left out: shells, terminals and this command's ancestors are never touched`));
2457
2241
  if (values.kill === true && pids.length > 0)
2458
2242
  console.error(`dry run: would stop ${pids.length} ${pids.length === 1 ? "process" : "processes"} (${pids.join(" ")}), pass --yes to do it`);
2459
2243
  return 0;
@@ -2468,7 +2252,7 @@ async function procs(args) {
2468
2252
  }
2469
2253
 
2470
2254
  // src/proc-cli.ts
2471
- process19.exitCode = await runCli({
2255
+ process16.exitCode = await runCli({
2472
2256
  name: "proc",
2473
2257
  about: "what a process is, who listens on a port and which dev processes are worth cleaning, read from /proc",
2474
2258
  replaces: "cat /proc/<pid>/..., ss -ltnp, lsof -i and pgrep -f one-liners",