@kaynooo/cli-forgejo 0.29.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +219 -63
- 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
|
|
5
|
+
import process30 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 =
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
626
|
-
|
|
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,
|
|
629
|
-
|
|
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[
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
1412
|
+
function usagePath(env = process17.env) {
|
|
1380
1413
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1381
1414
|
}
|
|
1382
|
-
function usageRecorded(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 =
|
|
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(
|
|
1487
|
-
const styled = takesControlCodes(
|
|
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(
|
|
1498
|
-
console.error(` ${takesControlCodes(
|
|
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]),
|
|
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]),
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
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 (
|
|
1782
|
-
dirs.add(join6(
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
2218
|
+
import process23 from "process";
|
|
2064
2219
|
function good(text) {
|
|
2065
|
-
return role("ok",
|
|
2220
|
+
return role("ok", process23.stdout)(text);
|
|
2066
2221
|
}
|
|
2067
2222
|
|
|
2068
2223
|
// src/config.ts
|
|
@@ -2097,7 +2252,7 @@ async function loadSettings(home) {
|
|
|
2097
2252
|
// src/forge.ts
|
|
2098
2253
|
import { homedir as homedir5 } from "os";
|
|
2099
2254
|
import { join as join7 } from "path";
|
|
2100
|
-
import
|
|
2255
|
+
import process24 from "process";
|
|
2101
2256
|
|
|
2102
2257
|
// src/remote.ts
|
|
2103
2258
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2152,7 +2307,7 @@ function loginHosts(config) {
|
|
|
2152
2307
|
return hosts;
|
|
2153
2308
|
}
|
|
2154
2309
|
function teaConfigPath() {
|
|
2155
|
-
const base =
|
|
2310
|
+
const base = process24.env.XDG_CONFIG_HOME;
|
|
2156
2311
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
2157
2312
|
}
|
|
2158
2313
|
async function readConfig() {
|
|
@@ -2685,7 +2840,7 @@ async function drop(args) {
|
|
|
2685
2840
|
}
|
|
2686
2841
|
|
|
2687
2842
|
// src/commands/ci.ts
|
|
2688
|
-
import
|
|
2843
|
+
import process25 from "process";
|
|
2689
2844
|
|
|
2690
2845
|
// src/git.ts
|
|
2691
2846
|
async function tagsAt(commit) {
|
|
@@ -2711,6 +2866,7 @@ var STAMP = /^\S+Z /;
|
|
|
2711
2866
|
var FAILED_STEP = /\u274C\s+Failure - Main /;
|
|
2712
2867
|
var STEP_TAIL = 30;
|
|
2713
2868
|
var TAIL = 40;
|
|
2869
|
+
var TOOL_WINDOW = 200;
|
|
2714
2870
|
function logLines(log) {
|
|
2715
2871
|
return log.split(`
|
|
2716
2872
|
`).map((line) => line.replace(STAMP, ""));
|
|
@@ -2736,7 +2892,7 @@ function excerpt(log) {
|
|
|
2736
2892
|
const parts = failedTests(lines);
|
|
2737
2893
|
for (const [index, line] of lines.entries()) {
|
|
2738
2894
|
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(`
|
|
2895
|
+
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
2896
|
`));
|
|
2741
2897
|
}
|
|
2742
2898
|
return parts.length === 0 ? lines.slice(-TAIL).join(`
|
|
@@ -2951,7 +3107,7 @@ async function ci2(args) {
|
|
|
2951
3107
|
return;
|
|
2952
3108
|
}
|
|
2953
3109
|
const json = values.json === true;
|
|
2954
|
-
const live = takesControlCodes(
|
|
3110
|
+
const live = takesControlCodes(process25.stderr) && takesControlCodes(process25.stdout) && !json && values.quiet !== true;
|
|
2955
3111
|
const runs = await waitForCi({
|
|
2956
3112
|
tool: "ft ci",
|
|
2957
3113
|
short,
|
|
@@ -2977,8 +3133,8 @@ async function ci2(args) {
|
|
|
2977
3133
|
return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
|
|
2978
3134
|
},
|
|
2979
3135
|
lines: (spinner, found, started) => [
|
|
2980
|
-
ciHeader(spinner, `CI on ${short}`, started,
|
|
2981
|
-
...(found ?? []).map((run) => ` ${runLine(run,
|
|
3136
|
+
ciHeader(spinner, `CI on ${short}`, started, process25.stderr),
|
|
3137
|
+
...(found ?? []).map((run) => ` ${runLine(run, process25.stderr, undefined, run.commit_sha.slice(0, 7))}`)
|
|
2982
3138
|
]
|
|
2983
3139
|
});
|
|
2984
3140
|
const status = overall(runs);
|
|
@@ -2995,7 +3151,7 @@ async function ci2(args) {
|
|
|
2995
3151
|
}
|
|
2996
3152
|
if (live) {
|
|
2997
3153
|
for (const run of runs)
|
|
2998
|
-
console.log(runLine(run,
|
|
3154
|
+
console.log(runLine(run, process25.stdout, undefined, run.commit_sha.slice(0, 7)));
|
|
2999
3155
|
}
|
|
3000
3156
|
if (status !== "failure") {
|
|
3001
3157
|
if (live)
|
|
@@ -3014,7 +3170,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
3014
3170
|
}
|
|
3015
3171
|
|
|
3016
3172
|
// src/commands/digest.ts
|
|
3017
|
-
import
|
|
3173
|
+
import process26 from "process";
|
|
3018
3174
|
var RUNS_SCANNED = 50;
|
|
3019
3175
|
var TITLE_WIDTH2 = 70;
|
|
3020
3176
|
var SHOWN = 8;
|
|
@@ -3064,7 +3220,7 @@ async function quietly(read) {
|
|
|
3064
3220
|
}
|
|
3065
3221
|
}
|
|
3066
3222
|
async function staleTodos() {
|
|
3067
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
3223
|
+
const bin = Bun.which("todo-scan", { PATH: process26.env.PATH ?? "" });
|
|
3068
3224
|
if (bin === null)
|
|
3069
3225
|
return [];
|
|
3070
3226
|
let found;
|
|
@@ -3086,8 +3242,8 @@ async function staleTodos() {
|
|
|
3086
3242
|
return [...byIssue.values()];
|
|
3087
3243
|
}
|
|
3088
3244
|
function claimLine(row, now) {
|
|
3089
|
-
const id = role("id",
|
|
3090
|
-
return [id(`#${row.number}`), row.holder, paint(
|
|
3245
|
+
const id = role("id", process26.stdout);
|
|
3246
|
+
return [id(`#${row.number}`), row.holder, paint(process26.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
|
|
3091
3247
|
}
|
|
3092
3248
|
function capped2(lines) {
|
|
3093
3249
|
return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
|
|
@@ -3098,13 +3254,13 @@ function renderDigest(digest, now = Date.now()) {
|
|
|
3098
3254
|
`) },
|
|
3099
3255
|
{ heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
|
|
3100
3256
|
`) },
|
|
3101
|
-
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status,
|
|
3257
|
+
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process26.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
|
|
3102
3258
|
`), TITLE_WIDTH2)}`) },
|
|
3103
3259
|
{ 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",
|
|
3260
|
+
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process26.stdout)(file.path)}`)) },
|
|
3105
3261
|
{ 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
3262
|
].filter((each) => each.count > 0);
|
|
3107
|
-
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count,
|
|
3263
|
+
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process26.stdout, process26.env, tone)}
|
|
3108
3264
|
${lines.join(`
|
|
3109
3265
|
`).replace(LINE_START2, " ")}`).join(`
|
|
3110
3266
|
|
|
@@ -3609,7 +3765,7 @@ async function issue(args) {
|
|
|
3609
3765
|
// src/commands/logs.ts
|
|
3610
3766
|
var usage4 = `ft logs <run id>
|
|
3611
3767
|
|
|
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.
|
|
3768
|
+
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
3769
|
With no failed job it prints every job's last lines; --full prints whole logs.`;
|
|
3614
3770
|
var EXITS3 = [[0, "it printed the logs"], [1, "Forgejo cannot be read"], [2, "a usage error or a job the run lacks"]];
|
|
3615
3771
|
var options3 = {
|
|
@@ -3656,7 +3812,7 @@ ${await text(job)}`);
|
|
|
3656
3812
|
}
|
|
3657
3813
|
|
|
3658
3814
|
// src/commands/milestone.ts
|
|
3659
|
-
import
|
|
3815
|
+
import process27 from "process";
|
|
3660
3816
|
var TITLE_WIDTH3 = 60;
|
|
3661
3817
|
var LIST_LIMIT = 30;
|
|
3662
3818
|
var CONCURRENCY2 = 4;
|
|
@@ -3665,15 +3821,15 @@ function counts(milestone) {
|
|
|
3665
3821
|
}
|
|
3666
3822
|
function progressBar(milestone) {
|
|
3667
3823
|
const total = milestone.open_issues + milestone.closed_issues;
|
|
3668
|
-
return takesControlCodes(
|
|
3824
|
+
return takesControlCodes(process27.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
|
|
3669
3825
|
}
|
|
3670
3826
|
function milestoneCells(each, showState) {
|
|
3671
3827
|
const drawn = progressBar(each);
|
|
3672
3828
|
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
3829
|
}
|
|
3674
3830
|
async function printWithIssues(list, repo) {
|
|
3675
|
-
const colors = paint(
|
|
3676
|
-
const id = role("id",
|
|
3831
|
+
const colors = paint(process27.stdout);
|
|
3832
|
+
const id = role("id", process27.stdout);
|
|
3677
3833
|
const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
3678
3834
|
const blocks = list.map((each, index) => {
|
|
3679
3835
|
const byNumber = (left, right) => left.number - right.number;
|
|
@@ -3684,7 +3840,7 @@ async function printWithIssues(list, repo) {
|
|
|
3684
3840
|
...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
|
|
3685
3841
|
...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
|
|
3686
3842
|
];
|
|
3687
|
-
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined,
|
|
3843
|
+
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process27.stdout, process27.env, "accent"), ...lines].join(`
|
|
3688
3844
|
`);
|
|
3689
3845
|
});
|
|
3690
3846
|
console.log(blocks.join(`
|
|
@@ -3944,7 +4100,7 @@ function report2(plan, added, skipped) {
|
|
|
3944
4100
|
|
|
3945
4101
|
// src/commands/release.ts
|
|
3946
4102
|
import { basename as basename3, join as join11 } from "path";
|
|
3947
|
-
import
|
|
4103
|
+
import process29 from "process";
|
|
3948
4104
|
var {$: $2 } = globalThis.Bun;
|
|
3949
4105
|
|
|
3950
4106
|
// src/commands/watch.ts
|
|
@@ -4182,12 +4338,12 @@ async function publishable() {
|
|
|
4182
4338
|
|
|
4183
4339
|
// src/commands/release-plan.ts
|
|
4184
4340
|
import { basename as basename2, join as join9, relative } from "path";
|
|
4185
|
-
import
|
|
4341
|
+
import process28 from "process";
|
|
4186
4342
|
async function planOf({ level, dir, prefix }, registry) {
|
|
4187
4343
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
4188
4344
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4189
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4190
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4345
|
+
const name = pkg?.name ?? basename2(dir ?? process28.cwd());
|
|
4346
|
+
const where = dir === undefined ? "" : ` in ${relative(process28.cwd(), dir) || "."}`;
|
|
4191
4347
|
let version;
|
|
4192
4348
|
let bump;
|
|
4193
4349
|
if (level === undefined) {
|
|
@@ -4432,7 +4588,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4432
4588
|
if (late !== undefined)
|
|
4433
4589
|
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
4590
|
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 ?
|
|
4591
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process29.stderr : process29.stdout, { json });
|
|
4436
4592
|
if (followed.code !== 0) {
|
|
4437
4593
|
report();
|
|
4438
4594
|
return followed.code;
|
|
@@ -4607,7 +4763,7 @@ async function runs(args) {
|
|
|
4607
4763
|
}
|
|
4608
4764
|
|
|
4609
4765
|
// src/cli.ts
|
|
4610
|
-
|
|
4766
|
+
process30.exitCode = await runCli({
|
|
4611
4767
|
name: "ft",
|
|
4612
4768
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4613
4769
|
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.
|
|
4
|
+
"version": "0.30.0",
|
|
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.
|
|
34
|
+
"@kaynooo/cli-kit": "0.39.0"
|
|
35
35
|
}
|
|
36
36
|
}
|