@kaynooo/cli-forgejo 0.16.0 → 0.18.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 +213 -109
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -2,16 +2,34 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process24 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
|
-
import
|
|
7
|
+
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
|
-
import
|
|
11
|
+
import process7 from "process";
|
|
12
|
+
|
|
13
|
+
// ../kit/src/mode.ts
|
|
14
|
+
import process2 from "process";
|
|
15
|
+
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
16
|
+
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
17
|
+
function isSet(value) {
|
|
18
|
+
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
19
|
+
}
|
|
20
|
+
function outputMode(stream = process2.stdout, env = process2.env) {
|
|
21
|
+
const chosen = env.KIT_MODE;
|
|
22
|
+
if (chosen !== undefined && MODES.has(chosen))
|
|
23
|
+
return chosen;
|
|
24
|
+
if (AGENT_VARIABLES.some((name) => isSet(env[name])))
|
|
25
|
+
return "agent";
|
|
26
|
+
if (stream.isTTY === true)
|
|
27
|
+
return "terminal";
|
|
28
|
+
return isSet(env.CI) ? "ci" : "pipe";
|
|
29
|
+
}
|
|
12
30
|
|
|
13
31
|
// ../kit/src/style.ts
|
|
14
|
-
import
|
|
32
|
+
import process6 from "process";
|
|
15
33
|
|
|
16
34
|
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
17
35
|
function x(s) {
|
|
@@ -278,13 +296,13 @@ var t = le();
|
|
|
278
296
|
import { existsSync as existsSync3, readFileSync, statSync } from "fs";
|
|
279
297
|
import { homedir as homedir2 } from "os";
|
|
280
298
|
import { join as join3, resolve as resolve2 } from "path";
|
|
281
|
-
import
|
|
299
|
+
import process5 from "process";
|
|
282
300
|
|
|
283
301
|
// ../kit/src/config.ts
|
|
284
302
|
import { existsSync } from "fs";
|
|
285
303
|
import { dirname, join, resolve } from "path";
|
|
286
|
-
import
|
|
287
|
-
function findUp(names, from =
|
|
304
|
+
import process3 from "process";
|
|
305
|
+
function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
288
306
|
const wanted = typeof names === "string" ? [names] : names;
|
|
289
307
|
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
290
308
|
const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
|
|
@@ -299,9 +317,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
|
|
|
299
317
|
import { existsSync as existsSync2 } from "fs";
|
|
300
318
|
import { homedir } from "os";
|
|
301
319
|
import { join as join2 } from "path";
|
|
302
|
-
import
|
|
320
|
+
import process4 from "process";
|
|
303
321
|
function configBase(where = {}) {
|
|
304
|
-
const xdg = where.xdg ?? (where.home === undefined ?
|
|
322
|
+
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
305
323
|
return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
|
|
306
324
|
}
|
|
307
325
|
function userConfigPath(bin, where = {}) {
|
|
@@ -341,10 +359,30 @@ function isColorSpec(spec) {
|
|
|
341
359
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
342
360
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
343
361
|
}
|
|
344
|
-
|
|
362
|
+
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
363
|
+
function cubeLevel(channel) {
|
|
364
|
+
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
365
|
+
}
|
|
366
|
+
function nearest256(hex) {
|
|
367
|
+
const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
|
|
368
|
+
const levels = rgb.map(cubeLevel);
|
|
369
|
+
const cube = levels.map((level) => CUBE[level]);
|
|
370
|
+
const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
|
|
371
|
+
const greyValue = 8 + grey * 10;
|
|
372
|
+
const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
|
|
373
|
+
return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
|
|
374
|
+
}
|
|
375
|
+
function hasTrueColor(env) {
|
|
376
|
+
return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
|
|
377
|
+
}
|
|
378
|
+
function tinted(colors, spec, env = process5.env) {
|
|
345
379
|
if (typeof spec === "number")
|
|
346
380
|
return colors.ansi256(spec);
|
|
347
|
-
return spec.trim().split(SPACES).reduce((chain, token) =>
|
|
381
|
+
return spec.trim().split(SPACES).reduce((chain, token) => {
|
|
382
|
+
if (HEX.test(token))
|
|
383
|
+
return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
|
|
384
|
+
return chain[token] ?? chain;
|
|
385
|
+
}, colors);
|
|
348
386
|
}
|
|
349
387
|
function isRecord(value) {
|
|
350
388
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -428,7 +466,7 @@ function warnOnce(message) {
|
|
|
428
466
|
function isPath(chosen) {
|
|
429
467
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
430
468
|
}
|
|
431
|
-
function loadTheme({ env =
|
|
469
|
+
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
432
470
|
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
433
471
|
const sources = [];
|
|
434
472
|
const chosen = env.KIT_THEME ?? "";
|
|
@@ -458,7 +496,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
|
|
|
458
496
|
var current;
|
|
459
497
|
var currentKey = "";
|
|
460
498
|
function activeTheme() {
|
|
461
|
-
const key = `${
|
|
499
|
+
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
462
500
|
if (current === undefined || key !== currentKey) {
|
|
463
501
|
current = loadTheme();
|
|
464
502
|
currentKey = key;
|
|
@@ -468,35 +506,35 @@ function activeTheme() {
|
|
|
468
506
|
|
|
469
507
|
// ../kit/src/style.ts
|
|
470
508
|
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
471
|
-
function takesControlCodes(stream, env =
|
|
472
|
-
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
509
|
+
function takesControlCodes(stream, env = process6.env) {
|
|
510
|
+
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
473
511
|
}
|
|
474
|
-
function paint(stream, env =
|
|
512
|
+
function paint(stream, env = process6.env) {
|
|
475
513
|
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
476
514
|
}
|
|
477
|
-
function marked(mark, text, stream, detail, env =
|
|
515
|
+
function marked(mark, text, stream, detail, env = process6.env) {
|
|
478
516
|
const colors = paint(stream, env);
|
|
479
517
|
let head = MARK_WORDS[mark];
|
|
480
518
|
if (takesControlCodes(stream, env)) {
|
|
481
519
|
const { theme } = activeTheme();
|
|
482
|
-
head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
|
|
520
|
+
head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
|
|
483
521
|
}
|
|
484
522
|
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
485
523
|
}
|
|
486
524
|
function note(text, detail) {
|
|
487
|
-
console.log(marked("note", text,
|
|
525
|
+
console.log(marked("note", text, process6.stdout, detail));
|
|
488
526
|
}
|
|
489
527
|
function warn(text, detail) {
|
|
490
|
-
console.error(marked("warn", text,
|
|
528
|
+
console.error(marked("warn", text, process6.stderr, detail));
|
|
491
529
|
}
|
|
492
|
-
function role(name, stream, env =
|
|
530
|
+
function role(name, stream, env = process6.env) {
|
|
493
531
|
const colors = paint(stream, env);
|
|
494
|
-
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
|
|
532
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
495
533
|
}
|
|
496
534
|
var STATUS_WORDS = {
|
|
497
535
|
passed: ["passed", "success", "succeeded", "ok"],
|
|
498
536
|
failed: ["failed", "failure", "error", "errored"],
|
|
499
|
-
running: ["running", "in_progress", "started"],
|
|
537
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
500
538
|
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
501
539
|
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
502
540
|
};
|
|
@@ -504,12 +542,17 @@ var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) =
|
|
|
504
542
|
function statusOf(word) {
|
|
505
543
|
return STATUS_OF.get(word.toLowerCase());
|
|
506
544
|
}
|
|
507
|
-
function badge(word, stream, env =
|
|
545
|
+
function badge(word, stream, env = process6.env) {
|
|
508
546
|
const status = statusOf(word);
|
|
509
547
|
if (status === undefined || !takesControlCodes(stream, env))
|
|
510
548
|
return word;
|
|
511
549
|
const { theme } = activeTheme();
|
|
512
|
-
return tinted(paint(stream, env), theme.colors[status])(`${theme.glyphs[status]} ${word}`);
|
|
550
|
+
return tinted(paint(stream, env), theme.colors[status], env)(`${theme.glyphs[status]} ${word}`);
|
|
551
|
+
}
|
|
552
|
+
function link(text, url, stream, env = process6.env) {
|
|
553
|
+
if (takesControlCodes(stream, env))
|
|
554
|
+
return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
|
|
555
|
+
return text === url ? text : `${text} (${url})`;
|
|
513
556
|
}
|
|
514
557
|
|
|
515
558
|
// ../kit/src/format.ts
|
|
@@ -552,8 +595,11 @@ var ESCAPE = String.fromCharCode(27);
|
|
|
552
595
|
function textWidth(text) {
|
|
553
596
|
return Bun.stringWidth(text);
|
|
554
597
|
}
|
|
555
|
-
function table(rows, { cellWidth, header = false, align = [], fit, stream =
|
|
598
|
+
function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
|
|
556
599
|
const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
|
|
600
|
+
if (outputMode(stream, env) === "agent")
|
|
601
|
+
return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
|
|
602
|
+
`);
|
|
557
603
|
const widths = [];
|
|
558
604
|
for (const row of cells) {
|
|
559
605
|
for (const [index, cell] of row.entries())
|
|
@@ -588,32 +634,35 @@ function narrow(rows, widths, limit) {
|
|
|
588
634
|
}
|
|
589
635
|
return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
|
|
590
636
|
}
|
|
637
|
+
function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
|
|
638
|
+
return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
|
|
639
|
+
}
|
|
591
640
|
function printJson(value) {
|
|
592
|
-
console.log(
|
|
641
|
+
console.log(jsonText(value));
|
|
593
642
|
}
|
|
594
643
|
|
|
595
644
|
// ../kit/src/help.ts
|
|
596
|
-
import
|
|
645
|
+
import process8 from "process";
|
|
597
646
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
598
647
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
599
648
|
var FULL_STOP = /\.$/;
|
|
600
|
-
function usageLine(usage, colors = paint(
|
|
649
|
+
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
601
650
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
602
651
|
}
|
|
603
|
-
function helpText(usage, options, colors = paint(
|
|
652
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
604
653
|
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
605
654
|
`);
|
|
606
655
|
}
|
|
607
|
-
function exitRows(exits, colors = paint(
|
|
656
|
+
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
608
657
|
if (exits.length === 0)
|
|
609
658
|
return [];
|
|
610
659
|
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
611
660
|
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
612
661
|
}
|
|
613
|
-
function replacesRows(replaces, colors = paint(
|
|
614
|
-
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
662
|
+
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
663
|
+
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
615
664
|
}
|
|
616
|
-
function wantsHelpJson(env =
|
|
665
|
+
function wantsHelpJson(env = process8.env) {
|
|
617
666
|
return env.KIT_HELP === "json";
|
|
618
667
|
}
|
|
619
668
|
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
@@ -632,12 +681,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
|
632
681
|
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
633
682
|
};
|
|
634
683
|
}
|
|
635
|
-
function exampleRows(examples, colors = paint(
|
|
636
|
-
if (examples.length === 0)
|
|
684
|
+
function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
685
|
+
if (examples.length === 0 || outputMode() === "agent")
|
|
637
686
|
return [];
|
|
638
687
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
639
688
|
}
|
|
640
|
-
function optionRows(options, colors = paint(
|
|
689
|
+
function optionRows(options, colors = paint(process8.stdout)) {
|
|
641
690
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
642
691
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
643
692
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -669,7 +718,7 @@ function closest(name, names) {
|
|
|
669
718
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
670
719
|
}
|
|
671
720
|
// ../kit/src/input.ts
|
|
672
|
-
import
|
|
721
|
+
import process9 from "process";
|
|
673
722
|
var WHOLE = /^\d+$/;
|
|
674
723
|
function wholeNumber(value, name, fallback, min = 1) {
|
|
675
724
|
if (value === undefined)
|
|
@@ -692,7 +741,7 @@ function duration(value, name, fallback, unit = "s") {
|
|
|
692
741
|
}
|
|
693
742
|
async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
694
743
|
if (path === "-") {
|
|
695
|
-
if (
|
|
744
|
+
if (process9.stdin.isTTY)
|
|
696
745
|
fail(noStdin);
|
|
697
746
|
return Bun.stdin.text();
|
|
698
747
|
}
|
|
@@ -751,7 +800,7 @@ var OUTPUT_OPTIONS = {
|
|
|
751
800
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
752
801
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
753
802
|
};
|
|
754
|
-
function applyOutput(color, plain, env =
|
|
803
|
+
function applyOutput(color, plain, env = process10.env) {
|
|
755
804
|
const when = plain === true ? "never" : color ?? "auto";
|
|
756
805
|
if (when === "auto")
|
|
757
806
|
return;
|
|
@@ -921,11 +970,11 @@ function nearestOption(message, options, allowNegative) {
|
|
|
921
970
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
922
971
|
}
|
|
923
972
|
// ../kit/src/progress.ts
|
|
924
|
-
import
|
|
973
|
+
import process12 from "process";
|
|
925
974
|
|
|
926
975
|
// ../kit/src/process.ts
|
|
927
976
|
import { constants } from "os";
|
|
928
|
-
import
|
|
977
|
+
import process11 from "process";
|
|
929
978
|
var KILL_GRACE_MS = 2000;
|
|
930
979
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
931
980
|
function exitCodeOf(code, signal) {
|
|
@@ -947,7 +996,7 @@ function holdSignals(cleanup) {
|
|
|
947
996
|
},
|
|
948
997
|
release: () => {
|
|
949
998
|
for (const signal of SIGNALS)
|
|
950
|
-
|
|
999
|
+
process11.off(signal, onSignal);
|
|
951
1000
|
}
|
|
952
1001
|
};
|
|
953
1002
|
function onSignal(signal) {
|
|
@@ -960,10 +1009,10 @@ function holdSignals(cleanup) {
|
|
|
960
1009
|
return;
|
|
961
1010
|
held.release();
|
|
962
1011
|
cleanup(signal);
|
|
963
|
-
|
|
1012
|
+
process11.kill(process11.pid, signal);
|
|
964
1013
|
}
|
|
965
1014
|
for (const signal of SIGNALS)
|
|
966
|
-
|
|
1015
|
+
process11.on(signal, onSignal);
|
|
967
1016
|
return held;
|
|
968
1017
|
}
|
|
969
1018
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -977,7 +1026,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
977
1026
|
return;
|
|
978
1027
|
try {
|
|
979
1028
|
if (grouped)
|
|
980
|
-
|
|
1029
|
+
process11.kill(-proc.pid, killing);
|
|
981
1030
|
else
|
|
982
1031
|
proc.kill(killing);
|
|
983
1032
|
} catch {}
|
|
@@ -1056,7 +1105,7 @@ var RESET_STYLE = `${ESC}[0m`;
|
|
|
1056
1105
|
var CTRL_C = 3;
|
|
1057
1106
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1058
1107
|
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
1059
|
-
function liveRegion(render, stream =
|
|
1108
|
+
function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
1060
1109
|
if (!takesControlCodes(stream, env))
|
|
1061
1110
|
return { redraw: () => {
|
|
1062
1111
|
return;
|
|
@@ -1066,25 +1115,28 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
|
|
|
1066
1115
|
} };
|
|
1067
1116
|
const write = stream.write.bind(stream);
|
|
1068
1117
|
let frame = 0;
|
|
1069
|
-
let drawn =
|
|
1118
|
+
let drawn = [];
|
|
1119
|
+
const columns = () => stream.columns === undefined || stream.columns === 0 ? 80 : stream.columns;
|
|
1120
|
+
const rowsDrawn = () => drawn.reduce((sum, width) => sum + Math.max(1, Math.ceil(width / columns())), 0);
|
|
1070
1121
|
const clear = () => {
|
|
1071
|
-
if (drawn > 0)
|
|
1072
|
-
write(`${CLEAR_LINE}${LINE_UP.repeat(
|
|
1073
|
-
drawn =
|
|
1122
|
+
if (drawn.length > 0)
|
|
1123
|
+
write(`${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}`);
|
|
1124
|
+
drawn = [];
|
|
1074
1125
|
};
|
|
1075
1126
|
const draw = () => {
|
|
1076
|
-
const width = (
|
|
1127
|
+
const width = columns() - 1;
|
|
1077
1128
|
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1078
1129
|
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
1079
1130
|
if (lines.length === 0) {
|
|
1080
1131
|
clear();
|
|
1081
1132
|
return;
|
|
1082
1133
|
}
|
|
1083
|
-
write(`${drawn > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(
|
|
1134
|
+
write(`${drawn.length > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(rowsDrawn() - 1)}` : CLEAR_LINE}${lines.join(`
|
|
1084
1135
|
`)}`);
|
|
1085
|
-
drawn = lines.
|
|
1136
|
+
drawn = lines.map((line) => Bun.stringWidth(line));
|
|
1086
1137
|
};
|
|
1087
1138
|
const timer = setInterval(draw, FRAME_MS);
|
|
1139
|
+
stream.on?.("resize", draw);
|
|
1088
1140
|
const restore = interceptOutput(clear);
|
|
1089
1141
|
const release = swallowInput();
|
|
1090
1142
|
const onExit = () => {
|
|
@@ -1094,14 +1146,15 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
|
|
|
1094
1146
|
const signals = holdSignals(stop);
|
|
1095
1147
|
function stop() {
|
|
1096
1148
|
clearInterval(timer);
|
|
1149
|
+
stream.off?.("resize", draw);
|
|
1097
1150
|
clear();
|
|
1098
1151
|
restore();
|
|
1099
1152
|
release();
|
|
1100
|
-
|
|
1153
|
+
process12.off("exit", onExit);
|
|
1101
1154
|
signals.release();
|
|
1102
1155
|
}
|
|
1103
1156
|
timer.unref();
|
|
1104
|
-
|
|
1157
|
+
process12.on("exit", onExit);
|
|
1105
1158
|
return {
|
|
1106
1159
|
redraw: draw,
|
|
1107
1160
|
print: (text) => {
|
|
@@ -1140,14 +1193,14 @@ function cutToWidth(line, width) {
|
|
|
1140
1193
|
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1141
1194
|
}
|
|
1142
1195
|
function swallowInput() {
|
|
1143
|
-
const input =
|
|
1196
|
+
const input = process12.stdin;
|
|
1144
1197
|
if (!input.isTTY)
|
|
1145
1198
|
return () => {
|
|
1146
1199
|
return;
|
|
1147
1200
|
};
|
|
1148
1201
|
const onData = (data) => {
|
|
1149
1202
|
if (data.includes(CTRL_C))
|
|
1150
|
-
|
|
1203
|
+
process12.kill(process12.pid, "SIGINT");
|
|
1151
1204
|
};
|
|
1152
1205
|
input.setRawMode(true);
|
|
1153
1206
|
input.on("data", onData);
|
|
@@ -1163,7 +1216,7 @@ function swallowInput() {
|
|
|
1163
1216
|
};
|
|
1164
1217
|
}
|
|
1165
1218
|
function interceptOutput(clear) {
|
|
1166
|
-
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [
|
|
1219
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process12.stdout, "write"], [process12.stderr, "write"]];
|
|
1167
1220
|
const wrapped = targets.map(([target, name]) => {
|
|
1168
1221
|
const original = Reflect.get(target, name);
|
|
1169
1222
|
const wrapper = (...args) => {
|
|
@@ -1182,11 +1235,11 @@ function interceptOutput(clear) {
|
|
|
1182
1235
|
}
|
|
1183
1236
|
|
|
1184
1237
|
// ../kit/src/tool.ts
|
|
1185
|
-
import
|
|
1238
|
+
import process13 from "process";
|
|
1186
1239
|
var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
|
|
1187
1240
|
function cwdGone() {
|
|
1188
1241
|
try {
|
|
1189
|
-
|
|
1242
|
+
process13.cwd();
|
|
1190
1243
|
return false;
|
|
1191
1244
|
} catch {
|
|
1192
1245
|
return true;
|
|
@@ -1213,7 +1266,7 @@ function isPermanentFailure(error) {
|
|
|
1213
1266
|
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1214
1267
|
let ran;
|
|
1215
1268
|
try {
|
|
1216
|
-
ran = await runCommand(argv, { env:
|
|
1269
|
+
ran = await runCommand(argv, { env: process13.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1217
1270
|
} catch (error) {
|
|
1218
1271
|
throw spawnFailure(label, error);
|
|
1219
1272
|
}
|
|
@@ -1300,13 +1353,13 @@ async function waitForCi(wait) {
|
|
|
1300
1353
|
// ../kit/src/cli.ts
|
|
1301
1354
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
1302
1355
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1303
|
-
import
|
|
1356
|
+
import process15 from "process";
|
|
1304
1357
|
|
|
1305
1358
|
// ../kit/src/usage.ts
|
|
1306
1359
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1307
1360
|
import { homedir as homedir3 } from "os";
|
|
1308
1361
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1309
|
-
import
|
|
1362
|
+
import process14 from "process";
|
|
1310
1363
|
|
|
1311
1364
|
// ../kit/src/logs.ts
|
|
1312
1365
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1320,14 +1373,14 @@ var usageError;
|
|
|
1320
1373
|
function noteUsageError(message) {
|
|
1321
1374
|
usageError = message;
|
|
1322
1375
|
}
|
|
1323
|
-
function stateHome(env =
|
|
1376
|
+
function stateHome(env = process14.env) {
|
|
1324
1377
|
const dir = env.XDG_STATE_HOME;
|
|
1325
1378
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1326
1379
|
}
|
|
1327
|
-
function usagePath(env =
|
|
1380
|
+
function usagePath(env = process14.env) {
|
|
1328
1381
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1329
1382
|
}
|
|
1330
|
-
function usageRecorded(env =
|
|
1383
|
+
function usageRecorded(env = process14.env) {
|
|
1331
1384
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1332
1385
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1333
1386
|
}
|
|
@@ -1341,7 +1394,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1341
1394
|
usageError = undefined;
|
|
1342
1395
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1343
1396
|
}
|
|
1344
|
-
function recordUsage(entry, env =
|
|
1397
|
+
function recordUsage(entry, env = process14.env) {
|
|
1345
1398
|
if (!usageRecorded(env))
|
|
1346
1399
|
return;
|
|
1347
1400
|
try {
|
|
@@ -1432,8 +1485,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1432
1485
|
`);
|
|
1433
1486
|
}
|
|
1434
1487
|
function printError(prefix, message, hint, cause) {
|
|
1435
|
-
const colors = paint(
|
|
1436
|
-
const styled = takesControlCodes(
|
|
1488
|
+
const colors = paint(process15.stderr);
|
|
1489
|
+
const styled = takesControlCodes(process15.stderr);
|
|
1437
1490
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1438
1491
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1439
1492
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1443,8 +1496,8 @@ function runHint(command, effect) {
|
|
|
1443
1496
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1444
1497
|
}
|
|
1445
1498
|
function printHint(hint) {
|
|
1446
|
-
const colors = paint(
|
|
1447
|
-
console.error(` ${takesControlCodes(
|
|
1499
|
+
const colors = paint(process15.stderr);
|
|
1500
|
+
console.error(` ${takesControlCodes(process15.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1448
1501
|
}
|
|
1449
1502
|
function printJsonError(message, hint, cause) {
|
|
1450
1503
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1483,11 +1536,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1483
1536
|
}
|
|
1484
1537
|
}
|
|
1485
1538
|
if (name === undefined && level.path.length > 1) {
|
|
1486
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1539
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process15.stderr));
|
|
1487
1540
|
return 2;
|
|
1488
1541
|
}
|
|
1489
1542
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1490
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1543
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process15.stdout));
|
|
1491
1544
|
return 0;
|
|
1492
1545
|
}
|
|
1493
1546
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1614,7 +1667,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1614
1667
|
return "0.0.0";
|
|
1615
1668
|
}
|
|
1616
1669
|
}
|
|
1617
|
-
async function runCli(cli, argv =
|
|
1670
|
+
async function runCli(cli, argv = process15.argv.slice(2)) {
|
|
1618
1671
|
const version = cli.version ?? packageVersion();
|
|
1619
1672
|
if (argv[0] === COMPLETE)
|
|
1620
1673
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1643,7 +1696,7 @@ function commandPath(scope, argv) {
|
|
|
1643
1696
|
}
|
|
1644
1697
|
// ../kit/src/git.ts
|
|
1645
1698
|
import { basename, dirname as dirname4 } from "path";
|
|
1646
|
-
import
|
|
1699
|
+
import process16 from "process";
|
|
1647
1700
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1648
1701
|
var GIT_NETWORK_MS = 60000;
|
|
1649
1702
|
async function git(args, timeoutMs) {
|
|
@@ -1673,7 +1726,7 @@ async function defaultBranch() {
|
|
|
1673
1726
|
async function leaveWorktree() {
|
|
1674
1727
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1675
1728
|
if (basename(common) === ".git")
|
|
1676
|
-
|
|
1729
|
+
process16.chdir(dirname4(common));
|
|
1677
1730
|
}
|
|
1678
1731
|
// ../kit/src/limit.ts
|
|
1679
1732
|
function limitOptions(fallback) {
|
|
@@ -1696,20 +1749,33 @@ function capped(rows, limit) {
|
|
|
1696
1749
|
const more = rows.length - limit;
|
|
1697
1750
|
return more > 0 ? { shown: rows.slice(0, limit), footer: moreFooter(more) } : { shown: [...rows], footer: undefined };
|
|
1698
1751
|
}
|
|
1752
|
+
// ../kit/src/pool.ts
|
|
1753
|
+
async function pool(items, limit, task) {
|
|
1754
|
+
const results = Array.from({ length: items.length });
|
|
1755
|
+
let next = 0;
|
|
1756
|
+
async function worker() {
|
|
1757
|
+
while (next < items.length) {
|
|
1758
|
+
const index = next++;
|
|
1759
|
+
results[index] = await task(items[index]);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
1763
|
+
return results;
|
|
1764
|
+
}
|
|
1699
1765
|
// ../kit/src/secrets.ts
|
|
1700
1766
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1701
1767
|
// ../kit/src/sessions.ts
|
|
1702
1768
|
import { homedir as homedir4 } from "os";
|
|
1703
1769
|
import { join as join6 } from "path";
|
|
1704
|
-
import
|
|
1770
|
+
import process17 from "process";
|
|
1705
1771
|
var {Glob } = globalThis.Bun;
|
|
1706
1772
|
var SESSION_FILES = new Glob("*.json");
|
|
1707
1773
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1708
1774
|
async function sessionDirs() {
|
|
1709
1775
|
const home = homedir4();
|
|
1710
1776
|
const dirs = new Set([join6(home, ".claude", "sessions")]);
|
|
1711
|
-
if (
|
|
1712
|
-
dirs.add(join6(
|
|
1777
|
+
if (process17.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
1778
|
+
dirs.add(join6(process17.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
1713
1779
|
try {
|
|
1714
1780
|
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
1715
1781
|
dirs.add(dir);
|
|
@@ -1755,7 +1821,7 @@ async function liveSessions() {
|
|
|
1755
1821
|
}
|
|
1756
1822
|
async function currentSession(sessions) {
|
|
1757
1823
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
1758
|
-
let pid =
|
|
1824
|
+
let pid = process17.ppid;
|
|
1759
1825
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
1760
1826
|
const session = byPid.get(pid);
|
|
1761
1827
|
if (session !== undefined)
|
|
@@ -1937,7 +2003,7 @@ function holderSession(holder, sessions) {
|
|
|
1937
2003
|
// src/forge.ts
|
|
1938
2004
|
import { homedir as homedir5 } from "os";
|
|
1939
2005
|
import { join as join7 } from "path";
|
|
1940
|
-
import
|
|
2006
|
+
import process19 from "process";
|
|
1941
2007
|
|
|
1942
2008
|
// src/remote.ts
|
|
1943
2009
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -1992,7 +2058,7 @@ function loginHosts(config) {
|
|
|
1992
2058
|
return hosts;
|
|
1993
2059
|
}
|
|
1994
2060
|
function teaConfigPath() {
|
|
1995
|
-
const base =
|
|
2061
|
+
const base = process19.env.XDG_CONFIG_HOME;
|
|
1996
2062
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
1997
2063
|
}
|
|
1998
2064
|
async function readConfig() {
|
|
@@ -2111,14 +2177,9 @@ async function commentsOf(number, repo) {
|
|
|
2111
2177
|
return repoApi(`issues/${number}/comments`, repo);
|
|
2112
2178
|
}
|
|
2113
2179
|
async function commentsOfAll(issues, repo) {
|
|
2114
|
-
const
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2117
|
-
for (let issue = queue.shift();issue !== undefined; issue = queue.shift())
|
|
2118
|
-
result.set(issue.number, await commentsOf(issue.number, repo));
|
|
2119
|
-
}
|
|
2120
|
-
await Promise.all(Array.from({ length: CONCURRENCY }, worker));
|
|
2121
|
-
return result;
|
|
2180
|
+
const commented = issues.filter((issue) => issue.comments > 0);
|
|
2181
|
+
const comments = await pool(commented, CONCURRENCY, async (issue) => commentsOf(issue.number, repo));
|
|
2182
|
+
return new Map(commented.map((issue, index) => [issue.number, comments[index]]));
|
|
2122
2183
|
}
|
|
2123
2184
|
async function editIssue(number, change, repo) {
|
|
2124
2185
|
const args = [String(number)];
|
|
@@ -2271,6 +2332,10 @@ var STATES = new Set(["available", "taken", "away"]);
|
|
|
2271
2332
|
function dimmed(text) {
|
|
2272
2333
|
return text === "" ? "" : paint(process.stdout).dim(text);
|
|
2273
2334
|
}
|
|
2335
|
+
function issueNumber2(issue) {
|
|
2336
|
+
const number = role("id", process.stdout)(`#${issue.number}`);
|
|
2337
|
+
return takesControlCodes(process.stdout) ? link(number, issue.html_url, process.stdout) : number;
|
|
2338
|
+
}
|
|
2274
2339
|
function boxesLeft(issue) {
|
|
2275
2340
|
const list = boxes(issue.body);
|
|
2276
2341
|
return list.length === 0 ? "" : `${list.filter((box) => !box.done).length}/${list.length} left`;
|
|
@@ -2278,7 +2343,7 @@ function boxesLeft(issue) {
|
|
|
2278
2343
|
function claimRow(issue, row, now) {
|
|
2279
2344
|
const holder = row.state === "taken" && row.session.name !== row.claim.holder ? `${row.claim.holder} via ${row.session.name}` : row.claim.holder;
|
|
2280
2345
|
const status = row.state === "taken" ? ` (${row.session.status})` : "";
|
|
2281
|
-
return [
|
|
2346
|
+
return [issueNumber2(issue), `${holder}${status}`, paint(process.stdout).dim(formatAge(row.claim.at, now)), boxesLeft(issue), truncate(issue.title, TITLE_WIDTH)];
|
|
2282
2347
|
}
|
|
2283
2348
|
function noteLine(comments, now) {
|
|
2284
2349
|
const note = latestNote(comments);
|
|
@@ -2297,7 +2362,7 @@ function renderBoard(rows, now = Date.now(), limit = Number.POSITIVE_INFINITY) {
|
|
|
2297
2362
|
const taken = claimed("taken");
|
|
2298
2363
|
const away = claimed("away");
|
|
2299
2364
|
const sections = [
|
|
2300
|
-
{ heading: "available", count: available.length, ...within(available, limit, ({ issue }) => [
|
|
2365
|
+
{ heading: "available", count: available.length, ...within(available, limit, ({ issue }) => [issueNumber2(issue), truncate(issue.title, TITLE_WIDTH), dimmed(issue.labels.map((label) => label.name).join(", "))]) },
|
|
2301
2366
|
{ heading: "taken", count: taken.length, ...within(taken, limit, ({ issue, row }) => claimRow(issue, row, now)) },
|
|
2302
2367
|
{ heading: "claimed, no live session here", count: away.length, ...within(away, limit, ({ issue, row }) => claimRow(issue, row, now), (line, index) => [line, ...noteLine(away[index]?.comments ?? [], now)]) }
|
|
2303
2368
|
].filter((section) => section.count > 0);
|
|
@@ -2459,34 +2524,73 @@ async function take(args) {
|
|
|
2459
2524
|
console.log(`took #${number} as ${name}: ${found.title}`);
|
|
2460
2525
|
});
|
|
2461
2526
|
}
|
|
2462
|
-
var dropUsage = `ft drop <n>...
|
|
2527
|
+
var dropUsage = `ft drop <n>... [--stale] | --all-stale [--dry-run]
|
|
2463
2528
|
|
|
2464
2529
|
Gives each issue back with a "Released by session <name>." comment, when this session holds it.
|
|
2530
|
+
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.
|
|
2465
2531
|
|
|
2466
|
-
Exits 0 when every issue is given back, 1 when one is not held by this session, 2 on a usage error.`;
|
|
2532
|
+
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.`;
|
|
2467
2533
|
var dropOptions = {
|
|
2468
2534
|
as: { type: "string", description: "the name it was taken as, instead of this session's" },
|
|
2535
|
+
stale: { type: "boolean", description: "also release a claim no live session here answers to" },
|
|
2536
|
+
"all-stale": { type: "boolean", description: "release every stale claim of the board, none needing a number" },
|
|
2537
|
+
"dry-run": { type: "boolean", description: "with --all-stale, list the claims without releasing them" },
|
|
2469
2538
|
...laneOption,
|
|
2470
2539
|
...repoOption
|
|
2471
2540
|
};
|
|
2541
|
+
async function releaseStale(number, me, author, sessions, repo) {
|
|
2542
|
+
const claim = latestClaim(await commentsOf(number, repo), author);
|
|
2543
|
+
if (claim === undefined)
|
|
2544
|
+
fail(`#${number} is not taken`, 1);
|
|
2545
|
+
const current = standing(claim, sessions);
|
|
2546
|
+
if (current.state === "taken")
|
|
2547
|
+
fail(`#${number} is taken by ${claim.holder}, which still runs (${current.session.status})`, 1);
|
|
2548
|
+
await comment(number, releasedComment(claim.holder), repo);
|
|
2549
|
+
await comment(number, `Claim of ${claim.holder} from ${formatAge(claim.at)}, which no live session answered to, released as stale by session ${me}.`, repo);
|
|
2550
|
+
console.log(`released #${number}, held by ${claim.holder}`);
|
|
2551
|
+
}
|
|
2472
2552
|
async function drop(args) {
|
|
2473
2553
|
const parsed = parse(args, dropUsage, dropOptions);
|
|
2474
2554
|
const { values, positionals } = parsed;
|
|
2475
|
-
const
|
|
2476
|
-
const nameFor = await claimant(values,
|
|
2555
|
+
const sessions = await liveSessions();
|
|
2556
|
+
const nameFor = await claimant(values, sessions);
|
|
2477
2557
|
const author = await sessionAuthor();
|
|
2558
|
+
if (values["dry-run"] === true && values["all-stale"] !== true)
|
|
2559
|
+
badUsage("--dry-run goes with --all-stale, which is the one that lists before releasing");
|
|
2560
|
+
if (values["all-stale"] === true) {
|
|
2561
|
+
if (positionals.length > 0)
|
|
2562
|
+
badUsage("--all-stale takes no issue number");
|
|
2563
|
+
const rows = await boardRows(await openIssues(undefined, values.repo), sessions, values.repo);
|
|
2564
|
+
const stale = rows.flatMap(({ issue, standing: now }) => now.state === "away" ? [{ issue, holder: now.claim.holder }] : []);
|
|
2565
|
+
if (stale.length === 0) {
|
|
2566
|
+
console.log("no stale claim");
|
|
2567
|
+
return 0;
|
|
2568
|
+
}
|
|
2569
|
+
for (const { issue, holder } of stale)
|
|
2570
|
+
console.log(`${values["dry-run"] === true ? "would release" : "releasing"} #${issue.number} held by ${holder}: ${issue.title}`);
|
|
2571
|
+
if (values["dry-run"] === true)
|
|
2572
|
+
return 0;
|
|
2573
|
+
return eachIssue("drop", stale.map(({ issue }) => issue.number), async (number) => {
|
|
2574
|
+
await releaseStale(number, nameFor(number), author, sessions, values.repo);
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2577
|
+
const numbers = issueNumbers(positionals, dropUsage);
|
|
2478
2578
|
return eachIssue("drop", numbers, async (number) => {
|
|
2479
2579
|
const name = nameFor(number);
|
|
2480
2580
|
const claim = latestClaim(await commentsOf(number, values.repo), author);
|
|
2581
|
+
if (claim !== undefined && claim.holder !== name && values.stale === true) {
|
|
2582
|
+
await releaseStale(number, name, author, sessions, values.repo);
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2481
2585
|
if (claim?.holder !== name)
|
|
2482
|
-
fail(`#${number} is ${claim === undefined ? "not taken" : `taken by ${claim.holder}, not ${name}`}`, 1);
|
|
2586
|
+
fail(`#${number} is ${claim === undefined ? "not taken" : `taken by ${claim.holder}, not ${name}`}`, 1, claim === undefined ? undefined : runHint(`ft drop ${number} --stale`, "release it if no session answers to it"));
|
|
2483
2587
|
await comment(number, releasedComment(name), values.repo);
|
|
2484
2588
|
console.log(`released #${number}`);
|
|
2485
2589
|
});
|
|
2486
2590
|
}
|
|
2487
2591
|
|
|
2488
2592
|
// src/commands/ci.ts
|
|
2489
|
-
import
|
|
2593
|
+
import process20 from "process";
|
|
2490
2594
|
|
|
2491
2595
|
// src/git.ts
|
|
2492
2596
|
async function tagsAt(commit) {
|
|
@@ -2742,7 +2846,7 @@ async function ci2(args) {
|
|
|
2742
2846
|
return;
|
|
2743
2847
|
}
|
|
2744
2848
|
const json = values.json === true;
|
|
2745
|
-
const { dim } = paint(
|
|
2849
|
+
const { dim } = paint(process20.stderr);
|
|
2746
2850
|
const runs = await waitForCi({
|
|
2747
2851
|
tool: "ft ci",
|
|
2748
2852
|
short,
|
|
@@ -2767,7 +2871,7 @@ async function ci2(args) {
|
|
|
2767
2871
|
},
|
|
2768
2872
|
lines: (spinner, found, started) => [
|
|
2769
2873
|
`${spinner} CI on ${short} ${dim(formatElapsed(Date.now() - started))}`,
|
|
2770
|
-
...(found ?? []).map((run) => ` ${badge(run.status,
|
|
2874
|
+
...(found ?? []).map((run) => ` ${badge(run.status, process20.stderr)} ${run.workflow_id} ${dim(`run ${run.id}`)}`)
|
|
2771
2875
|
]
|
|
2772
2876
|
});
|
|
2773
2877
|
const status = overall(runs);
|
|
@@ -2797,7 +2901,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
2797
2901
|
}
|
|
2798
2902
|
|
|
2799
2903
|
// src/commands/digest.ts
|
|
2800
|
-
import
|
|
2904
|
+
import process21 from "process";
|
|
2801
2905
|
var RUNS_SCANNED = 50;
|
|
2802
2906
|
var TITLE_WIDTH2 = 70;
|
|
2803
2907
|
var SHOWN = 8;
|
|
@@ -2847,7 +2951,7 @@ async function quietly(read) {
|
|
|
2847
2951
|
}
|
|
2848
2952
|
}
|
|
2849
2953
|
async function staleTodos() {
|
|
2850
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
2954
|
+
const bin = Bun.which("todo-scan", { PATH: process21.env.PATH ?? "" });
|
|
2851
2955
|
if (bin === null)
|
|
2852
2956
|
return [];
|
|
2853
2957
|
let found;
|
|
@@ -3691,7 +3795,7 @@ function report(plan, added, skipped) {
|
|
|
3691
3795
|
|
|
3692
3796
|
// src/commands/release.ts
|
|
3693
3797
|
import { basename as basename3, join as join11 } from "path";
|
|
3694
|
-
import
|
|
3798
|
+
import process23 from "process";
|
|
3695
3799
|
var {$: $2 } = globalThis.Bun;
|
|
3696
3800
|
|
|
3697
3801
|
// src/commands/watch.ts
|
|
@@ -3935,12 +4039,12 @@ async function publishable() {
|
|
|
3935
4039
|
|
|
3936
4040
|
// src/commands/release-plan.ts
|
|
3937
4041
|
import { basename as basename2, join as join9, relative } from "path";
|
|
3938
|
-
import
|
|
4042
|
+
import process22 from "process";
|
|
3939
4043
|
async function printPlan({ level, dir, prefix, branch, base, timeout, registry }) {
|
|
3940
4044
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
3941
4045
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
3942
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
3943
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4046
|
+
const name = pkg?.name ?? basename2(dir ?? process22.cwd());
|
|
4047
|
+
const where = dir === undefined ? "" : ` in ${relative(process22.cwd(), dir) || "."}`;
|
|
3944
4048
|
const sha = base.slice(0, 7);
|
|
3945
4049
|
let version;
|
|
3946
4050
|
let bump;
|
|
@@ -4199,7 +4303,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4199
4303
|
if (late !== undefined)
|
|
4200
4304
|
fail(`interrupted by ${late} after ${tag} was pushed: its runs are not waited for`, exitCodeOf(null, late));
|
|
4201
4305
|
say(`pushed ${branch} and ${tag}, waiting for their runs`);
|
|
4202
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2, json ?
|
|
4306
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2, json ? process23.stderr : process23.stdout, { json });
|
|
4203
4307
|
if (followed.code !== 0) {
|
|
4204
4308
|
outcome(false);
|
|
4205
4309
|
return followed.code;
|
|
@@ -4394,7 +4498,7 @@ async function runs(args) {
|
|
|
4394
4498
|
}
|
|
4395
4499
|
|
|
4396
4500
|
// src/cli.ts
|
|
4397
|
-
|
|
4501
|
+
process24.exitCode = await runCli({
|
|
4398
4502
|
name: "ft",
|
|
4399
4503
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4400
4504
|
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.18.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",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"ft": "$npm_execpath src/cli.ts"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@kaynooo/cli-kit": "0.
|
|
31
|
+
"@kaynooo/cli-kit": "0.23.0"
|
|
32
32
|
}
|
|
33
33
|
}
|