@kaynooo/cli-forgejo 0.29.0 → 0.30.2

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 +1 -1
  2. package/dist/cli.js +559 -247
  3. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process29 from "process";
5
+ import process31 from "process";
6
6
  // ../kit/src/args.ts
7
7
  import process10 from "process";
8
8
  import { parseArgs } from "util";
@@ -568,24 +568,20 @@ function formatPercent(ratio, digits = 0) {
568
568
 
569
569
  // ../kit/src/help.ts
570
570
  import process8 from "process";
571
- var OPTIONAL = /\[[^\]]+\]/g;
571
+ var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
572
572
  var USAGE_PREFIX = /^usage:\s*/i;
573
573
  var FULL_STOP = /\.$/;
574
574
  function usageLine(usage, colors = paint(process8.stdout)) {
575
575
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
576
576
  }
577
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
578
- return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
577
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
578
+ return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
579
579
  `);
580
580
  }
581
581
  function exitRows(exits, colors = paint(process8.stdout)) {
582
582
  if (exits.length === 0)
583
583
  return [];
584
- const width = Math.max(...exits.map(([code]) => String(code).length));
585
- return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
586
- }
587
- function replacesRows(replaces, colors = paint(process8.stdout)) {
588
- return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
584
+ return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
589
585
  }
590
586
  function wantsHelpJson(env = process8.env) {
591
587
  return env.KIT_HELP === "json";
@@ -611,29 +607,44 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
611
607
  return [];
612
608
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
613
609
  }
610
+ var MAX_INLINE_CHOICES = 24;
614
611
  function optionRows(options, colors = paint(process8.stdout)) {
615
612
  const rows = Object.entries(options).map(([name, option]) => {
616
613
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
617
- const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
614
+ const choices = option.choices?.join("|");
615
+ const inline = choices !== undefined && choices.length <= MAX_INLINE_CHOICES;
616
+ const named = inline ? `<${choices}>` : "<value>";
618
617
  const placeholder = option.optional === undefined ? named : `[${named}]`;
619
618
  const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
620
- return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
619
+ const described = choices === undefined || inline ? option.description ?? "" : [option.description, `one of ${option.choices.join(", ")}`].filter(Boolean).join("; ");
620
+ return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: described };
621
621
  });
622
622
  const width = Math.max(0, ...rows.map((row) => row.width));
623
623
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
624
624
  }
625
625
 
626
626
  // ../kit/src/text.ts
627
- var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
627
+ var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
628
+ function stripAnsi(text) {
629
+ return text.replace(ANSI, "");
630
+ }
628
631
  function distance(a, b) {
629
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
630
- for (const [i, left] of [...a].entries()) {
632
+ const left = [...a];
633
+ const right = [...b];
634
+ let before = [];
635
+ let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
636
+ for (const [i, x] of left.entries()) {
631
637
  const current = [i + 1];
632
- for (const [j, right] of [...b].entries())
633
- current.push(Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (left === right ? 0 : 1)));
638
+ for (const [j, y] of right.entries()) {
639
+ let cost = Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (x === y ? 0 : 1));
640
+ if (i > 0 && j > 0 && x === right[j - 1] && left[i - 1] === y)
641
+ cost = Math.min(cost, (before[j - 1] ?? 0) + 1);
642
+ current.push(cost);
643
+ }
644
+ before = previous;
634
645
  previous = current;
635
646
  }
636
- return previous[b.length] ?? 0;
647
+ return previous[right.length] ?? 0;
637
648
  }
638
649
  function closest(name, names) {
639
650
  const started = names.find((known) => known.startsWith(name));
@@ -725,7 +736,7 @@ class Completing {
725
736
  }
726
737
  var completion = { active: false };
727
738
  var OUTPUT_OPTIONS = {
728
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
739
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
729
740
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
730
741
  };
731
742
  function applyOutput(color, plain, env = process10.env) {
@@ -1356,13 +1367,91 @@ function ciHeader(spinner, label, startedAt, out) {
1356
1367
  // ../kit/src/cli.ts
1357
1368
  import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1358
1369
  import { dirname as dirname3, join as join5 } from "path";
1359
- import process17 from "process";
1370
+ import process18 from "process";
1371
+
1372
+ // ../kit/src/completions.ts
1373
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
1374
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
1375
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
1376
+ set -l current (commandline -ct)
1377
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
1378
+ if test "$line" = __files__
1379
+ __fish_complete_path $current
1380
+ else
1381
+ echo $line
1382
+ end
1383
+ end
1384
+ end`;
1385
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
1386
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
1387
+ local -a lines
1388
+ COMPREPLY=()
1389
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
1390
+ for line in "\${lines[@]}"; do
1391
+ if [[ $line == __files__ ]]; then
1392
+ COMPREPLY+=($(compgen -f -- "$cur"))
1393
+ else
1394
+ words+="\${line%%$'\\t'*}"$'\\n'
1395
+ fi
1396
+ done
1397
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
1398
+ }`;
1399
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1400
+ local line
1401
+ local -a described plain
1402
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
1403
+ if [[ $line == __files__ ]]; then
1404
+ _files
1405
+ elif [[ $line == *$'\\t'* ]]; then
1406
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
1407
+ else
1408
+ plain+=("$line")
1409
+ fi
1410
+ done
1411
+ (( \${#described} )) && _describe -V value described
1412
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
1413
+ return 0
1414
+ }`;
1415
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1416
+ if (shell === "fish")
1417
+ return `${header}
1418
+ ${FISH_FUNCTION}
1419
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
1420
+ `).join("")}`;
1421
+ if (shell === "bash")
1422
+ return `${header}
1423
+ ${BASH_FUNCTION}
1424
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1425
+ `;
1426
+ return `${header}
1427
+ ${ZSH_FUNCTION}
1428
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1429
+ `;
1430
+ }
1431
+
1432
+ // ../kit/src/notify.ts
1433
+ import process16 from "process";
1434
+ var NOTIFY_AFTER_MS = 1e4;
1435
+ var CANCELLED = 130;
1436
+ function base64(text) {
1437
+ return Buffer.from(text).toString("base64");
1438
+ }
1439
+ function notification(title, body, env = process16.env) {
1440
+ const id = `kit${process16.pid}`;
1441
+ const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
1442
+ return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1443
+ }
1444
+ function notifyEnd(command, code, ms, { stream = process16.stderr, env = process16.env } = {}) {
1445
+ if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1446
+ return;
1447
+ stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1448
+ }
1360
1449
 
1361
1450
  // ../kit/src/usage.ts
1362
1451
  import { appendFileSync, mkdirSync } from "fs";
1363
1452
  import { homedir as homedir3 } from "os";
1364
1453
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1365
- import process16 from "process";
1454
+ import process17 from "process";
1366
1455
 
1367
1456
  // ../kit/src/logs.ts
1368
1457
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -1376,14 +1465,14 @@ var usageError;
1376
1465
  function noteUsageError(message) {
1377
1466
  usageError = message;
1378
1467
  }
1379
- function stateHome(env = process16.env) {
1468
+ function stateHome(env = process17.env) {
1380
1469
  const dir = env.XDG_STATE_HOME;
1381
1470
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
1382
1471
  }
1383
- function usagePath(env = process16.env) {
1472
+ function usagePath(env = process17.env) {
1384
1473
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
1385
1474
  }
1386
- function usageRecorded(env = process16.env) {
1475
+ function usageRecorded(env = process17.env) {
1387
1476
  const off = env.KAYNOOO_CLI_NO_USAGE;
1388
1477
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1389
1478
  }
@@ -1397,7 +1486,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1397
1486
  usageError = undefined;
1398
1487
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1399
1488
  }
1400
- function recordUsage(entry, env = process16.env) {
1489
+ function recordUsage(entry, env = process17.env) {
1401
1490
  if (!usageRecorded(env))
1402
1491
  return;
1403
1492
  try {
@@ -1413,7 +1502,11 @@ var LEVEL_OPTIONS = {
1413
1502
  ...OUTPUT_OPTIONS,
1414
1503
  help: { type: "boolean", short: "h", description: "show this help" }
1415
1504
  };
1416
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1505
+ var TOP_OPTIONS = {
1506
+ ...LEVEL_OPTIONS,
1507
+ version: { type: "boolean", short: "v", description: "print the version" },
1508
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1509
+ };
1417
1510
  async function commandRows(all, colors) {
1418
1511
  const commands = shown(all);
1419
1512
  const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
@@ -1474,7 +1567,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1474
1567
  header(colors, summary),
1475
1568
  "",
1476
1569
  usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
1477
- ...replacesRows(replaces, colors),
1478
1570
  "",
1479
1571
  ...await commandRows(commands, colors),
1480
1572
  ...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
@@ -1488,8 +1580,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1488
1580
  `);
1489
1581
  }
1490
1582
  function printError(prefix, message, hint, cause) {
1491
- const colors = paint(process17.stderr);
1492
- const styled = takesControlCodes(process17.stderr);
1583
+ const colors = paint(process18.stderr);
1584
+ const styled = takesControlCodes(process18.stderr);
1493
1585
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1494
1586
  const under = (label, text, tint) => text === undefined ? "" : `
1495
1587
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1499,8 +1591,8 @@ function runHint(command, effect) {
1499
1591
  return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
1500
1592
  }
1501
1593
  function printHint(hint) {
1502
- const colors = paint(process17.stderr);
1503
- console.error(` ${takesControlCodes(process17.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
1594
+ const colors = paint(process18.stderr);
1595
+ console.error(` ${takesControlCodes(process18.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
1504
1596
  }
1505
1597
  function printJsonError(message, hint, cause) {
1506
1598
  console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
@@ -1539,11 +1631,11 @@ async function dispatch(level, typed, { version, redact }) {
1539
1631
  }
1540
1632
  }
1541
1633
  if (name === undefined && level.path.length > 1) {
1542
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stderr));
1634
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process18.stderr));
1543
1635
  return 2;
1544
1636
  }
1545
1637
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1546
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stdout));
1638
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process18.stdout));
1547
1639
  return 0;
1548
1640
  }
1549
1641
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1654,6 +1746,19 @@ async function candidates(scope, defaultCommand, words, before = []) {
1654
1746
  }
1655
1747
  return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
1656
1748
  }
1749
+ var COMPLETIONS = "--completions";
1750
+ function flagValue([flag = "", ...rest]) {
1751
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1752
+ }
1753
+ function printCompletionScript(name, args) {
1754
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1755
+ if (shell === undefined || args.length !== 1) {
1756
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1757
+ return 2;
1758
+ }
1759
+ console.log(completionScript(shell, [name]).trimEnd());
1760
+ return 0;
1761
+ }
1657
1762
  async function printCandidates(found) {
1658
1763
  for (const line of await found)
1659
1764
  console.log(line);
@@ -1678,10 +1783,15 @@ async function runCli(cli, argv = scriptArgs()) {
1678
1783
  const version = cli.version ?? packageVersion();
1679
1784
  if (argv[0] === COMPLETE)
1680
1785
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
1786
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1787
+ return printCompletionScript(cli.name, flagValue(argv));
1788
+ const started = performance.now();
1681
1789
  const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
1790
+ const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
1791
+ notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
1682
1792
  if (cli.usage !== false) {
1683
1793
  try {
1684
- recordUsage(usageEntry(cli.name, commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv), argv, code));
1794
+ recordUsage(usageEntry(cli.name, command, argv, code));
1685
1795
  } catch {}
1686
1796
  }
1687
1797
  return code;
@@ -1701,11 +1811,130 @@ function commandPath(scope, argv) {
1701
1811
  }
1702
1812
  return path.length === 0 ? undefined : path.join(" ");
1703
1813
  }
1814
+ // ../kit/src/excerpt.ts
1815
+ var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
1816
+ var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
1817
+ var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
1818
+ var BUN_CHECK_SUMMARY = /^Found \d+ errors?/;
1819
+ var TSC_ERROR = /\berror TS\d+/;
1820
+ var TSC_CONTINUATION = /^\s{2,}\S/;
1821
+ var TSC_FRAME = /^\s*[~^|]/;
1822
+ var TSC_SUMMARY = /^Found \d+ errors?/;
1823
+ var ESLINT_PROBLEM = /^\s+\d+:\d+\s+(?:error|warning)\s/;
1824
+ var ESLINT_SUMMARY = /^(?:\u2716 )?\d+ problems? \(/;
1825
+ var PHPSTAN_TABLE = /^\s*-{3,} -{3,}/;
1826
+ var PHPSTAN_NOISE = /^\s*\[OK\]/;
1827
+ var VITEST_FAIL_LINE = /^ FAIL {2}\S/;
1828
+ var PLAYWRIGHT_FAIL_LINE = /^ {2}1\) .+:\d+:\d+ \u203A .+ \u2500+$/;
1829
+ var CS_FIXER_LINE = /^\s+\d+\) \S.*\.php(?: \(.+\))?$/;
1830
+ var CS_FIXER_TOTAL = /^Found \d+ of \d+ files/;
1831
+ var MAX_LINES = 100;
1832
+ var bunCheck = (lines) => {
1833
+ const text = lines.join(`
1834
+ `);
1835
+ const blocks = text.match(BUN_CHECK_BLOCK);
1836
+ if (blocks === null)
1837
+ return;
1838
+ const errors = blocks.map((block) => {
1839
+ const { file, line, column, code, message } = bunCheckFields(block);
1840
+ return `${file}:${line}:${column} ${code}: ${message}`;
1841
+ });
1842
+ return [...errors, ...lines.filter((line) => BUN_CHECK_SUMMARY.test(line))];
1843
+ };
1844
+ function bunCheckFields(block) {
1845
+ const attributes = Object.fromEntries([...block.slice(0, block.indexOf(`
1846
+ `)).matchAll(BUN_CHECK_ATTRIBUTE)].map((match) => [match[1] ?? "", match[2] ?? ""]));
1847
+ return {
1848
+ file: attributes.file ?? "",
1849
+ line: attributes.line ?? "",
1850
+ column: attributes.column ?? "",
1851
+ code: attributes.code ?? "",
1852
+ message: block.replace(BUN_CHECK_SOURCE, "").split(`
1853
+ `).slice(1, -1).join(`
1854
+ `).trim()
1855
+ };
1856
+ }
1857
+ var tsc = (lines) => {
1858
+ const kept = [];
1859
+ let inError = false;
1860
+ for (const line of lines) {
1861
+ if (TSC_ERROR.test(line)) {
1862
+ inError = true;
1863
+ kept.push(line);
1864
+ } else if (TSC_SUMMARY.test(line)) {
1865
+ inError = false;
1866
+ kept.push(line);
1867
+ } else if (inError && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
1868
+ kept.push(line);
1869
+ } else {
1870
+ inError = false;
1871
+ }
1872
+ }
1873
+ return kept.some((line) => TSC_ERROR.test(line)) ? kept : undefined;
1874
+ };
1875
+ var eslint = (lines) => {
1876
+ const kept = [];
1877
+ let file = "";
1878
+ let shown = "";
1879
+ for (const line of lines) {
1880
+ if (ESLINT_PROBLEM.test(line)) {
1881
+ if (file !== shown) {
1882
+ kept.push(file);
1883
+ shown = file;
1884
+ }
1885
+ kept.push(line);
1886
+ } else if (ESLINT_SUMMARY.test(line)) {
1887
+ kept.push(line);
1888
+ } else if (line.trim() !== "") {
1889
+ file = line;
1890
+ }
1891
+ }
1892
+ return kept.some((line) => ESLINT_PROBLEM.test(line)) ? kept : undefined;
1893
+ };
1894
+ var phpstan = (lines) => {
1895
+ const start = lines.findIndex((line) => PHPSTAN_TABLE.test(line));
1896
+ return start === -1 ? undefined : lines.slice(start).filter((line) => !PHPSTAN_NOISE.test(line));
1897
+ };
1898
+ var vitest = (lines) => {
1899
+ const start = lines.findIndex((line) => VITEST_FAIL_LINE.test(line));
1900
+ return start === -1 ? undefined : lines.slice(start);
1901
+ };
1902
+ var playwright = (lines) => {
1903
+ const start = lines.findIndex((line) => PLAYWRIGHT_FAIL_LINE.test(line));
1904
+ return start === -1 ? undefined : lines.slice(start);
1905
+ };
1906
+ var phpCsFixer = (lines) => {
1907
+ const files = lines.filter((line) => CS_FIXER_LINE.test(line) || CS_FIXER_TOTAL.test(line));
1908
+ return files.some((line) => CS_FIXER_LINE.test(line)) ? files : undefined;
1909
+ };
1910
+ var TOOL_PARSERS = [bunCheck, tsc, eslint, vitest, playwright, phpCsFixer, phpstan];
1911
+ function squeeze(lines) {
1912
+ const out = [];
1913
+ for (const line of lines.map((text) => text.trimEnd())) {
1914
+ if (line !== "" || out.at(-1) !== "")
1915
+ out.push(line);
1916
+ }
1917
+ while (out.at(-1) === "")
1918
+ out.pop();
1919
+ return out;
1920
+ }
1921
+ function cut(shown) {
1922
+ return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
1923
+ `) : shown.join(`
1924
+ `);
1925
+ }
1926
+ function recognised(lines, parsers) {
1927
+ return parsers.map((parser) => parser(lines)).find((result) => result !== undefined && result.some((line) => line.trim() !== ""));
1928
+ }
1929
+ function toolExcerpt(lines) {
1930
+ const found = recognised(lines.map((line) => stripAnsi(line)), TOOL_PARSERS);
1931
+ return found === undefined ? undefined : cut(squeeze(found));
1932
+ }
1704
1933
  // ../kit/src/folders.ts
1705
1934
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1706
1935
  // ../kit/src/git.ts
1707
1936
  import { basename, dirname as dirname4 } from "path";
1708
- import process18 from "process";
1937
+ import process19 from "process";
1709
1938
  var ORIGIN_PREFIX = /^origin\//;
1710
1939
  var GIT_NETWORK_MS = 60000;
1711
1940
  async function git(args, timeoutMs) {
@@ -1735,7 +1964,7 @@ async function defaultBranch() {
1735
1964
  async function leaveWorktree() {
1736
1965
  const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
1737
1966
  if (basename(common) === ".git")
1738
- process18.chdir(dirname4(common));
1967
+ process19.chdir(dirname4(common));
1739
1968
  }
1740
1969
  // ../kit/src/limit.ts
1741
1970
  function limitOptions(fallback) {
@@ -1776,15 +2005,15 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
1776
2005
  // ../kit/src/sessions.ts
1777
2006
  import { homedir as homedir4 } from "os";
1778
2007
  import { join as join6 } from "path";
1779
- import process19 from "process";
2008
+ import process20 from "process";
1780
2009
  var {Glob } = globalThis.Bun;
1781
2010
  var SESSION_FILES = new Glob("*.json");
1782
2011
  var ACCOUNT_DIRS = new Glob("*/sessions");
1783
2012
  async function sessionDirs() {
1784
2013
  const home = homedir4();
1785
2014
  const dirs = new Set([join6(home, ".claude", "sessions")]);
1786
- if (process19.env.CLAUDE_CONFIG_DIR !== undefined)
1787
- dirs.add(join6(process19.env.CLAUDE_CONFIG_DIR, "sessions"));
2015
+ if (process20.env.CLAUDE_CONFIG_DIR !== undefined)
2016
+ dirs.add(join6(process20.env.CLAUDE_CONFIG_DIR, "sessions"));
1788
2017
  try {
1789
2018
  for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1790
2019
  dirs.add(dir);
@@ -1830,7 +2059,7 @@ async function liveSessions() {
1830
2059
  }
1831
2060
  async function currentSession(sessions) {
1832
2061
  const byPid = new Map(sessions.map((session) => [session.pid, session]));
1833
- let pid = process19.ppid;
2062
+ let pid = process20.ppid;
1834
2063
  for (let depth = 0;depth < 32 && pid > 1; depth++) {
1835
2064
  const session = byPid.get(pid);
1836
2065
  if (session !== undefined)
@@ -1843,7 +2072,7 @@ async function currentSession(sessions) {
1843
2072
  return;
1844
2073
  }
1845
2074
  // ../kit/src/watch.ts
1846
- import process20 from "process";
2075
+ import process21 from "process";
1847
2076
  import { format } from "util";
1848
2077
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1849
2078
  var DEFAULT_SECONDS = 2;
@@ -1865,7 +2094,7 @@ function withoutWatch(args) {
1865
2094
  }
1866
2095
  return rest;
1867
2096
  }
1868
- async function watching(value, step, stream = process20.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
2097
+ async function watching(value, step, stream = process21.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1869
2098
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1870
2099
  if (!takesControlCodes(stream))
1871
2100
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1873,12 +2102,12 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
1873
2102
  for (let round = 0;round < rounds; round++) {
1874
2103
  const held = [];
1875
2104
  const { log, info } = console;
1876
- const write = process20.stdout.write.bind(process20.stdout);
2105
+ const write = process21.stdout.write.bind(process21.stdout);
1877
2106
  const hold = (...parts) => void held.push(`${format(...parts)}
1878
2107
  `);
1879
2108
  console.log = hold;
1880
2109
  console.info = hold;
1881
- process20.stdout.write = (text) => {
2110
+ process21.stdout.write = (text) => {
1882
2111
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1883
2112
  return true;
1884
2113
  };
@@ -1887,7 +2116,7 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
1887
2116
  } finally {
1888
2117
  console.log = log;
1889
2118
  console.info = info;
1890
- process20.stdout.write = write;
2119
+ process21.stdout.write = write;
1891
2120
  }
1892
2121
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1893
2122
  await sleep(interval);
@@ -2065,9 +2294,9 @@ function holderSession(holder, sessions) {
2065
2294
  }
2066
2295
 
2067
2296
  // src/good.ts
2068
- import process22 from "process";
2297
+ import process23 from "process";
2069
2298
  function good(text) {
2070
- return role("ok", process22.stdout)(text);
2299
+ return role("ok", process23.stdout)(text);
2071
2300
  }
2072
2301
 
2073
2302
  // src/config.ts
@@ -2099,10 +2328,13 @@ async function loadSettings(home) {
2099
2328
  return typeof host === "string" && host !== "" ? { remoteHost: host } : {};
2100
2329
  }
2101
2330
 
2331
+ // src/tea.ts
2332
+ import process25 from "process";
2333
+
2102
2334
  // src/forge.ts
2103
2335
  import { homedir as homedir5 } from "os";
2104
2336
  import { join as join7 } from "path";
2105
- import process23 from "process";
2337
+ import process24 from "process";
2106
2338
 
2107
2339
  // src/remote.ts
2108
2340
  var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
@@ -2141,6 +2373,8 @@ async function reachesHost(hostname, host, hostAddresses, addressesOf) {
2141
2373
  // src/forge.ts
2142
2374
  var LOGIN_HOST = /^\s*(?:-\s*)?(?:url|ssh_host):\s*["']?([^\s"']+)/gm;
2143
2375
  var PORT = /:\d+$/;
2376
+ var LOGIN_LINE = /^\s*(-\s+)?([a-z_]+):(.*)$/;
2377
+ var QUOTES = /^["']|["']$/g;
2144
2378
  var SCP_REMOTE = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)/;
2145
2379
  var URL_REMOTE = /^[a-z+]+:\/\/(?:[^@/\s]+@)?(\[[^\]]+\]|[^:/\s]+)/i;
2146
2380
  function originHost(remote) {
@@ -2157,7 +2391,7 @@ function loginHosts(config) {
2157
2391
  return hosts;
2158
2392
  }
2159
2393
  function teaConfigPath() {
2160
- const base = process23.env.XDG_CONFIG_HOME;
2394
+ const base = process24.env.XDG_CONFIG_HOME;
2161
2395
  return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
2162
2396
  }
2163
2397
  async function readConfig() {
@@ -2176,35 +2410,105 @@ async function requireForgeOrigin() {
2176
2410
  const origin = await runTool("git remote get-url origin", ["git", "remote", "get-url", "origin"], { timeoutMs: 5000 });
2177
2411
  const host = origin.code === 0 ? originHost(origin.stdout) : undefined;
2178
2412
  if (host !== undefined && !hosts.has(host))
2179
- fail(`origin ${redactUrl(origin.stdout.trim())} is not on a Forgejo tea is logged in to (${[...hosts].join(", ")})`, 2, "name the repository with -r owner/name, or run ft in a repository hosted there (an ssh alias origin: ft remote --fix)");
2413
+ fail(`origin ${redactUrl(origin.stdout.trim())} is not on a Forgejo you are logged in to (${[...hosts].join(", ")})`, 2, "name the repository with -r owner/name, or run ft in a repository hosted there (an ssh alias origin: ft remote --fix)");
2180
2414
  })();
2181
2415
  return checked;
2182
2416
  }
2417
+ function teaLogins(config) {
2418
+ const logins = [];
2419
+ let current;
2420
+ const finish = () => {
2421
+ if (current?.url !== undefined && current.token !== undefined && current.token !== "")
2422
+ logins.push({ url: current.url, token: current.token, isDefault: current.default === "true" });
2423
+ };
2424
+ for (const line of config.split(`
2425
+ `)) {
2426
+ const entry = LOGIN_LINE.exec(line);
2427
+ if (entry === null)
2428
+ continue;
2429
+ if (entry[1] !== undefined) {
2430
+ finish();
2431
+ current = {};
2432
+ }
2433
+ if (current !== undefined)
2434
+ current[entry[2]] = (entry[3] ?? "").trim().replace(QUOTES, "");
2435
+ }
2436
+ finish();
2437
+ return logins;
2438
+ }
2439
+ async function pickLogin(useOrigin) {
2440
+ const logins = teaLogins(await readConfig());
2441
+ if (useOrigin) {
2442
+ const origin = await runTool("git remote get-url origin", ["git", "remote", "get-url", "origin"], { timeoutMs: 5000 });
2443
+ const host = origin.code === 0 ? originHost(origin.stdout) : undefined;
2444
+ const match = host === undefined ? undefined : logins.find((each) => URL.canParse(each.url) && new URL(each.url).hostname.toLowerCase() === host);
2445
+ if (match !== undefined)
2446
+ return match;
2447
+ }
2448
+ return logins.find((each) => each.isDefault) ?? logins[0];
2449
+ }
2183
2450
 
2184
2451
  // src/tea.ts
2185
2452
  var TEA_MS = 60000;
2186
2453
  function repoFlag(repo) {
2187
2454
  return repo === undefined ? [] : ["--repo", repo];
2188
2455
  }
2189
- async function request(path, repo) {
2456
+ function usesGt() {
2457
+ const PATH = process25.env.PATH ?? "";
2458
+ return Bun.which("tea", { PATH }) === null && Bun.which("gt", { PATH }) !== null;
2459
+ }
2460
+ var injected;
2461
+ async function injectLogin(repo) {
2462
+ if (process25.env.GITEA_TOKEN !== undefined && process25.env.GITEA_TOKEN !== "")
2463
+ return;
2464
+ const login = await pickLogin(repo === undefined);
2465
+ if (login === undefined)
2466
+ return;
2467
+ injected = login.token;
2468
+ process25.env.GITEA_TOKEN = login.token;
2469
+ process25.env.GITEA_CLI_HOST = login.url;
2470
+ }
2471
+ function scrub(text) {
2472
+ const token = injected ?? process25.env.GITEA_TOKEN;
2473
+ return token === undefined || token === "" ? text : text.replaceAll(token, "***");
2474
+ }
2475
+ function failureText(stdout, stderr, code) {
2476
+ try {
2477
+ const value = JSON.parse(stdout);
2478
+ if (value !== null && typeof value === "object" && "message" in value && typeof value.message === "string")
2479
+ return scrub(value.message);
2480
+ } catch {}
2481
+ return scrub(stderr.trim() || stdout.trim() || `exit ${code}`);
2482
+ }
2483
+ async function runApi(label, args, repo) {
2190
2484
  if (repo === undefined)
2191
2485
  await requireForgeOrigin();
2192
- const result = await runTool(`tea api ${path}`, ["tea", "api", ...repoFlag(repo), path], { timeoutMs: TEA_MS });
2486
+ const gt = usesGt();
2487
+ const bin = gt ? "gt" : "tea";
2488
+ if (gt)
2489
+ await injectLogin(repo);
2490
+ const result = await runTool(`${bin} api ${label}`, [bin, "api", ...repoFlag(repo), ...args], { timeoutMs: TEA_MS });
2193
2491
  if (result.code !== 0)
2194
- throw new Error(`tea api ${path}: ${result.stderr.trim() || `exit ${result.code}`}`);
2195
- return result.stdout;
2492
+ throw new Error(`${bin} api ${label}: ${gt ? failureText(result.stdout, result.stderr, result.code) : result.stderr.trim() || `exit ${result.code}`}`);
2493
+ return gt ? scrub(result.stdout) : result.stdout;
2494
+ }
2495
+ async function request(path, repo) {
2496
+ return runApi(path, [path], repo);
2497
+ }
2498
+ function clientName() {
2499
+ return usesGt() ? "gt" : "tea";
2196
2500
  }
2197
2501
  function parseJson(path, text) {
2198
2502
  let value;
2199
2503
  try {
2200
2504
  value = JSON.parse(text);
2201
2505
  } catch {
2202
- throw new Error(`tea api ${path}: ${upTo(text.trim(), `
2506
+ throw new Error(`${clientName()} api ${path}: ${upTo(text.trim(), `
2203
2507
  `) || "empty answer"}`);
2204
2508
  }
2205
2509
  const failure = apiError(value);
2206
2510
  if (failure !== undefined)
2207
- throw new Error(`tea api ${path}: ${failure}`);
2511
+ throw new Error(`${clientName()} api ${path}: ${failure}`);
2208
2512
  return value;
2209
2513
  }
2210
2514
  function apiError(value) {
@@ -2218,15 +2522,13 @@ async function api(path, repo) {
2218
2522
  async function repoApi(path, repo) {
2219
2523
  return api(`repos/{owner}/{repo}/${path}`, repo);
2220
2524
  }
2221
- async function repoWrite(method, path, fields, repo) {
2525
+ async function repoSend(method, path, fields, repo) {
2222
2526
  const full = `repos/{owner}/{repo}/${path}`;
2223
- const flags = Object.entries(fields).flatMap(([name, value]) => ["-f", `${name}=${value}`]);
2224
- if (repo === undefined)
2225
- await requireForgeOrigin();
2226
- const result = await runTool(`tea api ${full}`, ["tea", "api", ...repoFlag(repo), "-X", method, ...flags, full], { timeoutMs: TEA_MS });
2227
- if (result.code !== 0)
2228
- throw new Error(`tea api ${full}: ${result.stderr.trim() || `exit ${result.code}`}`);
2229
- return parseJson(full, result.stdout);
2527
+ const flags = Object.entries(fields).flatMap(([name, value]) => typeof value === "string" ? ["-f", `${name}=${value}`] : ["-F", `${name}=${JSON.stringify(value)}`]);
2528
+ return runApi(full, ["-X", method, ...flags, full], repo);
2529
+ }
2530
+ async function repoWrite(method, path, fields, repo) {
2531
+ return parseJson(`repos/{owner}/{repo}/${path}`, await repoSend(method, path, fields, repo));
2230
2532
  }
2231
2533
  async function repoApiText(path, repo) {
2232
2534
  const full = `repos/{owner}/{repo}/${path}`;
@@ -2239,7 +2541,7 @@ async function repoApiText(path, repo) {
2239
2541
  }
2240
2542
  const failure = apiError(value);
2241
2543
  if (failure !== undefined)
2242
- throw new Error(`tea api ${full}: ${failure}`);
2544
+ throw new Error(`${clientName()} api ${full}: ${failure}`);
2243
2545
  return text;
2244
2546
  }
2245
2547
  async function tea(command, args, repo) {
@@ -2251,8 +2553,56 @@ async function tea(command, args, repo) {
2251
2553
  return result.stdout;
2252
2554
  }
2253
2555
 
2254
- // src/issues.ts
2556
+ // src/milestones.ts
2255
2557
  var PAGE = 50;
2558
+ var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
2559
+ var NO_DUE_YEAR = 9999;
2560
+ async function listMilestones(state, repo) {
2561
+ const found = [];
2562
+ for (let page = 1;; page++) {
2563
+ const batch = await repoApi(`milestones?state=${state}&page=${page}&limit=${PAGE}`, repo);
2564
+ found.push(...batch);
2565
+ if (batch.length < PAGE)
2566
+ return found;
2567
+ }
2568
+ }
2569
+ async function findMilestone(reference, repo) {
2570
+ const all = await listMilestones("all", repo);
2571
+ const found = all.find((each) => each.title === reference) ?? all.find((each) => String(each.id) === reference);
2572
+ if (found === undefined)
2573
+ fail(`no milestone ${reference}, ${all.length === 0 ? "the repository has none" : `it has: ${all.map((each) => each.title).join(", ")}`}`, 2, runHint(`ft milestone new ${reference}`, "create it"));
2574
+ return found;
2575
+ }
2576
+ function dueOn(value) {
2577
+ const match = DATE.exec(value);
2578
+ const date = new Date(`${value}T00:00:00Z`);
2579
+ if (match === null || Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value || date.getUTCFullYear() < 2000)
2580
+ fail(`--due takes a date as YYYY-MM-DD, not ${value}`);
2581
+ return date.toISOString();
2582
+ }
2583
+ function dueDate(milestone) {
2584
+ if (milestone.due_on === null || new Date(milestone.due_on).getUTCFullYear() >= NO_DUE_YEAR)
2585
+ return "";
2586
+ return milestone.due_on.slice(0, 10);
2587
+ }
2588
+ function progress(milestone) {
2589
+ const total = milestone.open_issues + milestone.closed_issues;
2590
+ return total === 0 ? "" : `${Math.round(milestone.closed_issues / total * 100)}%`;
2591
+ }
2592
+ async function createMilestone(title, description, due, repo) {
2593
+ const fields = { title };
2594
+ if (description !== undefined)
2595
+ fields.description = description;
2596
+ if (due !== undefined)
2597
+ fields.due_on = due;
2598
+ return repoWrite("POST", "milestones", fields, repo);
2599
+ }
2600
+ async function closeMilestone(id, repo) {
2601
+ await repoWrite("PATCH", `milestones/${id}`, { state: "closed" }, repo);
2602
+ }
2603
+
2604
+ // src/issues.ts
2605
+ var PAGE2 = 50;
2256
2606
  var CONCURRENCY = 8;
2257
2607
  async function getIssue(number, repo) {
2258
2608
  return repoApi(`issues/${number}`, repo);
@@ -2260,9 +2610,9 @@ async function getIssue(number, repo) {
2260
2610
  async function listIssues(state, filter, repo) {
2261
2611
  const issues = [];
2262
2612
  for (let page = 1;; page++) {
2263
- const batch = await repoApi(`issues?state=${state}&type=issues&page=${page}&limit=${PAGE}${filter}`, repo);
2613
+ const batch = await repoApi(`issues?state=${state}&type=issues&page=${page}&limit=${PAGE2}${filter}`, repo);
2264
2614
  issues.push(...batch);
2265
- if (batch.length < PAGE)
2615
+ if (batch.length < PAGE2)
2266
2616
  return issues;
2267
2617
  }
2268
2618
  }
@@ -2281,6 +2631,10 @@ async function commentsOfAll(issues, repo) {
2281
2631
  return new Map(commented.map((issue, index) => [issue.number, comments[index]]));
2282
2632
  }
2283
2633
  async function editIssue(number, change, repo) {
2634
+ if (usesGt()) {
2635
+ await repoWrite("PATCH", `issues/${number}`, { ...change.title === undefined ? {} : { title: change.title }, ...change.body === undefined ? {} : { body: change.body }, ...change.milestone === undefined ? {} : { milestone: await milestoneId(change.milestone, repo) } }, repo);
2636
+ return;
2637
+ }
2284
2638
  const args = [String(number)];
2285
2639
  if (change.title !== undefined)
2286
2640
  args.push("-t", change.title);
@@ -2294,6 +2648,9 @@ async function setBody(number, body, repo) {
2294
2648
  await editIssue(number, { body }, repo);
2295
2649
  }
2296
2650
  async function createIssue(title, body, labels, milestone, repo) {
2651
+ if (usesGt()) {
2652
+ return repoWrite("POST", "issues", { title, body, ...labels === undefined ? {} : { labels: await labelIds(labels.split(","), repo) }, ...milestone === undefined ? {} : { milestone: await milestoneId(milestone, repo) } }, repo);
2653
+ }
2297
2654
  const args = ["-t", title, "-d", body];
2298
2655
  const same = (found) => found.title === title && sameText(found.body, body);
2299
2656
  const known = new Set((await openIssues(undefined, repo)).filter(same).map((found) => found.number));
@@ -2346,21 +2703,32 @@ async function comment(number, body, repo) {
2346
2703
  await repoWrite("POST", `issues/${number}/comments`, { body }, repo);
2347
2704
  }
2348
2705
  async function close(number, repo) {
2706
+ if (usesGt())
2707
+ return void await repoWrite("PATCH", `issues/${number}`, { state: "closed" }, repo);
2349
2708
  await tea(["issues", "close"], [String(number)], repo);
2350
2709
  }
2351
2710
  async function reopen(number, repo) {
2711
+ if (usesGt())
2712
+ return void await repoWrite("PATCH", `issues/${number}`, { state: "open" }, repo);
2352
2713
  await tea(["issues", "reopen"], [String(number)], repo);
2353
2714
  }
2354
2715
  async function repoLabels(repo) {
2355
2716
  const names = [];
2356
2717
  for (let page = 1;; page++) {
2357
- const batch = await repoApi(`labels?page=${page}&limit=${PAGE}`, repo);
2718
+ const batch = await repoApi(`labels?page=${page}&limit=${PAGE2}`, repo);
2358
2719
  names.push(...batch.map((each) => each.name));
2359
- if (batch.length < PAGE)
2720
+ if (batch.length < PAGE2)
2360
2721
  return names;
2361
2722
  }
2362
2723
  }
2363
2724
  async function editLabels(number, add, remove, repo) {
2725
+ if (usesGt()) {
2726
+ if (add.length > 0)
2727
+ await repoSend("POST", `issues/${number}/labels`, { labels: await labelIds(add, repo) }, repo);
2728
+ for (const id of await labelIds(remove, repo))
2729
+ await repoSend("DELETE", `issues/${number}/labels/${id}`, {}, repo);
2730
+ return;
2731
+ }
2364
2732
  const args = [String(number)];
2365
2733
  if (add.length > 0)
2366
2734
  args.push("--add-labels", add.join(","));
@@ -2368,53 +2736,23 @@ async function editLabels(number, add, remove, repo) {
2368
2736
  args.push("--remove-labels", remove.join(","));
2369
2737
  await tea(["issues", "edit"], args, repo);
2370
2738
  }
2371
-
2372
- // src/milestones.ts
2373
- var PAGE2 = 50;
2374
- var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
2375
- var NO_DUE_YEAR = 9999;
2376
- async function listMilestones(state, repo) {
2377
- const found = [];
2739
+ async function labelIds(names, repo) {
2740
+ const all = [];
2378
2741
  for (let page = 1;; page++) {
2379
- const batch = await repoApi(`milestones?state=${state}&page=${page}&limit=${PAGE2}`, repo);
2380
- found.push(...batch);
2742
+ const batch = await repoApi(`labels?page=${page}&limit=${PAGE2}`, repo);
2743
+ all.push(...batch);
2381
2744
  if (batch.length < PAGE2)
2382
- return found;
2745
+ break;
2383
2746
  }
2747
+ return names.map((name) => name.trim()).filter((name) => name !== "").map((name) => {
2748
+ const found = all.find((each) => each.name === name);
2749
+ if (found === undefined)
2750
+ throw new Error(`no label ${name}, the repository has: ${all.map((each) => each.name).join(", ")}`);
2751
+ return found.id;
2752
+ });
2384
2753
  }
2385
- async function findMilestone(reference, repo) {
2386
- const all = await listMilestones("all", repo);
2387
- const found = all.find((each) => each.title === reference) ?? all.find((each) => String(each.id) === reference);
2388
- if (found === undefined)
2389
- fail(`no milestone ${reference}, ${all.length === 0 ? "the repository has none" : `it has: ${all.map((each) => each.title).join(", ")}`}`, 2, runHint(`ft milestone new ${reference}`, "create it"));
2390
- return found;
2391
- }
2392
- function dueOn(value) {
2393
- const match = DATE.exec(value);
2394
- const date = new Date(`${value}T00:00:00Z`);
2395
- if (match === null || Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value || date.getUTCFullYear() < 2000)
2396
- fail(`--due takes a date as YYYY-MM-DD, not ${value}`);
2397
- return date.toISOString();
2398
- }
2399
- function dueDate(milestone) {
2400
- if (milestone.due_on === null || new Date(milestone.due_on).getUTCFullYear() >= NO_DUE_YEAR)
2401
- return "";
2402
- return milestone.due_on.slice(0, 10);
2403
- }
2404
- function progress(milestone) {
2405
- const total = milestone.open_issues + milestone.closed_issues;
2406
- return total === 0 ? "" : `${Math.round(milestone.closed_issues / total * 100)}%`;
2407
- }
2408
- async function createMilestone(title, description, due, repo) {
2409
- const fields = { title };
2410
- if (description !== undefined)
2411
- fields.description = description;
2412
- if (due !== undefined)
2413
- fields.due_on = due;
2414
- return repoWrite("POST", "milestones", fields, repo);
2415
- }
2416
- async function closeMilestone(id, repo) {
2417
- await repoWrite("PATCH", `milestones/${id}`, { state: "closed" }, repo);
2754
+ async function milestoneId(title, repo) {
2755
+ return title === "" ? 0 : (await findMilestone(title, repo)).id;
2418
2756
  }
2419
2757
 
2420
2758
  // src/commands/board.ts
@@ -2427,7 +2765,6 @@ function standing(claim, sessions) {
2427
2765
  return session === undefined ? { state: "away", claim } : { state: "taken", claim, session };
2428
2766
  }
2429
2767
  var NOTE_WIDTH = 100;
2430
- var STATES = new Set(["available", "taken", "away"]);
2431
2768
  function dimmed(text) {
2432
2769
  return text === "" ? "" : paint(process.stdout).dim(text);
2433
2770
  }
@@ -2509,29 +2846,26 @@ var boardUsage = `ft board
2509
2846
 
2510
2847
  Lists open issues, at most 30 of each kind (--full for all), as available, taken by a session running here, or claimed by a session no session here answers to, from their latest "Taken by session <name>." comment.
2511
2848
  A claim shows its boxes left, and one no live session holds also the latest comment that is not a claim.
2512
- A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs.
2513
-
2514
- Exits 0 when it listed them, 1 when the issues cannot be read, 2 on a usage error.`;
2849
+ A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs.`;
2850
+ var boardExits = [[0, "it listed them"], [1, "the issues cannot be read"], [2, "a usage error"]];
2515
2851
  var BOARD_LIMIT = 30;
2516
2852
  var boardOptions = {
2517
2853
  labels: { type: "string", short: "L", description: "only issues with these labels, comma separated" },
2518
2854
  milestone: { type: "string", short: "m", description: "only issues of this milestone, a title or an id" },
2519
2855
  query: { type: "string", description: "only issues whose title matches this, a case-insensitive regex such as dom|eager" },
2520
- state: { type: "string", description: "only issues in this state: available, taken or away (claimed, no live session here)" },
2856
+ state: { type: "string", choices: ["available", "taken", "away"], description: "only issues in this state (away: claimed, no live session here)" },
2521
2857
  ...limitOptions(BOARD_LIMIT),
2522
2858
  json: jsonOption("number, title, labels, state, holder, since, session, boxesTotal, boxesLeft and note (author, at, body of the latest comment that is not a claim)"),
2523
2859
  watch: watchOption("the board"),
2524
2860
  ...repoOption
2525
2861
  };
2526
2862
  async function board(args) {
2527
- const parsed = parse(args, boardUsage, boardOptions);
2863
+ const parsed = parse(args, boardUsage, boardOptions, { exits: boardExits });
2528
2864
  const { values } = parsed;
2529
2865
  if (values.watch !== undefined)
2530
2866
  return watching(values.watch, async () => board(withoutWatch(args)));
2531
2867
  const state = values.state;
2532
2868
  const limit = limitOf(values, BOARD_LIMIT);
2533
- if (state !== undefined && !STATES.has(state))
2534
- fail(`--state takes available, taken or away, not ${state}`);
2535
2869
  let query;
2536
2870
  try {
2537
2871
  query = values.query === undefined ? undefined : new RegExp(values.query, "i");
@@ -2561,9 +2895,8 @@ async function me(as, sessions) {
2561
2895
  var takeUsage = `ft take <n>...
2562
2896
 
2563
2897
  Claims each issue for this Claude Code session with a "Taken by session <name>." comment.
2564
- An issue another live session holds is refused, one this session or its lanes hold passes to the new name, and one claimed by a session no session here answers to needs --take-stale; a refusal leaves the other issues taken.
2565
-
2566
- Exits 0 when every issue is taken, 1 when one is refused, 2 on a usage error.`;
2898
+ An issue another live session holds is refused, one this session or its lanes hold passes to the new name, and one claimed by a session no session here answers to needs --take-stale; a refusal leaves the other issues taken.`;
2899
+ var takeExits = [[0, "every issue is taken"], [1, "one is refused"], [2, "a usage error"]];
2567
2900
  var laneOption = {
2568
2901
  lane: { type: "boolean", description: "claim each as lane-<s>-<n>, <s> ending this session's name, so the claim stays live while it runs" }
2569
2902
  };
@@ -2599,7 +2932,7 @@ async function eachIssue(command, numbers, step) {
2599
2932
  return code;
2600
2933
  }
2601
2934
  async function take(args) {
2602
- const parsed = parse(args, takeUsage, takeOptions);
2935
+ const parsed = parse(args, takeUsage, takeOptions, { exits: takeExits });
2603
2936
  const { values, positionals } = parsed;
2604
2937
  const numbers = issueNumbers(positionals, takeUsage);
2605
2938
  const sessions = await liveSessions();
@@ -2630,9 +2963,8 @@ async function take(args) {
2630
2963
  var dropUsage = `ft drop <n>... [--stale] | --all-stale [--dry-run]
2631
2964
 
2632
2965
  Gives each issue back with a "Released by session <name>." comment, when this session holds it.
2633
- With --stale, a claim no session here answers to is released too, in the name of its holder, followed by a comment saying this session released it as stale; a claim a live session holds is still refused. --all-stale does that for every such claim on the board, and with --dry-run only lists them.
2634
-
2635
- Exits 0 when every issue is given back, 1 when one is not held by this session or, with --stale, by a live one, 2 on a usage error.`;
2966
+ With --stale, a claim no session here answers to is released too, in the name of its holder, followed by a comment saying this session released it as stale; a claim a live session holds is still refused. --all-stale does that for every such claim on the board, and with --dry-run only lists them.`;
2967
+ var dropExits = [[0, "every issue is given back"], [1, "one is not held by this session or, with --stale, by a live one"], [2, "a usage error"]];
2636
2968
  var dropOptions = {
2637
2969
  as: { type: "string", description: "the name it was taken as, instead of this session's" },
2638
2970
  stale: { type: "boolean", description: "also release a claim no live session here answers to" },
@@ -2653,7 +2985,7 @@ async function releaseStale(number, me, author, sessions, repo) {
2653
2985
  console.log(good(`released #${number}, held by ${claim.holder}`));
2654
2986
  }
2655
2987
  async function drop(args) {
2656
- const parsed = parse(args, dropUsage, dropOptions);
2988
+ const parsed = parse(args, dropUsage, dropOptions, { exits: dropExits });
2657
2989
  const { values, positionals } = parsed;
2658
2990
  const sessions = await liveSessions();
2659
2991
  const nameFor = await claimant(values, sessions);
@@ -2693,7 +3025,7 @@ async function drop(args) {
2693
3025
  }
2694
3026
 
2695
3027
  // src/commands/ci.ts
2696
- import process24 from "process";
3028
+ import process26 from "process";
2697
3029
 
2698
3030
  // src/git.ts
2699
3031
  async function tagsAt(commit) {
@@ -2719,6 +3051,7 @@ var STAMP = /^\S+Z /;
2719
3051
  var FAILED_STEP = /\u274C\s+Failure - Main /;
2720
3052
  var STEP_TAIL = 30;
2721
3053
  var TAIL = 40;
3054
+ var TOOL_WINDOW = 200;
2722
3055
  function logLines(log) {
2723
3056
  return log.split(`
2724
3057
  `).map((line) => line.replace(STAMP, ""));
@@ -2744,7 +3077,7 @@ function excerpt(log) {
2744
3077
  const parts = failedTests(lines);
2745
3078
  for (const [index, line] of lines.entries()) {
2746
3079
  if (FAILED_STEP.test(line))
2747
- parts.push(lines.slice(Math.max(0, index - STEP_TAIL), index + 1).filter((text) => text.trim() !== "" && !text.startsWith(PASS) && !text.startsWith("::")).join(`
3080
+ parts.push(toolExcerpt(lines.slice(Math.max(0, index - TOOL_WINDOW), index)) ?? lines.slice(Math.max(0, index - STEP_TAIL), index + 1).filter((text) => text.trim() !== "" && !text.startsWith(PASS) && !text.startsWith("::")).join(`
2748
3081
  `));
2749
3082
  }
2750
3083
  return parts.length === 0 ? lines.slice(-TAIL).join(`
@@ -2872,7 +3205,7 @@ async function failedJobsOf(run, repo) {
2872
3205
  }
2873
3206
  return failed;
2874
3207
  }
2875
- function failureText(failed, out = process.stderr) {
3208
+ function failureText2(failed, out = process.stderr) {
2876
3209
  const problem = role("failed", out);
2877
3210
  return failed.map((job) => `${problem(`job ${job.name} of ${job.workflow} failed`)}:
2878
3211
  ${job.excerpt}`).join(`
@@ -2892,8 +3225,8 @@ var usage2 = `ft ci [ref]
2892
3225
 
2893
3226
  Waits for the push runs covering a commit on the branch, by default origin's tip, and prints what each failed job's log says.
2894
3227
  A push's run tests every commit since the previous push, so a commit whose own run was cancelled, or whose --job was skipped, is covered by the next commit's runs.
2895
- --json prints {status, runs, failedJobs, url} on stdout, the progress going to stderr; --quiet prints only the announcement, the failures and the result.
2896
- Exits 0 when they pass, 1 when one fails, 2 on a timeout, a stalled queue or a commit not on the branch.`;
3228
+ --json prints {status, runs, failedJobs, url} on stdout, the progress going to stderr; --quiet prints only the announcement, the failures and the result.`;
3229
+ var EXITS = [[0, "they pass"], [1, "one fails"], [2, "a timeout, a stalled queue or a commit not on the branch"]];
2897
3230
  var options = {
2898
3231
  branch: { type: "string", short: "b", description: "branch the commit is on, by default the one origin/HEAD names" },
2899
3232
  workflow: { type: "string", short: "w", description: "only this workflow file, e.g. test.yml; by default every workflow a push starts" },
@@ -2923,7 +3256,7 @@ function settled(latest) {
2923
3256
  return latest !== undefined && latest.every((run) => FINISHED.has(run.status)) && judge(latest, false, false).kind === "runs" ? latest : undefined;
2924
3257
  }
2925
3258
  async function ci2(args) {
2926
- const parsed = parse(args, usage2, options);
3259
+ const parsed = parse(args, usage2, options, { exits: EXITS });
2927
3260
  const { values, positionals } = parsed;
2928
3261
  const branch = values.branch ?? await defaultBranch();
2929
3262
  const giveUp = duration(values.timeout, "timeout", 30 * 60000, "m");
@@ -2959,7 +3292,7 @@ async function ci2(args) {
2959
3292
  return;
2960
3293
  }
2961
3294
  const json = values.json === true;
2962
- const live = takesControlCodes(process24.stderr) && takesControlCodes(process24.stdout) && !json && values.quiet !== true;
3295
+ const live = takesControlCodes(process26.stderr) && takesControlCodes(process26.stdout) && !json && values.quiet !== true;
2963
3296
  const runs = await waitForCi({
2964
3297
  tool: "ft ci",
2965
3298
  short,
@@ -2985,8 +3318,8 @@ async function ci2(args) {
2985
3318
  return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
2986
3319
  },
2987
3320
  lines: (spinner, found, started) => [
2988
- ciHeader(spinner, `CI on ${short}`, started, process24.stderr),
2989
- ...(found ?? []).map((run) => ` ${runLine(run, process24.stderr, undefined, run.commit_sha.slice(0, 7))}`)
3321
+ ciHeader(spinner, `CI on ${short}`, started, process26.stderr),
3322
+ ...(found ?? []).map((run) => ` ${runLine(run, process26.stderr, undefined, run.commit_sha.slice(0, 7))}`)
2990
3323
  ]
2991
3324
  });
2992
3325
  const status = overall(runs);
@@ -3003,7 +3336,7 @@ async function ci2(args) {
3003
3336
  }
3004
3337
  if (live) {
3005
3338
  for (const run of runs)
3006
- console.log(runLine(run, process24.stdout, undefined, run.commit_sha.slice(0, 7)));
3339
+ console.log(runLine(run, process26.stdout, undefined, run.commit_sha.slice(0, 7)));
3007
3340
  }
3008
3341
  if (status !== "failure") {
3009
3342
  if (live)
@@ -3014,7 +3347,7 @@ async function ci2(args) {
3014
3347
  for (const run of runs) {
3015
3348
  if (run.status === "failure")
3016
3349
  console.error(`
3017
- ${failureText(failed.filter((job) => job.run === run.id))}
3350
+ ${failureText2(failed.filter((job) => job.run === run.id))}
3018
3351
 
3019
3352
  run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from ${short} to ${run.commit_sha.slice(0, 7)}`}: ${run.html_url}`);
3020
3353
  }
@@ -3022,7 +3355,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
3022
3355
  }
3023
3356
 
3024
3357
  // src/commands/digest.ts
3025
- import process25 from "process";
3358
+ import process27 from "process";
3026
3359
  var RUNS_SCANNED = 50;
3027
3360
  var TITLE_WIDTH2 = 70;
3028
3361
  var SHOWN = 8;
@@ -3072,7 +3405,7 @@ async function quietly(read) {
3072
3405
  }
3073
3406
  }
3074
3407
  async function staleTodos() {
3075
- const bin = Bun.which("todo-scan", { PATH: process25.env.PATH ?? "" });
3408
+ const bin = Bun.which("todo-scan", { PATH: process27.env.PATH ?? "" });
3076
3409
  if (bin === null)
3077
3410
  return [];
3078
3411
  let found;
@@ -3094,8 +3427,8 @@ async function staleTodos() {
3094
3427
  return [...byIssue.values()];
3095
3428
  }
3096
3429
  function claimLine(row, now) {
3097
- const id = role("id", process25.stdout);
3098
- return [id(`#${row.number}`), row.holder, paint(process25.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
3430
+ const id = role("id", process27.stdout);
3431
+ return [id(`#${row.number}`), row.holder, paint(process27.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
3099
3432
  }
3100
3433
  function capped2(lines) {
3101
3434
  return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
@@ -3106,13 +3439,13 @@ function renderDigest(digest, now = Date.now()) {
3106
3439
  `) },
3107
3440
  { heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
3108
3441
  `) },
3109
- { heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process25.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
3442
+ { heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process27.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
3110
3443
  `), TITLE_WIDTH2)}`) },
3111
3444
  { heading: "unpushed commits", tone: "queued", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
3112
- { heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process25.stdout)(file.path)}`)) },
3445
+ { heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process27.stdout)(file.path)}`)) },
3113
3446
  { heading: "stale TODO comments", tone: "skipped", count: digest.stale.length, lines: capped2(digest.stale.map((todo) => `${todo.issue} closed: ${todo.comments.map((each) => `${each.path}:${each.line}`).join(", ")}`)) }
3114
3447
  ].filter((each) => each.count > 0);
3115
- return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process25.stdout, process25.env, tone)}
3448
+ return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process27.stdout, process27.env, tone)}
3116
3449
  ${lines.join(`
3117
3450
  `).replace(LINE_START2, " ")}`).join(`
3118
3451
 
@@ -3121,16 +3454,15 @@ ${lines.join(`
3121
3454
  var usage3 = `ft digest
3122
3455
 
3123
3456
  Summarises the repository for a session starting cold: the issues this session holds with their boxes left, the claims no live session here answers to, red or running CI on the default branch, unpushed commits, dirty files and TODO comments naming a closed issue.
3124
- A section with nothing in it is left out, and the stale TODO comments need todo-scan on the PATH.
3125
-
3126
- Exits 0 when it summarised the repository, 1 when Forgejo cannot be read, 2 on a usage error.`;
3457
+ A section with nothing in it is left out, and the stale TODO comments need todo-scan on the PATH.`;
3458
+ var EXITS2 = [[0, "it summarised the repository"], [1, "Forgejo cannot be read"], [2, "a usage error"]];
3127
3459
  var options2 = {
3128
3460
  json: jsonOption("held and away (number, title, holder, since, boxesLeft, boxesTotal), ci (id, status, workflow, started, title), unpushed, dirty (status, path) and stale (issue, comments: path, line)"),
3129
3461
  watch: watchOption("the digest"),
3130
3462
  ...repoOption
3131
3463
  };
3132
3464
  async function digest(args) {
3133
- const parsed = parse(args, usage3, options2);
3465
+ const parsed = parse(args, usage3, options2, { exits: EXITS2 });
3134
3466
  const { values } = parsed;
3135
3467
  if (values.watch !== undefined)
3136
3468
  return watching(values.watch, async () => digest(withoutWatch(args)));
@@ -3199,9 +3531,8 @@ var tickUsage = `ft tick [<n>] <box>...
3199
3531
  Ticks checklist boxes of issue <n>, each given by its number from \`ft issue\` or by text matching exactly one box, then posts the -m or -F comment.
3200
3532
  With --closed, ticks instead every box opening with \`#<issue>\` whose issue is closed, as a release plan lists them.
3201
3533
 
3202
- Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.
3203
-
3204
- Exits 0 when it ticked the boxes, 1 when Forgejo refuses, 2 on a usage error or a box matching none or several.`;
3534
+ Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.`;
3535
+ var tickExits = [[0, "it ticked the boxes"], [1, "Forgejo refuses"], [2, "a usage error or a box matching none or several"]];
3205
3536
  var tickOptions = {
3206
3537
  undo: { type: "boolean", short: "u", description: "untick them instead" },
3207
3538
  closed: { type: "boolean", description: "tick the boxes listing a closed issue, no box to name" },
@@ -3216,7 +3547,7 @@ function tickedOrFail(number, run) {
3216
3547
  }
3217
3548
  }
3218
3549
  async function tick(args) {
3219
- const parsed = parse(args, tickUsage, tickOptions);
3550
+ const parsed = parse(args, tickUsage, tickOptions, { exits: tickExits });
3220
3551
  const { values, positionals } = parsed;
3221
3552
  const { number, rest: picks } = await targetIssue(positionals, values.repo, tickUsage);
3222
3553
  if (values.closed === true && (picks.length > 0 || values.undo === true))
@@ -3253,9 +3584,8 @@ var fixedUsage = `ft fixed [<n>] [commit]...
3253
3584
 
3254
3585
  Comments "Fixed in <sha>: <message>" on issue <n> and closes it, naming each commit given as "Fixed in <a>, <b> and <c>".
3255
3586
  Without a commit it takes those on origin's default branch whose message names #<n>, and says which, or HEAD when none does.
3256
- Without <n> it takes the one open issue this session holds (\`ft take\`). The message defaults to the subject of the first commit. Every open issue listing \`- [ ] #<n>\` in its checklist gets that line ticked. An issue with boxes left is refused, as a partly done issue stays open, unless --tick ticks them first.
3257
-
3258
- Exits 0 when it closed the issue, 1 when the issue is already closed, has boxes left or Forgejo refuses, 2 on a usage error.`;
3587
+ Without <n> it takes the one open issue this session holds (\`ft take\`). The message defaults to the subject of the first commit. Every open issue listing \`- [ ] #<n>\` in its checklist gets that line ticked. An issue with boxes left is refused, as a partly done issue stays open, unless --tick ticks them first.`;
3588
+ var fixedExits = [[0, "it closed the issue"], [1, "the issue is already closed, has boxes left or Forgejo refuses"], [2, "a usage error"]];
3259
3589
  var fixedOptions = {
3260
3590
  message: { type: "string", short: "m", description: 'the line after "Fixed in <sha>:"' },
3261
3591
  tick: { type: "boolean", description: "tick the boxes left before closing" },
@@ -3296,7 +3626,7 @@ async function tickListings(closed, repo) {
3296
3626
  }
3297
3627
  }
3298
3628
  async function fixed(args) {
3299
- const parsed = parse(args, fixedUsage, fixedOptions);
3629
+ const parsed = parse(args, fixedUsage, fixedOptions, { exits: fixedExits });
3300
3630
  const { values, positionals } = parsed;
3301
3631
  const { number, rest } = await targetIssue(positionals, values.repo, fixedUsage);
3302
3632
  const commits = await fixingCommits(number, rest);
@@ -3334,8 +3664,8 @@ var stateOptions = {
3334
3664
  message: { type: "string", short: "m", description: "a comment posted first, saying why" },
3335
3665
  ...repoOption
3336
3666
  };
3337
- async function setState(args, usage, wanted) {
3338
- const parsed = parse(args, usage, stateOptions);
3667
+ async function setState(args, usage, exits, wanted) {
3668
+ const parsed = parse(args, usage, stateOptions, { exits });
3339
3669
  const { values, positionals } = parsed;
3340
3670
  for (const number of issueNumbers(positionals, usage)) {
3341
3671
  if ((await getIssue(number, values.repo)).state === wanted) {
@@ -3354,19 +3684,17 @@ async function setState(args, usage, wanted) {
3354
3684
  }
3355
3685
  var closeUsage = `ft close <n>... [-m <reason>]
3356
3686
 
3357
- Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed.
3358
-
3359
- Exits 0 when every issue is closed, 1 when Forgejo refuses, 2 on a usage error.`;
3687
+ Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed.`;
3688
+ var closeExits = [[0, "every issue is closed"], [1, "Forgejo refuses"], [2, "a usage error"]];
3360
3689
  async function closeIssues(args) {
3361
- return setState(args, closeUsage, "closed");
3690
+ return setState(args, closeUsage, closeExits, "closed");
3362
3691
  }
3363
3692
  var reopenUsage = `ft reopen <n>... [-m <reason>]
3364
3693
 
3365
- Reopens closed issues, posting the -m reason first.
3366
-
3367
- Exits 0 when every issue is open, 1 when Forgejo refuses, 2 on a usage error.`;
3694
+ Reopens closed issues, posting the -m reason first.`;
3695
+ var reopenExits = [[0, "every issue is open"], [1, "Forgejo refuses"], [2, "a usage error"]];
3368
3696
  async function reopenIssues(args) {
3369
- return setState(args, reopenUsage, "open");
3697
+ return setState(args, reopenUsage, reopenExits, "open");
3370
3698
  }
3371
3699
  var LABEL_FLAGS = new Set(["-h", "--help"]);
3372
3700
  var REPO_FLAGS = new Set(["-r", "--repo"]);
@@ -3389,12 +3717,11 @@ function labelChanges(args) {
3389
3717
  }
3390
3718
  var labelUsage = `ft label <n> [+]<label>... -<label>...
3391
3719
 
3392
- Adds the labels named bare or with +, removes those named with -, then prints the issue's labels. A label the repository lacks is refused.
3393
-
3394
- Exits 0 when it changed the labels, 1 when Forgejo refuses, 2 on a usage error or a label the repository lacks.`;
3720
+ Adds the labels named bare or with +, removes those named with -, then prints the issue's labels. A label the repository lacks is refused.`;
3721
+ var labelExits = [[0, "it changed the labels"], [1, "Forgejo refuses"], [2, "a usage error or a label the repository lacks"]];
3395
3722
  async function label(args) {
3396
3723
  const changes = labelChanges(args);
3397
- const parsed = parse(changes.rest, labelUsage, repoOption);
3724
+ const parsed = parse(changes.rest, labelUsage, repoOption, { exits: labelExits });
3398
3725
  const { values, positionals } = parsed;
3399
3726
  const number = issueNumber(positionals[0], labelUsage);
3400
3727
  const add = [...positionals.slice(1), ...changes.add];
@@ -3416,9 +3743,8 @@ ${labelUsage}`);
3416
3743
  // src/commands/issue-write.ts
3417
3744
  var newUsage = `ft new -t <title> [-F <file>] [-L a,b] [-m <milestone>]
3418
3745
 
3419
- Creates an issue and prints its number and url. The description is read from -F <file>, or from stdin with -F -, and is empty without it. A label or milestone the repository lacks is refused before anything is created.
3420
-
3421
- Exits 0 when it created the issue, 1 when Forgejo refuses, 2 on a usage error or a label or milestone the repository lacks.`;
3746
+ Creates an issue and prints its number and url. The description is read from -F <file>, or from stdin with -F -, and is empty without it. A label or milestone the repository lacks is refused before anything is created.`;
3747
+ var newExits = [[0, "it created the issue"], [1, "Forgejo refuses"], [2, "a usage error or a label or milestone the repository lacks"]];
3422
3748
  var newOptions = {
3423
3749
  title: { type: "string", short: "t", description: "the issue title" },
3424
3750
  file: { type: "string", short: "F", description: "the description: a file, - for stdin" },
@@ -3432,7 +3758,7 @@ async function milestoneTitle(reference, repo) {
3432
3758
  return reference.trim() === "" ? "" : (await findMilestone(reference.trim(), repo)).title;
3433
3759
  }
3434
3760
  async function newIssue(args) {
3435
- const parsed = parse(args, newUsage, newOptions);
3761
+ const parsed = parse(args, newUsage, newOptions, { exits: newExits });
3436
3762
  const { values } = parsed;
3437
3763
  if (values.title === undefined || values.title.trim() === "")
3438
3764
  fail(`give the issue a title with -t
@@ -3450,9 +3776,8 @@ var editUsage = `ft edit <n> [-t <title>] [-F <file> [--append]] [--add-box <tex
3450
3776
  Replaces the title and/or the description of issue <n>, the description from -F <file> or from stdin with -F -.
3451
3777
  -m moves it to a milestone given by title or id, and \`-m ''\` takes it out of its milestone.
3452
3778
  --append adds the -F text after the description instead, and each --add-box an unticked box after the last one, the rest of the description untouched.
3453
- \`ft issue <n> --body\` prints the description to edit.
3454
-
3455
- Exits 0 when it edited the issue, 1 when Forgejo refuses, 2 on a usage error.`;
3779
+ \`ft issue <n> --body\` prints the description to edit.`;
3780
+ var editExits = [[0, "it edited the issue"], [1, "Forgejo refuses"], [2, "a usage error"]];
3456
3781
  var editOptions = {
3457
3782
  title: { type: "string", short: "t", description: "the new title" },
3458
3783
  file: { type: "string", short: "F", description: "the new description: a file, - for stdin" },
@@ -3462,7 +3787,7 @@ var editOptions = {
3462
3787
  ...repoOption
3463
3788
  };
3464
3789
  async function edit(args) {
3465
- const parsed = parse(args, editUsage, editOptions);
3790
+ const parsed = parse(args, editUsage, editOptions, { exits: editExits });
3466
3791
  const { values, positionals } = parsed;
3467
3792
  const number = issueNumber(positionals[0], editUsage);
3468
3793
  const text = await noteText({ file: values.file });
@@ -3500,15 +3825,14 @@ ${text}` : body;
3500
3825
  var commentUsage = `ft comment [<n>] [text]
3501
3826
 
3502
3827
  Posts a comment on issue <n>: the text given, -F <file>, or stdin when neither is, so a heredoc needs no escaping.
3503
- Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.
3504
-
3505
- Exits 0 when it posted the comment, 1 when Forgejo refuses, 2 on a usage error.`;
3828
+ Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.`;
3829
+ var commentExits = [[0, "it posted the comment"], [1, "Forgejo refuses"], [2, "a usage error"]];
3506
3830
  var commentOptions = {
3507
3831
  file: noteOptions.file,
3508
3832
  ...repoOption
3509
3833
  };
3510
3834
  async function commentOn(args) {
3511
- const parsed = parse(args, commentUsage, commentOptions);
3835
+ const parsed = parse(args, commentUsage, commentOptions, { exits: commentExits });
3512
3836
  const { values, positionals } = parsed;
3513
3837
  const { number, rest } = await targetIssue(positionals, values.repo, commentUsage);
3514
3838
  const given = rest.join(" ") || undefined;
@@ -3527,9 +3851,8 @@ var issueUsage = `ft issue [<n>...]
3527
3851
 
3528
3852
  Prints each issue: its title, state, boxes left and claim, then its description with each checklist box numbered as \`ft tick\` takes it. --open also opens each in the browser.
3529
3853
  With --body, prints only the raw description, to edit and give back to \`ft edit -F\`.
3530
- With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none.
3531
-
3532
- Exits 0 when it printed them, 1 when an issue cannot be read, 2 on a usage error.`;
3854
+ With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none.`;
3855
+ var issueExits = [[0, "it printed them"], [1, "an issue cannot be read"], [2, "a usage error"]];
3533
3856
  var issueOptions = {
3534
3857
  todo: { type: "boolean", short: "t", description: "only the header and the boxes left to tick" },
3535
3858
  comments: { type: "boolean", short: "c", description: "add the comments, each with its author and age" },
@@ -3582,7 +3905,7 @@ function issueJson(found, comments, author) {
3582
3905
  };
3583
3906
  }
3584
3907
  async function issue(args) {
3585
- const parsed = parse(args, issueUsage, issueOptions);
3908
+ const parsed = parse(args, issueUsage, issueOptions, { exits: issueExits });
3586
3909
  const { values, positionals } = parsed;
3587
3910
  const held = positionals.length === 0 ? await heldIssues(values.repo) : [];
3588
3911
  const numbers = held.length === 0 ? issueNumbers(positionals, issueUsage) : held;
@@ -3627,10 +3950,9 @@ async function issue(args) {
3627
3950
  // src/commands/logs.ts
3628
3951
  var usage4 = `ft logs <run id>
3629
3952
 
3630
- Prints what the failed jobs of a run say went wrong: each failed bun test's output and the end of each failed step.
3631
- With no failed job it prints every job's last lines; --full prints whole logs.
3632
-
3633
- Exits 0 when it printed the logs, 1 when Forgejo cannot be read, 2 on a usage error or a job the run lacks.`;
3953
+ Prints what the failed jobs of a run say went wrong: each failed bun test's output and the end of each failed step, cut to the errors when it is a tsc, eslint, vitest, playwright, phpstan or php-cs-fixer step.
3954
+ With no failed job it prints every job's last lines; --full prints whole logs.`;
3955
+ var EXITS3 = [[0, "it printed the logs"], [1, "Forgejo cannot be read"], [2, "a usage error or a job the run lacks"]];
3634
3956
  var options3 = {
3635
3957
  job: { type: "string", short: "j", description: "only this job, by name or id" },
3636
3958
  full: { type: "boolean", short: "f", description: "the whole log, timestamps stripped" },
@@ -3644,7 +3966,7 @@ function pickJobs(jobs, wanted) {
3644
3966
  return failed.length > 0 ? failed : jobs;
3645
3967
  }
3646
3968
  async function logs2(args) {
3647
- const parsed = parse(args, usage4, options3);
3969
+ const parsed = parse(args, usage4, options3, { exits: EXITS3 });
3648
3970
  const { values, positionals } = parsed;
3649
3971
  if (positionals[0] === undefined)
3650
3972
  fail("a run id is needed", 2, runHint("ft runs", "list them"));
@@ -3675,7 +3997,7 @@ ${await text(job)}`);
3675
3997
  }
3676
3998
 
3677
3999
  // src/commands/milestone.ts
3678
- import process26 from "process";
4000
+ import process28 from "process";
3679
4001
  var TITLE_WIDTH3 = 60;
3680
4002
  var LIST_LIMIT = 30;
3681
4003
  var CONCURRENCY2 = 4;
@@ -3684,15 +4006,15 @@ function counts(milestone) {
3684
4006
  }
3685
4007
  function progressBar(milestone) {
3686
4008
  const total = milestone.open_issues + milestone.closed_issues;
3687
- return takesControlCodes(process26.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
4009
+ return takesControlCodes(process28.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
3688
4010
  }
3689
4011
  function milestoneCells(each, showState) {
3690
4012
  const drawn = progressBar(each);
3691
4013
  return [String(each.id), truncate(each.title, TITLE_WIDTH3), `${each.open_issues} open`, `${each.closed_issues} closed`, ...drawn === "" ? [] : [drawn], progress(each), dueDate(each) === "" ? "" : `due ${dueDate(each)}`, ...showState ? [each.state] : []];
3692
4014
  }
3693
4015
  async function printWithIssues(list, repo) {
3694
- const colors = paint(process26.stdout);
3695
- const id = role("id", process26.stdout);
4016
+ const colors = paint(process28.stdout);
4017
+ const id = role("id", process28.stdout);
3696
4018
  const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
3697
4019
  const blocks = list.map((each, index) => {
3698
4020
  const byNumber = (left, right) => left.number - right.number;
@@ -3703,7 +4025,7 @@ async function printWithIssues(list, repo) {
3703
4025
  ...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
3704
4026
  ...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
3705
4027
  ];
3706
- return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process26.stdout, process26.env, "accent"), ...lines].join(`
4028
+ return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process28.stdout, process28.env, "accent"), ...lines].join(`
3707
4029
  `);
3708
4030
  });
3709
4031
  console.log(blocks.join(`
@@ -3712,22 +4034,19 @@ async function printWithIssues(list, repo) {
3712
4034
  }
3713
4035
  var listUsage = `ft milestones
3714
4036
 
3715
- Lists the repository's milestones, the open ones unless --state says otherwise, with the issues open and closed in each, the progress and the due date; on a terminal the progress is a bar, and --issues lists the title of every issue under its milestone.
3716
-
3717
- Exits 0 when it listed them, 1 when Forgejo refuses, 2 on a usage error.`;
4037
+ Lists the repository's milestones, the open ones unless --state says otherwise, with the issues open and closed in each, the progress and the due date; on a terminal the progress is a bar, and --issues lists the title of every issue under its milestone.`;
4038
+ var listExits = [[0, "it listed them"], [1, "Forgejo refuses"], [2, "a usage error"]];
3718
4039
  var listOptions = {
3719
- state: { type: "string", description: "open (the default), closed or all" },
4040
+ state: { type: "string", choices: ["open", "closed", "all"], default: "open", description: "which milestones to list (open)" },
3720
4041
  issues: { type: "boolean", short: "i", description: "list the open and closed issues of each milestone by title" },
3721
4042
  ...limitOptions(LIST_LIMIT),
3722
4043
  json: jsonOption("id, title, state, description, open, closed, due (YYYY-MM-DD or null)"),
3723
4044
  ...repoOption
3724
4045
  };
3725
4046
  async function milestones(args) {
3726
- const parsed = parse(args, listUsage, listOptions);
4047
+ const parsed = parse(args, listUsage, listOptions, { exits: listExits });
3727
4048
  const { values } = parsed;
3728
- const state = values.state ?? "open";
3729
- if (state !== "open" && state !== "closed" && state !== "all")
3730
- fail(`--state takes open, closed or all, not ${state}`);
4049
+ const state = values.state;
3731
4050
  const limit = limitOf(values, LIST_LIMIT);
3732
4051
  const found = await listMilestones(state, values.repo);
3733
4052
  if (values.issues === true && values.json === true)
@@ -3751,16 +4070,15 @@ async function milestones(args) {
3751
4070
  }
3752
4071
  var newUsage2 = `ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
3753
4072
 
3754
- Creates a milestone through the API and prints its id. Without --due it has no due date.
3755
-
3756
- Exits 0 when it created the milestone, 1 when Forgejo refuses, 2 on a usage error.`;
4073
+ Creates a milestone through the API and prints its id. Without --due it has no due date.`;
4074
+ var newExits2 = [[0, "it created the milestone"], [1, "Forgejo refuses"], [2, "a usage error"]];
3757
4075
  var newOptions2 = {
3758
4076
  description: { type: "string", short: "d", description: "the milestone description" },
3759
4077
  due: { type: "string", description: "the due date, YYYY-MM-DD" },
3760
4078
  ...repoOption
3761
4079
  };
3762
4080
  async function create(args) {
3763
- const parsed = parse(args, newUsage2, newOptions2);
4081
+ const parsed = parse(args, newUsage2, newOptions2, { exits: newExits2 });
3764
4082
  const { values, positionals } = parsed;
3765
4083
  const title = positionals.join(" ").trim();
3766
4084
  if (title === "")
@@ -3774,15 +4092,14 @@ ${newUsage2}`);
3774
4092
  }
3775
4093
  var closeUsage2 = `ft milestone close <title|id> [--force]
3776
4094
 
3777
- Closes a milestone, refused while issues are open in it, which it names. --force closes it with them left.
3778
-
3779
- Exits 0 when it closed the milestone, 1 when issues are open in it or Forgejo refuses, 2 on a usage error.`;
4095
+ Closes a milestone, refused while issues are open in it, which it names. --force closes it with them left.`;
4096
+ var closeExits2 = [[0, "it closed the milestone"], [1, "issues are open in it or Forgejo refuses"], [2, "a usage error"]];
3780
4097
  var closeOptions = {
3781
4098
  force: { type: "boolean", description: "close it with issues left open" },
3782
4099
  ...repoOption
3783
4100
  };
3784
4101
  async function closeOne(args) {
3785
- const parsed = parse(args, closeUsage2, closeOptions);
4102
+ const parsed = parse(args, closeUsage2, closeOptions, { exits: closeExits2 });
3786
4103
  const { values, positionals } = parsed;
3787
4104
  const reference = positionals.join(" ").trim();
3788
4105
  if (reference === "")
@@ -3808,16 +4125,15 @@ ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
3808
4125
  ft milestone close <title|id> [--force]
3809
4126
 
3810
4127
  Shows a milestone with its open issues as \`ft board\` does: available, taken by a session running here, or claimed by one gone, each with its boxes left, at most 30 of each kind (--full for all).
3811
- \`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id.
3812
-
3813
- Exits 0 when it showed the milestone, 1 when it cannot be read, 2 on a usage error or an unknown milestone.`;
4128
+ \`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id.`;
4129
+ var showExits = [[0, "it showed the milestone"], [1, "it cannot be read"], [2, "a usage error or an unknown milestone"]];
3814
4130
  var showOptions = {
3815
4131
  ...limitOptions(LIST_LIMIT),
3816
4132
  json: jsonOption("the milestone (id, title, state, description, open, closed, due) and its open issues as `ft board --json` lists them"),
3817
4133
  ...repoOption
3818
4134
  };
3819
4135
  async function show(args) {
3820
- const parsed = parse(args, showUsage, showOptions);
4136
+ const parsed = parse(args, showUsage, showOptions, { exits: showExits });
3821
4137
  const { values, positionals } = parsed;
3822
4138
  const reference = positionals.join(" ").trim();
3823
4139
  if (reference === "")
@@ -3904,16 +4220,14 @@ var addUsage = `ft plan add <plan> <n>... [--section "Bugs:"]
3904
4220
 
3905
4221
  Lists each issue <n> as \`- [ ] #<n> <title>\` in the checklist of issue <plan>, skipping those already listed.
3906
4222
  Lines go under --section, created at the end of the body when missing, or else after the checklist's last box.
3907
- The body is read again just before it is written, so an edit made meanwhile is kept.
3908
-
3909
- Exits 0 when it listed the issues, 1 when Forgejo refuses, 2 on a usage error.`;
4223
+ The body is read again just before it is written, so an edit made meanwhile is kept.`;
4224
+ var addExits = [[0, "it listed the issues"], [1, "Forgejo refuses"], [2, "a usage error"]];
3910
4225
  var carryUsage = `ft plan carry <from> <to> [--section "Carried from 1.71.0:"]
3911
4226
 
3912
4227
  Copies the unticked \`#<n>\` lines of issue <from> into issue <to>, skipping those <to> already lists.
3913
4228
  Lines go under --section, created at the end of the body when missing, or else after the checklist's last box.
3914
- The body is read again just before it is written, so an edit made meanwhile is kept.
3915
-
3916
- Exits 0 when it copied the lines, 1 when Forgejo refuses, 2 on a usage error.`;
4229
+ The body is read again just before it is written, so an edit made meanwhile is kept.`;
4230
+ var carryExits = [[0, "it copied the lines"], [1, "Forgejo refuses"], [2, "a usage error"]];
3917
4231
  var options4 = {
3918
4232
  section: { type: "string", short: "s", description: 'the heading the lines go under, e.g. "Bugs:"' },
3919
4233
  ...repoOption
@@ -3926,7 +4240,7 @@ var plan = {
3926
4240
  }
3927
4241
  };
3928
4242
  async function add(args) {
3929
- const parsed = parse(args, addUsage, options4);
4243
+ const parsed = parse(args, addUsage, options4, { exits: addExits });
3930
4244
  const { section, repo } = parsed.values;
3931
4245
  const [target, ...listed] = parsed.positionals;
3932
4246
  const planNumber = issueNumber(target, addUsage);
@@ -3947,7 +4261,7 @@ ${addUsage}`);
3947
4261
  return 0;
3948
4262
  }
3949
4263
  async function carry(args) {
3950
- const parsed = parse(args, carryUsage, options4);
4264
+ const parsed = parse(args, carryUsage, options4, { exits: carryExits });
3951
4265
  const { section, repo } = parsed.values;
3952
4266
  const from = issueNumber(parsed.positionals[0], carryUsage);
3953
4267
  const to = issueNumber(parsed.positionals[1], carryUsage);
@@ -3969,15 +4283,15 @@ function report2(plan, added, skipped) {
3969
4283
 
3970
4284
  // src/commands/release.ts
3971
4285
  import { basename as basename3, join as join11 } from "path";
3972
- import process28 from "process";
4286
+ import process30 from "process";
3973
4287
  var {$: $2 } = globalThis.Bun;
3974
4288
 
3975
4289
  // src/commands/watch.ts
3976
4290
  var usage5 = `ft watch [--after <id>]
3977
4291
 
3978
4292
  Waits for runs to finish: those newer than run <id>, or else the ones in progress now.
3979
- Prints nothing but failures and each run's final status with --quiet, and a JSON result with --json.
3980
- Exits 0 when every one passed or was skipped, 1 when one failed or was cancelled, 2 on a timeout or a stalled queue.`;
4293
+ Prints nothing but failures and each run's final status with --quiet, and a JSON result with --json.`;
4294
+ var EXITS4 = [[0, "every one passed or was skipped"], [1, "one failed or was cancelled"], [2, "a timeout or a stalled queue"]];
3981
4295
  var options5 = {
3982
4296
  after: { type: "string", short: "a", description: "watch the runs newer than this run id, as `ft runs --json` gives it" },
3983
4297
  timeout: { type: "string", short: "t", description: "how long before giving up (15m), a bare number in minutes" },
@@ -4032,7 +4346,7 @@ async function followRuns(pick, timeout, repo, idle, out = process.stdout, mode
4032
4346
  failedJobs.push(...jobs);
4033
4347
  if (!json)
4034
4348
  console.error(`
4035
- ${failureText(jobs)}
4349
+ ${failureText2(jobs)}
4036
4350
 
4037
4351
  ${run.html_url}`);
4038
4352
  failed.add(run.id);
@@ -4081,7 +4395,7 @@ ${run.html_url}`);
4081
4395
  }
4082
4396
  }
4083
4397
  async function watch2(args) {
4084
- const parsed = parse(args, usage5, options5);
4398
+ const parsed = parse(args, usage5, options5, { exits: EXITS4 });
4085
4399
  const { values } = parsed;
4086
4400
  const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
4087
4401
  const json = values.json === true;
@@ -4207,12 +4521,12 @@ async function publishable() {
4207
4521
 
4208
4522
  // src/commands/release-plan.ts
4209
4523
  import { basename as basename2, join as join9, relative } from "path";
4210
- import process27 from "process";
4524
+ import process29 from "process";
4211
4525
  async function planOf({ level, dir, prefix }, registry) {
4212
4526
  const file = Bun.file(join9(dir ?? ".", "package.json"));
4213
4527
  const pkg = await file.exists() ? await file.json() : undefined;
4214
- const name = pkg?.name ?? basename2(dir ?? process27.cwd());
4215
- const where = dir === undefined ? "" : ` in ${relative(process27.cwd(), dir) || "."}`;
4528
+ const name = pkg?.name ?? basename2(dir ?? process29.cwd());
4529
+ const where = dir === undefined ? "" : ` in ${relative(process29.cwd(), dir) || "."}`;
4216
4530
  let version;
4217
4531
  let bump;
4218
4532
  if (level === undefined) {
@@ -4342,8 +4656,8 @@ Cuts a release from the default branch: first the commit it sits on is pushed an
4342
4656
  A refused or interrupted push drops the bump commits and their tags, so a retry starts clean; with --tagged the commit and tag are yours and stay.
4343
4657
  Once released, an open milestone titled like the version (\`1.2.0\`, \`v1.2.0\` or the tag) has its closed issues listed and is closed; a failure there only warns.
4344
4658
  --dry-run checks the same and prints the plan: the version bump, the tag, the pushes and the runs and registry it would wait for, changing nothing.
4345
- --json prints {released, tag, package, version, status, runs, failedJobs, url} on stdout and the progress on stderr, an array of them with --package a,b or --all; it does not take --dry-run.
4346
- Exits 0 once released or planned, 1 when a run fails, origin refuses a push or the registry never serves the version, 2 on a timeout, a stalled queue, a refusal before anything ran (another branch, uncommitted changes, origin ahead) or a usage error.`;
4659
+ --json prints {released, tag, package, version, status, runs, failedJobs, url} on stdout and the progress on stderr, an array of them with --package a,b or --all; it does not take --dry-run.`;
4660
+ var EXITS5 = [[0, "released or planned"], [1, "a run fails, origin refuses a push or the registry never serves the version"], [2, "a timeout, a stalled queue, a refusal before anything ran (another branch, uncommitted changes, origin ahead) or a usage error"]];
4347
4661
  var options6 = {
4348
4662
  tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
4349
4663
  package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/, several separated by commas" },
@@ -4354,7 +4668,7 @@ var options6 = {
4354
4668
  json: jsonOption("what was released and how its runs ended")
4355
4669
  };
4356
4670
  async function release(args) {
4357
- const parsed = parse(args, usage6, options6);
4671
+ const parsed = parse(args, usage6, options6, { exits: EXITS5 });
4358
4672
  const { values, positionals } = parsed;
4359
4673
  const json = values.json === true;
4360
4674
  const say = json ? console.error : console.log;
@@ -4457,7 +4771,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
4457
4771
  if (late !== undefined)
4458
4772
  fail(`interrupted by ${late} after ${bumped.map((each) => each.tag).join(", ")} ${bumped.length === 1 ? "was pushed: its runs are" : "were pushed: their runs are"} not waited for`, exitCodeOf(null, late));
4459
4773
  say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
4460
- followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process28.stderr : process28.stdout, { json });
4774
+ followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process30.stderr : process30.stdout, { json });
4461
4775
  if (followed.code !== 0) {
4462
4776
  report();
4463
4777
  return followed.code;
@@ -4492,9 +4806,8 @@ var usage7 = `ft remote [--fix]
4492
4806
 
4493
4807
  Checks that origin's URLs name the Forgejo host itself: tea only finds the repository when origin's host is the login's ssh_host, never through an ssh alias such as \`forgejo\` or \`gitea\`.
4494
4808
  --fix switches every alias URL to \`git@<host>:<owner>/<repo>.git\` and proves it with \`git ls-remote\`.
4495
- The host comes from --host, else \`remoteHost\` in ~/.config/kaynooo-cli/ft.json; with neither, it checks nothing.
4496
-
4497
- Exits 0 when origin names the Forgejo host (or was switched) or no host is set, 1 when it does not or a switch is still to run, 2 on a usage error.`;
4809
+ The host comes from --host, else \`remoteHost\` in ~/.config/kaynooo-cli/ft.json; with neither, it checks nothing.`;
4810
+ var EXITS6 = [[0, "origin names the Forgejo host (or was switched) or no host is set"], [1, "it does not or a switch is still to run"], [2, "a usage error"]];
4498
4811
  var options7 = {
4499
4812
  host: { type: "string", description: "the Forgejo ssh host, instead of remoteHost in ~/.config/kaynooo-cli/ft.json" },
4500
4813
  fix: { type: "boolean", description: "rewrite the alias URLs" }
@@ -4528,7 +4841,7 @@ function originHost2(url) {
4528
4841
  return parseSshRemote(url)?.host ?? (URL.canParse(url) ? new URL(url).hostname : undefined);
4529
4842
  }
4530
4843
  async function remote(args, home) {
4531
- const { values } = parse(args, usage7, options7);
4844
+ const { values } = parse(args, usage7, options7, { exits: EXITS6 });
4532
4845
  const host = values.host ?? (await loadSettings(home)).remoteHost;
4533
4846
  if (host === undefined) {
4534
4847
  note(`no Forgejo host to check origin against: pass --host, or set "remoteHost" in ${settingsPath(home)}`);
@@ -4588,9 +4901,8 @@ var usage8 = `ft runs [--sha <ref>]
4588
4901
 
4589
4902
  Lists recent runs with what tea's own listing leaves empty: workflow, ref, duration and age, ten by default with the count of the rest (--full for all of them; --json is never cut unless --limit is given).
4590
4903
 
4591
- --open also opens the newest run listed in the browser.
4592
-
4593
- Exits 0 when it listed them, 1 when Forgejo or git cannot be read, 2 on a usage error.`;
4904
+ --open also opens the newest run listed in the browser.`;
4905
+ var EXITS7 = [[0, "it listed them"], [1, "Forgejo or git cannot be read"], [2, "a usage error"]];
4594
4906
  var DEFAULT_LIMIT = 10;
4595
4907
  var options8 = {
4596
4908
  ...limitOptions(DEFAULT_LIMIT),
@@ -4606,7 +4918,7 @@ async function onCommit(sha, repo) {
4606
4918
  return { runs: found, total: found.length };
4607
4919
  }
4608
4920
  async function runs(args) {
4609
- const parsed = parse(args, usage8, options8);
4921
+ const parsed = parse(args, usage8, options8, { exits: EXITS7 });
4610
4922
  const { values } = parsed;
4611
4923
  const limit = limitOf(values, DEFAULT_LIMIT);
4612
4924
  const { runs: found, total } = values.sha === undefined ? await runsListing(limit, values.repo, values.workflow) : await onCommit(values.sha, values.repo);
@@ -4634,7 +4946,7 @@ async function runs(args) {
4634
4946
  }
4635
4947
 
4636
4948
  // src/cli.ts
4637
- process29.exitCode = await runCli({
4949
+ process31.exitCode = await runCli({
4638
4950
  name: "ft",
4639
4951
  about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
4640
4952
  replaces: "tea api calls piped through jq, and sleep loops waiting on CI",