@kaynooo/cli-forgejo 0.29.1 → 0.30.1

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 +395 -130
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -6,7 +6,7 @@ Forgejo tools for the terminal: CI runs and their failures, releases, issue chec
6
6
  bun install -g @kaynooo/cli-forgejo
7
7
  ```
8
8
 
9
- Needs [tea](https://gitea.com/gitea/tea) logged in to the Forgejo instance (`tea login add`). Every call goes through `tea api`, so ft has no token of its own: tea owns the login and finds the repository from origin. Run ft from the repository, or pass `--repo owner/name` to the commands that take it.
9
+ Needs [tea](https://gitea.com/gitea/tea) logged in to the Forgejo instance (`tea login add`), or [gt](https://gitea.com/gitea/gitea-cli) (gitea-cli) when tea is not installed: ft then hands gt the token and host of the matching login in `~/.config/tea/config.yml` through `GITEA_TOKEN` and `GITEA_CLI_HOST` (a `GITEA_TOKEN` already set wins), so no second login is needed, and issues are written through the API. Every call goes through `tea api` (`gt api`), so ft has no token of its own: the client owns the login and finds the repository from origin. Run ft from the repository, or pass `--repo owner/name` to the commands that take it.
10
10
 
11
11
  ## Commands
12
12
 
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,7 +568,7 @@ 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)) {
@@ -607,29 +607,44 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
607
607
  return [];
608
608
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
609
609
  }
610
+ var MAX_INLINE_CHOICES = 24;
610
611
  function optionRows(options, colors = paint(process8.stdout)) {
611
612
  const rows = Object.entries(options).map(([name, option]) => {
612
613
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
613
- 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>";
614
617
  const placeholder = option.optional === undefined ? named : `[${named}]`;
615
618
  const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
616
- 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 };
617
621
  });
618
622
  const width = Math.max(0, ...rows.map((row) => row.width));
619
623
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
620
624
  }
621
625
 
622
626
  // ../kit/src/text.ts
623
- 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
+ }
624
631
  function distance(a, b) {
625
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
626
- 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()) {
627
637
  const current = [i + 1];
628
- for (const [j, right] of [...b].entries())
629
- 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;
630
645
  previous = current;
631
646
  }
632
- return previous[b.length] ?? 0;
647
+ return previous[right.length] ?? 0;
633
648
  }
634
649
  function closest(name, names) {
635
650
  const started = names.find((known) => known.startsWith(name));
@@ -1352,13 +1367,31 @@ function ciHeader(spinner, label, startedAt, out) {
1352
1367
  // ../kit/src/cli.ts
1353
1368
  import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1354
1369
  import { dirname as dirname3, join as join5 } from "path";
1355
- import process17 from "process";
1370
+ import process18 from "process";
1371
+
1372
+ // ../kit/src/notify.ts
1373
+ import process16 from "process";
1374
+ var NOTIFY_AFTER_MS = 1e4;
1375
+ var CANCELLED = 130;
1376
+ function base64(text) {
1377
+ return Buffer.from(text).toString("base64");
1378
+ }
1379
+ function notification(title, body, env = process16.env) {
1380
+ const id = `kit${process16.pid}`;
1381
+ 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\\`];
1382
+ return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1383
+ }
1384
+ function notifyEnd(command, code, ms, { stream = process16.stderr, env = process16.env } = {}) {
1385
+ if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1386
+ return;
1387
+ stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1388
+ }
1356
1389
 
1357
1390
  // ../kit/src/usage.ts
1358
1391
  import { appendFileSync, mkdirSync } from "fs";
1359
1392
  import { homedir as homedir3 } from "os";
1360
1393
  import { dirname as dirname2, isAbsolute, join as join4 } from "path";
1361
- import process16 from "process";
1394
+ import process17 from "process";
1362
1395
 
1363
1396
  // ../kit/src/logs.ts
1364
1397
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -1372,14 +1405,14 @@ var usageError;
1372
1405
  function noteUsageError(message) {
1373
1406
  usageError = message;
1374
1407
  }
1375
- function stateHome(env = process16.env) {
1408
+ function stateHome(env = process17.env) {
1376
1409
  const dir = env.XDG_STATE_HOME;
1377
1410
  return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
1378
1411
  }
1379
- function usagePath(env = process16.env) {
1412
+ function usagePath(env = process17.env) {
1380
1413
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
1381
1414
  }
1382
- function usageRecorded(env = process16.env) {
1415
+ function usageRecorded(env = process17.env) {
1383
1416
  const off = env.KAYNOOO_CLI_NO_USAGE;
1384
1417
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1385
1418
  }
@@ -1393,7 +1426,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1393
1426
  usageError = undefined;
1394
1427
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1395
1428
  }
1396
- function recordUsage(entry, env = process16.env) {
1429
+ function recordUsage(entry, env = process17.env) {
1397
1430
  if (!usageRecorded(env))
1398
1431
  return;
1399
1432
  try {
@@ -1483,8 +1516,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
1483
1516
  `);
1484
1517
  }
1485
1518
  function printError(prefix, message, hint, cause) {
1486
- const colors = paint(process17.stderr);
1487
- const styled = takesControlCodes(process17.stderr);
1519
+ const colors = paint(process18.stderr);
1520
+ const styled = takesControlCodes(process18.stderr);
1488
1521
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1489
1522
  const under = (label, text, tint) => text === undefined ? "" : `
1490
1523
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1494,8 +1527,8 @@ function runHint(command, effect) {
1494
1527
  return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
1495
1528
  }
1496
1529
  function printHint(hint) {
1497
- const colors = paint(process17.stderr);
1498
- console.error(` ${takesControlCodes(process17.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
1530
+ const colors = paint(process18.stderr);
1531
+ console.error(` ${takesControlCodes(process18.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
1499
1532
  }
1500
1533
  function printJsonError(message, hint, cause) {
1501
1534
  console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
@@ -1534,11 +1567,11 @@ async function dispatch(level, typed, { version, redact }) {
1534
1567
  }
1535
1568
  }
1536
1569
  if (name === undefined && level.path.length > 1) {
1537
- console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stderr));
1570
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process18.stderr));
1538
1571
  return 2;
1539
1572
  }
1540
1573
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1541
- console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stdout));
1574
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process18.stdout));
1542
1575
  return 0;
1543
1576
  }
1544
1577
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1673,10 +1706,13 @@ async function runCli(cli, argv = scriptArgs()) {
1673
1706
  const version = cli.version ?? packageVersion();
1674
1707
  if (argv[0] === COMPLETE)
1675
1708
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
1709
+ const started = performance.now();
1676
1710
  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 });
1711
+ const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
1712
+ notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
1677
1713
  if (cli.usage !== false) {
1678
1714
  try {
1679
- recordUsage(usageEntry(cli.name, commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv), argv, code));
1715
+ recordUsage(usageEntry(cli.name, command, argv, code));
1680
1716
  } catch {}
1681
1717
  }
1682
1718
  return code;
@@ -1696,11 +1732,130 @@ function commandPath(scope, argv) {
1696
1732
  }
1697
1733
  return path.length === 0 ? undefined : path.join(" ");
1698
1734
  }
1735
+ // ../kit/src/excerpt.ts
1736
+ var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
1737
+ var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
1738
+ var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
1739
+ var BUN_CHECK_SUMMARY = /^Found \d+ errors?/;
1740
+ var TSC_ERROR = /\berror TS\d+/;
1741
+ var TSC_CONTINUATION = /^\s{2,}\S/;
1742
+ var TSC_FRAME = /^\s*[~^|]/;
1743
+ var TSC_SUMMARY = /^Found \d+ errors?/;
1744
+ var ESLINT_PROBLEM = /^\s+\d+:\d+\s+(?:error|warning)\s/;
1745
+ var ESLINT_SUMMARY = /^(?:\u2716 )?\d+ problems? \(/;
1746
+ var PHPSTAN_TABLE = /^\s*-{3,} -{3,}/;
1747
+ var PHPSTAN_NOISE = /^\s*\[OK\]/;
1748
+ var VITEST_FAIL_LINE = /^ FAIL {2}\S/;
1749
+ var PLAYWRIGHT_FAIL_LINE = /^ {2}1\) .+:\d+:\d+ \u203A .+ \u2500+$/;
1750
+ var CS_FIXER_LINE = /^\s+\d+\) \S.*\.php(?: \(.+\))?$/;
1751
+ var CS_FIXER_TOTAL = /^Found \d+ of \d+ files/;
1752
+ var MAX_LINES = 100;
1753
+ var bunCheck = (lines) => {
1754
+ const text = lines.join(`
1755
+ `);
1756
+ const blocks = text.match(BUN_CHECK_BLOCK);
1757
+ if (blocks === null)
1758
+ return;
1759
+ const errors = blocks.map((block) => {
1760
+ const { file, line, column, code, message } = bunCheckFields(block);
1761
+ return `${file}:${line}:${column} ${code}: ${message}`;
1762
+ });
1763
+ return [...errors, ...lines.filter((line) => BUN_CHECK_SUMMARY.test(line))];
1764
+ };
1765
+ function bunCheckFields(block) {
1766
+ const attributes = Object.fromEntries([...block.slice(0, block.indexOf(`
1767
+ `)).matchAll(BUN_CHECK_ATTRIBUTE)].map((match) => [match[1] ?? "", match[2] ?? ""]));
1768
+ return {
1769
+ file: attributes.file ?? "",
1770
+ line: attributes.line ?? "",
1771
+ column: attributes.column ?? "",
1772
+ code: attributes.code ?? "",
1773
+ message: block.replace(BUN_CHECK_SOURCE, "").split(`
1774
+ `).slice(1, -1).join(`
1775
+ `).trim()
1776
+ };
1777
+ }
1778
+ var tsc = (lines) => {
1779
+ const kept = [];
1780
+ let inError = false;
1781
+ for (const line of lines) {
1782
+ if (TSC_ERROR.test(line)) {
1783
+ inError = true;
1784
+ kept.push(line);
1785
+ } else if (TSC_SUMMARY.test(line)) {
1786
+ inError = false;
1787
+ kept.push(line);
1788
+ } else if (inError && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
1789
+ kept.push(line);
1790
+ } else {
1791
+ inError = false;
1792
+ }
1793
+ }
1794
+ return kept.some((line) => TSC_ERROR.test(line)) ? kept : undefined;
1795
+ };
1796
+ var eslint = (lines) => {
1797
+ const kept = [];
1798
+ let file = "";
1799
+ let shown = "";
1800
+ for (const line of lines) {
1801
+ if (ESLINT_PROBLEM.test(line)) {
1802
+ if (file !== shown) {
1803
+ kept.push(file);
1804
+ shown = file;
1805
+ }
1806
+ kept.push(line);
1807
+ } else if (ESLINT_SUMMARY.test(line)) {
1808
+ kept.push(line);
1809
+ } else if (line.trim() !== "") {
1810
+ file = line;
1811
+ }
1812
+ }
1813
+ return kept.some((line) => ESLINT_PROBLEM.test(line)) ? kept : undefined;
1814
+ };
1815
+ var phpstan = (lines) => {
1816
+ const start = lines.findIndex((line) => PHPSTAN_TABLE.test(line));
1817
+ return start === -1 ? undefined : lines.slice(start).filter((line) => !PHPSTAN_NOISE.test(line));
1818
+ };
1819
+ var vitest = (lines) => {
1820
+ const start = lines.findIndex((line) => VITEST_FAIL_LINE.test(line));
1821
+ return start === -1 ? undefined : lines.slice(start);
1822
+ };
1823
+ var playwright = (lines) => {
1824
+ const start = lines.findIndex((line) => PLAYWRIGHT_FAIL_LINE.test(line));
1825
+ return start === -1 ? undefined : lines.slice(start);
1826
+ };
1827
+ var phpCsFixer = (lines) => {
1828
+ const files = lines.filter((line) => CS_FIXER_LINE.test(line) || CS_FIXER_TOTAL.test(line));
1829
+ return files.some((line) => CS_FIXER_LINE.test(line)) ? files : undefined;
1830
+ };
1831
+ var TOOL_PARSERS = [bunCheck, tsc, eslint, vitest, playwright, phpCsFixer, phpstan];
1832
+ function squeeze(lines) {
1833
+ const out = [];
1834
+ for (const line of lines.map((text) => text.trimEnd())) {
1835
+ if (line !== "" || out.at(-1) !== "")
1836
+ out.push(line);
1837
+ }
1838
+ while (out.at(-1) === "")
1839
+ out.pop();
1840
+ return out;
1841
+ }
1842
+ function cut(shown) {
1843
+ return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
1844
+ `) : shown.join(`
1845
+ `);
1846
+ }
1847
+ function recognised(lines, parsers) {
1848
+ return parsers.map((parser) => parser(lines)).find((result) => result !== undefined && result.some((line) => line.trim() !== ""));
1849
+ }
1850
+ function toolExcerpt(lines) {
1851
+ const found = recognised(lines.map((line) => stripAnsi(line)), TOOL_PARSERS);
1852
+ return found === undefined ? undefined : cut(squeeze(found));
1853
+ }
1699
1854
  // ../kit/src/folders.ts
1700
1855
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1701
1856
  // ../kit/src/git.ts
1702
1857
  import { basename, dirname as dirname4 } from "path";
1703
- import process18 from "process";
1858
+ import process19 from "process";
1704
1859
  var ORIGIN_PREFIX = /^origin\//;
1705
1860
  var GIT_NETWORK_MS = 60000;
1706
1861
  async function git(args, timeoutMs) {
@@ -1730,7 +1885,7 @@ async function defaultBranch() {
1730
1885
  async function leaveWorktree() {
1731
1886
  const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
1732
1887
  if (basename(common) === ".git")
1733
- process18.chdir(dirname4(common));
1888
+ process19.chdir(dirname4(common));
1734
1889
  }
1735
1890
  // ../kit/src/limit.ts
1736
1891
  function limitOptions(fallback) {
@@ -1771,15 +1926,15 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
1771
1926
  // ../kit/src/sessions.ts
1772
1927
  import { homedir as homedir4 } from "os";
1773
1928
  import { join as join6 } from "path";
1774
- import process19 from "process";
1929
+ import process20 from "process";
1775
1930
  var {Glob } = globalThis.Bun;
1776
1931
  var SESSION_FILES = new Glob("*.json");
1777
1932
  var ACCOUNT_DIRS = new Glob("*/sessions");
1778
1933
  async function sessionDirs() {
1779
1934
  const home = homedir4();
1780
1935
  const dirs = new Set([join6(home, ".claude", "sessions")]);
1781
- if (process19.env.CLAUDE_CONFIG_DIR !== undefined)
1782
- dirs.add(join6(process19.env.CLAUDE_CONFIG_DIR, "sessions"));
1936
+ if (process20.env.CLAUDE_CONFIG_DIR !== undefined)
1937
+ dirs.add(join6(process20.env.CLAUDE_CONFIG_DIR, "sessions"));
1783
1938
  try {
1784
1939
  for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1785
1940
  dirs.add(dir);
@@ -1825,7 +1980,7 @@ async function liveSessions() {
1825
1980
  }
1826
1981
  async function currentSession(sessions) {
1827
1982
  const byPid = new Map(sessions.map((session) => [session.pid, session]));
1828
- let pid = process19.ppid;
1983
+ let pid = process20.ppid;
1829
1984
  for (let depth = 0;depth < 32 && pid > 1; depth++) {
1830
1985
  const session = byPid.get(pid);
1831
1986
  if (session !== undefined)
@@ -1838,7 +1993,7 @@ async function currentSession(sessions) {
1838
1993
  return;
1839
1994
  }
1840
1995
  // ../kit/src/watch.ts
1841
- import process20 from "process";
1996
+ import process21 from "process";
1842
1997
  import { format } from "util";
1843
1998
  var CLEAR_SCREEN = "\x1B[H\x1B[2J";
1844
1999
  var DEFAULT_SECONDS = 2;
@@ -1860,7 +2015,7 @@ function withoutWatch(args) {
1860
2015
  }
1861
2016
  return rest;
1862
2017
  }
1863
- async function watching(value, step, stream = process20.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
2018
+ async function watching(value, step, stream = process21.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
1864
2019
  const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
1865
2020
  if (!takesControlCodes(stream))
1866
2021
  badUsage("--watch redraws the screen, so it needs a terminal");
@@ -1868,12 +2023,12 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
1868
2023
  for (let round = 0;round < rounds; round++) {
1869
2024
  const held = [];
1870
2025
  const { log, info } = console;
1871
- const write = process20.stdout.write.bind(process20.stdout);
2026
+ const write = process21.stdout.write.bind(process21.stdout);
1872
2027
  const hold = (...parts) => void held.push(`${format(...parts)}
1873
2028
  `);
1874
2029
  console.log = hold;
1875
2030
  console.info = hold;
1876
- process20.stdout.write = (text) => {
2031
+ process21.stdout.write = (text) => {
1877
2032
  held.push(typeof text === "string" ? text : Buffer.from(text).toString());
1878
2033
  return true;
1879
2034
  };
@@ -1882,7 +2037,7 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
1882
2037
  } finally {
1883
2038
  console.log = log;
1884
2039
  console.info = info;
1885
- process20.stdout.write = write;
2040
+ process21.stdout.write = write;
1886
2041
  }
1887
2042
  stream.write(`${CLEAR_SCREEN}${held.join("")}`);
1888
2043
  await sleep(interval);
@@ -2060,9 +2215,9 @@ function holderSession(holder, sessions) {
2060
2215
  }
2061
2216
 
2062
2217
  // src/good.ts
2063
- import process22 from "process";
2218
+ import process23 from "process";
2064
2219
  function good(text) {
2065
- return role("ok", process22.stdout)(text);
2220
+ return role("ok", process23.stdout)(text);
2066
2221
  }
2067
2222
 
2068
2223
  // src/config.ts
@@ -2094,10 +2249,13 @@ async function loadSettings(home) {
2094
2249
  return typeof host === "string" && host !== "" ? { remoteHost: host } : {};
2095
2250
  }
2096
2251
 
2252
+ // src/tea.ts
2253
+ import process25 from "process";
2254
+
2097
2255
  // src/forge.ts
2098
2256
  import { homedir as homedir5 } from "os";
2099
2257
  import { join as join7 } from "path";
2100
- import process23 from "process";
2258
+ import process24 from "process";
2101
2259
 
2102
2260
  // src/remote.ts
2103
2261
  var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
@@ -2136,6 +2294,8 @@ async function reachesHost(hostname, host, hostAddresses, addressesOf) {
2136
2294
  // src/forge.ts
2137
2295
  var LOGIN_HOST = /^\s*(?:-\s*)?(?:url|ssh_host):\s*["']?([^\s"']+)/gm;
2138
2296
  var PORT = /:\d+$/;
2297
+ var LOGIN_LINE = /^\s*(-\s+)?([a-z_]+):(.*)$/;
2298
+ var QUOTES = /^["']|["']$/g;
2139
2299
  var SCP_REMOTE = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)/;
2140
2300
  var URL_REMOTE = /^[a-z+]+:\/\/(?:[^@/\s]+@)?(\[[^\]]+\]|[^:/\s]+)/i;
2141
2301
  function originHost(remote) {
@@ -2152,7 +2312,7 @@ function loginHosts(config) {
2152
2312
  return hosts;
2153
2313
  }
2154
2314
  function teaConfigPath() {
2155
- const base = process23.env.XDG_CONFIG_HOME;
2315
+ const base = process24.env.XDG_CONFIG_HOME;
2156
2316
  return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
2157
2317
  }
2158
2318
  async function readConfig() {
@@ -2171,35 +2331,105 @@ async function requireForgeOrigin() {
2171
2331
  const origin = await runTool("git remote get-url origin", ["git", "remote", "get-url", "origin"], { timeoutMs: 5000 });
2172
2332
  const host = origin.code === 0 ? originHost(origin.stdout) : undefined;
2173
2333
  if (host !== undefined && !hosts.has(host))
2174
- 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)");
2334
+ 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)");
2175
2335
  })();
2176
2336
  return checked;
2177
2337
  }
2338
+ function teaLogins(config) {
2339
+ const logins = [];
2340
+ let current;
2341
+ const finish = () => {
2342
+ if (current?.url !== undefined && current.token !== undefined && current.token !== "")
2343
+ logins.push({ url: current.url, token: current.token, isDefault: current.default === "true" });
2344
+ };
2345
+ for (const line of config.split(`
2346
+ `)) {
2347
+ const entry = LOGIN_LINE.exec(line);
2348
+ if (entry === null)
2349
+ continue;
2350
+ if (entry[1] !== undefined) {
2351
+ finish();
2352
+ current = {};
2353
+ }
2354
+ if (current !== undefined)
2355
+ current[entry[2]] = (entry[3] ?? "").trim().replace(QUOTES, "");
2356
+ }
2357
+ finish();
2358
+ return logins;
2359
+ }
2360
+ async function pickLogin(useOrigin) {
2361
+ const logins = teaLogins(await readConfig());
2362
+ if (useOrigin) {
2363
+ const origin = await runTool("git remote get-url origin", ["git", "remote", "get-url", "origin"], { timeoutMs: 5000 });
2364
+ const host = origin.code === 0 ? originHost(origin.stdout) : undefined;
2365
+ const match = host === undefined ? undefined : logins.find((each) => URL.canParse(each.url) && new URL(each.url).hostname.toLowerCase() === host);
2366
+ if (match !== undefined)
2367
+ return match;
2368
+ }
2369
+ return logins.find((each) => each.isDefault) ?? logins[0];
2370
+ }
2178
2371
 
2179
2372
  // src/tea.ts
2180
2373
  var TEA_MS = 60000;
2181
2374
  function repoFlag(repo) {
2182
2375
  return repo === undefined ? [] : ["--repo", repo];
2183
2376
  }
2184
- async function request(path, repo) {
2377
+ function usesGt() {
2378
+ const PATH = process25.env.PATH ?? "";
2379
+ return Bun.which("tea", { PATH }) === null && Bun.which("gt", { PATH }) !== null;
2380
+ }
2381
+ var injected;
2382
+ async function injectLogin(repo) {
2383
+ if (process25.env.GITEA_TOKEN !== undefined && process25.env.GITEA_TOKEN !== "")
2384
+ return;
2385
+ const login = await pickLogin(repo === undefined);
2386
+ if (login === undefined)
2387
+ return;
2388
+ injected = login.token;
2389
+ process25.env.GITEA_TOKEN = login.token;
2390
+ process25.env.GITEA_CLI_HOST = login.url;
2391
+ }
2392
+ function scrub(text) {
2393
+ const token = injected ?? process25.env.GITEA_TOKEN;
2394
+ return token === undefined || token === "" ? text : text.replaceAll(token, "***");
2395
+ }
2396
+ function failureText(stdout, stderr, code) {
2397
+ try {
2398
+ const value = JSON.parse(stdout);
2399
+ if (value !== null && typeof value === "object" && "message" in value && typeof value.message === "string")
2400
+ return scrub(value.message);
2401
+ } catch {}
2402
+ return scrub(stderr.trim() || stdout.trim() || `exit ${code}`);
2403
+ }
2404
+ async function runApi(label, args, repo) {
2185
2405
  if (repo === undefined)
2186
2406
  await requireForgeOrigin();
2187
- const result = await runTool(`tea api ${path}`, ["tea", "api", ...repoFlag(repo), path], { timeoutMs: TEA_MS });
2407
+ const gt = usesGt();
2408
+ const bin = gt ? "gt" : "tea";
2409
+ if (gt)
2410
+ await injectLogin(repo);
2411
+ const result = await runTool(`${bin} api ${label}`, [bin, "api", ...repoFlag(repo), ...args], { timeoutMs: TEA_MS });
2188
2412
  if (result.code !== 0)
2189
- throw new Error(`tea api ${path}: ${result.stderr.trim() || `exit ${result.code}`}`);
2190
- return result.stdout;
2413
+ throw new Error(`${bin} api ${label}: ${gt ? failureText(result.stdout, result.stderr, result.code) : result.stderr.trim() || `exit ${result.code}`}`);
2414
+ return gt ? scrub(result.stdout) : result.stdout;
2415
+ }
2416
+ async function request(path, repo) {
2417
+ return runApi(path, [path], repo);
2418
+ }
2419
+ function clientName() {
2420
+ return usesGt() ? "gt" : "tea";
2191
2421
  }
2192
2422
  function parseJson(path, text) {
2193
2423
  let value;
2194
2424
  try {
2195
2425
  value = JSON.parse(text);
2196
2426
  } catch {
2197
- throw new Error(`tea api ${path}: ${upTo(text.trim(), `
2427
+ throw new Error(`${clientName()} api ${path}: ${upTo(text.trim(), `
2198
2428
  `) || "empty answer"}`);
2199
2429
  }
2200
2430
  const failure = apiError(value);
2201
2431
  if (failure !== undefined)
2202
- throw new Error(`tea api ${path}: ${failure}`);
2432
+ throw new Error(`${clientName()} api ${path}: ${failure}`);
2203
2433
  return value;
2204
2434
  }
2205
2435
  function apiError(value) {
@@ -2213,15 +2443,13 @@ async function api(path, repo) {
2213
2443
  async function repoApi(path, repo) {
2214
2444
  return api(`repos/{owner}/{repo}/${path}`, repo);
2215
2445
  }
2216
- async function repoWrite(method, path, fields, repo) {
2446
+ async function repoSend(method, path, fields, repo) {
2217
2447
  const full = `repos/{owner}/{repo}/${path}`;
2218
- const flags = Object.entries(fields).flatMap(([name, value]) => ["-f", `${name}=${value}`]);
2219
- if (repo === undefined)
2220
- await requireForgeOrigin();
2221
- const result = await runTool(`tea api ${full}`, ["tea", "api", ...repoFlag(repo), "-X", method, ...flags, full], { timeoutMs: TEA_MS });
2222
- if (result.code !== 0)
2223
- throw new Error(`tea api ${full}: ${result.stderr.trim() || `exit ${result.code}`}`);
2224
- return parseJson(full, result.stdout);
2448
+ const flags = Object.entries(fields).flatMap(([name, value]) => typeof value === "string" ? ["-f", `${name}=${value}`] : ["-F", `${name}=${JSON.stringify(value)}`]);
2449
+ return runApi(full, ["-X", method, ...flags, full], repo);
2450
+ }
2451
+ async function repoWrite(method, path, fields, repo) {
2452
+ return parseJson(`repos/{owner}/{repo}/${path}`, await repoSend(method, path, fields, repo));
2225
2453
  }
2226
2454
  async function repoApiText(path, repo) {
2227
2455
  const full = `repos/{owner}/{repo}/${path}`;
@@ -2234,7 +2462,7 @@ async function repoApiText(path, repo) {
2234
2462
  }
2235
2463
  const failure = apiError(value);
2236
2464
  if (failure !== undefined)
2237
- throw new Error(`tea api ${full}: ${failure}`);
2465
+ throw new Error(`${clientName()} api ${full}: ${failure}`);
2238
2466
  return text;
2239
2467
  }
2240
2468
  async function tea(command, args, repo) {
@@ -2246,8 +2474,56 @@ async function tea(command, args, repo) {
2246
2474
  return result.stdout;
2247
2475
  }
2248
2476
 
2249
- // src/issues.ts
2477
+ // src/milestones.ts
2250
2478
  var PAGE = 50;
2479
+ var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
2480
+ var NO_DUE_YEAR = 9999;
2481
+ async function listMilestones(state, repo) {
2482
+ const found = [];
2483
+ for (let page = 1;; page++) {
2484
+ const batch = await repoApi(`milestones?state=${state}&page=${page}&limit=${PAGE}`, repo);
2485
+ found.push(...batch);
2486
+ if (batch.length < PAGE)
2487
+ return found;
2488
+ }
2489
+ }
2490
+ async function findMilestone(reference, repo) {
2491
+ const all = await listMilestones("all", repo);
2492
+ const found = all.find((each) => each.title === reference) ?? all.find((each) => String(each.id) === reference);
2493
+ if (found === undefined)
2494
+ 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"));
2495
+ return found;
2496
+ }
2497
+ function dueOn(value) {
2498
+ const match = DATE.exec(value);
2499
+ const date = new Date(`${value}T00:00:00Z`);
2500
+ if (match === null || Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value || date.getUTCFullYear() < 2000)
2501
+ fail(`--due takes a date as YYYY-MM-DD, not ${value}`);
2502
+ return date.toISOString();
2503
+ }
2504
+ function dueDate(milestone) {
2505
+ if (milestone.due_on === null || new Date(milestone.due_on).getUTCFullYear() >= NO_DUE_YEAR)
2506
+ return "";
2507
+ return milestone.due_on.slice(0, 10);
2508
+ }
2509
+ function progress(milestone) {
2510
+ const total = milestone.open_issues + milestone.closed_issues;
2511
+ return total === 0 ? "" : `${Math.round(milestone.closed_issues / total * 100)}%`;
2512
+ }
2513
+ async function createMilestone(title, description, due, repo) {
2514
+ const fields = { title };
2515
+ if (description !== undefined)
2516
+ fields.description = description;
2517
+ if (due !== undefined)
2518
+ fields.due_on = due;
2519
+ return repoWrite("POST", "milestones", fields, repo);
2520
+ }
2521
+ async function closeMilestone(id, repo) {
2522
+ await repoWrite("PATCH", `milestones/${id}`, { state: "closed" }, repo);
2523
+ }
2524
+
2525
+ // src/issues.ts
2526
+ var PAGE2 = 50;
2251
2527
  var CONCURRENCY = 8;
2252
2528
  async function getIssue(number, repo) {
2253
2529
  return repoApi(`issues/${number}`, repo);
@@ -2255,9 +2531,9 @@ async function getIssue(number, repo) {
2255
2531
  async function listIssues(state, filter, repo) {
2256
2532
  const issues = [];
2257
2533
  for (let page = 1;; page++) {
2258
- const batch = await repoApi(`issues?state=${state}&type=issues&page=${page}&limit=${PAGE}${filter}`, repo);
2534
+ const batch = await repoApi(`issues?state=${state}&type=issues&page=${page}&limit=${PAGE2}${filter}`, repo);
2259
2535
  issues.push(...batch);
2260
- if (batch.length < PAGE)
2536
+ if (batch.length < PAGE2)
2261
2537
  return issues;
2262
2538
  }
2263
2539
  }
@@ -2276,6 +2552,10 @@ async function commentsOfAll(issues, repo) {
2276
2552
  return new Map(commented.map((issue, index) => [issue.number, comments[index]]));
2277
2553
  }
2278
2554
  async function editIssue(number, change, repo) {
2555
+ if (usesGt()) {
2556
+ 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);
2557
+ return;
2558
+ }
2279
2559
  const args = [String(number)];
2280
2560
  if (change.title !== undefined)
2281
2561
  args.push("-t", change.title);
@@ -2289,6 +2569,9 @@ async function setBody(number, body, repo) {
2289
2569
  await editIssue(number, { body }, repo);
2290
2570
  }
2291
2571
  async function createIssue(title, body, labels, milestone, repo) {
2572
+ if (usesGt()) {
2573
+ return repoWrite("POST", "issues", { title, body, ...labels === undefined ? {} : { labels: await labelIds(labels.split(","), repo) }, ...milestone === undefined ? {} : { milestone: await milestoneId(milestone, repo) } }, repo);
2574
+ }
2292
2575
  const args = ["-t", title, "-d", body];
2293
2576
  const same = (found) => found.title === title && sameText(found.body, body);
2294
2577
  const known = new Set((await openIssues(undefined, repo)).filter(same).map((found) => found.number));
@@ -2341,21 +2624,32 @@ async function comment(number, body, repo) {
2341
2624
  await repoWrite("POST", `issues/${number}/comments`, { body }, repo);
2342
2625
  }
2343
2626
  async function close(number, repo) {
2627
+ if (usesGt())
2628
+ return void await repoWrite("PATCH", `issues/${number}`, { state: "closed" }, repo);
2344
2629
  await tea(["issues", "close"], [String(number)], repo);
2345
2630
  }
2346
2631
  async function reopen(number, repo) {
2632
+ if (usesGt())
2633
+ return void await repoWrite("PATCH", `issues/${number}`, { state: "open" }, repo);
2347
2634
  await tea(["issues", "reopen"], [String(number)], repo);
2348
2635
  }
2349
2636
  async function repoLabels(repo) {
2350
2637
  const names = [];
2351
2638
  for (let page = 1;; page++) {
2352
- const batch = await repoApi(`labels?page=${page}&limit=${PAGE}`, repo);
2639
+ const batch = await repoApi(`labels?page=${page}&limit=${PAGE2}`, repo);
2353
2640
  names.push(...batch.map((each) => each.name));
2354
- if (batch.length < PAGE)
2641
+ if (batch.length < PAGE2)
2355
2642
  return names;
2356
2643
  }
2357
2644
  }
2358
2645
  async function editLabels(number, add, remove, repo) {
2646
+ if (usesGt()) {
2647
+ if (add.length > 0)
2648
+ await repoSend("POST", `issues/${number}/labels`, { labels: await labelIds(add, repo) }, repo);
2649
+ for (const id of await labelIds(remove, repo))
2650
+ await repoSend("DELETE", `issues/${number}/labels/${id}`, {}, repo);
2651
+ return;
2652
+ }
2359
2653
  const args = [String(number)];
2360
2654
  if (add.length > 0)
2361
2655
  args.push("--add-labels", add.join(","));
@@ -2363,53 +2657,23 @@ async function editLabels(number, add, remove, repo) {
2363
2657
  args.push("--remove-labels", remove.join(","));
2364
2658
  await tea(["issues", "edit"], args, repo);
2365
2659
  }
2366
-
2367
- // src/milestones.ts
2368
- var PAGE2 = 50;
2369
- var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
2370
- var NO_DUE_YEAR = 9999;
2371
- async function listMilestones(state, repo) {
2372
- const found = [];
2660
+ async function labelIds(names, repo) {
2661
+ const all = [];
2373
2662
  for (let page = 1;; page++) {
2374
- const batch = await repoApi(`milestones?state=${state}&page=${page}&limit=${PAGE2}`, repo);
2375
- found.push(...batch);
2663
+ const batch = await repoApi(`labels?page=${page}&limit=${PAGE2}`, repo);
2664
+ all.push(...batch);
2376
2665
  if (batch.length < PAGE2)
2377
- return found;
2666
+ break;
2378
2667
  }
2668
+ return names.map((name) => name.trim()).filter((name) => name !== "").map((name) => {
2669
+ const found = all.find((each) => each.name === name);
2670
+ if (found === undefined)
2671
+ throw new Error(`no label ${name}, the repository has: ${all.map((each) => each.name).join(", ")}`);
2672
+ return found.id;
2673
+ });
2379
2674
  }
2380
- async function findMilestone(reference, repo) {
2381
- const all = await listMilestones("all", repo);
2382
- const found = all.find((each) => each.title === reference) ?? all.find((each) => String(each.id) === reference);
2383
- if (found === undefined)
2384
- 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"));
2385
- return found;
2386
- }
2387
- function dueOn(value) {
2388
- const match = DATE.exec(value);
2389
- const date = new Date(`${value}T00:00:00Z`);
2390
- if (match === null || Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value || date.getUTCFullYear() < 2000)
2391
- fail(`--due takes a date as YYYY-MM-DD, not ${value}`);
2392
- return date.toISOString();
2393
- }
2394
- function dueDate(milestone) {
2395
- if (milestone.due_on === null || new Date(milestone.due_on).getUTCFullYear() >= NO_DUE_YEAR)
2396
- return "";
2397
- return milestone.due_on.slice(0, 10);
2398
- }
2399
- function progress(milestone) {
2400
- const total = milestone.open_issues + milestone.closed_issues;
2401
- return total === 0 ? "" : `${Math.round(milestone.closed_issues / total * 100)}%`;
2402
- }
2403
- async function createMilestone(title, description, due, repo) {
2404
- const fields = { title };
2405
- if (description !== undefined)
2406
- fields.description = description;
2407
- if (due !== undefined)
2408
- fields.due_on = due;
2409
- return repoWrite("POST", "milestones", fields, repo);
2410
- }
2411
- async function closeMilestone(id, repo) {
2412
- await repoWrite("PATCH", `milestones/${id}`, { state: "closed" }, repo);
2675
+ async function milestoneId(title, repo) {
2676
+ return title === "" ? 0 : (await findMilestone(title, repo)).id;
2413
2677
  }
2414
2678
 
2415
2679
  // src/commands/board.ts
@@ -2685,7 +2949,7 @@ async function drop(args) {
2685
2949
  }
2686
2950
 
2687
2951
  // src/commands/ci.ts
2688
- import process24 from "process";
2952
+ import process26 from "process";
2689
2953
 
2690
2954
  // src/git.ts
2691
2955
  async function tagsAt(commit) {
@@ -2711,6 +2975,7 @@ var STAMP = /^\S+Z /;
2711
2975
  var FAILED_STEP = /\u274C\s+Failure - Main /;
2712
2976
  var STEP_TAIL = 30;
2713
2977
  var TAIL = 40;
2978
+ var TOOL_WINDOW = 200;
2714
2979
  function logLines(log) {
2715
2980
  return log.split(`
2716
2981
  `).map((line) => line.replace(STAMP, ""));
@@ -2736,7 +3001,7 @@ function excerpt(log) {
2736
3001
  const parts = failedTests(lines);
2737
3002
  for (const [index, line] of lines.entries()) {
2738
3003
  if (FAILED_STEP.test(line))
2739
- parts.push(lines.slice(Math.max(0, index - STEP_TAIL), index + 1).filter((text) => text.trim() !== "" && !text.startsWith(PASS) && !text.startsWith("::")).join(`
3004
+ 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(`
2740
3005
  `));
2741
3006
  }
2742
3007
  return parts.length === 0 ? lines.slice(-TAIL).join(`
@@ -2864,7 +3129,7 @@ async function failedJobsOf(run, repo) {
2864
3129
  }
2865
3130
  return failed;
2866
3131
  }
2867
- function failureText(failed, out = process.stderr) {
3132
+ function failureText2(failed, out = process.stderr) {
2868
3133
  const problem = role("failed", out);
2869
3134
  return failed.map((job) => `${problem(`job ${job.name} of ${job.workflow} failed`)}:
2870
3135
  ${job.excerpt}`).join(`
@@ -2951,7 +3216,7 @@ async function ci2(args) {
2951
3216
  return;
2952
3217
  }
2953
3218
  const json = values.json === true;
2954
- const live = takesControlCodes(process24.stderr) && takesControlCodes(process24.stdout) && !json && values.quiet !== true;
3219
+ const live = takesControlCodes(process26.stderr) && takesControlCodes(process26.stdout) && !json && values.quiet !== true;
2955
3220
  const runs = await waitForCi({
2956
3221
  tool: "ft ci",
2957
3222
  short,
@@ -2977,8 +3242,8 @@ async function ci2(args) {
2977
3242
  return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
2978
3243
  },
2979
3244
  lines: (spinner, found, started) => [
2980
- ciHeader(spinner, `CI on ${short}`, started, process24.stderr),
2981
- ...(found ?? []).map((run) => ` ${runLine(run, process24.stderr, undefined, run.commit_sha.slice(0, 7))}`)
3245
+ ciHeader(spinner, `CI on ${short}`, started, process26.stderr),
3246
+ ...(found ?? []).map((run) => ` ${runLine(run, process26.stderr, undefined, run.commit_sha.slice(0, 7))}`)
2982
3247
  ]
2983
3248
  });
2984
3249
  const status = overall(runs);
@@ -2995,7 +3260,7 @@ async function ci2(args) {
2995
3260
  }
2996
3261
  if (live) {
2997
3262
  for (const run of runs)
2998
- console.log(runLine(run, process24.stdout, undefined, run.commit_sha.slice(0, 7)));
3263
+ console.log(runLine(run, process26.stdout, undefined, run.commit_sha.slice(0, 7)));
2999
3264
  }
3000
3265
  if (status !== "failure") {
3001
3266
  if (live)
@@ -3006,7 +3271,7 @@ async function ci2(args) {
3006
3271
  for (const run of runs) {
3007
3272
  if (run.status === "failure")
3008
3273
  console.error(`
3009
- ${failureText(failed.filter((job) => job.run === run.id))}
3274
+ ${failureText2(failed.filter((job) => job.run === run.id))}
3010
3275
 
3011
3276
  run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from ${short} to ${run.commit_sha.slice(0, 7)}`}: ${run.html_url}`);
3012
3277
  }
@@ -3014,7 +3279,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
3014
3279
  }
3015
3280
 
3016
3281
  // src/commands/digest.ts
3017
- import process25 from "process";
3282
+ import process27 from "process";
3018
3283
  var RUNS_SCANNED = 50;
3019
3284
  var TITLE_WIDTH2 = 70;
3020
3285
  var SHOWN = 8;
@@ -3064,7 +3329,7 @@ async function quietly(read) {
3064
3329
  }
3065
3330
  }
3066
3331
  async function staleTodos() {
3067
- const bin = Bun.which("todo-scan", { PATH: process25.env.PATH ?? "" });
3332
+ const bin = Bun.which("todo-scan", { PATH: process27.env.PATH ?? "" });
3068
3333
  if (bin === null)
3069
3334
  return [];
3070
3335
  let found;
@@ -3086,8 +3351,8 @@ async function staleTodos() {
3086
3351
  return [...byIssue.values()];
3087
3352
  }
3088
3353
  function claimLine(row, now) {
3089
- const id = role("id", process25.stdout);
3090
- 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)];
3354
+ const id = role("id", process27.stdout);
3355
+ 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)];
3091
3356
  }
3092
3357
  function capped2(lines) {
3093
3358
  return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
@@ -3098,13 +3363,13 @@ function renderDigest(digest, now = Date.now()) {
3098
3363
  `) },
3099
3364
  { heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
3100
3365
  `) },
3101
- { 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, `
3366
+ { 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, `
3102
3367
  `), TITLE_WIDTH2)}`) },
3103
3368
  { heading: "unpushed commits", tone: "queued", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
3104
- { heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process25.stdout)(file.path)}`)) },
3369
+ { heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process27.stdout)(file.path)}`)) },
3105
3370
  { 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(", ")}`)) }
3106
3371
  ].filter((each) => each.count > 0);
3107
- return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process25.stdout, process25.env, tone)}
3372
+ return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process27.stdout, process27.env, tone)}
3108
3373
  ${lines.join(`
3109
3374
  `).replace(LINE_START2, " ")}`).join(`
3110
3375
 
@@ -3609,7 +3874,7 @@ async function issue(args) {
3609
3874
  // src/commands/logs.ts
3610
3875
  var usage4 = `ft logs <run id>
3611
3876
 
3612
- Prints what the failed jobs of a run say went wrong: each failed bun test's output and the end of each failed step.
3877
+ 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.
3613
3878
  With no failed job it prints every job's last lines; --full prints whole logs.`;
3614
3879
  var EXITS3 = [[0, "it printed the logs"], [1, "Forgejo cannot be read"], [2, "a usage error or a job the run lacks"]];
3615
3880
  var options3 = {
@@ -3656,7 +3921,7 @@ ${await text(job)}`);
3656
3921
  }
3657
3922
 
3658
3923
  // src/commands/milestone.ts
3659
- import process26 from "process";
3924
+ import process28 from "process";
3660
3925
  var TITLE_WIDTH3 = 60;
3661
3926
  var LIST_LIMIT = 30;
3662
3927
  var CONCURRENCY2 = 4;
@@ -3665,15 +3930,15 @@ function counts(milestone) {
3665
3930
  }
3666
3931
  function progressBar(milestone) {
3667
3932
  const total = milestone.open_issues + milestone.closed_issues;
3668
- return takesControlCodes(process26.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
3933
+ return takesControlCodes(process28.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
3669
3934
  }
3670
3935
  function milestoneCells(each, showState) {
3671
3936
  const drawn = progressBar(each);
3672
3937
  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] : []];
3673
3938
  }
3674
3939
  async function printWithIssues(list, repo) {
3675
- const colors = paint(process26.stdout);
3676
- const id = role("id", process26.stdout);
3940
+ const colors = paint(process28.stdout);
3941
+ const id = role("id", process28.stdout);
3677
3942
  const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
3678
3943
  const blocks = list.map((each, index) => {
3679
3944
  const byNumber = (left, right) => left.number - right.number;
@@ -3684,7 +3949,7 @@ async function printWithIssues(list, repo) {
3684
3949
  ...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
3685
3950
  ...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
3686
3951
  ];
3687
- return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process26.stdout, process26.env, "accent"), ...lines].join(`
3952
+ return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process28.stdout, process28.env, "accent"), ...lines].join(`
3688
3953
  `);
3689
3954
  });
3690
3955
  console.log(blocks.join(`
@@ -3944,7 +4209,7 @@ function report2(plan, added, skipped) {
3944
4209
 
3945
4210
  // src/commands/release.ts
3946
4211
  import { basename as basename3, join as join11 } from "path";
3947
- import process28 from "process";
4212
+ import process30 from "process";
3948
4213
  var {$: $2 } = globalThis.Bun;
3949
4214
 
3950
4215
  // src/commands/watch.ts
@@ -4007,7 +4272,7 @@ async function followRuns(pick, timeout, repo, idle, out = process.stdout, mode
4007
4272
  failedJobs.push(...jobs);
4008
4273
  if (!json)
4009
4274
  console.error(`
4010
- ${failureText(jobs)}
4275
+ ${failureText2(jobs)}
4011
4276
 
4012
4277
  ${run.html_url}`);
4013
4278
  failed.add(run.id);
@@ -4182,12 +4447,12 @@ async function publishable() {
4182
4447
 
4183
4448
  // src/commands/release-plan.ts
4184
4449
  import { basename as basename2, join as join9, relative } from "path";
4185
- import process27 from "process";
4450
+ import process29 from "process";
4186
4451
  async function planOf({ level, dir, prefix }, registry) {
4187
4452
  const file = Bun.file(join9(dir ?? ".", "package.json"));
4188
4453
  const pkg = await file.exists() ? await file.json() : undefined;
4189
- const name = pkg?.name ?? basename2(dir ?? process27.cwd());
4190
- const where = dir === undefined ? "" : ` in ${relative(process27.cwd(), dir) || "."}`;
4454
+ const name = pkg?.name ?? basename2(dir ?? process29.cwd());
4455
+ const where = dir === undefined ? "" : ` in ${relative(process29.cwd(), dir) || "."}`;
4191
4456
  let version;
4192
4457
  let bump;
4193
4458
  if (level === undefined) {
@@ -4432,7 +4697,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
4432
4697
  if (late !== undefined)
4433
4698
  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));
4434
4699
  say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
4435
- 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 });
4700
+ 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 });
4436
4701
  if (followed.code !== 0) {
4437
4702
  report();
4438
4703
  return followed.code;
@@ -4607,7 +4872,7 @@ async function runs(args) {
4607
4872
  }
4608
4873
 
4609
4874
  // src/cli.ts
4610
- process29.exitCode = await runCli({
4875
+ process31.exitCode = await runCli({
4611
4876
  name: "ft",
4612
4877
  about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
4613
4878
  replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-forgejo",
3
3
  "type": "module",
4
- "version": "0.29.1",
4
+ "version": "0.30.1",
5
5
  "description": "ft: Forgejo CI runs, logs, releases and issue checklists from the terminal, through tea.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -31,6 +31,6 @@
31
31
  "@kaynooo/utils": "3.0.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@kaynooo/cli-kit": "0.38.2"
34
+ "@kaynooo/cli-kit": "0.40.0"
35
35
  }
36
36
  }