@kaynooo/cli-pkg 0.8.1 → 0.10.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.
Files changed (3) hide show
  1. package/README.md +3 -2
  2. package/dist/cli.js +533 -208
  3. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -38,6 +38,27 @@ var init_advisory = __esm(() => {
38
38
  SEVERITIES = ["low", "moderate", "high", "critical"];
39
39
  });
40
40
 
41
+ // ../kit/src/mode.ts
42
+ import process2 from "process";
43
+ function isSet(value) {
44
+ return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
45
+ }
46
+ function outputMode(stream = process2.stdout, env = process2.env) {
47
+ const chosen = env.KIT_MODE;
48
+ if (chosen !== undefined && MODES.has(chosen))
49
+ return chosen;
50
+ if (AGENT_VARIABLES.some((name) => isSet(env[name])))
51
+ return "agent";
52
+ if (stream.isTTY === true)
53
+ return "terminal";
54
+ return isSet(env.CI) ? "ci" : "pipe";
55
+ }
56
+ var MODES, AGENT_VARIABLES;
57
+ var init_mode = __esm(() => {
58
+ MODES = new Set(["terminal", "ci", "agent", "pipe"]);
59
+ AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
60
+ });
61
+
41
62
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
42
63
  function x(s) {
43
64
  let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
@@ -304,53 +325,270 @@ var init_colors = __esm(() => {
304
325
  init_chunk_y1msbssb();
305
326
  });
306
327
 
328
+ // ../kit/src/config.ts
329
+ import { existsSync } from "fs";
330
+ import { dirname, join, resolve } from "path";
331
+ import process3 from "process";
332
+ function findUp(names, from = process3.cwd(), stop = () => false) {
333
+ const wanted = typeof names === "string" ? [names] : names;
334
+ for (let dir = resolve(from);; dir = dirname(dir)) {
335
+ const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
336
+ if (found !== undefined)
337
+ return found;
338
+ if (stop(dir) || dirname(dir) === dir)
339
+ return;
340
+ }
341
+ }
342
+ var init_config = __esm(() => {
343
+ init_args();
344
+ });
345
+
346
+ // ../kit/src/user-config.ts
347
+ import { existsSync as existsSync2 } from "fs";
348
+ import { homedir } from "os";
349
+ import { join as join2 } from "path";
350
+ import process4 from "process";
351
+ function configBase(where = {}) {
352
+ const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
353
+ return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
354
+ }
355
+ function userConfigPath(bin, where = {}) {
356
+ return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
357
+ }
358
+ function userConfigReadPath(bin, legacy = [], where = {}) {
359
+ const current = userConfigPath(bin, where);
360
+ if (existsSync2(current))
361
+ return current;
362
+ const base = configBase(where);
363
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
364
+ }
365
+ var init_user_config = () => {};
366
+
367
+ // ../kit/src/theme.ts
368
+ import { existsSync as existsSync3, readFileSync, statSync } from "fs";
369
+ import { homedir as homedir2 } from "os";
370
+ import { join as join3, resolve as resolve2 } from "path";
371
+ import process5 from "process";
372
+ function isColorSpec(spec) {
373
+ if (typeof spec === "number")
374
+ return Number.isInteger(spec) && spec >= 0 && spec <= 255;
375
+ return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
376
+ }
377
+ function cubeLevel(channel) {
378
+ return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
379
+ }
380
+ function nearest256(hex) {
381
+ const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
382
+ const levels = rgb.map(cubeLevel);
383
+ const cube = levels.map((level) => CUBE[level]);
384
+ const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
385
+ const greyValue = 8 + grey * 10;
386
+ const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
387
+ return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
388
+ }
389
+ function hasTrueColor(env) {
390
+ return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
391
+ }
392
+ function tinted(colors, spec, env = process5.env) {
393
+ if (typeof spec === "number")
394
+ return colors.ansi256(spec);
395
+ return spec.trim().split(SPACES).reduce((chain, token) => {
396
+ if (HEX.test(token))
397
+ return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
398
+ return chain[token] ?? chain;
399
+ }, colors);
400
+ }
401
+ function isRecord(value) {
402
+ return typeof value === "object" && value !== null && !Array.isArray(value);
403
+ }
404
+ function readThemeFile(path, warn) {
405
+ try {
406
+ const stat = statSync(path, { throwIfNoEntry: false });
407
+ if (stat === undefined)
408
+ return;
409
+ if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
410
+ warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
411
+ return;
412
+ }
413
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
414
+ if (isRecord(parsed))
415
+ return parsed;
416
+ warn(`${path} is not a JSON object, theme ignored`);
417
+ } catch (error) {
418
+ warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
419
+ }
420
+ return;
421
+ }
422
+ function applyPreset(theme, name, warn, where) {
423
+ if (name === undefined)
424
+ return;
425
+ if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
426
+ warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
427
+ return;
428
+ }
429
+ const preset = PRESETS[name];
430
+ Object.assign(theme.colors, preset.colors);
431
+ Object.assign(theme.glyphs, preset.glyphs);
432
+ if (preset.accents !== undefined)
433
+ theme.accents = [...preset.accents];
434
+ return name;
435
+ }
436
+ function applyFile(theme, file, where, warn) {
437
+ if (isRecord(file.colors)) {
438
+ for (const [key, value] of Object.entries(file.colors)) {
439
+ if (!Object.hasOwn(DEFAULT.colors, key))
440
+ warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
441
+ else if (!isColorSpec(value))
442
+ warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
443
+ else
444
+ theme.colors[key] = value;
445
+ }
446
+ }
447
+ if (isRecord(file.glyphs)) {
448
+ for (const [key, value] of Object.entries(file.glyphs)) {
449
+ if (!Object.hasOwn(DEFAULT.glyphs, key))
450
+ warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
451
+ else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
452
+ warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
453
+ else
454
+ theme.glyphs[key] = value;
455
+ }
456
+ }
457
+ if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
458
+ theme.accents = [...file.accents];
459
+ else if (file.accents !== undefined)
460
+ warn(`${where}: accents must be a non-empty list of colours`);
461
+ if (isRecord(file.bins)) {
462
+ for (const [bin, value] of Object.entries(file.bins)) {
463
+ if (isColorSpec(value))
464
+ theme.bins[bin] = value;
465
+ else
466
+ warn(`${where}: bin ${bin} has no valid colour`);
467
+ }
468
+ }
469
+ }
470
+ function endsWalk(home) {
471
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
472
+ }
473
+ function warnOnce(message) {
474
+ if (warned.has(message))
475
+ return;
476
+ warned.add(message);
477
+ console.error(`warning: theme ${message}`);
478
+ }
479
+ function isPath(chosen) {
480
+ return chosen.includes("/") || chosen.endsWith(".json");
481
+ }
482
+ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
483
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
484
+ const sources = [];
485
+ const chosen = env.KIT_THEME ?? "";
486
+ const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
487
+ if (isPath(chosen))
488
+ wanted.push(resolve2(from, chosen));
489
+ const files = [];
490
+ for (const path of wanted) {
491
+ const file = path === undefined ? undefined : readThemeFile(path, warn);
492
+ if (path !== undefined && file !== undefined)
493
+ files.push({ path, file });
494
+ }
495
+ let preset = "default";
496
+ if (chosen !== "" && !isPath(chosen)) {
497
+ preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
498
+ } else {
499
+ const named = files.findLast(({ file }) => file.preset !== undefined);
500
+ if (named !== undefined)
501
+ preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
502
+ }
503
+ for (const { path, file } of files) {
504
+ applyFile(theme, file, path, warn);
505
+ sources.push(path);
506
+ }
507
+ return { theme, sources, preset };
508
+ }
509
+ function activeTheme() {
510
+ const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
511
+ if (current === undefined || key !== currentKey) {
512
+ current = loadTheme();
513
+ currentKey = key;
514
+ }
515
+ return current;
516
+ }
517
+ var DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
518
+ var init_theme = __esm(() => {
519
+ init_config();
520
+ init_user_config();
521
+ DEFAULT = {
522
+ 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" },
523
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
524
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
525
+ bins: {}
526
+ };
527
+ 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" };
528
+ 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" };
529
+ ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
530
+ PRESETS = {
531
+ default: {},
532
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
533
+ mono: { colors: MONO, accents: ["bold"] },
534
+ ascii: { glyphs: ASCII }
535
+ };
536
+ 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"]);
537
+ HEX = /^#[0-9a-f]{6}$/i;
538
+ CONTROL = /\p{Cc}/u;
539
+ MAX_FILE_BYTES = 64 * 1024;
540
+ SPACES = /\s+/;
541
+ CUBE = [0, 95, 135, 175, 215, 255];
542
+ warned = new Set;
543
+ });
544
+
307
545
  // ../kit/src/style.ts
308
- import process2 from "process";
309
- function takesControlCodes(stream, env = process2.env) {
310
- return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
546
+ import process6 from "process";
547
+ function takesControlCodes(stream, env = process6.env) {
548
+ return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
311
549
  }
312
- function paint(stream, env = process2.env) {
550
+ function paint(stream, env = process6.env) {
313
551
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
314
552
  }
315
- function marked(mark, text, stream, detail, env = process2.env) {
553
+ function marked(mark, text, stream, detail, env = process6.env) {
316
554
  const colors = paint(stream, env);
317
- const { symbol, word, paint: tint } = MARKS[mark];
318
- const head = takesControlCodes(stream, env) ? tint(colors)(symbol) : word;
555
+ let head = MARK_WORDS[mark];
556
+ if (takesControlCodes(stream, env)) {
557
+ const { theme } = activeTheme();
558
+ head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
559
+ }
319
560
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
320
561
  }
321
562
  function ok(text, detail) {
322
- console.log(marked("ok", text, process2.stdout, detail));
563
+ console.log(marked("ok", text, process6.stdout, detail));
323
564
  }
324
565
  function note(text, detail) {
325
- console.log(marked("note", text, process2.stdout, detail));
566
+ console.log(marked("note", text, process6.stdout, detail));
326
567
  }
327
568
  function warn(text, detail) {
328
- console.error(marked("warn", text, process2.stderr, detail));
569
+ console.error(marked("warn", text, process6.stderr, detail));
329
570
  }
330
571
  function problem(text, detail) {
331
- console.error(marked("problem", text, process2.stderr, detail));
572
+ console.error(marked("problem", text, process6.stderr, detail));
332
573
  }
333
- var MARKS, STATUSES, STATUS_OF;
574
+ var MARK_WORDS, STATUS_WORDS, STATUS_OF;
334
575
  var init_style = __esm(() => {
335
576
  init_colors();
336
- MARKS = {
337
- ok: { symbol: "\u2713", word: "ok:", paint: (colors) => colors.green },
338
- warn: { symbol: "!", word: "warning:", paint: (colors) => colors.yellow },
339
- problem: { symbol: "\u2717", word: "error:", paint: (colors) => colors.red },
340
- note: { symbol: "\xB7", word: "note:", paint: (colors) => colors.dim }
577
+ init_mode();
578
+ init_theme();
579
+ MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
580
+ STATUS_WORDS = {
581
+ passed: ["passed", "success", "succeeded", "ok"],
582
+ failed: ["failed", "failure", "error", "errored"],
583
+ running: ["running", "in_progress", "started", "holding"],
584
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
585
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
341
586
  };
342
- STATUSES = {
343
- passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
344
- failed: { symbol: "\u2717", words: ["failed", "failure", "error", "errored"], paint: (colors) => colors.red },
345
- running: { symbol: "\u25CF", words: ["running", "in_progress", "started"], paint: (colors) => colors.cyan },
346
- queued: { symbol: "\u25CB", words: ["queued", "waiting", "pending", "created", "blocked", "scheduled"], paint: (colors) => colors.yellow },
347
- skipped: { symbol: "-", words: ["skipped", "cancelled", "canceled", "manual"], paint: (colors) => colors.dim }
348
- };
349
- STATUS_OF = new Map(Object.entries(STATUSES).flatMap(([status, { words }]) => words.map((word) => [word, status])));
587
+ STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
350
588
  });
351
589
 
352
590
  // ../kit/src/format.ts
353
- import process3 from "process";
591
+ import process7 from "process";
354
592
  function formatSeconds(total) {
355
593
  let rest = Math.max(0, Math.round(total));
356
594
  const amounts = UNITS.map(([unit, size]) => {
@@ -387,15 +625,18 @@ function truncate(text, width) {
387
625
  function textWidth(text) {
388
626
  return Bun.stringWidth(text);
389
627
  }
390
- function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
628
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
391
629
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
630
+ if (outputMode(stream, env) === "agent")
631
+ return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
632
+ `);
392
633
  const widths = [];
393
634
  for (const row of cells) {
394
635
  for (const [index, cell] of row.entries())
395
636
  widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
396
637
  }
397
638
  const shown = fit === undefined ? cells : narrow(cells, widths, fit);
398
- const colors = paint(process3.stdout);
639
+ const colors = paint(stream);
399
640
  const lines = shown.map((row) => row.map((cell, index) => {
400
641
  const width = widths[index] ?? 0;
401
642
  const gap = " ".repeat(Math.max(0, width - textWidth(cell)));
@@ -403,7 +644,8 @@ function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
403
644
  return `${gap}${cell}`;
404
645
  return index === row.length - 1 ? cell : `${cell}${gap}`;
405
646
  }).join(" ").trimEnd());
406
- return lines.map((line, index) => header && index === 0 ? colors.bold(line) : line).join(`
647
+ const rule = header && takesControlCodes(stream) && lines.length > 1 ? [colors.dim("\u2500".repeat(Math.max(...lines.map(textWidth))))] : [];
648
+ return lines.flatMap((line, index) => header && index === 0 ? [colors.bold(line), ...rule] : [line]).join(`
407
649
  `);
408
650
  }
409
651
  function narrow(rows, widths, limit) {
@@ -422,11 +664,15 @@ function narrow(rows, widths, limit) {
422
664
  }
423
665
  return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
424
666
  }
667
+ function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
668
+ return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
669
+ }
425
670
  function printJson(value) {
426
- console.log(JSON.stringify(value, undefined, 2));
671
+ console.log(jsonText(value));
427
672
  }
428
673
  var UNITS, LINE_BREAKS, ESCAPE;
429
674
  var init_format = __esm(() => {
675
+ init_mode();
430
676
  init_style();
431
677
  UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
432
678
  LINE_BREAKS = /\s*\n\s*/g;
@@ -434,24 +680,24 @@ var init_format = __esm(() => {
434
680
  });
435
681
 
436
682
  // ../kit/src/help.ts
437
- import process4 from "process";
438
- function usageLine(usage, colors = paint(process4.stdout)) {
683
+ import process8 from "process";
684
+ function usageLine(usage, colors = paint(process8.stdout)) {
439
685
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
440
686
  }
441
- function helpText(usage, options, colors = paint(process4.stdout), { examples = [], replaces, exits = [] } = {}) {
687
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
442
688
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
443
689
  `);
444
690
  }
445
- function exitRows(exits, colors = paint(process4.stdout)) {
691
+ function exitRows(exits, colors = paint(process8.stdout)) {
446
692
  if (exits.length === 0)
447
693
  return [];
448
694
  const width = Math.max(...exits.map(([code]) => String(code).length));
449
695
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
450
696
  }
451
- function replacesRows(replaces, colors = paint(process4.stdout)) {
452
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
697
+ function replacesRows(replaces, colors = paint(process8.stdout)) {
698
+ return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
453
699
  }
454
- function wantsHelpJson(env = process4.env) {
700
+ function wantsHelpJson(env = process8.env) {
455
701
  return env.KIT_HELP === "json";
456
702
  }
457
703
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -470,12 +716,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
470
716
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
471
717
  };
472
718
  }
473
- function exampleRows(examples, colors = paint(process4.stdout)) {
474
- if (examples.length === 0)
719
+ function exampleRows(examples, colors = paint(process8.stdout)) {
720
+ if (examples.length === 0 || outputMode() === "agent")
475
721
  return [];
476
722
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
477
723
  }
478
- function optionRows(options, colors = paint(process4.stdout)) {
724
+ function optionRows(options, colors = paint(process8.stdout)) {
479
725
  const rows = Object.entries(options).map(([name, option]) => {
480
726
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
481
727
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -488,6 +734,7 @@ function optionRows(options, colors = paint(process4.stdout)) {
488
734
  }
489
735
  var OPTIONAL, USAGE_PREFIX, FULL_STOP;
490
736
  var init_help = __esm(() => {
737
+ init_mode();
491
738
  init_style();
492
739
  OPTIONAL = /\[[^\]]+\]/g;
493
740
  USAGE_PREFIX = /^usage:\s*/i;
@@ -519,7 +766,7 @@ var init_text = __esm(() => {
519
766
 
520
767
  // ../kit/src/input.ts
521
768
  import { fstatSync } from "fs";
522
- import process5 from "process";
769
+ import process9 from "process";
523
770
  function wholeNumber(value, name, fallback, min = 1) {
524
771
  if (value === undefined)
525
772
  return fallback;
@@ -543,7 +790,7 @@ function isStdinPiped() {
543
790
  }
544
791
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
545
792
  if (path === "-") {
546
- if (process5.stdin.isTTY)
793
+ if (process9.stdin.isTTY)
547
794
  fail(noStdin);
548
795
  return Bun.stdin.text();
549
796
  }
@@ -561,7 +808,7 @@ var init_input = __esm(() => {
561
808
  });
562
809
 
563
810
  // ../kit/src/args.ts
564
- import process6 from "process";
811
+ import process10 from "process";
565
812
  import { parseArgs } from "util";
566
813
  function jsonOption(holds) {
567
814
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
@@ -583,7 +830,7 @@ class Completing {
583
830
  this.candidates = candidates;
584
831
  }
585
832
  }
586
- function applyOutput(color, plain, env = process6.env) {
833
+ function applyOutput(color, plain, env = process10.env) {
587
834
  const when = plain === true ? "never" : color ?? "auto";
588
835
  if (when === "auto")
589
836
  return;
@@ -789,12 +1036,14 @@ var init_args = __esm(() => {
789
1036
  // ../kit/src/chart.ts
790
1037
  var init_chart = __esm(() => {
791
1038
  init_format();
1039
+ init_mode();
792
1040
  init_style();
1041
+ init_theme();
793
1042
  });
794
1043
 
795
1044
  // ../kit/src/process.ts
796
1045
  import { constants } from "os";
797
- import process7 from "process";
1046
+ import process11 from "process";
798
1047
  function exitCodeOf(code, signal) {
799
1048
  if (code !== null)
800
1049
  return code;
@@ -814,7 +1063,7 @@ function holdSignals(cleanup) {
814
1063
  },
815
1064
  release: () => {
816
1065
  for (const signal of SIGNALS)
817
- process7.off(signal, onSignal);
1066
+ process11.off(signal, onSignal);
818
1067
  }
819
1068
  };
820
1069
  function onSignal(signal) {
@@ -827,10 +1076,10 @@ function holdSignals(cleanup) {
827
1076
  return;
828
1077
  held.release();
829
1078
  cleanup(signal);
830
- process7.kill(process7.pid, signal);
1079
+ process11.kill(process11.pid, signal);
831
1080
  }
832
1081
  for (const signal of SIGNALS)
833
- process7.on(signal, onSignal);
1082
+ process11.on(signal, onSignal);
834
1083
  return held;
835
1084
  }
836
1085
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -844,7 +1093,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
844
1093
  return;
845
1094
  try {
846
1095
  if (grouped)
847
- process7.kill(-proc.pid, killing);
1096
+ process11.kill(-proc.pid, killing);
848
1097
  else
849
1098
  proc.kill(killing);
850
1099
  } catch {}
@@ -917,8 +1166,8 @@ var init_process = __esm(() => {
917
1166
  });
918
1167
 
919
1168
  // ../kit/src/progress.ts
920
- import process8 from "process";
921
- function liveRegion(render, stream = process8.stderr, env = process8.env) {
1169
+ import process12 from "process";
1170
+ function liveRegion(render, stream = process12.stderr, env = process12.env) {
922
1171
  if (!takesControlCodes(stream, env))
923
1172
  return { redraw: () => {
924
1173
  return;
@@ -928,25 +1177,28 @@ function liveRegion(render, stream = process8.stderr, env = process8.env) {
928
1177
  } };
929
1178
  const write = stream.write.bind(stream);
930
1179
  let frame = 0;
931
- let drawn = 0;
1180
+ let drawn = [];
1181
+ const columns = () => stream.columns === undefined || stream.columns === 0 ? 80 : stream.columns;
1182
+ const rowsDrawn = () => drawn.reduce((sum, width) => sum + Math.max(1, Math.ceil(width / columns())), 0);
932
1183
  const clear = () => {
933
- if (drawn > 0)
934
- write(`${CLEAR_LINE}${LINE_UP.repeat(drawn - 1)}`);
935
- drawn = 0;
1184
+ if (drawn.length > 0)
1185
+ write(`${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}`);
1186
+ drawn = [];
936
1187
  };
937
1188
  const draw = () => {
938
- const width = (stream.columns === undefined || stream.columns === 0 ? 80 : stream.columns) - 1;
1189
+ const width = columns() - 1;
939
1190
  const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
940
1191
  const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
941
1192
  if (lines.length === 0) {
942
1193
  clear();
943
1194
  return;
944
1195
  }
945
- write(`${drawn > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(drawn - 1)}` : CLEAR_LINE}${lines.join(`
1196
+ write(`${drawn.length > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}` : CLEAR_LINE}${lines.join(`
946
1197
  `)}`);
947
- drawn = lines.length;
1198
+ drawn = lines.map((line) => Bun.stringWidth(line));
948
1199
  };
949
1200
  const timer = setInterval(draw, FRAME_MS);
1201
+ stream.on?.("resize", draw);
950
1202
  const restore = interceptOutput(clear);
951
1203
  const release = swallowInput();
952
1204
  const onExit = () => {
@@ -956,14 +1208,15 @@ function liveRegion(render, stream = process8.stderr, env = process8.env) {
956
1208
  const signals = holdSignals(stop);
957
1209
  function stop() {
958
1210
  clearInterval(timer);
1211
+ stream.off?.("resize", draw);
959
1212
  clear();
960
1213
  restore();
961
1214
  release();
962
- process8.off("exit", onExit);
1215
+ process12.off("exit", onExit);
963
1216
  signals.release();
964
1217
  }
965
1218
  timer.unref();
966
- process8.on("exit", onExit);
1219
+ process12.on("exit", onExit);
967
1220
  return {
968
1221
  redraw: draw,
969
1222
  print: (text) => {
@@ -1002,14 +1255,14 @@ function cutToWidth(line, width) {
1002
1255
  return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
1003
1256
  }
1004
1257
  function swallowInput() {
1005
- const input = process8.stdin;
1258
+ const input = process12.stdin;
1006
1259
  if (!input.isTTY)
1007
1260
  return () => {
1008
1261
  return;
1009
1262
  };
1010
1263
  const onData = (data) => {
1011
1264
  if (data.includes(CTRL_C))
1012
- process8.kill(process8.pid, "SIGINT");
1265
+ process12.kill(process12.pid, "SIGINT");
1013
1266
  };
1014
1267
  input.setRawMode(true);
1015
1268
  input.on("data", onData);
@@ -1025,7 +1278,7 @@ function swallowInput() {
1025
1278
  };
1026
1279
  }
1027
1280
  function interceptOutput(clear) {
1028
- const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process8.stdout, "write"], [process8.stderr, "write"]];
1281
+ const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process12.stdout, "write"], [process12.stderr, "write"]];
1029
1282
  const wrapped = targets.map(([target, name]) => {
1030
1283
  const original = Reflect.get(target, name);
1031
1284
  const wrapper = (...args) => {
@@ -1077,20 +1330,20 @@ var init_logs = __esm(() => {
1077
1330
 
1078
1331
  // ../kit/src/usage.ts
1079
1332
  import { appendFileSync, mkdirSync } from "fs";
1080
- import { homedir } from "os";
1081
- import { dirname, isAbsolute, join } from "path";
1082
- import process9 from "process";
1333
+ import { homedir as homedir3 } from "os";
1334
+ import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1335
+ import process13 from "process";
1083
1336
  function noteUsageError(message) {
1084
1337
  usageError = message;
1085
1338
  }
1086
- function stateHome(env = process9.env) {
1339
+ function stateHome(env = process13.env) {
1087
1340
  const dir = env.XDG_STATE_HOME;
1088
- return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
1341
+ return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
1089
1342
  }
1090
- function usagePath(env = process9.env) {
1091
- return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
1343
+ function usagePath(env = process13.env) {
1344
+ return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
1092
1345
  }
1093
- function usageRecorded(env = process9.env) {
1346
+ function usageRecorded(env = process13.env) {
1094
1347
  const off = env.KAYNOOO_CLI_NO_USAGE;
1095
1348
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1096
1349
  }
@@ -1104,12 +1357,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1104
1357
  usageError = undefined;
1105
1358
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1106
1359
  }
1107
- function recordUsage(entry, env = process9.env) {
1360
+ function recordUsage(entry, env = process13.env) {
1108
1361
  if (!usageRecorded(env))
1109
1362
  return;
1110
1363
  try {
1111
1364
  const path = usagePath(env);
1112
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
1365
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
1113
1366
  appendFileSync(path, `${JSON.stringify(entry)}
1114
1367
  `, { mode: 384 });
1115
1368
  } catch {}
@@ -1122,9 +1375,9 @@ var init_usage = __esm(() => {
1122
1375
  });
1123
1376
 
1124
1377
  // ../kit/src/cli.ts
1125
- import { readFileSync, realpathSync } from "fs";
1126
- import { dirname as dirname2, join as join2 } from "path";
1127
- import process10 from "process";
1378
+ import { readFileSync as readFileSync2, realpathSync } from "fs";
1379
+ import { dirname as dirname3, join as join5 } from "path";
1380
+ import process14 from "process";
1128
1381
  async function commandRows(all, colors) {
1129
1382
  const commands = shown(all);
1130
1383
  const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
@@ -1199,8 +1452,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1199
1452
  `);
1200
1453
  }
1201
1454
  function printError(prefix, message, hint, cause) {
1202
- const colors = paint(process10.stderr);
1203
- const styled = takesControlCodes(process10.stderr);
1455
+ const colors = paint(process14.stderr);
1456
+ const styled = takesControlCodes(process14.stderr);
1204
1457
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1205
1458
  const under = (label, text, tint) => text === undefined ? "" : `
1206
1459
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1219,7 +1472,7 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
1219
1472
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
1220
1473
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
1221
1474
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
1222
- if (error instanceof UsageError)
1475
+ if (error instanceof Exit && error.code === 2)
1223
1476
  noteUsageError(error.message);
1224
1477
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
1225
1478
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
@@ -1243,11 +1496,11 @@ async function dispatch(level, typed, { version, redact }) {
1243
1496
  }
1244
1497
  }
1245
1498
  if (name === undefined && level.path.length > 1) {
1246
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process10.stderr));
1499
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stderr));
1247
1500
  return 2;
1248
1501
  }
1249
1502
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1250
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process10.stdout));
1503
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stdout));
1251
1504
  return 0;
1252
1505
  }
1253
1506
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1362,17 +1615,17 @@ async function printCandidates(found) {
1362
1615
  return 0;
1363
1616
  }
1364
1617
  function packageVersion(entry = Bun.main) {
1365
- for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1618
+ for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1366
1619
  try {
1367
- const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
1620
+ const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1368
1621
  if (typeof version === "string")
1369
1622
  return version;
1370
1623
  } catch {}
1371
- if (dirname2(dir) === dir)
1624
+ if (dirname3(dir) === dir)
1372
1625
  return "0.0.0";
1373
1626
  }
1374
1627
  }
1375
- async function runCli(cli, argv = process10.argv.slice(2)) {
1628
+ async function runCli(cli, argv = process14.argv.slice(2)) {
1376
1629
  const version = cli.version ?? packageVersion();
1377
1630
  if (argv[0] === COMPLETE)
1378
1631
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1411,11 +1664,6 @@ var init_cli = __esm(() => {
1411
1664
  };
1412
1665
  TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1413
1666
  });
1414
- // ../kit/src/config.ts
1415
- var init_config = __esm(() => {
1416
- init_args();
1417
- });
1418
-
1419
1667
  // ../kit/src/git.ts
1420
1668
  var init_git = __esm(() => {
1421
1669
  init_args();
@@ -1447,6 +1695,20 @@ var init_limit = __esm(() => {
1447
1695
  init_args();
1448
1696
  });
1449
1697
 
1698
+ // ../kit/src/pool.ts
1699
+ async function pool(items, limit, task) {
1700
+ const results = Array.from({ length: items.length });
1701
+ let next = 0;
1702
+ async function worker() {
1703
+ while (next < items.length) {
1704
+ const index = next++;
1705
+ results[index] = await task(items[index]);
1706
+ }
1707
+ }
1708
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
1709
+ return results;
1710
+ }
1711
+
1450
1712
  // ../kit/src/secrets.ts
1451
1713
  var SECRET_WORDS;
1452
1714
  var init_secrets = __esm(() => {
@@ -1464,26 +1726,35 @@ var init_sessions = __esm(() => {
1464
1726
  // ../kit/src/size.ts
1465
1727
  var init_size = () => {};
1466
1728
 
1467
- // ../kit/src/user-config.ts
1468
- import { existsSync } from "fs";
1469
- import { homedir as homedir2 } from "os";
1470
- import { join as join3 } from "path";
1471
- import process11 from "process";
1472
- function configBase(where = {}) {
1473
- const xdg = where.xdg ?? (where.home === undefined ? process11.env.XDG_CONFIG_HOME : undefined);
1474
- return xdg !== undefined && xdg !== "" ? xdg : join3(where.home ?? homedir2(), ".config");
1475
- }
1476
- function userConfigPath(bin, where = {}) {
1477
- return join3(configBase(where), "kaynooo-cli", `${bin}.json`);
1729
+ // ../kit/src/workspace-root.ts
1730
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1731
+ import { homedir as homedir4 } from "os";
1732
+ import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
1733
+ import process15 from "process";
1734
+ function expandHome(path, home) {
1735
+ if (path === "~")
1736
+ return home;
1737
+ return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
1738
+ }
1739
+ function configured(env, home) {
1740
+ const path = userConfigPath("config", { home, xdg: env.XDG_CONFIG_HOME });
1741
+ if (!existsSync4(path))
1742
+ return;
1743
+ try {
1744
+ const parsed = JSON.parse(readFileSync3(path, "utf8"));
1745
+ const folder = typeof parsed === "object" && parsed !== null ? parsed.workspace : undefined;
1746
+ return typeof folder === "string" && folder !== "" ? folder : undefined;
1747
+ } catch {
1748
+ return;
1749
+ }
1478
1750
  }
1479
- function userConfigReadPath(bin, legacy = [], where = {}) {
1480
- const current = userConfigPath(bin, where);
1481
- if (existsSync(current))
1482
- return current;
1483
- const base = configBase(where);
1484
- return legacy.map((parts) => join3(base, ...parts)).find((path) => existsSync(path)) ?? current;
1751
+ function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
1752
+ const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1753
+ return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1485
1754
  }
1486
- var init_user_config = () => {};
1755
+ var init_workspace_root = __esm(() => {
1756
+ init_user_config();
1757
+ });
1487
1758
 
1488
1759
  // ../kit/src/index.ts
1489
1760
  var init_src = __esm(() => {
@@ -1497,15 +1768,18 @@ var init_src = __esm(() => {
1497
1768
  init_git();
1498
1769
  init_limit();
1499
1770
  init_logs();
1771
+ init_mode();
1500
1772
  init_process();
1501
1773
  init_secrets();
1502
1774
  init_sessions();
1503
1775
  init_size();
1504
1776
  init_style();
1505
1777
  init_text();
1778
+ init_theme();
1506
1779
  init_tool();
1507
1780
  init_usage();
1508
1781
  init_user_config();
1782
+ init_workspace_root();
1509
1783
  });
1510
1784
 
1511
1785
  // src/semver.ts
@@ -2232,7 +2506,7 @@ function parseSpec(text) {
2232
2506
  function isStable(version) {
2233
2507
  return !version.includes("-");
2234
2508
  }
2235
- function resolve(packument, request) {
2509
+ function resolve4(packument, request) {
2236
2510
  const tags = packument["dist-tags"] ?? {};
2237
2511
  const versions = Object.keys(packument.versions ?? {});
2238
2512
  const wanted = request === undefined || request === "" ? "latest" : request;
@@ -2277,7 +2551,7 @@ function analyze(input) {
2277
2551
  return report;
2278
2552
  }
2279
2553
  const latest = packument["dist-tags"]?.latest;
2280
- const version = resolve(packument, spec.request);
2554
+ const version = resolve4(packument, spec.request);
2281
2555
  const entry = version === undefined ? undefined : packument.versions?.[version];
2282
2556
  report.description = packument.description;
2283
2557
  report.license = licenseOf(entry?.license) ?? licenseOf(packument.license);
@@ -2344,9 +2618,9 @@ var init_analyze = __esm(() => {
2344
2618
  });
2345
2619
 
2346
2620
  // src/config.ts
2347
- import { homedir as homedir3 } from "os";
2348
- import { dirname as dirname3, join as join4 } from "path";
2349
- import process13 from "process";
2621
+ import { homedir as homedir5 } from "os";
2622
+ import { dirname as dirname5, join as join7 } from "path";
2623
+ import process17 from "process";
2350
2624
  function expand2(value, env) {
2351
2625
  let missing = false;
2352
2626
  const expanded = value.replace(ENV_REFERENCE, (_, braced, bare) => {
@@ -2435,18 +2709,18 @@ async function readIfThere(path) {
2435
2709
  const file = Bun.file(path);
2436
2710
  return await file.exists() ? file.text() : undefined;
2437
2711
  }
2438
- async function loadConfigs(cwd = process13.cwd(), env = process13.env, home = homedir3()) {
2712
+ async function loadConfigs(cwd = process17.cwd(), env = process17.env, home = homedir5()) {
2439
2713
  const directories = [];
2440
- for (let dir = cwd;!directories.includes(dir); dir = dirname3(dir))
2714
+ for (let dir = cwd;!directories.includes(dir); dir = dirname5(dir))
2441
2715
  directories.push(dir);
2442
2716
  if (!directories.includes(home))
2443
2717
  directories.push(home);
2444
2718
  const configs = [];
2445
2719
  for (const dir of directories) {
2446
- const bunfig = await readIfThere(join4(dir, "bunfig.toml"));
2447
- const npmrc = await readIfThere(join4(dir, ".npmrc"));
2720
+ const bunfig = await readIfThere(join7(dir, "bunfig.toml"));
2721
+ const npmrc = await readIfThere(join7(dir, ".npmrc"));
2448
2722
  if (bunfig !== undefined)
2449
- configs.push(readable(join4(dir, "bunfig.toml"), () => parseBunfig(bunfig, env)));
2723
+ configs.push(readable(join7(dir, "bunfig.toml"), () => parseBunfig(bunfig, env)));
2450
2724
  if (npmrc !== undefined)
2451
2725
  configs.push(parseNpmrc(npmrc, env));
2452
2726
  }
@@ -2462,12 +2736,14 @@ function parseSettings(text) {
2462
2736
  settings.licenses = raw.licenses;
2463
2737
  if (isSeverity(raw?.blockSeverity))
2464
2738
  settings.blockSeverity = raw.blockSeverity;
2739
+ if (typeof raw?.minAge === "number" && Number.isInteger(raw.minAge) && raw.minAge >= 0)
2740
+ settings.minAge = raw.minAge;
2465
2741
  return settings;
2466
2742
  }
2467
- async function loadSettings(cwd = process13.cwd(), home) {
2743
+ async function loadSettings(cwd = process17.cwd(), home) {
2468
2744
  const files = [];
2469
- for (let dir = cwd;!files.includes(join4(dir, SETTINGS_FILE)); dir = dirname3(dir))
2470
- files.push(join4(dir, SETTINGS_FILE));
2745
+ for (let dir = cwd;!files.includes(join7(dir, SETTINGS_FILE)); dir = dirname5(dir))
2746
+ files.push(join7(dir, SETTINGS_FILE));
2471
2747
  files.push(userConfigReadPath("pkg", [["pkg", "config.json"]], { home }));
2472
2748
  const settings = {};
2473
2749
  for (const file of files) {
@@ -2477,6 +2753,7 @@ async function loadSettings(cwd = process13.cwd(), home) {
2477
2753
  const found = readable(file, () => parseSettings(text));
2478
2754
  settings.licenses ??= found.licenses;
2479
2755
  settings.blockSeverity ??= found.blockSeverity;
2756
+ settings.minAge ??= found.minAge;
2480
2757
  }
2481
2758
  return settings;
2482
2759
  }
@@ -2579,8 +2856,8 @@ var init_pin = __esm(() => {
2579
2856
  });
2580
2857
 
2581
2858
  // src/consumers.ts
2582
- import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "fs";
2583
- import { dirname as dirname4, join as join5, relative } from "path";
2859
+ import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync4 } from "fs";
2860
+ import { dirname as dirname6, join as join8, relative } from "path";
2584
2861
  function packageFiles(dir, depth, found) {
2585
2862
  let entries;
2586
2863
  try {
@@ -2590,41 +2867,76 @@ function packageFiles(dir, depth, found) {
2590
2867
  }
2591
2868
  for (const entry of entries) {
2592
2869
  if (entry.isFile() && entry.name === "package.json")
2593
- found.push(join5(dir, entry.name));
2870
+ found.push(join8(dir, entry.name));
2594
2871
  else if (entry.isDirectory() && depth < MAX_DEPTH && !entry.name.startsWith(".") && !SKIPPED.has(entry.name))
2595
- packageFiles(join5(dir, entry.name), depth + 1, found);
2872
+ packageFiles(join8(dir, entry.name), depth + 1, found);
2596
2873
  }
2597
2874
  return found;
2598
2875
  }
2599
2876
  function managerFor(dir, root) {
2600
- for (let at = dir;; at = dirname4(at)) {
2601
- const lockfile = LOCKFILES.find(([file]) => existsSync2(join5(at, file)));
2877
+ for (let at = dir;; at = dirname6(at)) {
2878
+ const lockfile = LOCKFILES.find(([file]) => existsSync5(join8(at, file)));
2602
2879
  if (lockfile !== undefined)
2603
2880
  return lockfile[1];
2604
- if (at === root || at === dirname4(at))
2881
+ if (at === root || at === dirname6(at))
2605
2882
  return "bun";
2606
2883
  }
2607
2884
  }
2885
+ function readManifest(path) {
2886
+ try {
2887
+ return JSON.parse(readFileSync4(path, "utf8"));
2888
+ } catch {
2889
+ return;
2890
+ }
2891
+ }
2608
2892
  function findConsumers(name, root) {
2609
2893
  const consumers = [];
2610
2894
  for (const path of packageFiles(root, 0, []).sort()) {
2611
- let manifest;
2612
- try {
2613
- manifest = JSON.parse(readFileSync2(path, "utf8"));
2614
- } catch {
2895
+ const manifest = readManifest(path);
2896
+ if (manifest === undefined)
2615
2897
  continue;
2898
+ const seen = new Set;
2899
+ for (const kind of KINDS) {
2900
+ for (const [key, spec] of Object.entries(manifest[kind] ?? {})) {
2901
+ const aliased = typeof spec === "string" && key !== name && ALIAS.exec(spec)?.[1] === name;
2902
+ if (typeof spec === "string" && (key === name || aliased) && !seen.has(key)) {
2903
+ seen.add(key);
2904
+ consumers.push({ dir: relative(root, dirname6(path)) || ".", path, kind, spec, ...aliased ? { alias: key } : {}, manager: managerFor(dirname6(path), root) });
2905
+ }
2906
+ }
2616
2907
  }
2617
- const kind = KINDS.find((each) => typeof manifest[each]?.[name] === "string");
2618
- const spec = kind === undefined ? undefined : manifest[kind]?.[name];
2619
- if (kind !== undefined && spec !== undefined)
2620
- consumers.push({ dir: relative(root, dirname4(path)) || ".", path, kind, spec, manager: managerFor(dirname4(path), root) });
2621
2908
  }
2622
2909
  return consumers;
2623
2910
  }
2911
+ function similarDependencies(name, root) {
2912
+ const base = name.slice(name.lastIndexOf("/") + 1).toLowerCase();
2913
+ const found = new Set;
2914
+ for (const path of packageFiles(root, 0, []).sort()) {
2915
+ const manifest = readManifest(path);
2916
+ for (const kind of KINDS) {
2917
+ for (const [key, spec] of Object.entries(manifest?.[kind] ?? {})) {
2918
+ const target = typeof spec === "string" ? ALIAS.exec(spec)?.[1] : undefined;
2919
+ for (const candidate of [key, target]) {
2920
+ const last = candidate?.slice(candidate.lastIndexOf("/") + 1).toLowerCase();
2921
+ if (candidate !== undefined && last !== undefined && candidate !== name && last.length >= MIN_SIMILAR && base.length >= MIN_SIMILAR && (last.includes(base) || base.includes(last)))
2922
+ found.add(candidate);
2923
+ }
2924
+ }
2925
+ }
2926
+ }
2927
+ return [...found].toSorted().slice(0, 5);
2928
+ }
2624
2929
  function isLocal(consumer) {
2625
- return LOCAL_SPEC.test(consumer.spec);
2930
+ return consumer.alias === undefined && LOCAL_SPEC.test(consumer.spec);
2931
+ }
2932
+ function wantedVersion(consumer) {
2933
+ return consumer.alias === undefined ? consumer.spec : ALIAS.exec(consumer.spec)?.[2] ?? consumer.spec;
2626
2934
  }
2627
2935
  function addCommand(consumer, name, version) {
2936
+ if (consumer.alias !== undefined) {
2937
+ const prefix = RANGE_PREFIX.exec(wantedVersion(consumer))?.[0] ?? "";
2938
+ return ["bun", "add", ...KIND_FLAGS[consumer.kind], ...prefix === "" ? ["--exact"] : [], "--no-cache", `${consumer.alias}@npm:${name}@${prefix}${version}`];
2939
+ }
2628
2940
  return ["bun", "add", ...KIND_FLAGS[consumer.kind], "--exact", "--no-cache", `${name}@${version}`];
2629
2941
  }
2630
2942
  function registryDependencies(text) {
@@ -2636,14 +2948,16 @@ function registryDependencies(text) {
2636
2948
  }
2637
2949
  return REGISTRY_KINDS.flatMap((kind) => Object.entries(manifest?.[kind] ?? {}).flatMap(([name, spec]) => typeof spec === "string" && !LOCAL_SPEC.test(spec) ? [{ name, kind, spec }] : []));
2638
2950
  }
2639
- var KINDS, SKIPPED, MAX_DEPTH = 5, LOCAL_SPEC, KIND_FLAGS, REGISTRY_KINDS;
2951
+ var KINDS, SKIPPED, MAX_DEPTH = 5, LOCAL_SPEC, ALIAS, MIN_SIMILAR = 3, KIND_FLAGS, RANGE_PREFIX, REGISTRY_KINDS;
2640
2952
  var init_consumers = __esm(() => {
2641
2953
  init_src();
2642
2954
  init_pin();
2643
2955
  KINDS = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
2644
2956
  SKIPPED = new Set(["node_modules", "dist", "build", "vendor", "target", "coverage"]);
2645
2957
  LOCAL_SPEC = /[:/]/;
2958
+ ALIAS = /^npm:(@[^@/]+\/[^@/]+|[^@/]+)@(.+)$/;
2646
2959
  KIND_FLAGS = { dependencies: [], devDependencies: ["--dev"], optionalDependencies: ["--optional"], peerDependencies: ["--peer"] };
2960
+ RANGE_PREFIX = /^[~^]/;
2647
2961
  REGISTRY_KINDS = KINDS.filter((kind) => kind !== "peerDependencies");
2648
2962
  });
2649
2963
 
@@ -2710,7 +3024,8 @@ async function check(args) {
2710
3024
  fail(values.from === undefined ? `a package name is needed
2711
3025
 
2712
3026
  ${usage2}` : `${values.from} has no registry dependency to check`);
2713
- const context = { configs: await loadConfigs(), settings: await loadSettings(), minAgeDays: wholeNumber(values["min-age"], "min-age", DEFAULT_MIN_AGE_DAYS, 0) };
3027
+ const settings = await loadSettings();
3028
+ const context = { configs: await loadConfigs(), settings, minAgeDays: wholeNumber(values["min-age"], "min-age", settings.minAge ?? DEFAULT_MIN_AGE_DAYS, 0) };
2714
3029
  const reports = await Promise.all(positionals.map(async (text) => checkPackage(text, context)));
2715
3030
  if (values.json === true)
2716
3031
  printJson(reports.length === 1 ? reports[0] : reports);
@@ -2737,7 +3052,7 @@ var init_check = __esm(() => {
2737
3052
  EXITS = [[0, "every package passes"], [1, "one is blocked: missing, the version asked for is under the minimum age or has no date, its licence is outside the allowlist or an advisory reaches the threshold"], [2, "it could not check (the registry unreachable, slow or answering badly, a broken .pkgrc.json, bunfig.toml or .npmrc) or a usage error"]];
2738
3053
  options = {
2739
3054
  json: jsonOption(),
2740
- "min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS})` },
3055
+ "min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS}, or the minAge setting)` },
2741
3056
  from: { type: "string", description: "check the dependencies of this package.json" }
2742
3057
  };
2743
3058
  WORDS = /\s+/;
@@ -2813,8 +3128,8 @@ var exports_audit = {};
2813
3128
  __export(exports_audit, {
2814
3129
  audit: () => audit
2815
3130
  });
2816
- import { join as join6, resolve as resolve2 } from "path";
2817
- import process14 from "process";
3131
+ import { join as join9, resolve as resolve5 } from "path";
3132
+ import process18 from "process";
2818
3133
  function hasFinding(audited) {
2819
3134
  return audited.blocked || audited.warnings.length > 0 || audited.advisories.length > 0;
2820
3135
  }
@@ -2826,14 +3141,11 @@ async function auditPackages(packages, context) {
2826
3141
  packuments.set(key, fetchPackument(name, registry, context.fetcher));
2827
3142
  return packuments.get(key);
2828
3143
  };
2829
- const looked = [];
2830
- for (let start = 0;start < packages.length; start += BATCH) {
2831
- looked.push(...await Promise.all(packages.slice(start, start + BATCH).map(async ({ name, version }) => {
2832
- const registry = registryFor(name, context.configs);
2833
- const input = { spec: { name, request: version }, packument: await lookup(name, registry), registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays, licenses: context.settings.licenses };
2834
- return { name, version, registry, input, safe: analyze(input).safe?.version };
2835
- })));
2836
- }
3144
+ const looked = await pool(packages, BATCH, async ({ name, version }) => {
3145
+ const registry = registryFor(name, context.configs);
3146
+ const input = { spec: { name, request: version }, packument: await lookup(name, registry), registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays, licenses: context.settings.licenses };
3147
+ return { name, version, registry, input, safe: analyze(input).safe?.version };
3148
+ });
2837
3149
  const registries = new Map;
2838
3150
  for (const { name, version, registry, safe } of looked) {
2839
3151
  const group = registries.get(registry.url) ?? { registry, versions: {} };
@@ -2873,17 +3185,18 @@ async function audit(args) {
2873
3185
  const level = values.level ?? "moderate";
2874
3186
  if (!isSeverity(level))
2875
3187
  fail(`--level takes ${SEVERITIES.join(", ")}, not ${level}`);
2876
- const dir = resolve2(asked ?? process14.cwd());
2877
- const lock = Bun.file(join6(dir, "bun.lock"));
3188
+ const dir = resolve5(asked ?? process18.cwd());
3189
+ const lock = Bun.file(join9(dir, "bun.lock"));
2878
3190
  if (!await lock.exists())
2879
3191
  fail(`no bun.lock in ${dir}`);
2880
3192
  const text = await lock.text();
2881
3193
  const production = values.prod === true ? productionPackages(text) : undefined;
2882
3194
  const packages = parseBunLock(text).filter(({ name, version }) => production?.has(`${name}@${version}`) ?? true);
3195
+ const settings = await loadSettings(dir);
2883
3196
  const context = {
2884
3197
  configs: await loadConfigs(dir),
2885
- settings: await loadSettings(dir),
2886
- minAgeDays: wholeNumber(values["min-age"], "min-age", DEFAULT_MIN_AGE_DAYS, 0),
3198
+ settings,
3199
+ minAgeDays: wholeNumber(values["min-age"], "min-age", settings.minAge ?? DEFAULT_MIN_AGE_DAYS, 0),
2887
3200
  level,
2888
3201
  ignore: values.ignore ?? []
2889
3202
  };
@@ -2914,7 +3227,7 @@ var init_audit = __esm(() => {
2914
3227
  EXITS2 = [[0, "nothing blocks"], [1, "a package is missing, too fresh or outside the licence allowlist, or an advisory reaches --level"], [2, "the registry could not be reached or answered badly (a warning says which, and nothing is reported as clean), a usage error or no bun.lock"]];
2915
3228
  options2 = {
2916
3229
  json: jsonOption("[{name, version, license, blocked, warnings, advisories}] for the packages with a finding"),
2917
- "min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS})` },
3230
+ "min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS}, or the minAge setting)` },
2918
3231
  level: { type: "string", description: "lowest advisory severity listed and failing: low, moderate, high, critical (moderate)" },
2919
3232
  prod: { type: "boolean", description: "only the packages a production dependency or an optional one of a workspace reaches" },
2920
3233
  ignore: { type: "string", multiple: true, description: "an advisory skipped by GHSA or numeric id, repeatable" }
@@ -2926,8 +3239,8 @@ var exports_outdated = {};
2926
3239
  __export(exports_outdated, {
2927
3240
  outdatedCommand: () => outdatedCommand
2928
3241
  });
2929
- import { existsSync as existsSync3 } from "fs";
2930
- import { join as join7, resolve as resolve3 } from "path";
3242
+ import { existsSync as existsSync6 } from "fs";
3243
+ import { join as join10, resolve as resolve6 } from "path";
2931
3244
  function currentOf(name, spec, locked) {
2932
3245
  const pinned = locked.filter((each) => each.name === name && Bun.semver.satisfies(each.version, spec)).map((each) => each.version).sort(Bun.semver.order).at(-1);
2933
3246
  const written = FIRST_VERSION.exec(spec)?.[0];
@@ -2942,35 +3255,31 @@ function changeOf(current, next) {
2942
3255
  async function outdated(manifest, context) {
2943
3256
  const configs = await loadConfigs();
2944
3257
  const dependencies = registryDependencies(manifest);
2945
- const rows = [];
2946
- for (let start = 0;start < dependencies.length; start += BATCH2) {
2947
- const looked = await Promise.all(dependencies.slice(start, start + BATCH2).map(async ({ name, kind, spec }) => {
2948
- const registry = registryFor(name, configs);
2949
- const packument = await fetchPackument(name, registry, context.fetcher);
2950
- if (packument === undefined) {
2951
- warn(`${name} is not on ${new URL(registry.url).host}`);
2952
- return;
2953
- }
2954
- const { safe, latest } = analyze({ spec: { name }, packument, registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays });
2955
- const current = currentOf(name, spec, context.locked);
2956
- if (safe === undefined || current === undefined || Bun.semver.order(safe.version, current) <= 0)
2957
- return;
2958
- const row = { name, kind, spec, current, safe: safe.version, change: changeOf(current, safe.version), published: safe.published };
2959
- return latest !== undefined && latest.version !== safe.version && Bun.semver.order(latest.version, safe.version) > 0 ? { ...row, latest: latest.version } : row;
2960
- }));
2961
- rows.push(...looked.filter((row) => row !== undefined));
2962
- }
2963
- return rows.sort((a, b) => a.name.localeCompare(b.name));
3258
+ const looked = await pool(dependencies, BATCH2, async ({ name, kind, spec }) => {
3259
+ const registry = registryFor(name, configs);
3260
+ const packument = await fetchPackument(name, registry, context.fetcher);
3261
+ if (packument === undefined) {
3262
+ warn(`${name} is not on ${new URL(registry.url).host}`);
3263
+ return;
3264
+ }
3265
+ const { safe, latest } = analyze({ spec: { name }, packument, registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays });
3266
+ const current = currentOf(name, spec, context.locked);
3267
+ if (safe === undefined || current === undefined || Bun.semver.order(safe.version, current) <= 0)
3268
+ return;
3269
+ const row = { name, kind, spec, current, safe: safe.version, change: changeOf(current, safe.version), published: safe.published };
3270
+ return latest !== undefined && latest.version !== safe.version && Bun.semver.order(latest.version, safe.version) > 0 ? { ...row, latest: latest.version } : row;
3271
+ });
3272
+ return looked.filter((row) => row !== undefined).sort((a, b) => a.name.localeCompare(b.name));
2964
3273
  }
2965
3274
  async function outdatedCommand(args) {
2966
3275
  const { values, positionals: [dir = "."] } = parse(args, usage4, options3, { positionals: ["[dir]"], exits: EXITS3 });
2967
- const folder = resolve3(dir);
2968
- const manifest = Bun.file(join7(folder, "package.json"));
3276
+ const folder = resolve6(dir);
3277
+ const manifest = Bun.file(join10(folder, "package.json"));
2969
3278
  if (!await manifest.exists())
2970
3279
  fail(`no package.json in ${folder}`);
2971
- const lockPath = join7(folder, "bun.lock");
2972
- const locked = existsSync3(lockPath) ? parseBunLock(await Bun.file(lockPath).text()) : [];
2973
- const rows = await outdated(await manifest.text(), { minAgeDays: wholeNumber(values["min-age"], "min-age", DEFAULT_MIN_AGE_DAYS, 0), locked });
3280
+ const lockPath = join10(folder, "bun.lock");
3281
+ const locked = existsSync6(lockPath) ? parseBunLock(await Bun.file(lockPath).text()) : [];
3282
+ const rows = await outdated(await manifest.text(), { minAgeDays: wholeNumber(values["min-age"], "min-age", (await loadSettings(folder)).minAge ?? DEFAULT_MIN_AGE_DAYS, 0), locked });
2974
3283
  const { shown, footer } = capped(rows, limitOf(values, OUTDATED_LIMIT));
2975
3284
  if (values.json === true)
2976
3285
  printJson(shown);
@@ -2996,7 +3305,7 @@ var init_outdated = __esm(() => {
2996
3305
  FIRST_VERSION = /\d+(?:\.\d+){0,2}(?:-[\w.-]+)?/;
2997
3306
  DOT = /[.-]/;
2998
3307
  options3 = {
2999
- "min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS})` },
3308
+ "min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS}, or the minAge setting)` },
3000
3309
  ...limitOptions(OUTDATED_LIMIT),
3001
3310
  json: jsonOption("[{name, kind, spec, current, safe, change, published, latest?}]")
3002
3311
  };
@@ -3008,9 +3317,8 @@ __export(exports_bump, {
3008
3317
  ROOT_OPTION: () => ROOT_OPTION,
3009
3318
  bump: () => bump
3010
3319
  });
3011
- import { existsSync as existsSync4 } from "fs";
3012
- import { homedir as homedir4 } from "os";
3013
- import { dirname as dirname5, join as join8, relative as relative2 } from "path";
3320
+ import { existsSync as existsSync7 } from "fs";
3321
+ import { basename, dirname as dirname7, join as join11, relative as relative2 } from "path";
3014
3322
  async function lookup(name, registry, fetcher) {
3015
3323
  try {
3016
3324
  return { packument: await fetchPackument(name, registry, fetcher) };
@@ -3070,11 +3378,11 @@ async function vet(name, version, settings) {
3070
3378
  return false;
3071
3379
  }
3072
3380
  function lockfileOf(dir, root) {
3073
- for (let at = dir;; at = dirname5(at)) {
3074
- const found = ["bun.lock", "bun.lockb"].find((file) => existsSync4(join8(at, file)));
3381
+ for (let at = dir;; at = dirname7(at)) {
3382
+ const found = ["bun.lock", "bun.lockb"].find((file) => existsSync7(join11(at, file)));
3075
3383
  if (found !== undefined)
3076
- return relative2(dir, join8(at, found));
3077
- if (at === root || at === dirname5(at))
3384
+ return relative2(dir, join11(at, found));
3385
+ if (at === root || at === dirname7(at))
3078
3386
  return;
3079
3387
  }
3080
3388
  }
@@ -3093,26 +3401,38 @@ async function checkAndCommit(name, version, where, root, run) {
3093
3401
  return committed.code === 0 ? undefined : `gc exited ${committed.code}: ${committed.text.trim().split(`
3094
3402
  `).at(-1) ?? ""}`;
3095
3403
  }
3404
+ function matcher(patterns) {
3405
+ const globs = patterns.map((pattern) => new Bun.Glob(pattern));
3406
+ return (dir) => globs.some((glob) => glob.match(dir) || glob.match(basename(dir)));
3407
+ }
3096
3408
  async function bumpConsumers(name, version, settings) {
3097
- const found = findConsumers(name, settings.root);
3409
+ const everyone = findConsumers(name, settings.root);
3410
+ const isOnly = matcher(settings.only ?? []);
3411
+ const isExcept = matcher(settings.except ?? []);
3412
+ const found = everyone.filter((each) => (settings.only === undefined || settings.only.length === 0 || isOnly(each.dir)) && !isExcept(each.dir));
3098
3413
  const consumers = found.filter((each) => !isLocal(each));
3414
+ const left = everyone.length - found.length;
3099
3415
  const local = found.length - consumers.length;
3100
3416
  const run = settings.run ?? (async (argv, cwd) => runCommand(argv, { cwd }));
3101
3417
  const committed = [];
3102
3418
  const failing = [];
3103
3419
  const skipped = [];
3104
3420
  let isClean = true;
3105
- if (found.length === 0)
3106
- note(`nothing under ${settings.root} depends on ${name}`);
3421
+ if (everyone.length === 0) {
3422
+ const similar = similarDependencies(name, settings.root);
3423
+ note(`nothing under ${settings.root} depends on ${name}`, similar.length === 0 ? undefined : `did you mean ${similar.join(", ")}`);
3424
+ } else if (left > 0) {
3425
+ note(`${left} folder${left === 1 ? "" : "s"} left out by --only or --except`);
3426
+ }
3107
3427
  if (local > 0)
3108
3428
  note(`${local} non-registry dependenc${local === 1 ? "y" : "ies"} (workspace:, file:, git, URL, alias, catalog:)`, "left as they are");
3109
3429
  for (const consumer of consumers) {
3110
3430
  const argv = addCommand(consumer, name, version);
3111
- const where = join8(settings.root, consumer.dir);
3431
+ const where = join11(settings.root, consumer.dir);
3112
3432
  if (consumer.kind === "peerDependencies") {
3113
3433
  skipped.push(consumer.dir);
3114
3434
  note(consumer.dir, `peer range ${consumer.spec}, left as it is`);
3115
- } else if (consumer.spec === version) {
3435
+ } else if ((consumer.alias === undefined ? consumer.spec : wantedVersion(consumer).replace(RANGE_PREFIX, "")) === version) {
3116
3436
  skipped.push(consumer.dir);
3117
3437
  note(consumer.dir, `already on ${version}`);
3118
3438
  } else if (consumer.manager !== "bun") {
@@ -3153,12 +3473,14 @@ async function bumpConsumers(name, version, settings) {
3153
3473
  async function bump(args) {
3154
3474
  const { values, positionals: [name, asked] } = parse(args, usage5, options4, { positionals: ["<name>", "[version]"] });
3155
3475
  const settings = {
3156
- root: values.root ?? join8(homedir4(), "Workspace"),
3476
+ root: workspaceRoot({ given: values.root }),
3157
3477
  configs: await loadConfigs(),
3158
3478
  timeout: duration(values.timeout, "timeout", 10 * 60000),
3159
3479
  isDryRun: values["dry-run"] === true,
3160
3480
  isAll: values["all-consumers"] === true,
3161
3481
  isForced: values.force === true,
3482
+ only: values.only,
3483
+ except: values.except,
3162
3484
  pkgSettings: await loadSettings(),
3163
3485
  minAgeDays: wholeNumber(values["min-age"], "min-age", 0, 0)
3164
3486
  };
@@ -3171,7 +3493,8 @@ var usage5 = `pkg bump <name> [version]
3171
3493
 
3172
3494
  Waits until the registry serves the version (the latest when none is given, an exact version otherwise), vets it as \`pkg check\` does (advisories, licence allowlist, and a minimum age only when --min-age asks for one), then runs \`bun add --exact --no-cache\` in each folder under --root whose package.json depends on the package, the kind of dependency kept, a line per folder.
3173
3495
  A version the vetting blocks is refused before any folder is touched, unless --force is given.
3174
- A dependency that is not a registry version (workspace:, link:, file:, git, a URL, an npm: alias, catalog:), a peer range, a folder already on the version and one whose lockfile pins another manager are left as they are, each said so.
3496
+ A dependency declared through an alias of the package (\`"kay": "npm:@kaynooo/kayjs@~1.77.0"\`) is bumped under its own key, keeping the \`~\` or \`^\` of its range; --only and --except narrow the folders by name or glob (\`app\`, \`kay-*\`, a path relative to --root).
3497
+ A dependency that is not a registry version (workspace:, link:, file:, git, a URL, an npm: alias of another package, catalog:), a peer range, a folder already on the version and one whose lockfile pins another manager are left as they are, each said so.
3175
3498
  With --all-consumers a folder whose package.json or lockfile already has uncommitted changes is left alone, and each folder whose install went through then runs its own \`check\` (the check bin) and is committed with \`gc 'chore(deps): bump <name> to <version>' -- package.json <lockfile>\` only when that passes; a failing one is left uncommitted and listed in the summary with the skipped ones, and nothing is ever pushed.
3176
3499
 
3177
3500
  Exits 0 when every install ran or was left as it is (with --all-consumers, and every check passed and every commit landed), 1 when the vetting refuses the version, an install, a check or a commit fails or the registry has no such package, 2 when the version never shows within the timeout (a registry that cannot be reached is retried until then) or on a usage error.`, ROOT_OPTION, options4, POLL = 5000;
@@ -3183,11 +3506,13 @@ var init_bump = __esm(() => {
3183
3506
  init_registry();
3184
3507
  init_semver();
3185
3508
  init_check();
3186
- ROOT_OPTION = { type: "string", description: "the folder holding the repositories (~/Workspace)" };
3509
+ ROOT_OPTION = { type: "string", description: "the folder holding the repositories (the workspace of the user config or KAYNOOO_WORKSPACE, ~/Workspace by default)" };
3187
3510
  options4 = {
3188
3511
  root: ROOT_OPTION,
3189
3512
  timeout: { type: "string", short: "t", description: "how long to wait for the registry (10m): 30s, 5m, 1h" },
3190
3513
  "all-consumers": { type: "boolean", description: "after each install run the folder's check and commit it through gc when it passes" },
3514
+ only: { type: "string", multiple: true, description: "bump only the folders matching this name or glob, repeatable" },
3515
+ except: { type: "string", multiple: true, description: "leave the folders matching this name or glob alone, repeatable" },
3191
3516
  "dry-run": { type: "boolean", description: "print what would run, changing nothing" },
3192
3517
  force: { type: "boolean", description: "bump even when the version is blocked by the vetting" },
3193
3518
  "min-age": { type: "string", description: "days a version must be old (0: a bump adopts a release on purpose, often one just made)" }
@@ -3199,24 +3524,24 @@ var exports_consumers = {};
3199
3524
  __export(exports_consumers, {
3200
3525
  consumers: () => consumers
3201
3526
  });
3202
- import { homedir as homedir5 } from "os";
3203
- import { join as join9 } from "path";
3204
3527
  function consumers(args) {
3205
3528
  const { values, positionals: [name] } = parse(args, usage6, options5, { positionals: ["<name>"] });
3206
- const root = values.root ?? join9(homedir5(), "Workspace");
3529
+ const root = workspaceRoot({ given: values.root });
3207
3530
  const { shown, footer } = capped(findConsumers(name, root), limitOf(values, CONSUMERS_LIMIT));
3208
- if (values.json === true)
3531
+ if (values.json === true) {
3209
3532
  printJson(shown);
3210
- else if (shown.length === 0)
3211
- console.log(`nothing under ${root} depends on ${name}`);
3212
- else
3213
- console.log([table([["FOLDER", "KIND", "VERSION", "MANAGER"], ...shown.map((each) => [each.dir, each.kind, each.spec, each.manager])], { header: true }), ...footer === undefined ? [] : [footer]].join(`
3533
+ } else if (shown.length === 0) {
3534
+ const similar = similarDependencies(name, root);
3535
+ console.log(`nothing under ${root} depends on ${name}${similar.length === 0 ? "" : `, did you mean ${similar.join(", ")}`}`);
3536
+ } else {
3537
+ console.log([table([["FOLDER", "KIND", "VERSION", "MANAGER"], ...shown.map((each) => [each.dir, each.alias === undefined ? each.kind : `${each.kind} as ${each.alias}`, each.spec, each.manager])], { header: true }), ...footer === undefined ? [] : [footer]].join(`
3214
3538
  `));
3539
+ }
3215
3540
  return 0;
3216
3541
  }
3217
3542
  var usage6 = `pkg consumers <name>
3218
3543
 
3219
- Lists the folders under --root whose package.json depends on the package: the folder, the kind of dependency, the version it asks for and the manager its lockfile pins, 30 at most with the count of the rest after them (--limit <n>, --full for all; --json is never cut unless --limit is given).
3544
+ Lists the folders under --root whose package.json depends on the package, by its own name or through an \`npm:\` alias of it (the alias key is shown after the kind): the folder, the kind of dependency, the version it asks for and the manager its lockfile pins, 30 at most with the count of the rest after them (--limit <n>, --full for all; --json is never cut unless --limit is given).
3220
3545
 
3221
3546
  Exits 0 when it listed them, 2 on a usage error.`, CONSUMERS_LIMIT = 30, options5;
3222
3547
  var init_consumers2 = __esm(() => {
@@ -3232,8 +3557,8 @@ var init_consumers2 = __esm(() => {
3232
3557
 
3233
3558
  // src/cli.ts
3234
3559
  init_src();
3235
- import process15 from "process";
3236
- process15.exitCode = await runCli({
3560
+ import process19 from "process";
3561
+ process19.exitCode = await runCli({
3237
3562
  name: "pkg",
3238
3563
  about: "checks npm packages before they are added, and moves a lib's consumers onto a new release",
3239
3564
  replaces: "bun add on trust, and a bun info and sleep loop then a bun add per consumer",