@kaynooo/cli-wait 0.12.0 → 0.12.3
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 +458 -152
- package/dist/slot-cli.js +462 -156
- package/package.json +5 -5
package/dist/slot-cli.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
|
|
2
2
|
// @bun
|
|
3
|
+
var __esm = (fn, res, err) => () => {
|
|
4
|
+
if (fn)
|
|
5
|
+
try {
|
|
6
|
+
res = fn(fn = 0);
|
|
7
|
+
} catch (e) {
|
|
8
|
+
err = [e];
|
|
9
|
+
}
|
|
10
|
+
if (err)
|
|
11
|
+
throw err[0];
|
|
12
|
+
return res;
|
|
13
|
+
};
|
|
3
14
|
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
// ../kit/src/args.ts
|
|
7
|
-
import process9 from "process";
|
|
8
|
-
import { parseArgs } from "util";
|
|
9
|
-
|
|
10
|
-
// ../kit/src/format.ts
|
|
11
|
-
import process7 from "process";
|
|
12
|
-
|
|
13
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
14
|
-
var N = new Map;
|
|
15
|
-
var Nt = /\s+\S*$/;
|
|
16
|
-
var Y = /\s/;
|
|
17
|
-
function ko(t, e, r = "...") {
|
|
15
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
|
|
16
|
+
function Ao(t, e, r = "...") {
|
|
18
17
|
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
19
18
|
if (t.length <= e)
|
|
20
19
|
return t;
|
|
@@ -25,13 +24,22 @@ function ko(t, e, r = "...") {
|
|
|
25
24
|
c = c.trimEnd();
|
|
26
25
|
return s ? (c + n).slice(0, l) : c + n;
|
|
27
26
|
}
|
|
28
|
-
var
|
|
29
|
-
var
|
|
27
|
+
var N, Nt, Y, be, W;
|
|
28
|
+
var init_chunk_rkhsft4a = __esm(() => {
|
|
29
|
+
N = new Map;
|
|
30
|
+
Nt = /\s+\S*$/;
|
|
31
|
+
Y = /\s/;
|
|
32
|
+
be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
|
|
33
|
+
W = new Map;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
|
|
37
|
+
var init_text = __esm(() => {
|
|
38
|
+
init_chunk_rkhsft4a();
|
|
39
|
+
});
|
|
30
40
|
|
|
31
41
|
// ../kit/src/mode.ts
|
|
32
42
|
import process2 from "process";
|
|
33
|
-
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
34
|
-
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
35
43
|
function isSet(value) {
|
|
36
44
|
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
37
45
|
}
|
|
@@ -45,12 +53,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
|
|
|
45
53
|
return "terminal";
|
|
46
54
|
return isSet(env.CI) ? "ci" : "pipe";
|
|
47
55
|
}
|
|
56
|
+
var MODES, AGENT_VARIABLES;
|
|
57
|
+
var init_mode = __esm(() => {
|
|
58
|
+
MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
59
|
+
AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
60
|
+
});
|
|
48
61
|
|
|
49
|
-
//
|
|
50
|
-
import process6 from "process";
|
|
51
|
-
|
|
52
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
53
|
-
var G2 = /^[a-f0-9]+$/i;
|
|
62
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
54
63
|
function b(r) {
|
|
55
64
|
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
56
65
|
if (!G2.test(e))
|
|
@@ -61,11 +70,6 @@ function b(r) {
|
|
|
61
70
|
throw Error(`Invalid hex color length: ${e.length}`);
|
|
62
71
|
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
63
72
|
}
|
|
64
|
-
var B2 = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
|
|
65
|
-
let [l, n, c] = b(r);
|
|
66
|
-
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
67
|
-
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
68
|
-
var h = new Set(["", "1", "2", "3", "true"]);
|
|
69
73
|
function C(r, e = globalThis.process?.env ?? {}) {
|
|
70
74
|
if (e.FORCE_COLOR !== undefined)
|
|
71
75
|
return h.has(e.FORCE_COLOR);
|
|
@@ -79,7 +83,7 @@ function f(r, e = []) {
|
|
|
79
83
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
80
84
|
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
81
85
|
return new Proxy(c, { get(t, i) {
|
|
82
|
-
let a =
|
|
86
|
+
let a = B[i];
|
|
83
87
|
if (Array.isArray(a)) {
|
|
84
88
|
let s = g.get(i);
|
|
85
89
|
if (s === undefined)
|
|
@@ -102,13 +106,21 @@ function f(r, e = []) {
|
|
|
102
106
|
function Fe(r = {}) {
|
|
103
107
|
return f(r);
|
|
104
108
|
}
|
|
105
|
-
var
|
|
109
|
+
var G2, B, h, o;
|
|
110
|
+
var init_chunk_x450vn3m = __esm(() => {
|
|
111
|
+
G2 = /^[a-f0-9]+$/i;
|
|
112
|
+
B = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
|
|
113
|
+
let [l, n, c] = b(r);
|
|
114
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
115
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
116
|
+
h = new Set(["", "1", "2", "3", "true"]);
|
|
117
|
+
o = Fe();
|
|
118
|
+
});
|
|
106
119
|
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
import process5 from "process";
|
|
120
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
|
|
121
|
+
var init_colors = __esm(() => {
|
|
122
|
+
init_chunk_x450vn3m();
|
|
123
|
+
});
|
|
112
124
|
|
|
113
125
|
// ../kit/src/config.ts
|
|
114
126
|
import { existsSync } from "fs";
|
|
@@ -124,6 +136,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
124
136
|
return;
|
|
125
137
|
}
|
|
126
138
|
}
|
|
139
|
+
var init_config = __esm(() => {
|
|
140
|
+
init_args();
|
|
141
|
+
});
|
|
127
142
|
|
|
128
143
|
// ../kit/src/user-config.ts
|
|
129
144
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
@@ -159,36 +174,18 @@ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
|
159
174
|
const value = readUserConfig(bin, where, legacy)[key];
|
|
160
175
|
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
161
176
|
}
|
|
177
|
+
var init_user_config = () => {};
|
|
162
178
|
|
|
163
179
|
// ../kit/src/theme.ts
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
169
|
-
bins: {},
|
|
170
|
-
gradient: ["#c084fc", "#67e8f9"]
|
|
171
|
-
};
|
|
172
|
-
var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", plan: "magentaBright", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
|
|
173
|
-
var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", plan: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
|
|
174
|
-
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
175
|
-
var PRESETS = {
|
|
176
|
-
default: {},
|
|
177
|
-
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
178
|
-
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
179
|
-
ascii: { glyphs: ASCII }
|
|
180
|
-
};
|
|
181
|
-
var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
|
|
182
|
-
var HEX = /^#[0-9a-f]{6}$/i;
|
|
183
|
-
var CONTROL = /\p{Cc}/u;
|
|
184
|
-
var MAX_FILE_BYTES = 64 * 1024;
|
|
185
|
-
var SPACES = /\s+/;
|
|
180
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
181
|
+
import { homedir as homedir2 } from "os";
|
|
182
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
183
|
+
import process5 from "process";
|
|
186
184
|
function isColorSpec(spec) {
|
|
187
185
|
if (typeof spec === "number")
|
|
188
186
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
189
187
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
190
188
|
}
|
|
191
|
-
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
192
189
|
function cubeLevel(channel) {
|
|
193
190
|
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
194
191
|
}
|
|
@@ -293,7 +290,6 @@ function applyFile(theme, file, where, warn) {
|
|
|
293
290
|
function endsWalk(home) {
|
|
294
291
|
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
295
292
|
}
|
|
296
|
-
var warned = new Set;
|
|
297
293
|
function warnOnce(message) {
|
|
298
294
|
if (warned.has(message))
|
|
299
295
|
return;
|
|
@@ -330,8 +326,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
|
|
|
330
326
|
}
|
|
331
327
|
return { theme, sources, preset };
|
|
332
328
|
}
|
|
333
|
-
var current;
|
|
334
|
-
var currentKey = "";
|
|
335
329
|
function activeTheme() {
|
|
336
330
|
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
337
331
|
if (current === undefined || key !== currentKey) {
|
|
@@ -340,9 +334,38 @@ function activeTheme() {
|
|
|
340
334
|
}
|
|
341
335
|
return current;
|
|
342
336
|
}
|
|
337
|
+
var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
|
|
338
|
+
var init_theme = __esm(() => {
|
|
339
|
+
init_config();
|
|
340
|
+
init_user_config();
|
|
341
|
+
ENDS = new Map;
|
|
342
|
+
DEFAULT = {
|
|
343
|
+
colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", plan: "magenta", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
|
|
344
|
+
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", plan: "\u25C7", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
|
|
345
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
346
|
+
bins: {},
|
|
347
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
348
|
+
};
|
|
349
|
+
BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", plan: "magentaBright", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
|
|
350
|
+
MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", plan: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
|
|
351
|
+
ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
352
|
+
PRESETS = {
|
|
353
|
+
default: {},
|
|
354
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
355
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
356
|
+
ascii: { glyphs: ASCII }
|
|
357
|
+
};
|
|
358
|
+
STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
|
|
359
|
+
HEX = /^#[0-9a-f]{6}$/i;
|
|
360
|
+
CONTROL = /\p{Cc}/u;
|
|
361
|
+
MAX_FILE_BYTES = 64 * 1024;
|
|
362
|
+
SPACES = /\s+/;
|
|
363
|
+
CUBE = [0, 95, 135, 175, 215, 255];
|
|
364
|
+
warned = new Set;
|
|
365
|
+
});
|
|
343
366
|
|
|
344
367
|
// ../kit/src/style.ts
|
|
345
|
-
|
|
368
|
+
import process6 from "process";
|
|
346
369
|
function takesControlCodes(stream, env = process6.env) {
|
|
347
370
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
348
371
|
}
|
|
@@ -361,14 +384,6 @@ function marked(mark, text, stream, detail, env = process6.env) {
|
|
|
361
384
|
function problem(text, detail) {
|
|
362
385
|
console.error(marked("problem", text, process6.stderr, detail));
|
|
363
386
|
}
|
|
364
|
-
var STATUS_WORDS = {
|
|
365
|
-
passed: ["passed", "success", "succeeded", "ok"],
|
|
366
|
-
failed: ["failed", "failure", "error", "errored"],
|
|
367
|
-
running: ["running", "in_progress", "started", "holding"],
|
|
368
|
-
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
369
|
-
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
370
|
-
};
|
|
371
|
-
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
372
387
|
function statusOf(word) {
|
|
373
388
|
return STATUS_OF.get(word.toLowerCase());
|
|
374
389
|
}
|
|
@@ -379,9 +394,24 @@ function badge(word, stream, env = process6.env) {
|
|
|
379
394
|
const { theme } = activeTheme();
|
|
380
395
|
return tinted(paint(stream, env), theme.colors[status], env)(`${theme.glyphs[status]} ${word}`);
|
|
381
396
|
}
|
|
397
|
+
var MARK_WORDS, STATUS_WORDS, STATUS_OF;
|
|
398
|
+
var init_style = __esm(() => {
|
|
399
|
+
init_colors();
|
|
400
|
+
init_mode();
|
|
401
|
+
init_theme();
|
|
402
|
+
MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
403
|
+
STATUS_WORDS = {
|
|
404
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
405
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
406
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
407
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
408
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
409
|
+
};
|
|
410
|
+
STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
411
|
+
});
|
|
382
412
|
|
|
383
413
|
// ../kit/src/format.ts
|
|
384
|
-
|
|
414
|
+
import process7 from "process";
|
|
385
415
|
function formatSeconds(total) {
|
|
386
416
|
let rest = Math.max(0, Math.round(total));
|
|
387
417
|
const amounts = UNITS.map(([unit, size]) => {
|
|
@@ -413,10 +443,8 @@ function formatAge(date, now = Date.now()) {
|
|
|
413
443
|
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
414
444
|
}
|
|
415
445
|
function truncate(text, width) {
|
|
416
|
-
return
|
|
446
|
+
return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
417
447
|
}
|
|
418
|
-
var LINE_BREAKS = /\s*\n\s*/g;
|
|
419
|
-
var ESCAPE = String.fromCharCode(27);
|
|
420
448
|
function textWidth(text) {
|
|
421
449
|
return Bun.stringWidth(text);
|
|
422
450
|
}
|
|
@@ -465,14 +493,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
|
|
|
465
493
|
function printJson(value) {
|
|
466
494
|
console.log(jsonText(value));
|
|
467
495
|
}
|
|
496
|
+
var UNITS, LINE_BREAKS, ESCAPE;
|
|
497
|
+
var init_format = __esm(() => {
|
|
498
|
+
init_text();
|
|
499
|
+
init_mode();
|
|
500
|
+
init_style();
|
|
501
|
+
UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
502
|
+
LINE_BREAKS = /\s*\n\s*/g;
|
|
503
|
+
ESCAPE = String.fromCharCode(27);
|
|
504
|
+
});
|
|
468
505
|
|
|
469
506
|
// ../kit/src/help.ts
|
|
470
507
|
import process8 from "process";
|
|
471
|
-
var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
472
|
-
var USAGE_PREFIX = /^usage:\s*/i;
|
|
473
|
-
var FULL_STOP = /\.$/;
|
|
474
508
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
475
|
-
|
|
509
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
510
|
+
`);
|
|
511
|
+
const blank = lines.indexOf("");
|
|
512
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
513
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
514
|
+
const colon = synopses[0].indexOf(": ");
|
|
515
|
+
const inline = synopses[0].slice(colon + 2);
|
|
516
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
517
|
+
if (colon !== -1)
|
|
518
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
519
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
520
|
+
`)}`;
|
|
521
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
522
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
523
|
+
return [head, ...lead, ...rest].join(`
|
|
524
|
+
`);
|
|
525
|
+
}
|
|
526
|
+
function prose(line, colors) {
|
|
527
|
+
if (colors.cyan("x") === "x")
|
|
528
|
+
return line;
|
|
529
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
476
530
|
}
|
|
477
531
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
478
532
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -507,7 +561,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
507
561
|
return [];
|
|
508
562
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
509
563
|
}
|
|
510
|
-
var MAX_INLINE_CHOICES = 24;
|
|
511
564
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
512
565
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
513
566
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
@@ -522,6 +575,15 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
522
575
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
523
576
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
524
577
|
}
|
|
578
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
579
|
+
var init_help = __esm(() => {
|
|
580
|
+
init_mode();
|
|
581
|
+
init_style();
|
|
582
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
583
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
584
|
+
FULL_STOP = /\.$/;
|
|
585
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
586
|
+
});
|
|
525
587
|
|
|
526
588
|
// ../kit/src/text.ts
|
|
527
589
|
function distance(a, b) {
|
|
@@ -549,8 +611,9 @@ function closest(name, names) {
|
|
|
549
611
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
550
612
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
551
613
|
}
|
|
614
|
+
var init_text2 = () => {};
|
|
615
|
+
|
|
552
616
|
// ../kit/src/input.ts
|
|
553
|
-
var WHOLE = /^\d+$/;
|
|
554
617
|
function wholeNumber(value, name, fallback, min = 1) {
|
|
555
618
|
if (value === undefined)
|
|
556
619
|
return fallback;
|
|
@@ -559,8 +622,6 @@ function wholeNumber(value, name, fallback, min = 1) {
|
|
|
559
622
|
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
|
|
560
623
|
return number;
|
|
561
624
|
}
|
|
562
|
-
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
563
|
-
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
564
625
|
function duration(value, name, fallback, unit = "s") {
|
|
565
626
|
if (value === undefined)
|
|
566
627
|
return fallback;
|
|
@@ -570,40 +631,27 @@ function duration(value, name, fallback, unit = "s") {
|
|
|
570
631
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
571
632
|
return ms;
|
|
572
633
|
}
|
|
634
|
+
var WHOLE, DURATION, UNIT_MS;
|
|
635
|
+
var init_input = __esm(() => {
|
|
636
|
+
init_args();
|
|
637
|
+
WHOLE = /^\d+$/;
|
|
638
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
639
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
640
|
+
});
|
|
573
641
|
|
|
574
642
|
// ../kit/src/args.ts
|
|
575
|
-
|
|
643
|
+
import process9 from "process";
|
|
644
|
+
import { parseArgs } from "util";
|
|
576
645
|
function jsonOption(holds) {
|
|
577
646
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
578
647
|
}
|
|
579
|
-
class Exit extends Error {
|
|
580
|
-
code;
|
|
581
|
-
hint;
|
|
582
|
-
constructor(message, code, hint) {
|
|
583
|
-
super(message);
|
|
584
|
-
this.code = code;
|
|
585
|
-
this.hint = hint;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
648
|
function fail(message, code = 2, hint) {
|
|
589
649
|
throw new Exit(message, code, hint);
|
|
590
650
|
}
|
|
591
|
-
|
|
592
|
-
class UsageError extends Exit {
|
|
593
|
-
constructor(message, hint) {
|
|
594
|
-
super(message, 2, hint);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
651
|
function badUsage(message) {
|
|
598
652
|
throw new UsageError(message);
|
|
599
653
|
}
|
|
600
654
|
|
|
601
|
-
class HelpShown extends Exit {
|
|
602
|
-
constructor() {
|
|
603
|
-
super("help shown", 0);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
655
|
class Completing {
|
|
608
656
|
options;
|
|
609
657
|
positionals;
|
|
@@ -614,11 +662,6 @@ class Completing {
|
|
|
614
662
|
this.candidates = candidates;
|
|
615
663
|
}
|
|
616
664
|
}
|
|
617
|
-
var completion = { active: false };
|
|
618
|
-
var OUTPUT_OPTIONS = {
|
|
619
|
-
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
620
|
-
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
621
|
-
};
|
|
622
665
|
function applyOutput(color, plain, env = process9.env) {
|
|
623
666
|
const when = plain === true ? "never" : color ?? "auto";
|
|
624
667
|
if (when === "auto")
|
|
@@ -772,7 +815,6 @@ function parseError(error) {
|
|
|
772
815
|
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
773
816
|
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
774
817
|
}
|
|
775
|
-
var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
776
818
|
function nearestOption(message, options, allowNegative) {
|
|
777
819
|
const typed = UNKNOWN_OPTION.exec(message)?.[1];
|
|
778
820
|
if (typed === undefined)
|
|
@@ -788,6 +830,61 @@ function nearestOption(message, options, allowNegative) {
|
|
|
788
830
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
789
831
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
790
832
|
}
|
|
833
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
834
|
+
var init_args = __esm(() => {
|
|
835
|
+
init_format();
|
|
836
|
+
init_help();
|
|
837
|
+
init_text2();
|
|
838
|
+
init_help();
|
|
839
|
+
init_input();
|
|
840
|
+
DASHES = /^-+/;
|
|
841
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
842
|
+
Exit = class Exit extends Error {
|
|
843
|
+
code;
|
|
844
|
+
hint;
|
|
845
|
+
[EXIT] = true;
|
|
846
|
+
constructor(message, code, hint) {
|
|
847
|
+
super(message);
|
|
848
|
+
this.code = code;
|
|
849
|
+
this.hint = hint;
|
|
850
|
+
}
|
|
851
|
+
static [Symbol.hasInstance](value) {
|
|
852
|
+
if (this !== Exit)
|
|
853
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
854
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
UsageError = class UsageError extends Exit {
|
|
858
|
+
constructor(message, hint) {
|
|
859
|
+
super(message, 2, hint);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
HelpShown = class HelpShown extends Exit {
|
|
863
|
+
constructor() {
|
|
864
|
+
super("help shown", 0);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
completion = { active: false };
|
|
868
|
+
OUTPUT_OPTIONS = {
|
|
869
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
870
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
871
|
+
};
|
|
872
|
+
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
// ../kit/src/folders.ts
|
|
876
|
+
var SKIPPED_FOLDERS;
|
|
877
|
+
var init_folders = __esm(() => {
|
|
878
|
+
init_user_config();
|
|
879
|
+
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
// src/slot-cli.ts
|
|
883
|
+
import process22 from "process";
|
|
884
|
+
|
|
885
|
+
// ../kit/src/index.ts
|
|
886
|
+
init_args();
|
|
887
|
+
|
|
791
888
|
// ../kit/src/argv.ts
|
|
792
889
|
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
793
890
|
import { resolve as resolve3 } from "path";
|
|
@@ -812,7 +909,17 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
|
|
|
812
909
|
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
813
910
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
814
911
|
}
|
|
912
|
+
// ../kit/src/chart.ts
|
|
913
|
+
init_format();
|
|
914
|
+
init_mode();
|
|
915
|
+
init_style();
|
|
916
|
+
init_theme();
|
|
917
|
+
// ../kit/src/ci.ts
|
|
918
|
+
init_args();
|
|
919
|
+
init_format();
|
|
920
|
+
|
|
815
921
|
// ../kit/src/progress.ts
|
|
922
|
+
init_format();
|
|
816
923
|
import process12 from "process";
|
|
817
924
|
|
|
818
925
|
// ../kit/src/process.ts
|
|
@@ -858,10 +965,10 @@ function holdSignals(cleanup) {
|
|
|
858
965
|
process11.on(signal, onSignal);
|
|
859
966
|
return held;
|
|
860
967
|
}
|
|
861
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
968
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
862
969
|
const chunks = [];
|
|
863
970
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
864
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
971
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
865
972
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
866
973
|
const timers = [];
|
|
867
974
|
const killGroup = (killing) => {
|
|
@@ -938,6 +1045,8 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
938
1045
|
}
|
|
939
1046
|
|
|
940
1047
|
// ../kit/src/progress.ts
|
|
1048
|
+
init_style();
|
|
1049
|
+
init_theme();
|
|
941
1050
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
942
1051
|
var FRAME_MS = 200;
|
|
943
1052
|
var CLEAR_BELOW = "\r\x1B[J";
|
|
@@ -954,10 +1063,14 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
954
1063
|
}, print: (text) => void stream.write(`${text}
|
|
955
1064
|
`), stop: () => {
|
|
956
1065
|
return;
|
|
1066
|
+
}, pause: () => () => {
|
|
1067
|
+
return;
|
|
957
1068
|
} };
|
|
958
1069
|
const write = stream.write.bind(stream);
|
|
959
1070
|
let frame = 0;
|
|
960
1071
|
let drawn = false;
|
|
1072
|
+
let paused = false;
|
|
1073
|
+
let stopped = false;
|
|
961
1074
|
const columns = () => {
|
|
962
1075
|
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
963
1076
|
return now === undefined || now === 0 ? 80 : now;
|
|
@@ -968,6 +1081,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
968
1081
|
drawn = false;
|
|
969
1082
|
};
|
|
970
1083
|
const draw = () => {
|
|
1084
|
+
if (paused)
|
|
1085
|
+
return;
|
|
971
1086
|
const width = columns() - 1;
|
|
972
1087
|
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
973
1088
|
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
@@ -979,16 +1094,17 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
979
1094
|
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
980
1095
|
drawn = true;
|
|
981
1096
|
};
|
|
982
|
-
|
|
1097
|
+
let timer = setInterval(draw, FRAME_MS);
|
|
983
1098
|
stream.on?.("resize", draw);
|
|
984
|
-
|
|
985
|
-
|
|
1099
|
+
let restore = interceptOutput(clear);
|
|
1100
|
+
let release = swallowInput();
|
|
986
1101
|
const onExit = () => {
|
|
987
1102
|
clear();
|
|
988
1103
|
release();
|
|
989
1104
|
};
|
|
990
1105
|
const signals = holdSignals(stop);
|
|
991
1106
|
function stop() {
|
|
1107
|
+
stopped = true;
|
|
992
1108
|
clearInterval(timer);
|
|
993
1109
|
stream.off?.("resize", draw);
|
|
994
1110
|
clear();
|
|
@@ -997,6 +1113,29 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
997
1113
|
process12.off("exit", onExit);
|
|
998
1114
|
signals.release();
|
|
999
1115
|
}
|
|
1116
|
+
function pause() {
|
|
1117
|
+
if (paused || stopped)
|
|
1118
|
+
return () => {
|
|
1119
|
+
return;
|
|
1120
|
+
};
|
|
1121
|
+
paused = true;
|
|
1122
|
+
clearInterval(timer);
|
|
1123
|
+
stream.off?.("resize", draw);
|
|
1124
|
+
clear();
|
|
1125
|
+
restore();
|
|
1126
|
+
release();
|
|
1127
|
+
return () => {
|
|
1128
|
+
if (!paused || stopped)
|
|
1129
|
+
return;
|
|
1130
|
+
paused = false;
|
|
1131
|
+
timer = setInterval(draw, FRAME_MS);
|
|
1132
|
+
timer.unref();
|
|
1133
|
+
stream.on?.("resize", draw);
|
|
1134
|
+
restore = interceptOutput(clear);
|
|
1135
|
+
release = swallowInput();
|
|
1136
|
+
draw();
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1000
1139
|
timer.unref();
|
|
1001
1140
|
process12.on("exit", onExit);
|
|
1002
1141
|
return {
|
|
@@ -1007,7 +1146,8 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
1007
1146
|
`);
|
|
1008
1147
|
draw();
|
|
1009
1148
|
},
|
|
1010
|
-
stop
|
|
1149
|
+
stop,
|
|
1150
|
+
pause
|
|
1011
1151
|
};
|
|
1012
1152
|
}
|
|
1013
1153
|
function cutToWidth(line, width) {
|
|
@@ -1077,52 +1217,164 @@ function interceptOutput(clear) {
|
|
|
1077
1217
|
}
|
|
1078
1218
|
};
|
|
1079
1219
|
}
|
|
1220
|
+
|
|
1221
|
+
// ../kit/src/ci.ts
|
|
1222
|
+
init_style();
|
|
1223
|
+
|
|
1224
|
+
// ../kit/src/tool.ts
|
|
1225
|
+
init_format();
|
|
1080
1226
|
// ../kit/src/cli.ts
|
|
1227
|
+
init_args();
|
|
1081
1228
|
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
1082
1229
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1083
|
-
import
|
|
1230
|
+
import process17 from "process";
|
|
1084
1231
|
|
|
1085
|
-
// ../kit/src/
|
|
1232
|
+
// ../kit/src/askpass.ts
|
|
1086
1233
|
import process13 from "process";
|
|
1234
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1235
|
+
async function askpassClient(argv) {
|
|
1236
|
+
const socketPath = process13.env[SOCKET_VARIABLE];
|
|
1237
|
+
if (socketPath === undefined)
|
|
1238
|
+
return;
|
|
1239
|
+
const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
1240
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1241
|
+
let received = "";
|
|
1242
|
+
try {
|
|
1243
|
+
await Bun.connect({
|
|
1244
|
+
unix: socketPath,
|
|
1245
|
+
socket: {
|
|
1246
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
1247
|
+
`),
|
|
1248
|
+
data: (_, chunk) => {
|
|
1249
|
+
received += chunk.toString();
|
|
1250
|
+
},
|
|
1251
|
+
close: () => resolve(received),
|
|
1252
|
+
error: () => resolve("")
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
} catch {
|
|
1256
|
+
return 1;
|
|
1257
|
+
}
|
|
1258
|
+
const reply = await promise;
|
|
1259
|
+
if (reply === "")
|
|
1260
|
+
return 1;
|
|
1261
|
+
const { answer } = JSON.parse(reply);
|
|
1262
|
+
if (request.notice === true)
|
|
1263
|
+
return 0;
|
|
1264
|
+
if (answer === undefined)
|
|
1265
|
+
return 1;
|
|
1266
|
+
process13.stdout.write(`${answer}
|
|
1267
|
+
`);
|
|
1268
|
+
return 0;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// ../kit/src/completions.ts
|
|
1272
|
+
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
1273
|
+
var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
|
|
1274
|
+
set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
|
|
1275
|
+
set -l current (commandline -ct)
|
|
1276
|
+
for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
|
|
1277
|
+
if test "$line" = __files__
|
|
1278
|
+
__fish_complete_path $current
|
|
1279
|
+
else
|
|
1280
|
+
echo $line
|
|
1281
|
+
end
|
|
1282
|
+
end
|
|
1283
|
+
end`;
|
|
1284
|
+
var BASH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1285
|
+
local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
|
|
1286
|
+
local -a lines
|
|
1287
|
+
COMPREPLY=()
|
|
1288
|
+
lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
|
|
1289
|
+
for line in "\${lines[@]}"; do
|
|
1290
|
+
if [[ $line == __files__ ]]; then
|
|
1291
|
+
COMPREPLY+=($(compgen -f -- "$cur"))
|
|
1292
|
+
else
|
|
1293
|
+
words+="\${line%%$'\\t'*}"$'\\n'
|
|
1294
|
+
fi
|
|
1295
|
+
done
|
|
1296
|
+
COMPREPLY+=($(compgen -W "$words" -- "$cur"))
|
|
1297
|
+
}`;
|
|
1298
|
+
var ZSH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1299
|
+
local line
|
|
1300
|
+
local -a described plain
|
|
1301
|
+
for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
|
|
1302
|
+
if [[ $line == __files__ ]]; then
|
|
1303
|
+
_files
|
|
1304
|
+
elif [[ $line == *$'\\t'* ]]; then
|
|
1305
|
+
described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
|
|
1306
|
+
else
|
|
1307
|
+
plain+=("$line")
|
|
1308
|
+
fi
|
|
1309
|
+
done
|
|
1310
|
+
(( \${#described} )) && _describe -V value described
|
|
1311
|
+
(( \${#plain} )) && compadd -- "\${plain[@]}"
|
|
1312
|
+
return 0
|
|
1313
|
+
}`;
|
|
1314
|
+
function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
|
|
1315
|
+
if (shell === "fish")
|
|
1316
|
+
return `${header}
|
|
1317
|
+
${FISH_FUNCTION}
|
|
1318
|
+
${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
|
|
1319
|
+
`).join("")}`;
|
|
1320
|
+
if (shell === "bash")
|
|
1321
|
+
return `${header}
|
|
1322
|
+
${BASH_FUNCTION}
|
|
1323
|
+
complete -F __kaynooo_cli_complete ${bins.join(" ")}
|
|
1324
|
+
`;
|
|
1325
|
+
return `${header}
|
|
1326
|
+
${ZSH_FUNCTION}
|
|
1327
|
+
compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
1328
|
+
`;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
// ../kit/src/notify.ts
|
|
1332
|
+
init_format();
|
|
1333
|
+
init_mode();
|
|
1334
|
+
import process14 from "process";
|
|
1087
1335
|
var NOTIFY_AFTER_MS = 1e4;
|
|
1088
1336
|
var CANCELLED = 130;
|
|
1089
1337
|
function base64(text) {
|
|
1090
1338
|
return Buffer.from(text).toString("base64");
|
|
1091
1339
|
}
|
|
1092
|
-
function notification(title, body, env =
|
|
1093
|
-
const id = `kit${
|
|
1340
|
+
function notification(title, body, env = process14.env) {
|
|
1341
|
+
const id = `kit${process14.pid}`;
|
|
1094
1342
|
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\\`];
|
|
1095
1343
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1096
1344
|
}
|
|
1097
|
-
function notifyEnd(command, code, ms, { stream =
|
|
1345
|
+
function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
|
|
1098
1346
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1099
1347
|
return;
|
|
1100
1348
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1101
1349
|
}
|
|
1102
1350
|
|
|
1351
|
+
// ../kit/src/cli.ts
|
|
1352
|
+
init_style();
|
|
1353
|
+
init_text2();
|
|
1354
|
+
|
|
1103
1355
|
// ../kit/src/usage.ts
|
|
1104
1356
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1105
1357
|
import { homedir as homedir4 } from "os";
|
|
1106
1358
|
import { dirname as dirname2, isAbsolute, join as join5 } from "path";
|
|
1107
|
-
import
|
|
1359
|
+
import process16 from "process";
|
|
1108
1360
|
|
|
1109
1361
|
// ../kit/src/logs.ts
|
|
1110
1362
|
import { lstatSync, openSync } from "fs";
|
|
1111
1363
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
1112
1364
|
import { homedir as homedir3, tmpdir } from "os";
|
|
1113
1365
|
import { join as join4 } from "path";
|
|
1114
|
-
import
|
|
1366
|
+
import process15 from "process";
|
|
1115
1367
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
1116
1368
|
var CLI_FOLDER = "kaynooo-cli";
|
|
1117
1369
|
function isPrivateDirectory(path) {
|
|
1118
1370
|
try {
|
|
1119
1371
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
1120
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
1372
|
+
return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
1121
1373
|
} catch {
|
|
1122
1374
|
return false;
|
|
1123
1375
|
}
|
|
1124
1376
|
}
|
|
1125
|
-
async function privateLogDirectory(name, env =
|
|
1377
|
+
async function privateLogDirectory(name, env = process15.env) {
|
|
1126
1378
|
const runtime = env.XDG_RUNTIME_DIR;
|
|
1127
1379
|
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
1128
1380
|
const path = join4(base, name);
|
|
@@ -1142,14 +1394,14 @@ var usageError;
|
|
|
1142
1394
|
function noteUsageError(message) {
|
|
1143
1395
|
usageError = message;
|
|
1144
1396
|
}
|
|
1145
|
-
function stateHome(env =
|
|
1397
|
+
function stateHome(env = process16.env) {
|
|
1146
1398
|
const dir = env.XDG_STATE_HOME;
|
|
1147
1399
|
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1148
1400
|
}
|
|
1149
|
-
function usagePath(env =
|
|
1401
|
+
function usagePath(env = process16.env) {
|
|
1150
1402
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1151
1403
|
}
|
|
1152
|
-
function usageRecorded(env =
|
|
1404
|
+
function usageRecorded(env = process16.env) {
|
|
1153
1405
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1154
1406
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1155
1407
|
}
|
|
@@ -1158,12 +1410,12 @@ function flagNames(argv) {
|
|
|
1158
1410
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
1159
1411
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
1160
1412
|
}
|
|
1161
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
1413
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
1162
1414
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
1163
1415
|
usageError = undefined;
|
|
1164
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1416
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
1165
1417
|
}
|
|
1166
|
-
function recordUsage(entry, env =
|
|
1418
|
+
function recordUsage(entry, env = process16.env) {
|
|
1167
1419
|
if (!usageRecorded(env))
|
|
1168
1420
|
return;
|
|
1169
1421
|
try {
|
|
@@ -1179,10 +1431,14 @@ var LEVEL_OPTIONS = {
|
|
|
1179
1431
|
...OUTPUT_OPTIONS,
|
|
1180
1432
|
help: { type: "boolean", short: "h", description: "show this help" }
|
|
1181
1433
|
};
|
|
1182
|
-
var TOP_OPTIONS = {
|
|
1434
|
+
var TOP_OPTIONS = {
|
|
1435
|
+
...LEVEL_OPTIONS,
|
|
1436
|
+
version: { type: "boolean", short: "v", description: "print the version" },
|
|
1437
|
+
completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
|
|
1438
|
+
};
|
|
1183
1439
|
function printError(prefix, message, hint, cause) {
|
|
1184
|
-
const colors = paint(
|
|
1185
|
-
const styled = takesControlCodes(
|
|
1440
|
+
const colors = paint(process17.stderr);
|
|
1441
|
+
const styled = takesControlCodes(process17.stderr);
|
|
1186
1442
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1187
1443
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1188
1444
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1259,6 +1515,19 @@ async function leafCandidates(run, words) {
|
|
|
1259
1515
|
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1260
1516
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1261
1517
|
}
|
|
1518
|
+
var COMPLETIONS = "--completions";
|
|
1519
|
+
function flagValue([flag = "", ...rest]) {
|
|
1520
|
+
return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
|
|
1521
|
+
}
|
|
1522
|
+
function printCompletionScript(name, args) {
|
|
1523
|
+
const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
|
|
1524
|
+
if (shell === undefined || args.length !== 1) {
|
|
1525
|
+
printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
|
|
1526
|
+
return 2;
|
|
1527
|
+
}
|
|
1528
|
+
console.log(completionScript(shell, [name]).trimEnd());
|
|
1529
|
+
return 0;
|
|
1530
|
+
}
|
|
1262
1531
|
async function printCandidates(found) {
|
|
1263
1532
|
for (const line of await found)
|
|
1264
1533
|
console.log(line);
|
|
@@ -1280,8 +1549,13 @@ function packageVersion(entry = Bun.main) {
|
|
|
1280
1549
|
}
|
|
1281
1550
|
}
|
|
1282
1551
|
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1552
|
+
const answered = await askpassClient(argv);
|
|
1553
|
+
if (answered !== undefined)
|
|
1554
|
+
return answered;
|
|
1283
1555
|
if (argv[0] === COMPLETE)
|
|
1284
1556
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1557
|
+
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
1558
|
+
return printCompletionScript(name, flagValue(argv));
|
|
1285
1559
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
1286
1560
|
console.log(version ?? packageVersion());
|
|
1287
1561
|
return 0;
|
|
@@ -1296,27 +1570,47 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
1296
1570
|
notifyEnd(name, code, performance.now() - started);
|
|
1297
1571
|
if (usage !== false) {
|
|
1298
1572
|
try {
|
|
1299
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
1573
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
1300
1574
|
} catch {}
|
|
1301
1575
|
}
|
|
1302
1576
|
return code;
|
|
1303
1577
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1578
|
+
|
|
1579
|
+
// ../kit/src/index.ts
|
|
1580
|
+
init_config();
|
|
1581
|
+
|
|
1582
|
+
// ../kit/src/excerpt.ts
|
|
1583
|
+
init_text2();
|
|
1584
|
+
|
|
1585
|
+
// ../kit/src/index.ts
|
|
1586
|
+
init_folders();
|
|
1587
|
+
init_format();
|
|
1588
|
+
|
|
1589
|
+
// ../kit/src/git.ts
|
|
1590
|
+
init_args();
|
|
1591
|
+
// ../kit/src/limit.ts
|
|
1592
|
+
init_args();
|
|
1593
|
+
|
|
1594
|
+
// ../kit/src/index.ts
|
|
1595
|
+
init_mode();
|
|
1596
|
+
|
|
1597
|
+
// ../kit/src/report.ts
|
|
1598
|
+
init_style();
|
|
1599
|
+
init_text2();
|
|
1306
1600
|
// ../kit/src/secrets.ts
|
|
1307
1601
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1308
1602
|
// ../kit/src/sessions.ts
|
|
1309
1603
|
import { homedir as homedir5 } from "os";
|
|
1310
1604
|
import { join as join7 } from "path";
|
|
1311
|
-
import
|
|
1605
|
+
import process18 from "process";
|
|
1312
1606
|
var {Glob } = globalThis.Bun;
|
|
1313
1607
|
var SESSION_FILES = new Glob("*.json");
|
|
1314
1608
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1315
1609
|
async function sessionDirs() {
|
|
1316
1610
|
const home = homedir5();
|
|
1317
1611
|
const dirs = new Set([join7(home, ".claude", "sessions")]);
|
|
1318
|
-
if (
|
|
1319
|
-
dirs.add(join7(
|
|
1612
|
+
if (process18.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
1613
|
+
dirs.add(join7(process18.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
1320
1614
|
try {
|
|
1321
1615
|
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join7(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
1322
1616
|
dirs.add(dir);
|
|
@@ -1362,7 +1656,7 @@ async function liveSessions() {
|
|
|
1362
1656
|
}
|
|
1363
1657
|
async function currentSession(sessions) {
|
|
1364
1658
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
1365
|
-
let pid =
|
|
1659
|
+
let pid = process18.ppid;
|
|
1366
1660
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
1367
1661
|
const session = byPid.get(pid);
|
|
1368
1662
|
if (session !== undefined)
|
|
@@ -1374,21 +1668,34 @@ async function currentSession(sessions) {
|
|
|
1374
1668
|
}
|
|
1375
1669
|
return;
|
|
1376
1670
|
}
|
|
1671
|
+
|
|
1672
|
+
// ../kit/src/index.ts
|
|
1673
|
+
init_style();
|
|
1674
|
+
init_text2();
|
|
1675
|
+
init_theme();
|
|
1676
|
+
init_user_config();
|
|
1677
|
+
|
|
1678
|
+
// ../kit/src/watch.ts
|
|
1679
|
+
init_args();
|
|
1680
|
+
init_input();
|
|
1681
|
+
init_style();
|
|
1682
|
+
// ../kit/src/workspace-root.ts
|
|
1683
|
+
init_user_config();
|
|
1377
1684
|
// src/slot.ts
|
|
1378
1685
|
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync5, rmSync } from "fs";
|
|
1379
1686
|
import { availableParallelism } from "os";
|
|
1380
1687
|
import { join as join8 } from "path";
|
|
1381
|
-
import
|
|
1688
|
+
import process21 from "process";
|
|
1382
1689
|
|
|
1383
1690
|
// src/flock.ts
|
|
1384
1691
|
import { closeSync, constants as constants2, ftruncateSync, openSync as openSync2, writeSync } from "fs";
|
|
1385
|
-
import
|
|
1692
|
+
import process20 from "process";
|
|
1386
1693
|
import { dlopen, FFIType } from "bun:ffi";
|
|
1387
1694
|
var LOCK_EX = 2;
|
|
1388
1695
|
var LOCK_NB = 4;
|
|
1389
1696
|
var flock;
|
|
1390
1697
|
function native() {
|
|
1391
|
-
flock ??= dlopen(
|
|
1698
|
+
flock ??= dlopen(process20.platform === "darwin" ? "libSystem.B.dylib" : "libc.so.6", { flock: { args: [FFIType.i32, FFIType.i32], returns: FFIType.i32 } }).symbols.flock;
|
|
1392
1699
|
return flock;
|
|
1393
1700
|
}
|
|
1394
1701
|
function tryLock(path) {
|
|
@@ -1408,10 +1715,9 @@ function writeHeld(held, text) {
|
|
|
1408
1715
|
var RUN_USAGE = `slot [options] -- <cmd>...: waits for a free machine-wide slot, then runs the command and exits with its code
|
|
1409
1716
|
slot ls [--json]: lists who holds a slot or a lock and who waits for one (slot ls --help)
|
|
1410
1717
|
|
|
1411
|
-
The slots and locks are shared by every session, worktree and shell of this user, so heavy jobs (phpunit, playwright, vue-tsc, eslint) queue instead of overloading the machine.
|
|
1412
|
-
A
|
|
1413
|
-
A
|
|
1414
|
-
A first word \`ls\` always means the listing, so run the ls command as \`slot -n 4 -- ls\` or by its path.`;
|
|
1718
|
+
The slots and locks are shared by every session, worktree and shell of this user, so heavy jobs (phpunit, playwright, vue-tsc, eslint) queue instead of overloading the machine; one is freed the moment its holder ends, SIGKILL included.
|
|
1719
|
+
A slotted command that runs slot again does not wait for a second slot, so wrapping a script and the commands inside it cannot deadlock.
|
|
1720
|
+
A first word \`ls\` always means the listing: run the ls command as \`slot -n 4 -- ls\`.`;
|
|
1415
1721
|
var RUN_EXITS = [[0, "the command did"], ["its own", "the code of a command that failed"], [2, "it timed out waiting for the slot or a usage error"], [127, "the command cannot be started"]];
|
|
1416
1722
|
var LS_USAGE = `slot ls [options]: lists the slots and locks held, with the session, the command and how long ago it started, then who waits for one
|
|
1417
1723
|
|
|
@@ -1432,7 +1738,7 @@ function defaultSlots() {
|
|
|
1432
1738
|
return Math.max(1, Math.floor(availableParallelism() / 2));
|
|
1433
1739
|
}
|
|
1434
1740
|
async function stateDir() {
|
|
1435
|
-
const dir =
|
|
1741
|
+
const dir = process21.env.SLOT_DIR ?? await privateLogDirectory("slot");
|
|
1436
1742
|
for (const sub of ["slots", "locks", "waiters"])
|
|
1437
1743
|
mkdirSync2(join8(dir, sub), { recursive: true, mode: 448 });
|
|
1438
1744
|
return dir;
|
|
@@ -1474,7 +1780,7 @@ function waitingLine(dir, wanted) {
|
|
|
1474
1780
|
}
|
|
1475
1781
|
async function holderOf(command) {
|
|
1476
1782
|
const session = await currentSession(await liveSessions());
|
|
1477
|
-
return { pid:
|
|
1783
|
+
return { pid: process21.pid, command: command.join(" "), cwd: process21.cwd(), since: Date.now(), ...session === undefined ? {} : { session: session.name } };
|
|
1478
1784
|
}
|
|
1479
1785
|
var waiterCount = 0;
|
|
1480
1786
|
async function acquire(dir, resources, holder, deadline, timeoutMs) {
|
|
@@ -1500,7 +1806,7 @@ async function acquire(dir, resources, holder, deadline, timeoutMs) {
|
|
|
1500
1806
|
held.release();
|
|
1501
1807
|
const resource = busy.kind === "lock" ? `lock ${busy.name}` : "slot";
|
|
1502
1808
|
if (waiter === undefined) {
|
|
1503
|
-
const path = join8(dir, "waiters", `${
|
|
1809
|
+
const path = join8(dir, "waiters", `${process21.pid}-${waiterCount++}`);
|
|
1504
1810
|
const held = tryLock(path);
|
|
1505
1811
|
if (held !== undefined) {
|
|
1506
1812
|
writeHeld(held, JSON.stringify({ ...holder, resource }));
|
|
@@ -1541,7 +1847,7 @@ ${RUN_USAGE}`);
|
|
|
1541
1847
|
const count = wholeNumber(values.slots, "slots", defaultSlots());
|
|
1542
1848
|
const timeoutMs = duration(values.timeout, "timeout", Number.POSITIVE_INFINITY);
|
|
1543
1849
|
const deadline = Date.now() + timeoutMs;
|
|
1544
|
-
const holding = new Set((
|
|
1850
|
+
const holding = new Set((process21.env[HOLDING] ?? "").split(",").filter((token) => token !== ""));
|
|
1545
1851
|
const wanted = [...locks.filter((name) => !holding.has(`lock:${name}`)).map((name) => ({ kind: "lock", name, count })), ...values["no-slot"] === true || holding.has("slot") ? [] : [{ kind: "slot", name: "", count }]];
|
|
1546
1852
|
const signals = holdSignals(() => {
|
|
1547
1853
|
return;
|
|
@@ -1556,7 +1862,7 @@ ${RUN_USAGE}`);
|
|
|
1556
1862
|
const tokens = new Set([...holding, ...locks.map((name) => `lock:${name}`), ...wanted.some((resource) => resource.kind === "slot") ? ["slot"] : []]);
|
|
1557
1863
|
let child;
|
|
1558
1864
|
try {
|
|
1559
|
-
child = Bun.spawn(rest, { stdio: ["inherit", "inherit", "inherit"], env: { ...
|
|
1865
|
+
child = Bun.spawn(rest, { stdio: ["inherit", "inherit", "inherit"], env: { ...process21.env, [HOLDING]: [...tokens].join(",") } });
|
|
1560
1866
|
} catch (error) {
|
|
1561
1867
|
fail(`cannot run ${rest[0]}: ${error instanceof Error ? error.message : String(error)}`, 127);
|
|
1562
1868
|
}
|
|
@@ -1599,11 +1905,11 @@ async function listSlots(args) {
|
|
|
1599
1905
|
printJson({ slots: count, busy, entries });
|
|
1600
1906
|
return 0;
|
|
1601
1907
|
}
|
|
1602
|
-
console.log(paint(
|
|
1908
|
+
console.log(paint(process21.stdout).bold(`slots: ${busy} of ${count} busy`));
|
|
1603
1909
|
if (entries.length > 0)
|
|
1604
|
-
console.log(table(entries.map((entry) => [badge(entry.state,
|
|
1910
|
+
console.log(table(entries.map((entry) => [badge(entry.state, process21.stdout), entry.resource, entry.session ?? `pid ${entry.pid}`, truncate(entry.command, COMMAND_WIDTH), entry.since === 0 ? "?" : formatAge(entry.since)])));
|
|
1605
1911
|
return 0;
|
|
1606
1912
|
}
|
|
1607
1913
|
|
|
1608
1914
|
// src/slot-cli.ts
|
|
1609
|
-
|
|
1915
|
+
process22.exitCode = await runMain({ name: "slot", run: async (args) => args[0] === "ls" ? listSlots(args.slice(1)) : runSlotted(args) });
|