@kaynooo/cli-wait 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cli.js +63 -37
- package/dist/slot-cli.js +52 -26
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,3 +55,7 @@ check --slot
|
|
|
55
55
|
- `slot ls` is the listing even as a first word, `slot -- ls` being read as `slot ls` because Bun drops a leading `--`: write `slot -n 4 -- ls` for the command.
|
|
56
56
|
- State lives in `$XDG_RUNTIME_DIR/kaynooo-cli/slot` (`~/.cache/kaynooo-cli/slot` without it), only the user can enter it; `$SLOT_DIR` points elsewhere.
|
|
57
57
|
- Exit codes: the command's, 2 on a timeout or a usage error.
|
|
58
|
+
|
|
59
|
+
## Config
|
|
60
|
+
|
|
61
|
+
`~/.config/kaynooo-cli/wait.json` (`$XDG_CONFIG_HOME/kaynooo-cli/` when set) takes positive whole numbers: `tail` (20, the lines of a file kept for a timeout excerpt), `around` (5, the lines kept on each side of a failure line) and `portTimeoutMs` (3000, how long one port probe waits).
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
|
-
import { existsSync as
|
|
5
|
+
import { existsSync as existsSync6 } from "fs";
|
|
6
6
|
import process18 from "process";
|
|
7
7
|
// ../kit/src/args.ts
|
|
8
8
|
import process9 from "process";
|
|
@@ -10,6 +10,7 @@ import { parseArgs } from "util";
|
|
|
10
10
|
|
|
11
11
|
// ../kit/src/format.ts
|
|
12
12
|
import process7 from "process";
|
|
13
|
+
|
|
13
14
|
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
14
15
|
var N = new Map;
|
|
15
16
|
var Nt = /\s+\S*$/;
|
|
@@ -27,6 +28,7 @@ function ko(t, e, r = "...") {
|
|
|
27
28
|
}
|
|
28
29
|
var 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));
|
|
29
30
|
var z = new Map;
|
|
31
|
+
|
|
30
32
|
// ../kit/src/mode.ts
|
|
31
33
|
import process2 from "process";
|
|
32
34
|
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
@@ -72,7 +74,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
|
|
|
72
74
|
return false;
|
|
73
75
|
return r?.isTTY === true;
|
|
74
76
|
}
|
|
75
|
-
function
|
|
77
|
+
function f(r, e = []) {
|
|
76
78
|
let l = "", n = "";
|
|
77
79
|
for (let t = 0, i = e.length;t < i; t++)
|
|
78
80
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
@@ -82,7 +84,7 @@ function f2(r, e = []) {
|
|
|
82
84
|
if (Array.isArray(a)) {
|
|
83
85
|
let s = g.get(i);
|
|
84
86
|
if (s === undefined)
|
|
85
|
-
s =
|
|
87
|
+
s = f(r, [...e, a]), g.set(i, s);
|
|
86
88
|
return s;
|
|
87
89
|
}
|
|
88
90
|
if (typeof a === "function")
|
|
@@ -91,20 +93,20 @@ function f2(r, e = []) {
|
|
|
91
93
|
if (u === undefined) {
|
|
92
94
|
if (g.size >= 64)
|
|
93
95
|
g.clear();
|
|
94
|
-
u =
|
|
96
|
+
u = f(r, [...e, a(...s)]), g.set(y, u);
|
|
95
97
|
}
|
|
96
98
|
return u;
|
|
97
99
|
};
|
|
98
100
|
throw Error(`Unknown style: ${String(i)}`);
|
|
99
101
|
} });
|
|
100
102
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
103
|
+
function Fe(r = {}) {
|
|
104
|
+
return f(r);
|
|
103
105
|
}
|
|
104
|
-
var
|
|
106
|
+
var o = Fe();
|
|
105
107
|
|
|
106
108
|
// ../kit/src/theme.ts
|
|
107
|
-
import { existsSync as
|
|
109
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
108
110
|
import { homedir as homedir2 } from "os";
|
|
109
111
|
import { join as join3, resolve as resolve2 } from "path";
|
|
110
112
|
import process5 from "process";
|
|
@@ -125,6 +127,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
// ../kit/src/user-config.ts
|
|
130
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
128
131
|
import { homedir } from "os";
|
|
129
132
|
import { join as join2 } from "path";
|
|
130
133
|
import process4 from "process";
|
|
@@ -135,6 +138,28 @@ function configBase(where = {}) {
|
|
|
135
138
|
function userConfigPath(bin, where = {}) {
|
|
136
139
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
137
140
|
}
|
|
141
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
142
|
+
const current = userConfigPath(bin, where);
|
|
143
|
+
if (existsSync2(current))
|
|
144
|
+
return current;
|
|
145
|
+
const base = configBase(where);
|
|
146
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
147
|
+
}
|
|
148
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
149
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
150
|
+
if (!existsSync2(path))
|
|
151
|
+
return {};
|
|
152
|
+
try {
|
|
153
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
154
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
155
|
+
} catch {
|
|
156
|
+
return {};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
160
|
+
const value = readUserConfig(bin, where, legacy)[key];
|
|
161
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
162
|
+
}
|
|
138
163
|
|
|
139
164
|
// ../kit/src/theme.ts
|
|
140
165
|
var ENDS = new Map;
|
|
@@ -201,7 +226,7 @@ function readThemeFile(path, warn) {
|
|
|
201
226
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
202
227
|
return;
|
|
203
228
|
}
|
|
204
|
-
const parsed = JSON.parse(
|
|
229
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
205
230
|
if (isRecord(parsed))
|
|
206
231
|
return parsed;
|
|
207
232
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -267,7 +292,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
267
292
|
}
|
|
268
293
|
}
|
|
269
294
|
function endsWalk(home) {
|
|
270
|
-
return (dir) => dir === resolve2(home) ||
|
|
295
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
271
296
|
}
|
|
272
297
|
var warned = new Set;
|
|
273
298
|
function warnOnce(message) {
|
|
@@ -323,7 +348,7 @@ function takesControlCodes(stream, env = process6.env) {
|
|
|
323
348
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
324
349
|
}
|
|
325
350
|
function paint(stream, env = process6.env) {
|
|
326
|
-
return
|
|
351
|
+
return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
327
352
|
}
|
|
328
353
|
function marked(mark, text, stream, detail, env = process6.env) {
|
|
329
354
|
const colors = paint(stream, env);
|
|
@@ -885,8 +910,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
885
910
|
// ../kit/src/progress.ts
|
|
886
911
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
887
912
|
var FRAME_MS = 200;
|
|
888
|
-
var
|
|
889
|
-
var LINE_UP = "\x1B[1A\x1B[2K";
|
|
913
|
+
var CLEAR_BELOW = "\r\x1B[J";
|
|
890
914
|
var ESC = String.fromCharCode(27);
|
|
891
915
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
892
916
|
var RESET_STYLE = `${ESC}[0m`;
|
|
@@ -903,13 +927,15 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
|
|
|
903
927
|
} };
|
|
904
928
|
const write = stream.write.bind(stream);
|
|
905
929
|
let frame = 0;
|
|
906
|
-
let drawn =
|
|
907
|
-
const columns = () =>
|
|
908
|
-
|
|
930
|
+
let drawn = false;
|
|
931
|
+
const columns = () => {
|
|
932
|
+
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
933
|
+
return now === undefined || now === 0 ? 80 : now;
|
|
934
|
+
};
|
|
909
935
|
const clear = () => {
|
|
910
|
-
if (drawn
|
|
911
|
-
write(
|
|
912
|
-
drawn =
|
|
936
|
+
if (drawn)
|
|
937
|
+
write(CLEAR_BELOW);
|
|
938
|
+
drawn = false;
|
|
913
939
|
};
|
|
914
940
|
const draw = () => {
|
|
915
941
|
const width = columns() - 1;
|
|
@@ -919,9 +945,9 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
|
|
|
919
945
|
clear();
|
|
920
946
|
return;
|
|
921
947
|
}
|
|
922
|
-
write(`${
|
|
923
|
-
`)}`);
|
|
924
|
-
drawn =
|
|
948
|
+
write(`${CLEAR_BELOW}${lines.join(`
|
|
949
|
+
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
950
|
+
drawn = true;
|
|
925
951
|
};
|
|
926
952
|
const timer = setInterval(draw, FRAME_MS);
|
|
927
953
|
stream.on?.("resize", draw);
|
|
@@ -1022,7 +1048,7 @@ function interceptOutput(clear) {
|
|
|
1022
1048
|
};
|
|
1023
1049
|
}
|
|
1024
1050
|
// ../kit/src/cli.ts
|
|
1025
|
-
import { readFileSync as
|
|
1051
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
1026
1052
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1027
1053
|
import process14 from "process";
|
|
1028
1054
|
|
|
@@ -1193,7 +1219,7 @@ async function printCandidates(found) {
|
|
|
1193
1219
|
function packageVersion(entry = Bun.main) {
|
|
1194
1220
|
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
1195
1221
|
try {
|
|
1196
|
-
const { version } = JSON.parse(
|
|
1222
|
+
const { version } = JSON.parse(readFileSync3(join6(dir, "package.json"), "utf8"));
|
|
1197
1223
|
if (typeof version === "string")
|
|
1198
1224
|
return version;
|
|
1199
1225
|
} catch {}
|
|
@@ -1295,13 +1321,13 @@ async function currentSession(sessions) {
|
|
|
1295
1321
|
return;
|
|
1296
1322
|
}
|
|
1297
1323
|
// src/conditions.ts
|
|
1298
|
-
import { existsSync as
|
|
1299
|
-
var TAIL = 20;
|
|
1300
|
-
var AROUND = 5;
|
|
1324
|
+
import { existsSync as existsSync4, statSync as statSync2 } from "fs";
|
|
1325
|
+
var TAIL = configuredNumber("wait", "tail", 20);
|
|
1326
|
+
var AROUND = configuredNumber("wait", "around", 5);
|
|
1301
1327
|
var CARRIAGE_RETURN = /\r$/;
|
|
1302
1328
|
var SLICE_BYTES = 1024 * 1024;
|
|
1303
1329
|
var MAX_LINE = 1e4;
|
|
1304
|
-
var PORT_TIMEOUT_MS = 3000;
|
|
1330
|
+
var PORT_TIMEOUT_MS = configuredNumber("wait", "portTimeoutMs", 3000);
|
|
1305
1331
|
|
|
1306
1332
|
class FileWatch {
|
|
1307
1333
|
path;
|
|
@@ -1327,7 +1353,7 @@ class FileWatch {
|
|
|
1327
1353
|
return this.failure !== undefined;
|
|
1328
1354
|
}
|
|
1329
1355
|
get exists() {
|
|
1330
|
-
return
|
|
1356
|
+
return existsSync4(this.path);
|
|
1331
1357
|
}
|
|
1332
1358
|
async poll() {
|
|
1333
1359
|
const events = [];
|
|
@@ -1361,7 +1387,7 @@ class FileWatch {
|
|
|
1361
1387
|
return this.recent;
|
|
1362
1388
|
}
|
|
1363
1389
|
async nextLines() {
|
|
1364
|
-
if (!
|
|
1390
|
+
if (!existsSync4(this.path))
|
|
1365
1391
|
return;
|
|
1366
1392
|
const { size, dev, ino } = statSync2(this.path);
|
|
1367
1393
|
const replaced = this.identity !== undefined && (this.identity.dev !== dev || this.identity.ino !== ino);
|
|
@@ -1419,7 +1445,7 @@ async function urlCheck(url, timeout) {
|
|
|
1419
1445
|
}
|
|
1420
1446
|
|
|
1421
1447
|
// src/task.ts
|
|
1422
|
-
import { existsSync as
|
|
1448
|
+
import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync4, statSync as statSync3 } from "fs";
|
|
1423
1449
|
import { join as join8 } from "path";
|
|
1424
1450
|
import process17 from "process";
|
|
1425
1451
|
var EXITED = /(?:^|\n)\[exited with code (-?\d+)\]\n*$/;
|
|
@@ -1437,21 +1463,21 @@ function taskFile(task, env = process17.env) {
|
|
|
1437
1463
|
if (!TASK_ID.test(task))
|
|
1438
1464
|
return;
|
|
1439
1465
|
const root = tasksRoot(env);
|
|
1440
|
-
const found =
|
|
1466
|
+
const found = existsSync5(root) ? [...new Bun.Glob(`*/*/tasks/${task}.output`).scanSync({ cwd: root, onlyFiles: false })] : [];
|
|
1441
1467
|
return found.length === 0 ? undefined : join8(root, found[0] ?? "");
|
|
1442
1468
|
}
|
|
1443
1469
|
function isTranscript(path) {
|
|
1444
|
-
return
|
|
1470
|
+
return existsSync5(path) && lstatSync2(path).isSymbolicLink() && path.endsWith(".output");
|
|
1445
1471
|
}
|
|
1446
1472
|
async function exitCode(path) {
|
|
1447
|
-
if (!
|
|
1473
|
+
if (!existsSync5(path))
|
|
1448
1474
|
return;
|
|
1449
1475
|
const size = statSync3(path).size;
|
|
1450
1476
|
const found = EXITED.exec(await Bun.file(path).slice(Math.max(0, size - TAIL_BYTES), size).text());
|
|
1451
1477
|
return found === null ? undefined : Number(found[1]);
|
|
1452
1478
|
}
|
|
1453
1479
|
async function taskEnd(path, lines) {
|
|
1454
|
-
if (!
|
|
1480
|
+
if (!existsSync5(path))
|
|
1455
1481
|
return { failures: [], tail: [] };
|
|
1456
1482
|
const text = (await Bun.file(path).text()).replace(EXITED, "");
|
|
1457
1483
|
const all = text.split(`
|
|
@@ -1472,7 +1498,7 @@ function pidAlive(pid) {
|
|
|
1472
1498
|
}
|
|
1473
1499
|
function isZombie(pid) {
|
|
1474
1500
|
try {
|
|
1475
|
-
const stat =
|
|
1501
|
+
const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
|
|
1476
1502
|
return stat.slice(stat.lastIndexOf(")") + 2, stat.lastIndexOf(")") + 3) === "Z";
|
|
1477
1503
|
} catch {
|
|
1478
1504
|
return false;
|
|
@@ -1548,7 +1574,7 @@ async function waitTask(args) {
|
|
|
1548
1574
|
const path = taskFile(task);
|
|
1549
1575
|
if (path === undefined)
|
|
1550
1576
|
fail(`no background task ${task}: give the id a background Bash call returned, or the path of its .output file`);
|
|
1551
|
-
if (!
|
|
1577
|
+
if (!existsSync6(path))
|
|
1552
1578
|
fail(`no output file ${path}: ${task} is no background task of this machine`);
|
|
1553
1579
|
if (isTranscript(path))
|
|
1554
1580
|
fail(`${task} is a subagent, whose end its notification reports: waitfor task waits on a background Bash task`);
|
package/dist/slot-cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { parseArgs } from "util";
|
|
|
9
9
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
11
|
import process7 from "process";
|
|
12
|
+
|
|
12
13
|
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
13
14
|
var N = new Map;
|
|
14
15
|
var Nt = /\s+\S*$/;
|
|
@@ -26,6 +27,7 @@ function ko(t, e, r = "...") {
|
|
|
26
27
|
}
|
|
27
28
|
var 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));
|
|
28
29
|
var z = new Map;
|
|
30
|
+
|
|
29
31
|
// ../kit/src/mode.ts
|
|
30
32
|
import process2 from "process";
|
|
31
33
|
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
@@ -71,7 +73,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
|
|
|
71
73
|
return false;
|
|
72
74
|
return r?.isTTY === true;
|
|
73
75
|
}
|
|
74
|
-
function
|
|
76
|
+
function f(r, e = []) {
|
|
75
77
|
let l = "", n = "";
|
|
76
78
|
for (let t = 0, i = e.length;t < i; t++)
|
|
77
79
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
@@ -81,7 +83,7 @@ function f2(r, e = []) {
|
|
|
81
83
|
if (Array.isArray(a)) {
|
|
82
84
|
let s = g.get(i);
|
|
83
85
|
if (s === undefined)
|
|
84
|
-
s =
|
|
86
|
+
s = f(r, [...e, a]), g.set(i, s);
|
|
85
87
|
return s;
|
|
86
88
|
}
|
|
87
89
|
if (typeof a === "function")
|
|
@@ -90,20 +92,20 @@ function f2(r, e = []) {
|
|
|
90
92
|
if (u === undefined) {
|
|
91
93
|
if (g.size >= 64)
|
|
92
94
|
g.clear();
|
|
93
|
-
u =
|
|
95
|
+
u = f(r, [...e, a(...s)]), g.set(y, u);
|
|
94
96
|
}
|
|
95
97
|
return u;
|
|
96
98
|
};
|
|
97
99
|
throw Error(`Unknown style: ${String(i)}`);
|
|
98
100
|
} });
|
|
99
101
|
}
|
|
100
|
-
function
|
|
101
|
-
return
|
|
102
|
+
function Fe(r = {}) {
|
|
103
|
+
return f(r);
|
|
102
104
|
}
|
|
103
|
-
var
|
|
105
|
+
var o = Fe();
|
|
104
106
|
|
|
105
107
|
// ../kit/src/theme.ts
|
|
106
|
-
import { existsSync as
|
|
108
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
107
109
|
import { homedir as homedir2 } from "os";
|
|
108
110
|
import { join as join3, resolve as resolve2 } from "path";
|
|
109
111
|
import process5 from "process";
|
|
@@ -124,6 +126,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// ../kit/src/user-config.ts
|
|
129
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
127
130
|
import { homedir } from "os";
|
|
128
131
|
import { join as join2 } from "path";
|
|
129
132
|
import process4 from "process";
|
|
@@ -134,6 +137,28 @@ function configBase(where = {}) {
|
|
|
134
137
|
function userConfigPath(bin, where = {}) {
|
|
135
138
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
136
139
|
}
|
|
140
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
141
|
+
const current = userConfigPath(bin, where);
|
|
142
|
+
if (existsSync2(current))
|
|
143
|
+
return current;
|
|
144
|
+
const base = configBase(where);
|
|
145
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
146
|
+
}
|
|
147
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
148
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
149
|
+
if (!existsSync2(path))
|
|
150
|
+
return {};
|
|
151
|
+
try {
|
|
152
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
153
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
154
|
+
} catch {
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
159
|
+
const value = readUserConfig(bin, where, legacy)[key];
|
|
160
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
161
|
+
}
|
|
137
162
|
|
|
138
163
|
// ../kit/src/theme.ts
|
|
139
164
|
var ENDS = new Map;
|
|
@@ -200,7 +225,7 @@ function readThemeFile(path, warn) {
|
|
|
200
225
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
201
226
|
return;
|
|
202
227
|
}
|
|
203
|
-
const parsed = JSON.parse(
|
|
228
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
204
229
|
if (isRecord(parsed))
|
|
205
230
|
return parsed;
|
|
206
231
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -266,7 +291,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
266
291
|
}
|
|
267
292
|
}
|
|
268
293
|
function endsWalk(home) {
|
|
269
|
-
return (dir) => dir === resolve2(home) ||
|
|
294
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
270
295
|
}
|
|
271
296
|
var warned = new Set;
|
|
272
297
|
function warnOnce(message) {
|
|
@@ -322,7 +347,7 @@ function takesControlCodes(stream, env = process6.env) {
|
|
|
322
347
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
323
348
|
}
|
|
324
349
|
function paint(stream, env = process6.env) {
|
|
325
|
-
return
|
|
350
|
+
return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
326
351
|
}
|
|
327
352
|
function marked(mark, text, stream, detail, env = process6.env) {
|
|
328
353
|
const colors = paint(stream, env);
|
|
@@ -884,8 +909,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
884
909
|
// ../kit/src/progress.ts
|
|
885
910
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
886
911
|
var FRAME_MS = 200;
|
|
887
|
-
var
|
|
888
|
-
var LINE_UP = "\x1B[1A\x1B[2K";
|
|
912
|
+
var CLEAR_BELOW = "\r\x1B[J";
|
|
889
913
|
var ESC = String.fromCharCode(27);
|
|
890
914
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
891
915
|
var RESET_STYLE = `${ESC}[0m`;
|
|
@@ -902,13 +926,15 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
|
|
|
902
926
|
} };
|
|
903
927
|
const write = stream.write.bind(stream);
|
|
904
928
|
let frame = 0;
|
|
905
|
-
let drawn =
|
|
906
|
-
const columns = () =>
|
|
907
|
-
|
|
929
|
+
let drawn = false;
|
|
930
|
+
const columns = () => {
|
|
931
|
+
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
932
|
+
return now === undefined || now === 0 ? 80 : now;
|
|
933
|
+
};
|
|
908
934
|
const clear = () => {
|
|
909
|
-
if (drawn
|
|
910
|
-
write(
|
|
911
|
-
drawn =
|
|
935
|
+
if (drawn)
|
|
936
|
+
write(CLEAR_BELOW);
|
|
937
|
+
drawn = false;
|
|
912
938
|
};
|
|
913
939
|
const draw = () => {
|
|
914
940
|
const width = columns() - 1;
|
|
@@ -918,9 +944,9 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
|
|
|
918
944
|
clear();
|
|
919
945
|
return;
|
|
920
946
|
}
|
|
921
|
-
write(`${
|
|
922
|
-
`)}`);
|
|
923
|
-
drawn =
|
|
947
|
+
write(`${CLEAR_BELOW}${lines.join(`
|
|
948
|
+
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
949
|
+
drawn = true;
|
|
924
950
|
};
|
|
925
951
|
const timer = setInterval(draw, FRAME_MS);
|
|
926
952
|
stream.on?.("resize", draw);
|
|
@@ -1021,7 +1047,7 @@ function interceptOutput(clear) {
|
|
|
1021
1047
|
};
|
|
1022
1048
|
}
|
|
1023
1049
|
// ../kit/src/cli.ts
|
|
1024
|
-
import { readFileSync as
|
|
1050
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
1025
1051
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1026
1052
|
import process14 from "process";
|
|
1027
1053
|
|
|
@@ -1192,7 +1218,7 @@ async function printCandidates(found) {
|
|
|
1192
1218
|
function packageVersion(entry = Bun.main) {
|
|
1193
1219
|
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
1194
1220
|
try {
|
|
1195
|
-
const { version } = JSON.parse(
|
|
1221
|
+
const { version } = JSON.parse(readFileSync3(join6(dir, "package.json"), "utf8"));
|
|
1196
1222
|
if (typeof version === "string")
|
|
1197
1223
|
return version;
|
|
1198
1224
|
} catch {}
|
|
@@ -1294,7 +1320,7 @@ async function currentSession(sessions) {
|
|
|
1294
1320
|
return;
|
|
1295
1321
|
}
|
|
1296
1322
|
// src/slot.ts
|
|
1297
|
-
import { existsSync as
|
|
1323
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync4, rmSync } from "fs";
|
|
1298
1324
|
import { availableParallelism } from "os";
|
|
1299
1325
|
import { join as join8 } from "path";
|
|
1300
1326
|
import process18 from "process";
|
|
@@ -1358,7 +1384,7 @@ async function stateDir() {
|
|
|
1358
1384
|
}
|
|
1359
1385
|
function readHolder(path) {
|
|
1360
1386
|
try {
|
|
1361
|
-
const holder = JSON.parse(
|
|
1387
|
+
const holder = JSON.parse(readFileSync4(path, "utf8"));
|
|
1362
1388
|
return typeof holder.pid === "number" && typeof holder.command === "string" ? { pid: holder.pid, command: holder.command, cwd: holder.cwd ?? "", since: holder.since ?? 0, ...holder.session === undefined ? {} : { session: holder.session }, ...holder.resource === undefined ? {} : { resource: holder.resource } } : undefined;
|
|
1363
1389
|
} catch {
|
|
1364
1390
|
return;
|
|
@@ -1491,7 +1517,7 @@ ${RUN_USAGE}`);
|
|
|
1491
1517
|
function scan(dir, state, kind) {
|
|
1492
1518
|
const folder = join8(dir, kind);
|
|
1493
1519
|
const entries = [];
|
|
1494
|
-
for (const name of
|
|
1520
|
+
for (const name of existsSync4(folder) ? readdirSync(folder) : []) {
|
|
1495
1521
|
const path = join8(folder, name);
|
|
1496
1522
|
const probe = tryLock(path);
|
|
1497
1523
|
if (probe !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-wait",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"description": "waitfor and slot: waits for a log line, a listening port or a URL answering, and queues heavy commands behind machine-wide slots and named locks, for Claude Code, instead of sleep and polling loops.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"waitfor": "$npm_execpath src/cli.ts"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@kaynooo/cli-kit": "0.
|
|
41
|
+
"@kaynooo/cli-kit": "0.37.0"
|
|
42
42
|
}
|
|
43
43
|
}
|