@craftspace/cli 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2338 -143
- package/dist/machine.d.ts +15 -1
- package/dist/machine.js +103 -14
- package/dist/probe.js +13 -13
- package/dist/run.js +26 -4
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +49 -5
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1199,9 +1199,9 @@ var require_command = __commonJS({
|
|
|
1199
1199
|
"../../../node_modules/commander/lib/command.js"(exports) {
|
|
1200
1200
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
1201
1201
|
var childProcess = __require("node:child_process");
|
|
1202
|
-
var
|
|
1202
|
+
var path5 = __require("node:path");
|
|
1203
1203
|
var fs = __require("node:fs");
|
|
1204
|
-
var
|
|
1204
|
+
var process5 = __require("node:process");
|
|
1205
1205
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
1206
1206
|
var { CommanderError: CommanderError2 } = require_error();
|
|
1207
1207
|
var { Help: Help2, stripColor } = require_help();
|
|
@@ -1248,13 +1248,13 @@ var require_command = __commonJS({
|
|
|
1248
1248
|
this._showSuggestionAfterError = true;
|
|
1249
1249
|
this._savedState = null;
|
|
1250
1250
|
this._outputConfiguration = {
|
|
1251
|
-
writeOut: (str) =>
|
|
1252
|
-
writeErr: (str) =>
|
|
1251
|
+
writeOut: (str) => process5.stdout.write(str),
|
|
1252
|
+
writeErr: (str) => process5.stderr.write(str),
|
|
1253
1253
|
outputError: (str, write) => write(str),
|
|
1254
|
-
getOutHelpWidth: () =>
|
|
1255
|
-
getErrHelpWidth: () =>
|
|
1256
|
-
getOutHasColors: () => useColor() ?? (
|
|
1257
|
-
getErrHasColors: () => useColor() ?? (
|
|
1254
|
+
getOutHelpWidth: () => process5.stdout.isTTY ? process5.stdout.columns : void 0,
|
|
1255
|
+
getErrHelpWidth: () => process5.stderr.isTTY ? process5.stderr.columns : void 0,
|
|
1256
|
+
getOutHasColors: () => useColor() ?? (process5.stdout.isTTY && process5.stdout.hasColors?.()),
|
|
1257
|
+
getErrHasColors: () => useColor() ?? (process5.stderr.isTTY && process5.stderr.hasColors?.()),
|
|
1258
1258
|
stripColor: (str) => stripColor(str)
|
|
1259
1259
|
};
|
|
1260
1260
|
this._hidden = false;
|
|
@@ -1648,7 +1648,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1648
1648
|
if (this._exitCallback) {
|
|
1649
1649
|
this._exitCallback(new CommanderError2(exitCode, code, message));
|
|
1650
1650
|
}
|
|
1651
|
-
|
|
1651
|
+
process5.exit(exitCode);
|
|
1652
1652
|
}
|
|
1653
1653
|
/**
|
|
1654
1654
|
* Register callback `fn` for the command.
|
|
@@ -2048,16 +2048,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2048
2048
|
}
|
|
2049
2049
|
parseOptions = parseOptions || {};
|
|
2050
2050
|
if (argv === void 0 && parseOptions.from === void 0) {
|
|
2051
|
-
if (
|
|
2051
|
+
if (process5.versions?.electron) {
|
|
2052
2052
|
parseOptions.from = "electron";
|
|
2053
2053
|
}
|
|
2054
|
-
const execArgv =
|
|
2054
|
+
const execArgv = process5.execArgv ?? [];
|
|
2055
2055
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
2056
2056
|
parseOptions.from = "eval";
|
|
2057
2057
|
}
|
|
2058
2058
|
}
|
|
2059
2059
|
if (argv === void 0) {
|
|
2060
|
-
argv =
|
|
2060
|
+
argv = process5.argv;
|
|
2061
2061
|
}
|
|
2062
2062
|
this.rawArgs = argv.slice();
|
|
2063
2063
|
let userArgs;
|
|
@@ -2068,7 +2068,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2068
2068
|
userArgs = argv.slice(2);
|
|
2069
2069
|
break;
|
|
2070
2070
|
case "electron":
|
|
2071
|
-
if (
|
|
2071
|
+
if (process5.defaultApp) {
|
|
2072
2072
|
this._scriptPath = argv[1];
|
|
2073
2073
|
userArgs = argv.slice(2);
|
|
2074
2074
|
} else {
|
|
@@ -2212,9 +2212,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2212
2212
|
let launchWithNode = false;
|
|
2213
2213
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2214
2214
|
function findFile(baseDir, baseName) {
|
|
2215
|
-
const localBin =
|
|
2215
|
+
const localBin = path5.resolve(baseDir, baseName);
|
|
2216
2216
|
if (fs.existsSync(localBin)) return localBin;
|
|
2217
|
-
if (sourceExt.includes(
|
|
2217
|
+
if (sourceExt.includes(path5.extname(baseName))) return void 0;
|
|
2218
2218
|
const foundExt = sourceExt.find(
|
|
2219
2219
|
(ext) => fs.existsSync(`${localBin}${ext}`)
|
|
2220
2220
|
);
|
|
@@ -2232,17 +2232,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2232
2232
|
} catch {
|
|
2233
2233
|
resolvedScriptPath = this._scriptPath;
|
|
2234
2234
|
}
|
|
2235
|
-
executableDir =
|
|
2236
|
-
|
|
2235
|
+
executableDir = path5.resolve(
|
|
2236
|
+
path5.dirname(resolvedScriptPath),
|
|
2237
2237
|
executableDir
|
|
2238
2238
|
);
|
|
2239
2239
|
}
|
|
2240
2240
|
if (executableDir) {
|
|
2241
2241
|
let localFile = findFile(executableDir, executableFile);
|
|
2242
2242
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2243
|
-
const legacyName =
|
|
2243
|
+
const legacyName = path5.basename(
|
|
2244
2244
|
this._scriptPath,
|
|
2245
|
-
|
|
2245
|
+
path5.extname(this._scriptPath)
|
|
2246
2246
|
);
|
|
2247
2247
|
if (legacyName !== this._name) {
|
|
2248
2248
|
localFile = findFile(
|
|
@@ -2253,13 +2253,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2253
2253
|
}
|
|
2254
2254
|
executableFile = localFile || executableFile;
|
|
2255
2255
|
}
|
|
2256
|
-
launchWithNode = sourceExt.includes(
|
|
2256
|
+
launchWithNode = sourceExt.includes(path5.extname(executableFile));
|
|
2257
2257
|
let proc;
|
|
2258
|
-
if (
|
|
2258
|
+
if (process5.platform !== "win32") {
|
|
2259
2259
|
if (launchWithNode) {
|
|
2260
2260
|
args.unshift(executableFile);
|
|
2261
|
-
args = incrementNodeInspectorPort(
|
|
2262
|
-
proc = childProcess.spawn(
|
|
2261
|
+
args = incrementNodeInspectorPort(process5.execArgv).concat(args);
|
|
2262
|
+
proc = childProcess.spawn(process5.argv[0], args, { stdio: "inherit" });
|
|
2263
2263
|
} else {
|
|
2264
2264
|
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
2265
2265
|
}
|
|
@@ -2270,13 +2270,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2270
2270
|
subcommand._name
|
|
2271
2271
|
);
|
|
2272
2272
|
args.unshift(executableFile);
|
|
2273
|
-
args = incrementNodeInspectorPort(
|
|
2274
|
-
proc = childProcess.spawn(
|
|
2273
|
+
args = incrementNodeInspectorPort(process5.execArgv).concat(args);
|
|
2274
|
+
proc = childProcess.spawn(process5.execPath, args, { stdio: "inherit" });
|
|
2275
2275
|
}
|
|
2276
2276
|
if (!proc.killed) {
|
|
2277
|
-
const
|
|
2278
|
-
|
|
2279
|
-
|
|
2277
|
+
const signals2 = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
2278
|
+
signals2.forEach((signal) => {
|
|
2279
|
+
process5.on(signal, () => {
|
|
2280
2280
|
if (proc.killed === false && proc.exitCode === null) {
|
|
2281
2281
|
proc.kill(signal);
|
|
2282
2282
|
}
|
|
@@ -2287,7 +2287,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2287
2287
|
proc.on("close", (code) => {
|
|
2288
2288
|
code = code ?? 1;
|
|
2289
2289
|
if (!exitCallback) {
|
|
2290
|
-
|
|
2290
|
+
process5.exit(code);
|
|
2291
2291
|
} else {
|
|
2292
2292
|
exitCallback(
|
|
2293
2293
|
new CommanderError2(
|
|
@@ -2309,7 +2309,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2309
2309
|
throw new Error(`'${executableFile}' not executable`);
|
|
2310
2310
|
}
|
|
2311
2311
|
if (!exitCallback) {
|
|
2312
|
-
|
|
2312
|
+
process5.exit(1);
|
|
2313
2313
|
} else {
|
|
2314
2314
|
const wrappedError = new CommanderError2(
|
|
2315
2315
|
1,
|
|
@@ -2809,13 +2809,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2809
2809
|
*/
|
|
2810
2810
|
_parseOptionsEnv() {
|
|
2811
2811
|
this.options.forEach((option) => {
|
|
2812
|
-
if (option.envVar && option.envVar in
|
|
2812
|
+
if (option.envVar && option.envVar in process5.env) {
|
|
2813
2813
|
const optionKey = option.attributeName();
|
|
2814
2814
|
if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
|
|
2815
2815
|
this.getOptionValueSource(optionKey)
|
|
2816
2816
|
)) {
|
|
2817
2817
|
if (option.required || option.optional) {
|
|
2818
|
-
this.emit(`optionEnv:${option.name()}`,
|
|
2818
|
+
this.emit(`optionEnv:${option.name()}`, process5.env[option.envVar]);
|
|
2819
2819
|
} else {
|
|
2820
2820
|
this.emit(`optionEnv:${option.name()}`);
|
|
2821
2821
|
}
|
|
@@ -3168,7 +3168,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3168
3168
|
* @return {Command}
|
|
3169
3169
|
*/
|
|
3170
3170
|
nameFromFilename(filename) {
|
|
3171
|
-
this._name =
|
|
3171
|
+
this._name = path5.basename(filename, path5.extname(filename));
|
|
3172
3172
|
return this;
|
|
3173
3173
|
}
|
|
3174
3174
|
/**
|
|
@@ -3182,9 +3182,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3182
3182
|
* @param {string} [path]
|
|
3183
3183
|
* @return {(string|null|Command)}
|
|
3184
3184
|
*/
|
|
3185
|
-
executableDir(
|
|
3186
|
-
if (
|
|
3187
|
-
this._executableDir =
|
|
3185
|
+
executableDir(path6) {
|
|
3186
|
+
if (path6 === void 0) return this._executableDir;
|
|
3187
|
+
this._executableDir = path6;
|
|
3188
3188
|
return this;
|
|
3189
3189
|
}
|
|
3190
3190
|
/**
|
|
@@ -3339,7 +3339,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3339
3339
|
*/
|
|
3340
3340
|
help(contextOptions) {
|
|
3341
3341
|
this.outputHelp(contextOptions);
|
|
3342
|
-
let exitCode = Number(
|
|
3342
|
+
let exitCode = Number(process5.exitCode ?? 0);
|
|
3343
3343
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
3344
3344
|
exitCode = 1;
|
|
3345
3345
|
}
|
|
@@ -3429,9 +3429,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3429
3429
|
});
|
|
3430
3430
|
}
|
|
3431
3431
|
function useColor() {
|
|
3432
|
-
if (
|
|
3432
|
+
if (process5.env.NO_COLOR || process5.env.FORCE_COLOR === "0" || process5.env.FORCE_COLOR === "false")
|
|
3433
3433
|
return false;
|
|
3434
|
-
if (
|
|
3434
|
+
if (process5.env.FORCE_COLOR || process5.env.CLICOLOR_FORCE !== void 0)
|
|
3435
3435
|
return true;
|
|
3436
3436
|
return void 0;
|
|
3437
3437
|
}
|
|
@@ -3462,6 +3462,171 @@ var require_commander = __commonJS({
|
|
|
3462
3462
|
}
|
|
3463
3463
|
});
|
|
3464
3464
|
|
|
3465
|
+
// ../../../node_modules/cli-width/index.js
|
|
3466
|
+
var require_cli_width = __commonJS({
|
|
3467
|
+
"../../../node_modules/cli-width/index.js"(exports, module) {
|
|
3468
|
+
"use strict";
|
|
3469
|
+
module.exports = cliWidth2;
|
|
3470
|
+
function normalizeOpts(options) {
|
|
3471
|
+
const defaultOpts = {
|
|
3472
|
+
defaultWidth: 0,
|
|
3473
|
+
output: process.stdout,
|
|
3474
|
+
tty: __require("tty")
|
|
3475
|
+
};
|
|
3476
|
+
if (!options) {
|
|
3477
|
+
return defaultOpts;
|
|
3478
|
+
}
|
|
3479
|
+
Object.keys(defaultOpts).forEach(function(key) {
|
|
3480
|
+
if (!options[key]) {
|
|
3481
|
+
options[key] = defaultOpts[key];
|
|
3482
|
+
}
|
|
3483
|
+
});
|
|
3484
|
+
return options;
|
|
3485
|
+
}
|
|
3486
|
+
function cliWidth2(options) {
|
|
3487
|
+
const opts = normalizeOpts(options);
|
|
3488
|
+
if (opts.output.getWindowSize) {
|
|
3489
|
+
return opts.output.getWindowSize()[0] || opts.defaultWidth;
|
|
3490
|
+
}
|
|
3491
|
+
if (opts.tty.getWindowSize) {
|
|
3492
|
+
return opts.tty.getWindowSize()[1] || opts.defaultWidth;
|
|
3493
|
+
}
|
|
3494
|
+
if (opts.output.columns) {
|
|
3495
|
+
return opts.output.columns;
|
|
3496
|
+
}
|
|
3497
|
+
if (process.env.CLI_WIDTH) {
|
|
3498
|
+
const width = parseInt(process.env.CLI_WIDTH, 10);
|
|
3499
|
+
if (!isNaN(width) && width !== 0) {
|
|
3500
|
+
return width;
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
return opts.defaultWidth;
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
});
|
|
3507
|
+
|
|
3508
|
+
// ../../../node_modules/mute-stream/lib/index.js
|
|
3509
|
+
var require_lib = __commonJS({
|
|
3510
|
+
"../../../node_modules/mute-stream/lib/index.js"(exports, module) {
|
|
3511
|
+
var Stream = __require("stream");
|
|
3512
|
+
var MuteStream2 = class extends Stream {
|
|
3513
|
+
#isTTY = null;
|
|
3514
|
+
constructor(opts = {}) {
|
|
3515
|
+
super(opts);
|
|
3516
|
+
this.writable = this.readable = true;
|
|
3517
|
+
this.muted = false;
|
|
3518
|
+
this.on("pipe", this._onpipe);
|
|
3519
|
+
this.replace = opts.replace;
|
|
3520
|
+
this._prompt = opts.prompt || null;
|
|
3521
|
+
this._hadControl = false;
|
|
3522
|
+
}
|
|
3523
|
+
#destSrc(key, def) {
|
|
3524
|
+
if (this._dest) {
|
|
3525
|
+
return this._dest[key];
|
|
3526
|
+
}
|
|
3527
|
+
if (this._src) {
|
|
3528
|
+
return this._src[key];
|
|
3529
|
+
}
|
|
3530
|
+
return def;
|
|
3531
|
+
}
|
|
3532
|
+
#proxy(method, ...args) {
|
|
3533
|
+
if (typeof this._dest?.[method] === "function") {
|
|
3534
|
+
this._dest[method](...args);
|
|
3535
|
+
}
|
|
3536
|
+
if (typeof this._src?.[method] === "function") {
|
|
3537
|
+
this._src[method](...args);
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
get isTTY() {
|
|
3541
|
+
if (this.#isTTY !== null) {
|
|
3542
|
+
return this.#isTTY;
|
|
3543
|
+
}
|
|
3544
|
+
return this.#destSrc("isTTY", false);
|
|
3545
|
+
}
|
|
3546
|
+
// basically just get replace the getter/setter with a regular value
|
|
3547
|
+
set isTTY(val) {
|
|
3548
|
+
this.#isTTY = val;
|
|
3549
|
+
}
|
|
3550
|
+
get rows() {
|
|
3551
|
+
return this.#destSrc("rows");
|
|
3552
|
+
}
|
|
3553
|
+
get columns() {
|
|
3554
|
+
return this.#destSrc("columns");
|
|
3555
|
+
}
|
|
3556
|
+
mute() {
|
|
3557
|
+
this.muted = true;
|
|
3558
|
+
}
|
|
3559
|
+
unmute() {
|
|
3560
|
+
this.muted = false;
|
|
3561
|
+
}
|
|
3562
|
+
_onpipe(src) {
|
|
3563
|
+
this._src = src;
|
|
3564
|
+
}
|
|
3565
|
+
pipe(dest, options) {
|
|
3566
|
+
this._dest = dest;
|
|
3567
|
+
return super.pipe(dest, options);
|
|
3568
|
+
}
|
|
3569
|
+
pause() {
|
|
3570
|
+
if (this._src) {
|
|
3571
|
+
return this._src.pause();
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
resume() {
|
|
3575
|
+
if (this._src) {
|
|
3576
|
+
return this._src.resume();
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
write(c) {
|
|
3580
|
+
if (this.muted) {
|
|
3581
|
+
if (!this.replace) {
|
|
3582
|
+
return true;
|
|
3583
|
+
}
|
|
3584
|
+
if (c.match(/^\u001b/)) {
|
|
3585
|
+
if (c.indexOf(this._prompt) === 0) {
|
|
3586
|
+
c = c.slice(this._prompt.length);
|
|
3587
|
+
c = c.replace(/./g, this.replace);
|
|
3588
|
+
c = this._prompt + c;
|
|
3589
|
+
}
|
|
3590
|
+
this._hadControl = true;
|
|
3591
|
+
return this.emit("data", c);
|
|
3592
|
+
} else {
|
|
3593
|
+
if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
|
|
3594
|
+
this._hadControl = false;
|
|
3595
|
+
this.emit("data", this._prompt);
|
|
3596
|
+
c = c.slice(this._prompt.length);
|
|
3597
|
+
}
|
|
3598
|
+
c = c.toString().replace(/./g, this.replace);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
this.emit("data", c);
|
|
3602
|
+
}
|
|
3603
|
+
end(c) {
|
|
3604
|
+
if (this.muted) {
|
|
3605
|
+
if (c && this.replace) {
|
|
3606
|
+
c = c.toString().replace(/./g, this.replace);
|
|
3607
|
+
} else {
|
|
3608
|
+
c = null;
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
if (c) {
|
|
3612
|
+
this.emit("data", c);
|
|
3613
|
+
}
|
|
3614
|
+
this.emit("end");
|
|
3615
|
+
}
|
|
3616
|
+
destroy(...args) {
|
|
3617
|
+
return this.#proxy("destroy", ...args);
|
|
3618
|
+
}
|
|
3619
|
+
destroySoon(...args) {
|
|
3620
|
+
return this.#proxy("destroySoon", ...args);
|
|
3621
|
+
}
|
|
3622
|
+
close(...args) {
|
|
3623
|
+
return this.#proxy("close", ...args);
|
|
3624
|
+
}
|
|
3625
|
+
};
|
|
3626
|
+
module.exports = MuteStream2;
|
|
3627
|
+
}
|
|
3628
|
+
});
|
|
3629
|
+
|
|
3465
3630
|
// ../../../node_modules/commander/esm.mjs
|
|
3466
3631
|
var import_index = __toESM(require_commander(), 1);
|
|
3467
3632
|
var {
|
|
@@ -4245,10 +4410,10 @@ function mergeDefs(...defs) {
|
|
|
4245
4410
|
function cloneDef(schema) {
|
|
4246
4411
|
return mergeDefs(schema._zod.def);
|
|
4247
4412
|
}
|
|
4248
|
-
function getElementAtPath(obj,
|
|
4249
|
-
if (!
|
|
4413
|
+
function getElementAtPath(obj, path5) {
|
|
4414
|
+
if (!path5)
|
|
4250
4415
|
return obj;
|
|
4251
|
-
return
|
|
4416
|
+
return path5.reduce((acc, key) => acc?.[key], obj);
|
|
4252
4417
|
}
|
|
4253
4418
|
function promiseAllObject(promisesObj) {
|
|
4254
4419
|
const keys = Object.keys(promisesObj);
|
|
@@ -4657,11 +4822,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
4657
4822
|
}
|
|
4658
4823
|
return false;
|
|
4659
4824
|
}
|
|
4660
|
-
function prefixIssues(
|
|
4825
|
+
function prefixIssues(path5, issues) {
|
|
4661
4826
|
return issues.map((iss) => {
|
|
4662
4827
|
var _a3;
|
|
4663
4828
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
4664
|
-
iss.path.unshift(
|
|
4829
|
+
iss.path.unshift(path5);
|
|
4665
4830
|
return iss;
|
|
4666
4831
|
});
|
|
4667
4832
|
}
|
|
@@ -4808,16 +4973,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4808
4973
|
}
|
|
4809
4974
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
4810
4975
|
const fieldErrors = { _errors: [] };
|
|
4811
|
-
const processError = (error52,
|
|
4976
|
+
const processError = (error52, path5 = []) => {
|
|
4812
4977
|
for (const issue2 of error52.issues) {
|
|
4813
4978
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4814
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
4979
|
+
issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
|
|
4815
4980
|
} else if (issue2.code === "invalid_key") {
|
|
4816
|
-
processError({ issues: issue2.issues }, [...
|
|
4981
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
4817
4982
|
} else if (issue2.code === "invalid_element") {
|
|
4818
|
-
processError({ issues: issue2.issues }, [...
|
|
4983
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
4819
4984
|
} else {
|
|
4820
|
-
const fullpath = [...
|
|
4985
|
+
const fullpath = [...path5, ...issue2.path];
|
|
4821
4986
|
if (fullpath.length === 0) {
|
|
4822
4987
|
fieldErrors._errors.push(mapper(issue2));
|
|
4823
4988
|
} else {
|
|
@@ -4844,17 +5009,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4844
5009
|
}
|
|
4845
5010
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
4846
5011
|
const result = { errors: [] };
|
|
4847
|
-
const processError = (error52,
|
|
5012
|
+
const processError = (error52, path5 = []) => {
|
|
4848
5013
|
var _a3, _b;
|
|
4849
5014
|
for (const issue2 of error52.issues) {
|
|
4850
5015
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4851
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
5016
|
+
issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
|
|
4852
5017
|
} else if (issue2.code === "invalid_key") {
|
|
4853
|
-
processError({ issues: issue2.issues }, [...
|
|
5018
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
4854
5019
|
} else if (issue2.code === "invalid_element") {
|
|
4855
|
-
processError({ issues: issue2.issues }, [...
|
|
5020
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
4856
5021
|
} else {
|
|
4857
|
-
const fullpath = [...
|
|
5022
|
+
const fullpath = [...path5, ...issue2.path];
|
|
4858
5023
|
if (fullpath.length === 0) {
|
|
4859
5024
|
result.errors.push(mapper(issue2));
|
|
4860
5025
|
continue;
|
|
@@ -4886,8 +5051,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4886
5051
|
}
|
|
4887
5052
|
function toDotPath(_path) {
|
|
4888
5053
|
const segs = [];
|
|
4889
|
-
const
|
|
4890
|
-
for (const seg of
|
|
5054
|
+
const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
5055
|
+
for (const seg of path5) {
|
|
4891
5056
|
if (typeof seg === "number")
|
|
4892
5057
|
segs.push(`[${seg}]`);
|
|
4893
5058
|
else if (typeof seg === "symbol")
|
|
@@ -17579,13 +17744,13 @@ function resolveRef(ref, ctx) {
|
|
|
17579
17744
|
if (!ref.startsWith("#")) {
|
|
17580
17745
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
17581
17746
|
}
|
|
17582
|
-
const
|
|
17583
|
-
if (
|
|
17747
|
+
const path5 = ref.slice(1).split("/").filter(Boolean);
|
|
17748
|
+
if (path5.length === 0) {
|
|
17584
17749
|
return ctx.rootSchema;
|
|
17585
17750
|
}
|
|
17586
17751
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
17587
|
-
if (
|
|
17588
|
-
const key =
|
|
17752
|
+
if (path5[0] === defsKey) {
|
|
17753
|
+
const key = path5[1];
|
|
17589
17754
|
if (!key || !ctx.defs[key]) {
|
|
17590
17755
|
throw new Error(`Reference not found: ${ref}`);
|
|
17591
17756
|
}
|
|
@@ -19093,6 +19258,12 @@ var CreateConnectionBodySchema = external_exports.object({
|
|
|
19093
19258
|
// sent it, and can start a connect for that one kit and nothing else.
|
|
19094
19259
|
inviteToken: external_exports.string().optional()
|
|
19095
19260
|
});
|
|
19261
|
+
var ReplaceConnectionSecretBodySchema = external_exports.object({
|
|
19262
|
+
mcpUrl: external_exports.url().optional(),
|
|
19263
|
+
authToken: external_exports.string().min(1).optional(),
|
|
19264
|
+
dsn: external_exports.string().min(1).optional(),
|
|
19265
|
+
apiKey: external_exports.string().min(1).optional()
|
|
19266
|
+
});
|
|
19096
19267
|
var ConnectionIdParamsSchema = external_exports.object({ id: external_exports.string() });
|
|
19097
19268
|
var PendingOAuthSchema = external_exports.object({
|
|
19098
19269
|
id: external_exports.string(),
|
|
@@ -19589,7 +19760,7 @@ var SaveWorkstationBodySchema = external_exports.object({
|
|
|
19589
19760
|
var WorkstationResponseSchema = external_exports.object({ workstation: WorkstationSchema });
|
|
19590
19761
|
|
|
19591
19762
|
// ../../shared/dist/machines/machine.js
|
|
19592
|
-
var CLI_VERSION = "0.
|
|
19763
|
+
var CLI_VERSION = "0.2.0";
|
|
19593
19764
|
var MACHINE_BEAT_INTERVAL_MS = 15e3;
|
|
19594
19765
|
var MACHINE_BEAT_BUSY_INTERVAL_MS = 3e3;
|
|
19595
19766
|
var MACHINE_RUN_OUTPUT_MAX = 32e3;
|
|
@@ -20056,12 +20227,1877 @@ var MemberActivityListResponse = external_exports.object({
|
|
|
20056
20227
|
// dist/machine.js
|
|
20057
20228
|
import { execFile as execFile3 } from "node:child_process";
|
|
20058
20229
|
import { mkdir, readFile as readFile2, readdir, rm, writeFile } from "node:fs/promises";
|
|
20059
|
-
import
|
|
20060
|
-
import
|
|
20230
|
+
import os4 from "node:os";
|
|
20231
|
+
import path4 from "node:path";
|
|
20061
20232
|
import { promisify as promisify3 } from "node:util";
|
|
20062
20233
|
|
|
20234
|
+
// ../../../node_modules/@inquirer/core/dist/lib/key.js
|
|
20235
|
+
var keybindings = ["emacs", "vim"];
|
|
20236
|
+
var keybindingLookup = new Set(keybindings);
|
|
20237
|
+
function isKeybinding(value) {
|
|
20238
|
+
return keybindingLookup.has(value);
|
|
20239
|
+
}
|
|
20240
|
+
function getDefaultKeybindings() {
|
|
20241
|
+
const env = process.env["INQUIRER_KEYBINDINGS"];
|
|
20242
|
+
if (!env)
|
|
20243
|
+
return [];
|
|
20244
|
+
return Array.from(new Set(env.toLowerCase().split(/[\s,]+/).filter(isKeybinding)));
|
|
20245
|
+
}
|
|
20246
|
+
var isUpKey = (key, keybindings2 = []) => (
|
|
20247
|
+
// The up key
|
|
20248
|
+
key.name === "up" || // Vim keybinding: hjkl keys map to left/down/up/right
|
|
20249
|
+
keybindings2.includes("vim") && key.name === "k" || // Emacs keybinding: Ctrl+P means "previous" in Emacs navigation conventions
|
|
20250
|
+
keybindings2.includes("emacs") && key.ctrl && key.name === "p"
|
|
20251
|
+
);
|
|
20252
|
+
var isDownKey = (key, keybindings2 = []) => (
|
|
20253
|
+
// The down key
|
|
20254
|
+
key.name === "down" || // Vim keybinding: hjkl keys map to left/down/up/right
|
|
20255
|
+
keybindings2.includes("vim") && key.name === "j" || // Emacs keybinding: Ctrl+N means "next" in Emacs navigation conventions
|
|
20256
|
+
keybindings2.includes("emacs") && key.ctrl && key.name === "n"
|
|
20257
|
+
);
|
|
20258
|
+
var isBackspaceKey = (key) => key.name === "backspace";
|
|
20259
|
+
var isTabKey = (key) => key.name === "tab";
|
|
20260
|
+
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
20261
|
+
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
20262
|
+
|
|
20263
|
+
// ../../../node_modules/@inquirer/core/dist/lib/errors.js
|
|
20264
|
+
var AbortPromptError = class extends Error {
|
|
20265
|
+
name = "AbortPromptError";
|
|
20266
|
+
message = "Prompt was aborted";
|
|
20267
|
+
constructor(options) {
|
|
20268
|
+
super();
|
|
20269
|
+
this.cause = options?.cause;
|
|
20270
|
+
}
|
|
20271
|
+
};
|
|
20272
|
+
var CancelPromptError = class extends Error {
|
|
20273
|
+
name = "CancelPromptError";
|
|
20274
|
+
message = "Prompt was canceled";
|
|
20275
|
+
};
|
|
20276
|
+
var ExitPromptError = class extends Error {
|
|
20277
|
+
name = "ExitPromptError";
|
|
20278
|
+
};
|
|
20279
|
+
var HookError = class extends Error {
|
|
20280
|
+
name = "HookError";
|
|
20281
|
+
};
|
|
20282
|
+
var ValidationError = class extends Error {
|
|
20283
|
+
name = "ValidationError";
|
|
20284
|
+
};
|
|
20285
|
+
|
|
20286
|
+
// ../../../node_modules/@inquirer/core/dist/lib/use-state.js
|
|
20287
|
+
import { AsyncResource as AsyncResource2 } from "node:async_hooks";
|
|
20288
|
+
|
|
20289
|
+
// ../../../node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
20290
|
+
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
20291
|
+
var hookStorage = new AsyncLocalStorage();
|
|
20292
|
+
function createStore(rl) {
|
|
20293
|
+
const store = {
|
|
20294
|
+
rl,
|
|
20295
|
+
hooks: [],
|
|
20296
|
+
hooksCleanup: [],
|
|
20297
|
+
hooksEffect: [],
|
|
20298
|
+
index: 0,
|
|
20299
|
+
handleChange() {
|
|
20300
|
+
}
|
|
20301
|
+
};
|
|
20302
|
+
return store;
|
|
20303
|
+
}
|
|
20304
|
+
function withHooks(rl, cb) {
|
|
20305
|
+
const store = createStore(rl);
|
|
20306
|
+
return hookStorage.run(store, () => {
|
|
20307
|
+
function cycle(render) {
|
|
20308
|
+
store.handleChange = () => {
|
|
20309
|
+
store.index = 0;
|
|
20310
|
+
render();
|
|
20311
|
+
};
|
|
20312
|
+
store.handleChange();
|
|
20313
|
+
}
|
|
20314
|
+
return cb(cycle);
|
|
20315
|
+
});
|
|
20316
|
+
}
|
|
20317
|
+
function getStore() {
|
|
20318
|
+
const store = hookStorage.getStore();
|
|
20319
|
+
if (!store) {
|
|
20320
|
+
throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
|
|
20321
|
+
}
|
|
20322
|
+
return store;
|
|
20323
|
+
}
|
|
20324
|
+
function readline() {
|
|
20325
|
+
return getStore().rl;
|
|
20326
|
+
}
|
|
20327
|
+
function withUpdates(fn) {
|
|
20328
|
+
const wrapped = (...args) => {
|
|
20329
|
+
const store = getStore();
|
|
20330
|
+
let shouldUpdate = false;
|
|
20331
|
+
const oldHandleChange = store.handleChange;
|
|
20332
|
+
store.handleChange = () => {
|
|
20333
|
+
shouldUpdate = true;
|
|
20334
|
+
};
|
|
20335
|
+
const returnValue = fn(...args);
|
|
20336
|
+
if (shouldUpdate) {
|
|
20337
|
+
oldHandleChange();
|
|
20338
|
+
}
|
|
20339
|
+
store.handleChange = oldHandleChange;
|
|
20340
|
+
return returnValue;
|
|
20341
|
+
};
|
|
20342
|
+
return AsyncResource.bind(wrapped);
|
|
20343
|
+
}
|
|
20344
|
+
function withPointer(cb) {
|
|
20345
|
+
const store = getStore();
|
|
20346
|
+
const { index } = store;
|
|
20347
|
+
const pointer = {
|
|
20348
|
+
get() {
|
|
20349
|
+
return store.hooks[index];
|
|
20350
|
+
},
|
|
20351
|
+
set(value) {
|
|
20352
|
+
store.hooks[index] = value;
|
|
20353
|
+
},
|
|
20354
|
+
initialized: index in store.hooks
|
|
20355
|
+
};
|
|
20356
|
+
const returnValue = cb(pointer);
|
|
20357
|
+
store.index++;
|
|
20358
|
+
return returnValue;
|
|
20359
|
+
}
|
|
20360
|
+
function handleChange() {
|
|
20361
|
+
getStore().handleChange();
|
|
20362
|
+
}
|
|
20363
|
+
var effectScheduler = {
|
|
20364
|
+
queue(cb) {
|
|
20365
|
+
const store = getStore();
|
|
20366
|
+
const { index } = store;
|
|
20367
|
+
store.hooksEffect.push(() => {
|
|
20368
|
+
store.hooksCleanup[index]?.();
|
|
20369
|
+
const cleanFn = cb(readline());
|
|
20370
|
+
if (cleanFn != null && typeof cleanFn !== "function") {
|
|
20371
|
+
throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
|
|
20372
|
+
}
|
|
20373
|
+
store.hooksCleanup[index] = cleanFn;
|
|
20374
|
+
});
|
|
20375
|
+
},
|
|
20376
|
+
run() {
|
|
20377
|
+
const store = getStore();
|
|
20378
|
+
withUpdates(() => {
|
|
20379
|
+
store.hooksEffect.forEach((effect) => {
|
|
20380
|
+
effect();
|
|
20381
|
+
});
|
|
20382
|
+
store.hooksEffect.length = 0;
|
|
20383
|
+
})();
|
|
20384
|
+
},
|
|
20385
|
+
clearAll() {
|
|
20386
|
+
const store = getStore();
|
|
20387
|
+
store.hooksCleanup.forEach((cleanFn) => {
|
|
20388
|
+
cleanFn?.();
|
|
20389
|
+
});
|
|
20390
|
+
store.hooksEffect.length = 0;
|
|
20391
|
+
store.hooksCleanup.length = 0;
|
|
20392
|
+
}
|
|
20393
|
+
};
|
|
20394
|
+
|
|
20395
|
+
// ../../../node_modules/@inquirer/core/dist/lib/use-state.js
|
|
20396
|
+
function isFactory(value) {
|
|
20397
|
+
return typeof value === "function";
|
|
20398
|
+
}
|
|
20399
|
+
function isReducer(value) {
|
|
20400
|
+
return typeof value === "function";
|
|
20401
|
+
}
|
|
20402
|
+
function useState(defaultValue) {
|
|
20403
|
+
return withPointer((pointer) => {
|
|
20404
|
+
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
20405
|
+
const currentValue = pointer.get();
|
|
20406
|
+
const nextValue = isReducer(newValue) ? newValue(currentValue) : newValue;
|
|
20407
|
+
if (!Object.is(currentValue, nextValue)) {
|
|
20408
|
+
pointer.set(nextValue);
|
|
20409
|
+
handleChange();
|
|
20410
|
+
}
|
|
20411
|
+
});
|
|
20412
|
+
if (pointer.initialized) {
|
|
20413
|
+
return [pointer.get(), setState];
|
|
20414
|
+
}
|
|
20415
|
+
const value = isFactory(defaultValue) ? defaultValue() : defaultValue;
|
|
20416
|
+
pointer.set(value);
|
|
20417
|
+
return [value, setState];
|
|
20418
|
+
});
|
|
20419
|
+
}
|
|
20420
|
+
|
|
20421
|
+
// ../../../node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
20422
|
+
function useEffect(cb, depArray) {
|
|
20423
|
+
withPointer((pointer) => {
|
|
20424
|
+
const oldDeps = pointer.get();
|
|
20425
|
+
const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
|
|
20426
|
+
if (hasChanged) {
|
|
20427
|
+
effectScheduler.queue(cb);
|
|
20428
|
+
}
|
|
20429
|
+
pointer.set(depArray);
|
|
20430
|
+
});
|
|
20431
|
+
}
|
|
20432
|
+
|
|
20433
|
+
// ../../../node_modules/@inquirer/core/dist/lib/theme.js
|
|
20434
|
+
import { styleText } from "node:util";
|
|
20435
|
+
|
|
20436
|
+
// ../../../node_modules/@inquirer/figures/dist/index.js
|
|
20437
|
+
import process3 from "node:process";
|
|
20438
|
+
function isUnicodeSupported() {
|
|
20439
|
+
if (!process3.platform.startsWith("win")) {
|
|
20440
|
+
return process3.env["TERM"] !== "linux";
|
|
20441
|
+
}
|
|
20442
|
+
return Boolean(process3.env["CI"]) || // CI environments generally support unicode
|
|
20443
|
+
Boolean(process3.env["WT_SESSION"]) || // Windows Terminal
|
|
20444
|
+
Boolean(process3.env["TERMINUS_SUBLIME"]) || // Terminus (<0.2.27)
|
|
20445
|
+
process3.env["ConEmuTask"] === "{cmd::Cmder}" || // ConEmu and cmder
|
|
20446
|
+
process3.env["TERM_PROGRAM"] === "Terminus-Sublime" || process3.env["TERM_PROGRAM"] === "vscode" || process3.env["TERM"] === "xterm-256color" || process3.env["TERM"] === "alacritty" || process3.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
|
|
20447
|
+
}
|
|
20448
|
+
var common = {
|
|
20449
|
+
circleQuestionMark: "(?)",
|
|
20450
|
+
questionMarkPrefix: "(?)",
|
|
20451
|
+
square: "\u2588",
|
|
20452
|
+
squareDarkShade: "\u2593",
|
|
20453
|
+
squareMediumShade: "\u2592",
|
|
20454
|
+
squareLightShade: "\u2591",
|
|
20455
|
+
squareTop: "\u2580",
|
|
20456
|
+
squareBottom: "\u2584",
|
|
20457
|
+
squareLeft: "\u258C",
|
|
20458
|
+
squareRight: "\u2590",
|
|
20459
|
+
squareCenter: "\u25A0",
|
|
20460
|
+
bullet: "\u25CF",
|
|
20461
|
+
dot: "\u2024",
|
|
20462
|
+
ellipsis: "\u2026",
|
|
20463
|
+
pointerSmall: "\u203A",
|
|
20464
|
+
triangleUp: "\u25B2",
|
|
20465
|
+
triangleUpSmall: "\u25B4",
|
|
20466
|
+
triangleDown: "\u25BC",
|
|
20467
|
+
triangleDownSmall: "\u25BE",
|
|
20468
|
+
triangleLeftSmall: "\u25C2",
|
|
20469
|
+
triangleRightSmall: "\u25B8",
|
|
20470
|
+
home: "\u2302",
|
|
20471
|
+
heart: "\u2665",
|
|
20472
|
+
musicNote: "\u266A",
|
|
20473
|
+
musicNoteBeamed: "\u266B",
|
|
20474
|
+
arrowUp: "\u2191",
|
|
20475
|
+
arrowDown: "\u2193",
|
|
20476
|
+
arrowLeft: "\u2190",
|
|
20477
|
+
arrowRight: "\u2192",
|
|
20478
|
+
arrowLeftRight: "\u2194",
|
|
20479
|
+
arrowUpDown: "\u2195",
|
|
20480
|
+
almostEqual: "\u2248",
|
|
20481
|
+
notEqual: "\u2260",
|
|
20482
|
+
lessOrEqual: "\u2264",
|
|
20483
|
+
greaterOrEqual: "\u2265",
|
|
20484
|
+
identical: "\u2261",
|
|
20485
|
+
infinity: "\u221E",
|
|
20486
|
+
subscriptZero: "\u2080",
|
|
20487
|
+
subscriptOne: "\u2081",
|
|
20488
|
+
subscriptTwo: "\u2082",
|
|
20489
|
+
subscriptThree: "\u2083",
|
|
20490
|
+
subscriptFour: "\u2084",
|
|
20491
|
+
subscriptFive: "\u2085",
|
|
20492
|
+
subscriptSix: "\u2086",
|
|
20493
|
+
subscriptSeven: "\u2087",
|
|
20494
|
+
subscriptEight: "\u2088",
|
|
20495
|
+
subscriptNine: "\u2089",
|
|
20496
|
+
oneHalf: "\xBD",
|
|
20497
|
+
oneThird: "\u2153",
|
|
20498
|
+
oneQuarter: "\xBC",
|
|
20499
|
+
oneFifth: "\u2155",
|
|
20500
|
+
oneSixth: "\u2159",
|
|
20501
|
+
oneEighth: "\u215B",
|
|
20502
|
+
twoThirds: "\u2154",
|
|
20503
|
+
twoFifths: "\u2156",
|
|
20504
|
+
threeQuarters: "\xBE",
|
|
20505
|
+
threeFifths: "\u2157",
|
|
20506
|
+
threeEighths: "\u215C",
|
|
20507
|
+
fourFifths: "\u2158",
|
|
20508
|
+
fiveSixths: "\u215A",
|
|
20509
|
+
fiveEighths: "\u215D",
|
|
20510
|
+
sevenEighths: "\u215E",
|
|
20511
|
+
line: "\u2500",
|
|
20512
|
+
lineBold: "\u2501",
|
|
20513
|
+
lineDouble: "\u2550",
|
|
20514
|
+
lineDashed0: "\u2504",
|
|
20515
|
+
lineDashed1: "\u2505",
|
|
20516
|
+
lineDashed2: "\u2508",
|
|
20517
|
+
lineDashed3: "\u2509",
|
|
20518
|
+
lineDashed4: "\u254C",
|
|
20519
|
+
lineDashed5: "\u254D",
|
|
20520
|
+
lineDashed6: "\u2574",
|
|
20521
|
+
lineDashed7: "\u2576",
|
|
20522
|
+
lineDashed8: "\u2578",
|
|
20523
|
+
lineDashed9: "\u257A",
|
|
20524
|
+
lineDashed10: "\u257C",
|
|
20525
|
+
lineDashed11: "\u257E",
|
|
20526
|
+
lineDashed12: "\u2212",
|
|
20527
|
+
lineDashed13: "\u2013",
|
|
20528
|
+
lineDashed14: "\u2010",
|
|
20529
|
+
lineDashed15: "\u2043",
|
|
20530
|
+
lineVertical: "\u2502",
|
|
20531
|
+
lineVerticalBold: "\u2503",
|
|
20532
|
+
lineVerticalDouble: "\u2551",
|
|
20533
|
+
lineVerticalDashed0: "\u2506",
|
|
20534
|
+
lineVerticalDashed1: "\u2507",
|
|
20535
|
+
lineVerticalDashed2: "\u250A",
|
|
20536
|
+
lineVerticalDashed3: "\u250B",
|
|
20537
|
+
lineVerticalDashed4: "\u254E",
|
|
20538
|
+
lineVerticalDashed5: "\u254F",
|
|
20539
|
+
lineVerticalDashed6: "\u2575",
|
|
20540
|
+
lineVerticalDashed7: "\u2577",
|
|
20541
|
+
lineVerticalDashed8: "\u2579",
|
|
20542
|
+
lineVerticalDashed9: "\u257B",
|
|
20543
|
+
lineVerticalDashed10: "\u257D",
|
|
20544
|
+
lineVerticalDashed11: "\u257F",
|
|
20545
|
+
lineDownLeft: "\u2510",
|
|
20546
|
+
lineDownLeftArc: "\u256E",
|
|
20547
|
+
lineDownBoldLeftBold: "\u2513",
|
|
20548
|
+
lineDownBoldLeft: "\u2512",
|
|
20549
|
+
lineDownLeftBold: "\u2511",
|
|
20550
|
+
lineDownDoubleLeftDouble: "\u2557",
|
|
20551
|
+
lineDownDoubleLeft: "\u2556",
|
|
20552
|
+
lineDownLeftDouble: "\u2555",
|
|
20553
|
+
lineDownRight: "\u250C",
|
|
20554
|
+
lineDownRightArc: "\u256D",
|
|
20555
|
+
lineDownBoldRightBold: "\u250F",
|
|
20556
|
+
lineDownBoldRight: "\u250E",
|
|
20557
|
+
lineDownRightBold: "\u250D",
|
|
20558
|
+
lineDownDoubleRightDouble: "\u2554",
|
|
20559
|
+
lineDownDoubleRight: "\u2553",
|
|
20560
|
+
lineDownRightDouble: "\u2552",
|
|
20561
|
+
lineUpLeft: "\u2518",
|
|
20562
|
+
lineUpLeftArc: "\u256F",
|
|
20563
|
+
lineUpBoldLeftBold: "\u251B",
|
|
20564
|
+
lineUpBoldLeft: "\u251A",
|
|
20565
|
+
lineUpLeftBold: "\u2519",
|
|
20566
|
+
lineUpDoubleLeftDouble: "\u255D",
|
|
20567
|
+
lineUpDoubleLeft: "\u255C",
|
|
20568
|
+
lineUpLeftDouble: "\u255B",
|
|
20569
|
+
lineUpRight: "\u2514",
|
|
20570
|
+
lineUpRightArc: "\u2570",
|
|
20571
|
+
lineUpBoldRightBold: "\u2517",
|
|
20572
|
+
lineUpBoldRight: "\u2516",
|
|
20573
|
+
lineUpRightBold: "\u2515",
|
|
20574
|
+
lineUpDoubleRightDouble: "\u255A",
|
|
20575
|
+
lineUpDoubleRight: "\u2559",
|
|
20576
|
+
lineUpRightDouble: "\u2558",
|
|
20577
|
+
lineUpDownLeft: "\u2524",
|
|
20578
|
+
lineUpBoldDownBoldLeftBold: "\u252B",
|
|
20579
|
+
lineUpBoldDownBoldLeft: "\u2528",
|
|
20580
|
+
lineUpDownLeftBold: "\u2525",
|
|
20581
|
+
lineUpBoldDownLeftBold: "\u2529",
|
|
20582
|
+
lineUpDownBoldLeftBold: "\u252A",
|
|
20583
|
+
lineUpDownBoldLeft: "\u2527",
|
|
20584
|
+
lineUpBoldDownLeft: "\u2526",
|
|
20585
|
+
lineUpDoubleDownDoubleLeftDouble: "\u2563",
|
|
20586
|
+
lineUpDoubleDownDoubleLeft: "\u2562",
|
|
20587
|
+
lineUpDownLeftDouble: "\u2561",
|
|
20588
|
+
lineUpDownRight: "\u251C",
|
|
20589
|
+
lineUpBoldDownBoldRightBold: "\u2523",
|
|
20590
|
+
lineUpBoldDownBoldRight: "\u2520",
|
|
20591
|
+
lineUpDownRightBold: "\u251D",
|
|
20592
|
+
lineUpBoldDownRightBold: "\u2521",
|
|
20593
|
+
lineUpDownBoldRightBold: "\u2522",
|
|
20594
|
+
lineUpDownBoldRight: "\u251F",
|
|
20595
|
+
lineUpBoldDownRight: "\u251E",
|
|
20596
|
+
lineUpDoubleDownDoubleRightDouble: "\u2560",
|
|
20597
|
+
lineUpDoubleDownDoubleRight: "\u255F",
|
|
20598
|
+
lineUpDownRightDouble: "\u255E",
|
|
20599
|
+
lineDownLeftRight: "\u252C",
|
|
20600
|
+
lineDownBoldLeftBoldRightBold: "\u2533",
|
|
20601
|
+
lineDownLeftBoldRightBold: "\u252F",
|
|
20602
|
+
lineDownBoldLeftRight: "\u2530",
|
|
20603
|
+
lineDownBoldLeftBoldRight: "\u2531",
|
|
20604
|
+
lineDownBoldLeftRightBold: "\u2532",
|
|
20605
|
+
lineDownLeftRightBold: "\u252E",
|
|
20606
|
+
lineDownLeftBoldRight: "\u252D",
|
|
20607
|
+
lineDownDoubleLeftDoubleRightDouble: "\u2566",
|
|
20608
|
+
lineDownDoubleLeftRight: "\u2565",
|
|
20609
|
+
lineDownLeftDoubleRightDouble: "\u2564",
|
|
20610
|
+
lineUpLeftRight: "\u2534",
|
|
20611
|
+
lineUpBoldLeftBoldRightBold: "\u253B",
|
|
20612
|
+
lineUpLeftBoldRightBold: "\u2537",
|
|
20613
|
+
lineUpBoldLeftRight: "\u2538",
|
|
20614
|
+
lineUpBoldLeftBoldRight: "\u2539",
|
|
20615
|
+
lineUpBoldLeftRightBold: "\u253A",
|
|
20616
|
+
lineUpLeftRightBold: "\u2536",
|
|
20617
|
+
lineUpLeftBoldRight: "\u2535",
|
|
20618
|
+
lineUpDoubleLeftDoubleRightDouble: "\u2569",
|
|
20619
|
+
lineUpDoubleLeftRight: "\u2568",
|
|
20620
|
+
lineUpLeftDoubleRightDouble: "\u2567",
|
|
20621
|
+
lineUpDownLeftRight: "\u253C",
|
|
20622
|
+
lineUpBoldDownBoldLeftBoldRightBold: "\u254B",
|
|
20623
|
+
lineUpDownBoldLeftBoldRightBold: "\u2548",
|
|
20624
|
+
lineUpBoldDownLeftBoldRightBold: "\u2547",
|
|
20625
|
+
lineUpBoldDownBoldLeftRightBold: "\u254A",
|
|
20626
|
+
lineUpBoldDownBoldLeftBoldRight: "\u2549",
|
|
20627
|
+
lineUpBoldDownLeftRight: "\u2540",
|
|
20628
|
+
lineUpDownBoldLeftRight: "\u2541",
|
|
20629
|
+
lineUpDownLeftBoldRight: "\u253D",
|
|
20630
|
+
lineUpDownLeftRightBold: "\u253E",
|
|
20631
|
+
lineUpBoldDownBoldLeftRight: "\u2542",
|
|
20632
|
+
lineUpDownLeftBoldRightBold: "\u253F",
|
|
20633
|
+
lineUpBoldDownLeftBoldRight: "\u2543",
|
|
20634
|
+
lineUpBoldDownLeftRightBold: "\u2544",
|
|
20635
|
+
lineUpDownBoldLeftBoldRight: "\u2545",
|
|
20636
|
+
lineUpDownBoldLeftRightBold: "\u2546",
|
|
20637
|
+
lineUpDoubleDownDoubleLeftDoubleRightDouble: "\u256C",
|
|
20638
|
+
lineUpDoubleDownDoubleLeftRight: "\u256B",
|
|
20639
|
+
lineUpDownLeftDoubleRightDouble: "\u256A",
|
|
20640
|
+
lineCross: "\u2573",
|
|
20641
|
+
lineBackslash: "\u2572",
|
|
20642
|
+
lineSlash: "\u2571"
|
|
20643
|
+
};
|
|
20644
|
+
var specialMainSymbols = {
|
|
20645
|
+
tick: "\u2714",
|
|
20646
|
+
info: "\u2139",
|
|
20647
|
+
warning: "\u26A0",
|
|
20648
|
+
cross: "\u2718",
|
|
20649
|
+
squareSmall: "\u25FB",
|
|
20650
|
+
squareSmallFilled: "\u25FC",
|
|
20651
|
+
circle: "\u25EF",
|
|
20652
|
+
circleFilled: "\u25C9",
|
|
20653
|
+
circleDotted: "\u25CC",
|
|
20654
|
+
circleDouble: "\u25CE",
|
|
20655
|
+
circleCircle: "\u24DE",
|
|
20656
|
+
circleCross: "\u24E7",
|
|
20657
|
+
circlePipe: "\u24BE",
|
|
20658
|
+
radioOn: "\u25C9",
|
|
20659
|
+
radioOff: "\u25EF",
|
|
20660
|
+
checkboxOn: "\u2612",
|
|
20661
|
+
checkboxOff: "\u2610",
|
|
20662
|
+
checkboxCircleOn: "\u24E7",
|
|
20663
|
+
checkboxCircleOff: "\u24BE",
|
|
20664
|
+
pointer: "\u276F",
|
|
20665
|
+
triangleUpOutline: "\u25B3",
|
|
20666
|
+
triangleLeft: "\u25C0",
|
|
20667
|
+
triangleRight: "\u25B6",
|
|
20668
|
+
lozenge: "\u25C6",
|
|
20669
|
+
lozengeOutline: "\u25C7",
|
|
20670
|
+
hamburger: "\u2630",
|
|
20671
|
+
smiley: "\u32E1",
|
|
20672
|
+
mustache: "\u0DF4",
|
|
20673
|
+
star: "\u2605",
|
|
20674
|
+
play: "\u25B6",
|
|
20675
|
+
nodejs: "\u2B22",
|
|
20676
|
+
oneSeventh: "\u2150",
|
|
20677
|
+
oneNinth: "\u2151",
|
|
20678
|
+
oneTenth: "\u2152"
|
|
20679
|
+
};
|
|
20680
|
+
var specialFallbackSymbols = {
|
|
20681
|
+
tick: "\u221A",
|
|
20682
|
+
info: "i",
|
|
20683
|
+
warning: "\u203C",
|
|
20684
|
+
cross: "\xD7",
|
|
20685
|
+
squareSmall: "\u25A1",
|
|
20686
|
+
squareSmallFilled: "\u25A0",
|
|
20687
|
+
circle: "( )",
|
|
20688
|
+
circleFilled: "(*)",
|
|
20689
|
+
circleDotted: "( )",
|
|
20690
|
+
circleDouble: "( )",
|
|
20691
|
+
circleCircle: "(\u25CB)",
|
|
20692
|
+
circleCross: "(\xD7)",
|
|
20693
|
+
circlePipe: "(\u2502)",
|
|
20694
|
+
radioOn: "(*)",
|
|
20695
|
+
radioOff: "( )",
|
|
20696
|
+
checkboxOn: "[\xD7]",
|
|
20697
|
+
checkboxOff: "[ ]",
|
|
20698
|
+
checkboxCircleOn: "(\xD7)",
|
|
20699
|
+
checkboxCircleOff: "( )",
|
|
20700
|
+
pointer: ">",
|
|
20701
|
+
triangleUpOutline: "\u2206",
|
|
20702
|
+
triangleLeft: "\u25C4",
|
|
20703
|
+
triangleRight: "\u25BA",
|
|
20704
|
+
lozenge: "\u2666",
|
|
20705
|
+
lozengeOutline: "\u25CA",
|
|
20706
|
+
hamburger: "\u2261",
|
|
20707
|
+
smiley: "\u263A",
|
|
20708
|
+
mustache: "\u250C\u2500\u2510",
|
|
20709
|
+
star: "\u2736",
|
|
20710
|
+
play: "\u25BA",
|
|
20711
|
+
nodejs: "\u2666",
|
|
20712
|
+
oneSeventh: "1/7",
|
|
20713
|
+
oneNinth: "1/9",
|
|
20714
|
+
oneTenth: "1/10"
|
|
20715
|
+
};
|
|
20716
|
+
var mainSymbols = {
|
|
20717
|
+
...common,
|
|
20718
|
+
...specialMainSymbols
|
|
20719
|
+
};
|
|
20720
|
+
var fallbackSymbols = {
|
|
20721
|
+
...common,
|
|
20722
|
+
...specialFallbackSymbols
|
|
20723
|
+
};
|
|
20724
|
+
var shouldUseMain = isUnicodeSupported();
|
|
20725
|
+
var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
20726
|
+
var dist_default = figures;
|
|
20727
|
+
var replacements = Object.entries(specialMainSymbols);
|
|
20728
|
+
|
|
20729
|
+
// ../../../node_modules/@inquirer/core/dist/lib/theme.js
|
|
20730
|
+
var defaultTheme = {
|
|
20731
|
+
prefix: {
|
|
20732
|
+
idle: styleText("blue", "?"),
|
|
20733
|
+
done: styleText("green", dist_default.tick)
|
|
20734
|
+
},
|
|
20735
|
+
spinner: {
|
|
20736
|
+
interval: 80,
|
|
20737
|
+
frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"].map((frame) => styleText("yellow", frame))
|
|
20738
|
+
},
|
|
20739
|
+
keybindings: [],
|
|
20740
|
+
style: {
|
|
20741
|
+
answer: (text) => styleText("cyan", text),
|
|
20742
|
+
message: (text) => styleText("bold", text),
|
|
20743
|
+
error: (text) => styleText("red", `> ${text}`),
|
|
20744
|
+
defaultAnswer: (text) => styleText("dim", `(${text})`),
|
|
20745
|
+
help: (text) => styleText("dim", text),
|
|
20746
|
+
highlight: (text) => styleText("cyan", text),
|
|
20747
|
+
key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
|
|
20748
|
+
}
|
|
20749
|
+
};
|
|
20750
|
+
function getDefaultTheme() {
|
|
20751
|
+
return {
|
|
20752
|
+
...defaultTheme,
|
|
20753
|
+
keybindings: getDefaultKeybindings()
|
|
20754
|
+
};
|
|
20755
|
+
}
|
|
20756
|
+
|
|
20757
|
+
// ../../../node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
20758
|
+
function isPlainObject2(value) {
|
|
20759
|
+
if (typeof value !== "object" || value === null)
|
|
20760
|
+
return false;
|
|
20761
|
+
let proto = value;
|
|
20762
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
20763
|
+
proto = Object.getPrototypeOf(proto);
|
|
20764
|
+
}
|
|
20765
|
+
return Object.getPrototypeOf(value) === proto;
|
|
20766
|
+
}
|
|
20767
|
+
function deepMerge(...objects) {
|
|
20768
|
+
const output = {};
|
|
20769
|
+
for (const obj of objects) {
|
|
20770
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
20771
|
+
const prevValue = output[key];
|
|
20772
|
+
output[key] = isPlainObject2(prevValue) && isPlainObject2(value) ? deepMerge(prevValue, value) : value;
|
|
20773
|
+
}
|
|
20774
|
+
}
|
|
20775
|
+
return output;
|
|
20776
|
+
}
|
|
20777
|
+
function makeTheme(...themes) {
|
|
20778
|
+
const themesToMerge = [
|
|
20779
|
+
getDefaultTheme(),
|
|
20780
|
+
...themes.filter((theme) => theme != null)
|
|
20781
|
+
];
|
|
20782
|
+
return deepMerge(...themesToMerge);
|
|
20783
|
+
}
|
|
20784
|
+
|
|
20785
|
+
// ../../../node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
20786
|
+
function usePrefix({ status = "idle", theme }) {
|
|
20787
|
+
const [showLoader, setShowLoader] = useState(false);
|
|
20788
|
+
const [tick, setTick] = useState(0);
|
|
20789
|
+
const { prefix, spinner } = makeTheme(theme);
|
|
20790
|
+
useEffect(() => {
|
|
20791
|
+
if (status === "loading") {
|
|
20792
|
+
let tickInterval;
|
|
20793
|
+
let inc = -1;
|
|
20794
|
+
const delayTimeout = setTimeout(() => {
|
|
20795
|
+
setShowLoader(true);
|
|
20796
|
+
tickInterval = setInterval(() => {
|
|
20797
|
+
inc = inc + 1;
|
|
20798
|
+
setTick(inc % spinner.frames.length);
|
|
20799
|
+
}, spinner.interval);
|
|
20800
|
+
}, 300);
|
|
20801
|
+
return () => {
|
|
20802
|
+
clearTimeout(delayTimeout);
|
|
20803
|
+
clearInterval(tickInterval);
|
|
20804
|
+
};
|
|
20805
|
+
} else {
|
|
20806
|
+
setShowLoader(false);
|
|
20807
|
+
}
|
|
20808
|
+
}, [status]);
|
|
20809
|
+
if (showLoader) {
|
|
20810
|
+
return spinner.frames[tick];
|
|
20811
|
+
}
|
|
20812
|
+
const iconName = status === "loading" ? "idle" : status;
|
|
20813
|
+
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
|
|
20814
|
+
}
|
|
20815
|
+
|
|
20816
|
+
// ../../../node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
20817
|
+
function useMemo(fn, dependencies) {
|
|
20818
|
+
return withPointer((pointer) => {
|
|
20819
|
+
const prev = pointer.get();
|
|
20820
|
+
if (!pointer.initialized || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
|
|
20821
|
+
const value = fn();
|
|
20822
|
+
pointer.set({ value, dependencies });
|
|
20823
|
+
return value;
|
|
20824
|
+
}
|
|
20825
|
+
return prev.value;
|
|
20826
|
+
});
|
|
20827
|
+
}
|
|
20828
|
+
|
|
20829
|
+
// ../../../node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
20830
|
+
function useRef(val) {
|
|
20831
|
+
return useState({ current: val })[0];
|
|
20832
|
+
}
|
|
20833
|
+
|
|
20834
|
+
// ../../../node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
20835
|
+
function useKeypress(userHandler) {
|
|
20836
|
+
const signal = useRef(userHandler);
|
|
20837
|
+
signal.current = userHandler;
|
|
20838
|
+
useEffect((rl) => {
|
|
20839
|
+
let ignore = false;
|
|
20840
|
+
const handler = withUpdates((_input, event) => {
|
|
20841
|
+
if (ignore)
|
|
20842
|
+
return;
|
|
20843
|
+
void signal.current(event, rl);
|
|
20844
|
+
});
|
|
20845
|
+
rl.input.on("keypress", handler);
|
|
20846
|
+
return () => {
|
|
20847
|
+
ignore = true;
|
|
20848
|
+
rl.input.removeListener("keypress", handler);
|
|
20849
|
+
};
|
|
20850
|
+
}, []);
|
|
20851
|
+
}
|
|
20852
|
+
|
|
20853
|
+
// ../../../node_modules/@inquirer/core/dist/lib/utils.js
|
|
20854
|
+
var import_cli_width = __toESM(require_cli_width(), 1);
|
|
20855
|
+
|
|
20856
|
+
// ../../../node_modules/fast-string-truncated-width/dist/utils.js
|
|
20857
|
+
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
20858
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
20859
|
+
return (input) => {
|
|
20860
|
+
let surrogatePairsNr = 0;
|
|
20861
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
20862
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
20863
|
+
surrogatePairsNr += 1;
|
|
20864
|
+
}
|
|
20865
|
+
return input.length - surrogatePairsNr;
|
|
20866
|
+
};
|
|
20867
|
+
})();
|
|
20868
|
+
var isFullWidth = (x) => {
|
|
20869
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
20870
|
+
};
|
|
20871
|
+
var isWideNotCJKTNotEmoji = (x) => {
|
|
20872
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || 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 >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
20873
|
+
};
|
|
20874
|
+
|
|
20875
|
+
// ../../../node_modules/fast-string-truncated-width/dist/index.js
|
|
20876
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
20877
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
20878
|
+
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
20879
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
20880
|
+
var EMOJI_RE = /[\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;
|
|
20881
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
20882
|
+
var MODIFIER_RE = /\p{M}+/gu;
|
|
20883
|
+
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
20884
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
20885
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
20886
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
20887
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
20888
|
+
const ANSI_WIDTH = 0;
|
|
20889
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
20890
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
20891
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
20892
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
20893
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
20894
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
20895
|
+
const PARSE_BLOCKS = [
|
|
20896
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
20897
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
20898
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
20899
|
+
[TAB_RE, TAB_WIDTH],
|
|
20900
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
20901
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
20902
|
+
];
|
|
20903
|
+
let indexPrev = 0;
|
|
20904
|
+
let index = 0;
|
|
20905
|
+
let length = input.length;
|
|
20906
|
+
let lengthExtra = 0;
|
|
20907
|
+
let truncationEnabled = false;
|
|
20908
|
+
let truncationIndex = length;
|
|
20909
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
20910
|
+
let unmatchedStart = 0;
|
|
20911
|
+
let unmatchedEnd = 0;
|
|
20912
|
+
let width = 0;
|
|
20913
|
+
let widthExtra = 0;
|
|
20914
|
+
outer: while (true) {
|
|
20915
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
20916
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
20917
|
+
lengthExtra = 0;
|
|
20918
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
20919
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
20920
|
+
if (isFullWidth(codePoint)) {
|
|
20921
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
20922
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
20923
|
+
widthExtra = WIDE_WIDTH;
|
|
20924
|
+
} else {
|
|
20925
|
+
widthExtra = REGULAR_WIDTH;
|
|
20926
|
+
}
|
|
20927
|
+
if (width + widthExtra > truncationLimit) {
|
|
20928
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
20929
|
+
}
|
|
20930
|
+
if (width + widthExtra > LIMIT) {
|
|
20931
|
+
truncationEnabled = true;
|
|
20932
|
+
break outer;
|
|
20933
|
+
}
|
|
20934
|
+
lengthExtra += char.length;
|
|
20935
|
+
width += widthExtra;
|
|
20936
|
+
}
|
|
20937
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
20938
|
+
}
|
|
20939
|
+
if (index >= length) {
|
|
20940
|
+
break outer;
|
|
20941
|
+
}
|
|
20942
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
20943
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
20944
|
+
BLOCK_RE.lastIndex = index;
|
|
20945
|
+
if (BLOCK_RE.test(input)) {
|
|
20946
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
20947
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
20948
|
+
if (width + widthExtra > truncationLimit) {
|
|
20949
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
20950
|
+
}
|
|
20951
|
+
if (width + widthExtra > LIMIT) {
|
|
20952
|
+
truncationEnabled = true;
|
|
20953
|
+
break outer;
|
|
20954
|
+
}
|
|
20955
|
+
width += widthExtra;
|
|
20956
|
+
unmatchedStart = indexPrev;
|
|
20957
|
+
unmatchedEnd = index;
|
|
20958
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
20959
|
+
continue outer;
|
|
20960
|
+
}
|
|
20961
|
+
}
|
|
20962
|
+
index += 1;
|
|
20963
|
+
}
|
|
20964
|
+
return {
|
|
20965
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
20966
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
20967
|
+
truncated: truncationEnabled,
|
|
20968
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
20969
|
+
};
|
|
20970
|
+
};
|
|
20971
|
+
var dist_default2 = getStringTruncatedWidth;
|
|
20972
|
+
|
|
20973
|
+
// ../../../node_modules/fast-string-width/dist/index.js
|
|
20974
|
+
var NO_TRUNCATION2 = {
|
|
20975
|
+
limit: Infinity,
|
|
20976
|
+
ellipsis: "",
|
|
20977
|
+
ellipsisWidth: 0
|
|
20978
|
+
};
|
|
20979
|
+
var fastStringWidth = (input, options = {}) => {
|
|
20980
|
+
return dist_default2(input, NO_TRUNCATION2, options).width;
|
|
20981
|
+
};
|
|
20982
|
+
var dist_default3 = fastStringWidth;
|
|
20983
|
+
|
|
20984
|
+
// ../../../node_modules/fast-wrap-ansi/lib/main.js
|
|
20985
|
+
var ESC = "\x1B";
|
|
20986
|
+
var CSI = "\x9B";
|
|
20987
|
+
var END_CODE = 39;
|
|
20988
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
20989
|
+
var ANSI_CSI = "[";
|
|
20990
|
+
var ANSI_OSC = "]";
|
|
20991
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
20992
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
20993
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
20994
|
+
var getClosingCode = (openingCode) => {
|
|
20995
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
20996
|
+
return 39;
|
|
20997
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
20998
|
+
return 39;
|
|
20999
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
21000
|
+
return 49;
|
|
21001
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
21002
|
+
return 49;
|
|
21003
|
+
if (openingCode === 1 || openingCode === 2)
|
|
21004
|
+
return 22;
|
|
21005
|
+
if (openingCode === 3)
|
|
21006
|
+
return 23;
|
|
21007
|
+
if (openingCode === 4)
|
|
21008
|
+
return 24;
|
|
21009
|
+
if (openingCode === 7)
|
|
21010
|
+
return 27;
|
|
21011
|
+
if (openingCode === 8)
|
|
21012
|
+
return 28;
|
|
21013
|
+
if (openingCode === 9)
|
|
21014
|
+
return 29;
|
|
21015
|
+
if (openingCode === 0)
|
|
21016
|
+
return 0;
|
|
21017
|
+
return void 0;
|
|
21018
|
+
};
|
|
21019
|
+
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
21020
|
+
var wrapAnsiHyperlink = (url2) => `${ESC}${ANSI_ESCAPE_LINK}${url2}${ANSI_ESCAPE_BELL}`;
|
|
21021
|
+
var wrapWord = (rows, word, columns) => {
|
|
21022
|
+
const characters = word[Symbol.iterator]();
|
|
21023
|
+
let isInsideEscape = false;
|
|
21024
|
+
let isInsideLinkEscape = false;
|
|
21025
|
+
let lastRow = rows.at(-1);
|
|
21026
|
+
let visible = lastRow === void 0 ? 0 : dist_default3(lastRow);
|
|
21027
|
+
let currentCharacter = characters.next();
|
|
21028
|
+
let nextCharacter = characters.next();
|
|
21029
|
+
let rawCharacterIndex = 0;
|
|
21030
|
+
while (!currentCharacter.done) {
|
|
21031
|
+
const character = currentCharacter.value;
|
|
21032
|
+
const characterLength = dist_default3(character);
|
|
21033
|
+
if (visible + characterLength <= columns) {
|
|
21034
|
+
rows[rows.length - 1] += character;
|
|
21035
|
+
} else {
|
|
21036
|
+
rows.push(character);
|
|
21037
|
+
visible = 0;
|
|
21038
|
+
}
|
|
21039
|
+
if (character === ESC || character === CSI) {
|
|
21040
|
+
isInsideEscape = true;
|
|
21041
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
21042
|
+
}
|
|
21043
|
+
if (isInsideEscape) {
|
|
21044
|
+
if (isInsideLinkEscape) {
|
|
21045
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
21046
|
+
isInsideEscape = false;
|
|
21047
|
+
isInsideLinkEscape = false;
|
|
21048
|
+
}
|
|
21049
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
21050
|
+
isInsideEscape = false;
|
|
21051
|
+
}
|
|
21052
|
+
} else {
|
|
21053
|
+
visible += characterLength;
|
|
21054
|
+
if (visible === columns && !nextCharacter.done) {
|
|
21055
|
+
rows.push("");
|
|
21056
|
+
visible = 0;
|
|
21057
|
+
}
|
|
21058
|
+
}
|
|
21059
|
+
currentCharacter = nextCharacter;
|
|
21060
|
+
nextCharacter = characters.next();
|
|
21061
|
+
rawCharacterIndex += character.length;
|
|
21062
|
+
}
|
|
21063
|
+
lastRow = rows.at(-1);
|
|
21064
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) {
|
|
21065
|
+
rows[rows.length - 2] += rows.pop();
|
|
21066
|
+
}
|
|
21067
|
+
};
|
|
21068
|
+
var stringVisibleTrimSpacesRight = (string4) => {
|
|
21069
|
+
const words = string4.split(" ");
|
|
21070
|
+
let last = words.length;
|
|
21071
|
+
while (last) {
|
|
21072
|
+
if (dist_default3(words[last - 1])) {
|
|
21073
|
+
break;
|
|
21074
|
+
}
|
|
21075
|
+
last--;
|
|
21076
|
+
}
|
|
21077
|
+
if (last === words.length) {
|
|
21078
|
+
return string4;
|
|
21079
|
+
}
|
|
21080
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
21081
|
+
};
|
|
21082
|
+
var exec = (string4, columns, options = {}) => {
|
|
21083
|
+
if (options.trim !== false && string4.trim() === "") {
|
|
21084
|
+
return "";
|
|
21085
|
+
}
|
|
21086
|
+
let returnValue = "";
|
|
21087
|
+
let escapeCode;
|
|
21088
|
+
let escapeUrl;
|
|
21089
|
+
const words = string4.split(" ");
|
|
21090
|
+
let rows = [""];
|
|
21091
|
+
let rowLength = 0;
|
|
21092
|
+
for (let index = 0; index < words.length; index++) {
|
|
21093
|
+
const word = words[index];
|
|
21094
|
+
if (options.trim !== false) {
|
|
21095
|
+
const row = rows.at(-1) ?? "";
|
|
21096
|
+
const trimmed = row.trimStart();
|
|
21097
|
+
if (row.length !== trimmed.length) {
|
|
21098
|
+
rows[rows.length - 1] = trimmed;
|
|
21099
|
+
rowLength = dist_default3(trimmed);
|
|
21100
|
+
}
|
|
21101
|
+
}
|
|
21102
|
+
if (index !== 0) {
|
|
21103
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
21104
|
+
rows.push("");
|
|
21105
|
+
rowLength = 0;
|
|
21106
|
+
}
|
|
21107
|
+
if (rowLength || options.trim === false) {
|
|
21108
|
+
rows[rows.length - 1] += " ";
|
|
21109
|
+
rowLength++;
|
|
21110
|
+
}
|
|
21111
|
+
}
|
|
21112
|
+
const wordLength = dist_default3(word);
|
|
21113
|
+
if (options.hard && wordLength > columns) {
|
|
21114
|
+
const remainingColumns = columns - rowLength;
|
|
21115
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
21116
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
21117
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
21118
|
+
rows.push("");
|
|
21119
|
+
}
|
|
21120
|
+
wrapWord(rows, word, columns);
|
|
21121
|
+
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
21122
|
+
continue;
|
|
21123
|
+
}
|
|
21124
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
21125
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
21126
|
+
wrapWord(rows, word, columns);
|
|
21127
|
+
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
21128
|
+
continue;
|
|
21129
|
+
}
|
|
21130
|
+
rows.push("");
|
|
21131
|
+
rowLength = 0;
|
|
21132
|
+
}
|
|
21133
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
21134
|
+
wrapWord(rows, word, columns);
|
|
21135
|
+
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
21136
|
+
continue;
|
|
21137
|
+
}
|
|
21138
|
+
rows[rows.length - 1] += word;
|
|
21139
|
+
rowLength += wordLength;
|
|
21140
|
+
}
|
|
21141
|
+
if (options.trim !== false) {
|
|
21142
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
21143
|
+
}
|
|
21144
|
+
const preString = rows.join("\n");
|
|
21145
|
+
let inSurrogate = false;
|
|
21146
|
+
for (let i = 0; i < preString.length; i++) {
|
|
21147
|
+
const character = preString[i];
|
|
21148
|
+
returnValue += character;
|
|
21149
|
+
if (!inSurrogate) {
|
|
21150
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
21151
|
+
if (inSurrogate) {
|
|
21152
|
+
continue;
|
|
21153
|
+
}
|
|
21154
|
+
} else {
|
|
21155
|
+
inSurrogate = false;
|
|
21156
|
+
}
|
|
21157
|
+
if (character === ESC || character === CSI) {
|
|
21158
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
21159
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
21160
|
+
const groups = groupsResult?.groups;
|
|
21161
|
+
if (groups?.code !== void 0) {
|
|
21162
|
+
const code = Number.parseFloat(groups.code);
|
|
21163
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
21164
|
+
} else if (groups?.uri !== void 0) {
|
|
21165
|
+
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
21166
|
+
}
|
|
21167
|
+
}
|
|
21168
|
+
if (preString[i + 1] === "\n") {
|
|
21169
|
+
if (escapeUrl) {
|
|
21170
|
+
returnValue += wrapAnsiHyperlink("");
|
|
21171
|
+
}
|
|
21172
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
21173
|
+
if (escapeCode && closingCode) {
|
|
21174
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
21175
|
+
}
|
|
21176
|
+
} else if (character === "\n") {
|
|
21177
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
21178
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
21179
|
+
}
|
|
21180
|
+
if (escapeUrl) {
|
|
21181
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
21182
|
+
}
|
|
21183
|
+
}
|
|
21184
|
+
}
|
|
21185
|
+
return returnValue;
|
|
21186
|
+
};
|
|
21187
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
21188
|
+
function wrapAnsi(string4, columns, options) {
|
|
21189
|
+
return String(string4).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
21190
|
+
}
|
|
21191
|
+
|
|
21192
|
+
// ../../../node_modules/@inquirer/core/dist/lib/utils.js
|
|
21193
|
+
function breakLines(content, width) {
|
|
21194
|
+
return content.split("\n").flatMap((line) => wrapAnsi(line, width, { trim: false, wordWrap: false }).split("\n").map((str) => str.trimEnd())).join("\n");
|
|
21195
|
+
}
|
|
21196
|
+
function readlineWidth() {
|
|
21197
|
+
return (0, import_cli_width.default)({ defaultWidth: 80, output: readline().output });
|
|
21198
|
+
}
|
|
21199
|
+
|
|
21200
|
+
// ../../../node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
21201
|
+
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
21202
|
+
const state = useRef({
|
|
21203
|
+
lastPointer: active,
|
|
21204
|
+
lastActive: void 0
|
|
21205
|
+
});
|
|
21206
|
+
const { lastPointer, lastActive } = state.current;
|
|
21207
|
+
const middle = Math.floor(pageSize / 2);
|
|
21208
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
21209
|
+
const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
|
|
21210
|
+
let pointer = defaultPointerPosition;
|
|
21211
|
+
if (renderedLength > pageSize) {
|
|
21212
|
+
if (loop) {
|
|
21213
|
+
pointer = lastPointer;
|
|
21214
|
+
if (
|
|
21215
|
+
// First render, skip this logic.
|
|
21216
|
+
lastActive != null && // Only move the pointer down when the user moves down.
|
|
21217
|
+
lastActive < active && // Check user didn't move up across page boundary.
|
|
21218
|
+
active - lastActive < pageSize
|
|
21219
|
+
) {
|
|
21220
|
+
pointer = Math.min(
|
|
21221
|
+
// Furthest allowed position for the pointer is the middle of the list
|
|
21222
|
+
middle,
|
|
21223
|
+
Math.abs(active - lastActive) === 1 ? Math.min(
|
|
21224
|
+
// Move the pointer at most the height of the last active item.
|
|
21225
|
+
lastPointer + (renderedItems[lastActive]?.length ?? 0),
|
|
21226
|
+
// If the user moved by one item, move the pointer to the natural position of the active item as
|
|
21227
|
+
// long as it doesn't move the cursor up.
|
|
21228
|
+
Math.max(defaultPointerPosition, lastPointer)
|
|
21229
|
+
) : (
|
|
21230
|
+
// Otherwise, move the pointer down by the difference between the active and last active item.
|
|
21231
|
+
lastPointer + active - lastActive
|
|
21232
|
+
)
|
|
21233
|
+
);
|
|
21234
|
+
}
|
|
21235
|
+
} else {
|
|
21236
|
+
const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
|
|
21237
|
+
pointer = spaceUnderActive < pageSize - middle ? (
|
|
21238
|
+
// If the active item is near the end of the list, progressively move the cursor towards the end.
|
|
21239
|
+
pageSize - spaceUnderActive
|
|
21240
|
+
) : (
|
|
21241
|
+
// Otherwise, progressively move the pointer to the middle of the list.
|
|
21242
|
+
Math.min(defaultPointerPosition, middle)
|
|
21243
|
+
);
|
|
21244
|
+
}
|
|
21245
|
+
}
|
|
21246
|
+
state.current.lastPointer = pointer;
|
|
21247
|
+
state.current.lastActive = active;
|
|
21248
|
+
return pointer;
|
|
21249
|
+
}
|
|
21250
|
+
function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
21251
|
+
const width = readlineWidth();
|
|
21252
|
+
const bound = (num) => (num % items.length + items.length) % items.length;
|
|
21253
|
+
const renderedItems = items.map((item, index) => {
|
|
21254
|
+
if (item == null)
|
|
21255
|
+
return [];
|
|
21256
|
+
return breakLines(renderItem({ item, index, isActive: index === active }), width).split("\n");
|
|
21257
|
+
});
|
|
21258
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
21259
|
+
const renderItemAtIndex = (index) => renderedItems[index] ?? [];
|
|
21260
|
+
const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
|
|
21261
|
+
const activeItem = renderItemAtIndex(active).slice(0, pageSize);
|
|
21262
|
+
const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
|
|
21263
|
+
const pageBuffer = Array.from({ length: pageSize });
|
|
21264
|
+
pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
|
|
21265
|
+
const itemVisited = /* @__PURE__ */ new Set([active]);
|
|
21266
|
+
let bufferPointer = activeItemPosition + activeItem.length;
|
|
21267
|
+
let itemPointer = bound(active + 1);
|
|
21268
|
+
while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
|
|
21269
|
+
const lines = renderItemAtIndex(itemPointer);
|
|
21270
|
+
const linesToAdd = lines.slice(0, pageSize - bufferPointer);
|
|
21271
|
+
pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
|
|
21272
|
+
itemVisited.add(itemPointer);
|
|
21273
|
+
bufferPointer += linesToAdd.length;
|
|
21274
|
+
itemPointer = bound(itemPointer + 1);
|
|
21275
|
+
}
|
|
21276
|
+
bufferPointer = activeItemPosition - 1;
|
|
21277
|
+
itemPointer = bound(active - 1);
|
|
21278
|
+
while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
|
|
21279
|
+
const lines = renderItemAtIndex(itemPointer);
|
|
21280
|
+
const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
|
|
21281
|
+
pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
|
|
21282
|
+
itemVisited.add(itemPointer);
|
|
21283
|
+
bufferPointer -= linesToAdd.length;
|
|
21284
|
+
itemPointer = bound(itemPointer - 1);
|
|
21285
|
+
}
|
|
21286
|
+
return pageBuffer.filter((line) => typeof line === "string").join("\n");
|
|
21287
|
+
}
|
|
21288
|
+
|
|
21289
|
+
// ../../../node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
21290
|
+
var import_mute_stream = __toESM(require_lib(), 1);
|
|
21291
|
+
import * as readline2 from "node:readline";
|
|
21292
|
+
import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
21293
|
+
|
|
21294
|
+
// ../../../node_modules/signal-exit/dist/mjs/signals.js
|
|
21295
|
+
var signals = [];
|
|
21296
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
21297
|
+
if (process.platform !== "win32") {
|
|
21298
|
+
signals.push(
|
|
21299
|
+
"SIGALRM",
|
|
21300
|
+
"SIGABRT",
|
|
21301
|
+
"SIGVTALRM",
|
|
21302
|
+
"SIGXCPU",
|
|
21303
|
+
"SIGXFSZ",
|
|
21304
|
+
"SIGUSR2",
|
|
21305
|
+
"SIGTRAP",
|
|
21306
|
+
"SIGSYS",
|
|
21307
|
+
"SIGQUIT",
|
|
21308
|
+
"SIGIOT"
|
|
21309
|
+
// should detect profiler and enable/disable accordingly.
|
|
21310
|
+
// see #21
|
|
21311
|
+
// 'SIGPROF'
|
|
21312
|
+
);
|
|
21313
|
+
}
|
|
21314
|
+
if (process.platform === "linux") {
|
|
21315
|
+
signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
21316
|
+
}
|
|
21317
|
+
|
|
21318
|
+
// ../../../node_modules/signal-exit/dist/mjs/index.js
|
|
21319
|
+
var processOk = (process5) => !!process5 && typeof process5 === "object" && typeof process5.removeListener === "function" && typeof process5.emit === "function" && typeof process5.reallyExit === "function" && typeof process5.listeners === "function" && typeof process5.kill === "function" && typeof process5.pid === "number" && typeof process5.on === "function";
|
|
21320
|
+
var kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
|
|
21321
|
+
var global = globalThis;
|
|
21322
|
+
var ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
21323
|
+
var Emitter = class {
|
|
21324
|
+
emitted = {
|
|
21325
|
+
afterExit: false,
|
|
21326
|
+
exit: false
|
|
21327
|
+
};
|
|
21328
|
+
listeners = {
|
|
21329
|
+
afterExit: [],
|
|
21330
|
+
exit: []
|
|
21331
|
+
};
|
|
21332
|
+
count = 0;
|
|
21333
|
+
id = Math.random();
|
|
21334
|
+
constructor() {
|
|
21335
|
+
if (global[kExitEmitter]) {
|
|
21336
|
+
return global[kExitEmitter];
|
|
21337
|
+
}
|
|
21338
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
21339
|
+
value: this,
|
|
21340
|
+
writable: false,
|
|
21341
|
+
enumerable: false,
|
|
21342
|
+
configurable: false
|
|
21343
|
+
});
|
|
21344
|
+
}
|
|
21345
|
+
on(ev, fn) {
|
|
21346
|
+
this.listeners[ev].push(fn);
|
|
21347
|
+
}
|
|
21348
|
+
removeListener(ev, fn) {
|
|
21349
|
+
const list = this.listeners[ev];
|
|
21350
|
+
const i = list.indexOf(fn);
|
|
21351
|
+
if (i === -1) {
|
|
21352
|
+
return;
|
|
21353
|
+
}
|
|
21354
|
+
if (i === 0 && list.length === 1) {
|
|
21355
|
+
list.length = 0;
|
|
21356
|
+
} else {
|
|
21357
|
+
list.splice(i, 1);
|
|
21358
|
+
}
|
|
21359
|
+
}
|
|
21360
|
+
emit(ev, code, signal) {
|
|
21361
|
+
if (this.emitted[ev]) {
|
|
21362
|
+
return false;
|
|
21363
|
+
}
|
|
21364
|
+
this.emitted[ev] = true;
|
|
21365
|
+
let ret = false;
|
|
21366
|
+
for (const fn of this.listeners[ev]) {
|
|
21367
|
+
ret = fn(code, signal) === true || ret;
|
|
21368
|
+
}
|
|
21369
|
+
if (ev === "exit") {
|
|
21370
|
+
ret = this.emit("afterExit", code, signal) || ret;
|
|
21371
|
+
}
|
|
21372
|
+
return ret;
|
|
21373
|
+
}
|
|
21374
|
+
};
|
|
21375
|
+
var SignalExitBase = class {
|
|
21376
|
+
};
|
|
21377
|
+
var signalExitWrap = (handler) => {
|
|
21378
|
+
return {
|
|
21379
|
+
onExit(cb, opts) {
|
|
21380
|
+
return handler.onExit(cb, opts);
|
|
21381
|
+
},
|
|
21382
|
+
load() {
|
|
21383
|
+
return handler.load();
|
|
21384
|
+
},
|
|
21385
|
+
unload() {
|
|
21386
|
+
return handler.unload();
|
|
21387
|
+
}
|
|
21388
|
+
};
|
|
21389
|
+
};
|
|
21390
|
+
var SignalExitFallback = class extends SignalExitBase {
|
|
21391
|
+
onExit() {
|
|
21392
|
+
return () => {
|
|
21393
|
+
};
|
|
21394
|
+
}
|
|
21395
|
+
load() {
|
|
21396
|
+
}
|
|
21397
|
+
unload() {
|
|
21398
|
+
}
|
|
21399
|
+
};
|
|
21400
|
+
var SignalExit = class extends SignalExitBase {
|
|
21401
|
+
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
|
21402
|
+
// so use a supported signal instead
|
|
21403
|
+
/* c8 ignore start */
|
|
21404
|
+
#hupSig = process4.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
21405
|
+
/* c8 ignore stop */
|
|
21406
|
+
#emitter = new Emitter();
|
|
21407
|
+
#process;
|
|
21408
|
+
#originalProcessEmit;
|
|
21409
|
+
#originalProcessReallyExit;
|
|
21410
|
+
#sigListeners = {};
|
|
21411
|
+
#loaded = false;
|
|
21412
|
+
constructor(process5) {
|
|
21413
|
+
super();
|
|
21414
|
+
this.#process = process5;
|
|
21415
|
+
this.#sigListeners = {};
|
|
21416
|
+
for (const sig of signals) {
|
|
21417
|
+
this.#sigListeners[sig] = () => {
|
|
21418
|
+
const listeners = this.#process.listeners(sig);
|
|
21419
|
+
let { count } = this.#emitter;
|
|
21420
|
+
const p = process5;
|
|
21421
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
|
|
21422
|
+
count += p.__signal_exit_emitter__.count;
|
|
21423
|
+
}
|
|
21424
|
+
if (listeners.length === count) {
|
|
21425
|
+
this.unload();
|
|
21426
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
21427
|
+
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
21428
|
+
if (!ret)
|
|
21429
|
+
process5.kill(process5.pid, s);
|
|
21430
|
+
}
|
|
21431
|
+
};
|
|
21432
|
+
}
|
|
21433
|
+
this.#originalProcessReallyExit = process5.reallyExit;
|
|
21434
|
+
this.#originalProcessEmit = process5.emit;
|
|
21435
|
+
}
|
|
21436
|
+
onExit(cb, opts) {
|
|
21437
|
+
if (!processOk(this.#process)) {
|
|
21438
|
+
return () => {
|
|
21439
|
+
};
|
|
21440
|
+
}
|
|
21441
|
+
if (this.#loaded === false) {
|
|
21442
|
+
this.load();
|
|
21443
|
+
}
|
|
21444
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
21445
|
+
this.#emitter.on(ev, cb);
|
|
21446
|
+
return () => {
|
|
21447
|
+
this.#emitter.removeListener(ev, cb);
|
|
21448
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
|
|
21449
|
+
this.unload();
|
|
21450
|
+
}
|
|
21451
|
+
};
|
|
21452
|
+
}
|
|
21453
|
+
load() {
|
|
21454
|
+
if (this.#loaded) {
|
|
21455
|
+
return;
|
|
21456
|
+
}
|
|
21457
|
+
this.#loaded = true;
|
|
21458
|
+
this.#emitter.count += 1;
|
|
21459
|
+
for (const sig of signals) {
|
|
21460
|
+
try {
|
|
21461
|
+
const fn = this.#sigListeners[sig];
|
|
21462
|
+
if (fn)
|
|
21463
|
+
this.#process.on(sig, fn);
|
|
21464
|
+
} catch (_) {
|
|
21465
|
+
}
|
|
21466
|
+
}
|
|
21467
|
+
this.#process.emit = (ev, ...a) => {
|
|
21468
|
+
return this.#processEmit(ev, ...a);
|
|
21469
|
+
};
|
|
21470
|
+
this.#process.reallyExit = (code) => {
|
|
21471
|
+
return this.#processReallyExit(code);
|
|
21472
|
+
};
|
|
21473
|
+
}
|
|
21474
|
+
unload() {
|
|
21475
|
+
if (!this.#loaded) {
|
|
21476
|
+
return;
|
|
21477
|
+
}
|
|
21478
|
+
this.#loaded = false;
|
|
21479
|
+
signals.forEach((sig) => {
|
|
21480
|
+
const listener = this.#sigListeners[sig];
|
|
21481
|
+
if (!listener) {
|
|
21482
|
+
throw new Error("Listener not defined for signal: " + sig);
|
|
21483
|
+
}
|
|
21484
|
+
try {
|
|
21485
|
+
this.#process.removeListener(sig, listener);
|
|
21486
|
+
} catch (_) {
|
|
21487
|
+
}
|
|
21488
|
+
});
|
|
21489
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
21490
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
21491
|
+
this.#emitter.count -= 1;
|
|
21492
|
+
}
|
|
21493
|
+
#processReallyExit(code) {
|
|
21494
|
+
if (!processOk(this.#process)) {
|
|
21495
|
+
return 0;
|
|
21496
|
+
}
|
|
21497
|
+
this.#process.exitCode = code || 0;
|
|
21498
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
21499
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
21500
|
+
}
|
|
21501
|
+
#processEmit(ev, ...args) {
|
|
21502
|
+
const og = this.#originalProcessEmit;
|
|
21503
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
21504
|
+
if (typeof args[0] === "number") {
|
|
21505
|
+
this.#process.exitCode = args[0];
|
|
21506
|
+
}
|
|
21507
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
21508
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
21509
|
+
return ret;
|
|
21510
|
+
} else {
|
|
21511
|
+
return og.call(this.#process, ev, ...args);
|
|
21512
|
+
}
|
|
21513
|
+
}
|
|
21514
|
+
};
|
|
21515
|
+
var process4 = globalThis.process;
|
|
21516
|
+
var {
|
|
21517
|
+
/**
|
|
21518
|
+
* Called when the process is exiting, whether via signal, explicit
|
|
21519
|
+
* exit, or running out of stuff to do.
|
|
21520
|
+
*
|
|
21521
|
+
* If the global process object is not suitable for instrumentation,
|
|
21522
|
+
* then this will be a no-op.
|
|
21523
|
+
*
|
|
21524
|
+
* Returns a function that may be used to unload signal-exit.
|
|
21525
|
+
*/
|
|
21526
|
+
onExit,
|
|
21527
|
+
/**
|
|
21528
|
+
* Load the listeners. Likely you never need to call this, unless
|
|
21529
|
+
* doing a rather deep integration with signal-exit functionality.
|
|
21530
|
+
* Mostly exposed for the benefit of testing.
|
|
21531
|
+
*
|
|
21532
|
+
* @internal
|
|
21533
|
+
*/
|
|
21534
|
+
load,
|
|
21535
|
+
/**
|
|
21536
|
+
* Unload the listeners. Likely you never need to call this, unless
|
|
21537
|
+
* doing a rather deep integration with signal-exit functionality.
|
|
21538
|
+
* Mostly exposed for the benefit of testing.
|
|
21539
|
+
*
|
|
21540
|
+
* @internal
|
|
21541
|
+
*/
|
|
21542
|
+
unload
|
|
21543
|
+
} = signalExitWrap(processOk(process4) ? new SignalExit(process4) : new SignalExitFallback());
|
|
21544
|
+
|
|
21545
|
+
// ../../../node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
21546
|
+
import { stripVTControlCharacters } from "node:util";
|
|
21547
|
+
|
|
21548
|
+
// ../../../node_modules/@inquirer/ansi/dist/index.js
|
|
21549
|
+
var ESC2 = "\x1B[";
|
|
21550
|
+
var cursorLeft = ESC2 + "G";
|
|
21551
|
+
var cursorHide = ESC2 + "?25l";
|
|
21552
|
+
var cursorShow = ESC2 + "?25h";
|
|
21553
|
+
var cursorUp = (rows = 1) => rows > 0 ? `${ESC2}${rows}A` : "";
|
|
21554
|
+
var cursorDown = (rows = 1) => rows > 0 ? `${ESC2}${rows}B` : "";
|
|
21555
|
+
var cursorTo = (x, y) => {
|
|
21556
|
+
if (typeof y === "number" && !Number.isNaN(y)) {
|
|
21557
|
+
return `${ESC2}${y + 1};${x + 1}H`;
|
|
21558
|
+
}
|
|
21559
|
+
return `${ESC2}${x + 1}G`;
|
|
21560
|
+
};
|
|
21561
|
+
var eraseLine = ESC2 + "2K";
|
|
21562
|
+
var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
21563
|
+
|
|
21564
|
+
// ../../../node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
21565
|
+
var height = (content) => content.split("\n").length;
|
|
21566
|
+
var lastLine = (content) => content.split("\n").pop() ?? "";
|
|
21567
|
+
var ScreenManager = class {
|
|
21568
|
+
// These variables are keeping information to allow correct prompt re-rendering
|
|
21569
|
+
height = 0;
|
|
21570
|
+
extraLinesUnderPrompt = 0;
|
|
21571
|
+
cursorPos;
|
|
21572
|
+
rl;
|
|
21573
|
+
constructor(rl) {
|
|
21574
|
+
this.rl = rl;
|
|
21575
|
+
this.cursorPos = rl.getCursorPos();
|
|
21576
|
+
}
|
|
21577
|
+
write(content) {
|
|
21578
|
+
this.rl.output.unmute();
|
|
21579
|
+
this.rl.output.write(content);
|
|
21580
|
+
this.rl.output.mute();
|
|
21581
|
+
}
|
|
21582
|
+
render(content, bottomContent = "") {
|
|
21583
|
+
const promptLine = lastLine(content);
|
|
21584
|
+
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
21585
|
+
let prompt = rawPromptLine;
|
|
21586
|
+
if (this.rl.line.length > 0) {
|
|
21587
|
+
prompt = prompt.slice(0, -this.rl.line.length);
|
|
21588
|
+
}
|
|
21589
|
+
this.rl.setPrompt(prompt);
|
|
21590
|
+
this.cursorPos = this.rl.getCursorPos();
|
|
21591
|
+
const width = readlineWidth();
|
|
21592
|
+
content = breakLines(content, width);
|
|
21593
|
+
bottomContent = breakLines(bottomContent, width);
|
|
21594
|
+
if (rawPromptLine.length % width === 0) {
|
|
21595
|
+
content += "\n";
|
|
21596
|
+
}
|
|
21597
|
+
let output = content + (bottomContent ? "\n" + bottomContent : "");
|
|
21598
|
+
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
|
|
21599
|
+
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
|
|
21600
|
+
if (bottomContentHeight > 0)
|
|
21601
|
+
output += cursorUp(bottomContentHeight);
|
|
21602
|
+
output += cursorTo(this.cursorPos.cols);
|
|
21603
|
+
this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
|
|
21604
|
+
this.extraLinesUnderPrompt = bottomContentHeight;
|
|
21605
|
+
this.height = height(output);
|
|
21606
|
+
}
|
|
21607
|
+
checkCursorPos() {
|
|
21608
|
+
const cursorPos = this.rl.getCursorPos();
|
|
21609
|
+
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
21610
|
+
this.write(cursorTo(cursorPos.cols));
|
|
21611
|
+
this.cursorPos = cursorPos;
|
|
21612
|
+
}
|
|
21613
|
+
}
|
|
21614
|
+
done({ clearContent }) {
|
|
21615
|
+
this.rl.setPrompt("");
|
|
21616
|
+
let output = cursorDown(this.extraLinesUnderPrompt);
|
|
21617
|
+
output += clearContent ? eraseLines(this.height) : "\n";
|
|
21618
|
+
output += cursorLeft;
|
|
21619
|
+
output += cursorShow;
|
|
21620
|
+
this.write(output);
|
|
21621
|
+
this.rl.close();
|
|
21622
|
+
}
|
|
21623
|
+
};
|
|
21624
|
+
|
|
21625
|
+
// ../../../node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
21626
|
+
var PromisePolyfill = class extends Promise {
|
|
21627
|
+
// Available starting from Node 22
|
|
21628
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
21629
|
+
static withResolver() {
|
|
21630
|
+
let resolve;
|
|
21631
|
+
let reject;
|
|
21632
|
+
const promise2 = new Promise((res, rej) => {
|
|
21633
|
+
resolve = res;
|
|
21634
|
+
reject = rej;
|
|
21635
|
+
});
|
|
21636
|
+
return { promise: promise2, resolve, reject };
|
|
21637
|
+
}
|
|
21638
|
+
};
|
|
21639
|
+
|
|
21640
|
+
// ../../../node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
21641
|
+
import path from "node:path";
|
|
21642
|
+
var nativeSetImmediate = globalThis.setImmediate;
|
|
21643
|
+
function listenTo(target, event, listener) {
|
|
21644
|
+
if ("on" in target) {
|
|
21645
|
+
target.on(event, listener);
|
|
21646
|
+
return () => target.removeListener(event, listener);
|
|
21647
|
+
}
|
|
21648
|
+
target.addEventListener(event, listener);
|
|
21649
|
+
return () => target.removeEventListener(event, listener);
|
|
21650
|
+
}
|
|
21651
|
+
function getCallSites() {
|
|
21652
|
+
const savedPrepareStackTrace = Error.prepareStackTrace;
|
|
21653
|
+
let result = [];
|
|
21654
|
+
try {
|
|
21655
|
+
Error.prepareStackTrace = (_, callSites) => {
|
|
21656
|
+
const callSitesWithoutCurrent = callSites.slice(1);
|
|
21657
|
+
result = callSitesWithoutCurrent;
|
|
21658
|
+
return callSitesWithoutCurrent;
|
|
21659
|
+
};
|
|
21660
|
+
new Error().stack;
|
|
21661
|
+
} catch {
|
|
21662
|
+
return result;
|
|
21663
|
+
}
|
|
21664
|
+
Error.prepareStackTrace = savedPrepareStackTrace;
|
|
21665
|
+
return result;
|
|
21666
|
+
}
|
|
21667
|
+
function createPrompt(view) {
|
|
21668
|
+
const callSites = getCallSites();
|
|
21669
|
+
const prompt = (config2, context = {}) => {
|
|
21670
|
+
const { input = process.stdin, signal } = context;
|
|
21671
|
+
const cleanups = /* @__PURE__ */ new Set();
|
|
21672
|
+
const output = new import_mute_stream.default();
|
|
21673
|
+
output.pipe(context.output ?? process.stdout);
|
|
21674
|
+
const rl = readline2.createInterface({
|
|
21675
|
+
terminal: true,
|
|
21676
|
+
input,
|
|
21677
|
+
output
|
|
21678
|
+
});
|
|
21679
|
+
output.mute();
|
|
21680
|
+
const screen = new ScreenManager(rl);
|
|
21681
|
+
const { promise: promise2, resolve, reject } = PromisePolyfill.withResolver();
|
|
21682
|
+
return withHooks(rl, (cycle) => {
|
|
21683
|
+
const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
21684
|
+
const settlePrompt = (settle) => {
|
|
21685
|
+
try {
|
|
21686
|
+
clearEffects();
|
|
21687
|
+
settle();
|
|
21688
|
+
} catch (error51) {
|
|
21689
|
+
reject(error51);
|
|
21690
|
+
}
|
|
21691
|
+
};
|
|
21692
|
+
const resolvePrompt = (value) => settlePrompt(() => resolve(value));
|
|
21693
|
+
const rejectPrompt = (error51) => settlePrompt(() => reject(error51));
|
|
21694
|
+
const promptPromise = Object.assign(promise2.finally(() => {
|
|
21695
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
21696
|
+
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
21697
|
+
output.end();
|
|
21698
|
+
}).then(() => promise2), { cancel: () => rejectPrompt(new CancelPromptError()) });
|
|
21699
|
+
if (signal) {
|
|
21700
|
+
const abort = () => rejectPrompt(new AbortPromptError({ cause: signal.reason }));
|
|
21701
|
+
if (signal.aborted) {
|
|
21702
|
+
abort();
|
|
21703
|
+
return promptPromise;
|
|
21704
|
+
}
|
|
21705
|
+
cleanups.add(listenTo(signal, "abort", abort));
|
|
21706
|
+
}
|
|
21707
|
+
cleanups.add(onExit((code, signal2) => {
|
|
21708
|
+
rejectPrompt(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
|
|
21709
|
+
}));
|
|
21710
|
+
cleanups.add(listenTo(rl, "SIGINT", () => rejectPrompt(new ExitPromptError(`User force closed the prompt with SIGINT`))));
|
|
21711
|
+
cleanups.add(listenTo(rl, "close", clearEffects));
|
|
21712
|
+
const startCycle = () => {
|
|
21713
|
+
cleanups.add(listenTo(rl.input, "keypress", () => screen.checkCursorPos()));
|
|
21714
|
+
let pendingDone = null;
|
|
21715
|
+
cycle(() => {
|
|
21716
|
+
let effectsSettled = false;
|
|
21717
|
+
try {
|
|
21718
|
+
const nextView = view(config2, (value) => {
|
|
21719
|
+
if (effectsSettled) {
|
|
21720
|
+
resolvePrompt(value);
|
|
21721
|
+
} else {
|
|
21722
|
+
pendingDone = { value };
|
|
21723
|
+
}
|
|
21724
|
+
});
|
|
21725
|
+
if (nextView === void 0) {
|
|
21726
|
+
let callerFilename = callSites[1]?.getFileName();
|
|
21727
|
+
if (callerFilename && !callerFilename.startsWith("file://")) {
|
|
21728
|
+
callerFilename = path.resolve(callerFilename);
|
|
21729
|
+
}
|
|
21730
|
+
throw new Error(`Prompt functions must return a string.
|
|
21731
|
+
at ${callerFilename}`);
|
|
21732
|
+
}
|
|
21733
|
+
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
21734
|
+
screen.render(content, bottomContent);
|
|
21735
|
+
effectScheduler.run();
|
|
21736
|
+
} catch (error51) {
|
|
21737
|
+
rejectPrompt(error51);
|
|
21738
|
+
}
|
|
21739
|
+
effectsSettled = true;
|
|
21740
|
+
if (pendingDone !== null) {
|
|
21741
|
+
const { value } = pendingDone;
|
|
21742
|
+
pendingDone = null;
|
|
21743
|
+
resolvePrompt(value);
|
|
21744
|
+
}
|
|
21745
|
+
});
|
|
21746
|
+
};
|
|
21747
|
+
if ("readableFlowing" in input) {
|
|
21748
|
+
nativeSetImmediate(startCycle);
|
|
21749
|
+
} else {
|
|
21750
|
+
startCycle();
|
|
21751
|
+
}
|
|
21752
|
+
return promptPromise;
|
|
21753
|
+
});
|
|
21754
|
+
};
|
|
21755
|
+
return prompt;
|
|
21756
|
+
}
|
|
21757
|
+
|
|
21758
|
+
// ../../../node_modules/@inquirer/core/dist/lib/Separator.js
|
|
21759
|
+
import { styleText as styleText2 } from "node:util";
|
|
21760
|
+
var Separator = class {
|
|
21761
|
+
separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
|
|
21762
|
+
type = "separator";
|
|
21763
|
+
constructor(separator) {
|
|
21764
|
+
if (separator) {
|
|
21765
|
+
this.separator = separator;
|
|
21766
|
+
}
|
|
21767
|
+
}
|
|
21768
|
+
static isSeparator(choice) {
|
|
21769
|
+
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
21770
|
+
}
|
|
21771
|
+
};
|
|
21772
|
+
|
|
21773
|
+
// ../../../node_modules/@inquirer/confirm/dist/index.js
|
|
21774
|
+
import { styleText as styleText3 } from "node:util";
|
|
21775
|
+
var confirmTheme = {
|
|
21776
|
+
keywords: {
|
|
21777
|
+
yes: "Yes",
|
|
21778
|
+
no: "No"
|
|
21779
|
+
},
|
|
21780
|
+
style: {
|
|
21781
|
+
confirmDefault: (text) => {
|
|
21782
|
+
const first = text[0] ?? "";
|
|
21783
|
+
if (first.toLowerCase() === first.toUpperCase()) {
|
|
21784
|
+
return styleText3("cyan", text);
|
|
21785
|
+
}
|
|
21786
|
+
return first.toUpperCase() + text.slice(1);
|
|
21787
|
+
}
|
|
21788
|
+
}
|
|
21789
|
+
};
|
|
21790
|
+
var dist_default4 = createPrompt((config2, done) => {
|
|
21791
|
+
const [status, setStatus] = useState("idle");
|
|
21792
|
+
const [value, setValue] = useState("");
|
|
21793
|
+
const theme = makeTheme(confirmTheme, config2.theme);
|
|
21794
|
+
const prefix = usePrefix({ status, theme });
|
|
21795
|
+
const { yes, no } = theme.keywords;
|
|
21796
|
+
const yesHint = (yes[0] ?? "").toLowerCase();
|
|
21797
|
+
const noHint = (no[0] ?? "").toLowerCase();
|
|
21798
|
+
const hint = config2.default === false ? `${yesHint}/${theme.style.confirmDefault(noHint)}` : `${theme.style.confirmDefault(yesHint)}/${noHint}`;
|
|
21799
|
+
function boolToString(value2) {
|
|
21800
|
+
return value2 ? yes : no;
|
|
21801
|
+
}
|
|
21802
|
+
const { transformer = boolToString } = config2;
|
|
21803
|
+
function getBooleanValue(value2, defaultValue2) {
|
|
21804
|
+
const v = value2.trim().toLowerCase();
|
|
21805
|
+
if (v === "")
|
|
21806
|
+
return defaultValue2 !== false;
|
|
21807
|
+
if (yes.toLowerCase().startsWith(v))
|
|
21808
|
+
return true;
|
|
21809
|
+
if (no.toLowerCase().startsWith(v))
|
|
21810
|
+
return false;
|
|
21811
|
+
return defaultValue2 !== false;
|
|
21812
|
+
}
|
|
21813
|
+
useKeypress((key, rl) => {
|
|
21814
|
+
if (status !== "idle")
|
|
21815
|
+
return;
|
|
21816
|
+
if (isEnterKey(key)) {
|
|
21817
|
+
const answer = getBooleanValue(value, config2.default);
|
|
21818
|
+
setValue(transformer(answer));
|
|
21819
|
+
setStatus("done");
|
|
21820
|
+
done(answer);
|
|
21821
|
+
} else if (isTabKey(key)) {
|
|
21822
|
+
const answer = boolToString(!getBooleanValue(value, config2.default));
|
|
21823
|
+
rl.clearLine(0);
|
|
21824
|
+
rl.write(answer);
|
|
21825
|
+
setValue(answer);
|
|
21826
|
+
} else {
|
|
21827
|
+
setValue(rl.line);
|
|
21828
|
+
}
|
|
21829
|
+
});
|
|
21830
|
+
let formattedValue = value;
|
|
21831
|
+
let defaultValue = "";
|
|
21832
|
+
if (status === "done") {
|
|
21833
|
+
formattedValue = theme.style.answer(value);
|
|
21834
|
+
} else {
|
|
21835
|
+
defaultValue = ` ${theme.style.defaultAnswer(hint)}`;
|
|
21836
|
+
}
|
|
21837
|
+
const message = theme.style.message(config2.message, status);
|
|
21838
|
+
return `${prefix} ${message}${defaultValue} ${formattedValue}`;
|
|
21839
|
+
});
|
|
21840
|
+
|
|
21841
|
+
// ../../../node_modules/@inquirer/input/dist/index.js
|
|
21842
|
+
var inputTheme = {
|
|
21843
|
+
validationFailureMode: "keep"
|
|
21844
|
+
};
|
|
21845
|
+
var dist_default5 = createPrompt((config2, done) => {
|
|
21846
|
+
const { prefill = "tab" } = config2;
|
|
21847
|
+
const theme = makeTheme(inputTheme, config2.theme);
|
|
21848
|
+
const [status, setStatus] = useState("idle");
|
|
21849
|
+
const [defaultValue, setDefaultValue] = useState(String(config2.default ?? ""));
|
|
21850
|
+
const [errorMsg, setError] = useState();
|
|
21851
|
+
const [value, setValue] = useState("");
|
|
21852
|
+
const prefix = usePrefix({ status, theme });
|
|
21853
|
+
async function validate(value2) {
|
|
21854
|
+
const { required: required2, pattern, patternError = "Invalid input" } = config2;
|
|
21855
|
+
if (required2 && !value2) {
|
|
21856
|
+
return "You must provide a value";
|
|
21857
|
+
}
|
|
21858
|
+
if (pattern && !pattern.test(value2)) {
|
|
21859
|
+
return patternError;
|
|
21860
|
+
}
|
|
21861
|
+
if (typeof config2.validate === "function") {
|
|
21862
|
+
return await config2.validate(value2) || "You must provide a valid value";
|
|
21863
|
+
}
|
|
21864
|
+
return true;
|
|
21865
|
+
}
|
|
21866
|
+
useKeypress(async (key, rl) => {
|
|
21867
|
+
if (status !== "idle") {
|
|
21868
|
+
return;
|
|
21869
|
+
}
|
|
21870
|
+
if (isEnterKey(key)) {
|
|
21871
|
+
const answer = value || defaultValue;
|
|
21872
|
+
setStatus("loading");
|
|
21873
|
+
const isValid = await validate(answer);
|
|
21874
|
+
if (isValid === true) {
|
|
21875
|
+
setValue(answer);
|
|
21876
|
+
setStatus("done");
|
|
21877
|
+
done(answer);
|
|
21878
|
+
} else {
|
|
21879
|
+
if (theme.validationFailureMode === "clear") {
|
|
21880
|
+
setValue("");
|
|
21881
|
+
} else {
|
|
21882
|
+
rl.write(value);
|
|
21883
|
+
}
|
|
21884
|
+
setError(isValid);
|
|
21885
|
+
setStatus("idle");
|
|
21886
|
+
}
|
|
21887
|
+
} else if (isBackspaceKey(key) && !value) {
|
|
21888
|
+
setDefaultValue("");
|
|
21889
|
+
} else if (isTabKey(key) && !value) {
|
|
21890
|
+
setDefaultValue("");
|
|
21891
|
+
rl.clearLine(0);
|
|
21892
|
+
rl.write(defaultValue);
|
|
21893
|
+
setValue(defaultValue);
|
|
21894
|
+
} else {
|
|
21895
|
+
setValue(rl.line);
|
|
21896
|
+
setError(void 0);
|
|
21897
|
+
}
|
|
21898
|
+
});
|
|
21899
|
+
useEffect((rl) => {
|
|
21900
|
+
if (prefill === "editable" && defaultValue) {
|
|
21901
|
+
rl.write(defaultValue);
|
|
21902
|
+
setValue(defaultValue);
|
|
21903
|
+
}
|
|
21904
|
+
}, []);
|
|
21905
|
+
const message = theme.style.message(config2.message, status);
|
|
21906
|
+
let formattedValue = value;
|
|
21907
|
+
if (typeof config2.transformer === "function") {
|
|
21908
|
+
formattedValue = config2.transformer(value, { isFinal: status === "done" });
|
|
21909
|
+
} else if (status === "done") {
|
|
21910
|
+
formattedValue = theme.style.answer(value);
|
|
21911
|
+
}
|
|
21912
|
+
let defaultStr;
|
|
21913
|
+
if (defaultValue && status !== "done" && !value) {
|
|
21914
|
+
defaultStr = theme.style.defaultAnswer(defaultValue);
|
|
21915
|
+
}
|
|
21916
|
+
let error51 = "";
|
|
21917
|
+
if (errorMsg) {
|
|
21918
|
+
error51 = theme.style.error(errorMsg);
|
|
21919
|
+
}
|
|
21920
|
+
return [
|
|
21921
|
+
[prefix, message, defaultStr, formattedValue].filter((v) => v !== void 0).join(" "),
|
|
21922
|
+
error51
|
|
21923
|
+
];
|
|
21924
|
+
});
|
|
21925
|
+
|
|
21926
|
+
// ../../../node_modules/@inquirer/select/dist/index.js
|
|
21927
|
+
import { styleText as styleText4 } from "node:util";
|
|
21928
|
+
var selectTheme = {
|
|
21929
|
+
icon: { cursor: dist_default.pointer },
|
|
21930
|
+
style: {
|
|
21931
|
+
disabled: (text) => styleText4("dim", text),
|
|
21932
|
+
description: (text) => styleText4("cyan", text),
|
|
21933
|
+
keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText4("bold", key)} ${styleText4("dim", action)}`).join(styleText4("dim", " \u2022 "))
|
|
21934
|
+
},
|
|
21935
|
+
i18n: { disabledError: "This option is disabled and cannot be selected." },
|
|
21936
|
+
indexMode: "hidden"
|
|
21937
|
+
};
|
|
21938
|
+
function isSelectable(item) {
|
|
21939
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
|
21940
|
+
}
|
|
21941
|
+
function isNavigable(item) {
|
|
21942
|
+
return !Separator.isSeparator(item);
|
|
21943
|
+
}
|
|
21944
|
+
function normalizeChoices(choices) {
|
|
21945
|
+
return choices.map((choice) => {
|
|
21946
|
+
if (Separator.isSeparator(choice))
|
|
21947
|
+
return choice;
|
|
21948
|
+
if (typeof choice !== "object" || choice === null || !("value" in choice)) {
|
|
21949
|
+
const name2 = String(choice);
|
|
21950
|
+
return {
|
|
21951
|
+
value: choice,
|
|
21952
|
+
name: name2,
|
|
21953
|
+
short: name2,
|
|
21954
|
+
disabled: false
|
|
21955
|
+
};
|
|
21956
|
+
}
|
|
21957
|
+
const name = choice.name ?? String(choice.value);
|
|
21958
|
+
const normalizedChoice = {
|
|
21959
|
+
value: choice.value,
|
|
21960
|
+
name,
|
|
21961
|
+
short: choice.short ?? name,
|
|
21962
|
+
disabled: choice.disabled ?? false
|
|
21963
|
+
};
|
|
21964
|
+
if (choice.description) {
|
|
21965
|
+
normalizedChoice.description = choice.description;
|
|
21966
|
+
}
|
|
21967
|
+
return normalizedChoice;
|
|
21968
|
+
});
|
|
21969
|
+
}
|
|
21970
|
+
var dist_default6 = createPrompt((config2, done) => {
|
|
21971
|
+
const { loop = true, pageSize = 7 } = config2;
|
|
21972
|
+
const theme = makeTheme(selectTheme, config2.theme);
|
|
21973
|
+
const { keybindings: keybindings2 } = theme;
|
|
21974
|
+
const [status, setStatus] = useState("idle");
|
|
21975
|
+
const prefix = usePrefix({ status, theme });
|
|
21976
|
+
const searchTimeoutRef = useRef();
|
|
21977
|
+
const searchEnabled = !keybindings2.includes("vim");
|
|
21978
|
+
const items = useMemo(() => normalizeChoices(config2.choices), [config2.choices]);
|
|
21979
|
+
const bounds = useMemo(() => {
|
|
21980
|
+
const first = items.findIndex(isNavigable);
|
|
21981
|
+
const last = items.findLastIndex(isNavigable);
|
|
21982
|
+
if (first === -1) {
|
|
21983
|
+
throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
|
|
21984
|
+
}
|
|
21985
|
+
return { first, last };
|
|
21986
|
+
}, [items]);
|
|
21987
|
+
const defaultItemIndex = useMemo(() => {
|
|
21988
|
+
if (!("default" in config2))
|
|
21989
|
+
return -1;
|
|
21990
|
+
return items.findIndex((item) => isSelectable(item) && item.value === config2.default);
|
|
21991
|
+
}, [config2.default, items]);
|
|
21992
|
+
const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
|
|
21993
|
+
const selectedChoice = items[active];
|
|
21994
|
+
if (selectedChoice == null || Separator.isSeparator(selectedChoice)) {
|
|
21995
|
+
throw new Error("Active index does not point to a choice");
|
|
21996
|
+
}
|
|
21997
|
+
const [errorMsg, setError] = useState();
|
|
21998
|
+
useKeypress((key, rl) => {
|
|
21999
|
+
clearTimeout(searchTimeoutRef.current);
|
|
22000
|
+
if (errorMsg) {
|
|
22001
|
+
setError(void 0);
|
|
22002
|
+
}
|
|
22003
|
+
if (isEnterKey(key)) {
|
|
22004
|
+
if (selectedChoice.disabled) {
|
|
22005
|
+
setError(theme.i18n.disabledError);
|
|
22006
|
+
} else {
|
|
22007
|
+
setStatus("done");
|
|
22008
|
+
done(selectedChoice.value);
|
|
22009
|
+
}
|
|
22010
|
+
} else if (isUpKey(key, keybindings2) || isDownKey(key, keybindings2)) {
|
|
22011
|
+
rl.clearLine(0);
|
|
22012
|
+
if (loop || isUpKey(key, keybindings2) && active !== bounds.first || isDownKey(key, keybindings2) && active !== bounds.last) {
|
|
22013
|
+
const offset = isUpKey(key, keybindings2) ? -1 : 1;
|
|
22014
|
+
let next = active;
|
|
22015
|
+
do {
|
|
22016
|
+
next = (next + offset + items.length) % items.length;
|
|
22017
|
+
} while (!isNavigable(items[next]));
|
|
22018
|
+
setActive(next);
|
|
22019
|
+
}
|
|
22020
|
+
} else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
|
|
22021
|
+
const selectedIndex = Number(rl.line) - 1;
|
|
22022
|
+
let selectableIndex = -1;
|
|
22023
|
+
const position = items.findIndex((item2) => {
|
|
22024
|
+
if (Separator.isSeparator(item2))
|
|
22025
|
+
return false;
|
|
22026
|
+
selectableIndex++;
|
|
22027
|
+
return selectableIndex === selectedIndex;
|
|
22028
|
+
});
|
|
22029
|
+
const item = items[position];
|
|
22030
|
+
if (item != null && isSelectable(item)) {
|
|
22031
|
+
setActive(position);
|
|
22032
|
+
}
|
|
22033
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
22034
|
+
rl.clearLine(0);
|
|
22035
|
+
}, 700);
|
|
22036
|
+
} else if (isBackspaceKey(key)) {
|
|
22037
|
+
rl.clearLine(0);
|
|
22038
|
+
} else if (searchEnabled) {
|
|
22039
|
+
const searchTerm = rl.line.toLowerCase();
|
|
22040
|
+
const matchIndex = items.findIndex((item) => {
|
|
22041
|
+
if (Separator.isSeparator(item) || !isSelectable(item))
|
|
22042
|
+
return false;
|
|
22043
|
+
return item.name.toLowerCase().startsWith(searchTerm);
|
|
22044
|
+
});
|
|
22045
|
+
if (matchIndex !== -1) {
|
|
22046
|
+
setActive(matchIndex);
|
|
22047
|
+
}
|
|
22048
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
22049
|
+
rl.clearLine(0);
|
|
22050
|
+
}, 700);
|
|
22051
|
+
}
|
|
22052
|
+
});
|
|
22053
|
+
useEffect(() => () => {
|
|
22054
|
+
clearTimeout(searchTimeoutRef.current);
|
|
22055
|
+
}, []);
|
|
22056
|
+
const message = theme.style.message(config2.message, status);
|
|
22057
|
+
const helpLine = theme.style.keysHelpTip([
|
|
22058
|
+
["\u2191\u2193", "navigate"],
|
|
22059
|
+
["\u23CE", "select"]
|
|
22060
|
+
]);
|
|
22061
|
+
let separatorCount = 0;
|
|
22062
|
+
const page = usePagination({
|
|
22063
|
+
items,
|
|
22064
|
+
active,
|
|
22065
|
+
renderItem({ item, isActive, index }) {
|
|
22066
|
+
if (Separator.isSeparator(item)) {
|
|
22067
|
+
separatorCount++;
|
|
22068
|
+
return ` ${item.separator}`;
|
|
22069
|
+
}
|
|
22070
|
+
const cursor = isActive ? theme.icon.cursor : " ";
|
|
22071
|
+
const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
|
|
22072
|
+
if (item.disabled) {
|
|
22073
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
22074
|
+
const disabledCursor = isActive ? theme.icon.cursor : "-";
|
|
22075
|
+
return theme.style.disabled(`${disabledCursor} ${indexLabel}${item.name} ${disabledLabel}`);
|
|
22076
|
+
}
|
|
22077
|
+
const color = isActive ? theme.style.highlight : (x) => x;
|
|
22078
|
+
return color(`${cursor} ${indexLabel}${item.name}`);
|
|
22079
|
+
},
|
|
22080
|
+
pageSize,
|
|
22081
|
+
loop
|
|
22082
|
+
});
|
|
22083
|
+
if (status === "done") {
|
|
22084
|
+
return [prefix, message, theme.style.answer(selectedChoice.short)].filter(Boolean).join(" ");
|
|
22085
|
+
}
|
|
22086
|
+
const { description } = selectedChoice;
|
|
22087
|
+
const lines = [
|
|
22088
|
+
[prefix, message].filter(Boolean).join(" "),
|
|
22089
|
+
page,
|
|
22090
|
+
" ",
|
|
22091
|
+
description ? theme.style.description(description) : "",
|
|
22092
|
+
errorMsg ? theme.style.error(errorMsg) : "",
|
|
22093
|
+
helpLine
|
|
22094
|
+
].filter(Boolean).join("\n").trimEnd();
|
|
22095
|
+
return `${lines}${cursorHide}`;
|
|
22096
|
+
});
|
|
22097
|
+
|
|
20063
22098
|
// dist/run.js
|
|
20064
22099
|
import { spawn } from "node:child_process";
|
|
22100
|
+
import os from "node:os";
|
|
20065
22101
|
var runner = {
|
|
20066
22102
|
attended(argv) {
|
|
20067
22103
|
return new Promise((resolve) => {
|
|
@@ -20072,6 +22108,7 @@ var runner = {
|
|
|
20072
22108
|
},
|
|
20073
22109
|
async unattended({ work, onProgress }) {
|
|
20074
22110
|
const argv = headlessArgv(work);
|
|
22111
|
+
const raw = argv[0] === "script";
|
|
20075
22112
|
let output = "";
|
|
20076
22113
|
let agentSessionId = work.agentSessionId ?? void 0;
|
|
20077
22114
|
let lastText = "";
|
|
@@ -20097,10 +22134,24 @@ var runner = {
|
|
|
20097
22134
|
}
|
|
20098
22135
|
};
|
|
20099
22136
|
const code = await new Promise((resolve) => {
|
|
20100
|
-
const child = spawn(argv[0], argv.slice(1), {
|
|
22137
|
+
const child = spawn(argv[0], argv.slice(1), {
|
|
22138
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
22139
|
+
cwd: os.homedir(),
|
|
22140
|
+
env: {
|
|
22141
|
+
...process.env,
|
|
22142
|
+
TERM: process.env.TERM ?? "xterm-256color",
|
|
22143
|
+
COLUMNS: process.env.COLUMNS ?? "120",
|
|
22144
|
+
LINES: process.env.LINES ?? "40"
|
|
22145
|
+
}
|
|
22146
|
+
});
|
|
22147
|
+
append("");
|
|
20101
22148
|
child.stdout.setEncoding("utf8");
|
|
20102
22149
|
child.stderr.setEncoding("utf8");
|
|
20103
22150
|
child.stdout.on("data", (chunk) => {
|
|
22151
|
+
if (raw) {
|
|
22152
|
+
append(chunk);
|
|
22153
|
+
return;
|
|
22154
|
+
}
|
|
20104
22155
|
pending += chunk;
|
|
20105
22156
|
const lines = pending.split("\n");
|
|
20106
22157
|
pending = lines.pop() ?? "";
|
|
@@ -20140,7 +22191,7 @@ function headlessArgv(work) {
|
|
|
20140
22191
|
if (!isAgent(argv[0]))
|
|
20141
22192
|
return argv;
|
|
20142
22193
|
if (argv.includes("--remote-control"))
|
|
20143
|
-
return argv;
|
|
22194
|
+
return underTty(argv);
|
|
20144
22195
|
const streaming = ["--output-format", "stream-json", "--verbose"];
|
|
20145
22196
|
if (work.answer !== null && work.agentSessionId !== null) {
|
|
20146
22197
|
return [argv[0], "--resume", work.agentSessionId, "-p", work.answer, ...streaming];
|
|
@@ -20149,6 +22200,12 @@ function headlessArgv(work) {
|
|
|
20149
22200
|
return [...argv, ...streaming];
|
|
20150
22201
|
return [argv[0], "-p", argv.slice(1).join(" "), ...streaming];
|
|
20151
22202
|
}
|
|
22203
|
+
function underTty(argv) {
|
|
22204
|
+
const line = `stty rows ${PTY_ROWS} cols ${PTY_COLS} 2>/dev/null; exec ${argv.join(" ")}`;
|
|
22205
|
+
return process.platform === "linux" ? ["script", "-qec", line, "/dev/null"] : ["script", "-q", "/dev/null", "sh", "-c", line];
|
|
22206
|
+
}
|
|
22207
|
+
var PTY_ROWS = 40;
|
|
22208
|
+
var PTY_COLS = 120;
|
|
20152
22209
|
function isAgent(command) {
|
|
20153
22210
|
return AGENTS.has((command ?? "").split("/").pop() ?? "");
|
|
20154
22211
|
}
|
|
@@ -20177,18 +22234,20 @@ function parseJson(line) {
|
|
|
20177
22234
|
|
|
20178
22235
|
// dist/setup.js
|
|
20179
22236
|
import { execFile as execFile2 } from "node:child_process";
|
|
22237
|
+
import os3 from "node:os";
|
|
22238
|
+
import path3 from "node:path";
|
|
20180
22239
|
import { promisify as promisify2 } from "node:util";
|
|
20181
22240
|
|
|
20182
22241
|
// dist/probe.js
|
|
20183
22242
|
import { execFile } from "node:child_process";
|
|
20184
22243
|
import net from "node:net";
|
|
20185
22244
|
import { access, readFile } from "node:fs/promises";
|
|
20186
|
-
import
|
|
20187
|
-
import
|
|
22245
|
+
import os2 from "node:os";
|
|
22246
|
+
import path2 from "node:path";
|
|
20188
22247
|
import { promisify } from "node:util";
|
|
20189
22248
|
var run = promisify(execFile);
|
|
20190
22249
|
var probe = {
|
|
20191
|
-
async tools({ mcpPath =
|
|
22250
|
+
async tools({ mcpPath = path2.join(os2.homedir(), ".mcp.json") } = {}) {
|
|
20192
22251
|
const [brain, claude, codex, git, chrome, ssh] = await Promise.all([
|
|
20193
22252
|
brainWired(mcpPath),
|
|
20194
22253
|
version2({ id: "claude", command: "claude" }),
|
|
@@ -20215,26 +22274,26 @@ async function brainWired(mcpPath) {
|
|
|
20215
22274
|
}
|
|
20216
22275
|
async function version2({ id, command }) {
|
|
20217
22276
|
const found = await firstLine(command, ["--version"]);
|
|
20218
|
-
if (
|
|
20219
|
-
return { id, ok: true, detail: found };
|
|
20220
|
-
return { id, ok: false, detail: found === "absent" ? "not installed" : "installed, but it will not report a version" };
|
|
22277
|
+
if (found.ran)
|
|
22278
|
+
return { id, ok: true, detail: found.line };
|
|
22279
|
+
return { id, ok: false, detail: found.why === "absent" ? "not installed" : "installed, but it will not report a version" };
|
|
20221
22280
|
}
|
|
20222
22281
|
async function gitAndGithub() {
|
|
20223
22282
|
const git = await firstLine("git", ["--version"]);
|
|
20224
|
-
if (
|
|
22283
|
+
if (!git.ran)
|
|
20225
22284
|
return { id: "git", ok: false, detail: "git is not installed" };
|
|
20226
22285
|
const gh = await firstLine("gh", ["--version"]);
|
|
20227
|
-
if (
|
|
20228
|
-
return { id: "git", ok: false, detail: `${git} \xB7 the GitHub CLI is not installed yet` };
|
|
22286
|
+
if (!gh.ran)
|
|
22287
|
+
return { id: "git", ok: false, detail: `${git.line} \xB7 the GitHub CLI is not installed yet` };
|
|
20229
22288
|
const account = await githubAccount();
|
|
20230
22289
|
return {
|
|
20231
22290
|
id: "git",
|
|
20232
22291
|
ok: account !== null,
|
|
20233
|
-
detail: account === null ? `${git} \xB7 ${gh}, run gh auth login on this machine` : `${git} \xB7 ${gh}, signed in as ${account}`
|
|
22292
|
+
detail: account === null ? `${git.line} \xB7 ${gh.line}, run gh auth login on this machine` : `${git.line} \xB7 ${gh.line}, signed in as ${account}`
|
|
20234
22293
|
};
|
|
20235
22294
|
}
|
|
20236
22295
|
async function githubAccount() {
|
|
20237
|
-
const raw = await readFile(
|
|
22296
|
+
const raw = await readFile(path2.join(os2.homedir(), ".config", "gh", "hosts.yml"), "utf8").catch(() => null);
|
|
20238
22297
|
return raw === null ? null : githubUser(raw);
|
|
20239
22298
|
}
|
|
20240
22299
|
function githubUser(hostsYml) {
|
|
@@ -20243,8 +22302,8 @@ function githubUser(hostsYml) {
|
|
|
20243
22302
|
async function chromeInstalled() {
|
|
20244
22303
|
for (const command of [...MAC_CHROME, ...LINUX_CHROME]) {
|
|
20245
22304
|
const found = await firstLine(command, ["--version"]);
|
|
20246
|
-
if (
|
|
20247
|
-
return { id: "chrome", ok: true, detail: found };
|
|
22305
|
+
if (found.ran)
|
|
22306
|
+
return { id: "chrome", ok: true, detail: found.line };
|
|
20248
22307
|
}
|
|
20249
22308
|
return { id: "chrome", ok: false, detail: "not installed yet, so browser runs will fail" };
|
|
20250
22309
|
}
|
|
@@ -20265,16 +22324,16 @@ async function firstLine(command, args) {
|
|
|
20265
22324
|
if (command.includes("/")) {
|
|
20266
22325
|
const reachable = await access(command).then(() => true, () => false);
|
|
20267
22326
|
if (!reachable)
|
|
20268
|
-
return "absent";
|
|
22327
|
+
return { ran: false, why: "absent" };
|
|
20269
22328
|
}
|
|
20270
22329
|
const answer = await run(command, args, { timeout: PROBE_TIMEOUT_MS }).catch((thrown) => thrown);
|
|
20271
22330
|
if (answer instanceof Error)
|
|
20272
|
-
return answer.code === "ENOENT" ? "absent" : "broken";
|
|
22331
|
+
return { ran: false, why: answer.code === "ENOENT" ? "absent" : "broken" };
|
|
20273
22332
|
const line = answer.stdout.split("\n")[0]?.trim() ?? "";
|
|
20274
|
-
return line === "" ? "broken" : line.slice(0, 200);
|
|
22333
|
+
return line === "" ? { ran: false, why: "broken" } : { ran: true, line: line.slice(0, 200) };
|
|
20275
22334
|
}
|
|
20276
22335
|
function short(target) {
|
|
20277
|
-
return target.startsWith(
|
|
22336
|
+
return target.startsWith(os2.homedir()) ? `~${target.slice(os2.homedir().length)}` : target;
|
|
20278
22337
|
}
|
|
20279
22338
|
var MAC_CHROME = ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"];
|
|
20280
22339
|
var LINUX_CHROME = ["google-chrome", "google-chrome-stable", "chromium"];
|
|
@@ -20284,29 +22343,68 @@ var SSH_PROBE_TIMEOUT_MS = 1500;
|
|
|
20284
22343
|
// dist/setup.js
|
|
20285
22344
|
var run2 = promisify2(execFile2);
|
|
20286
22345
|
var setup = {
|
|
22346
|
+
widenPath() {
|
|
22347
|
+
const current = (process.env.PATH ?? "").split(path3.delimiter).filter((entry) => entry !== "");
|
|
22348
|
+
const missing = toolDirs().filter((entry) => !current.includes(entry));
|
|
22349
|
+
if (missing.length > 0)
|
|
22350
|
+
process.env.PATH = [...current, ...missing].join(path3.delimiter);
|
|
22351
|
+
},
|
|
20287
22352
|
async run({ install, rewire: rewire2, say }) {
|
|
20288
22353
|
const found = await probe.tools();
|
|
20289
22354
|
if (!install)
|
|
20290
|
-
return found;
|
|
22355
|
+
return withReasons(found);
|
|
20291
22356
|
const repairs = { ...REPAIRS, ...rewire2 === void 0 ? {} : { brain: { name: "the brain", fix: rewire2 } } };
|
|
20292
|
-
const broken = found.filter((tool) => !tool.ok && repairs[tool.id] !== void 0);
|
|
22357
|
+
const broken = found.filter((tool) => !tool.ok && repairs[tool.id] !== void 0 && isDue(tool.id));
|
|
20293
22358
|
if (broken.length === 0)
|
|
20294
|
-
return found;
|
|
22359
|
+
return withReasons(found);
|
|
20295
22360
|
for (const tool of broken) {
|
|
20296
22361
|
const repair = repairs[tool.id];
|
|
20297
22362
|
if (repair === void 0)
|
|
20298
22363
|
continue;
|
|
20299
22364
|
say?.(`Setting up ${repair.name}`);
|
|
22365
|
+
tried.set(tool.id, Date.now());
|
|
20300
22366
|
const failed = await repair.fix().then(() => null, (error51) => firstLine2(error51.message));
|
|
22367
|
+
if (failed === null)
|
|
22368
|
+
reasons.delete(tool.id);
|
|
22369
|
+
else
|
|
22370
|
+
reasons.set(tool.id, failed);
|
|
20301
22371
|
say?.(failed === null ? ` ${repair.name} is ready` : ` could not set up ${repair.name}: ${failed}`);
|
|
20302
22372
|
}
|
|
20303
|
-
return probe.tools();
|
|
22373
|
+
return withReasons(await probe.tools());
|
|
20304
22374
|
}
|
|
20305
22375
|
};
|
|
22376
|
+
function isDue(id) {
|
|
22377
|
+
const last = tried.get(id);
|
|
22378
|
+
return last === void 0 || Date.now() - last > RETRY_AFTER_MS;
|
|
22379
|
+
}
|
|
22380
|
+
function withReasons(tools2) {
|
|
22381
|
+
return tools2.map((tool) => {
|
|
22382
|
+
const reason = tool.ok ? void 0 : reasons.get(tool.id);
|
|
22383
|
+
return reason === void 0 ? tool : { ...tool, detail: `${tool.detail} \xB7 ${reason}`.slice(0, 200) };
|
|
22384
|
+
});
|
|
22385
|
+
}
|
|
22386
|
+
function toolDirs() {
|
|
22387
|
+
const prefix = process.env.npm_config_prefix;
|
|
22388
|
+
return [
|
|
22389
|
+
path3.dirname(process.execPath),
|
|
22390
|
+
...prefix === void 0 ? [] : [path3.join(prefix, "bin")],
|
|
22391
|
+
path3.join(os3.homedir(), ".local", "bin"),
|
|
22392
|
+
path3.join(os3.homedir(), ".npm-global", "bin"),
|
|
22393
|
+
"/opt/homebrew/bin",
|
|
22394
|
+
"/usr/local/bin"
|
|
22395
|
+
];
|
|
22396
|
+
}
|
|
20306
22397
|
var REPAIRS = {
|
|
20307
22398
|
claude: { name: "Claude Code", fix: () => npmGlobal("@anthropic-ai/claude-code") },
|
|
20308
22399
|
codex: { name: "Codex", fix: () => npmGlobal("@openai/codex") },
|
|
20309
|
-
git: {
|
|
22400
|
+
git: {
|
|
22401
|
+
name: "the GitHub CLI",
|
|
22402
|
+
fix: async () => {
|
|
22403
|
+
if (await firstAvailable(["gh"]) !== null)
|
|
22404
|
+
return;
|
|
22405
|
+
await installPackage({ brew: ["gh"], apt: ["gh"], dnf: ["gh"] });
|
|
22406
|
+
}
|
|
22407
|
+
},
|
|
20310
22408
|
chrome: {
|
|
20311
22409
|
name: "Google Chrome",
|
|
20312
22410
|
fix: () => installPackage({ brew: ["--cask", "google-chrome"], apt: ["chromium"], dnf: ["chromium"] })
|
|
@@ -20337,13 +22435,16 @@ async function firstAvailable(commands) {
|
|
|
20337
22435
|
function firstLine2(message) {
|
|
20338
22436
|
return message.split("\n")[0] ?? "it failed";
|
|
20339
22437
|
}
|
|
22438
|
+
var tried = /* @__PURE__ */ new Map();
|
|
22439
|
+
var reasons = /* @__PURE__ */ new Map();
|
|
20340
22440
|
var INSTALL_TIMEOUT_MS = 18e4;
|
|
22441
|
+
var RETRY_AFTER_MS = 216e5;
|
|
20341
22442
|
|
|
20342
22443
|
// dist/machine.js
|
|
20343
22444
|
var run3 = promisify3(execFile3);
|
|
20344
22445
|
var machine = {
|
|
20345
22446
|
home() {
|
|
20346
|
-
return process.env.CRAFTSPACE_CLI_HOME ??
|
|
22447
|
+
return process.env.CRAFTSPACE_CLI_HOME ?? path4.join(os4.homedir(), ".craftspace");
|
|
20347
22448
|
},
|
|
20348
22449
|
async login({ token, url: url2, install }) {
|
|
20349
22450
|
const answer = await call({
|
|
@@ -20352,11 +22453,11 @@ var machine = {
|
|
|
20352
22453
|
method: "POST",
|
|
20353
22454
|
path: "/api/machines/login",
|
|
20354
22455
|
body: {
|
|
20355
|
-
name:
|
|
22456
|
+
name: os4.hostname().split(".")[0] ?? "machine",
|
|
20356
22457
|
platform: `${process.platform}-${process.arch}`,
|
|
20357
|
-
sshUser:
|
|
20358
|
-
cores:
|
|
20359
|
-
memoryGb: Math.max(1, Math.round(
|
|
22458
|
+
sshUser: os4.userInfo().username,
|
|
22459
|
+
cores: os4.cpus().length,
|
|
22460
|
+
memoryGb: Math.max(1, Math.round(os4.totalmem() / 1024 ** 3)),
|
|
20360
22461
|
cli: CLI_VERSION,
|
|
20361
22462
|
publicKey: await ensureKey()
|
|
20362
22463
|
},
|
|
@@ -20374,15 +22475,37 @@ var machine = {
|
|
|
20374
22475
|
};
|
|
20375
22476
|
return answer.machine;
|
|
20376
22477
|
},
|
|
22478
|
+
async signIn({ url: url2, why, install = false }) {
|
|
22479
|
+
const where = url2 ?? (await readConfig())?.url ?? DEFAULT_URL;
|
|
22480
|
+
if (!process.stdin.isTTY)
|
|
22481
|
+
throw new Error(`${why} Run: craftspace login --token <token>`);
|
|
22482
|
+
const page = `${where}/workstations`;
|
|
22483
|
+
process.stdout.write(`
|
|
22484
|
+
${why}
|
|
22485
|
+
|
|
22486
|
+
`);
|
|
22487
|
+
if (await dist_default4({ message: `Open ${page} for a key?`, default: true })) {
|
|
22488
|
+
await openInBrowser(page);
|
|
22489
|
+
process.stdout.write(' Click "Add a workstation" there, then copy the line it gives you.\n');
|
|
22490
|
+
} else {
|
|
22491
|
+
process.stdout.write(` Get one at ${page} under "Add a workstation".
|
|
22492
|
+
`);
|
|
22493
|
+
}
|
|
22494
|
+
const token = tokenIn(await dist_default5({
|
|
22495
|
+
message: "Paste it here",
|
|
22496
|
+
validate: (line) => tokenIn(line) !== void 0 || "No cst_\u2026 token in that. Paste the whole line if it is easier."
|
|
22497
|
+
}));
|
|
22498
|
+
if (token === void 0)
|
|
22499
|
+
throw new Error("That line carries no key.");
|
|
22500
|
+
const signed = await machine.login({ token, url: where, install });
|
|
22501
|
+
process.stdout.write(`
|
|
22502
|
+
Signed in as ${signed.ownerName}. This machine is ${signed.name}.
|
|
22503
|
+
`);
|
|
22504
|
+
return { url: where, token, machine: signed };
|
|
22505
|
+
},
|
|
20377
22506
|
async status() {
|
|
20378
|
-
const
|
|
20379
|
-
|
|
20380
|
-
return null;
|
|
20381
|
-
const token = await readToken();
|
|
20382
|
-
if (!token)
|
|
20383
|
-
return null;
|
|
20384
|
-
const found = await call({ url: config2.url, token, method: "GET", path: "/api/machines/me", schema: MachineSchema });
|
|
20385
|
-
return { machine: found, url: config2.url };
|
|
22507
|
+
const found = await withAuth(await signedInOrAsk(), (auth) => call({ ...auth, method: "GET", path: "/api/machines/me", schema: MachineSchema }));
|
|
22508
|
+
return { machine: found.value, url: found.auth.url };
|
|
20386
22509
|
},
|
|
20387
22510
|
async beatOnce() {
|
|
20388
22511
|
const { url: url2, token } = await requireSignedIn();
|
|
@@ -20393,11 +22516,11 @@ var machine = {
|
|
|
20393
22516
|
path: "/api/machines/beat",
|
|
20394
22517
|
body: {
|
|
20395
22518
|
cli: CLI_VERSION,
|
|
20396
|
-
...
|
|
22519
|
+
...load2(),
|
|
20397
22520
|
sessions: await readSessions(),
|
|
20398
22521
|
runs: drainReports(),
|
|
20399
22522
|
tools: await tools(),
|
|
20400
|
-
sshUser:
|
|
22523
|
+
sshUser: os4.userInfo().username
|
|
20401
22524
|
},
|
|
20402
22525
|
schema: MachineBeatResponseSchema
|
|
20403
22526
|
});
|
|
@@ -20458,8 +22581,9 @@ async function runHere(argv) {
|
|
|
20458
22581
|
}
|
|
20459
22582
|
}
|
|
20460
22583
|
async function runThere({ argv, on }) {
|
|
20461
|
-
const
|
|
20462
|
-
const target = await machineNamed({
|
|
22584
|
+
const first = await signedInOrAsk();
|
|
22585
|
+
const { auth, value: target } = await withAuth(first, (live) => machineNamed({ ...live, name: on }));
|
|
22586
|
+
const { url: url2, token } = auth;
|
|
20463
22587
|
let run4 = await call({
|
|
20464
22588
|
url: url2,
|
|
20465
22589
|
token,
|
|
@@ -20519,10 +22643,24 @@ async function readRun({ url: url2, token, machineId, runId }) {
|
|
|
20519
22643
|
async function machineNamed({ url: url2, token, name }) {
|
|
20520
22644
|
const answer = await call({ url: url2, token, method: "GET", path: "/api/machines", schema: MachinesResponseSchema });
|
|
20521
22645
|
const found = answer.machines.find((candidate) => candidate.name === name || candidate.id === name);
|
|
20522
|
-
if (found
|
|
22646
|
+
if (found !== void 0)
|
|
22647
|
+
return found;
|
|
22648
|
+
if (answer.machines.length === 0)
|
|
22649
|
+
throw new Error("This team has no workstations yet. Add one at /workstations.");
|
|
22650
|
+
if (!process.stdin.isTTY) {
|
|
20523
22651
|
throw new Error(`No workstation called ${name}. This team has: ${answer.machines.map((m) => m.name).join(", ")}`);
|
|
20524
22652
|
}
|
|
20525
|
-
|
|
22653
|
+
process.stdout.write(`
|
|
22654
|
+
No workstation called ${name}.
|
|
22655
|
+
|
|
22656
|
+
`);
|
|
22657
|
+
return dist_default6({
|
|
22658
|
+
message: "Run it on",
|
|
22659
|
+
choices: answer.machines.map((candidate) => ({
|
|
22660
|
+
name: `${candidate.name.padEnd(20)} ${candidate.state}`,
|
|
22661
|
+
value: candidate
|
|
22662
|
+
}))
|
|
22663
|
+
});
|
|
20526
22664
|
}
|
|
20527
22665
|
function readStdinLine() {
|
|
20528
22666
|
return new Promise((resolve) => {
|
|
@@ -20577,18 +22715,53 @@ async function call({ url: url2, token, method, path: route, body, schema }) {
|
|
|
20577
22715
|
...body === void 0 ? {} : { body: JSON.stringify(body) },
|
|
20578
22716
|
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
20579
22717
|
});
|
|
22718
|
+
if (response.status === 401)
|
|
22719
|
+
throw new Unauthorized();
|
|
20580
22720
|
if (!response.ok)
|
|
20581
22721
|
throw new Error(`${route} answered ${response.status}`);
|
|
20582
22722
|
return schema.parse(await response.json());
|
|
20583
22723
|
}
|
|
22724
|
+
var Unauthorized = class extends Error {
|
|
22725
|
+
constructor() {
|
|
22726
|
+
super("This machine no longer has a key Craftspace accepts.");
|
|
22727
|
+
}
|
|
22728
|
+
};
|
|
22729
|
+
async function signedInOrAsk() {
|
|
22730
|
+
const config2 = await readConfig();
|
|
22731
|
+
const token = await readToken();
|
|
22732
|
+
if (config2 && token)
|
|
22733
|
+
return { url: config2.url, token };
|
|
22734
|
+
return machine.signIn({ why: "This machine is not signed in to Craftspace yet." });
|
|
22735
|
+
}
|
|
22736
|
+
async function withAuth(auth, work) {
|
|
22737
|
+
try {
|
|
22738
|
+
return { auth, value: await work(auth) };
|
|
22739
|
+
} catch (error51) {
|
|
22740
|
+
if (!(error51 instanceof Unauthorized))
|
|
22741
|
+
throw error51;
|
|
22742
|
+
const next = await machine.signIn({
|
|
22743
|
+
url: auth.url,
|
|
22744
|
+
why: "Craftspace does not know this machine any more. Its key was revoked, which is what forgetting the workstation, or signing the same box in somewhere else, does."
|
|
22745
|
+
});
|
|
22746
|
+
process.stdout.write("\nPicking up where you left off.\n\n");
|
|
22747
|
+
return { auth: next, value: await work(next) };
|
|
22748
|
+
}
|
|
22749
|
+
}
|
|
22750
|
+
async function openInBrowser(url2) {
|
|
22751
|
+
const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
22752
|
+
await run3(opener, [url2]).catch(() => void 0);
|
|
22753
|
+
}
|
|
22754
|
+
function tokenIn(line) {
|
|
22755
|
+
return /cst_[A-Za-z0-9_-]+/.exec(line)?.[0];
|
|
22756
|
+
}
|
|
20584
22757
|
async function ensureKey() {
|
|
20585
|
-
const priv =
|
|
22758
|
+
const priv = path4.join(machine.home(), "id_ed25519");
|
|
20586
22759
|
const pub = `${priv}.pub`;
|
|
20587
22760
|
const existing = await readFile2(pub, "utf8").catch(() => null);
|
|
20588
22761
|
if (existing !== null)
|
|
20589
22762
|
return existing.trim();
|
|
20590
22763
|
await mkdir(machine.home(), { recursive: true, mode: 448 });
|
|
20591
|
-
await run3("ssh-keygen", ["-t", "ed25519", "-N", "", "-q", "-f", priv, "-C", `craftspace-${
|
|
22764
|
+
await run3("ssh-keygen", ["-t", "ed25519", "-N", "", "-q", "-f", priv, "-C", `craftspace-${os4.hostname()}`]);
|
|
20592
22765
|
return (await readFile2(pub, "utf8")).trim();
|
|
20593
22766
|
}
|
|
20594
22767
|
async function readConfig() {
|
|
@@ -20602,11 +22775,11 @@ async function readToken() {
|
|
|
20602
22775
|
return raw === null ? null : raw.trim();
|
|
20603
22776
|
}
|
|
20604
22777
|
async function readSessions() {
|
|
20605
|
-
const dir =
|
|
22778
|
+
const dir = path4.join(machine.home(), "sessions");
|
|
20606
22779
|
const names = await readdir(dir).catch(() => []);
|
|
20607
22780
|
const sessions = [];
|
|
20608
22781
|
for (const name of names.filter((entry) => entry.endsWith(".json"))) {
|
|
20609
|
-
const raw = await readFile2(
|
|
22782
|
+
const raw = await readFile2(path4.join(dir, name), "utf8").catch(() => null);
|
|
20610
22783
|
if (raw === null)
|
|
20611
22784
|
continue;
|
|
20612
22785
|
const parsed = MachineSessionSchema.safeParse(JSON.parse(raw));
|
|
@@ -20616,7 +22789,7 @@ async function readSessions() {
|
|
|
20616
22789
|
return sessions.slice(0, MAX_REPORTED_SESSIONS);
|
|
20617
22790
|
}
|
|
20618
22791
|
async function writeAuthorizedKeys(keys) {
|
|
20619
|
-
const target =
|
|
22792
|
+
const target = path4.join(os4.homedir(), ".ssh", "authorized_keys");
|
|
20620
22793
|
const current = await readFile2(target, "utf8").catch(() => "");
|
|
20621
22794
|
const before = current.split(KEYS_BEGIN)[0] ?? "";
|
|
20622
22795
|
const after = current.includes(KEYS_END) ? current.split(KEYS_END)[1] ?? "" : "";
|
|
@@ -20627,26 +22800,26 @@ ${KEYS_END}
|
|
|
20627
22800
|
const next = `${trimEnd(before)}${trimEnd(before) === "" ? "" : "\n"}${block}${after.replace(/^\n/, "")}`;
|
|
20628
22801
|
if (next === current)
|
|
20629
22802
|
return;
|
|
20630
|
-
await mkdir(
|
|
22803
|
+
await mkdir(path4.dirname(target), { recursive: true, mode: 448 });
|
|
20631
22804
|
await writeFile(target, next, { mode: 384 });
|
|
20632
22805
|
}
|
|
20633
22806
|
function trimEnd(text) {
|
|
20634
22807
|
return text.replace(/\s+$/, "");
|
|
20635
22808
|
}
|
|
20636
22809
|
async function writeSession(session) {
|
|
20637
|
-
const dir =
|
|
22810
|
+
const dir = path4.join(machine.home(), "sessions");
|
|
20638
22811
|
await mkdir(dir, { recursive: true, mode: 448 });
|
|
20639
|
-
await writeFile(
|
|
22812
|
+
await writeFile(path4.join(dir, `${session.id}.json`), JSON.stringify(session), { mode: 384 });
|
|
20640
22813
|
}
|
|
20641
22814
|
async function clearSession(id) {
|
|
20642
|
-
await rm(
|
|
22815
|
+
await rm(path4.join(machine.home(), "sessions", `${id}.json`), { force: true });
|
|
20643
22816
|
}
|
|
20644
22817
|
async function writeAgentConfigs({ url: url2, token, writes }) {
|
|
20645
22818
|
const planned = writes.length > 0 ? writes : defaultWrites({ url: url2, token });
|
|
20646
22819
|
const owned = [];
|
|
20647
22820
|
for (const write of planned) {
|
|
20648
22821
|
const target = expand(write.path);
|
|
20649
|
-
await mkdir(
|
|
22822
|
+
await mkdir(path4.dirname(target), { recursive: true });
|
|
20650
22823
|
const current = await readFile2(target, "utf8").catch(() => null);
|
|
20651
22824
|
if (current !== null)
|
|
20652
22825
|
await writeFile(`${target}.craftspace-backup`, current, { flag: "wx" }).catch(() => void 0);
|
|
@@ -20656,16 +22829,41 @@ async function writeAgentConfigs({ url: url2, token, writes }) {
|
|
|
20656
22829
|
owned.push(target);
|
|
20657
22830
|
}
|
|
20658
22831
|
await writeFile(ownedPath(), JSON.stringify({ paths: owned }, null, 2));
|
|
22832
|
+
await acceptClaudeGates(serversIn(planned));
|
|
22833
|
+
}
|
|
22834
|
+
function serversIn(writes) {
|
|
22835
|
+
return writes.flatMap((write) => isPlainObject3(write.contents.mcpServers) ? Object.keys(write.contents.mcpServers) : []);
|
|
22836
|
+
}
|
|
22837
|
+
async function acceptClaudeGates(servers) {
|
|
22838
|
+
const target = path4.join(os4.homedir(), ".claude.json");
|
|
22839
|
+
const raw = await readFile2(target, "utf8").catch(() => null);
|
|
22840
|
+
if (raw === null)
|
|
22841
|
+
return;
|
|
22842
|
+
const parsed = JSON.parse(raw);
|
|
22843
|
+
const projects = isPlainObject3(parsed.projects) ? parsed.projects : {};
|
|
22844
|
+
const found = projects[os4.homedir()];
|
|
22845
|
+
const here = isPlainObject3(found) ? { ...found } : {};
|
|
22846
|
+
const enabled = /* @__PURE__ */ new Set([...Array.isArray(here.enabledMcpjsonServers) ? here.enabledMcpjsonServers : [], ...servers]);
|
|
22847
|
+
if (here.hasTrustDialogAccepted === true && enabled.size === asArray(here.enabledMcpjsonServers).length)
|
|
22848
|
+
return;
|
|
22849
|
+
here.hasTrustDialogAccepted = true;
|
|
22850
|
+
here.enabledMcpjsonServers = [...enabled];
|
|
22851
|
+
const next = { ...parsed, projects: { ...projects, [os4.homedir()]: here } };
|
|
22852
|
+
await writeFile(target, `${JSON.stringify(next, null, 2)}
|
|
22853
|
+
`, { mode: 384 });
|
|
22854
|
+
}
|
|
22855
|
+
function asArray(value) {
|
|
22856
|
+
return Array.isArray(value) ? value : [];
|
|
20659
22857
|
}
|
|
20660
22858
|
function mergeInto(current, incoming) {
|
|
20661
22859
|
const merged = { ...current };
|
|
20662
22860
|
for (const [key, value] of Object.entries(incoming)) {
|
|
20663
22861
|
const existing = merged[key];
|
|
20664
|
-
merged[key] =
|
|
22862
|
+
merged[key] = isPlainObject3(existing) && isPlainObject3(value) ? mergeInto(existing, value) : value;
|
|
20665
22863
|
}
|
|
20666
22864
|
return merged;
|
|
20667
22865
|
}
|
|
20668
|
-
function
|
|
22866
|
+
function isPlainObject3(value) {
|
|
20669
22867
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20670
22868
|
}
|
|
20671
22869
|
function defaultWrites({ url: url2, token }) {
|
|
@@ -20683,7 +22881,7 @@ async function removeAgentConfigs() {
|
|
|
20683
22881
|
continue;
|
|
20684
22882
|
const parsed = JSON.parse(current);
|
|
20685
22883
|
const servers = parsed.mcpServers;
|
|
20686
|
-
if (
|
|
22884
|
+
if (isPlainObject3(servers))
|
|
20687
22885
|
delete servers.craftspace;
|
|
20688
22886
|
if (await weCreated(target)) {
|
|
20689
22887
|
await rm(target, { force: true });
|
|
@@ -20703,16 +22901,16 @@ async function installService() {
|
|
|
20703
22901
|
return;
|
|
20704
22902
|
}
|
|
20705
22903
|
if (process.platform === "linux") {
|
|
20706
|
-
const dir =
|
|
22904
|
+
const dir = path4.join(os4.homedir(), ".config", "systemd", "user");
|
|
20707
22905
|
await mkdir(dir, { recursive: true });
|
|
20708
|
-
await writeFile(
|
|
22906
|
+
await writeFile(path4.join(dir, `${SERVICE_NAME}.service`), systemdUnit());
|
|
20709
22907
|
await run3("systemctl", ["--user", "daemon-reload"]).catch(() => void 0);
|
|
20710
22908
|
await run3("systemctl", ["--user", "enable", "--now", SERVICE_NAME]).catch(() => void 0);
|
|
20711
22909
|
return;
|
|
20712
22910
|
}
|
|
20713
22911
|
if (process.platform === "darwin") {
|
|
20714
|
-
const target =
|
|
20715
|
-
await mkdir(
|
|
22912
|
+
const target = path4.join(os4.homedir(), "Library", "LaunchAgents", `${LAUNCH_LABEL}.plist`);
|
|
22913
|
+
await mkdir(path4.dirname(target), { recursive: true });
|
|
20716
22914
|
await writeFile(target, launchdPlist());
|
|
20717
22915
|
await run3("launchctl", ["unload", target]).catch(() => void 0);
|
|
20718
22916
|
await run3("launchctl", ["load", target]).catch(() => void 0);
|
|
@@ -20721,11 +22919,11 @@ async function installService() {
|
|
|
20721
22919
|
async function uninstallService() {
|
|
20722
22920
|
if (process.platform === "linux") {
|
|
20723
22921
|
await run3("systemctl", ["--user", "disable", "--now", SERVICE_NAME]).catch(() => void 0);
|
|
20724
|
-
await rm(
|
|
22922
|
+
await rm(path4.join(os4.homedir(), ".config", "systemd", "user", `${SERVICE_NAME}.service`), { force: true });
|
|
20725
22923
|
return;
|
|
20726
22924
|
}
|
|
20727
22925
|
if (process.platform === "darwin") {
|
|
20728
|
-
const target =
|
|
22926
|
+
const target = path4.join(os4.homedir(), "Library", "LaunchAgents", `${LAUNCH_LABEL}.plist`);
|
|
20729
22927
|
await run3("launchctl", ["unload", target]).catch(() => void 0);
|
|
20730
22928
|
await rm(target, { force: true });
|
|
20731
22929
|
}
|
|
@@ -20760,24 +22958,24 @@ function launchdPlist() {
|
|
|
20760
22958
|
`;
|
|
20761
22959
|
}
|
|
20762
22960
|
function entryPath() {
|
|
20763
|
-
return
|
|
22961
|
+
return path4.join(path4.dirname(new URL(import.meta.url).pathname), "index.js");
|
|
20764
22962
|
}
|
|
20765
22963
|
function expand(target) {
|
|
20766
|
-
return target.startsWith("~/") ?
|
|
22964
|
+
return target.startsWith("~/") ? path4.join(os4.homedir(), target.slice(2)) : target;
|
|
20767
22965
|
}
|
|
20768
22966
|
function configPath() {
|
|
20769
|
-
return
|
|
22967
|
+
return path4.join(machine.home(), "config.json");
|
|
20770
22968
|
}
|
|
20771
22969
|
function tokenPath() {
|
|
20772
|
-
return
|
|
22970
|
+
return path4.join(machine.home(), "token");
|
|
20773
22971
|
}
|
|
20774
22972
|
function ownedPath() {
|
|
20775
|
-
return
|
|
22973
|
+
return path4.join(machine.home(), "owned.json");
|
|
20776
22974
|
}
|
|
20777
|
-
function
|
|
20778
|
-
const cores = Math.max(1,
|
|
20779
|
-
const busy = Math.min(100, (
|
|
20780
|
-
const used = (
|
|
22975
|
+
function load2() {
|
|
22976
|
+
const cores = Math.max(1, os4.cpus().length);
|
|
22977
|
+
const busy = Math.min(100, (os4.loadavg()[0] ?? 0) / cores * 100);
|
|
22978
|
+
const used = (os4.totalmem() - os4.freemem()) / os4.totalmem() * 100;
|
|
20781
22979
|
return { cpuPercent: Math.round(busy), memoryPercent: Math.round(used) };
|
|
20782
22980
|
}
|
|
20783
22981
|
function nextDelayMs(failures, busy = false) {
|
|
@@ -20801,16 +22999,19 @@ var MAX_BACKOFF_MS = 12e4;
|
|
|
20801
22999
|
var KEYS_BEGIN = "# craftspace begin";
|
|
20802
23000
|
var KEYS_END = "# craftspace end";
|
|
20803
23001
|
var POLL_INTERVAL_MS = 1e3;
|
|
23002
|
+
var DEFAULT_URL = process.env.CRAFTSPACE_URL ?? "https://craftspace.app";
|
|
20804
23003
|
var PROBE_EVERY_MS = 3e5;
|
|
20805
23004
|
var probed = null;
|
|
20806
23005
|
var reports = /* @__PURE__ */ new Map();
|
|
20807
23006
|
var running = /* @__PURE__ */ new Set();
|
|
20808
23007
|
|
|
20809
23008
|
// dist/index.js
|
|
23009
|
+
setup.widenPath();
|
|
20810
23010
|
var program2 = new Command();
|
|
20811
23011
|
program2.enablePositionalOptions().name("craftspace").description("Sign this machine in to your team, so every agent on it reads the same brain.").version(CLI_VERSION).showHelpAfterError();
|
|
20812
|
-
program2.command("login").description("sign this machine in").
|
|
20813
|
-
const
|
|
23012
|
+
program2.command("login").description("sign this machine in").option("--token <token>", "the login token from your team", process.env.CRAFTSPACE_TOKEN).option("--url <url>", "your control plane", process.env.CRAFTSPACE_URL ?? "https://craftspace.app").option("--no-install", "do not install anything this machine is missing").action(async ({ token, url: url2, install }) => {
|
|
23013
|
+
const where = url2.replace(/\/$/, "");
|
|
23014
|
+
const signed = token === void 0 ? (await machine.signIn({ url: where, why: "Signing this machine in.", install })).machine : await machine.login({ token, url: where, install });
|
|
20814
23015
|
process.stdout.write([
|
|
20815
23016
|
`Signed in as ${signed.ownerName}`,
|
|
20816
23017
|
`Machine ${signed.name} \xB7 ${signed.platform} \xB7 ${signed.cores ?? "?"} vCPU`,
|
|
@@ -20825,13 +23026,7 @@ program2.command("run").description("run a command here, or on another workstati
|
|
|
20825
23026
|
process.exitCode = await machine.run({ argv: command, ...on === void 0 ? {} : { on } });
|
|
20826
23027
|
});
|
|
20827
23028
|
program2.command("status").description("what this machine is and what it is doing").action(async () => {
|
|
20828
|
-
const
|
|
20829
|
-
if (!current) {
|
|
20830
|
-
process.stdout.write("Not signed in. Run: craftspace login --token <token>\n");
|
|
20831
|
-
process.exitCode = 1;
|
|
20832
|
-
return;
|
|
20833
|
-
}
|
|
20834
|
-
const { machine: found } = current;
|
|
23029
|
+
const { machine: found } = await machine.status();
|
|
20835
23030
|
const since = found.lastBeatAt === null ? "never" : `${secondsSince(found.lastBeatAt)}s ago`;
|
|
20836
23031
|
process.stdout.write([
|
|
20837
23032
|
`${found.name} ${found.state} cli ${found.cli} beat ${since}`,
|