@kaynooo/cli-workspace 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/audit-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/audit-cli.ts
5
- import process17 from "process";
5
+ import process18 from "process";
6
6
 
7
7
  // ../kit/src/advisory.ts
8
8
  var SEVERITIES = ["low", "moderate", "high", "critical"];
@@ -348,13 +348,13 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
348
348
  // ../kit/src/theme.ts
349
349
  var DEFAULT = {
350
350
  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" },
351
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
351
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
352
352
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
353
353
  bins: {}
354
354
  };
355
355
  var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
356
356
  var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
357
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
357
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
358
358
  var PRESETS = {
359
359
  default: {},
360
360
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -554,6 +554,21 @@ var STATUS_WORDS = {
554
554
  skipped: ["skipped", "cancelled", "canceled", "manual"]
555
555
  };
556
556
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
557
+ function header(bin, context, stream, env = process6.env) {
558
+ if (!takesControlCodes(stream, env))
559
+ return "";
560
+ const colors = paint(stream, env);
561
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
562
+ const { theme } = activeTheme();
563
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
564
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
565
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
566
+ }
567
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
568
+ const line = header(bin, context, stream, env);
569
+ if (line !== "")
570
+ console.log(line);
571
+ }
557
572
 
558
573
  // ../kit/src/format.ts
559
574
  var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
@@ -1437,6 +1452,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process13.a
1437
1452
  }
1438
1453
  return code;
1439
1454
  }
1455
+ // ../kit/src/folders.ts
1456
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1440
1457
  // ../kit/src/pool.ts
1441
1458
  async function pool(items, limit, task) {
1442
1459
  const results = Array.from({ length: items.length });
@@ -1466,11 +1483,63 @@ function parseSize(text, bareUnit = 1) {
1466
1483
  const suffix = match[2].toLowerCase();
1467
1484
  return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
1468
1485
  }
1486
+ // ../kit/src/watch.ts
1487
+ import process14 from "process";
1488
+ import { format } from "util";
1489
+ var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1490
+ var DEFAULT_SECONDS = 2;
1491
+ var ATTACHED_SHORT = /^-w./;
1492
+ var INTERVAL = /^\d+(?:\.\d+)?(?:ms|[smh])?$/;
1493
+ function watchOption(what) {
1494
+ return { type: "string", short: "w", optional: { bare: "", accepts: INTERVAL }, description: `redraw ${what} every 2s, or every interval given (500ms, 5s), until ctrl-c` };
1495
+ }
1496
+ function withoutWatch(args) {
1497
+ const rest = [];
1498
+ for (let at = 0;at < args.length; at++) {
1499
+ const arg = args[at];
1500
+ if (arg === "--watch" || arg === "-w") {
1501
+ if (args[at + 1] !== undefined && INTERVAL.test(args[at + 1]))
1502
+ at++;
1503
+ } else if (!arg.startsWith("--watch=") && !ATTACHED_SHORT.test(arg)) {
1504
+ rest.push(arg);
1505
+ }
1506
+ }
1507
+ return rest;
1508
+ }
1509
+ async function watching(value, step, stream = process14.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1510
+ const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1511
+ if (!takesControlCodes(stream))
1512
+ badUsage("--watch redraws the screen, so it needs a terminal");
1513
+ let code = 0;
1514
+ for (let round = 0;round < rounds; round++) {
1515
+ const held = [];
1516
+ const { log, info } = console;
1517
+ const write = process14.stdout.write.bind(process14.stdout);
1518
+ const hold = (...parts) => void held.push(`${format(...parts)}
1519
+ `);
1520
+ console.log = hold;
1521
+ console.info = hold;
1522
+ process14.stdout.write = (text) => {
1523
+ held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1524
+ return true;
1525
+ };
1526
+ try {
1527
+ code = await step();
1528
+ } finally {
1529
+ console.log = log;
1530
+ console.info = info;
1531
+ process14.stdout.write = write;
1532
+ }
1533
+ stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1534
+ await sleep(interval);
1535
+ }
1536
+ return code;
1537
+ }
1469
1538
  // ../kit/src/workspace-root.ts
1470
1539
  import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1471
1540
  import { homedir as homedir4 } from "os";
1472
1541
  import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
1473
- import process14 from "process";
1542
+ import process15 from "process";
1474
1543
  function expandHome(path, home) {
1475
1544
  if (path === "~")
1476
1545
  return home;
@@ -1488,7 +1557,7 @@ function configured(env, home) {
1488
1557
  return;
1489
1558
  }
1490
1559
  }
1491
- function workspaceRoot({ given, env = process14.env, home = homedir4() } = {}) {
1560
+ function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
1492
1561
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1493
1562
  return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1494
1563
  }
@@ -1496,7 +1565,7 @@ function workspaceRoot({ given, env = process14.env, home = homedir4() } = {}) {
1496
1565
  import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
1497
1566
  import { readdir } from "fs/promises";
1498
1567
  import { join as join8, relative, resolve as resolve4 } from "path";
1499
- import process16 from "process";
1568
+ import process17 from "process";
1500
1569
 
1501
1570
  // src/report.ts
1502
1571
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
@@ -1708,7 +1777,7 @@ function failure(ran) {
1708
1777
  `).at(-1) ?? `exit ${ran.code}`;
1709
1778
  }
1710
1779
  function tint(severity) {
1711
- const colors = paint(process16.stdout);
1780
+ const colors = paint(process17.stdout);
1712
1781
  if (severity === "critical" || severity === "high")
1713
1782
  return colors.red;
1714
1783
  return severity === "moderate" ? colors.yellow : colors.dim;
@@ -1743,8 +1812,8 @@ async function audit(args) {
1743
1812
  return kept.some((each) => each.findings.length > 0) ? 1 : 0;
1744
1813
  }
1745
1814
  function show(audits, total) {
1746
- const label = role("label", process16.stdout);
1747
- const path = role("path", process16.stdout);
1815
+ const label = role("label", process17.stdout);
1816
+ const path = role("path", process17.stdout);
1748
1817
  const flagged = audits.filter((each) => each.error !== undefined || each.findings.length > 0);
1749
1818
  if (flagged.length === 0) {
1750
1819
  console.log(label(`no advisory in ${total} ${total === 1 ? "repository" : "repositories"}`));
@@ -1764,4 +1833,4 @@ function show(audits, total) {
1764
1833
  }
1765
1834
 
1766
1835
  // src/audit-cli.ts
1767
- process17.exitCode = await runMain({ name: "audit", run: audit });
1836
+ process18.exitCode = await runMain({ name: "audit", run: audit });
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process20 from "process";
5
+ import process21 from "process";
6
6
 
7
7
  // ../kit/src/advisory.ts
8
8
  var SEVERITIES = ["low", "moderate", "high", "critical"];
@@ -348,13 +348,13 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
348
348
  // ../kit/src/theme.ts
349
349
  var DEFAULT = {
350
350
  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" },
351
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
351
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
352
352
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
353
353
  bins: {}
354
354
  };
355
355
  var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
356
356
  var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
357
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
357
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
358
358
  var PRESETS = {
359
359
  default: {},
360
360
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -554,6 +554,21 @@ var STATUS_WORDS = {
554
554
  skipped: ["skipped", "cancelled", "canceled", "manual"]
555
555
  };
556
556
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
557
+ function header(bin, context, stream, env = process6.env) {
558
+ if (!takesControlCodes(stream, env))
559
+ return "";
560
+ const colors = paint(stream, env);
561
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
562
+ const { theme } = activeTheme();
563
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
564
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
565
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
566
+ }
567
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
568
+ const line = header(bin, context, stream, env);
569
+ if (line !== "")
570
+ console.log(line);
571
+ }
557
572
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-hrsswv1w.js
558
573
  function $e(t, e = false, i = 1) {
559
574
  let n = typeof e === "object" ? e : { units: e ? "si" : "iec", dp: i }, { units: s = "iec", dp: u = 1 } = n, r = s === "si" ? 1000 : 1024;
@@ -1448,6 +1463,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process13.a
1448
1463
  }
1449
1464
  return code;
1450
1465
  }
1466
+ // ../kit/src/folders.ts
1467
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1451
1468
  // ../kit/src/pool.ts
1452
1469
  async function pool(items, limit, task) {
1453
1470
  const results = Array.from({ length: items.length });
@@ -1477,11 +1494,63 @@ function parseSize(text, bareUnit = 1) {
1477
1494
  const suffix = match[2].toLowerCase();
1478
1495
  return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
1479
1496
  }
1497
+ // ../kit/src/watch.ts
1498
+ import process14 from "process";
1499
+ import { format } from "util";
1500
+ var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1501
+ var DEFAULT_SECONDS = 2;
1502
+ var ATTACHED_SHORT = /^-w./;
1503
+ var INTERVAL = /^\d+(?:\.\d+)?(?:ms|[smh])?$/;
1504
+ function watchOption(what) {
1505
+ return { type: "string", short: "w", optional: { bare: "", accepts: INTERVAL }, description: `redraw ${what} every 2s, or every interval given (500ms, 5s), until ctrl-c` };
1506
+ }
1507
+ function withoutWatch(args) {
1508
+ const rest = [];
1509
+ for (let at = 0;at < args.length; at++) {
1510
+ const arg = args[at];
1511
+ if (arg === "--watch" || arg === "-w") {
1512
+ if (args[at + 1] !== undefined && INTERVAL.test(args[at + 1]))
1513
+ at++;
1514
+ } else if (!arg.startsWith("--watch=") && !ATTACHED_SHORT.test(arg)) {
1515
+ rest.push(arg);
1516
+ }
1517
+ }
1518
+ return rest;
1519
+ }
1520
+ async function watching(value, step, stream = process14.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1521
+ const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1522
+ if (!takesControlCodes(stream))
1523
+ badUsage("--watch redraws the screen, so it needs a terminal");
1524
+ let code = 0;
1525
+ for (let round = 0;round < rounds; round++) {
1526
+ const held = [];
1527
+ const { log, info } = console;
1528
+ const write = process14.stdout.write.bind(process14.stdout);
1529
+ const hold = (...parts) => void held.push(`${format(...parts)}
1530
+ `);
1531
+ console.log = hold;
1532
+ console.info = hold;
1533
+ process14.stdout.write = (text) => {
1534
+ held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1535
+ return true;
1536
+ };
1537
+ try {
1538
+ code = await step();
1539
+ } finally {
1540
+ console.log = log;
1541
+ console.info = info;
1542
+ process14.stdout.write = write;
1543
+ }
1544
+ stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1545
+ await sleep(interval);
1546
+ }
1547
+ return code;
1548
+ }
1480
1549
  // ../kit/src/workspace-root.ts
1481
1550
  import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1482
1551
  import { homedir as homedir4 } from "os";
1483
1552
  import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
1484
- import process14 from "process";
1553
+ import process15 from "process";
1485
1554
  function expandHome(path, home) {
1486
1555
  if (path === "~")
1487
1556
  return home;
@@ -1499,7 +1568,7 @@ function configured(env, home) {
1499
1568
  return;
1500
1569
  }
1501
1570
  }
1502
- function workspaceRoot({ given, env = process14.env, home = homedir4() } = {}) {
1571
+ function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
1503
1572
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1504
1573
  return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1505
1574
  }
@@ -1507,7 +1576,7 @@ function workspaceRoot({ given, env = process14.env, home = homedir4() } = {}) {
1507
1576
  import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
1508
1577
  import { readdir } from "fs/promises";
1509
1578
  import { join as join8, relative, resolve as resolve4 } from "path";
1510
- import process16 from "process";
1579
+ import process17 from "process";
1511
1580
 
1512
1581
  // src/report.ts
1513
1582
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
@@ -1719,7 +1788,7 @@ function failure(ran) {
1719
1788
  `).at(-1) ?? `exit ${ran.code}`;
1720
1789
  }
1721
1790
  function tint(severity) {
1722
- const colors = paint(process16.stdout);
1791
+ const colors = paint(process17.stdout);
1723
1792
  if (severity === "critical" || severity === "high")
1724
1793
  return colors.red;
1725
1794
  return severity === "moderate" ? colors.yellow : colors.dim;
@@ -1754,8 +1823,8 @@ async function audit(args) {
1754
1823
  return kept.some((each) => each.findings.length > 0) ? 1 : 0;
1755
1824
  }
1756
1825
  function show(audits, total) {
1757
- const label = role("label", process16.stdout);
1758
- const path = role("path", process16.stdout);
1826
+ const label = role("label", process17.stdout);
1827
+ const path = role("path", process17.stdout);
1759
1828
  const flagged = audits.filter((each) => each.error !== undefined || each.findings.length > 0);
1760
1829
  if (flagged.length === 0) {
1761
1830
  console.log(label(`no advisory in ${total} ${total === 1 ? "repository" : "repositories"}`));
@@ -1776,14 +1845,14 @@ function show(audits, total) {
1776
1845
 
1777
1846
  // src/repos.ts
1778
1847
  import { existsSync as existsSync8, statSync as statSync3 } from "fs";
1779
- import { relative as relative2 } from "path";
1780
- import process18 from "process";
1848
+ import { basename as basename2, relative as relative2 } from "path";
1849
+ import process19 from "process";
1781
1850
 
1782
1851
  // src/repos-scan.ts
1783
1852
  import { existsSync as existsSync7 } from "fs";
1784
1853
  import { readdir as readdir2 } from "fs/promises";
1785
1854
  import { basename, join as join9 } from "path";
1786
- import process17 from "process";
1855
+ import process18 from "process";
1787
1856
  var MAX_DEPTH2 = 3;
1788
1857
  var CONCURRENCY2 = 8;
1789
1858
  var PACKAGE_CONCURRENCY = 4;
@@ -1830,7 +1899,7 @@ async function findRepos2(root, skip) {
1830
1899
  }
1831
1900
  async function read(path, args, timeoutMs = GIT_MS) {
1832
1901
  try {
1833
- const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...process17.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs });
1902
+ const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...process18.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs });
1834
1903
  return ran.code === 0 && !ran.timedOut ? ran.text.trim() : undefined;
1835
1904
  } catch {
1836
1905
  return;
@@ -1907,7 +1976,7 @@ function firstLine(text) {
1907
1976
  }
1908
1977
  async function fastForward(path) {
1909
1978
  try {
1910
- const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...process17.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs: GIT_MS });
1979
+ const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...process18.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs: GIT_MS });
1911
1980
  if (ran.timedOut)
1912
1981
  return "timed out";
1913
1982
  return ran.code === 0 ? undefined : firstLine(ran.text.trim()) || `exit ${ran.code}`;
@@ -1928,8 +1997,9 @@ var EXITS2 = [[0, "it listed the repositories, including when none needs attenti
1928
1997
  var OPTIONS2 = {
1929
1998
  all: { type: "boolean", short: "a", description: "list the repositories with nothing to report too" },
1930
1999
  only: { type: "string", choices: REASONS, description: "only the repositories with this reason: dirty, unpushed, unreleased or behind" },
1931
- fetch: { type: "boolean", description: "refresh the upstreams first (reaches the remote)" },
1932
- pull: { type: "boolean", description: "fetch, then fast-forward the clean repositories listed that are only behind their upstream (reaches the remote)" },
2000
+ watch: watchOption("the repositories"),
2001
+ fetch: { type: "boolean", conflicts: ["watch"], description: "refresh the upstreams first (reaches the remote)" },
2002
+ pull: { type: "boolean", conflicts: ["watch"], description: "fetch, then fast-forward the clean repositories listed that are only behind their upstream (reaches the remote)" },
1933
2003
  path: { type: "boolean", conflicts: ["json"], description: "print only the paths of the repositories listed, one per line" },
1934
2004
  json: jsonOption("[{name, path, branch, upstream, dirty, ahead, behind, worktrees, tag, unreleased, packages, reasons, fetchFailed, unreadable}]")
1935
2005
  };
@@ -1949,7 +2019,7 @@ function releasedCell(repo) {
1949
2019
  return repo.packages.filter((release) => release.unreleased > 0).map((release) => `${release.name} ${release.unreleased}`).join(", ") || "-";
1950
2020
  return repo.tag === null || repo.unreleased === 0 ? "-" : `${repo.unreleased} since ${repo.tag}`;
1951
2021
  }
1952
- function syncCell(repo, stream = process18.stdout) {
2022
+ function syncCell(repo, stream = process19.stdout) {
1953
2023
  const colors = paint(stream);
1954
2024
  const ahead = repo.ahead ?? 0;
1955
2025
  const behind = repo.behind ?? 0;
@@ -1960,7 +2030,7 @@ function syncCell(repo, stream = process18.stdout) {
1960
2030
  return parts.length === 0 ? colors.dim("-") : `${parts.join(" ")}${diverged ? colors.yellow(" diverged") : ""}`;
1961
2031
  }
1962
2032
  var DEFAULT_BRANCHES = new Set(["main", "master"]);
1963
- function branchCell(repo, stream = process18.stdout) {
2033
+ function branchCell(repo, stream = process19.stdout) {
1964
2034
  const colors = paint(stream);
1965
2035
  if (repo.unreadable)
1966
2036
  return colors.red("? (unreadable)");
@@ -1969,8 +2039,8 @@ function branchCell(repo, stream = process18.stdout) {
1969
2039
  return DEFAULT_BRANCHES.has(repo.branch) ? repo.branch : role("accent", stream)(repo.branch);
1970
2040
  }
1971
2041
  function row(repo, shown) {
1972
- const colors = paint(process18.stdout);
1973
- const tint = role("path", process18.stdout);
2042
+ const colors = paint(process19.stdout);
2043
+ const tint = role("path", process19.stdout);
1974
2044
  const unreleased = releasedCell(repo);
1975
2045
  return [
1976
2046
  tint(shown),
@@ -1983,6 +2053,8 @@ function row(repo, shown) {
1983
2053
  }
1984
2054
  async function repos(args) {
1985
2055
  const { values, positionals } = parse(args, USAGE2, OPTIONS2, { positionals: ["[root]"], exits: EXITS2, replaces: "a cd, git status, git log and git tag loop over each repository of the workspace", examples: ["repos", "repos ~/Workspace --only unreleased --fetch", ["repos --only behind --pull", "fast-forward what is behind and clean"], ["repos --only dirty --path", "the paths, for xargs"]] });
2056
+ if (values.watch !== undefined)
2057
+ return watching(values.watch, async () => repos(withoutWatch(args)));
1986
2058
  const root = workspaceRoot({ given: positionals[0] });
1987
2059
  if (!existsSync8(root) || !statSync3(root).isDirectory())
1988
2060
  fail(`no folder ${root}`);
@@ -2002,12 +2074,12 @@ async function repos(args) {
2002
2074
  const blocker = pullBlocker(repo);
2003
2075
  const refused = blocker === undefined ? await fastForward(repo.path) : undefined;
2004
2076
  if (blocker !== undefined) {
2005
- log(marked("note", `${repo.name} skipped`, process18.stdout, blocker));
2077
+ log(marked("note", `${repo.name} skipped`, process19.stdout, blocker));
2006
2078
  } else if (refused !== undefined) {
2007
2079
  failedPulls++;
2008
- log(marked("problem", `${repo.name} not pulled`, process18.stdout, refused));
2080
+ log(marked("problem", `${repo.name} not pulled`, process19.stdout, refused));
2009
2081
  } else {
2010
- log(marked("ok", `${repo.name} pulled`, process18.stdout, `${repo.behind} ${repo.behind === 1 ? "commit" : "commits"}`));
2082
+ log(marked("ok", `${repo.name} pulled`, process19.stdout, `${repo.behind} ${repo.behind === 1 ? "commit" : "commits"}`));
2011
2083
  states[index] = await inspect(repo.path, false);
2012
2084
  }
2013
2085
  }
@@ -2022,7 +2094,8 @@ async function repos(args) {
2022
2094
  printJson(kept.map((repo) => ({ ...repo, reasons: reasonsOf(repo) })));
2023
2095
  return failedPulls > 0 ? 1 : 0;
2024
2096
  }
2025
- const label = role("label", process18.stdout);
2097
+ const label = role("label", process19.stdout);
2098
+ printHeader("repos", basename2(root) || undefined);
2026
2099
  if (kept.length === 0) {
2027
2100
  console.log(label(`nothing needs attention in ${states.length} repositories`));
2028
2101
  return failedPulls > 0 ? 1 : 0;
@@ -2042,14 +2115,50 @@ import { homedir as homedir6 } from "os";
2042
2115
  import { relative as relative3 } from "path";
2043
2116
 
2044
2117
  // ../kit/src/prompt.ts
2045
- import process19 from "process";
2046
- var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|[\s\S]/giu;
2047
- var CONTROL2 = /^[\x00-\x1F\x7F]/;
2118
+ import process20 from "process";
2119
+
2120
+ // ../kit/src/picker/score.ts
2121
+ var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
2122
+ var NONE = Number.NEGATIVE_INFINITY;
2123
+
2124
+ // ../kit/src/picker/state.ts
2125
+ var IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
2048
2126
  var PASTE_START = "\x1B[200~";
2049
2127
  var PASTE_END = "\x1B[201~";
2050
- var KEYS = { "\x1B[A": "up", "\x1BOA": "up", "\x1B[B": "down", "\x1BOB": "down", "\x1B[5~": "pageup", "\x1B[6~": "pagedown", "\x1B[H": "home", "\x1B[1~": "home", "\x1BOH": "home", "\x1B[F": "end", "\x1B[4~": "end", "\x1BOF": "end", "\r": "enter", "\n": "enter", "\x03": "cancel", "\x1B": "cancel", "\x7F": "erase", "\b": "erase" };
2051
- function readKeys(input, paste = { active: false }) {
2128
+ var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
2129
+ var KEYS = {
2130
+ "\x1B[A": "up",
2131
+ "\x1BOA": "up",
2132
+ "\x10": "up",
2133
+ "\x1B[B": "down",
2134
+ "\x1BOB": "down",
2135
+ "\x0E": "down",
2136
+ "\x1B[5~": "pageup",
2137
+ "\x1B[6~": "pagedown",
2138
+ "\x1B[H": "home",
2139
+ "\x1B[1~": "home",
2140
+ "\x1BOH": "home",
2141
+ "\x1B[F": "end",
2142
+ "\x1B[4~": "end",
2143
+ "\x1BOF": "end",
2144
+ "\r": "enter",
2145
+ "\n": "enter",
2146
+ "\x03": "cancel",
2147
+ "\x1B": "cancel",
2148
+ "\x7F": "erase",
2149
+ "\b": "erase",
2150
+ "\x15": "clear",
2151
+ "\x17": "word",
2152
+ "\t": "tab",
2153
+ "\x1F": "help",
2154
+ "\x1BOP": "help",
2155
+ "\x1B[11~": "help"
2156
+ };
2157
+ function parseKeys(input, paste = { active: false }, ctrls = []) {
2158
+ const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
2052
2159
  return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
2160
+ const named = codes.get(sequence);
2161
+ const key = named === undefined ? KEYS[sequence] : { ctrl: named };
2053
2162
  if (sequence === PASTE_START || sequence === PASTE_END) {
2054
2163
  paste.active = sequence === PASTE_START;
2055
2164
  return [];
@@ -2057,9 +2166,17 @@ function readKeys(input, paste = { active: false }) {
2057
2166
  if (paste.active && (sequence === "\r" || sequence === `
2058
2167
  `))
2059
2168
  return [];
2060
- return KEYS[sequence] ?? (CONTROL2.test(sequence) ? [] : [{ text: sequence }]);
2169
+ if (key !== undefined)
2170
+ return [key];
2171
+ return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
2061
2172
  });
2062
2173
  }
2174
+
2175
+ // ../kit/src/prompt.ts
2176
+ var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
2177
+ function readKeys(input, paste = { active: false }) {
2178
+ return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key));
2179
+ }
2063
2180
  async function confirm(question, { default: fallback, ...settings } = {}) {
2064
2181
  let answered = fallback;
2065
2182
  const choices = { true: "Y/n", false: "y/N", undefined: "y/n" }[String(fallback)];
@@ -2082,7 +2199,7 @@ function asking(colors, question, typed, keys) {
2082
2199
  function answer(colors, question, state, picked) {
2083
2200
  return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
2084
2201
  }
2085
- async function ask(question, { hint, terminal = process19 }, render, press) {
2202
+ async function ask(question, { hint, terminal = process20 }, render, press) {
2086
2203
  const { stdin, stderr } = terminal;
2087
2204
  if (!isInteractive(terminal))
2088
2205
  fail(`cannot ask "${question}" off a terminal`, 2, hint);
@@ -2143,13 +2260,13 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
2143
2260
  // src/apply.ts
2144
2261
  import { existsSync as existsSync10 } from "fs";
2145
2262
  import { lstat as lstat3, rm } from "fs/promises";
2146
- import { basename as basename3, join as join12 } from "path";
2263
+ import { basename as basename4, join as join12 } from "path";
2147
2264
 
2148
2265
  // src/sweep-scan.ts
2149
2266
  import { existsSync as existsSync9 } from "fs";
2150
2267
  import { lstat as lstat2, readdir as readdir4, realpath } from "fs/promises";
2151
2268
  import { homedir as homedir5 } from "os";
2152
- import { basename as basename2, dirname as dirname5, join as join11 } from "path";
2269
+ import { basename as basename3, dirname as dirname5, join as join11 } from "path";
2153
2270
 
2154
2271
  // src/size.ts
2155
2272
  import { lstat, readdir as readdir3 } from "fs/promises";
@@ -2230,7 +2347,7 @@ var MAX_DEPTH3 = 3;
2230
2347
  var PROJECT_CACHE_NAMES = new Set([".turbo", ".nuxt", ".next", ".svelte-kit"]);
2231
2348
  var GLOBAL_CACHES = [".bun/install/cache", ".npm/_cacache", ".cache/pip", ".cache/uv", ".cache/ms-playwright", ".cache/puppeteer", ".cache/go-build", ".cache/typescript", ".cargo/registry"];
2232
2349
  function isCachePath(path, home = homedir5()) {
2233
- return GLOBAL_CACHES.some((cache) => join11(home, cache) === path) || basename2(path) === ".cache" && basename2(dirname5(path)) === "node_modules";
2350
+ return GLOBAL_CACHES.some((cache) => join11(home, cache) === path) || basename3(path) === ".cache" && basename3(dirname5(path)) === "node_modules";
2234
2351
  }
2235
2352
  async function listing(dir) {
2236
2353
  try {
@@ -2259,7 +2376,7 @@ async function findCandidates(root, home = homedir5(), withGlobal = true) {
2259
2376
  const path = join11(dir, entry.name);
2260
2377
  if (entry.name === ".git")
2261
2378
  continue;
2262
- if (entry.name === ".worktrees" || entry.name === "worktrees" && basename2(dir) === ".claude") {
2379
+ if (entry.name === ".worktrees" || entry.name === "worktrees" && basename3(dir) === ".claude") {
2263
2380
  if (!entry.isDirectory()) {
2264
2381
  found.skipped.push({ path, reason: "symlink" });
2265
2382
  continue;
@@ -2354,7 +2471,7 @@ var worktreesOf = memo(async (repo) => {
2354
2471
  });
2355
2472
  async function judgeFolder(path, kind, inside) {
2356
2473
  const parent = dirname5(path);
2357
- const name = basename2(path);
2474
+ const name = basename3(path);
2358
2475
  const located = await toplevelOf(parent);
2359
2476
  if (located === "failed")
2360
2477
  return { skip: "git failed" };
@@ -2391,7 +2508,7 @@ async function judgeWorktree(path) {
2391
2508
  const changes = status.stdout.split("\x00").filter((line) => line !== "");
2392
2509
  if (changes.some((line) => !line.startsWith("!! ")))
2393
2510
  return keep("uncommitted changes");
2394
- if (changes.some((line) => !line.endsWith("/") || !FOLDER_NAMES.has(basename2(line.slice(3).replace(TRAILING_SLASH, "")))))
2511
+ if (changes.some((line) => !line.endsWith("/") || !FOLDER_NAMES.has(basename3(line.slice(3).replace(TRAILING_SLASH, "")))))
2395
2512
  return keep("ignored files (.env, local data) that removing would delete");
2396
2513
  const unique = await gitIn(path, ["log", "--format=%h", branch, "--not", "--remotes", `--exclude=${branch.replace(HEADS_PREFIX, "")}`, "--branches"]);
2397
2514
  if (unique.code !== 0)
@@ -2424,7 +2541,7 @@ async function inspect2({ candidates, skipped }) {
2424
2541
  async function removeFolder(entry) {
2425
2542
  try {
2426
2543
  const stat = await lstat3(entry.path);
2427
- if (stat.isSymbolicLink() || !stat.isDirectory() || !(FOLDER_NAMES.has(basename3(entry.path)) || entry.kind === "cache" && isCachePath(entry.path)))
2544
+ if (stat.isSymbolicLink() || !stat.isDirectory() || !(FOLDER_NAMES.has(basename4(entry.path)) || entry.kind === "cache" && isCachePath(entry.path)))
2428
2545
  return { path: entry.path, removed: false, error: "no longer a plain folder" };
2429
2546
  if (existsSync10(join12(entry.path, ".git")))
2430
2547
  return { path: entry.path, removed: false, error: "holds a git repository" };
@@ -2563,7 +2680,7 @@ ${$e(reclaimable)} reclaimable${skipped === 0 ? "" : `, ${skipped} skipped (syml
2563
2680
  }
2564
2681
 
2565
2682
  // src/cli.ts
2566
- process20.exitCode = await runCli({
2683
+ process21.exitCode = await runCli({
2567
2684
  name: "ws",
2568
2685
  about: "the repositories under a root: the ones needing attention, the folders worth reclaiming and their known vulnerabilities",
2569
2686
  replaces: "a cd, git status and du loop over each repository of the workspace, and a bun audit run in each",
package/dist/repos-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/repos-cli.ts
5
- import process18 from "process";
5
+ import process19 from "process";
6
6
 
7
7
  // ../kit/src/advisory.ts
8
8
  var SEVERITIES = ["low", "moderate", "high", "critical"];
@@ -348,13 +348,13 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
348
348
  // ../kit/src/theme.ts
349
349
  var DEFAULT = {
350
350
  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" },
351
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
351
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
352
352
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
353
353
  bins: {}
354
354
  };
355
355
  var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
356
356
  var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
357
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
357
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
358
358
  var PRESETS = {
359
359
  default: {},
360
360
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -554,6 +554,21 @@ var STATUS_WORDS = {
554
554
  skipped: ["skipped", "cancelled", "canceled", "manual"]
555
555
  };
556
556
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
557
+ function header(bin, context, stream, env = process6.env) {
558
+ if (!takesControlCodes(stream, env))
559
+ return "";
560
+ const colors = paint(stream, env);
561
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
562
+ const { theme } = activeTheme();
563
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
564
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
565
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
566
+ }
567
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
568
+ const line = header(bin, context, stream, env);
569
+ if (line !== "")
570
+ console.log(line);
571
+ }
557
572
 
558
573
  // ../kit/src/format.ts
559
574
  var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
@@ -1437,6 +1452,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process13.a
1437
1452
  }
1438
1453
  return code;
1439
1454
  }
1455
+ // ../kit/src/folders.ts
1456
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1440
1457
  // ../kit/src/pool.ts
1441
1458
  async function pool(items, limit, task) {
1442
1459
  const results = Array.from({ length: items.length });
@@ -1466,11 +1483,63 @@ function parseSize(text, bareUnit = 1) {
1466
1483
  const suffix = match[2].toLowerCase();
1467
1484
  return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
1468
1485
  }
1486
+ // ../kit/src/watch.ts
1487
+ import process14 from "process";
1488
+ import { format } from "util";
1489
+ var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1490
+ var DEFAULT_SECONDS = 2;
1491
+ var ATTACHED_SHORT = /^-w./;
1492
+ var INTERVAL = /^\d+(?:\.\d+)?(?:ms|[smh])?$/;
1493
+ function watchOption(what) {
1494
+ return { type: "string", short: "w", optional: { bare: "", accepts: INTERVAL }, description: `redraw ${what} every 2s, or every interval given (500ms, 5s), until ctrl-c` };
1495
+ }
1496
+ function withoutWatch(args) {
1497
+ const rest = [];
1498
+ for (let at = 0;at < args.length; at++) {
1499
+ const arg = args[at];
1500
+ if (arg === "--watch" || arg === "-w") {
1501
+ if (args[at + 1] !== undefined && INTERVAL.test(args[at + 1]))
1502
+ at++;
1503
+ } else if (!arg.startsWith("--watch=") && !ATTACHED_SHORT.test(arg)) {
1504
+ rest.push(arg);
1505
+ }
1506
+ }
1507
+ return rest;
1508
+ }
1509
+ async function watching(value, step, stream = process14.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1510
+ const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1511
+ if (!takesControlCodes(stream))
1512
+ badUsage("--watch redraws the screen, so it needs a terminal");
1513
+ let code = 0;
1514
+ for (let round = 0;round < rounds; round++) {
1515
+ const held = [];
1516
+ const { log, info } = console;
1517
+ const write = process14.stdout.write.bind(process14.stdout);
1518
+ const hold = (...parts) => void held.push(`${format(...parts)}
1519
+ `);
1520
+ console.log = hold;
1521
+ console.info = hold;
1522
+ process14.stdout.write = (text) => {
1523
+ held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1524
+ return true;
1525
+ };
1526
+ try {
1527
+ code = await step();
1528
+ } finally {
1529
+ console.log = log;
1530
+ console.info = info;
1531
+ process14.stdout.write = write;
1532
+ }
1533
+ stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1534
+ await sleep(interval);
1535
+ }
1536
+ return code;
1537
+ }
1469
1538
  // ../kit/src/workspace-root.ts
1470
1539
  import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1471
1540
  import { homedir as homedir4 } from "os";
1472
1541
  import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
1473
- import process14 from "process";
1542
+ import process15 from "process";
1474
1543
  function expandHome(path, home) {
1475
1544
  if (path === "~")
1476
1545
  return home;
@@ -1488,20 +1557,20 @@ function configured(env, home) {
1488
1557
  return;
1489
1558
  }
1490
1559
  }
1491
- function workspaceRoot({ given, env = process14.env, home = homedir4() } = {}) {
1560
+ function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
1492
1561
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1493
1562
  return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1494
1563
  }
1495
1564
  // src/repos.ts
1496
1565
  import { existsSync as existsSync6, statSync as statSync2 } from "fs";
1497
- import { relative } from "path";
1498
- import process17 from "process";
1566
+ import { basename as basename2, relative } from "path";
1567
+ import process18 from "process";
1499
1568
 
1500
1569
  // src/repos-scan.ts
1501
1570
  import { existsSync as existsSync5 } from "fs";
1502
1571
  import { readdir } from "fs/promises";
1503
1572
  import { basename, join as join7 } from "path";
1504
- import process16 from "process";
1573
+ import process17 from "process";
1505
1574
  var MAX_DEPTH = 3;
1506
1575
  var CONCURRENCY = 8;
1507
1576
  var PACKAGE_CONCURRENCY = 4;
@@ -1548,7 +1617,7 @@ async function findRepos(root, skip) {
1548
1617
  }
1549
1618
  async function read(path, args, timeoutMs = GIT_MS) {
1550
1619
  try {
1551
- const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...process16.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs });
1620
+ const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...process17.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs });
1552
1621
  return ran.code === 0 && !ran.timedOut ? ran.text.trim() : undefined;
1553
1622
  } catch {
1554
1623
  return;
@@ -1625,7 +1694,7 @@ function firstLine(text) {
1625
1694
  }
1626
1695
  async function fastForward(path) {
1627
1696
  try {
1628
- const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...process16.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs: GIT_MS });
1697
+ const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...process17.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs: GIT_MS });
1629
1698
  if (ran.timedOut)
1630
1699
  return "timed out";
1631
1700
  return ran.code === 0 ? undefined : firstLine(ran.text.trim()) || `exit ${ran.code}`;
@@ -1646,8 +1715,9 @@ var EXITS = [[0, "it listed the repositories, including when none needs attentio
1646
1715
  var OPTIONS = {
1647
1716
  all: { type: "boolean", short: "a", description: "list the repositories with nothing to report too" },
1648
1717
  only: { type: "string", choices: REASONS, description: "only the repositories with this reason: dirty, unpushed, unreleased or behind" },
1649
- fetch: { type: "boolean", description: "refresh the upstreams first (reaches the remote)" },
1650
- pull: { type: "boolean", description: "fetch, then fast-forward the clean repositories listed that are only behind their upstream (reaches the remote)" },
1718
+ watch: watchOption("the repositories"),
1719
+ fetch: { type: "boolean", conflicts: ["watch"], description: "refresh the upstreams first (reaches the remote)" },
1720
+ pull: { type: "boolean", conflicts: ["watch"], description: "fetch, then fast-forward the clean repositories listed that are only behind their upstream (reaches the remote)" },
1651
1721
  path: { type: "boolean", conflicts: ["json"], description: "print only the paths of the repositories listed, one per line" },
1652
1722
  json: jsonOption("[{name, path, branch, upstream, dirty, ahead, behind, worktrees, tag, unreleased, packages, reasons, fetchFailed, unreadable}]")
1653
1723
  };
@@ -1667,7 +1737,7 @@ function releasedCell(repo) {
1667
1737
  return repo.packages.filter((release) => release.unreleased > 0).map((release) => `${release.name} ${release.unreleased}`).join(", ") || "-";
1668
1738
  return repo.tag === null || repo.unreleased === 0 ? "-" : `${repo.unreleased} since ${repo.tag}`;
1669
1739
  }
1670
- function syncCell(repo, stream = process17.stdout) {
1740
+ function syncCell(repo, stream = process18.stdout) {
1671
1741
  const colors = paint(stream);
1672
1742
  const ahead = repo.ahead ?? 0;
1673
1743
  const behind = repo.behind ?? 0;
@@ -1678,7 +1748,7 @@ function syncCell(repo, stream = process17.stdout) {
1678
1748
  return parts.length === 0 ? colors.dim("-") : `${parts.join(" ")}${diverged ? colors.yellow(" diverged") : ""}`;
1679
1749
  }
1680
1750
  var DEFAULT_BRANCHES = new Set(["main", "master"]);
1681
- function branchCell(repo, stream = process17.stdout) {
1751
+ function branchCell(repo, stream = process18.stdout) {
1682
1752
  const colors = paint(stream);
1683
1753
  if (repo.unreadable)
1684
1754
  return colors.red("? (unreadable)");
@@ -1687,8 +1757,8 @@ function branchCell(repo, stream = process17.stdout) {
1687
1757
  return DEFAULT_BRANCHES.has(repo.branch) ? repo.branch : role("accent", stream)(repo.branch);
1688
1758
  }
1689
1759
  function row(repo, shown) {
1690
- const colors = paint(process17.stdout);
1691
- const tint = role("path", process17.stdout);
1760
+ const colors = paint(process18.stdout);
1761
+ const tint = role("path", process18.stdout);
1692
1762
  const unreleased = releasedCell(repo);
1693
1763
  return [
1694
1764
  tint(shown),
@@ -1701,6 +1771,8 @@ function row(repo, shown) {
1701
1771
  }
1702
1772
  async function repos(args) {
1703
1773
  const { values, positionals } = parse(args, USAGE, OPTIONS, { positionals: ["[root]"], exits: EXITS, replaces: "a cd, git status, git log and git tag loop over each repository of the workspace", examples: ["repos", "repos ~/Workspace --only unreleased --fetch", ["repos --only behind --pull", "fast-forward what is behind and clean"], ["repos --only dirty --path", "the paths, for xargs"]] });
1774
+ if (values.watch !== undefined)
1775
+ return watching(values.watch, async () => repos(withoutWatch(args)));
1704
1776
  const root = workspaceRoot({ given: positionals[0] });
1705
1777
  if (!existsSync6(root) || !statSync2(root).isDirectory())
1706
1778
  fail(`no folder ${root}`);
@@ -1720,12 +1792,12 @@ async function repos(args) {
1720
1792
  const blocker = pullBlocker(repo);
1721
1793
  const refused = blocker === undefined ? await fastForward(repo.path) : undefined;
1722
1794
  if (blocker !== undefined) {
1723
- log(marked("note", `${repo.name} skipped`, process17.stdout, blocker));
1795
+ log(marked("note", `${repo.name} skipped`, process18.stdout, blocker));
1724
1796
  } else if (refused !== undefined) {
1725
1797
  failedPulls++;
1726
- log(marked("problem", `${repo.name} not pulled`, process17.stdout, refused));
1798
+ log(marked("problem", `${repo.name} not pulled`, process18.stdout, refused));
1727
1799
  } else {
1728
- log(marked("ok", `${repo.name} pulled`, process17.stdout, `${repo.behind} ${repo.behind === 1 ? "commit" : "commits"}`));
1800
+ log(marked("ok", `${repo.name} pulled`, process18.stdout, `${repo.behind} ${repo.behind === 1 ? "commit" : "commits"}`));
1729
1801
  states[index] = await inspect(repo.path, false);
1730
1802
  }
1731
1803
  }
@@ -1740,7 +1812,8 @@ async function repos(args) {
1740
1812
  printJson(kept.map((repo) => ({ ...repo, reasons: reasonsOf(repo) })));
1741
1813
  return failedPulls > 0 ? 1 : 0;
1742
1814
  }
1743
- const label = role("label", process17.stdout);
1815
+ const label = role("label", process18.stdout);
1816
+ printHeader("repos", basename2(root) || undefined);
1744
1817
  if (kept.length === 0) {
1745
1818
  console.log(label(`nothing needs attention in ${states.length} repositories`));
1746
1819
  return failedPulls > 0 ? 1 : 0;
@@ -1755,4 +1828,4 @@ async function repos(args) {
1755
1828
  }
1756
1829
 
1757
1830
  // src/repos-cli.ts
1758
- process18.exitCode = await runMain({ name: "repos", run: repos });
1831
+ process19.exitCode = await runMain({ name: "repos", run: repos });
package/dist/sweep-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/sweep-cli.ts
5
- import process17 from "process";
5
+ import process18 from "process";
6
6
 
7
7
  // ../kit/src/advisory.ts
8
8
  var SEVERITIES = ["low", "moderate", "high", "critical"];
@@ -348,13 +348,13 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
348
348
  // ../kit/src/theme.ts
349
349
  var DEFAULT = {
350
350
  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" },
351
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
351
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
352
352
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
353
353
  bins: {}
354
354
  };
355
355
  var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
356
356
  var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
357
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
357
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
358
358
  var PRESETS = {
359
359
  default: {},
360
360
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -554,6 +554,21 @@ var STATUS_WORDS = {
554
554
  skipped: ["skipped", "cancelled", "canceled", "manual"]
555
555
  };
556
556
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
557
+ function header(bin, context, stream, env = process6.env) {
558
+ if (!takesControlCodes(stream, env))
559
+ return "";
560
+ const colors = paint(stream, env);
561
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
562
+ const { theme } = activeTheme();
563
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
564
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
565
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
566
+ }
567
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
568
+ const line = header(bin, context, stream, env);
569
+ if (line !== "")
570
+ console.log(line);
571
+ }
557
572
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-hrsswv1w.js
558
573
  function $e(t, e = false, i = 1) {
559
574
  let n = typeof e === "object" ? e : { units: e ? "si" : "iec", dp: i }, { units: s = "iec", dp: u = 1 } = n, r = s === "si" ? 1000 : 1024;
@@ -1448,6 +1463,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process13.a
1448
1463
  }
1449
1464
  return code;
1450
1465
  }
1466
+ // ../kit/src/folders.ts
1467
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1451
1468
  // ../kit/src/pool.ts
1452
1469
  async function pool(items, limit, task) {
1453
1470
  const results = Array.from({ length: items.length });
@@ -1477,11 +1494,63 @@ function parseSize(text, bareUnit = 1) {
1477
1494
  const suffix = match[2].toLowerCase();
1478
1495
  return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
1479
1496
  }
1497
+ // ../kit/src/watch.ts
1498
+ import process14 from "process";
1499
+ import { format } from "util";
1500
+ var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1501
+ var DEFAULT_SECONDS = 2;
1502
+ var ATTACHED_SHORT = /^-w./;
1503
+ var INTERVAL = /^\d+(?:\.\d+)?(?:ms|[smh])?$/;
1504
+ function watchOption(what) {
1505
+ return { type: "string", short: "w", optional: { bare: "", accepts: INTERVAL }, description: `redraw ${what} every 2s, or every interval given (500ms, 5s), until ctrl-c` };
1506
+ }
1507
+ function withoutWatch(args) {
1508
+ const rest = [];
1509
+ for (let at = 0;at < args.length; at++) {
1510
+ const arg = args[at];
1511
+ if (arg === "--watch" || arg === "-w") {
1512
+ if (args[at + 1] !== undefined && INTERVAL.test(args[at + 1]))
1513
+ at++;
1514
+ } else if (!arg.startsWith("--watch=") && !ATTACHED_SHORT.test(arg)) {
1515
+ rest.push(arg);
1516
+ }
1517
+ }
1518
+ return rest;
1519
+ }
1520
+ async function watching(value, step, stream = process14.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1521
+ const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1522
+ if (!takesControlCodes(stream))
1523
+ badUsage("--watch redraws the screen, so it needs a terminal");
1524
+ let code = 0;
1525
+ for (let round = 0;round < rounds; round++) {
1526
+ const held = [];
1527
+ const { log, info } = console;
1528
+ const write = process14.stdout.write.bind(process14.stdout);
1529
+ const hold = (...parts) => void held.push(`${format(...parts)}
1530
+ `);
1531
+ console.log = hold;
1532
+ console.info = hold;
1533
+ process14.stdout.write = (text) => {
1534
+ held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1535
+ return true;
1536
+ };
1537
+ try {
1538
+ code = await step();
1539
+ } finally {
1540
+ console.log = log;
1541
+ console.info = info;
1542
+ process14.stdout.write = write;
1543
+ }
1544
+ stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1545
+ await sleep(interval);
1546
+ }
1547
+ return code;
1548
+ }
1480
1549
  // ../kit/src/workspace-root.ts
1481
1550
  import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
1482
1551
  import { homedir as homedir4 } from "os";
1483
1552
  import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
1484
- import process14 from "process";
1553
+ import process15 from "process";
1485
1554
  function expandHome(path, home) {
1486
1555
  if (path === "~")
1487
1556
  return home;
@@ -1499,7 +1568,7 @@ function configured(env, home) {
1499
1568
  return;
1500
1569
  }
1501
1570
  }
1502
- function workspaceRoot({ given, env = process14.env, home = homedir4() } = {}) {
1571
+ function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
1503
1572
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1504
1573
  return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1505
1574
  }
@@ -1509,14 +1578,50 @@ import { homedir as homedir6 } from "os";
1509
1578
  import { relative } from "path";
1510
1579
 
1511
1580
  // ../kit/src/prompt.ts
1512
- import process16 from "process";
1513
- var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|[\s\S]/giu;
1514
- var CONTROL2 = /^[\x00-\x1F\x7F]/;
1581
+ import process17 from "process";
1582
+
1583
+ // ../kit/src/picker/score.ts
1584
+ var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
1585
+ var NONE = Number.NEGATIVE_INFINITY;
1586
+
1587
+ // ../kit/src/picker/state.ts
1588
+ var IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
1515
1589
  var PASTE_START = "\x1B[200~";
1516
1590
  var PASTE_END = "\x1B[201~";
1517
- var KEYS = { "\x1B[A": "up", "\x1BOA": "up", "\x1B[B": "down", "\x1BOB": "down", "\x1B[5~": "pageup", "\x1B[6~": "pagedown", "\x1B[H": "home", "\x1B[1~": "home", "\x1BOH": "home", "\x1B[F": "end", "\x1B[4~": "end", "\x1BOF": "end", "\r": "enter", "\n": "enter", "\x03": "cancel", "\x1B": "cancel", "\x7F": "erase", "\b": "erase" };
1518
- function readKeys(input, paste = { active: false }) {
1591
+ var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
1592
+ var KEYS = {
1593
+ "\x1B[A": "up",
1594
+ "\x1BOA": "up",
1595
+ "\x10": "up",
1596
+ "\x1B[B": "down",
1597
+ "\x1BOB": "down",
1598
+ "\x0E": "down",
1599
+ "\x1B[5~": "pageup",
1600
+ "\x1B[6~": "pagedown",
1601
+ "\x1B[H": "home",
1602
+ "\x1B[1~": "home",
1603
+ "\x1BOH": "home",
1604
+ "\x1B[F": "end",
1605
+ "\x1B[4~": "end",
1606
+ "\x1BOF": "end",
1607
+ "\r": "enter",
1608
+ "\n": "enter",
1609
+ "\x03": "cancel",
1610
+ "\x1B": "cancel",
1611
+ "\x7F": "erase",
1612
+ "\b": "erase",
1613
+ "\x15": "clear",
1614
+ "\x17": "word",
1615
+ "\t": "tab",
1616
+ "\x1F": "help",
1617
+ "\x1BOP": "help",
1618
+ "\x1B[11~": "help"
1619
+ };
1620
+ function parseKeys(input, paste = { active: false }, ctrls = []) {
1621
+ const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
1519
1622
  return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
1623
+ const named = codes.get(sequence);
1624
+ const key = named === undefined ? KEYS[sequence] : { ctrl: named };
1520
1625
  if (sequence === PASTE_START || sequence === PASTE_END) {
1521
1626
  paste.active = sequence === PASTE_START;
1522
1627
  return [];
@@ -1524,9 +1629,17 @@ function readKeys(input, paste = { active: false }) {
1524
1629
  if (paste.active && (sequence === "\r" || sequence === `
1525
1630
  `))
1526
1631
  return [];
1527
- return KEYS[sequence] ?? (CONTROL2.test(sequence) ? [] : [{ text: sequence }]);
1632
+ if (key !== undefined)
1633
+ return [key];
1634
+ return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
1528
1635
  });
1529
1636
  }
1637
+
1638
+ // ../kit/src/prompt.ts
1639
+ var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
1640
+ function readKeys(input, paste = { active: false }) {
1641
+ return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key));
1642
+ }
1530
1643
  async function confirm(question, { default: fallback, ...settings } = {}) {
1531
1644
  let answered = fallback;
1532
1645
  const choices = { true: "Y/n", false: "y/N", undefined: "y/n" }[String(fallback)];
@@ -1549,7 +1662,7 @@ function asking(colors, question, typed, keys) {
1549
1662
  function answer(colors, question, state, picked) {
1550
1663
  return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1551
1664
  }
1552
- async function ask(question, { hint, terminal = process16 }, render, press) {
1665
+ async function ask(question, { hint, terminal = process17 }, render, press) {
1553
1666
  const { stdin, stderr } = terminal;
1554
1667
  if (!isInteractive(terminal))
1555
1668
  fail(`cannot ask "${question}" off a terminal`, 2, hint);
@@ -2030,4 +2143,4 @@ ${$e(reclaimable)} reclaimable${skipped === 0 ? "" : `, ${skipped} skipped (syml
2030
2143
  }
2031
2144
 
2032
2145
  // src/sweep-cli.ts
2033
- process17.exitCode = await runMain({ name: "sweep", run: sweep });
2146
+ process18.exitCode = await runMain({ name: "sweep", run: sweep });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-workspace",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.8.0",
5
5
  "description": "ws, repos, sweep, audit: the repositories of the workspace that need attention, the folders worth reclaiming and their known vulnerabilities.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -34,6 +34,6 @@
34
34
  "audit": "$npm_execpath src/audit-cli.ts"
35
35
  },
36
36
  "devDependencies": {
37
- "@kaynooo/cli-kit": "0.25.0"
37
+ "@kaynooo/cli-kit": "0.28.0"
38
38
  }
39
39
  }