codeam-cli 2.0.2 → 2.1.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/CHANGELOG.md +16 -0
- package/dist/index.js +2295 -211
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -6,6 +6,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
9
16
|
var __copyProps = (to, from, except, desc) => {
|
|
10
17
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
18
|
for (let key of __getOwnPropNames(from))
|
|
@@ -23,6 +30,62 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
30
|
mod
|
|
24
31
|
));
|
|
25
32
|
|
|
33
|
+
// ../../node_modules/sisteransi/src/index.js
|
|
34
|
+
var require_src = __commonJS({
|
|
35
|
+
"../../node_modules/sisteransi/src/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
var ESC2 = "\x1B";
|
|
38
|
+
var CSI2 = `${ESC2}[`;
|
|
39
|
+
var beep = "\x07";
|
|
40
|
+
var cursor = {
|
|
41
|
+
to(x, y2) {
|
|
42
|
+
if (!y2) return `${CSI2}${x + 1}G`;
|
|
43
|
+
return `${CSI2}${y2 + 1};${x + 1}H`;
|
|
44
|
+
},
|
|
45
|
+
move(x, y2) {
|
|
46
|
+
let ret = "";
|
|
47
|
+
if (x < 0) ret += `${CSI2}${-x}D`;
|
|
48
|
+
else if (x > 0) ret += `${CSI2}${x}C`;
|
|
49
|
+
if (y2 < 0) ret += `${CSI2}${-y2}A`;
|
|
50
|
+
else if (y2 > 0) ret += `${CSI2}${y2}B`;
|
|
51
|
+
return ret;
|
|
52
|
+
},
|
|
53
|
+
up: (count = 1) => `${CSI2}${count}A`,
|
|
54
|
+
down: (count = 1) => `${CSI2}${count}B`,
|
|
55
|
+
forward: (count = 1) => `${CSI2}${count}C`,
|
|
56
|
+
backward: (count = 1) => `${CSI2}${count}D`,
|
|
57
|
+
nextLine: (count = 1) => `${CSI2}E`.repeat(count),
|
|
58
|
+
prevLine: (count = 1) => `${CSI2}F`.repeat(count),
|
|
59
|
+
left: `${CSI2}G`,
|
|
60
|
+
hide: `${CSI2}?25l`,
|
|
61
|
+
show: `${CSI2}?25h`,
|
|
62
|
+
save: `${ESC2}7`,
|
|
63
|
+
restore: `${ESC2}8`
|
|
64
|
+
};
|
|
65
|
+
var scroll = {
|
|
66
|
+
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
67
|
+
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
68
|
+
};
|
|
69
|
+
var erase = {
|
|
70
|
+
screen: `${CSI2}2J`,
|
|
71
|
+
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
72
|
+
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
73
|
+
line: `${CSI2}2K`,
|
|
74
|
+
lineEnd: `${CSI2}K`,
|
|
75
|
+
lineStart: `${CSI2}1K`,
|
|
76
|
+
lines(count) {
|
|
77
|
+
let clear = "";
|
|
78
|
+
for (let i = 0; i < count; i++)
|
|
79
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
80
|
+
if (count)
|
|
81
|
+
clear += cursor.left;
|
|
82
|
+
return clear;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
module2.exports = { cursor, scroll, erase, beep };
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
26
89
|
// src/commands/start.ts
|
|
27
90
|
var fs5 = __toESM(require("fs"));
|
|
28
91
|
var os5 = __toESM(require("os"));
|
|
@@ -56,45 +119,45 @@ function makeConfig(baseDir) {
|
|
|
56
119
|
return EMPTY_CONFIG();
|
|
57
120
|
}
|
|
58
121
|
}
|
|
59
|
-
function save(
|
|
122
|
+
function save(c2) {
|
|
60
123
|
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
61
|
-
fs.writeFileSync(file, JSON.stringify(
|
|
124
|
+
fs.writeFileSync(file, JSON.stringify(c2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
62
125
|
}
|
|
63
126
|
function getConfig2() {
|
|
64
127
|
return load();
|
|
65
128
|
}
|
|
66
129
|
function ensurePluginId2() {
|
|
67
|
-
const
|
|
68
|
-
save(
|
|
69
|
-
return
|
|
130
|
+
const c2 = load();
|
|
131
|
+
save(c2);
|
|
132
|
+
return c2.pluginId;
|
|
70
133
|
}
|
|
71
134
|
function addSession2(session) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
save(
|
|
135
|
+
const c2 = load();
|
|
136
|
+
c2.sessions = c2.sessions.filter((s) => s.id !== session.id);
|
|
137
|
+
c2.sessions.unshift(session);
|
|
138
|
+
c2.activeSessionId = session.id;
|
|
139
|
+
save(c2);
|
|
77
140
|
}
|
|
78
141
|
function removeSession2(sessionId) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
142
|
+
const c2 = load();
|
|
143
|
+
c2.sessions = c2.sessions.filter((s) => s.id !== sessionId);
|
|
144
|
+
if (c2.activeSessionId === sessionId) {
|
|
145
|
+
c2.activeSessionId = c2.sessions[0]?.id ?? null;
|
|
83
146
|
}
|
|
84
|
-
save(
|
|
147
|
+
save(c2);
|
|
85
148
|
}
|
|
86
149
|
function setActiveSession2(sessionId) {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
save(
|
|
150
|
+
const c2 = load();
|
|
151
|
+
c2.activeSessionId = sessionId;
|
|
152
|
+
save(c2);
|
|
90
153
|
}
|
|
91
154
|
function getActiveSession2() {
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
94
|
-
const session =
|
|
155
|
+
const c2 = load();
|
|
156
|
+
if (!c2.activeSessionId) return null;
|
|
157
|
+
const session = c2.sessions.find((s) => s.id === c2.activeSessionId) ?? null;
|
|
95
158
|
if (!session) {
|
|
96
|
-
|
|
97
|
-
save(
|
|
159
|
+
c2.activeSessionId = null;
|
|
160
|
+
save(c2);
|
|
98
161
|
}
|
|
99
162
|
return session;
|
|
100
163
|
}
|
|
@@ -116,7 +179,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
|
|
|
116
179
|
// package.json
|
|
117
180
|
var package_default = {
|
|
118
181
|
name: "codeam-cli",
|
|
119
|
-
version: "2.0
|
|
182
|
+
version: "2.1.0",
|
|
120
183
|
description: "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands \u2014 from anywhere.",
|
|
121
184
|
main: "dist/index.js",
|
|
122
185
|
bin: {
|
|
@@ -184,10 +247,11 @@ var package_default = {
|
|
|
184
247
|
node: ">=18.0.0"
|
|
185
248
|
},
|
|
186
249
|
dependencies: {
|
|
187
|
-
"@clack/prompts": "^
|
|
250
|
+
"@clack/prompts": "^1.2.0",
|
|
188
251
|
picocolors: "^1.1.0",
|
|
189
252
|
"qrcode-terminal": "^0.12.0",
|
|
190
|
-
ws: "^8.18.0"
|
|
253
|
+
ws: "^8.18.0",
|
|
254
|
+
zod: "^3.22.4"
|
|
191
255
|
},
|
|
192
256
|
devDependencies: {
|
|
193
257
|
"@codeagent/shared": "*",
|
|
@@ -196,7 +260,7 @@ var package_default = {
|
|
|
196
260
|
"@types/ws": "^8.5.0",
|
|
197
261
|
tsup: "^8.0.0",
|
|
198
262
|
typescript: "^5.0.0",
|
|
199
|
-
vitest: "^2.
|
|
263
|
+
vitest: "^3.2.4"
|
|
200
264
|
}
|
|
201
265
|
};
|
|
202
266
|
|
|
@@ -266,7 +330,7 @@ var WebSocketService = class {
|
|
|
266
330
|
this.reconnectAttempts = 0;
|
|
267
331
|
this.client.send(JSON.stringify({
|
|
268
332
|
type: "auth",
|
|
269
|
-
payload: {
|
|
333
|
+
payload: { sessionId: this.sessionId, pluginId: this.pluginId },
|
|
270
334
|
timestamp: Date.now()
|
|
271
335
|
}));
|
|
272
336
|
this.startHeartbeat();
|
|
@@ -329,6 +393,16 @@ var WebSocketService = class {
|
|
|
329
393
|
var https = __toESM(require("https"));
|
|
330
394
|
var http = __toESM(require("http"));
|
|
331
395
|
var os2 = __toESM(require("os"));
|
|
396
|
+
|
|
397
|
+
// src/lib/poll-delay.ts
|
|
398
|
+
var MAX_DELAY_MS = 3e4;
|
|
399
|
+
function computePollDelay({ baseMs, failures }) {
|
|
400
|
+
const exp = Math.min(MAX_DELAY_MS, baseMs * Math.pow(2, failures));
|
|
401
|
+
const jitter = exp * (0.9 + Math.random() * 0.2);
|
|
402
|
+
return Math.round(jitter);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/services/pairing.service.ts
|
|
332
406
|
var API_BASE2 = process.env.CODEAM_API_URL ?? "https://codeagent-mobile-api.vercel.app";
|
|
333
407
|
async function requestCode(pluginId) {
|
|
334
408
|
try {
|
|
@@ -347,33 +421,52 @@ async function requestCode(pluginId) {
|
|
|
347
421
|
}
|
|
348
422
|
function pollStatus(pluginId, onPaired, onTimeout) {
|
|
349
423
|
let stopped = false;
|
|
350
|
-
|
|
424
|
+
let pollTimer = null;
|
|
425
|
+
let consecutiveFailures = 0;
|
|
426
|
+
const tick = async () => {
|
|
351
427
|
if (stopped) return;
|
|
352
428
|
try {
|
|
353
429
|
const result = await _transport.getJson(
|
|
354
430
|
`${API_BASE2}/api/pairing/status?pluginId=${pluginId}`
|
|
355
431
|
);
|
|
432
|
+
consecutiveFailures = 0;
|
|
356
433
|
const data = result?.data;
|
|
357
434
|
if (data?.paired) {
|
|
358
435
|
stop();
|
|
359
436
|
const user = data.user ?? {};
|
|
437
|
+
const rawToken = data.pluginAuthToken;
|
|
360
438
|
onPaired({
|
|
361
439
|
sessionId: data.sessionId,
|
|
362
440
|
userName: user.name || "",
|
|
363
441
|
userEmail: user.email || "",
|
|
364
|
-
plan: user.plan || "FREE"
|
|
442
|
+
plan: user.plan || "FREE",
|
|
443
|
+
pluginAuthToken: typeof rawToken === "string" && rawToken.length > 0 ? rawToken : void 0
|
|
365
444
|
});
|
|
445
|
+
return;
|
|
366
446
|
}
|
|
367
447
|
} catch {
|
|
448
|
+
consecutiveFailures += 1;
|
|
368
449
|
}
|
|
369
|
-
|
|
450
|
+
if (stopped) return;
|
|
451
|
+
const delay = computePollDelay({ baseMs: 3e3, failures: consecutiveFailures });
|
|
452
|
+
pollTimer = setTimeout(() => {
|
|
453
|
+
void tick();
|
|
454
|
+
}, delay);
|
|
455
|
+
};
|
|
456
|
+
const initialDelay = computePollDelay({ baseMs: 3e3, failures: 0 });
|
|
457
|
+
pollTimer = setTimeout(() => {
|
|
458
|
+
void tick();
|
|
459
|
+
}, initialDelay);
|
|
370
460
|
const timeout = setTimeout(() => {
|
|
371
461
|
stop();
|
|
372
462
|
onTimeout();
|
|
373
463
|
}, 3e5);
|
|
374
464
|
function stop() {
|
|
375
465
|
stopped = true;
|
|
376
|
-
|
|
466
|
+
if (pollTimer) {
|
|
467
|
+
clearTimeout(pollTimer);
|
|
468
|
+
pollTimer = null;
|
|
469
|
+
}
|
|
377
470
|
clearTimeout(timeout);
|
|
378
471
|
}
|
|
379
472
|
return stop;
|
|
@@ -385,13 +478,13 @@ var _transport = {
|
|
|
385
478
|
async function _postJson(url, body) {
|
|
386
479
|
return new Promise((resolve, reject) => {
|
|
387
480
|
const data = JSON.stringify(body);
|
|
388
|
-
const
|
|
389
|
-
const transport =
|
|
481
|
+
const u2 = new URL(url);
|
|
482
|
+
const transport = u2.protocol === "https:" ? https : http;
|
|
390
483
|
const req = transport.request(
|
|
391
484
|
{
|
|
392
|
-
hostname:
|
|
393
|
-
port:
|
|
394
|
-
path:
|
|
485
|
+
hostname: u2.hostname,
|
|
486
|
+
port: u2.port || (u2.protocol === "https:" ? 443 : 80),
|
|
487
|
+
path: u2.pathname + u2.search,
|
|
395
488
|
method: "POST",
|
|
396
489
|
headers: {
|
|
397
490
|
"Content-Type": "application/json",
|
|
@@ -429,13 +522,13 @@ async function _postJson(url, body) {
|
|
|
429
522
|
}
|
|
430
523
|
async function _getJson(url) {
|
|
431
524
|
return new Promise((resolve, reject) => {
|
|
432
|
-
const
|
|
433
|
-
const transport =
|
|
525
|
+
const u2 = new URL(url);
|
|
526
|
+
const transport = u2.protocol === "https:" ? https : http;
|
|
434
527
|
const req = transport.request(
|
|
435
528
|
{
|
|
436
|
-
hostname:
|
|
437
|
-
port:
|
|
438
|
-
path:
|
|
529
|
+
hostname: u2.hostname,
|
|
530
|
+
port: u2.port || (u2.protocol === "https:" ? 443 : 80),
|
|
531
|
+
path: u2.pathname + u2.search,
|
|
439
532
|
method: "GET",
|
|
440
533
|
timeout: 1e4
|
|
441
534
|
},
|
|
@@ -479,6 +572,7 @@ var CommandRelayService = class {
|
|
|
479
572
|
_running = false;
|
|
480
573
|
pollTimer = null;
|
|
481
574
|
heartbeatTimer = null;
|
|
575
|
+
consecutiveFailures = 0;
|
|
482
576
|
start() {
|
|
483
577
|
if (this.pollTimer) {
|
|
484
578
|
clearTimeout(this.pollTimer);
|
|
@@ -515,7 +609,11 @@ var CommandRelayService = class {
|
|
|
515
609
|
if (!this._running) return;
|
|
516
610
|
await this.poll();
|
|
517
611
|
if (this._running) {
|
|
518
|
-
|
|
612
|
+
const delay = computePollDelay({
|
|
613
|
+
baseMs: 2e3,
|
|
614
|
+
failures: this.consecutiveFailures
|
|
615
|
+
});
|
|
616
|
+
this.pollTimer = setTimeout(() => this.pollLoop(), delay);
|
|
519
617
|
}
|
|
520
618
|
}
|
|
521
619
|
async poll() {
|
|
@@ -524,6 +622,7 @@ var CommandRelayService = class {
|
|
|
524
622
|
`${API_BASE3}/api/commands/pending?pluginId=${this.pluginId}`
|
|
525
623
|
);
|
|
526
624
|
const commands = data?.data;
|
|
625
|
+
this.consecutiveFailures = 0;
|
|
527
626
|
if (!Array.isArray(commands)) return;
|
|
528
627
|
for (const obj of commands) {
|
|
529
628
|
try {
|
|
@@ -537,6 +636,7 @@ var CommandRelayService = class {
|
|
|
537
636
|
}
|
|
538
637
|
}
|
|
539
638
|
} catch {
|
|
639
|
+
this.consecutiveFailures += 1;
|
|
540
640
|
}
|
|
541
641
|
}
|
|
542
642
|
async sendHeartbeat(online) {
|
|
@@ -647,13 +747,11 @@ var UnixPtyStrategy = class {
|
|
|
647
747
|
this.spawnDirect(cmd, cwd, args2);
|
|
648
748
|
return;
|
|
649
749
|
}
|
|
650
|
-
const shell = process.env.SHELL || "/bin/sh";
|
|
651
750
|
const cols = process.stdout.columns || 220;
|
|
652
751
|
const rows = process.stdout.rows || 50;
|
|
653
752
|
this.helperPath = path3.join(os3.tmpdir(), "codeam-pty-helper.py");
|
|
654
753
|
fs3.writeFileSync(this.helperPath, PYTHON_PTY_HELPER, { mode: 420 });
|
|
655
|
-
|
|
656
|
-
this.proc = (0, import_child_process.spawn)(python, [this.helperPath, shell, "-c", `exec ${fullCmd}`], {
|
|
754
|
+
this.proc = (0, import_child_process.spawn)(python, [this.helperPath, cmd, ...args2], {
|
|
657
755
|
stdio: ["pipe", "pipe", "inherit"],
|
|
658
756
|
cwd,
|
|
659
757
|
env: {
|
|
@@ -661,7 +759,8 @@ var UnixPtyStrategy = class {
|
|
|
661
759
|
TERM: "xterm-256color",
|
|
662
760
|
COLUMNS: String(cols),
|
|
663
761
|
LINES: String(rows)
|
|
664
|
-
}
|
|
762
|
+
},
|
|
763
|
+
shell: false
|
|
665
764
|
});
|
|
666
765
|
this.proc.on("error", (err) => {
|
|
667
766
|
console.error(
|
|
@@ -685,17 +784,43 @@ var UnixPtyStrategy = class {
|
|
|
685
784
|
this.dispose();
|
|
686
785
|
this.opts.onExit(code ?? 0);
|
|
687
786
|
});
|
|
787
|
+
this.installSignalHandlers();
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Install once-fired SIGINT/SIGTERM handlers that kill the child PTY helper
|
|
791
|
+
* (and via it the Claude process group) before this Node process exits.
|
|
792
|
+
*
|
|
793
|
+
* Without this, Ctrl+C tears down Node but the Python helper / Claude can
|
|
794
|
+
* be left as a zombie or orphaned process. Exit codes follow the standard
|
|
795
|
+
* 128 + signal-number convention (130 for SIGINT, 143 for SIGTERM).
|
|
796
|
+
*
|
|
797
|
+
* No-op if the child has already exited (`proc.killed === true`) so we
|
|
798
|
+
* don't double-signal a dead process.
|
|
799
|
+
*/
|
|
800
|
+
installSignalHandlers() {
|
|
801
|
+
const handler = (signal) => {
|
|
802
|
+
if (this.proc && !this.proc.killed) {
|
|
803
|
+
this.proc.kill("SIGTERM");
|
|
804
|
+
}
|
|
805
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
806
|
+
};
|
|
807
|
+
process.once("SIGINT", () => handler("SIGINT"));
|
|
808
|
+
process.once("SIGTERM", () => handler("SIGTERM"));
|
|
688
809
|
}
|
|
689
810
|
/**
|
|
690
811
|
* Python-unavailable fallback: direct spawn without PTY.
|
|
691
812
|
* Mobile command injection is limited (no real TTY for Claude).
|
|
813
|
+
*
|
|
814
|
+
* `shell: false` so args are passed as discrete argv elements — shell
|
|
815
|
+
* metacharacters in user-supplied args (e.g. session ids on `--resume`)
|
|
816
|
+
* are NOT interpreted by /bin/sh.
|
|
692
817
|
*/
|
|
693
818
|
spawnDirect(cmd, cwd, args2 = []) {
|
|
694
819
|
this.proc = (0, import_child_process.spawn)(cmd, args2, {
|
|
695
820
|
stdio: ["pipe", "inherit", "inherit"],
|
|
696
821
|
cwd,
|
|
697
822
|
env: process.env,
|
|
698
|
-
shell:
|
|
823
|
+
shell: false
|
|
699
824
|
});
|
|
700
825
|
this.proc.on("error", (err) => {
|
|
701
826
|
console.error(
|
|
@@ -715,6 +840,7 @@ var UnixPtyStrategy = class {
|
|
|
715
840
|
this.dispose();
|
|
716
841
|
this.opts.onExit(code ?? 0);
|
|
717
842
|
});
|
|
843
|
+
this.installSignalHandlers();
|
|
718
844
|
}
|
|
719
845
|
write(data) {
|
|
720
846
|
this.proc?.stdin?.write(data);
|
|
@@ -935,55 +1061,55 @@ var BULLET_TOOL_RE = /^•\s+(?:Read(?:ing)?|Edit(?:ing)?|Writ(?:e|ing)|Bash|Run
|
|
|
935
1061
|
var TREE_LINE_RE = /^└\s/;
|
|
936
1062
|
var STATUS_LINE_RE = /^\+\s/;
|
|
937
1063
|
function isChromeLine(line) {
|
|
938
|
-
const
|
|
939
|
-
if (!
|
|
940
|
-
if (/^[─━—═─\-]{3,}$/.test(
|
|
941
|
-
if (SPINNER_RE.test(
|
|
942
|
-
if (BULLET_TOOL_RE.test(
|
|
943
|
-
if (TREE_LINE_RE.test(
|
|
944
|
-
if (STATUS_LINE_RE.test(
|
|
945
|
-
if (/^↓\s*\d+\s*tokens/i.test(
|
|
946
|
-
if (/^\bthought\s+for\s+\d+/i.test(
|
|
947
|
-
if (/esc.{0,5}to.{0,5}interrupt/i.test(
|
|
948
|
-
if (/high\s*[·•]\s*\/effort/i.test(
|
|
949
|
-
if (/^[❯>]\s*$/.test(
|
|
950
|
-
if (/^\(thinking\)\s*$/.test(
|
|
951
|
-
if (/^\?\s.*shortcut/i.test(
|
|
952
|
-
if (/spending limit|usage limit/i.test(
|
|
953
|
-
if (/↑\s*\/?\s*↓\s*to\s*navigate/i.test(
|
|
954
|
-
if (
|
|
955
|
-
if ((
|
|
956
|
-
if (/ctrl\+?o\s+to\s+expand/i.test(
|
|
957
|
-
const hasBoxPrefix = /^[│╭╰╮╯┌└┐┘├┤┬┴┼]/.test(
|
|
958
|
-
const stripped =
|
|
1064
|
+
const t2 = line.trim();
|
|
1065
|
+
if (!t2) return false;
|
|
1066
|
+
if (/^[─━—═─\-]{3,}$/.test(t2)) return true;
|
|
1067
|
+
if (SPINNER_RE.test(t2)) return true;
|
|
1068
|
+
if (BULLET_TOOL_RE.test(t2)) return true;
|
|
1069
|
+
if (TREE_LINE_RE.test(t2)) return true;
|
|
1070
|
+
if (STATUS_LINE_RE.test(t2) && /\d+\s*s\s*[·•]|\bthought\s+for\b|\d+\s*tokens|\(thinking\)/i.test(t2)) return true;
|
|
1071
|
+
if (/^↓\s*\d+\s*tokens/i.test(t2)) return true;
|
|
1072
|
+
if (/^\bthought\s+for\s+\d+/i.test(t2)) return true;
|
|
1073
|
+
if (/esc.{0,5}to.{0,5}interrupt/i.test(t2)) return true;
|
|
1074
|
+
if (/high\s*[·•]\s*\/effort/i.test(t2)) return true;
|
|
1075
|
+
if (/^[❯>]\s*$/.test(t2)) return true;
|
|
1076
|
+
if (/^\(thinking\)\s*$/.test(t2)) return true;
|
|
1077
|
+
if (/^\?\s.*shortcut/i.test(t2)) return true;
|
|
1078
|
+
if (/spending limit|usage limit/i.test(t2) && t2.length < 80) return true;
|
|
1079
|
+
if (/↑\s*\/?\s*↓\s*to\s*navigate/i.test(t2)) return true;
|
|
1080
|
+
if (t2.replace(/\s/g, "").length === 1) return true;
|
|
1081
|
+
if ((t2.match(/─/g)?.length ?? 0) >= 6) return true;
|
|
1082
|
+
if (/ctrl\+?o\s+to\s+expand/i.test(t2)) return true;
|
|
1083
|
+
const hasBoxPrefix = /^[│╭╰╮╯┌└┐┘├┤┬┴┼]/.test(t2);
|
|
1084
|
+
const stripped = t2.replace(/^[│╭╰╮╯┌└┐┘├┤┬┴┼]\s?/, "");
|
|
959
1085
|
if (hasBoxPrefix && /^[❯>]\s+\S/.test(stripped) && !/^[❯>]\s*\d+\./.test(stripped)) return true;
|
|
960
1086
|
return false;
|
|
961
1087
|
}
|
|
962
1088
|
function parseChromeLine(line) {
|
|
963
|
-
const
|
|
964
|
-
if (!
|
|
965
|
-
if (/^[─━—═─\-]{3,}$/.test(
|
|
966
|
-
if (/^[❯>]\s*$/.test(
|
|
967
|
-
if (
|
|
968
|
-
if ((
|
|
969
|
-
if (/esc.{0,5}to.{0,5}interrupt/i.test(
|
|
970
|
-
if (/high\s*[·•]\s*\/effort/i.test(
|
|
971
|
-
if (/↑\s*\/?\s*↓\s*to\s*navigate/i.test(
|
|
972
|
-
if (/ctrl\+?o\s+to\s+expand/i.test(
|
|
973
|
-
if (/spending limit|usage limit/i.test(
|
|
974
|
-
if (/^\(thinking\)\s*$/.test(
|
|
1089
|
+
const t2 = line.trim();
|
|
1090
|
+
if (!t2) return null;
|
|
1091
|
+
if (/^[─━—═─\-]{3,}$/.test(t2)) return null;
|
|
1092
|
+
if (/^[❯>]\s*$/.test(t2)) return null;
|
|
1093
|
+
if (t2.replace(/\s/g, "").length === 1) return null;
|
|
1094
|
+
if ((t2.match(/─/g)?.length ?? 0) >= 6) return null;
|
|
1095
|
+
if (/esc.{0,5}to.{0,5}interrupt/i.test(t2)) return null;
|
|
1096
|
+
if (/high\s*[·•]\s*\/effort/i.test(t2)) return null;
|
|
1097
|
+
if (/↑\s*\/?\s*↓\s*to\s*navigate/i.test(t2)) return null;
|
|
1098
|
+
if (/ctrl\+?o\s+to\s+expand/i.test(t2)) return null;
|
|
1099
|
+
if (/spending limit|usage limit/i.test(t2)) return null;
|
|
1100
|
+
if (/^\(thinking\)\s*$/.test(t2)) {
|
|
975
1101
|
return { tool: "thinking", label: "Thinking\u2026", status: "running" };
|
|
976
1102
|
}
|
|
977
|
-
if (TREE_LINE_RE.test(
|
|
978
|
-
if (STATUS_LINE_RE.test(
|
|
979
|
-
const label =
|
|
1103
|
+
if (TREE_LINE_RE.test(t2)) return null;
|
|
1104
|
+
if (STATUS_LINE_RE.test(t2)) {
|
|
1105
|
+
const label = t2.slice(2).replace(/….*/s, "").trim() || "Thinking\u2026";
|
|
980
1106
|
return { tool: "thinking", label, status: "running" };
|
|
981
1107
|
}
|
|
982
|
-
let text =
|
|
983
|
-
if (SPINNER_RE.test(
|
|
984
|
-
text =
|
|
985
|
-
} else if (BULLET_TOOL_RE.test(
|
|
986
|
-
text =
|
|
1108
|
+
let text = t2;
|
|
1109
|
+
if (SPINNER_RE.test(t2)) {
|
|
1110
|
+
text = t2.slice(2).trim().replace(/….*/s, "").trim();
|
|
1111
|
+
} else if (BULLET_TOOL_RE.test(t2)) {
|
|
1112
|
+
text = t2.slice(2).trim();
|
|
987
1113
|
text = text.replace(/\s*\(ctrl\+?o[^)]*\)/gi, "").replace(/,\s*reading\s+\d+\s+files?\s*…?/gi, "").replace(/,\s*\d+\s+files?\s*…?/gi, "").replace(/…$/, "").trim();
|
|
988
1114
|
}
|
|
989
1115
|
if (!text) return null;
|
|
@@ -1134,22 +1260,22 @@ function detectSelector(lines) {
|
|
|
1134
1260
|
if (optionStartIdx === -1) return null;
|
|
1135
1261
|
const questionParts = [];
|
|
1136
1262
|
for (let i = 0; i < optionStartIdx; i++) {
|
|
1137
|
-
const
|
|
1138
|
-
if (!
|
|
1139
|
-
if (/^[─━—═\-]{3,}$/.test(
|
|
1140
|
-
if (/^\[.*\]$/.test(
|
|
1141
|
-
if (/^[>❯]\s/.test(
|
|
1142
|
-
if (!
|
|
1143
|
-
questionParts.push(
|
|
1144
|
-
}
|
|
1145
|
-
const question = questionParts.filter((line, i, arr) => !arr.some((other,
|
|
1263
|
+
const t2 = clean[i].trim();
|
|
1264
|
+
if (!t2) continue;
|
|
1265
|
+
if (/^[─━—═\-]{3,}$/.test(t2)) continue;
|
|
1266
|
+
if (/^\[.*\]$/.test(t2)) continue;
|
|
1267
|
+
if (/^[>❯]\s/.test(t2)) continue;
|
|
1268
|
+
if (!t2.includes(" ") && t2.length > 15) continue;
|
|
1269
|
+
questionParts.push(t2);
|
|
1270
|
+
}
|
|
1271
|
+
const question = questionParts.filter((line, i, arr) => !arr.some((other, j2) => j2 !== i && other.includes(line))).join("\n").trim();
|
|
1146
1272
|
const optionLabels = /* @__PURE__ */ new Map();
|
|
1147
1273
|
const optionDescs = /* @__PURE__ */ new Map();
|
|
1148
1274
|
let currentNum = -1;
|
|
1149
1275
|
for (let i = optionStartIdx; i < clean.length; i++) {
|
|
1150
|
-
const
|
|
1151
|
-
if (!
|
|
1152
|
-
const m =
|
|
1276
|
+
const t2 = clean[i].trim();
|
|
1277
|
+
if (!t2) continue;
|
|
1278
|
+
const m = t2.match(/^(?:❯\s*)?(\d+)\.\s+(.+)/);
|
|
1153
1279
|
if (m) {
|
|
1154
1280
|
const num = parseInt(m[1], 10);
|
|
1155
1281
|
if (!optionLabels.has(num)) {
|
|
@@ -1157,16 +1283,16 @@ function detectSelector(lines) {
|
|
|
1157
1283
|
optionDescs.set(num, []);
|
|
1158
1284
|
}
|
|
1159
1285
|
currentNum = num;
|
|
1160
|
-
} else if (currentNum !== -1 && !/^Enter to/i.test(
|
|
1161
|
-
optionDescs.get(currentNum)?.push(
|
|
1286
|
+
} else if (currentNum !== -1 && !/^Enter to/i.test(t2) && !/^[─━—═\-]{3,}$/.test(t2) && !/↑.*↓.*navigate/i.test(t2) && !/Esc to/i.test(t2)) {
|
|
1287
|
+
optionDescs.get(currentNum)?.push(t2);
|
|
1162
1288
|
}
|
|
1163
1289
|
}
|
|
1164
1290
|
const keys = [...optionLabels.keys()].sort((a, b) => a - b);
|
|
1165
1291
|
if (keys.length < 2 || keys[0] !== 1) return null;
|
|
1166
1292
|
return {
|
|
1167
1293
|
question,
|
|
1168
|
-
options: keys.map((
|
|
1169
|
-
optionDescriptions: keys.map((
|
|
1294
|
+
options: keys.map((k2) => optionLabels.get(k2)),
|
|
1295
|
+
optionDescriptions: keys.map((k2) => (optionDescs.get(k2) ?? []).join(" ").trim()),
|
|
1170
1296
|
currentIndex: 0
|
|
1171
1297
|
};
|
|
1172
1298
|
}
|
|
@@ -1187,32 +1313,32 @@ function detectListSelector(lines) {
|
|
|
1187
1313
|
if (optionStartIdx === -1) return null;
|
|
1188
1314
|
const questionParts = [];
|
|
1189
1315
|
for (let i = 0; i < optionStartIdx; i++) {
|
|
1190
|
-
const
|
|
1191
|
-
if (!
|
|
1192
|
-
if (/^[─━—═\-]{3,}$/.test(
|
|
1193
|
-
if (/[┌└│┐┘├┤┬┴┼]/.test(
|
|
1194
|
-
const inner =
|
|
1316
|
+
const t2 = lines[i].trim();
|
|
1317
|
+
if (!t2) continue;
|
|
1318
|
+
if (/^[─━—═\-]{3,}$/.test(t2)) continue;
|
|
1319
|
+
if (/[┌└│┐┘├┤┬┴┼]/.test(t2)) {
|
|
1320
|
+
const inner = t2.replace(/[│┌└┐┘├┤┬┴┼─]/g, "").trim();
|
|
1195
1321
|
if (inner) questionParts.push(inner);
|
|
1196
1322
|
continue;
|
|
1197
1323
|
}
|
|
1198
|
-
if (/^[>❯]\s/.test(
|
|
1199
|
-
if (/[↑↓].*navigate/i.test(
|
|
1200
|
-
if (!
|
|
1201
|
-
questionParts.push(
|
|
1324
|
+
if (/^[>❯]\s/.test(t2)) continue;
|
|
1325
|
+
if (/[↑↓].*navigate/i.test(t2)) continue;
|
|
1326
|
+
if (!t2.includes(" ") && t2.length > 15) continue;
|
|
1327
|
+
questionParts.push(t2);
|
|
1202
1328
|
}
|
|
1203
|
-
const question = questionParts.filter((line, i, arr) => !arr.some((other,
|
|
1329
|
+
const question = questionParts.filter((line, i, arr) => !arr.some((other, j2) => j2 !== i && other.includes(line))).join("\n").trim();
|
|
1204
1330
|
const options = [];
|
|
1205
1331
|
let currentIndex = 0;
|
|
1206
1332
|
for (const line of lines.slice(optionStartIdx)) {
|
|
1207
|
-
const
|
|
1208
|
-
if (!
|
|
1209
|
-
if (/[↑↓].*navigate/i.test(
|
|
1210
|
-
if (/^[─━—═\-]{3,}$/.test(
|
|
1333
|
+
const t2 = line.trim();
|
|
1334
|
+
if (!t2) continue;
|
|
1335
|
+
if (/[↑↓].*navigate/i.test(t2)) break;
|
|
1336
|
+
if (/^[─━—═\-]{3,}$/.test(t2)) continue;
|
|
1211
1337
|
if (isSelected(line)) {
|
|
1212
1338
|
currentIndex = options.length;
|
|
1213
|
-
options.push(
|
|
1339
|
+
options.push(t2.replace(/^❯\s+/, "").trim());
|
|
1214
1340
|
} else if (isUnselected(line)) {
|
|
1215
|
-
options.push(
|
|
1341
|
+
options.push(t2);
|
|
1216
1342
|
}
|
|
1217
1343
|
}
|
|
1218
1344
|
if (options.length < 2) return null;
|
|
@@ -1229,35 +1355,35 @@ function filterChrome(lines) {
|
|
|
1229
1355
|
const result = [];
|
|
1230
1356
|
let skipEchoContinuation = false;
|
|
1231
1357
|
for (const line of lines) {
|
|
1232
|
-
const
|
|
1233
|
-
if (!
|
|
1358
|
+
const t2 = line.trim();
|
|
1359
|
+
if (!t2) {
|
|
1234
1360
|
skipEchoContinuation = false;
|
|
1235
1361
|
continue;
|
|
1236
1362
|
}
|
|
1237
|
-
if (/^[─━—═─\-]{3,}$/.test(
|
|
1363
|
+
if (/^[─━—═─\-]{3,}$/.test(t2)) {
|
|
1238
1364
|
skipEchoContinuation = false;
|
|
1239
1365
|
continue;
|
|
1240
1366
|
}
|
|
1241
|
-
if (/^[✳✢✶✻✽✴✷✸✹⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏◐◑◒◓▁▂▃▄▅▆▇█]\s/.test(
|
|
1242
|
-
if (/esc.{0,5}to.{0,5}interrupt/i.test(
|
|
1243
|
-
if (/high\s*[·•]\s*\/effort/i.test(
|
|
1244
|
-
if (/^[❯>]\s*$/.test(
|
|
1245
|
-
if (/^\(thinking\)\s*$/.test(
|
|
1246
|
-
if (/^\?\s.*shortcut/i.test(
|
|
1247
|
-
if (/spending limit|usage limit/i.test(
|
|
1248
|
-
if (/↑\s*\/?\s*↓\s*to\s*navigate/i.test(
|
|
1249
|
-
if (
|
|
1250
|
-
if ((
|
|
1251
|
-
if (/ctrl\+?o\s+to\s+expand/i.test(
|
|
1367
|
+
if (/^[✳✢✶✻✽✴✷✸✹⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏◐◑◒◓▁▂▃▄▅▆▇█]\s/.test(t2)) continue;
|
|
1368
|
+
if (/esc.{0,5}to.{0,5}interrupt/i.test(t2)) continue;
|
|
1369
|
+
if (/high\s*[·•]\s*\/effort/i.test(t2)) continue;
|
|
1370
|
+
if (/^[❯>]\s*$/.test(t2)) continue;
|
|
1371
|
+
if (/^\(thinking\)\s*$/.test(t2)) continue;
|
|
1372
|
+
if (/^\?\s.*shortcut/i.test(t2)) continue;
|
|
1373
|
+
if (/spending limit|usage limit/i.test(t2) && t2.length < 80) continue;
|
|
1374
|
+
if (/↑\s*\/?\s*↓\s*to\s*navigate/i.test(t2)) continue;
|
|
1375
|
+
if (t2.replace(/\s/g, "").length === 1) continue;
|
|
1376
|
+
if ((t2.match(/─/g)?.length ?? 0) >= 6) continue;
|
|
1377
|
+
if (/ctrl\+?o\s+to\s+expand/i.test(t2)) continue;
|
|
1252
1378
|
if (/^•\s+(?:Read(?:ing)?|Edit(?:ing)?|Writ(?:e|ing)|Bash|Runn(?:ing)?|Search(?:ing)?|Glob(?:bing)?|Grep(?:ping)?|Creat(?:e|ing)|Execut(?:e|ing)|Task|Agent|NotebookEdit)\b/i.test(
|
|
1253
|
-
|
|
1379
|
+
t2
|
|
1254
1380
|
))
|
|
1255
1381
|
continue;
|
|
1256
|
-
if (/^└\s/.test(
|
|
1257
|
-
if (/^\+\s/.test(
|
|
1258
|
-
if (/^↓\s*\d+\s*tokens/i.test(
|
|
1259
|
-
if (/^\bthought\s+for\s+\d+/i.test(
|
|
1260
|
-
const stripped =
|
|
1382
|
+
if (/^└\s/.test(t2)) continue;
|
|
1383
|
+
if (/^\+\s/.test(t2) && /\d+\s*s\s*[·•]|\bthought\s+for\b|\d+\s*tokens|\(thinking\)/i.test(t2)) continue;
|
|
1384
|
+
if (/^↓\s*\d+\s*tokens/i.test(t2)) continue;
|
|
1385
|
+
if (/^\bthought\s+for\s+\d+/i.test(t2)) continue;
|
|
1386
|
+
const stripped = t2.replace(/^[│╭╰╮╯┌└┐┘├┤┬┴┼]\s?/, "");
|
|
1261
1387
|
if (/^[❯>]\s+\S/.test(stripped) && !/^[❯>]\s*\d+\./.test(stripped)) {
|
|
1262
1388
|
skipEchoContinuation = true;
|
|
1263
1389
|
continue;
|
|
@@ -1301,9 +1427,10 @@ function getContextWindow(model) {
|
|
|
1301
1427
|
// src/services/output.service.ts
|
|
1302
1428
|
var API_BASE4 = process.env.CODEAM_API_URL ?? "https://codeagent-mobile-api.vercel.app";
|
|
1303
1429
|
var OutputService = class _OutputService {
|
|
1304
|
-
constructor(sessionId, pluginId, onSessionIdDetected, onRateLimitDetected, onTurnComplete, onTerminalTurnDetected) {
|
|
1430
|
+
constructor(sessionId, pluginId, onSessionIdDetected, onRateLimitDetected, onTurnComplete, onTerminalTurnDetected, pluginAuthToken) {
|
|
1305
1431
|
this.sessionId = sessionId;
|
|
1306
1432
|
this.pluginId = pluginId;
|
|
1433
|
+
this.pluginAuthToken = pluginAuthToken;
|
|
1307
1434
|
this.onSessionIdDetected = onSessionIdDetected;
|
|
1308
1435
|
this.onRateLimitDetected = onRateLimitDetected;
|
|
1309
1436
|
this.onTurnComplete = onTurnComplete;
|
|
@@ -1311,6 +1438,7 @@ var OutputService = class _OutputService {
|
|
|
1311
1438
|
}
|
|
1312
1439
|
sessionId;
|
|
1313
1440
|
pluginId;
|
|
1441
|
+
pluginAuthToken;
|
|
1314
1442
|
rawBuffer = "";
|
|
1315
1443
|
lastSentContent = "";
|
|
1316
1444
|
lastSentChromeStepsJson = "";
|
|
@@ -1527,42 +1655,21 @@ var OutputService = class _OutputService {
|
|
|
1527
1655
|
pluginId: this.pluginId,
|
|
1528
1656
|
...body
|
|
1529
1657
|
});
|
|
1658
|
+
const headers = {
|
|
1659
|
+
"Content-Type": "application/json"
|
|
1660
|
+
};
|
|
1661
|
+
if (this.pluginAuthToken) {
|
|
1662
|
+
headers["X-Plugin-Auth-Token"] = this.pluginAuthToken;
|
|
1663
|
+
}
|
|
1530
1664
|
return new Promise((resolve) => {
|
|
1531
1665
|
const attempt = (attemptsLeft) => {
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
const req = transport.request(
|
|
1536
|
-
{
|
|
1537
|
-
hostname: u.hostname,
|
|
1538
|
-
port: u.port || (u.protocol === "https:" ? 443 : 80),
|
|
1539
|
-
path: u.pathname,
|
|
1540
|
-
method: "POST",
|
|
1541
|
-
headers: {
|
|
1542
|
-
"Content-Type": "application/json",
|
|
1543
|
-
"Content-Length": Buffer.byteLength(payload)
|
|
1544
|
-
},
|
|
1545
|
-
timeout: 8e3
|
|
1546
|
-
},
|
|
1547
|
-
(res) => {
|
|
1548
|
-
let resData = "";
|
|
1549
|
-
res.on("data", (c) => {
|
|
1550
|
-
resData += c.toString();
|
|
1551
|
-
});
|
|
1552
|
-
res.on("end", () => {
|
|
1553
|
-
if (settled) return;
|
|
1554
|
-
settled = true;
|
|
1555
|
-
if (res.statusCode && res.statusCode >= 400) {
|
|
1556
|
-
process.stderr.write(`[codeam] output API error ${res.statusCode}: ${resData}
|
|
1666
|
+
_transport2.sendOutputChunk(`${API_BASE4}/api/commands/output`, headers, payload).then(({ statusCode, body: resBody }) => {
|
|
1667
|
+
if (statusCode >= 400) {
|
|
1668
|
+
process.stderr.write(`[codeam] output API error ${statusCode}: ${resBody}
|
|
1557
1669
|
`);
|
|
1558
|
-
}
|
|
1559
|
-
resolve();
|
|
1560
|
-
});
|
|
1561
1670
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
if (settled) return;
|
|
1565
|
-
settled = true;
|
|
1671
|
+
resolve();
|
|
1672
|
+
}).catch(() => {
|
|
1566
1673
|
if (attemptsLeft > 0) {
|
|
1567
1674
|
const delay = 200 * (maxRetries - attemptsLeft + 1);
|
|
1568
1675
|
setTimeout(() => attempt(attemptsLeft - 1), delay);
|
|
@@ -1570,16 +1677,55 @@ var OutputService = class _OutputService {
|
|
|
1570
1677
|
resolve();
|
|
1571
1678
|
}
|
|
1572
1679
|
});
|
|
1573
|
-
req.on("timeout", () => {
|
|
1574
|
-
req.destroy();
|
|
1575
|
-
});
|
|
1576
|
-
req.write(payload);
|
|
1577
|
-
req.end();
|
|
1578
1680
|
};
|
|
1579
1681
|
attempt(maxRetries);
|
|
1580
1682
|
});
|
|
1581
1683
|
}
|
|
1582
1684
|
};
|
|
1685
|
+
var _transport2 = {
|
|
1686
|
+
sendOutputChunk: _sendOutputChunk
|
|
1687
|
+
};
|
|
1688
|
+
function _sendOutputChunk(url, headers, payload) {
|
|
1689
|
+
return new Promise((resolve, reject) => {
|
|
1690
|
+
let settled = false;
|
|
1691
|
+
const u2 = new URL(url);
|
|
1692
|
+
const transport = u2.protocol === "https:" ? https2 : http2;
|
|
1693
|
+
const req = transport.request(
|
|
1694
|
+
{
|
|
1695
|
+
hostname: u2.hostname,
|
|
1696
|
+
port: u2.port || (u2.protocol === "https:" ? 443 : 80),
|
|
1697
|
+
path: u2.pathname,
|
|
1698
|
+
method: "POST",
|
|
1699
|
+
headers: {
|
|
1700
|
+
...headers,
|
|
1701
|
+
"Content-Length": Buffer.byteLength(payload)
|
|
1702
|
+
},
|
|
1703
|
+
timeout: 8e3
|
|
1704
|
+
},
|
|
1705
|
+
(res) => {
|
|
1706
|
+
let resData = "";
|
|
1707
|
+
res.on("data", (c2) => {
|
|
1708
|
+
resData += c2.toString();
|
|
1709
|
+
});
|
|
1710
|
+
res.on("end", () => {
|
|
1711
|
+
if (settled) return;
|
|
1712
|
+
settled = true;
|
|
1713
|
+
resolve({ statusCode: res.statusCode ?? 0, body: resData });
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
);
|
|
1717
|
+
req.on("error", (err) => {
|
|
1718
|
+
if (settled) return;
|
|
1719
|
+
settled = true;
|
|
1720
|
+
reject(err);
|
|
1721
|
+
});
|
|
1722
|
+
req.on("timeout", () => {
|
|
1723
|
+
req.destroy();
|
|
1724
|
+
});
|
|
1725
|
+
req.write(payload);
|
|
1726
|
+
req.end();
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1583
1729
|
|
|
1584
1730
|
// src/services/history.service.ts
|
|
1585
1731
|
var fs4 = __toESM(require("fs"));
|
|
@@ -1656,13 +1802,13 @@ function parseJsonl(filePath) {
|
|
|
1656
1802
|
function post(endpoint, body) {
|
|
1657
1803
|
return new Promise((resolve) => {
|
|
1658
1804
|
const payload = JSON.stringify(body);
|
|
1659
|
-
const
|
|
1660
|
-
const transport =
|
|
1805
|
+
const u2 = new URL(`${API_BASE5}${endpoint}`);
|
|
1806
|
+
const transport = u2.protocol === "https:" ? https3 : http3;
|
|
1661
1807
|
const req = transport.request(
|
|
1662
1808
|
{
|
|
1663
|
-
hostname:
|
|
1664
|
-
port:
|
|
1665
|
-
path:
|
|
1809
|
+
hostname: u2.hostname,
|
|
1810
|
+
port: u2.port || (u2.protocol === "https:" ? 443 : 80),
|
|
1811
|
+
path: u2.pathname,
|
|
1666
1812
|
method: "POST",
|
|
1667
1813
|
headers: {
|
|
1668
1814
|
"Content-Type": "application/json",
|
|
@@ -1980,6 +2126,27 @@ var HistoryService = class {
|
|
|
1980
2126
|
}
|
|
1981
2127
|
};
|
|
1982
2128
|
|
|
2129
|
+
// src/lib/payload.ts
|
|
2130
|
+
var import_zod = require("zod");
|
|
2131
|
+
var fileEntrySchema = import_zod.z.object({
|
|
2132
|
+
filename: import_zod.z.string().min(1).max(256),
|
|
2133
|
+
mimeType: import_zod.z.string(),
|
|
2134
|
+
base64: import_zod.z.string()
|
|
2135
|
+
});
|
|
2136
|
+
var startCommandSchema = import_zod.z.object({
|
|
2137
|
+
prompt: import_zod.z.string().optional(),
|
|
2138
|
+
files: import_zod.z.array(fileEntrySchema).optional(),
|
|
2139
|
+
input: import_zod.z.string().optional(),
|
|
2140
|
+
index: import_zod.z.number().optional(),
|
|
2141
|
+
from: import_zod.z.number().optional(),
|
|
2142
|
+
id: import_zod.z.string().optional(),
|
|
2143
|
+
auto: import_zod.z.boolean().optional()
|
|
2144
|
+
});
|
|
2145
|
+
function parsePayload(schema, raw) {
|
|
2146
|
+
const result = schema.safeParse(raw);
|
|
2147
|
+
return result.success ? result.data : null;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
1983
2150
|
// src/commands/start.ts
|
|
1984
2151
|
function saveFilesTemp(files) {
|
|
1985
2152
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
@@ -2118,16 +2285,20 @@ except Exception:sys.exit(0)
|
|
|
2118
2285
|
}, () => {
|
|
2119
2286
|
const prevCount = historySvc.getCurrentMessageCount();
|
|
2120
2287
|
historySvc.waitForNewUserMessage(prevCount).then((userText) => outputSvc.startTerminalTurn(userText ?? void 0)).catch(() => outputSvc.startTerminalTurn(void 0));
|
|
2121
|
-
});
|
|
2288
|
+
}, session.pluginAuthToken);
|
|
2122
2289
|
function sendPrompt(prompt) {
|
|
2123
2290
|
outputSvc.newTurn();
|
|
2124
2291
|
claude.sendCommand(prompt);
|
|
2125
2292
|
}
|
|
2126
2293
|
const relay = new CommandRelayService(pluginId, async (cmd) => {
|
|
2294
|
+
const parsed = parsePayload(startCommandSchema, cmd.payload);
|
|
2295
|
+
if (!parsed) {
|
|
2296
|
+
showInfo(`Ignoring malformed ${cmd.type} payload.`);
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2127
2299
|
switch (cmd.type) {
|
|
2128
2300
|
case "start_task": {
|
|
2129
|
-
const prompt =
|
|
2130
|
-
const files = cmd.payload.files;
|
|
2301
|
+
const { prompt, files } = parsed;
|
|
2131
2302
|
const effectivePrompt = prompt ?? "";
|
|
2132
2303
|
if (files && files.length > 0) {
|
|
2133
2304
|
const paths = saveFilesTemp(files);
|
|
@@ -2148,13 +2319,13 @@ except Exception:sys.exit(0)
|
|
|
2148
2319
|
break;
|
|
2149
2320
|
}
|
|
2150
2321
|
case "provide_input": {
|
|
2151
|
-
const input =
|
|
2322
|
+
const { input } = parsed;
|
|
2152
2323
|
if (input) sendPrompt(input);
|
|
2153
2324
|
break;
|
|
2154
2325
|
}
|
|
2155
2326
|
case "select_option": {
|
|
2156
|
-
const index =
|
|
2157
|
-
const from =
|
|
2327
|
+
const index = parsed.index ?? 0;
|
|
2328
|
+
const from = parsed.from ?? 0;
|
|
2158
2329
|
outputSvc.newTurn();
|
|
2159
2330
|
claude.selectOption(index, from);
|
|
2160
2331
|
break;
|
|
@@ -2177,13 +2348,12 @@ except Exception:sys.exit(0)
|
|
|
2177
2348
|
break;
|
|
2178
2349
|
}
|
|
2179
2350
|
case "resume_session": {
|
|
2180
|
-
const id =
|
|
2181
|
-
const auto = cmd.payload.auto ?? false;
|
|
2351
|
+
const { id, auto } = parsed;
|
|
2182
2352
|
if (!id) break;
|
|
2183
2353
|
historySvc.setCurrentConversationId(id);
|
|
2184
2354
|
await historySvc.loadConversation(id);
|
|
2185
2355
|
await outputSvc.newTurnResume(id);
|
|
2186
|
-
claude.restart(id, auto);
|
|
2356
|
+
claude.restart(id, auto ?? false);
|
|
2187
2357
|
break;
|
|
2188
2358
|
}
|
|
2189
2359
|
case "get_conversation": {
|
|
@@ -2219,11 +2389,15 @@ except Exception:sys.exit(0)
|
|
|
2219
2389
|
},
|
|
2220
2390
|
onMessage(type, payload) {
|
|
2221
2391
|
if (type !== "agent_command") return;
|
|
2222
|
-
const cmdType = payload.type;
|
|
2223
|
-
|
|
2392
|
+
const cmdType = typeof payload.type === "string" ? payload.type : null;
|
|
2393
|
+
if (!cmdType) return;
|
|
2394
|
+
const parsed = parsePayload(startCommandSchema, payload.payload ?? {});
|
|
2395
|
+
if (!parsed) {
|
|
2396
|
+
showInfo(`Ignoring malformed ${cmdType} payload (ws).`);
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2224
2399
|
if (cmdType === "start_task") {
|
|
2225
|
-
const prompt =
|
|
2226
|
-
const files = inner.files;
|
|
2400
|
+
const { prompt, files } = parsed;
|
|
2227
2401
|
const effectivePrompt = prompt ?? "";
|
|
2228
2402
|
if (files && files.length > 0) {
|
|
2229
2403
|
const paths = saveFilesTemp(files);
|
|
@@ -2242,11 +2416,11 @@ except Exception:sys.exit(0)
|
|
|
2242
2416
|
sendPrompt(effectivePrompt);
|
|
2243
2417
|
}
|
|
2244
2418
|
} else if (cmdType === "provide_input") {
|
|
2245
|
-
const input =
|
|
2419
|
+
const { input } = parsed;
|
|
2246
2420
|
if (input) sendPrompt(input);
|
|
2247
2421
|
} else if (cmdType === "select_option") {
|
|
2248
|
-
const index =
|
|
2249
|
-
const from =
|
|
2422
|
+
const index = parsed.index ?? 0;
|
|
2423
|
+
const from = parsed.from ?? 0;
|
|
2250
2424
|
outputSvc.newTurn();
|
|
2251
2425
|
claude.selectOption(index, from);
|
|
2252
2426
|
} else if (cmdType === "escape_key") {
|
|
@@ -2261,11 +2435,11 @@ except Exception:sys.exit(0)
|
|
|
2261
2435
|
});
|
|
2262
2436
|
}
|
|
2263
2437
|
} else if (cmdType === "resume_session") {
|
|
2264
|
-
const id =
|
|
2265
|
-
const auto = inner.auto ?? false;
|
|
2438
|
+
const { id, auto } = parsed;
|
|
2266
2439
|
if (id) {
|
|
2440
|
+
const autoFlag = auto ?? false;
|
|
2267
2441
|
historySvc.loadConversation(id).then(() => outputSvc.newTurnResume(id)).then(() => {
|
|
2268
|
-
claude.restart(id,
|
|
2442
|
+
claude.restart(id, autoFlag);
|
|
2269
2443
|
}).catch(() => {
|
|
2270
2444
|
});
|
|
2271
2445
|
}
|
|
@@ -2315,15 +2489,1924 @@ except Exception:sys.exit(0)
|
|
|
2315
2489
|
var import_crypto2 = require("crypto");
|
|
2316
2490
|
var import_picocolors3 = __toESM(require("picocolors"));
|
|
2317
2491
|
|
|
2492
|
+
// ../../node_modules/@clack/prompts/dist/index.mjs
|
|
2493
|
+
var dist_exports = {};
|
|
2494
|
+
__export(dist_exports, {
|
|
2495
|
+
S_BAR: () => d2,
|
|
2496
|
+
S_BAR_END: () => E2,
|
|
2497
|
+
S_BAR_END_RIGHT: () => Ee,
|
|
2498
|
+
S_BAR_H: () => se,
|
|
2499
|
+
S_BAR_START: () => le,
|
|
2500
|
+
S_BAR_START_RIGHT: () => Ie,
|
|
2501
|
+
S_CHECKBOX_ACTIVE: () => te,
|
|
2502
|
+
S_CHECKBOX_INACTIVE: () => J2,
|
|
2503
|
+
S_CHECKBOX_SELECTED: () => U,
|
|
2504
|
+
S_CONNECT_LEFT: () => Ge,
|
|
2505
|
+
S_CORNER_BOTTOM_LEFT: () => de,
|
|
2506
|
+
S_CORNER_BOTTOM_RIGHT: () => $e,
|
|
2507
|
+
S_CORNER_TOP_LEFT: () => Oe,
|
|
2508
|
+
S_CORNER_TOP_RIGHT: () => ce,
|
|
2509
|
+
S_ERROR: () => ge,
|
|
2510
|
+
S_INFO: () => he,
|
|
2511
|
+
S_PASSWORD_MASK: () => xe,
|
|
2512
|
+
S_RADIO_ACTIVE: () => z3,
|
|
2513
|
+
S_RADIO_INACTIVE: () => H2,
|
|
2514
|
+
S_STEP_ACTIVE: () => _e,
|
|
2515
|
+
S_STEP_CANCEL: () => oe,
|
|
2516
|
+
S_STEP_ERROR: () => ue,
|
|
2517
|
+
S_STEP_SUBMIT: () => F2,
|
|
2518
|
+
S_SUCCESS: () => pe,
|
|
2519
|
+
S_WARN: () => me,
|
|
2520
|
+
autocomplete: () => Ae,
|
|
2521
|
+
autocompleteMultiselect: () => st2,
|
|
2522
|
+
box: () => at2,
|
|
2523
|
+
cancel: () => pt,
|
|
2524
|
+
confirm: () => ot2,
|
|
2525
|
+
date: () => ut,
|
|
2526
|
+
group: () => dt,
|
|
2527
|
+
groupMultiselect: () => ht,
|
|
2528
|
+
intro: () => mt,
|
|
2529
|
+
isCI: () => ae,
|
|
2530
|
+
isCancel: () => q,
|
|
2531
|
+
isTTY: () => Te,
|
|
2532
|
+
limitOptions: () => Y2,
|
|
2533
|
+
log: () => O2,
|
|
2534
|
+
multiselect: () => yt,
|
|
2535
|
+
note: () => wt,
|
|
2536
|
+
outro: () => gt,
|
|
2537
|
+
password: () => bt,
|
|
2538
|
+
path: () => St,
|
|
2539
|
+
progress: () => Tt,
|
|
2540
|
+
select: () => _t,
|
|
2541
|
+
selectKey: () => It,
|
|
2542
|
+
settings: () => u,
|
|
2543
|
+
spinner: () => fe,
|
|
2544
|
+
stream: () => K2,
|
|
2545
|
+
symbol: () => V2,
|
|
2546
|
+
symbolBar: () => ye,
|
|
2547
|
+
taskLog: () => Gt,
|
|
2548
|
+
tasks: () => Et,
|
|
2549
|
+
text: () => Ot,
|
|
2550
|
+
unicode: () => ee,
|
|
2551
|
+
unicodeOr: () => w2,
|
|
2552
|
+
updateSettings: () => K
|
|
2553
|
+
});
|
|
2554
|
+
|
|
2555
|
+
// ../../node_modules/@clack/core/dist/index.mjs
|
|
2556
|
+
var import_node_util = require("util");
|
|
2557
|
+
var import_node_process = require("process");
|
|
2558
|
+
var _ = __toESM(require("readline"), 1);
|
|
2559
|
+
var import_node_readline = __toESM(require("readline"), 1);
|
|
2560
|
+
|
|
2561
|
+
// ../../node_modules/fast-string-truncated-width/dist/utils.js
|
|
2562
|
+
var isAmbiguous = (x) => {
|
|
2563
|
+
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
2564
|
+
};
|
|
2565
|
+
var isFullWidth = (x) => {
|
|
2566
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
2567
|
+
};
|
|
2568
|
+
var isWide = (x) => {
|
|
2569
|
+
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
2570
|
+
};
|
|
2571
|
+
|
|
2572
|
+
// ../../node_modules/fast-string-truncated-width/dist/index.js
|
|
2573
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
2574
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
2575
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
2576
|
+
var EMOJI_RE = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
2577
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
2578
|
+
var MODIFIER_RE = new RegExp("\\p{M}+", "gu");
|
|
2579
|
+
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
2580
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
2581
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
2582
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
2583
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
2584
|
+
const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
|
|
2585
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
2586
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
2587
|
+
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
2588
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
2589
|
+
const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
|
|
2590
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
2591
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
|
|
2592
|
+
let indexPrev = 0;
|
|
2593
|
+
let index = 0;
|
|
2594
|
+
let length = input.length;
|
|
2595
|
+
let lengthExtra = 0;
|
|
2596
|
+
let truncationEnabled = false;
|
|
2597
|
+
let truncationIndex = length;
|
|
2598
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
2599
|
+
let unmatchedStart = 0;
|
|
2600
|
+
let unmatchedEnd = 0;
|
|
2601
|
+
let width = 0;
|
|
2602
|
+
let widthExtra = 0;
|
|
2603
|
+
outer: while (true) {
|
|
2604
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
2605
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
2606
|
+
lengthExtra = 0;
|
|
2607
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
2608
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
2609
|
+
if (isFullWidth(codePoint)) {
|
|
2610
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
2611
|
+
} else if (isWide(codePoint)) {
|
|
2612
|
+
widthExtra = WIDE_WIDTH;
|
|
2613
|
+
} else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
|
|
2614
|
+
widthExtra = AMBIGUOUS_WIDTH;
|
|
2615
|
+
} else {
|
|
2616
|
+
widthExtra = REGULAR_WIDTH;
|
|
2617
|
+
}
|
|
2618
|
+
if (width + widthExtra > truncationLimit) {
|
|
2619
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
2620
|
+
}
|
|
2621
|
+
if (width + widthExtra > LIMIT) {
|
|
2622
|
+
truncationEnabled = true;
|
|
2623
|
+
break outer;
|
|
2624
|
+
}
|
|
2625
|
+
lengthExtra += char.length;
|
|
2626
|
+
width += widthExtra;
|
|
2627
|
+
}
|
|
2628
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
2629
|
+
}
|
|
2630
|
+
if (index >= length)
|
|
2631
|
+
break;
|
|
2632
|
+
LATIN_RE.lastIndex = index;
|
|
2633
|
+
if (LATIN_RE.test(input)) {
|
|
2634
|
+
lengthExtra = LATIN_RE.lastIndex - index;
|
|
2635
|
+
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
2636
|
+
if (width + widthExtra > truncationLimit) {
|
|
2637
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
2638
|
+
}
|
|
2639
|
+
if (width + widthExtra > LIMIT) {
|
|
2640
|
+
truncationEnabled = true;
|
|
2641
|
+
break;
|
|
2642
|
+
}
|
|
2643
|
+
width += widthExtra;
|
|
2644
|
+
unmatchedStart = indexPrev;
|
|
2645
|
+
unmatchedEnd = index;
|
|
2646
|
+
index = indexPrev = LATIN_RE.lastIndex;
|
|
2647
|
+
continue;
|
|
2648
|
+
}
|
|
2649
|
+
ANSI_RE.lastIndex = index;
|
|
2650
|
+
if (ANSI_RE.test(input)) {
|
|
2651
|
+
if (width + ANSI_WIDTH > truncationLimit) {
|
|
2652
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
2653
|
+
}
|
|
2654
|
+
if (width + ANSI_WIDTH > LIMIT) {
|
|
2655
|
+
truncationEnabled = true;
|
|
2656
|
+
break;
|
|
2657
|
+
}
|
|
2658
|
+
width += ANSI_WIDTH;
|
|
2659
|
+
unmatchedStart = indexPrev;
|
|
2660
|
+
unmatchedEnd = index;
|
|
2661
|
+
index = indexPrev = ANSI_RE.lastIndex;
|
|
2662
|
+
continue;
|
|
2663
|
+
}
|
|
2664
|
+
CONTROL_RE.lastIndex = index;
|
|
2665
|
+
if (CONTROL_RE.test(input)) {
|
|
2666
|
+
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
2667
|
+
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
2668
|
+
if (width + widthExtra > truncationLimit) {
|
|
2669
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
2670
|
+
}
|
|
2671
|
+
if (width + widthExtra > LIMIT) {
|
|
2672
|
+
truncationEnabled = true;
|
|
2673
|
+
break;
|
|
2674
|
+
}
|
|
2675
|
+
width += widthExtra;
|
|
2676
|
+
unmatchedStart = indexPrev;
|
|
2677
|
+
unmatchedEnd = index;
|
|
2678
|
+
index = indexPrev = CONTROL_RE.lastIndex;
|
|
2679
|
+
continue;
|
|
2680
|
+
}
|
|
2681
|
+
TAB_RE.lastIndex = index;
|
|
2682
|
+
if (TAB_RE.test(input)) {
|
|
2683
|
+
lengthExtra = TAB_RE.lastIndex - index;
|
|
2684
|
+
widthExtra = lengthExtra * TAB_WIDTH;
|
|
2685
|
+
if (width + widthExtra > truncationLimit) {
|
|
2686
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
2687
|
+
}
|
|
2688
|
+
if (width + widthExtra > LIMIT) {
|
|
2689
|
+
truncationEnabled = true;
|
|
2690
|
+
break;
|
|
2691
|
+
}
|
|
2692
|
+
width += widthExtra;
|
|
2693
|
+
unmatchedStart = indexPrev;
|
|
2694
|
+
unmatchedEnd = index;
|
|
2695
|
+
index = indexPrev = TAB_RE.lastIndex;
|
|
2696
|
+
continue;
|
|
2697
|
+
}
|
|
2698
|
+
EMOJI_RE.lastIndex = index;
|
|
2699
|
+
if (EMOJI_RE.test(input)) {
|
|
2700
|
+
if (width + EMOJI_WIDTH > truncationLimit) {
|
|
2701
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
2702
|
+
}
|
|
2703
|
+
if (width + EMOJI_WIDTH > LIMIT) {
|
|
2704
|
+
truncationEnabled = true;
|
|
2705
|
+
break;
|
|
2706
|
+
}
|
|
2707
|
+
width += EMOJI_WIDTH;
|
|
2708
|
+
unmatchedStart = indexPrev;
|
|
2709
|
+
unmatchedEnd = index;
|
|
2710
|
+
index = indexPrev = EMOJI_RE.lastIndex;
|
|
2711
|
+
continue;
|
|
2712
|
+
}
|
|
2713
|
+
index += 1;
|
|
2714
|
+
}
|
|
2715
|
+
return {
|
|
2716
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
2717
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
2718
|
+
truncated: truncationEnabled,
|
|
2719
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
2720
|
+
};
|
|
2721
|
+
};
|
|
2722
|
+
var dist_default = getStringTruncatedWidth;
|
|
2723
|
+
|
|
2724
|
+
// ../../node_modules/fast-string-width/dist/index.js
|
|
2725
|
+
var NO_TRUNCATION2 = {
|
|
2726
|
+
limit: Infinity,
|
|
2727
|
+
ellipsis: "",
|
|
2728
|
+
ellipsisWidth: 0
|
|
2729
|
+
};
|
|
2730
|
+
var fastStringWidth = (input, options = {}) => {
|
|
2731
|
+
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
2732
|
+
};
|
|
2733
|
+
var dist_default2 = fastStringWidth;
|
|
2734
|
+
|
|
2735
|
+
// ../../node_modules/fast-wrap-ansi/lib/main.js
|
|
2736
|
+
var ESC = "\x1B";
|
|
2737
|
+
var CSI = "\x9B";
|
|
2738
|
+
var END_CODE = 39;
|
|
2739
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
2740
|
+
var ANSI_CSI = "[";
|
|
2741
|
+
var ANSI_OSC = "]";
|
|
2742
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
2743
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
2744
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
2745
|
+
var getClosingCode = (openingCode) => {
|
|
2746
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
2747
|
+
return 39;
|
|
2748
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
2749
|
+
return 39;
|
|
2750
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
2751
|
+
return 49;
|
|
2752
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
2753
|
+
return 49;
|
|
2754
|
+
if (openingCode === 1 || openingCode === 2)
|
|
2755
|
+
return 22;
|
|
2756
|
+
if (openingCode === 3)
|
|
2757
|
+
return 23;
|
|
2758
|
+
if (openingCode === 4)
|
|
2759
|
+
return 24;
|
|
2760
|
+
if (openingCode === 7)
|
|
2761
|
+
return 27;
|
|
2762
|
+
if (openingCode === 8)
|
|
2763
|
+
return 28;
|
|
2764
|
+
if (openingCode === 9)
|
|
2765
|
+
return 29;
|
|
2766
|
+
if (openingCode === 0)
|
|
2767
|
+
return 0;
|
|
2768
|
+
return void 0;
|
|
2769
|
+
};
|
|
2770
|
+
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
2771
|
+
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
2772
|
+
var wrapWord = (rows, word, columns) => {
|
|
2773
|
+
const characters = word[Symbol.iterator]();
|
|
2774
|
+
let isInsideEscape = false;
|
|
2775
|
+
let isInsideLinkEscape = false;
|
|
2776
|
+
let lastRow = rows.at(-1);
|
|
2777
|
+
let visible = lastRow === void 0 ? 0 : dist_default2(lastRow);
|
|
2778
|
+
let currentCharacter = characters.next();
|
|
2779
|
+
let nextCharacter = characters.next();
|
|
2780
|
+
let rawCharacterIndex = 0;
|
|
2781
|
+
while (!currentCharacter.done) {
|
|
2782
|
+
const character = currentCharacter.value;
|
|
2783
|
+
const characterLength = dist_default2(character);
|
|
2784
|
+
if (visible + characterLength <= columns) {
|
|
2785
|
+
rows[rows.length - 1] += character;
|
|
2786
|
+
} else {
|
|
2787
|
+
rows.push(character);
|
|
2788
|
+
visible = 0;
|
|
2789
|
+
}
|
|
2790
|
+
if (character === ESC || character === CSI) {
|
|
2791
|
+
isInsideEscape = true;
|
|
2792
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
2793
|
+
}
|
|
2794
|
+
if (isInsideEscape) {
|
|
2795
|
+
if (isInsideLinkEscape) {
|
|
2796
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
2797
|
+
isInsideEscape = false;
|
|
2798
|
+
isInsideLinkEscape = false;
|
|
2799
|
+
}
|
|
2800
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
2801
|
+
isInsideEscape = false;
|
|
2802
|
+
}
|
|
2803
|
+
} else {
|
|
2804
|
+
visible += characterLength;
|
|
2805
|
+
if (visible === columns && !nextCharacter.done) {
|
|
2806
|
+
rows.push("");
|
|
2807
|
+
visible = 0;
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
currentCharacter = nextCharacter;
|
|
2811
|
+
nextCharacter = characters.next();
|
|
2812
|
+
rawCharacterIndex += character.length;
|
|
2813
|
+
}
|
|
2814
|
+
lastRow = rows.at(-1);
|
|
2815
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) {
|
|
2816
|
+
rows[rows.length - 2] += rows.pop();
|
|
2817
|
+
}
|
|
2818
|
+
};
|
|
2819
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
2820
|
+
const words = string.split(" ");
|
|
2821
|
+
let last = words.length;
|
|
2822
|
+
while (last) {
|
|
2823
|
+
if (dist_default2(words[last - 1])) {
|
|
2824
|
+
break;
|
|
2825
|
+
}
|
|
2826
|
+
last--;
|
|
2827
|
+
}
|
|
2828
|
+
if (last === words.length) {
|
|
2829
|
+
return string;
|
|
2830
|
+
}
|
|
2831
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
2832
|
+
};
|
|
2833
|
+
var exec = (string, columns, options = {}) => {
|
|
2834
|
+
if (options.trim !== false && string.trim() === "") {
|
|
2835
|
+
return "";
|
|
2836
|
+
}
|
|
2837
|
+
let returnValue = "";
|
|
2838
|
+
let escapeCode;
|
|
2839
|
+
let escapeUrl;
|
|
2840
|
+
const words = string.split(" ");
|
|
2841
|
+
let rows = [""];
|
|
2842
|
+
let rowLength = 0;
|
|
2843
|
+
for (let index = 0; index < words.length; index++) {
|
|
2844
|
+
const word = words[index];
|
|
2845
|
+
if (options.trim !== false) {
|
|
2846
|
+
const row = rows.at(-1) ?? "";
|
|
2847
|
+
const trimmed = row.trimStart();
|
|
2848
|
+
if (row.length !== trimmed.length) {
|
|
2849
|
+
rows[rows.length - 1] = trimmed;
|
|
2850
|
+
rowLength = dist_default2(trimmed);
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
if (index !== 0) {
|
|
2854
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
2855
|
+
rows.push("");
|
|
2856
|
+
rowLength = 0;
|
|
2857
|
+
}
|
|
2858
|
+
if (rowLength || options.trim === false) {
|
|
2859
|
+
rows[rows.length - 1] += " ";
|
|
2860
|
+
rowLength++;
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
const wordLength = dist_default2(word);
|
|
2864
|
+
if (options.hard && wordLength > columns) {
|
|
2865
|
+
const remainingColumns = columns - rowLength;
|
|
2866
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
2867
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
2868
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
2869
|
+
rows.push("");
|
|
2870
|
+
}
|
|
2871
|
+
wrapWord(rows, word, columns);
|
|
2872
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
2873
|
+
continue;
|
|
2874
|
+
}
|
|
2875
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
2876
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
2877
|
+
wrapWord(rows, word, columns);
|
|
2878
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
2879
|
+
continue;
|
|
2880
|
+
}
|
|
2881
|
+
rows.push("");
|
|
2882
|
+
rowLength = 0;
|
|
2883
|
+
}
|
|
2884
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
2885
|
+
wrapWord(rows, word, columns);
|
|
2886
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
2887
|
+
continue;
|
|
2888
|
+
}
|
|
2889
|
+
rows[rows.length - 1] += word;
|
|
2890
|
+
rowLength += wordLength;
|
|
2891
|
+
}
|
|
2892
|
+
if (options.trim !== false) {
|
|
2893
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
2894
|
+
}
|
|
2895
|
+
const preString = rows.join("\n");
|
|
2896
|
+
let inSurrogate = false;
|
|
2897
|
+
for (let i = 0; i < preString.length; i++) {
|
|
2898
|
+
const character = preString[i];
|
|
2899
|
+
returnValue += character;
|
|
2900
|
+
if (!inSurrogate) {
|
|
2901
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
2902
|
+
} else {
|
|
2903
|
+
continue;
|
|
2904
|
+
}
|
|
2905
|
+
if (character === ESC || character === CSI) {
|
|
2906
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
2907
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
2908
|
+
const groups = groupsResult?.groups;
|
|
2909
|
+
if (groups?.code !== void 0) {
|
|
2910
|
+
const code = Number.parseFloat(groups.code);
|
|
2911
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
2912
|
+
} else if (groups?.uri !== void 0) {
|
|
2913
|
+
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
if (preString[i + 1] === "\n") {
|
|
2917
|
+
if (escapeUrl) {
|
|
2918
|
+
returnValue += wrapAnsiHyperlink("");
|
|
2919
|
+
}
|
|
2920
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
2921
|
+
if (escapeCode && closingCode) {
|
|
2922
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
2923
|
+
}
|
|
2924
|
+
} else if (character === "\n") {
|
|
2925
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
2926
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
2927
|
+
}
|
|
2928
|
+
if (escapeUrl) {
|
|
2929
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
return returnValue;
|
|
2934
|
+
};
|
|
2935
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
2936
|
+
function wrapAnsi(string, columns, options) {
|
|
2937
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
// ../../node_modules/@clack/core/dist/index.mjs
|
|
2941
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
2942
|
+
var import_node_tty = require("tty");
|
|
2943
|
+
function d(r, t2, e) {
|
|
2944
|
+
if (!e.some((o) => !o.disabled)) return r;
|
|
2945
|
+
const s = r + t2, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
|
|
2946
|
+
return e[n].disabled ? d(n, t2 < 0 ? -1 : 1, e) : n;
|
|
2947
|
+
}
|
|
2948
|
+
var E = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
2949
|
+
var G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
2950
|
+
var u = { actions: new Set(E), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...G], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t2) => `There are only ${r} days in ${t2}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
|
|
2951
|
+
function K(r) {
|
|
2952
|
+
if (r.aliases !== void 0) {
|
|
2953
|
+
const t2 = r.aliases;
|
|
2954
|
+
for (const e in t2) {
|
|
2955
|
+
if (!Object.hasOwn(t2, e)) continue;
|
|
2956
|
+
const s = t2[e];
|
|
2957
|
+
u.actions.has(s) && (u.aliases.has(e) || u.aliases.set(e, s));
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
if (r.messages !== void 0) {
|
|
2961
|
+
const t2 = r.messages;
|
|
2962
|
+
t2.cancel !== void 0 && (u.messages.cancel = t2.cancel), t2.error !== void 0 && (u.messages.error = t2.error);
|
|
2963
|
+
}
|
|
2964
|
+
if (r.withGuide !== void 0 && (u.withGuide = r.withGuide !== false), r.date !== void 0) {
|
|
2965
|
+
const t2 = r.date;
|
|
2966
|
+
t2.monthNames !== void 0 && (u.date.monthNames = [...t2.monthNames]), t2.messages !== void 0 && (t2.messages.required !== void 0 && (u.date.messages.required = t2.messages.required), t2.messages.invalidMonth !== void 0 && (u.date.messages.invalidMonth = t2.messages.invalidMonth), t2.messages.invalidDay !== void 0 && (u.date.messages.invalidDay = t2.messages.invalidDay), t2.messages.afterMin !== void 0 && (u.date.messages.afterMin = t2.messages.afterMin), t2.messages.beforeMax !== void 0 && (u.date.messages.beforeMax = t2.messages.beforeMax));
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
function V(r, t2) {
|
|
2970
|
+
if (typeof r == "string") return u.aliases.get(r) === t2;
|
|
2971
|
+
for (const e of r) if (e !== void 0 && V(e, t2)) return true;
|
|
2972
|
+
return false;
|
|
2973
|
+
}
|
|
2974
|
+
function j(r, t2) {
|
|
2975
|
+
if (r === t2) return;
|
|
2976
|
+
const e = r.split(`
|
|
2977
|
+
`), s = t2.split(`
|
|
2978
|
+
`), i = Math.max(e.length, s.length), n = [];
|
|
2979
|
+
for (let o = 0; o < i; o++) e[o] !== s[o] && n.push(o);
|
|
2980
|
+
return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
|
|
2981
|
+
}
|
|
2982
|
+
var Y = globalThis.process.platform.startsWith("win");
|
|
2983
|
+
var C = /* @__PURE__ */ Symbol("clack:cancel");
|
|
2984
|
+
function q(r) {
|
|
2985
|
+
return r === C;
|
|
2986
|
+
}
|
|
2987
|
+
function w(r, t2) {
|
|
2988
|
+
const e = r;
|
|
2989
|
+
e.isTTY && e.setRawMode(t2);
|
|
2990
|
+
}
|
|
2991
|
+
function z2({ input: r = import_node_process.stdin, output: t2 = import_node_process.stdout, overwrite: e = true, hideCursor: s = true } = {}) {
|
|
2992
|
+
const i = _.createInterface({ input: r, output: t2, prompt: "", tabSize: 1 });
|
|
2993
|
+
_.emitKeypressEvents(r, i), r instanceof import_node_tty.ReadStream && r.isTTY && r.setRawMode(true);
|
|
2994
|
+
const n = (o, { name: a, sequence: h }) => {
|
|
2995
|
+
const l = String(o);
|
|
2996
|
+
if (V([l, a, h], "cancel")) {
|
|
2997
|
+
s && t2.write(import_sisteransi.cursor.show), process.exit(0);
|
|
2998
|
+
return;
|
|
2999
|
+
}
|
|
3000
|
+
if (!e) return;
|
|
3001
|
+
const f = a === "return" ? 0 : -1, v = a === "return" ? -1 : 0;
|
|
3002
|
+
_.moveCursor(t2, f, v, () => {
|
|
3003
|
+
_.clearLine(t2, 1, () => {
|
|
3004
|
+
r.once("keypress", n);
|
|
3005
|
+
});
|
|
3006
|
+
});
|
|
3007
|
+
};
|
|
3008
|
+
return s && t2.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
|
|
3009
|
+
r.off("keypress", n), s && t2.write(import_sisteransi.cursor.show), r instanceof import_node_tty.ReadStream && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
var O = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80;
|
|
3013
|
+
var A = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
|
|
3014
|
+
function R(r, t2, e, s = e) {
|
|
3015
|
+
const i = O(r ?? import_node_process.stdout);
|
|
3016
|
+
return wrapAnsi(t2, i - e.length, { hard: true, trim: false }).split(`
|
|
3017
|
+
`).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
|
|
3018
|
+
`);
|
|
3019
|
+
}
|
|
3020
|
+
var p = class {
|
|
3021
|
+
input;
|
|
3022
|
+
output;
|
|
3023
|
+
_abortSignal;
|
|
3024
|
+
rl;
|
|
3025
|
+
opts;
|
|
3026
|
+
_render;
|
|
3027
|
+
_track = false;
|
|
3028
|
+
_prevFrame = "";
|
|
3029
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
3030
|
+
_cursor = 0;
|
|
3031
|
+
state = "initial";
|
|
3032
|
+
error = "";
|
|
3033
|
+
value;
|
|
3034
|
+
userInput = "";
|
|
3035
|
+
constructor(t2, e = true) {
|
|
3036
|
+
const { input: s = import_node_process.stdin, output: i = import_node_process.stdout, render: n, signal: o, ...a } = t2;
|
|
3037
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = e, this._abortSignal = o, this.input = s, this.output = i;
|
|
3038
|
+
}
|
|
3039
|
+
unsubscribe() {
|
|
3040
|
+
this._subscribers.clear();
|
|
3041
|
+
}
|
|
3042
|
+
setSubscriber(t2, e) {
|
|
3043
|
+
const s = this._subscribers.get(t2) ?? [];
|
|
3044
|
+
s.push(e), this._subscribers.set(t2, s);
|
|
3045
|
+
}
|
|
3046
|
+
on(t2, e) {
|
|
3047
|
+
this.setSubscriber(t2, { cb: e });
|
|
3048
|
+
}
|
|
3049
|
+
once(t2, e) {
|
|
3050
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
3051
|
+
}
|
|
3052
|
+
emit(t2, ...e) {
|
|
3053
|
+
const s = this._subscribers.get(t2) ?? [], i = [];
|
|
3054
|
+
for (const n of s) n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
|
|
3055
|
+
for (const n of i) n();
|
|
3056
|
+
}
|
|
3057
|
+
prompt() {
|
|
3058
|
+
return new Promise((t2) => {
|
|
3059
|
+
if (this._abortSignal) {
|
|
3060
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t2(C);
|
|
3061
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
3062
|
+
this.state = "cancel", this.close();
|
|
3063
|
+
}, { once: true });
|
|
3064
|
+
}
|
|
3065
|
+
this.rl = import_node_readline.default.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
3066
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t2(this.value);
|
|
3067
|
+
}), this.once("cancel", () => {
|
|
3068
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t2(C);
|
|
3069
|
+
});
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
_isActionKey(t2, e) {
|
|
3073
|
+
return t2 === " ";
|
|
3074
|
+
}
|
|
3075
|
+
_setValue(t2) {
|
|
3076
|
+
this.value = t2, this.emit("value", this.value);
|
|
3077
|
+
}
|
|
3078
|
+
_setUserInput(t2, e) {
|
|
3079
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
3080
|
+
}
|
|
3081
|
+
_clearUserInput() {
|
|
3082
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
3083
|
+
}
|
|
3084
|
+
onKeypress(t2, e) {
|
|
3085
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2?.toLowerCase(), e), e?.name === "return") {
|
|
3086
|
+
if (this.opts.validate) {
|
|
3087
|
+
const s = this.opts.validate(this.value);
|
|
3088
|
+
s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
|
|
3089
|
+
}
|
|
3090
|
+
this.state !== "error" && (this.state = "submit");
|
|
3091
|
+
}
|
|
3092
|
+
V([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
3093
|
+
}
|
|
3094
|
+
close() {
|
|
3095
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
3096
|
+
`), w(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
3097
|
+
}
|
|
3098
|
+
restoreCursor() {
|
|
3099
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
3100
|
+
`).length - 1;
|
|
3101
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
3102
|
+
}
|
|
3103
|
+
render() {
|
|
3104
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
3105
|
+
if (t2 !== this._prevFrame) {
|
|
3106
|
+
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
3107
|
+
else {
|
|
3108
|
+
const e = j(this._prevFrame, t2), s = A(this.output);
|
|
3109
|
+
if (this.restoreCursor(), e) {
|
|
3110
|
+
const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
|
|
3111
|
+
let o = e.lines.find((a) => a >= i);
|
|
3112
|
+
if (o === void 0) {
|
|
3113
|
+
this._prevFrame = t2;
|
|
3114
|
+
return;
|
|
3115
|
+
}
|
|
3116
|
+
if (e.lines.length === 1) {
|
|
3117
|
+
this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
3118
|
+
const a = t2.split(`
|
|
3119
|
+
`);
|
|
3120
|
+
this.output.write(a[o]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
|
|
3121
|
+
return;
|
|
3122
|
+
} else if (e.lines.length > 1) {
|
|
3123
|
+
if (i < n) o = i;
|
|
3124
|
+
else {
|
|
3125
|
+
const h = o - n;
|
|
3126
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
3127
|
+
}
|
|
3128
|
+
this.output.write(import_sisteransi.erase.down());
|
|
3129
|
+
const a = t2.split(`
|
|
3130
|
+
`).slice(o);
|
|
3131
|
+
this.output.write(a.join(`
|
|
3132
|
+
`)), this._prevFrame = t2;
|
|
3133
|
+
return;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
this.output.write(import_sisteransi.erase.down());
|
|
3137
|
+
}
|
|
3138
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
function W(r, t2) {
|
|
3143
|
+
if (r === void 0 || t2.length === 0) return 0;
|
|
3144
|
+
const e = t2.findIndex((s) => s.value === r);
|
|
3145
|
+
return e !== -1 ? e : 0;
|
|
3146
|
+
}
|
|
3147
|
+
function B(r, t2) {
|
|
3148
|
+
return (t2.label ?? String(t2.value)).toLowerCase().includes(r.toLowerCase());
|
|
3149
|
+
}
|
|
3150
|
+
function J(r, t2) {
|
|
3151
|
+
if (t2) return r ? t2 : t2[0];
|
|
3152
|
+
}
|
|
3153
|
+
var H = class extends p {
|
|
3154
|
+
filteredOptions;
|
|
3155
|
+
multiple;
|
|
3156
|
+
isNavigating = false;
|
|
3157
|
+
selectedValues = [];
|
|
3158
|
+
focusedValue;
|
|
3159
|
+
#e = 0;
|
|
3160
|
+
#o = "";
|
|
3161
|
+
#t;
|
|
3162
|
+
#n;
|
|
3163
|
+
#a;
|
|
3164
|
+
get cursor() {
|
|
3165
|
+
return this.#e;
|
|
3166
|
+
}
|
|
3167
|
+
get userInputWithCursor() {
|
|
3168
|
+
if (!this.userInput) return (0, import_node_util.styleText)(["inverse", "hidden"], "_");
|
|
3169
|
+
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
3170
|
+
const t2 = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
|
|
3171
|
+
return `${t2}${(0, import_node_util.styleText)("inverse", e)}${s.join("")}`;
|
|
3172
|
+
}
|
|
3173
|
+
get options() {
|
|
3174
|
+
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
3175
|
+
}
|
|
3176
|
+
constructor(t2) {
|
|
3177
|
+
super(t2), this.#n = t2.options, this.#a = t2.placeholder;
|
|
3178
|
+
const e = this.options;
|
|
3179
|
+
this.filteredOptions = [...e], this.multiple = t2.multiple === true, this.#t = typeof t2.options == "function" ? t2.filter : t2.filter ?? B;
|
|
3180
|
+
let s;
|
|
3181
|
+
if (t2.initialValue && Array.isArray(t2.initialValue) ? this.multiple ? s = t2.initialValue : s = t2.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s) for (const i of s) {
|
|
3182
|
+
const n = e.findIndex((o) => o.value === i);
|
|
3183
|
+
n !== -1 && (this.toggleSelected(i), this.#e = n);
|
|
3184
|
+
}
|
|
3185
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
3186
|
+
}
|
|
3187
|
+
_isActionKey(t2, e) {
|
|
3188
|
+
return t2 === " " || this.multiple && this.isNavigating && e.name === "space" && t2 !== void 0 && t2 !== "";
|
|
3189
|
+
}
|
|
3190
|
+
#s(t2, e) {
|
|
3191
|
+
const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === " ", a = this.#a, h = this.options, l = a !== void 0 && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : true));
|
|
3192
|
+
if (e.name === "tab" && o && l) {
|
|
3193
|
+
this.userInput === " " && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
|
|
3194
|
+
return;
|
|
3195
|
+
}
|
|
3196
|
+
s || i ? (this.#e = d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
3197
|
+
}
|
|
3198
|
+
deselectAll() {
|
|
3199
|
+
this.selectedValues = [];
|
|
3200
|
+
}
|
|
3201
|
+
toggleSelected(t2) {
|
|
3202
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t2) ? this.selectedValues = this.selectedValues.filter((e) => e !== t2) : this.selectedValues = [...this.selectedValues, t2] : this.selectedValues = [t2]);
|
|
3203
|
+
}
|
|
3204
|
+
#i(t2) {
|
|
3205
|
+
if (t2 !== this.#o) {
|
|
3206
|
+
this.#o = t2;
|
|
3207
|
+
const e = this.options;
|
|
3208
|
+
t2 && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t2, n)) : this.filteredOptions = [...e];
|
|
3209
|
+
const s = W(this.focusedValue, this.filteredOptions);
|
|
3210
|
+
this.#e = d(s, 0, this.filteredOptions);
|
|
3211
|
+
const i = this.filteredOptions[this.#e];
|
|
3212
|
+
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
var Q = class extends p {
|
|
3217
|
+
get cursor() {
|
|
3218
|
+
return this.value ? 0 : 1;
|
|
3219
|
+
}
|
|
3220
|
+
get _value() {
|
|
3221
|
+
return this.cursor === 0;
|
|
3222
|
+
}
|
|
3223
|
+
constructor(t2) {
|
|
3224
|
+
super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
|
|
3225
|
+
this.value = this._value;
|
|
3226
|
+
}), this.on("confirm", (e) => {
|
|
3227
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = e, this.state = "submit", this.close();
|
|
3228
|
+
}), this.on("cursor", () => {
|
|
3229
|
+
this.value = !this.value;
|
|
3230
|
+
});
|
|
3231
|
+
}
|
|
3232
|
+
};
|
|
3233
|
+
var X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
3234
|
+
function L(r) {
|
|
3235
|
+
return [...r].map((t2) => X[t2]);
|
|
3236
|
+
}
|
|
3237
|
+
function Z(r) {
|
|
3238
|
+
const t2 = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2e3, 0, 15)), e = [];
|
|
3239
|
+
let s = "/";
|
|
3240
|
+
for (const i of t2) i.type === "literal" ? s = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && e.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
|
|
3241
|
+
return { segments: e, separator: s };
|
|
3242
|
+
}
|
|
3243
|
+
function k(r) {
|
|
3244
|
+
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
3245
|
+
}
|
|
3246
|
+
function I(r) {
|
|
3247
|
+
return { year: k(r.year), month: k(r.month), day: k(r.day) };
|
|
3248
|
+
}
|
|
3249
|
+
function T(r, t2) {
|
|
3250
|
+
return new Date(r || 2001, t2 || 1, 0).getDate();
|
|
3251
|
+
}
|
|
3252
|
+
function F(r) {
|
|
3253
|
+
const { year: t2, month: e, day: s } = I(r);
|
|
3254
|
+
if (!t2 || t2 < 0 || t2 > 9999 || !e || e < 1 || e > 12 || !s || s < 1) return;
|
|
3255
|
+
const i = new Date(Date.UTC(t2, e - 1, s));
|
|
3256
|
+
if (!(i.getUTCFullYear() !== t2 || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s)) return { year: t2, month: e, day: s };
|
|
3257
|
+
}
|
|
3258
|
+
function N(r) {
|
|
3259
|
+
const t2 = F(r);
|
|
3260
|
+
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : void 0;
|
|
3261
|
+
}
|
|
3262
|
+
function tt(r, t2, e, s) {
|
|
3263
|
+
const i = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null, n = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null;
|
|
3264
|
+
return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t2.year === i.year ? i.month : 1, max: n && t2.year === n.year ? n.month : 12 } : { min: i && t2.year === i.year && t2.month === i.month ? i.day : 1, max: n && t2.year === n.year && t2.month === n.month ? n.day : T(t2.year, t2.month) };
|
|
3265
|
+
}
|
|
3266
|
+
var et = class extends p {
|
|
3267
|
+
#e;
|
|
3268
|
+
#o;
|
|
3269
|
+
#t;
|
|
3270
|
+
#n;
|
|
3271
|
+
#a;
|
|
3272
|
+
#s = { segmentIndex: 0, positionInSegment: 0 };
|
|
3273
|
+
#i = true;
|
|
3274
|
+
#r = null;
|
|
3275
|
+
inlineError = "";
|
|
3276
|
+
get segmentCursor() {
|
|
3277
|
+
return { ...this.#s };
|
|
3278
|
+
}
|
|
3279
|
+
get segmentValues() {
|
|
3280
|
+
return { ...this.#t };
|
|
3281
|
+
}
|
|
3282
|
+
get segments() {
|
|
3283
|
+
return this.#e;
|
|
3284
|
+
}
|
|
3285
|
+
get separator() {
|
|
3286
|
+
return this.#o;
|
|
3287
|
+
}
|
|
3288
|
+
get formattedValue() {
|
|
3289
|
+
return this.#c(this.#t);
|
|
3290
|
+
}
|
|
3291
|
+
#c(t2) {
|
|
3292
|
+
return this.#e.map((e) => t2[e.type]).join(this.#o);
|
|
3293
|
+
}
|
|
3294
|
+
#h() {
|
|
3295
|
+
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? void 0);
|
|
3296
|
+
}
|
|
3297
|
+
constructor(t2) {
|
|
3298
|
+
const e = t2.format ? { segments: L(t2.format), separator: t2.separator ?? "/" } : Z(t2.locale), s = t2.separator ?? e.separator, i = t2.format ? L(t2.format) : e.segments, n = t2.initialValue ?? t2.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, a = i.map((h) => o[h.type]).join(s);
|
|
3299
|
+
super({ ...t2, initialUserInput: a }, false), this.#e = i, this.#o = s, this.#t = o, this.#n = t2.minDate, this.#a = t2.maxDate, this.#h(), this.on("cursor", (h) => this.#d(h)), this.on("key", (h, l) => this.#f(h, l)), this.on("finalize", () => this.#g(t2));
|
|
3300
|
+
}
|
|
3301
|
+
#u() {
|
|
3302
|
+
const t2 = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t2];
|
|
3303
|
+
if (e) return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t2 };
|
|
3304
|
+
}
|
|
3305
|
+
#l(t2) {
|
|
3306
|
+
this.inlineError = "", this.#r = null;
|
|
3307
|
+
const e = this.#u();
|
|
3308
|
+
e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t2)), this.#s.positionInSegment = 0, this.#i = true);
|
|
3309
|
+
}
|
|
3310
|
+
#p(t2) {
|
|
3311
|
+
const e = this.#u();
|
|
3312
|
+
if (!e) return;
|
|
3313
|
+
const { segment: s } = e, i = this.#t[s.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, a = tt(s.type, I(this.#t), this.#n, this.#a);
|
|
3314
|
+
let h;
|
|
3315
|
+
n ? h = t2 === 1 ? a.min : a.max : h = Math.max(Math.min(a.max, o + t2), a.min), this.#t = { ...this.#t, [s.type]: h.toString().padStart(s.len, "0") }, this.#i = true, this.#r = null, this.#h();
|
|
3316
|
+
}
|
|
3317
|
+
#d(t2) {
|
|
3318
|
+
if (t2) switch (t2) {
|
|
3319
|
+
case "right":
|
|
3320
|
+
return this.#l(1);
|
|
3321
|
+
case "left":
|
|
3322
|
+
return this.#l(-1);
|
|
3323
|
+
case "up":
|
|
3324
|
+
return this.#p(1);
|
|
3325
|
+
case "down":
|
|
3326
|
+
return this.#p(-1);
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
#f(t2, e) {
|
|
3330
|
+
if (e?.name === "backspace" || e?.sequence === "\x7F" || e?.sequence === "\b" || t2 === "\x7F" || t2 === "\b") {
|
|
3331
|
+
this.inlineError = "";
|
|
3332
|
+
const s = this.#u();
|
|
3333
|
+
if (!s) return;
|
|
3334
|
+
if (!this.#t[s.segment.type].replace(/_/g, "")) {
|
|
3335
|
+
this.#l(-1);
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
|
|
3339
|
+
return;
|
|
3340
|
+
}
|
|
3341
|
+
if (e?.name === "tab") {
|
|
3342
|
+
this.inlineError = "";
|
|
3343
|
+
const s = this.#u();
|
|
3344
|
+
if (!s) return;
|
|
3345
|
+
const i = e.shift ? -1 : 1, n = s.index + i;
|
|
3346
|
+
n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
|
|
3347
|
+
return;
|
|
3348
|
+
}
|
|
3349
|
+
if (t2 && /^[0-9]$/.test(t2)) {
|
|
3350
|
+
const s = this.#u();
|
|
3351
|
+
if (!s) return;
|
|
3352
|
+
const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
|
|
3353
|
+
if (this.#i && this.#r !== null && !n) {
|
|
3354
|
+
const m = this.#r + t2, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
|
|
3355
|
+
if (b) {
|
|
3356
|
+
this.inlineError = b, this.#r = null, this.#i = false;
|
|
3357
|
+
return;
|
|
3358
|
+
}
|
|
3359
|
+
this.inlineError = "", this.#t[i.type] = m, this.#r = null, this.#i = false, this.#h(), s.index < this.#e.length - 1 && (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true);
|
|
3360
|
+
return;
|
|
3361
|
+
}
|
|
3362
|
+
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
|
|
3363
|
+
const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
|
|
3364
|
+
if (h < 0 || h >= i.len) return;
|
|
3365
|
+
let l = o.slice(0, h) + t2 + o.slice(h + 1), f = false;
|
|
3366
|
+
if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
|
|
3367
|
+
const m = Number.parseInt(t2, 10);
|
|
3368
|
+
l = `0${t2}`, f = m <= (i.type === "month" ? 1 : 2);
|
|
3369
|
+
}
|
|
3370
|
+
if (i.type === "year" && (l = (o.replace(/_/g, "") + t2).padStart(i.len, "_")), !l.includes("_")) {
|
|
3371
|
+
const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
|
|
3372
|
+
if (g) {
|
|
3373
|
+
this.inlineError = g;
|
|
3374
|
+
return;
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
this.inlineError = "", this.#t[i.type] = l;
|
|
3378
|
+
const v = l.includes("_") ? void 0 : F(this.#t);
|
|
3379
|
+
if (v) {
|
|
3380
|
+
const { year: m, month: g } = v, b = T(m, g);
|
|
3381
|
+
this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(b, v.day))).padStart(2, "0") };
|
|
3382
|
+
}
|
|
3383
|
+
this.#h();
|
|
3384
|
+
const U2 = l.indexOf("_");
|
|
3385
|
+
f ? (this.#i = true, this.#r = t2) : U2 >= 0 ? this.#s.positionInSegment = U2 : a >= 0 && s.index < this.#e.length - 1 ? (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true) : this.#s.positionInSegment = Math.min(h + 1, i.len - 1);
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
#m(t2, e) {
|
|
3389
|
+
const { month: s, day: i } = I(t2);
|
|
3390
|
+
if (e.type === "month" && (s < 0 || s > 12)) return u.date.messages.invalidMonth;
|
|
3391
|
+
if (e.type === "day" && (i < 0 || i > 31)) return u.date.messages.invalidDay(31, "any month");
|
|
3392
|
+
}
|
|
3393
|
+
#g(t2) {
|
|
3394
|
+
const { year: e, month: s, day: i } = I(this.#t);
|
|
3395
|
+
if (e && s && i) {
|
|
3396
|
+
const n = T(e, s);
|
|
3397
|
+
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
3398
|
+
}
|
|
3399
|
+
this.value = N(this.#t) ?? t2.defaultValue ?? void 0;
|
|
3400
|
+
}
|
|
3401
|
+
};
|
|
3402
|
+
var st = class extends p {
|
|
3403
|
+
options;
|
|
3404
|
+
cursor = 0;
|
|
3405
|
+
#e;
|
|
3406
|
+
getGroupItems(t2) {
|
|
3407
|
+
return this.options.filter((e) => e.group === t2);
|
|
3408
|
+
}
|
|
3409
|
+
isGroupSelected(t2) {
|
|
3410
|
+
const e = this.getGroupItems(t2), s = this.value;
|
|
3411
|
+
return s === void 0 ? false : e.every((i) => s.includes(i.value));
|
|
3412
|
+
}
|
|
3413
|
+
toggleValue() {
|
|
3414
|
+
const t2 = this.options[this.cursor];
|
|
3415
|
+
if (this.value === void 0 && (this.value = []), t2.group === true) {
|
|
3416
|
+
const e = t2.value, s = this.getGroupItems(e);
|
|
3417
|
+
this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
|
|
3418
|
+
} else {
|
|
3419
|
+
const e = this.value.includes(t2.value);
|
|
3420
|
+
this.value = e ? this.value.filter((s) => s !== t2.value) : [...this.value, t2.value];
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
constructor(t2) {
|
|
3424
|
+
super(t2, false);
|
|
3425
|
+
const { options: e } = t2;
|
|
3426
|
+
this.#e = t2.selectableGroups !== false, this.options = Object.entries(e).flatMap(([s, i]) => [{ value: s, group: true, label: s }, ...i.map((n) => ({ ...n, group: s }))]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t2.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
|
|
3427
|
+
switch (s) {
|
|
3428
|
+
case "left":
|
|
3429
|
+
case "up": {
|
|
3430
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
3431
|
+
const i = this.options[this.cursor]?.group === true;
|
|
3432
|
+
!this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
3433
|
+
break;
|
|
3434
|
+
}
|
|
3435
|
+
case "down":
|
|
3436
|
+
case "right": {
|
|
3437
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
3438
|
+
const i = this.options[this.cursor]?.group === true;
|
|
3439
|
+
!this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
3440
|
+
break;
|
|
3441
|
+
}
|
|
3442
|
+
case "space":
|
|
3443
|
+
this.toggleValue();
|
|
3444
|
+
break;
|
|
3445
|
+
}
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3448
|
+
};
|
|
3449
|
+
var it = class extends p {
|
|
3450
|
+
options;
|
|
3451
|
+
cursor = 0;
|
|
3452
|
+
get _value() {
|
|
3453
|
+
return this.options[this.cursor].value;
|
|
3454
|
+
}
|
|
3455
|
+
get _enabledOptions() {
|
|
3456
|
+
return this.options.filter((t2) => t2.disabled !== true);
|
|
3457
|
+
}
|
|
3458
|
+
toggleAll() {
|
|
3459
|
+
const t2 = this._enabledOptions, e = this.value !== void 0 && this.value.length === t2.length;
|
|
3460
|
+
this.value = e ? [] : t2.map((s) => s.value);
|
|
3461
|
+
}
|
|
3462
|
+
toggleInvert() {
|
|
3463
|
+
const t2 = this.value;
|
|
3464
|
+
if (!t2) return;
|
|
3465
|
+
const e = this._enabledOptions.filter((s) => !t2.includes(s.value));
|
|
3466
|
+
this.value = e.map((s) => s.value);
|
|
3467
|
+
}
|
|
3468
|
+
toggleValue() {
|
|
3469
|
+
this.value === void 0 && (this.value = []);
|
|
3470
|
+
const t2 = this.value.includes(this._value);
|
|
3471
|
+
this.value = t2 ? this.value.filter((e) => e !== this._value) : [...this.value, this._value];
|
|
3472
|
+
}
|
|
3473
|
+
constructor(t2) {
|
|
3474
|
+
super(t2, false), this.options = t2.options, this.value = [...t2.initialValues ?? []];
|
|
3475
|
+
const e = Math.max(this.options.findIndex(({ value: s }) => s === t2.cursorAt), 0);
|
|
3476
|
+
this.cursor = this.options[e].disabled ? d(e, 1, this.options) : e, this.on("key", (s) => {
|
|
3477
|
+
s === "a" && this.toggleAll(), s === "i" && this.toggleInvert();
|
|
3478
|
+
}), this.on("cursor", (s) => {
|
|
3479
|
+
switch (s) {
|
|
3480
|
+
case "left":
|
|
3481
|
+
case "up":
|
|
3482
|
+
this.cursor = d(this.cursor, -1, this.options);
|
|
3483
|
+
break;
|
|
3484
|
+
case "down":
|
|
3485
|
+
case "right":
|
|
3486
|
+
this.cursor = d(this.cursor, 1, this.options);
|
|
3487
|
+
break;
|
|
3488
|
+
case "space":
|
|
3489
|
+
this.toggleValue();
|
|
3490
|
+
break;
|
|
3491
|
+
}
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
};
|
|
3495
|
+
var rt = class extends p {
|
|
3496
|
+
_mask = "\u2022";
|
|
3497
|
+
get cursor() {
|
|
3498
|
+
return this._cursor;
|
|
3499
|
+
}
|
|
3500
|
+
get masked() {
|
|
3501
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
3502
|
+
}
|
|
3503
|
+
get userInputWithCursor() {
|
|
3504
|
+
if (this.state === "submit" || this.state === "cancel") return this.masked;
|
|
3505
|
+
const t2 = this.userInput;
|
|
3506
|
+
if (this.cursor >= t2.length) return `${this.masked}${(0, import_node_util.styleText)(["inverse", "hidden"], "_")}`;
|
|
3507
|
+
const e = this.masked, s = e.slice(0, this.cursor), i = e.slice(this.cursor);
|
|
3508
|
+
return `${s}${(0, import_node_util.styleText)("inverse", i[0])}${i.slice(1)}`;
|
|
3509
|
+
}
|
|
3510
|
+
clear() {
|
|
3511
|
+
this._clearUserInput();
|
|
3512
|
+
}
|
|
3513
|
+
constructor({ mask: t2, ...e }) {
|
|
3514
|
+
super(e), this._mask = t2 ?? "\u2022", this.on("userInput", (s) => {
|
|
3515
|
+
this._setValue(s);
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3518
|
+
};
|
|
3519
|
+
var nt = class extends p {
|
|
3520
|
+
options;
|
|
3521
|
+
cursor = 0;
|
|
3522
|
+
get _selectedValue() {
|
|
3523
|
+
return this.options[this.cursor];
|
|
3524
|
+
}
|
|
3525
|
+
changeValue() {
|
|
3526
|
+
this.value = this._selectedValue.value;
|
|
3527
|
+
}
|
|
3528
|
+
constructor(t2) {
|
|
3529
|
+
super(t2, false), this.options = t2.options;
|
|
3530
|
+
const e = this.options.findIndex(({ value: i }) => i === t2.initialValue), s = e === -1 ? 0 : e;
|
|
3531
|
+
this.cursor = this.options[s].disabled ? d(s, 1, this.options) : s, this.changeValue(), this.on("cursor", (i) => {
|
|
3532
|
+
switch (i) {
|
|
3533
|
+
case "left":
|
|
3534
|
+
case "up":
|
|
3535
|
+
this.cursor = d(this.cursor, -1, this.options);
|
|
3536
|
+
break;
|
|
3537
|
+
case "down":
|
|
3538
|
+
case "right":
|
|
3539
|
+
this.cursor = d(this.cursor, 1, this.options);
|
|
3540
|
+
break;
|
|
3541
|
+
}
|
|
3542
|
+
this.changeValue();
|
|
3543
|
+
});
|
|
3544
|
+
}
|
|
3545
|
+
};
|
|
3546
|
+
var ot = class extends p {
|
|
3547
|
+
options;
|
|
3548
|
+
cursor = 0;
|
|
3549
|
+
constructor(t2) {
|
|
3550
|
+
super(t2, false), this.options = t2.options;
|
|
3551
|
+
const e = t2.caseSensitive === true, s = this.options.map(({ value: [i] }) => e ? i : i?.toLowerCase());
|
|
3552
|
+
this.cursor = Math.max(s.indexOf(t2.initialValue), 0), this.on("key", (i, n) => {
|
|
3553
|
+
if (!i) return;
|
|
3554
|
+
const o = e && n.shift ? i.toUpperCase() : i;
|
|
3555
|
+
if (!s.includes(o)) return;
|
|
3556
|
+
const a = this.options.find(({ value: [h] }) => e ? h === o : h?.toLowerCase() === i);
|
|
3557
|
+
a && (this.value = a.value, this.state = "submit", this.emit("submit"));
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3560
|
+
};
|
|
3561
|
+
var at = class extends p {
|
|
3562
|
+
get userInputWithCursor() {
|
|
3563
|
+
if (this.state === "submit") return this.userInput;
|
|
3564
|
+
const t2 = this.userInput;
|
|
3565
|
+
if (this.cursor >= t2.length) return `${this.userInput}\u2588`;
|
|
3566
|
+
const e = t2.slice(0, this.cursor), [s, ...i] = t2.slice(this.cursor);
|
|
3567
|
+
return `${e}${(0, import_node_util.styleText)("inverse", s)}${i.join("")}`;
|
|
3568
|
+
}
|
|
3569
|
+
get cursor() {
|
|
3570
|
+
return this._cursor;
|
|
3571
|
+
}
|
|
3572
|
+
constructor(t2) {
|
|
3573
|
+
super({ ...t2, initialUserInput: t2.initialUserInput ?? t2.initialValue }), this.on("userInput", (e) => {
|
|
3574
|
+
this._setValue(e);
|
|
3575
|
+
}), this.on("finalize", () => {
|
|
3576
|
+
this.value || (this.value = t2.defaultValue), this.value === void 0 && (this.value = "");
|
|
3577
|
+
});
|
|
3578
|
+
}
|
|
3579
|
+
};
|
|
3580
|
+
|
|
3581
|
+
// ../../node_modules/@clack/prompts/dist/index.mjs
|
|
3582
|
+
var import_node_util2 = require("util");
|
|
3583
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
3584
|
+
var import_node_fs = require("fs");
|
|
3585
|
+
var import_node_path = require("path");
|
|
3586
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
3587
|
+
function Ze() {
|
|
3588
|
+
return import_node_process2.default.platform !== "win32" ? import_node_process2.default.env.TERM !== "linux" : !!import_node_process2.default.env.CI || !!import_node_process2.default.env.WT_SESSION || !!import_node_process2.default.env.TERMINUS_SUBLIME || import_node_process2.default.env.ConEmuTask === "{cmd::Cmder}" || import_node_process2.default.env.TERM_PROGRAM === "Terminus-Sublime" || import_node_process2.default.env.TERM_PROGRAM === "vscode" || import_node_process2.default.env.TERM === "xterm-256color" || import_node_process2.default.env.TERM === "alacritty" || import_node_process2.default.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
3589
|
+
}
|
|
3590
|
+
var ee = Ze();
|
|
3591
|
+
var ae = () => process.env.CI === "true";
|
|
3592
|
+
var Te = (e) => e.isTTY === true;
|
|
3593
|
+
var w2 = (e, i) => ee ? e : i;
|
|
3594
|
+
var _e = w2("\u25C6", "*");
|
|
3595
|
+
var oe = w2("\u25A0", "x");
|
|
3596
|
+
var ue = w2("\u25B2", "x");
|
|
3597
|
+
var F2 = w2("\u25C7", "o");
|
|
3598
|
+
var le = w2("\u250C", "T");
|
|
3599
|
+
var d2 = w2("\u2502", "|");
|
|
3600
|
+
var E2 = w2("\u2514", "\u2014");
|
|
3601
|
+
var Ie = w2("\u2510", "T");
|
|
3602
|
+
var Ee = w2("\u2518", "\u2014");
|
|
3603
|
+
var z3 = w2("\u25CF", ">");
|
|
3604
|
+
var H2 = w2("\u25CB", " ");
|
|
3605
|
+
var te = w2("\u25FB", "[\u2022]");
|
|
3606
|
+
var U = w2("\u25FC", "[+]");
|
|
3607
|
+
var J2 = w2("\u25FB", "[ ]");
|
|
3608
|
+
var xe = w2("\u25AA", "\u2022");
|
|
3609
|
+
var se = w2("\u2500", "-");
|
|
3610
|
+
var ce = w2("\u256E", "+");
|
|
3611
|
+
var Ge = w2("\u251C", "+");
|
|
3612
|
+
var $e = w2("\u256F", "+");
|
|
3613
|
+
var de = w2("\u2570", "+");
|
|
3614
|
+
var Oe = w2("\u256D", "+");
|
|
3615
|
+
var he = w2("\u25CF", "\u2022");
|
|
3616
|
+
var pe = w2("\u25C6", "*");
|
|
3617
|
+
var me = w2("\u25B2", "!");
|
|
3618
|
+
var ge = w2("\u25A0", "x");
|
|
3619
|
+
var V2 = (e) => {
|
|
3620
|
+
switch (e) {
|
|
3621
|
+
case "initial":
|
|
3622
|
+
case "active":
|
|
3623
|
+
return (0, import_node_util2.styleText)("cyan", _e);
|
|
3624
|
+
case "cancel":
|
|
3625
|
+
return (0, import_node_util2.styleText)("red", oe);
|
|
3626
|
+
case "error":
|
|
3627
|
+
return (0, import_node_util2.styleText)("yellow", ue);
|
|
3628
|
+
case "submit":
|
|
3629
|
+
return (0, import_node_util2.styleText)("green", F2);
|
|
3630
|
+
}
|
|
3631
|
+
};
|
|
3632
|
+
var ye = (e) => {
|
|
3633
|
+
switch (e) {
|
|
3634
|
+
case "initial":
|
|
3635
|
+
case "active":
|
|
3636
|
+
return (0, import_node_util2.styleText)("cyan", d2);
|
|
3637
|
+
case "cancel":
|
|
3638
|
+
return (0, import_node_util2.styleText)("red", d2);
|
|
3639
|
+
case "error":
|
|
3640
|
+
return (0, import_node_util2.styleText)("yellow", d2);
|
|
3641
|
+
case "submit":
|
|
3642
|
+
return (0, import_node_util2.styleText)("green", d2);
|
|
3643
|
+
}
|
|
3644
|
+
};
|
|
3645
|
+
var et2 = (e, i, s, r, u2) => {
|
|
3646
|
+
let n = i, o = 0;
|
|
3647
|
+
for (let c2 = s; c2 < r; c2++) {
|
|
3648
|
+
const a = e[c2];
|
|
3649
|
+
if (n = n - a.length, o++, n <= u2) break;
|
|
3650
|
+
}
|
|
3651
|
+
return { lineCount: n, removals: o };
|
|
3652
|
+
};
|
|
3653
|
+
var Y2 = ({ cursor: e, options: i, style: s, output: r = process.stdout, maxItems: u2 = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
|
|
3654
|
+
const c2 = O(r) - n, a = A(r), l = (0, import_node_util2.styleText)("dim", "..."), $2 = Math.max(a - o, 0), y2 = Math.max(Math.min(u2, $2), 5);
|
|
3655
|
+
let p2 = 0;
|
|
3656
|
+
e >= y2 - 3 && (p2 = Math.max(Math.min(e - y2 + 3, i.length - y2), 0));
|
|
3657
|
+
let m = y2 < i.length && p2 > 0, g = y2 < i.length && p2 + y2 < i.length;
|
|
3658
|
+
const S2 = Math.min(p2 + y2, i.length), h = [];
|
|
3659
|
+
let f = 0;
|
|
3660
|
+
m && f++, g && f++;
|
|
3661
|
+
const v = p2 + (m ? 1 : 0), T2 = S2 - (g ? 1 : 0);
|
|
3662
|
+
for (let b = v; b < T2; b++) {
|
|
3663
|
+
const x = wrapAnsi(s(i[b], b === e), c2, { hard: true, trim: false }).split(`
|
|
3664
|
+
`);
|
|
3665
|
+
h.push(x), f += x.length;
|
|
3666
|
+
}
|
|
3667
|
+
if (f > $2) {
|
|
3668
|
+
let b = 0, x = 0, G2 = f;
|
|
3669
|
+
const M2 = e - v, R2 = (j2, D2) => et2(h, G2, j2, D2, $2);
|
|
3670
|
+
m ? ({ lineCount: G2, removals: b } = R2(0, M2), G2 > $2 && ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length))) : ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length), G2 > $2 && ({ lineCount: G2, removals: b } = R2(0, M2))), b > 0 && (m = true, h.splice(0, b)), x > 0 && (g = true, h.splice(h.length - x, x));
|
|
3671
|
+
}
|
|
3672
|
+
const C2 = [];
|
|
3673
|
+
m && C2.push(l);
|
|
3674
|
+
for (const b of h) for (const x of b) C2.push(x);
|
|
3675
|
+
return g && C2.push(l), C2;
|
|
3676
|
+
};
|
|
3677
|
+
function Me(e) {
|
|
3678
|
+
return e.label ?? String(e.value ?? "");
|
|
3679
|
+
}
|
|
3680
|
+
function Re(e, i) {
|
|
3681
|
+
if (!e) return true;
|
|
3682
|
+
const s = (i.label ?? String(i.value ?? "")).toLowerCase(), r = (i.hint ?? "").toLowerCase(), u2 = String(i.value).toLowerCase(), n = e.toLowerCase();
|
|
3683
|
+
return s.includes(n) || r.includes(n) || u2.includes(n);
|
|
3684
|
+
}
|
|
3685
|
+
function tt2(e, i) {
|
|
3686
|
+
const s = [];
|
|
3687
|
+
for (const r of i) e.includes(r.value) && s.push(r);
|
|
3688
|
+
return s;
|
|
3689
|
+
}
|
|
3690
|
+
var Ae = (e) => new H({ options: e.options, initialValue: e.initialValue ? [e.initialValue] : void 0, initialUserInput: e.initialUserInput, placeholder: e.placeholder, filter: e.filter ?? ((i, s) => Re(i, s)), signal: e.signal, input: e.input, output: e.output, validate: e.validate, render() {
|
|
3691
|
+
const i = e.withGuide ?? u.withGuide, s = i ? [`${(0, import_node_util2.styleText)("gray", d2)}`, `${V2(this.state)} ${e.message}`] : [`${V2(this.state)} ${e.message}`], r = this.userInput, u2 = this.options, n = e.placeholder, o = r === "" && n !== void 0, c2 = (a, l) => {
|
|
3692
|
+
const $2 = Me(a), y2 = a.hint && a.value === this.focusedValue ? (0, import_node_util2.styleText)("dim", ` (${a.hint})`) : "";
|
|
3693
|
+
switch (l) {
|
|
3694
|
+
case "active":
|
|
3695
|
+
return `${(0, import_node_util2.styleText)("green", z3)} ${$2}${y2}`;
|
|
3696
|
+
case "inactive":
|
|
3697
|
+
return `${(0, import_node_util2.styleText)("dim", H2)} ${(0, import_node_util2.styleText)("dim", $2)}`;
|
|
3698
|
+
case "disabled":
|
|
3699
|
+
return `${(0, import_node_util2.styleText)("gray", H2)} ${(0, import_node_util2.styleText)(["strikethrough", "gray"], $2)}`;
|
|
3700
|
+
}
|
|
3701
|
+
};
|
|
3702
|
+
switch (this.state) {
|
|
3703
|
+
case "submit": {
|
|
3704
|
+
const a = tt2(this.selectedValues, u2), l = a.length > 0 ? ` ${(0, import_node_util2.styleText)("dim", a.map(Me).join(", "))}` : "", $2 = i ? (0, import_node_util2.styleText)("gray", d2) : "";
|
|
3705
|
+
return `${s.join(`
|
|
3706
|
+
`)}
|
|
3707
|
+
${$2}${l}`;
|
|
3708
|
+
}
|
|
3709
|
+
case "cancel": {
|
|
3710
|
+
const a = r ? ` ${(0, import_node_util2.styleText)(["strikethrough", "dim"], r)}` : "", l = i ? (0, import_node_util2.styleText)("gray", d2) : "";
|
|
3711
|
+
return `${s.join(`
|
|
3712
|
+
`)}
|
|
3713
|
+
${l}${a}`;
|
|
3714
|
+
}
|
|
3715
|
+
default: {
|
|
3716
|
+
const a = this.state === "error" ? "yellow" : "cyan", l = i ? `${(0, import_node_util2.styleText)(a, d2)} ` : "", $2 = i ? (0, import_node_util2.styleText)(a, E2) : "";
|
|
3717
|
+
let y2 = "";
|
|
3718
|
+
if (this.isNavigating || o) {
|
|
3719
|
+
const v = o ? n : r;
|
|
3720
|
+
y2 = v !== "" ? ` ${(0, import_node_util2.styleText)("dim", v)}` : "";
|
|
3721
|
+
} else y2 = ` ${this.userInputWithCursor}`;
|
|
3722
|
+
const p2 = this.filteredOptions.length !== u2.length ? (0, import_node_util2.styleText)("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", m = this.filteredOptions.length === 0 && r ? [`${l}${(0, import_node_util2.styleText)("yellow", "No matches found")}`] : [], g = this.state === "error" ? [`${l}${(0, import_node_util2.styleText)("yellow", this.error)}`] : [];
|
|
3723
|
+
i && s.push(`${l.trimEnd()}`), s.push(`${l}${(0, import_node_util2.styleText)("dim", "Search:")}${y2}${p2}`, ...m, ...g);
|
|
3724
|
+
const S2 = [`${(0, import_node_util2.styleText)("dim", "\u2191/\u2193")} to select`, `${(0, import_node_util2.styleText)("dim", "Enter:")} confirm`, `${(0, import_node_util2.styleText)("dim", "Type:")} to search`], h = [`${l}${S2.join(" \u2022 ")}`, $2], f = this.filteredOptions.length === 0 ? [] : Y2({ cursor: this.cursor, options: this.filteredOptions, columnPadding: i ? 3 : 0, rowPadding: s.length + h.length, style: (v, T2) => c2(v, v.disabled ? "disabled" : T2 ? "active" : "inactive"), maxItems: e.maxItems, output: e.output });
|
|
3725
|
+
return [...s, ...f.map((v) => `${l}${v}`), ...h].join(`
|
|
3726
|
+
`);
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
} }).prompt();
|
|
3730
|
+
var st2 = (e) => {
|
|
3731
|
+
const i = (r, u2, n, o) => {
|
|
3732
|
+
const c2 = n.includes(r.value), a = r.label ?? String(r.value ?? ""), l = r.hint && o !== void 0 && r.value === o ? (0, import_node_util2.styleText)("dim", ` (${r.hint})`) : "", $2 = c2 ? (0, import_node_util2.styleText)("green", U) : (0, import_node_util2.styleText)("dim", J2);
|
|
3733
|
+
return r.disabled ? `${(0, import_node_util2.styleText)("gray", J2)} ${(0, import_node_util2.styleText)(["strikethrough", "gray"], a)}` : u2 ? `${$2} ${a}${l}` : `${$2} ${(0, import_node_util2.styleText)("dim", a)}`;
|
|
3734
|
+
}, s = new H({ options: e.options, multiple: true, placeholder: e.placeholder, filter: e.filter ?? ((r, u2) => Re(r, u2)), validate: () => {
|
|
3735
|
+
if (e.required && s.selectedValues.length === 0) return "Please select at least one item";
|
|
3736
|
+
}, initialValue: e.initialValues, signal: e.signal, input: e.input, output: e.output, render() {
|
|
3737
|
+
const r = e.withGuide ?? u.withGuide, u2 = `${r ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
3738
|
+
` : ""}${V2(this.state)} ${e.message}
|
|
3739
|
+
`, n = this.userInput, o = e.placeholder, c2 = n === "" && o !== void 0, a = this.isNavigating || c2 ? (0, import_node_util2.styleText)("dim", c2 ? o : n) : this.userInputWithCursor, l = this.options, $2 = this.filteredOptions.length !== l.length ? (0, import_node_util2.styleText)("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
3740
|
+
switch (this.state) {
|
|
3741
|
+
case "submit":
|
|
3742
|
+
return `${u2}${r ? `${(0, import_node_util2.styleText)("gray", d2)} ` : ""}${(0, import_node_util2.styleText)("dim", `${this.selectedValues.length} items selected`)}`;
|
|
3743
|
+
case "cancel":
|
|
3744
|
+
return `${u2}${r ? `${(0, import_node_util2.styleText)("gray", d2)} ` : ""}${(0, import_node_util2.styleText)(["strikethrough", "dim"], n)}`;
|
|
3745
|
+
default: {
|
|
3746
|
+
const y2 = this.state === "error" ? "yellow" : "cyan", p2 = r ? `${(0, import_node_util2.styleText)(y2, d2)} ` : "", m = r ? (0, import_node_util2.styleText)(y2, E2) : "", g = [`${(0, import_node_util2.styleText)("dim", "\u2191/\u2193")} to navigate`, `${(0, import_node_util2.styleText)("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`, `${(0, import_node_util2.styleText)("dim", "Enter:")} confirm`, `${(0, import_node_util2.styleText)("dim", "Type:")} to search`], S2 = this.filteredOptions.length === 0 && n ? [`${p2}${(0, import_node_util2.styleText)("yellow", "No matches found")}`] : [], h = this.state === "error" ? [`${p2}${(0, import_node_util2.styleText)("yellow", this.error)}`] : [], f = [...`${u2}${r ? (0, import_node_util2.styleText)(y2, d2) : ""}`.split(`
|
|
3747
|
+
`), `${p2}${(0, import_node_util2.styleText)("dim", "Search:")} ${a}${$2}`, ...S2, ...h], v = [`${p2}${g.join(" \u2022 ")}`, m], T2 = Y2({ cursor: this.cursor, options: this.filteredOptions, style: (C2, b) => i(C2, b, this.selectedValues, this.focusedValue), maxItems: e.maxItems, output: e.output, rowPadding: f.length + v.length });
|
|
3748
|
+
return [...f, ...T2.map((C2) => `${p2}${C2}`), ...v].join(`
|
|
3749
|
+
`);
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
} });
|
|
3753
|
+
return s.prompt();
|
|
3754
|
+
};
|
|
3755
|
+
var rt2 = [Oe, ce, de, $e];
|
|
3756
|
+
var it2 = [le, Ie, E2, Ee];
|
|
3757
|
+
function Pe(e, i, s, r) {
|
|
3758
|
+
let u2 = s, n = s;
|
|
3759
|
+
return r === "center" ? u2 = Math.floor((i - e) / 2) : r === "right" && (u2 = i - e - s), n = i - u2 - e, [u2, n];
|
|
3760
|
+
}
|
|
3761
|
+
var nt2 = (e) => e;
|
|
3762
|
+
var at2 = (e = "", i = "", s) => {
|
|
3763
|
+
const r = s?.output ?? process.stdout, u2 = O(r), n = 2, o = s?.titlePadding ?? 1, c2 = s?.contentPadding ?? 2, a = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), l = s?.withGuide ?? u.withGuide ? `${d2} ` : "", $2 = s?.formatBorder ?? nt2, y2 = (s?.rounded ? rt2 : it2).map($2), p2 = $2(se), m = $2(d2), g = dist_default2(l), S2 = dist_default2(i), h = u2 - g;
|
|
3764
|
+
let f = Math.floor(u2 * a) - g;
|
|
3765
|
+
if (s?.width === "auto") {
|
|
3766
|
+
const R2 = e.split(`
|
|
3767
|
+
`);
|
|
3768
|
+
let j2 = S2 + o * 2;
|
|
3769
|
+
for (const ie of R2) {
|
|
3770
|
+
const W2 = dist_default2(ie) + c2 * 2;
|
|
3771
|
+
W2 > j2 && (j2 = W2);
|
|
3772
|
+
}
|
|
3773
|
+
const D2 = j2 + n;
|
|
3774
|
+
D2 < f && (f = D2);
|
|
3775
|
+
}
|
|
3776
|
+
f % 2 !== 0 && (f < h ? f++ : f--);
|
|
3777
|
+
const v = f - n, T2 = v - o * 2, C2 = S2 > T2 ? `${i.slice(0, T2 - 3)}...` : i, [b, x] = Pe(dist_default2(C2), v, o, s?.titleAlign), G2 = wrapAnsi(e, v - c2 * 2, { hard: true, trim: false });
|
|
3778
|
+
r.write(`${l}${y2[0]}${p2.repeat(b)}${C2}${p2.repeat(x)}${y2[1]}
|
|
3779
|
+
`);
|
|
3780
|
+
const M2 = G2.split(`
|
|
3781
|
+
`);
|
|
3782
|
+
for (const R2 of M2) {
|
|
3783
|
+
const [j2, D2] = Pe(dist_default2(R2), v, c2, s?.contentAlign);
|
|
3784
|
+
r.write(`${l}${m}${" ".repeat(j2)}${R2}${" ".repeat(D2)}${m}
|
|
3785
|
+
`);
|
|
3786
|
+
}
|
|
3787
|
+
r.write(`${l}${y2[2]}${p2.repeat(v)}${y2[3]}
|
|
3788
|
+
`);
|
|
3789
|
+
};
|
|
3790
|
+
var ot2 = (e) => {
|
|
3791
|
+
const i = e.active ?? "Yes", s = e.inactive ?? "No";
|
|
3792
|
+
return new Q({ active: i, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
|
|
3793
|
+
const r = e.withGuide ?? u.withGuide, u2 = `${V2(this.state)} `, n = r ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "", o = R(e.output, e.message, n, u2), c2 = `${r ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
3794
|
+
` : ""}${o}
|
|
3795
|
+
`, a = this.value ? i : s;
|
|
3796
|
+
switch (this.state) {
|
|
3797
|
+
case "submit": {
|
|
3798
|
+
const l = r ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "";
|
|
3799
|
+
return `${c2}${l}${(0, import_node_util2.styleText)("dim", a)}`;
|
|
3800
|
+
}
|
|
3801
|
+
case "cancel": {
|
|
3802
|
+
const l = r ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "";
|
|
3803
|
+
return `${c2}${l}${(0, import_node_util2.styleText)(["strikethrough", "dim"], a)}${r ? `
|
|
3804
|
+
${(0, import_node_util2.styleText)("gray", d2)}` : ""}`;
|
|
3805
|
+
}
|
|
3806
|
+
default: {
|
|
3807
|
+
const l = r ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", $2 = r ? (0, import_node_util2.styleText)("cyan", E2) : "";
|
|
3808
|
+
return `${c2}${l}${this.value ? `${(0, import_node_util2.styleText)("green", z3)} ${i}` : `${(0, import_node_util2.styleText)("dim", H2)} ${(0, import_node_util2.styleText)("dim", i)}`}${e.vertical ? r ? `
|
|
3809
|
+
${(0, import_node_util2.styleText)("cyan", d2)} ` : `
|
|
3810
|
+
` : ` ${(0, import_node_util2.styleText)("dim", "/")} `}${this.value ? `${(0, import_node_util2.styleText)("dim", H2)} ${(0, import_node_util2.styleText)("dim", s)}` : `${(0, import_node_util2.styleText)("green", z3)} ${s}`}
|
|
3811
|
+
${$2}
|
|
3812
|
+
`;
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
} }).prompt();
|
|
3816
|
+
};
|
|
3817
|
+
var ut = (e) => {
|
|
3818
|
+
const i = e.validate;
|
|
3819
|
+
return new et({ ...e, validate(s) {
|
|
3820
|
+
if (s === void 0) return e.defaultValue !== void 0 ? void 0 : i ? i(s) : u.date.messages.required;
|
|
3821
|
+
const r = (u2) => u2.toISOString().slice(0, 10);
|
|
3822
|
+
if (e.minDate && r(s) < r(e.minDate)) return u.date.messages.afterMin(e.minDate);
|
|
3823
|
+
if (e.maxDate && r(s) > r(e.maxDate)) return u.date.messages.beforeMax(e.maxDate);
|
|
3824
|
+
if (i) return i(s);
|
|
3825
|
+
}, render() {
|
|
3826
|
+
const s = (e?.withGuide ?? u.withGuide) !== false, r = `${`${s ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
3827
|
+
` : ""}${V2(this.state)} `}${e.message}
|
|
3828
|
+
`, u2 = this.state !== "initial" ? this.state : "active", n = lt(this, u2), o = this.value instanceof Date ? this.formattedValue : "";
|
|
3829
|
+
switch (this.state) {
|
|
3830
|
+
case "error": {
|
|
3831
|
+
const c2 = this.error ? ` ${(0, import_node_util2.styleText)("yellow", this.error)}` : "", a = s ? `${(0, import_node_util2.styleText)("yellow", d2)} ` : "", l = s ? (0, import_node_util2.styleText)("yellow", E2) : "";
|
|
3832
|
+
return `${r.trim()}
|
|
3833
|
+
${a}${n}
|
|
3834
|
+
${l}${c2}
|
|
3835
|
+
`;
|
|
3836
|
+
}
|
|
3837
|
+
case "submit": {
|
|
3838
|
+
const c2 = o ? ` ${(0, import_node_util2.styleText)("dim", o)}` : "", a = s ? (0, import_node_util2.styleText)("gray", d2) : "";
|
|
3839
|
+
return `${r}${a}${c2}`;
|
|
3840
|
+
}
|
|
3841
|
+
case "cancel": {
|
|
3842
|
+
const c2 = o ? ` ${(0, import_node_util2.styleText)(["strikethrough", "dim"], o)}` : "", a = s ? (0, import_node_util2.styleText)("gray", d2) : "";
|
|
3843
|
+
return `${r}${a}${c2}${o.trim() ? `
|
|
3844
|
+
${a}` : ""}`;
|
|
3845
|
+
}
|
|
3846
|
+
default: {
|
|
3847
|
+
const c2 = s ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", a = s ? (0, import_node_util2.styleText)("cyan", E2) : "", l = s ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", $2 = this.inlineError ? `
|
|
3848
|
+
${l}${(0, import_node_util2.styleText)("yellow", this.inlineError)}` : "";
|
|
3849
|
+
return `${r}${c2}${n}${$2}
|
|
3850
|
+
${a}
|
|
3851
|
+
`;
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
} }).prompt();
|
|
3855
|
+
};
|
|
3856
|
+
function lt(e, i) {
|
|
3857
|
+
const s = e.segmentValues, r = e.segmentCursor;
|
|
3858
|
+
if (i === "submit" || i === "cancel") return e.formattedValue;
|
|
3859
|
+
const u2 = (0, import_node_util2.styleText)("gray", e.separator);
|
|
3860
|
+
return e.segments.map((n, o) => {
|
|
3861
|
+
const c2 = o === r.segmentIndex && !["submit", "cancel"].includes(i), a = $t[n.type];
|
|
3862
|
+
return ct(s[n.type], { isActive: c2, label: a });
|
|
3863
|
+
}).join(u2);
|
|
3864
|
+
}
|
|
3865
|
+
function ct(e, i) {
|
|
3866
|
+
const s = !e || e.replace(/_/g, "") === "";
|
|
3867
|
+
return i.isActive ? (0, import_node_util2.styleText)("inverse", s ? i.label : e.replace(/_/g, " ")) : s ? (0, import_node_util2.styleText)("dim", i.label) : e.replace(/_/g, (0, import_node_util2.styleText)("dim", " "));
|
|
3868
|
+
}
|
|
3869
|
+
var $t = { year: "yyyy", month: "mm", day: "dd" };
|
|
3870
|
+
var dt = async (e, i) => {
|
|
3871
|
+
const s = {}, r = Object.keys(e);
|
|
3872
|
+
for (const u2 of r) {
|
|
3873
|
+
const n = e[u2], o = await n({ results: s })?.catch((c2) => {
|
|
3874
|
+
throw c2;
|
|
3875
|
+
});
|
|
3876
|
+
if (typeof i?.onCancel == "function" && q(o)) {
|
|
3877
|
+
s[u2] = "canceled", i.onCancel({ results: s });
|
|
3878
|
+
continue;
|
|
3879
|
+
}
|
|
3880
|
+
s[u2] = o;
|
|
3881
|
+
}
|
|
3882
|
+
return s;
|
|
3883
|
+
};
|
|
3884
|
+
var ht = (e) => {
|
|
3885
|
+
const { selectableGroups: i = true, groupSpacing: s = 0 } = e, r = (n, o, c2 = []) => {
|
|
3886
|
+
const a = n.label ?? String(n.value), l = typeof n.group == "string", $2 = l && (c2[c2.indexOf(n) + 1] ?? { group: true }), y2 = l && $2 && $2.group === true, p2 = l ? i ? `${y2 ? E2 : d2} ` : " " : "";
|
|
3887
|
+
let m = "";
|
|
3888
|
+
if (s > 0 && !l) {
|
|
3889
|
+
const S2 = `
|
|
3890
|
+
${(0, import_node_util2.styleText)("cyan", d2)}`;
|
|
3891
|
+
m = `${S2.repeat(s - 1)}${S2} `;
|
|
3892
|
+
}
|
|
3893
|
+
if (o === "active") return `${m}${(0, import_node_util2.styleText)("dim", p2)}${(0, import_node_util2.styleText)("cyan", te)} ${a}${n.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${n.hint})`)}` : ""}`;
|
|
3894
|
+
if (o === "group-active") return `${m}${p2}${(0, import_node_util2.styleText)("cyan", te)} ${(0, import_node_util2.styleText)("dim", a)}`;
|
|
3895
|
+
if (o === "group-active-selected") return `${m}${p2}${(0, import_node_util2.styleText)("green", U)} ${(0, import_node_util2.styleText)("dim", a)}`;
|
|
3896
|
+
if (o === "selected") {
|
|
3897
|
+
const S2 = l || i ? (0, import_node_util2.styleText)("green", U) : "";
|
|
3898
|
+
return `${m}${(0, import_node_util2.styleText)("dim", p2)}${S2} ${(0, import_node_util2.styleText)("dim", a)}${n.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${n.hint})`)}` : ""}`;
|
|
3899
|
+
}
|
|
3900
|
+
if (o === "cancelled") return `${(0, import_node_util2.styleText)(["strikethrough", "dim"], a)}`;
|
|
3901
|
+
if (o === "active-selected") return `${m}${(0, import_node_util2.styleText)("dim", p2)}${(0, import_node_util2.styleText)("green", U)} ${a}${n.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${n.hint})`)}` : ""}`;
|
|
3902
|
+
if (o === "submitted") return `${(0, import_node_util2.styleText)("dim", a)}`;
|
|
3903
|
+
const g = l || i ? (0, import_node_util2.styleText)("dim", J2) : "";
|
|
3904
|
+
return `${m}${(0, import_node_util2.styleText)("dim", p2)}${g} ${(0, import_node_util2.styleText)("dim", a)}`;
|
|
3905
|
+
}, u2 = e.required ?? true;
|
|
3906
|
+
return new st({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValues: e.initialValues, required: u2, cursorAt: e.cursorAt, selectableGroups: i, validate(n) {
|
|
3907
|
+
if (u2 && (n === void 0 || n.length === 0)) return `Please select at least one option.
|
|
3908
|
+
${(0, import_node_util2.styleText)("reset", (0, import_node_util2.styleText)("dim", `Press ${(0, import_node_util2.styleText)(["gray", "bgWhite", "inverse"], " space ")} to select, ${(0, import_node_util2.styleText)("gray", (0, import_node_util2.styleText)(["bgWhite", "inverse"], " enter "))} to submit`))}`;
|
|
3909
|
+
}, render() {
|
|
3910
|
+
const n = e.withGuide ?? u.withGuide, o = `${n ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
3911
|
+
` : ""}${V2(this.state)} ${e.message}
|
|
3912
|
+
`, c2 = this.value ?? [];
|
|
3913
|
+
switch (this.state) {
|
|
3914
|
+
case "submit": {
|
|
3915
|
+
const a = this.options.filter(({ value: $2 }) => c2.includes($2)).map(($2) => r($2, "submitted")), l = a.length === 0 ? "" : ` ${a.join((0, import_node_util2.styleText)("dim", ", "))}`;
|
|
3916
|
+
return `${o}${n ? (0, import_node_util2.styleText)("gray", d2) : ""}${l}`;
|
|
3917
|
+
}
|
|
3918
|
+
case "cancel": {
|
|
3919
|
+
const a = this.options.filter(({ value: l }) => c2.includes(l)).map((l) => r(l, "cancelled")).join((0, import_node_util2.styleText)("dim", ", "));
|
|
3920
|
+
return `${o}${n ? `${(0, import_node_util2.styleText)("gray", d2)} ` : ""}${a.trim() ? `${a}${n ? `
|
|
3921
|
+
${(0, import_node_util2.styleText)("gray", d2)}` : ""}` : ""}`;
|
|
3922
|
+
}
|
|
3923
|
+
case "error": {
|
|
3924
|
+
const a = this.error.split(`
|
|
3925
|
+
`).map((l, $2) => $2 === 0 ? `${n ? `${(0, import_node_util2.styleText)("yellow", E2)} ` : ""}${(0, import_node_util2.styleText)("yellow", l)}` : ` ${l}`).join(`
|
|
3926
|
+
`);
|
|
3927
|
+
return `${o}${n ? `${(0, import_node_util2.styleText)("yellow", d2)} ` : ""}${this.options.map((l, $2, y2) => {
|
|
3928
|
+
const p2 = c2.includes(l.value) || l.group === true && this.isGroupSelected(`${l.value}`), m = $2 === this.cursor;
|
|
3929
|
+
return !m && typeof l.group == "string" && this.options[this.cursor].value === l.group ? r(l, p2 ? "group-active-selected" : "group-active", y2) : m && p2 ? r(l, "active-selected", y2) : p2 ? r(l, "selected", y2) : r(l, m ? "active" : "inactive", y2);
|
|
3930
|
+
}).join(`
|
|
3931
|
+
${n ? `${(0, import_node_util2.styleText)("yellow", d2)} ` : ""}`)}
|
|
3932
|
+
${a}
|
|
3933
|
+
`;
|
|
3934
|
+
}
|
|
3935
|
+
default: {
|
|
3936
|
+
const a = this.options.map(($2, y2, p2) => {
|
|
3937
|
+
const m = c2.includes($2.value) || $2.group === true && this.isGroupSelected(`${$2.value}`), g = y2 === this.cursor, S2 = !g && typeof $2.group == "string" && this.options[this.cursor].value === $2.group;
|
|
3938
|
+
let h = "";
|
|
3939
|
+
return S2 ? h = r($2, m ? "group-active-selected" : "group-active", p2) : g && m ? h = r($2, "active-selected", p2) : m ? h = r($2, "selected", p2) : h = r($2, g ? "active" : "inactive", p2), `${y2 !== 0 && !h.startsWith(`
|
|
3940
|
+
`) ? " " : ""}${h}`;
|
|
3941
|
+
}).join(`
|
|
3942
|
+
${n ? (0, import_node_util2.styleText)("cyan", d2) : ""}`), l = a.startsWith(`
|
|
3943
|
+
`) ? "" : " ";
|
|
3944
|
+
return `${o}${n ? (0, import_node_util2.styleText)("cyan", d2) : ""}${l}${a}
|
|
3945
|
+
${n ? (0, import_node_util2.styleText)("cyan", E2) : ""}
|
|
3946
|
+
`;
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
} }).prompt();
|
|
3950
|
+
};
|
|
3951
|
+
var O2 = { message: (e = [], { symbol: i = (0, import_node_util2.styleText)("gray", d2), secondarySymbol: s = (0, import_node_util2.styleText)("gray", d2), output: r = process.stdout, spacing: u2 = 1, withGuide: n } = {}) => {
|
|
3952
|
+
const o = [], c2 = n ?? u.withGuide, a = c2 ? s : "", l = c2 ? `${i} ` : "", $2 = c2 ? `${s} ` : "";
|
|
3953
|
+
for (let p2 = 0; p2 < u2; p2++) o.push(a);
|
|
3954
|
+
const y2 = Array.isArray(e) ? e : e.split(`
|
|
3955
|
+
`);
|
|
3956
|
+
if (y2.length > 0) {
|
|
3957
|
+
const [p2, ...m] = y2;
|
|
3958
|
+
p2.length > 0 ? o.push(`${l}${p2}`) : o.push(c2 ? i : "");
|
|
3959
|
+
for (const g of m) g.length > 0 ? o.push(`${$2}${g}`) : o.push(c2 ? s : "");
|
|
3960
|
+
}
|
|
3961
|
+
r.write(`${o.join(`
|
|
3962
|
+
`)}
|
|
3963
|
+
`);
|
|
3964
|
+
}, info: (e, i) => {
|
|
3965
|
+
O2.message(e, { ...i, symbol: (0, import_node_util2.styleText)("blue", he) });
|
|
3966
|
+
}, success: (e, i) => {
|
|
3967
|
+
O2.message(e, { ...i, symbol: (0, import_node_util2.styleText)("green", pe) });
|
|
3968
|
+
}, step: (e, i) => {
|
|
3969
|
+
O2.message(e, { ...i, symbol: (0, import_node_util2.styleText)("green", F2) });
|
|
3970
|
+
}, warn: (e, i) => {
|
|
3971
|
+
O2.message(e, { ...i, symbol: (0, import_node_util2.styleText)("yellow", me) });
|
|
3972
|
+
}, warning: (e, i) => {
|
|
3973
|
+
O2.warn(e, i);
|
|
3974
|
+
}, error: (e, i) => {
|
|
3975
|
+
O2.message(e, { ...i, symbol: (0, import_node_util2.styleText)("red", ge) });
|
|
3976
|
+
} };
|
|
3977
|
+
var pt = (e = "", i) => {
|
|
3978
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${(0, import_node_util2.styleText)("gray", E2)} ` : "";
|
|
3979
|
+
s.write(`${r}${(0, import_node_util2.styleText)("red", e)}
|
|
3980
|
+
|
|
3981
|
+
`);
|
|
3982
|
+
};
|
|
3983
|
+
var mt = (e = "", i) => {
|
|
3984
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${(0, import_node_util2.styleText)("gray", le)} ` : "";
|
|
3985
|
+
s.write(`${r}${e}
|
|
3986
|
+
`);
|
|
3987
|
+
};
|
|
3988
|
+
var gt = (e = "", i) => {
|
|
3989
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
3990
|
+
${(0, import_node_util2.styleText)("gray", E2)} ` : "";
|
|
3991
|
+
s.write(`${r}${e}
|
|
3992
|
+
|
|
3993
|
+
`);
|
|
3994
|
+
};
|
|
3995
|
+
var Q2 = (e, i) => e.split(`
|
|
3996
|
+
`).map((s) => i(s)).join(`
|
|
3997
|
+
`);
|
|
3998
|
+
var yt = (e) => {
|
|
3999
|
+
const i = (r, u2) => {
|
|
4000
|
+
const n = r.label ?? String(r.value);
|
|
4001
|
+
return u2 === "disabled" ? `${(0, import_node_util2.styleText)("gray", J2)} ${Q2(n, (o) => (0, import_node_util2.styleText)(["strikethrough", "gray"], o))}${r.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : u2 === "active" ? `${(0, import_node_util2.styleText)("cyan", te)} ${n}${r.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${r.hint})`)}` : ""}` : u2 === "selected" ? `${(0, import_node_util2.styleText)("green", U)} ${Q2(n, (o) => (0, import_node_util2.styleText)("dim", o))}${r.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${r.hint})`)}` : ""}` : u2 === "cancelled" ? `${Q2(n, (o) => (0, import_node_util2.styleText)(["strikethrough", "dim"], o))}` : u2 === "active-selected" ? `${(0, import_node_util2.styleText)("green", U)} ${n}${r.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${r.hint})`)}` : ""}` : u2 === "submitted" ? `${Q2(n, (o) => (0, import_node_util2.styleText)("dim", o))}` : `${(0, import_node_util2.styleText)("dim", J2)} ${Q2(n, (o) => (0, import_node_util2.styleText)("dim", o))}`;
|
|
4002
|
+
}, s = e.required ?? true;
|
|
4003
|
+
return new it({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValues: e.initialValues, required: s, cursorAt: e.cursorAt, validate(r) {
|
|
4004
|
+
if (s && (r === void 0 || r.length === 0)) return `Please select at least one option.
|
|
4005
|
+
${(0, import_node_util2.styleText)("reset", (0, import_node_util2.styleText)("dim", `Press ${(0, import_node_util2.styleText)(["gray", "bgWhite", "inverse"], " space ")} to select, ${(0, import_node_util2.styleText)("gray", (0, import_node_util2.styleText)("bgWhite", (0, import_node_util2.styleText)("inverse", " enter ")))} to submit`))}`;
|
|
4006
|
+
}, render() {
|
|
4007
|
+
const r = e.withGuide ?? u.withGuide, u2 = R(e.output, e.message, r ? `${ye(this.state)} ` : "", `${V2(this.state)} `), n = `${r ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
4008
|
+
` : ""}${u2}
|
|
4009
|
+
`, o = this.value ?? [], c2 = (a, l) => {
|
|
4010
|
+
if (a.disabled) return i(a, "disabled");
|
|
4011
|
+
const $2 = o.includes(a.value);
|
|
4012
|
+
return l && $2 ? i(a, "active-selected") : $2 ? i(a, "selected") : i(a, l ? "active" : "inactive");
|
|
4013
|
+
};
|
|
4014
|
+
switch (this.state) {
|
|
4015
|
+
case "submit": {
|
|
4016
|
+
const a = this.options.filter(({ value: $2 }) => o.includes($2)).map(($2) => i($2, "submitted")).join((0, import_node_util2.styleText)("dim", ", ")) || (0, import_node_util2.styleText)("dim", "none"), l = R(e.output, a, r ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "");
|
|
4017
|
+
return `${n}${l}`;
|
|
4018
|
+
}
|
|
4019
|
+
case "cancel": {
|
|
4020
|
+
const a = this.options.filter(({ value: $2 }) => o.includes($2)).map(($2) => i($2, "cancelled")).join((0, import_node_util2.styleText)("dim", ", "));
|
|
4021
|
+
if (a.trim() === "") return `${n}${(0, import_node_util2.styleText)("gray", d2)}`;
|
|
4022
|
+
const l = R(e.output, a, r ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "");
|
|
4023
|
+
return `${n}${l}${r ? `
|
|
4024
|
+
${(0, import_node_util2.styleText)("gray", d2)}` : ""}`;
|
|
4025
|
+
}
|
|
4026
|
+
case "error": {
|
|
4027
|
+
const a = r ? `${(0, import_node_util2.styleText)("yellow", d2)} ` : "", l = this.error.split(`
|
|
4028
|
+
`).map((p2, m) => m === 0 ? `${r ? `${(0, import_node_util2.styleText)("yellow", E2)} ` : ""}${(0, import_node_util2.styleText)("yellow", p2)}` : ` ${p2}`).join(`
|
|
4029
|
+
`), $2 = n.split(`
|
|
4030
|
+
`).length, y2 = l.split(`
|
|
4031
|
+
`).length + 1;
|
|
4032
|
+
return `${n}${a}${Y2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: a.length, rowPadding: $2 + y2, style: c2 }).join(`
|
|
4033
|
+
${a}`)}
|
|
4034
|
+
${l}
|
|
4035
|
+
`;
|
|
4036
|
+
}
|
|
4037
|
+
default: {
|
|
4038
|
+
const a = r ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", l = n.split(`
|
|
4039
|
+
`).length, $2 = r ? 2 : 1;
|
|
4040
|
+
return `${n}${a}${Y2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: a.length, rowPadding: l + $2, style: c2 }).join(`
|
|
4041
|
+
${a}`)}
|
|
4042
|
+
${r ? (0, import_node_util2.styleText)("cyan", E2) : ""}
|
|
4043
|
+
`;
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
} }).prompt();
|
|
4047
|
+
};
|
|
4048
|
+
var ft = (e) => (0, import_node_util2.styleText)("dim", e);
|
|
4049
|
+
var vt = (e, i, s) => {
|
|
4050
|
+
const r = { hard: true, trim: false }, u2 = wrapAnsi(e, i, r).split(`
|
|
4051
|
+
`), n = u2.reduce((a, l) => Math.max(dist_default2(l), a), 0), o = u2.map(s).reduce((a, l) => Math.max(dist_default2(l), a), 0), c2 = i - (o - n);
|
|
4052
|
+
return wrapAnsi(e, c2, r);
|
|
4053
|
+
};
|
|
4054
|
+
var wt = (e = "", i = "", s) => {
|
|
4055
|
+
const r = s?.output ?? import_node_process2.default.stdout, u2 = s?.withGuide ?? u.withGuide, n = s?.format ?? ft, o = ["", ...vt(e, O(r) - 6, n).split(`
|
|
4056
|
+
`).map(n), ""], c2 = dist_default2(i), a = Math.max(o.reduce((p2, m) => {
|
|
4057
|
+
const g = dist_default2(m);
|
|
4058
|
+
return g > p2 ? g : p2;
|
|
4059
|
+
}, 0), c2) + 2, l = o.map((p2) => `${(0, import_node_util2.styleText)("gray", d2)} ${p2}${" ".repeat(a - dist_default2(p2))}${(0, import_node_util2.styleText)("gray", d2)}`).join(`
|
|
4060
|
+
`), $2 = u2 ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
4061
|
+
` : "", y2 = u2 ? Ge : de;
|
|
4062
|
+
r.write(`${$2}${(0, import_node_util2.styleText)("green", F2)} ${(0, import_node_util2.styleText)("reset", i)} ${(0, import_node_util2.styleText)("gray", se.repeat(Math.max(a - c2 - 1, 1)) + ce)}
|
|
4063
|
+
${l}
|
|
4064
|
+
${(0, import_node_util2.styleText)("gray", y2 + se.repeat(a + 2) + $e)}
|
|
4065
|
+
`);
|
|
4066
|
+
};
|
|
4067
|
+
var bt = (e) => new rt({ validate: e.validate, mask: e.mask ?? xe, signal: e.signal, input: e.input, output: e.output, render() {
|
|
4068
|
+
const i = e.withGuide ?? u.withGuide, s = `${i ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
4069
|
+
` : ""}${V2(this.state)} ${e.message}
|
|
4070
|
+
`, r = this.userInputWithCursor, u2 = this.masked;
|
|
4071
|
+
switch (this.state) {
|
|
4072
|
+
case "error": {
|
|
4073
|
+
const n = i ? `${(0, import_node_util2.styleText)("yellow", d2)} ` : "", o = i ? `${(0, import_node_util2.styleText)("yellow", E2)} ` : "", c2 = u2 ?? "";
|
|
4074
|
+
return e.clearOnError && this.clear(), `${s.trim()}
|
|
4075
|
+
${n}${c2}
|
|
4076
|
+
${o}${(0, import_node_util2.styleText)("yellow", this.error)}
|
|
4077
|
+
`;
|
|
4078
|
+
}
|
|
4079
|
+
case "submit": {
|
|
4080
|
+
const n = i ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "", o = u2 ? (0, import_node_util2.styleText)("dim", u2) : "";
|
|
4081
|
+
return `${s}${n}${o}`;
|
|
4082
|
+
}
|
|
4083
|
+
case "cancel": {
|
|
4084
|
+
const n = i ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "", o = u2 ? (0, import_node_util2.styleText)(["strikethrough", "dim"], u2) : "";
|
|
4085
|
+
return `${s}${n}${o}${u2 && i ? `
|
|
4086
|
+
${(0, import_node_util2.styleText)("gray", d2)}` : ""}`;
|
|
4087
|
+
}
|
|
4088
|
+
default: {
|
|
4089
|
+
const n = i ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", o = i ? (0, import_node_util2.styleText)("cyan", E2) : "";
|
|
4090
|
+
return `${s}${n}${r}
|
|
4091
|
+
${o}
|
|
4092
|
+
`;
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
} }).prompt();
|
|
4096
|
+
var St = (e) => {
|
|
4097
|
+
const i = e.validate;
|
|
4098
|
+
return Ae({ ...e, initialUserInput: e.initialValue ?? e.root ?? process.cwd(), maxItems: 5, validate(s) {
|
|
4099
|
+
if (!Array.isArray(s)) {
|
|
4100
|
+
if (!s) return "Please select a path";
|
|
4101
|
+
if (i) return i(s);
|
|
4102
|
+
}
|
|
4103
|
+
}, options() {
|
|
4104
|
+
const s = this.userInput;
|
|
4105
|
+
if (s === "") return [];
|
|
4106
|
+
try {
|
|
4107
|
+
let r;
|
|
4108
|
+
(0, import_node_fs.existsSync)(s) ? (0, import_node_fs.lstatSync)(s).isDirectory() && (!e.directory || s.endsWith("/")) ? r = s : r = (0, import_node_path.dirname)(s) : r = (0, import_node_path.dirname)(s);
|
|
4109
|
+
const u2 = s.length > 1 && s.endsWith("/") ? s.slice(0, -1) : s;
|
|
4110
|
+
return (0, import_node_fs.readdirSync)(r).map((n) => {
|
|
4111
|
+
const o = (0, import_node_path.join)(r, n), c2 = (0, import_node_fs.lstatSync)(o);
|
|
4112
|
+
return { name: n, path: o, isDirectory: c2.isDirectory() };
|
|
4113
|
+
}).filter(({ path: n, isDirectory: o }) => n.startsWith(u2) && (o || !e.directory)).map((n) => ({ value: n.path }));
|
|
4114
|
+
} catch {
|
|
4115
|
+
return [];
|
|
4116
|
+
}
|
|
4117
|
+
} });
|
|
4118
|
+
};
|
|
4119
|
+
var Ct = (e) => (0, import_node_util2.styleText)("magenta", e);
|
|
4120
|
+
var fe = ({ indicator: e = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u2, frames: n = ee ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: o = ee ? 80 : 120, signal: c2, ...a } = {}) => {
|
|
4121
|
+
const l = ae();
|
|
4122
|
+
let $2, y2, p2 = false, m = false, g = "", S2, h = performance.now();
|
|
4123
|
+
const f = O(s), v = a?.styleFrame ?? Ct, T2 = (_2) => {
|
|
4124
|
+
const A2 = _2 > 1 ? u2 ?? u.messages.error : r ?? u.messages.cancel;
|
|
4125
|
+
m = _2 === 1, p2 && (W2(A2, _2), m && typeof i == "function" && i());
|
|
4126
|
+
}, C2 = () => T2(2), b = () => T2(1), x = () => {
|
|
4127
|
+
process.on("uncaughtExceptionMonitor", C2), process.on("unhandledRejection", C2), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", T2), c2 && c2.addEventListener("abort", b);
|
|
4128
|
+
}, G2 = () => {
|
|
4129
|
+
process.removeListener("uncaughtExceptionMonitor", C2), process.removeListener("unhandledRejection", C2), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", T2), c2 && c2.removeEventListener("abort", b);
|
|
4130
|
+
}, M2 = () => {
|
|
4131
|
+
if (S2 === void 0) return;
|
|
4132
|
+
l && s.write(`
|
|
4133
|
+
`);
|
|
4134
|
+
const _2 = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
|
|
4135
|
+
`);
|
|
4136
|
+
_2.length > 1 && s.write(import_sisteransi2.cursor.up(_2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
|
|
4137
|
+
}, R2 = (_2) => _2.replace(/\.+$/, ""), j2 = (_2) => {
|
|
4138
|
+
const A2 = (performance.now() - _2) / 1e3, k2 = Math.floor(A2 / 60), L2 = Math.floor(A2 % 60);
|
|
4139
|
+
return k2 > 0 ? `[${k2}m ${L2}s]` : `[${L2}s]`;
|
|
4140
|
+
}, D2 = a.withGuide ?? u.withGuide, ie = (_2 = "") => {
|
|
4141
|
+
p2 = true, $2 = z2({ output: s }), g = R2(_2), h = performance.now(), D2 && s.write(`${(0, import_node_util2.styleText)("gray", d2)}
|
|
4142
|
+
`);
|
|
4143
|
+
let A2 = 0, k2 = 0;
|
|
4144
|
+
x(), y2 = setInterval(() => {
|
|
4145
|
+
if (l && g === S2) return;
|
|
4146
|
+
M2(), S2 = g;
|
|
4147
|
+
const L2 = v(n[A2]);
|
|
4148
|
+
let Z2;
|
|
4149
|
+
if (l) Z2 = `${L2} ${g}...`;
|
|
4150
|
+
else if (e === "timer") Z2 = `${L2} ${g} ${j2(h)}`;
|
|
4151
|
+
else {
|
|
4152
|
+
const Be = ".".repeat(Math.floor(k2)).slice(0, 3);
|
|
4153
|
+
Z2 = `${L2} ${g}${Be}`;
|
|
4154
|
+
}
|
|
4155
|
+
const Ne = wrapAnsi(Z2, f, { hard: true, trim: false });
|
|
4156
|
+
s.write(Ne), A2 = A2 + 1 < n.length ? A2 + 1 : 0, k2 = k2 < 4 ? k2 + 0.125 : 0;
|
|
4157
|
+
}, o);
|
|
4158
|
+
}, W2 = (_2 = "", A2 = 0, k2 = false) => {
|
|
4159
|
+
if (!p2) return;
|
|
4160
|
+
p2 = false, clearInterval(y2), M2();
|
|
4161
|
+
const L2 = A2 === 0 ? (0, import_node_util2.styleText)("green", F2) : A2 === 1 ? (0, import_node_util2.styleText)("red", oe) : (0, import_node_util2.styleText)("red", ue);
|
|
4162
|
+
g = _2 ?? g, k2 || (e === "timer" ? s.write(`${L2} ${g} ${j2(h)}
|
|
4163
|
+
`) : s.write(`${L2} ${g}
|
|
4164
|
+
`)), G2(), $2();
|
|
4165
|
+
};
|
|
4166
|
+
return { start: ie, stop: (_2 = "") => W2(_2, 0), message: (_2 = "") => {
|
|
4167
|
+
g = R2(_2 ?? g);
|
|
4168
|
+
}, cancel: (_2 = "") => W2(_2, 1), error: (_2 = "") => W2(_2, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
4169
|
+
return m;
|
|
4170
|
+
} };
|
|
4171
|
+
};
|
|
4172
|
+
var Ve = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
4173
|
+
function Tt({ style: e = "heavy", max: i = 100, size: s = 40, ...r } = {}) {
|
|
4174
|
+
const u2 = fe(r);
|
|
4175
|
+
let n = 0, o = "";
|
|
4176
|
+
const c2 = Math.max(1, i), a = Math.max(1, s), l = (m) => {
|
|
4177
|
+
switch (m) {
|
|
4178
|
+
case "initial":
|
|
4179
|
+
case "active":
|
|
4180
|
+
return (g) => (0, import_node_util2.styleText)("magenta", g);
|
|
4181
|
+
case "error":
|
|
4182
|
+
case "cancel":
|
|
4183
|
+
return (g) => (0, import_node_util2.styleText)("red", g);
|
|
4184
|
+
case "submit":
|
|
4185
|
+
return (g) => (0, import_node_util2.styleText)("green", g);
|
|
4186
|
+
default:
|
|
4187
|
+
return (g) => (0, import_node_util2.styleText)("magenta", g);
|
|
4188
|
+
}
|
|
4189
|
+
}, $2 = (m, g) => {
|
|
4190
|
+
const S2 = Math.floor(n / c2 * a);
|
|
4191
|
+
return `${l(m)(Ve[e].repeat(S2))}${(0, import_node_util2.styleText)("dim", Ve[e].repeat(a - S2))} ${g}`;
|
|
4192
|
+
}, y2 = (m = "") => {
|
|
4193
|
+
o = m, u2.start($2("initial", m));
|
|
4194
|
+
}, p2 = (m = 1, g) => {
|
|
4195
|
+
n = Math.min(c2, m + n), u2.message($2("active", g ?? o)), o = g ?? o;
|
|
4196
|
+
};
|
|
4197
|
+
return { start: y2, stop: u2.stop, cancel: u2.cancel, error: u2.error, clear: u2.clear, advance: p2, isCancelled: u2.isCancelled, message: (m) => p2(0, m) };
|
|
4198
|
+
}
|
|
4199
|
+
var re = (e, i) => e.includes(`
|
|
4200
|
+
`) ? e.split(`
|
|
4201
|
+
`).map((s) => i(s)).join(`
|
|
4202
|
+
`) : i(e);
|
|
4203
|
+
var _t = (e) => {
|
|
4204
|
+
const i = (s, r) => {
|
|
4205
|
+
const u2 = s.label ?? String(s.value);
|
|
4206
|
+
switch (r) {
|
|
4207
|
+
case "disabled":
|
|
4208
|
+
return `${(0, import_node_util2.styleText)("gray", H2)} ${re(u2, (n) => (0, import_node_util2.styleText)("gray", n))}${s.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
4209
|
+
case "selected":
|
|
4210
|
+
return `${re(u2, (n) => (0, import_node_util2.styleText)("dim", n))}`;
|
|
4211
|
+
case "active":
|
|
4212
|
+
return `${(0, import_node_util2.styleText)("green", z3)} ${u2}${s.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${s.hint})`)}` : ""}`;
|
|
4213
|
+
case "cancelled":
|
|
4214
|
+
return `${re(u2, (n) => (0, import_node_util2.styleText)(["strikethrough", "dim"], n))}`;
|
|
4215
|
+
default:
|
|
4216
|
+
return `${(0, import_node_util2.styleText)("dim", H2)} ${re(u2, (n) => (0, import_node_util2.styleText)("dim", n))}`;
|
|
4217
|
+
}
|
|
4218
|
+
};
|
|
4219
|
+
return new nt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
|
|
4220
|
+
const s = e.withGuide ?? u.withGuide, r = `${V2(this.state)} `, u2 = `${ye(this.state)} `, n = R(e.output, e.message, u2, r), o = `${s ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
4221
|
+
` : ""}${n}
|
|
4222
|
+
`;
|
|
4223
|
+
switch (this.state) {
|
|
4224
|
+
case "submit": {
|
|
4225
|
+
const c2 = s ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "selected"), c2);
|
|
4226
|
+
return `${o}${a}`;
|
|
4227
|
+
}
|
|
4228
|
+
case "cancel": {
|
|
4229
|
+
const c2 = s ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "cancelled"), c2);
|
|
4230
|
+
return `${o}${a}${s ? `
|
|
4231
|
+
${(0, import_node_util2.styleText)("gray", d2)}` : ""}`;
|
|
4232
|
+
}
|
|
4233
|
+
default: {
|
|
4234
|
+
const c2 = s ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", a = s ? (0, import_node_util2.styleText)("cyan", E2) : "", l = o.split(`
|
|
4235
|
+
`).length, $2 = s ? 2 : 1;
|
|
4236
|
+
return `${o}${c2}${Y2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: c2.length, rowPadding: l + $2, style: (y2, p2) => i(y2, y2.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
|
|
4237
|
+
${c2}`)}
|
|
4238
|
+
${a}
|
|
4239
|
+
`;
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
} }).prompt();
|
|
4243
|
+
};
|
|
4244
|
+
var It = (e) => {
|
|
4245
|
+
const i = (s, r = "inactive") => {
|
|
4246
|
+
const u2 = s.label ?? String(s.value);
|
|
4247
|
+
return r === "selected" ? `${(0, import_node_util2.styleText)("dim", u2)}` : r === "cancelled" ? `${(0, import_node_util2.styleText)(["strikethrough", "dim"], u2)}` : r === "active" ? `${(0, import_node_util2.styleText)(["bgCyan", "gray"], ` ${s.value} `)} ${u2}${s.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${s.hint})`)}` : ""}` : `${(0, import_node_util2.styleText)(["gray", "bgWhite", "inverse"], ` ${s.value} `)} ${u2}${s.hint ? ` ${(0, import_node_util2.styleText)("dim", `(${s.hint})`)}` : ""}`;
|
|
4248
|
+
};
|
|
4249
|
+
return new ot({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, caseSensitive: e.caseSensitive, render() {
|
|
4250
|
+
const s = e.withGuide ?? u.withGuide, r = `${s ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
4251
|
+
` : ""}${V2(this.state)} ${e.message}
|
|
4252
|
+
`;
|
|
4253
|
+
switch (this.state) {
|
|
4254
|
+
case "submit": {
|
|
4255
|
+
const u2 = s ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "", n = this.options.find((c2) => c2.value === this.value) ?? e.options[0], o = R(e.output, i(n, "selected"), u2);
|
|
4256
|
+
return `${r}${o}`;
|
|
4257
|
+
}
|
|
4258
|
+
case "cancel": {
|
|
4259
|
+
const u2 = s ? `${(0, import_node_util2.styleText)("gray", d2)} ` : "", n = R(e.output, i(this.options[0], "cancelled"), u2);
|
|
4260
|
+
return `${r}${n}${s ? `
|
|
4261
|
+
${(0, import_node_util2.styleText)("gray", d2)}` : ""}`;
|
|
4262
|
+
}
|
|
4263
|
+
default: {
|
|
4264
|
+
const u2 = s ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", n = s ? (0, import_node_util2.styleText)("cyan", E2) : "", o = this.options.map((c2, a) => R(e.output, i(c2, a === this.cursor ? "active" : "inactive"), u2)).join(`
|
|
4265
|
+
`);
|
|
4266
|
+
return `${r}${o}
|
|
4267
|
+
${n}
|
|
4268
|
+
`;
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
} }).prompt();
|
|
4272
|
+
};
|
|
4273
|
+
var je = `${(0, import_node_util2.styleText)("gray", d2)} `;
|
|
4274
|
+
var K2 = { message: async (e, { symbol: i = (0, import_node_util2.styleText)("gray", d2) } = {}) => {
|
|
4275
|
+
process.stdout.write(`${(0, import_node_util2.styleText)("gray", d2)}
|
|
4276
|
+
${i} `);
|
|
4277
|
+
let s = 3;
|
|
4278
|
+
for await (let r of e) {
|
|
4279
|
+
r = r.replace(/\n/g, `
|
|
4280
|
+
${je}`), r.includes(`
|
|
4281
|
+
`) && (s = 3 + (0, import_node_util2.stripVTControlCharacters)(r.slice(r.lastIndexOf(`
|
|
4282
|
+
`))).length);
|
|
4283
|
+
const u2 = (0, import_node_util2.stripVTControlCharacters)(r).length;
|
|
4284
|
+
s + u2 < process.stdout.columns ? (s += u2, process.stdout.write(r)) : (process.stdout.write(`
|
|
4285
|
+
${je}${r.trimStart()}`), s = 3 + (0, import_node_util2.stripVTControlCharacters)(r.trimStart()).length);
|
|
4286
|
+
}
|
|
4287
|
+
process.stdout.write(`
|
|
4288
|
+
`);
|
|
4289
|
+
}, info: (e) => K2.message(e, { symbol: (0, import_node_util2.styleText)("blue", he) }), success: (e) => K2.message(e, { symbol: (0, import_node_util2.styleText)("green", pe) }), step: (e) => K2.message(e, { symbol: (0, import_node_util2.styleText)("green", F2) }), warn: (e) => K2.message(e, { symbol: (0, import_node_util2.styleText)("yellow", me) }), warning: (e) => K2.warn(e), error: (e) => K2.message(e, { symbol: (0, import_node_util2.styleText)("red", ge) }) };
|
|
4290
|
+
var Et = async (e, i) => {
|
|
4291
|
+
for (const s of e) {
|
|
4292
|
+
if (s.enabled === false) continue;
|
|
4293
|
+
const r = fe(i);
|
|
4294
|
+
r.start(s.title);
|
|
4295
|
+
const u2 = await s.task(r.message);
|
|
4296
|
+
r.stop(u2 || s.title);
|
|
4297
|
+
}
|
|
4298
|
+
};
|
|
4299
|
+
var xt = (e) => e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
|
|
4300
|
+
var Gt = (e) => {
|
|
4301
|
+
const i = e.output ?? process.stdout, s = O(i), r = (0, import_node_util2.styleText)("gray", d2), u2 = e.spacing ?? 1, n = 3, o = e.retainLog === true, c2 = !ae() && Te(i);
|
|
4302
|
+
i.write(`${r}
|
|
4303
|
+
`), i.write(`${(0, import_node_util2.styleText)("green", F2)} ${e.title}
|
|
4304
|
+
`);
|
|
4305
|
+
for (let h = 0; h < u2; h++) i.write(`${r}
|
|
4306
|
+
`);
|
|
4307
|
+
const a = [{ value: "", full: "" }];
|
|
4308
|
+
let l = false;
|
|
4309
|
+
const $2 = (h) => {
|
|
4310
|
+
if (a.length === 0) return;
|
|
4311
|
+
let f = 0;
|
|
4312
|
+
h && (f += u2 + 2);
|
|
4313
|
+
for (const v of a) {
|
|
4314
|
+
const { value: T2, result: C2 } = v;
|
|
4315
|
+
let b = C2?.message ?? T2;
|
|
4316
|
+
if (b.length === 0) continue;
|
|
4317
|
+
C2 === void 0 && v.header !== void 0 && v.header !== "" && (b += `
|
|
4318
|
+
${v.header}`);
|
|
4319
|
+
const x = b.split(`
|
|
4320
|
+
`).reduce((G2, M2) => M2 === "" ? G2 + 1 : G2 + Math.ceil((M2.length + n) / s), 0);
|
|
4321
|
+
f += x;
|
|
4322
|
+
}
|
|
4323
|
+
f > 0 && (f += 1, i.write(import_sisteransi2.erase.lines(f)));
|
|
4324
|
+
}, y2 = (h, f, v) => {
|
|
4325
|
+
const T2 = v ? `${h.full}
|
|
4326
|
+
${h.value}` : h.value;
|
|
4327
|
+
h.header !== void 0 && h.header !== "" && O2.message(h.header.split(`
|
|
4328
|
+
`).map((C2) => (0, import_node_util2.styleText)("bold", C2)), { output: i, secondarySymbol: r, symbol: r, spacing: 0 }), O2.message(T2.split(`
|
|
4329
|
+
`).map((C2) => (0, import_node_util2.styleText)("dim", C2)), { output: i, secondarySymbol: r, symbol: r, spacing: f ?? u2 });
|
|
4330
|
+
}, p2 = () => {
|
|
4331
|
+
for (const h of a) {
|
|
4332
|
+
const { header: f, value: v, full: T2 } = h;
|
|
4333
|
+
(f === void 0 || f.length === 0) && v.length === 0 || y2(h, void 0, o === true && T2.length > 0);
|
|
4334
|
+
}
|
|
4335
|
+
}, m = (h, f, v) => {
|
|
4336
|
+
if ($2(false), (v?.raw !== true || !l) && h.value !== "" && (h.value += `
|
|
4337
|
+
`), h.value += xt(f), l = v?.raw === true, e.limit !== void 0) {
|
|
4338
|
+
const T2 = h.value.split(`
|
|
4339
|
+
`), C2 = T2.length - e.limit;
|
|
4340
|
+
if (C2 > 0) {
|
|
4341
|
+
const b = T2.splice(0, C2);
|
|
4342
|
+
o && (h.full += (h.full === "" ? "" : `
|
|
4343
|
+
`) + b.join(`
|
|
4344
|
+
`));
|
|
4345
|
+
}
|
|
4346
|
+
h.value = T2.join(`
|
|
4347
|
+
`);
|
|
4348
|
+
}
|
|
4349
|
+
c2 && g();
|
|
4350
|
+
}, g = () => {
|
|
4351
|
+
for (const h of a) h.result ? h.result.status === "error" ? O2.error(h.result.message, { output: i, secondarySymbol: r, spacing: 0 }) : O2.success(h.result.message, { output: i, secondarySymbol: r, spacing: 0 }) : h.value !== "" && y2(h, 0);
|
|
4352
|
+
}, S2 = (h, f) => {
|
|
4353
|
+
$2(false), h.result = f, c2 && g();
|
|
4354
|
+
};
|
|
4355
|
+
return { message(h, f) {
|
|
4356
|
+
m(a[0], h, f);
|
|
4357
|
+
}, group(h) {
|
|
4358
|
+
const f = { header: h, value: "", full: "" };
|
|
4359
|
+
return a.push(f), { message(v, T2) {
|
|
4360
|
+
m(f, v, T2);
|
|
4361
|
+
}, error(v) {
|
|
4362
|
+
S2(f, { status: "error", message: v });
|
|
4363
|
+
}, success(v) {
|
|
4364
|
+
S2(f, { status: "success", message: v });
|
|
4365
|
+
} };
|
|
4366
|
+
}, error(h, f) {
|
|
4367
|
+
$2(true), O2.error(h, { output: i, secondarySymbol: r, spacing: 1 }), f?.showLog !== false && p2(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
4368
|
+
}, success(h, f) {
|
|
4369
|
+
$2(true), O2.success(h, { output: i, secondarySymbol: r, spacing: 1 }), f?.showLog === true && p2(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
4370
|
+
} };
|
|
4371
|
+
};
|
|
4372
|
+
var Ot = (e) => new at({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
|
|
4373
|
+
const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${(0, import_node_util2.styleText)("gray", d2)}
|
|
4374
|
+
` : ""}${V2(this.state)} `}${e.message}
|
|
4375
|
+
`, r = e.placeholder ? (0, import_node_util2.styleText)("inverse", e.placeholder[0]) + (0, import_node_util2.styleText)("dim", e.placeholder.slice(1)) : (0, import_node_util2.styleText)(["inverse", "hidden"], "_"), u2 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
4376
|
+
switch (this.state) {
|
|
4377
|
+
case "error": {
|
|
4378
|
+
const o = this.error ? ` ${(0, import_node_util2.styleText)("yellow", this.error)}` : "", c2 = i ? `${(0, import_node_util2.styleText)("yellow", d2)} ` : "", a = i ? (0, import_node_util2.styleText)("yellow", E2) : "";
|
|
4379
|
+
return `${s.trim()}
|
|
4380
|
+
${c2}${u2}
|
|
4381
|
+
${a}${o}
|
|
4382
|
+
`;
|
|
4383
|
+
}
|
|
4384
|
+
case "submit": {
|
|
4385
|
+
const o = n ? ` ${(0, import_node_util2.styleText)("dim", n)}` : "", c2 = i ? (0, import_node_util2.styleText)("gray", d2) : "";
|
|
4386
|
+
return `${s}${c2}${o}`;
|
|
4387
|
+
}
|
|
4388
|
+
case "cancel": {
|
|
4389
|
+
const o = n ? ` ${(0, import_node_util2.styleText)(["strikethrough", "dim"], n)}` : "", c2 = i ? (0, import_node_util2.styleText)("gray", d2) : "";
|
|
4390
|
+
return `${s}${c2}${o}${n.trim() ? `
|
|
4391
|
+
${c2}` : ""}`;
|
|
4392
|
+
}
|
|
4393
|
+
default: {
|
|
4394
|
+
const o = i ? `${(0, import_node_util2.styleText)("cyan", d2)} ` : "", c2 = i ? (0, import_node_util2.styleText)("cyan", E2) : "";
|
|
4395
|
+
return `${s}${o}${u2}
|
|
4396
|
+
${c2}
|
|
4397
|
+
`;
|
|
4398
|
+
}
|
|
4399
|
+
}
|
|
4400
|
+
} }).prompt();
|
|
4401
|
+
|
|
2318
4402
|
// src/ui/prompts.ts
|
|
2319
|
-
var p = __toESM(require("@clack/prompts"));
|
|
2320
4403
|
async function confirmAction(message) {
|
|
2321
|
-
const result = await
|
|
2322
|
-
if (
|
|
4404
|
+
const result = await ot2({ message });
|
|
4405
|
+
if (q(result)) return false;
|
|
2323
4406
|
return result;
|
|
2324
4407
|
}
|
|
2325
4408
|
async function selectSession(sessions2, activeId) {
|
|
2326
|
-
const result = await
|
|
4409
|
+
const result = await _t({
|
|
2327
4410
|
message: "Select active session:",
|
|
2328
4411
|
options: sessions2.map((s) => ({
|
|
2329
4412
|
value: s.id,
|
|
@@ -2332,7 +4415,7 @@ async function selectSession(sessions2, activeId) {
|
|
|
2332
4415
|
})),
|
|
2333
4416
|
initialValue: activeId ?? void 0
|
|
2334
4417
|
});
|
|
2335
|
-
if (
|
|
4418
|
+
if (q(result)) return null;
|
|
2336
4419
|
return result;
|
|
2337
4420
|
}
|
|
2338
4421
|
|
|
@@ -2340,7 +4423,7 @@ async function selectSession(sessions2, activeId) {
|
|
|
2340
4423
|
async function pair() {
|
|
2341
4424
|
showIntro();
|
|
2342
4425
|
const pluginId = (0, import_crypto2.randomUUID)();
|
|
2343
|
-
const spin =
|
|
4426
|
+
const spin = dist_exports.spinner();
|
|
2344
4427
|
spin.start("Requesting pairing code...");
|
|
2345
4428
|
const result = await requestCode(pluginId);
|
|
2346
4429
|
if (!result) {
|
|
@@ -2352,7 +4435,7 @@ async function pair() {
|
|
|
2352
4435
|
showPairingCode(result.code, result.expiresAt);
|
|
2353
4436
|
console.log(import_picocolors3.default.dim(" Scan the QR code or enter the code in CodeAgent Mobile."));
|
|
2354
4437
|
console.log("");
|
|
2355
|
-
const waitSpin =
|
|
4438
|
+
const waitSpin = dist_exports.spinner();
|
|
2356
4439
|
waitSpin.start("Waiting for mobile app...");
|
|
2357
4440
|
await new Promise((resolve) => {
|
|
2358
4441
|
let stopPolling = null;
|
|
@@ -2372,7 +4455,8 @@ async function pair() {
|
|
|
2372
4455
|
userName: info.userName,
|
|
2373
4456
|
userEmail: info.userEmail,
|
|
2374
4457
|
plan: info.plan,
|
|
2375
|
-
pairedAt: Date.now()
|
|
4458
|
+
pairedAt: Date.now(),
|
|
4459
|
+
pluginAuthToken: info.pluginAuthToken
|
|
2376
4460
|
});
|
|
2377
4461
|
showSuccess(`Paired with ${info.userName} (${info.plan})`);
|
|
2378
4462
|
console.log("");
|