@kaynooo/cli-pkg 0.8.0 → 0.9.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 +2 -2
  2. package/dist/cli.js +511 -195
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -54,8 +54,8 @@ pkg consumers @kaynooo/cli-kit
54
54
  pkg bump @kaynooo/cli-kit 0.8.0 --dry-run
55
55
  ```
56
56
 
57
- - `pkg consumers <name>` lists every `package.json` under `--root` (`~/Workspace`) depending on the package, `node_modules`, `dist`, `build`, `vendor`, `target`, `coverage` and dot folders left out and nothing deeper than 5 levels below `--root` (point `--root` at the folder to reach further): the folder, the kind of dependency, the version it asks for and the manager its nearest lockfile pins; `--json` for the rows.
58
- - `pkg bump <name> [version]` waits until the package's registry serves the version (every 5 s, `-t 10m`; the latest when none is given, an exact version otherwise, never a range or a tag), then vets it with the checks of `pkg check` (advisories, licence allowlist) before any folder is touched, and runs `bun add --exact --no-cache <name>@<version>` in each of those folders, one after another, as the same kind of dependency (`--dev`, `--optional`), a line per folder. A version the vetting blocks is refused with its reasons and exit 1; `--force` bumps it anyway. A bump adopts a release on purpose, often one just made, so it checks no minimum age unless `--min-age <days>` asks for one. A dependency that is not a registry version (`workspace:`, `link:`, `file:`, `git`, a URL, an `npm:` alias, `catalog:`), a `peerDependencies` range, a folder already on the version and one whose lockfile pins another manager are left alone and said so; `--dry-run` prints what would run. A transient registry error is retried until the timeout. It exits 1 when the vetting refuses the version, an install fails or the registry has no such package (at once, without waiting), 2 when the version never shows within the timeout.
57
+ - `pkg consumers <name>` lists every `package.json` under `--root` (the configured workspace folder, `~/Workspace` by default) depending on the package, `node_modules`, `dist`, `build`, `vendor`, `target`, `coverage` and dot folders left out and nothing deeper than 5 levels below `--root` (point `--root` at the folder to reach further): the folder, the kind of dependency, the version it asks for and the manager its nearest lockfile pins; `--json` for the rows.
58
+ - `pkg bump <name> [version]` waits until the package's registry serves the version (every 5 s, `-t 10m`; the latest when none is given, an exact version otherwise, never a range or a tag), then vets it with the checks of `pkg check` (advisories, licence allowlist) before any folder is touched, and runs `bun add --exact --no-cache <name>@<version>` in each of those folders, one after another, as the same kind of dependency (`--dev`, `--optional`), a line per folder. A version the vetting blocks is refused with its reasons and exit 1; `--force` bumps it anyway. A bump adopts a release on purpose, often one just made, so it checks no minimum age unless `--min-age <days>` asks for one. A dependency declared through an alias of the package (`"kay": "npm:@scope/name@~1.2.0"`) is found and bumped under its own key, keeping its `~` or `^`; `--only <name|glob>` and `--except <name|glob>` (repeatable) narrow the folders, and a package nothing depends on names similar dependencies. A dependency that is not a registry version (`workspace:`, `link:`, `file:`, `git`, a URL, another package's `npm:` alias, `catalog:`), a `peerDependencies` range, a folder already on the version and one whose lockfile pins another manager are left alone and said so; `--dry-run` prints what would run. A transient registry error is retried until the timeout. It exits 1 when the vetting refuses the version, an install fails or the registry has no such package (at once, without waiting), 2 when the version never shows within the timeout.
59
59
  - `pkg bump <name> [version] --all-consumers` leaves alone a folder whose `package.json` or lockfile already has uncommitted changes, so that `gc` never commits them as the bump, and goes on in each folder whose install went through: it runs the folder's own `check` and, only when that passes, commits with `gc 'chore(deps): bump <name> to <version>' -- package.json <lockfile>` (the `bun.lock` or `bun.lockb` nearest the folder, a monorepo's at its root). A folder whose check fails stays uncommitted. It ends on a summary line of the folders bumped and committed, bumped and failing, and skipped, exits 1 when an install, a check or a commit failed, and never pushes. With `--dry-run` it lists the `bun add`, `check` and `gc` each folder would run.
60
60
  - `pkg <name>` alone still runs `pkg check`.
61
61
  - `pkg check --from <package.json>` checks every registry dependency of a manifest (`dependencies`, `devDependencies` and `optionalDependencies`, each as `name@range` so it resolves what an install would; peer ranges and `workspace:`, `link:`, `file:`, git, URL and `npm:` sources left out). Names also come from stdin, separated by spaces or lines, with `-` as the argument or when nothing else names a package and stdin is piped; the three sources add up.
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bun
1
+ #!/usr/bin/env -S bun --no-env-file
2
2
  // @bun
3
3
  var __defProp = Object.defineProperty;
4
4
  var __returnValue = (v) => v;
@@ -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;
@@ -959,11 +1208,11 @@ function liveRegion(render, stream = process8.stderr, env = process8.env) {
959
1208
  clear();
960
1209
  restore();
961
1210
  release();
962
- process8.off("exit", onExit);
1211
+ process12.off("exit", onExit);
963
1212
  signals.release();
964
1213
  }
965
1214
  timer.unref();
966
- process8.on("exit", onExit);
1215
+ process12.on("exit", onExit);
967
1216
  return {
968
1217
  redraw: draw,
969
1218
  print: (text) => {
@@ -1002,14 +1251,14 @@ function cutToWidth(line, width) {
1002
1251
  return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
1003
1252
  }
1004
1253
  function swallowInput() {
1005
- const input = process8.stdin;
1254
+ const input = process12.stdin;
1006
1255
  if (!input.isTTY)
1007
1256
  return () => {
1008
1257
  return;
1009
1258
  };
1010
1259
  const onData = (data) => {
1011
1260
  if (data.includes(CTRL_C))
1012
- process8.kill(process8.pid, "SIGINT");
1261
+ process12.kill(process12.pid, "SIGINT");
1013
1262
  };
1014
1263
  input.setRawMode(true);
1015
1264
  input.on("data", onData);
@@ -1025,7 +1274,7 @@ function swallowInput() {
1025
1274
  };
1026
1275
  }
1027
1276
  function interceptOutput(clear) {
1028
- const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process8.stdout, "write"], [process8.stderr, "write"]];
1277
+ const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process12.stdout, "write"], [process12.stderr, "write"]];
1029
1278
  const wrapped = targets.map(([target, name]) => {
1030
1279
  const original = Reflect.get(target, name);
1031
1280
  const wrapper = (...args) => {
@@ -1077,20 +1326,20 @@ var init_logs = __esm(() => {
1077
1326
 
1078
1327
  // ../kit/src/usage.ts
1079
1328
  import { appendFileSync, mkdirSync } from "fs";
1080
- import { homedir } from "os";
1081
- import { dirname, isAbsolute, join } from "path";
1082
- import process9 from "process";
1329
+ import { homedir as homedir3 } from "os";
1330
+ import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1331
+ import process13 from "process";
1083
1332
  function noteUsageError(message) {
1084
1333
  usageError = message;
1085
1334
  }
1086
- function stateHome(env = process9.env) {
1335
+ function stateHome(env = process13.env) {
1087
1336
  const dir = env.XDG_STATE_HOME;
1088
- return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
1337
+ return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
1089
1338
  }
1090
- function usagePath(env = process9.env) {
1091
- return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
1339
+ function usagePath(env = process13.env) {
1340
+ return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
1092
1341
  }
1093
- function usageRecorded(env = process9.env) {
1342
+ function usageRecorded(env = process13.env) {
1094
1343
  const off = env.KAYNOOO_CLI_NO_USAGE;
1095
1344
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1096
1345
  }
@@ -1104,12 +1353,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1104
1353
  usageError = undefined;
1105
1354
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1106
1355
  }
1107
- function recordUsage(entry, env = process9.env) {
1356
+ function recordUsage(entry, env = process13.env) {
1108
1357
  if (!usageRecorded(env))
1109
1358
  return;
1110
1359
  try {
1111
1360
  const path = usagePath(env);
1112
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
1361
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
1113
1362
  appendFileSync(path, `${JSON.stringify(entry)}
1114
1363
  `, { mode: 384 });
1115
1364
  } catch {}
@@ -1122,9 +1371,9 @@ var init_usage = __esm(() => {
1122
1371
  });
1123
1372
 
1124
1373
  // ../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";
1374
+ import { readFileSync as readFileSync2, realpathSync } from "fs";
1375
+ import { dirname as dirname3, join as join5 } from "path";
1376
+ import process14 from "process";
1128
1377
  async function commandRows(all, colors) {
1129
1378
  const commands = shown(all);
1130
1379
  const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
@@ -1199,8 +1448,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1199
1448
  `);
1200
1449
  }
1201
1450
  function printError(prefix, message, hint, cause) {
1202
- const colors = paint(process10.stderr);
1203
- const styled = takesControlCodes(process10.stderr);
1451
+ const colors = paint(process14.stderr);
1452
+ const styled = takesControlCodes(process14.stderr);
1204
1453
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1205
1454
  const under = (label, text, tint) => text === undefined ? "" : `
1206
1455
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1219,7 +1468,7 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
1219
1468
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
1220
1469
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
1221
1470
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
1222
- if (error instanceof UsageError)
1471
+ if (error instanceof Exit && error.code === 2)
1223
1472
  noteUsageError(error.message);
1224
1473
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
1225
1474
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
@@ -1243,11 +1492,11 @@ async function dispatch(level, typed, { version, redact }) {
1243
1492
  }
1244
1493
  }
1245
1494
  if (name === undefined && level.path.length > 1) {
1246
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process10.stderr));
1495
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stderr));
1247
1496
  return 2;
1248
1497
  }
1249
1498
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1250
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process10.stdout));
1499
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stdout));
1251
1500
  return 0;
1252
1501
  }
1253
1502
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1362,17 +1611,17 @@ async function printCandidates(found) {
1362
1611
  return 0;
1363
1612
  }
1364
1613
  function packageVersion(entry = Bun.main) {
1365
- for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1614
+ for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1366
1615
  try {
1367
- const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
1616
+ const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1368
1617
  if (typeof version === "string")
1369
1618
  return version;
1370
1619
  } catch {}
1371
- if (dirname2(dir) === dir)
1620
+ if (dirname3(dir) === dir)
1372
1621
  return "0.0.0";
1373
1622
  }
1374
1623
  }
1375
- async function runCli(cli, argv = process10.argv.slice(2)) {
1624
+ async function runCli(cli, argv = process14.argv.slice(2)) {
1376
1625
  const version = cli.version ?? packageVersion();
1377
1626
  if (argv[0] === COMPLETE)
1378
1627
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
@@ -1411,11 +1660,6 @@ var init_cli = __esm(() => {
1411
1660
  };
1412
1661
  TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1413
1662
  });
1414
- // ../kit/src/config.ts
1415
- var init_config = __esm(() => {
1416
- init_args();
1417
- });
1418
-
1419
1663
  // ../kit/src/git.ts
1420
1664
  var init_git = __esm(() => {
1421
1665
  init_args();
@@ -1447,6 +1691,20 @@ var init_limit = __esm(() => {
1447
1691
  init_args();
1448
1692
  });
1449
1693
 
1694
+ // ../kit/src/pool.ts
1695
+ async function pool(items, limit, task) {
1696
+ const results = Array.from({ length: items.length });
1697
+ let next = 0;
1698
+ async function worker() {
1699
+ while (next < items.length) {
1700
+ const index = next++;
1701
+ results[index] = await task(items[index]);
1702
+ }
1703
+ }
1704
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
1705
+ return results;
1706
+ }
1707
+
1450
1708
  // ../kit/src/secrets.ts
1451
1709
  var SECRET_WORDS;
1452
1710
  var init_secrets = __esm(() => {
@@ -1464,26 +1722,35 @@ var init_sessions = __esm(() => {
1464
1722
  // ../kit/src/size.ts
1465
1723
  var init_size = () => {};
1466
1724
 
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`);
1725
+ // ../kit/src/workspace-root.ts
1726
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1727
+ import { homedir as homedir4 } from "os";
1728
+ import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
1729
+ import process15 from "process";
1730
+ function expandHome(path, home) {
1731
+ if (path === "~")
1732
+ return home;
1733
+ return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
1734
+ }
1735
+ function configured(env, home) {
1736
+ const path = userConfigPath("config", { home, xdg: env.XDG_CONFIG_HOME });
1737
+ if (!existsSync4(path))
1738
+ return;
1739
+ try {
1740
+ const parsed = JSON.parse(readFileSync3(path, "utf8"));
1741
+ const folder = typeof parsed === "object" && parsed !== null ? parsed.workspace : undefined;
1742
+ return typeof folder === "string" && folder !== "" ? folder : undefined;
1743
+ } catch {
1744
+ return;
1745
+ }
1478
1746
  }
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;
1747
+ function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
1748
+ const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1749
+ return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1485
1750
  }
1486
- var init_user_config = () => {};
1751
+ var init_workspace_root = __esm(() => {
1752
+ init_user_config();
1753
+ });
1487
1754
 
1488
1755
  // ../kit/src/index.ts
1489
1756
  var init_src = __esm(() => {
@@ -1497,15 +1764,18 @@ var init_src = __esm(() => {
1497
1764
  init_git();
1498
1765
  init_limit();
1499
1766
  init_logs();
1767
+ init_mode();
1500
1768
  init_process();
1501
1769
  init_secrets();
1502
1770
  init_sessions();
1503
1771
  init_size();
1504
1772
  init_style();
1505
1773
  init_text();
1774
+ init_theme();
1506
1775
  init_tool();
1507
1776
  init_usage();
1508
1777
  init_user_config();
1778
+ init_workspace_root();
1509
1779
  });
1510
1780
 
1511
1781
  // src/semver.ts
@@ -2232,7 +2502,7 @@ function parseSpec(text) {
2232
2502
  function isStable(version) {
2233
2503
  return !version.includes("-");
2234
2504
  }
2235
- function resolve(packument, request) {
2505
+ function resolve4(packument, request) {
2236
2506
  const tags = packument["dist-tags"] ?? {};
2237
2507
  const versions = Object.keys(packument.versions ?? {});
2238
2508
  const wanted = request === undefined || request === "" ? "latest" : request;
@@ -2277,7 +2547,7 @@ function analyze(input) {
2277
2547
  return report;
2278
2548
  }
2279
2549
  const latest = packument["dist-tags"]?.latest;
2280
- const version = resolve(packument, spec.request);
2550
+ const version = resolve4(packument, spec.request);
2281
2551
  const entry = version === undefined ? undefined : packument.versions?.[version];
2282
2552
  report.description = packument.description;
2283
2553
  report.license = licenseOf(entry?.license) ?? licenseOf(packument.license);
@@ -2344,9 +2614,9 @@ var init_analyze = __esm(() => {
2344
2614
  });
2345
2615
 
2346
2616
  // 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";
2617
+ import { homedir as homedir5 } from "os";
2618
+ import { dirname as dirname5, join as join7 } from "path";
2619
+ import process17 from "process";
2350
2620
  function expand2(value, env) {
2351
2621
  let missing = false;
2352
2622
  const expanded = value.replace(ENV_REFERENCE, (_, braced, bare) => {
@@ -2435,18 +2705,18 @@ async function readIfThere(path) {
2435
2705
  const file = Bun.file(path);
2436
2706
  return await file.exists() ? file.text() : undefined;
2437
2707
  }
2438
- async function loadConfigs(cwd = process13.cwd(), env = process13.env, home = homedir3()) {
2708
+ async function loadConfigs(cwd = process17.cwd(), env = process17.env, home = homedir5()) {
2439
2709
  const directories = [];
2440
- for (let dir = cwd;!directories.includes(dir); dir = dirname3(dir))
2710
+ for (let dir = cwd;!directories.includes(dir); dir = dirname5(dir))
2441
2711
  directories.push(dir);
2442
2712
  if (!directories.includes(home))
2443
2713
  directories.push(home);
2444
2714
  const configs = [];
2445
2715
  for (const dir of directories) {
2446
- const bunfig = await readIfThere(join4(dir, "bunfig.toml"));
2447
- const npmrc = await readIfThere(join4(dir, ".npmrc"));
2716
+ const bunfig = await readIfThere(join7(dir, "bunfig.toml"));
2717
+ const npmrc = await readIfThere(join7(dir, ".npmrc"));
2448
2718
  if (bunfig !== undefined)
2449
- configs.push(readable(join4(dir, "bunfig.toml"), () => parseBunfig(bunfig, env)));
2719
+ configs.push(readable(join7(dir, "bunfig.toml"), () => parseBunfig(bunfig, env)));
2450
2720
  if (npmrc !== undefined)
2451
2721
  configs.push(parseNpmrc(npmrc, env));
2452
2722
  }
@@ -2464,10 +2734,10 @@ function parseSettings(text) {
2464
2734
  settings.blockSeverity = raw.blockSeverity;
2465
2735
  return settings;
2466
2736
  }
2467
- async function loadSettings(cwd = process13.cwd(), home) {
2737
+ async function loadSettings(cwd = process17.cwd(), home) {
2468
2738
  const files = [];
2469
- for (let dir = cwd;!files.includes(join4(dir, SETTINGS_FILE)); dir = dirname3(dir))
2470
- files.push(join4(dir, SETTINGS_FILE));
2739
+ for (let dir = cwd;!files.includes(join7(dir, SETTINGS_FILE)); dir = dirname5(dir))
2740
+ files.push(join7(dir, SETTINGS_FILE));
2471
2741
  files.push(userConfigReadPath("pkg", [["pkg", "config.json"]], { home }));
2472
2742
  const settings = {};
2473
2743
  for (const file of files) {
@@ -2579,8 +2849,8 @@ var init_pin = __esm(() => {
2579
2849
  });
2580
2850
 
2581
2851
  // 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";
2852
+ import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync4 } from "fs";
2853
+ import { dirname as dirname6, join as join8, relative } from "path";
2584
2854
  function packageFiles(dir, depth, found) {
2585
2855
  let entries;
2586
2856
  try {
@@ -2590,41 +2860,76 @@ function packageFiles(dir, depth, found) {
2590
2860
  }
2591
2861
  for (const entry of entries) {
2592
2862
  if (entry.isFile() && entry.name === "package.json")
2593
- found.push(join5(dir, entry.name));
2863
+ found.push(join8(dir, entry.name));
2594
2864
  else if (entry.isDirectory() && depth < MAX_DEPTH && !entry.name.startsWith(".") && !SKIPPED.has(entry.name))
2595
- packageFiles(join5(dir, entry.name), depth + 1, found);
2865
+ packageFiles(join8(dir, entry.name), depth + 1, found);
2596
2866
  }
2597
2867
  return found;
2598
2868
  }
2599
2869
  function managerFor(dir, root) {
2600
- for (let at = dir;; at = dirname4(at)) {
2601
- const lockfile = LOCKFILES.find(([file]) => existsSync2(join5(at, file)));
2870
+ for (let at = dir;; at = dirname6(at)) {
2871
+ const lockfile = LOCKFILES.find(([file]) => existsSync5(join8(at, file)));
2602
2872
  if (lockfile !== undefined)
2603
2873
  return lockfile[1];
2604
- if (at === root || at === dirname4(at))
2874
+ if (at === root || at === dirname6(at))
2605
2875
  return "bun";
2606
2876
  }
2607
2877
  }
2878
+ function readManifest(path) {
2879
+ try {
2880
+ return JSON.parse(readFileSync4(path, "utf8"));
2881
+ } catch {
2882
+ return;
2883
+ }
2884
+ }
2608
2885
  function findConsumers(name, root) {
2609
2886
  const consumers = [];
2610
2887
  for (const path of packageFiles(root, 0, []).sort()) {
2611
- let manifest;
2612
- try {
2613
- manifest = JSON.parse(readFileSync2(path, "utf8"));
2614
- } catch {
2888
+ const manifest = readManifest(path);
2889
+ if (manifest === undefined)
2615
2890
  continue;
2891
+ const seen = new Set;
2892
+ for (const kind of KINDS) {
2893
+ for (const [key, spec] of Object.entries(manifest[kind] ?? {})) {
2894
+ const aliased = typeof spec === "string" && key !== name && ALIAS.exec(spec)?.[1] === name;
2895
+ if (typeof spec === "string" && (key === name || aliased) && !seen.has(key)) {
2896
+ seen.add(key);
2897
+ consumers.push({ dir: relative(root, dirname6(path)) || ".", path, kind, spec, ...aliased ? { alias: key } : {}, manager: managerFor(dirname6(path), root) });
2898
+ }
2899
+ }
2616
2900
  }
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
2901
  }
2622
2902
  return consumers;
2623
2903
  }
2904
+ function similarDependencies(name, root) {
2905
+ const base = name.slice(name.lastIndexOf("/") + 1).toLowerCase();
2906
+ const found = new Set;
2907
+ for (const path of packageFiles(root, 0, []).sort()) {
2908
+ const manifest = readManifest(path);
2909
+ for (const kind of KINDS) {
2910
+ for (const [key, spec] of Object.entries(manifest?.[kind] ?? {})) {
2911
+ const target = typeof spec === "string" ? ALIAS.exec(spec)?.[1] : undefined;
2912
+ for (const candidate of [key, target]) {
2913
+ const last = candidate?.slice(candidate.lastIndexOf("/") + 1).toLowerCase();
2914
+ if (candidate !== undefined && last !== undefined && candidate !== name && last.length >= MIN_SIMILAR && base.length >= MIN_SIMILAR && (last.includes(base) || base.includes(last)))
2915
+ found.add(candidate);
2916
+ }
2917
+ }
2918
+ }
2919
+ }
2920
+ return [...found].toSorted().slice(0, 5);
2921
+ }
2624
2922
  function isLocal(consumer) {
2625
- return LOCAL_SPEC.test(consumer.spec);
2923
+ return consumer.alias === undefined && LOCAL_SPEC.test(consumer.spec);
2924
+ }
2925
+ function wantedVersion(consumer) {
2926
+ return consumer.alias === undefined ? consumer.spec : ALIAS.exec(consumer.spec)?.[2] ?? consumer.spec;
2626
2927
  }
2627
2928
  function addCommand(consumer, name, version) {
2929
+ if (consumer.alias !== undefined) {
2930
+ const prefix = RANGE_PREFIX.exec(wantedVersion(consumer))?.[0] ?? "";
2931
+ return ["bun", "add", ...KIND_FLAGS[consumer.kind], ...prefix === "" ? ["--exact"] : [], "--no-cache", `${consumer.alias}@npm:${name}@${prefix}${version}`];
2932
+ }
2628
2933
  return ["bun", "add", ...KIND_FLAGS[consumer.kind], "--exact", "--no-cache", `${name}@${version}`];
2629
2934
  }
2630
2935
  function registryDependencies(text) {
@@ -2636,14 +2941,16 @@ function registryDependencies(text) {
2636
2941
  }
2637
2942
  return REGISTRY_KINDS.flatMap((kind) => Object.entries(manifest?.[kind] ?? {}).flatMap(([name, spec]) => typeof spec === "string" && !LOCAL_SPEC.test(spec) ? [{ name, kind, spec }] : []));
2638
2943
  }
2639
- var KINDS, SKIPPED, MAX_DEPTH = 5, LOCAL_SPEC, KIND_FLAGS, REGISTRY_KINDS;
2944
+ var KINDS, SKIPPED, MAX_DEPTH = 5, LOCAL_SPEC, ALIAS, MIN_SIMILAR = 3, KIND_FLAGS, RANGE_PREFIX, REGISTRY_KINDS;
2640
2945
  var init_consumers = __esm(() => {
2641
2946
  init_src();
2642
2947
  init_pin();
2643
2948
  KINDS = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
2644
2949
  SKIPPED = new Set(["node_modules", "dist", "build", "vendor", "target", "coverage"]);
2645
2950
  LOCAL_SPEC = /[:/]/;
2951
+ ALIAS = /^npm:(@[^@/]+\/[^@/]+|[^@/]+)@(.+)$/;
2646
2952
  KIND_FLAGS = { dependencies: [], devDependencies: ["--dev"], optionalDependencies: ["--optional"], peerDependencies: ["--peer"] };
2953
+ RANGE_PREFIX = /^[~^]/;
2647
2954
  REGISTRY_KINDS = KINDS.filter((kind) => kind !== "peerDependencies");
2648
2955
  });
2649
2956
 
@@ -2813,8 +3120,8 @@ var exports_audit = {};
2813
3120
  __export(exports_audit, {
2814
3121
  audit: () => audit
2815
3122
  });
2816
- import { join as join6, resolve as resolve2 } from "path";
2817
- import process14 from "process";
3123
+ import { join as join9, resolve as resolve5 } from "path";
3124
+ import process18 from "process";
2818
3125
  function hasFinding(audited) {
2819
3126
  return audited.blocked || audited.warnings.length > 0 || audited.advisories.length > 0;
2820
3127
  }
@@ -2826,14 +3133,11 @@ async function auditPackages(packages, context) {
2826
3133
  packuments.set(key, fetchPackument(name, registry, context.fetcher));
2827
3134
  return packuments.get(key);
2828
3135
  };
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
- }
3136
+ const looked = await pool(packages, BATCH, async ({ name, version }) => {
3137
+ const registry = registryFor(name, context.configs);
3138
+ 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 };
3139
+ return { name, version, registry, input, safe: analyze(input).safe?.version };
3140
+ });
2837
3141
  const registries = new Map;
2838
3142
  for (const { name, version, registry, safe } of looked) {
2839
3143
  const group = registries.get(registry.url) ?? { registry, versions: {} };
@@ -2873,8 +3177,8 @@ async function audit(args) {
2873
3177
  const level = values.level ?? "moderate";
2874
3178
  if (!isSeverity(level))
2875
3179
  fail(`--level takes ${SEVERITIES.join(", ")}, not ${level}`);
2876
- const dir = resolve2(asked ?? process14.cwd());
2877
- const lock = Bun.file(join6(dir, "bun.lock"));
3180
+ const dir = resolve5(asked ?? process18.cwd());
3181
+ const lock = Bun.file(join9(dir, "bun.lock"));
2878
3182
  if (!await lock.exists())
2879
3183
  fail(`no bun.lock in ${dir}`);
2880
3184
  const text = await lock.text();
@@ -2926,8 +3230,8 @@ var exports_outdated = {};
2926
3230
  __export(exports_outdated, {
2927
3231
  outdatedCommand: () => outdatedCommand
2928
3232
  });
2929
- import { existsSync as existsSync3 } from "fs";
2930
- import { join as join7, resolve as resolve3 } from "path";
3233
+ import { existsSync as existsSync6 } from "fs";
3234
+ import { join as join10, resolve as resolve6 } from "path";
2931
3235
  function currentOf(name, spec, locked) {
2932
3236
  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
3237
  const written = FIRST_VERSION.exec(spec)?.[0];
@@ -2942,34 +3246,30 @@ function changeOf(current, next) {
2942
3246
  async function outdated(manifest, context) {
2943
3247
  const configs = await loadConfigs();
2944
3248
  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));
3249
+ const looked = await pool(dependencies, BATCH2, async ({ name, kind, spec }) => {
3250
+ const registry = registryFor(name, configs);
3251
+ const packument = await fetchPackument(name, registry, context.fetcher);
3252
+ if (packument === undefined) {
3253
+ warn(`${name} is not on ${new URL(registry.url).host}`);
3254
+ return;
3255
+ }
3256
+ const { safe, latest } = analyze({ spec: { name }, packument, registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays });
3257
+ const current = currentOf(name, spec, context.locked);
3258
+ if (safe === undefined || current === undefined || Bun.semver.order(safe.version, current) <= 0)
3259
+ return;
3260
+ const row = { name, kind, spec, current, safe: safe.version, change: changeOf(current, safe.version), published: safe.published };
3261
+ return latest !== undefined && latest.version !== safe.version && Bun.semver.order(latest.version, safe.version) > 0 ? { ...row, latest: latest.version } : row;
3262
+ });
3263
+ return looked.filter((row) => row !== undefined).sort((a, b) => a.name.localeCompare(b.name));
2964
3264
  }
2965
3265
  async function outdatedCommand(args) {
2966
3266
  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"));
3267
+ const folder = resolve6(dir);
3268
+ const manifest = Bun.file(join10(folder, "package.json"));
2969
3269
  if (!await manifest.exists())
2970
3270
  fail(`no package.json in ${folder}`);
2971
- const lockPath = join7(folder, "bun.lock");
2972
- const locked = existsSync3(lockPath) ? parseBunLock(await Bun.file(lockPath).text()) : [];
3271
+ const lockPath = join10(folder, "bun.lock");
3272
+ const locked = existsSync6(lockPath) ? parseBunLock(await Bun.file(lockPath).text()) : [];
2973
3273
  const rows = await outdated(await manifest.text(), { minAgeDays: wholeNumber(values["min-age"], "min-age", DEFAULT_MIN_AGE_DAYS, 0), locked });
2974
3274
  const { shown, footer } = capped(rows, limitOf(values, OUTDATED_LIMIT));
2975
3275
  if (values.json === true)
@@ -3008,9 +3308,8 @@ __export(exports_bump, {
3008
3308
  ROOT_OPTION: () => ROOT_OPTION,
3009
3309
  bump: () => bump
3010
3310
  });
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";
3311
+ import { existsSync as existsSync7 } from "fs";
3312
+ import { basename, dirname as dirname7, join as join11, relative as relative2 } from "path";
3014
3313
  async function lookup(name, registry, fetcher) {
3015
3314
  try {
3016
3315
  return { packument: await fetchPackument(name, registry, fetcher) };
@@ -3070,11 +3369,11 @@ async function vet(name, version, settings) {
3070
3369
  return false;
3071
3370
  }
3072
3371
  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)));
3372
+ for (let at = dir;; at = dirname7(at)) {
3373
+ const found = ["bun.lock", "bun.lockb"].find((file) => existsSync7(join11(at, file)));
3075
3374
  if (found !== undefined)
3076
- return relative2(dir, join8(at, found));
3077
- if (at === root || at === dirname5(at))
3375
+ return relative2(dir, join11(at, found));
3376
+ if (at === root || at === dirname7(at))
3078
3377
  return;
3079
3378
  }
3080
3379
  }
@@ -3093,26 +3392,38 @@ async function checkAndCommit(name, version, where, root, run) {
3093
3392
  return committed.code === 0 ? undefined : `gc exited ${committed.code}: ${committed.text.trim().split(`
3094
3393
  `).at(-1) ?? ""}`;
3095
3394
  }
3395
+ function matcher(patterns) {
3396
+ const globs = patterns.map((pattern) => new Bun.Glob(pattern));
3397
+ return (dir) => globs.some((glob) => glob.match(dir) || glob.match(basename(dir)));
3398
+ }
3096
3399
  async function bumpConsumers(name, version, settings) {
3097
- const found = findConsumers(name, settings.root);
3400
+ const everyone = findConsumers(name, settings.root);
3401
+ const isOnly = matcher(settings.only ?? []);
3402
+ const isExcept = matcher(settings.except ?? []);
3403
+ const found = everyone.filter((each) => (settings.only === undefined || settings.only.length === 0 || isOnly(each.dir)) && !isExcept(each.dir));
3098
3404
  const consumers = found.filter((each) => !isLocal(each));
3405
+ const left = everyone.length - found.length;
3099
3406
  const local = found.length - consumers.length;
3100
3407
  const run = settings.run ?? (async (argv, cwd) => runCommand(argv, { cwd }));
3101
3408
  const committed = [];
3102
3409
  const failing = [];
3103
3410
  const skipped = [];
3104
3411
  let isClean = true;
3105
- if (found.length === 0)
3106
- note(`nothing under ${settings.root} depends on ${name}`);
3412
+ if (everyone.length === 0) {
3413
+ const similar = similarDependencies(name, settings.root);
3414
+ note(`nothing under ${settings.root} depends on ${name}`, similar.length === 0 ? undefined : `did you mean ${similar.join(", ")}`);
3415
+ } else if (left > 0) {
3416
+ note(`${left} folder${left === 1 ? "" : "s"} left out by --only or --except`);
3417
+ }
3107
3418
  if (local > 0)
3108
3419
  note(`${local} non-registry dependenc${local === 1 ? "y" : "ies"} (workspace:, file:, git, URL, alias, catalog:)`, "left as they are");
3109
3420
  for (const consumer of consumers) {
3110
3421
  const argv = addCommand(consumer, name, version);
3111
- const where = join8(settings.root, consumer.dir);
3422
+ const where = join11(settings.root, consumer.dir);
3112
3423
  if (consumer.kind === "peerDependencies") {
3113
3424
  skipped.push(consumer.dir);
3114
3425
  note(consumer.dir, `peer range ${consumer.spec}, left as it is`);
3115
- } else if (consumer.spec === version) {
3426
+ } else if ((consumer.alias === undefined ? consumer.spec : wantedVersion(consumer).replace(RANGE_PREFIX, "")) === version) {
3116
3427
  skipped.push(consumer.dir);
3117
3428
  note(consumer.dir, `already on ${version}`);
3118
3429
  } else if (consumer.manager !== "bun") {
@@ -3153,12 +3464,14 @@ async function bumpConsumers(name, version, settings) {
3153
3464
  async function bump(args) {
3154
3465
  const { values, positionals: [name, asked] } = parse(args, usage5, options4, { positionals: ["<name>", "[version]"] });
3155
3466
  const settings = {
3156
- root: values.root ?? join8(homedir4(), "Workspace"),
3467
+ root: workspaceRoot({ given: values.root }),
3157
3468
  configs: await loadConfigs(),
3158
3469
  timeout: duration(values.timeout, "timeout", 10 * 60000),
3159
3470
  isDryRun: values["dry-run"] === true,
3160
3471
  isAll: values["all-consumers"] === true,
3161
3472
  isForced: values.force === true,
3473
+ only: values.only,
3474
+ except: values.except,
3162
3475
  pkgSettings: await loadSettings(),
3163
3476
  minAgeDays: wholeNumber(values["min-age"], "min-age", 0, 0)
3164
3477
  };
@@ -3171,7 +3484,8 @@ var usage5 = `pkg bump <name> [version]
3171
3484
 
3172
3485
  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
3486
  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.
3487
+ 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).
3488
+ 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
3489
  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
3490
 
3177
3491
  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 +3497,13 @@ var init_bump = __esm(() => {
3183
3497
  init_registry();
3184
3498
  init_semver();
3185
3499
  init_check();
3186
- ROOT_OPTION = { type: "string", description: "the folder holding the repositories (~/Workspace)" };
3500
+ ROOT_OPTION = { type: "string", description: "the folder holding the repositories (the workspace of the user config or KAYNOOO_WORKSPACE, ~/Workspace by default)" };
3187
3501
  options4 = {
3188
3502
  root: ROOT_OPTION,
3189
3503
  timeout: { type: "string", short: "t", description: "how long to wait for the registry (10m): 30s, 5m, 1h" },
3190
3504
  "all-consumers": { type: "boolean", description: "after each install run the folder's check and commit it through gc when it passes" },
3505
+ only: { type: "string", multiple: true, description: "bump only the folders matching this name or glob, repeatable" },
3506
+ except: { type: "string", multiple: true, description: "leave the folders matching this name or glob alone, repeatable" },
3191
3507
  "dry-run": { type: "boolean", description: "print what would run, changing nothing" },
3192
3508
  force: { type: "boolean", description: "bump even when the version is blocked by the vetting" },
3193
3509
  "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 +3515,24 @@ var exports_consumers = {};
3199
3515
  __export(exports_consumers, {
3200
3516
  consumers: () => consumers
3201
3517
  });
3202
- import { homedir as homedir5 } from "os";
3203
- import { join as join9 } from "path";
3204
3518
  function consumers(args) {
3205
3519
  const { values, positionals: [name] } = parse(args, usage6, options5, { positionals: ["<name>"] });
3206
- const root = values.root ?? join9(homedir5(), "Workspace");
3520
+ const root = workspaceRoot({ given: values.root });
3207
3521
  const { shown, footer } = capped(findConsumers(name, root), limitOf(values, CONSUMERS_LIMIT));
3208
- if (values.json === true)
3522
+ if (values.json === true) {
3209
3523
  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(`
3524
+ } else if (shown.length === 0) {
3525
+ const similar = similarDependencies(name, root);
3526
+ console.log(`nothing under ${root} depends on ${name}${similar.length === 0 ? "" : `, did you mean ${similar.join(", ")}`}`);
3527
+ } else {
3528
+ 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
3529
  `));
3530
+ }
3215
3531
  return 0;
3216
3532
  }
3217
3533
  var usage6 = `pkg consumers <name>
3218
3534
 
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).
3535
+ 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
3536
 
3221
3537
  Exits 0 when it listed them, 2 on a usage error.`, CONSUMERS_LIMIT = 30, options5;
3222
3538
  var init_consumers2 = __esm(() => {
@@ -3232,8 +3548,8 @@ var init_consumers2 = __esm(() => {
3232
3548
 
3233
3549
  // src/cli.ts
3234
3550
  init_src();
3235
- import process15 from "process";
3236
- process15.exitCode = await runCli({
3551
+ import process19 from "process";
3552
+ process19.exitCode = await runCli({
3237
3553
  name: "pkg",
3238
3554
  about: "checks npm packages before they are added, and moves a lib's consumers onto a new release",
3239
3555
  replaces: "bun add on trust, and a bun info and sleep loop then a bun add per consumer",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-pkg",
3
3
  "type": "module",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "description": "pkg: check an npm package before it is added, for a guessed name, a version under two weeks old and install scripts.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -30,6 +30,6 @@
30
30
  "record": "$npm_execpath scripts/record.ts"
31
31
  },
32
32
  "devDependencies": {
33
- "@kaynooo/cli-kit": "0.21.0"
33
+ "@kaynooo/cli-kit": "0.23.0"
34
34
  }
35
35
  }