@mnmal-ai/substrate 0.0.0 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +118 -1
- package/dist/agent-token-BIboWOU0.js +200 -0
- package/dist/client.d.ts +782 -0
- package/dist/client.js +7 -0
- package/dist/cluster-worker.js +35 -0
- package/dist/content-type-C7T28xNb.js +25 -0
- package/dist/dataset-BXkus75W.js +1527 -0
- package/dist/env-utils-B7SGmoeJ.js +21 -0
- package/dist/errors-D4vKuwz8.d.ts +130 -0
- package/dist/fake-DUVtKVSE.js +36 -0
- package/dist/index-D7mSOFlM.d.ts +69 -0
- package/dist/pack.d.ts +192 -0
- package/dist/pack.js +5 -0
- package/dist/plugin-j1jt1l3n.js +3844 -0
- package/dist/plugin-t2g2wX0b.d.ts +1568 -0
- package/dist/proposals-bootstrap.js +37 -0
- package/dist/proposals.config.schema.json +20 -0
- package/dist/proposals.d.ts +118 -0
- package/dist/proposals.default-config.json +4 -0
- package/dist/proposals.js +4 -0
- package/dist/recall-bootstrap.js +451 -0
- package/dist/recall.config.schema.json +232 -0
- package/dist/recall.d.ts +1981 -0
- package/dist/recall.default-config.json +4 -0
- package/dist/recall.js +5 -0
- package/dist/repl-C52wyfMs.js +2213 -0
- package/dist/row-ByLFE2Wx.d.ts +719 -0
- package/dist/row-DK7lPZVe.js +732 -0
- package/dist/runtime-metrics-DwpDJ8vz.d.ts +159 -0
- package/dist/schema-g4FQLr0V.d.ts +433 -0
- package/dist/sdk.d.ts +694 -0
- package/dist/sdk.js +112 -0
- package/dist/src-C4DzaIQZ.js +837 -0
- package/dist/src-CrEgiMJQ.js +1015 -0
- package/dist/src-CzxvmhFn.js +2327 -0
- package/dist/src-D88LvCX8.js +1797 -0
- package/dist/src-D91yij6C.js +13523 -0
- package/dist/src-DuopV8u7.js +2408 -0
- package/dist/substrate-admin.js +808 -0
- package/dist/substrate.js +5477 -0
- package/dist/testing.d.ts +1240 -0
- package/dist/testing.js +702 -0
- package/dist/types-8c0gtnd2.d.ts +35 -0
- package/dist/ws-C72iVS5T.d.ts +143 -0
- package/package.json +117 -4
|
@@ -0,0 +1,2213 @@
|
|
|
1
|
+
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
+
import { n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./substrate.js";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { stripVTControlCharacters, styleText } from "node:util";
|
|
6
|
+
import * as readline from "node:readline";
|
|
7
|
+
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
8
|
+
import process$1 from "node:process";
|
|
9
|
+
|
|
10
|
+
//#region \0rolldown/runtime.js
|
|
11
|
+
var __create = Object.create;
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
|
+
key = keys[i];
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
23
|
+
__defProp(to, key, {
|
|
24
|
+
get: ((k) => from[k]).bind(null, key),
|
|
25
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
33
|
+
value: mod,
|
|
34
|
+
enumerable: true
|
|
35
|
+
}) : target, mod));
|
|
36
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/key.js
|
|
40
|
+
const keybindingLookup = /* @__PURE__ */ new Set(["emacs", "vim"]);
|
|
41
|
+
function isKeybinding(value) {
|
|
42
|
+
return keybindingLookup.has(value);
|
|
43
|
+
}
|
|
44
|
+
function getDefaultKeybindings() {
|
|
45
|
+
const env = process.env["INQUIRER_KEYBINDINGS"];
|
|
46
|
+
if (!env) return [];
|
|
47
|
+
return Array.from(new Set(env.toLowerCase().split(/[\s,]+/).filter(isKeybinding)));
|
|
48
|
+
}
|
|
49
|
+
const isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
50
|
+
const isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
51
|
+
const isSpaceKey = (key) => key.name === "space";
|
|
52
|
+
const isBackspaceKey = (key) => key.name === "backspace";
|
|
53
|
+
const isTabKey = (key) => key.name === "tab";
|
|
54
|
+
const isNumberKey = (key) => "1234567890".includes(key.name);
|
|
55
|
+
const isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/errors.js
|
|
59
|
+
var AbortPromptError = class extends Error {
|
|
60
|
+
name = "AbortPromptError";
|
|
61
|
+
message = "Prompt was aborted";
|
|
62
|
+
constructor(options) {
|
|
63
|
+
super();
|
|
64
|
+
this.cause = options?.cause;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var CancelPromptError = class extends Error {
|
|
68
|
+
name = "CancelPromptError";
|
|
69
|
+
message = "Prompt was canceled";
|
|
70
|
+
};
|
|
71
|
+
var ExitPromptError = class extends Error {
|
|
72
|
+
name = "ExitPromptError";
|
|
73
|
+
};
|
|
74
|
+
var HookError = class extends Error {
|
|
75
|
+
name = "HookError";
|
|
76
|
+
};
|
|
77
|
+
var ValidationError = class extends Error {
|
|
78
|
+
name = "ValidationError";
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
83
|
+
const hookStorage = new AsyncLocalStorage();
|
|
84
|
+
function createStore(rl) {
|
|
85
|
+
return {
|
|
86
|
+
rl,
|
|
87
|
+
hooks: [],
|
|
88
|
+
hooksCleanup: [],
|
|
89
|
+
hooksEffect: [],
|
|
90
|
+
index: 0,
|
|
91
|
+
handleChange() {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function withHooks(rl, cb) {
|
|
95
|
+
const store = createStore(rl);
|
|
96
|
+
function cycle(render) {
|
|
97
|
+
store.handleChange = () => {
|
|
98
|
+
store.index = 0;
|
|
99
|
+
render();
|
|
100
|
+
};
|
|
101
|
+
store.handleChange();
|
|
102
|
+
}
|
|
103
|
+
return hookStorage.run(store, () => cb(cycle));
|
|
104
|
+
}
|
|
105
|
+
function getStore() {
|
|
106
|
+
const store = hookStorage.getStore();
|
|
107
|
+
if (!store) throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
|
|
108
|
+
return store;
|
|
109
|
+
}
|
|
110
|
+
function readline$1() {
|
|
111
|
+
return getStore().rl;
|
|
112
|
+
}
|
|
113
|
+
function withUpdates(fn) {
|
|
114
|
+
const wrapped = (...args) => {
|
|
115
|
+
const store = getStore();
|
|
116
|
+
let shouldUpdate = false;
|
|
117
|
+
const oldHandleChange = store.handleChange;
|
|
118
|
+
store.handleChange = () => {
|
|
119
|
+
shouldUpdate = true;
|
|
120
|
+
};
|
|
121
|
+
const returnValue = fn(...args);
|
|
122
|
+
if (shouldUpdate) oldHandleChange();
|
|
123
|
+
store.handleChange = oldHandleChange;
|
|
124
|
+
return returnValue;
|
|
125
|
+
};
|
|
126
|
+
return AsyncResource.bind(wrapped);
|
|
127
|
+
}
|
|
128
|
+
function withPointer(cb) {
|
|
129
|
+
const store = getStore();
|
|
130
|
+
const { index } = store;
|
|
131
|
+
const returnValue = cb({
|
|
132
|
+
get() {
|
|
133
|
+
return store.hooks[index];
|
|
134
|
+
},
|
|
135
|
+
set(value) {
|
|
136
|
+
store.hooks[index] = value;
|
|
137
|
+
},
|
|
138
|
+
initialized: index in store.hooks
|
|
139
|
+
});
|
|
140
|
+
store.index++;
|
|
141
|
+
return returnValue;
|
|
142
|
+
}
|
|
143
|
+
function handleChange() {
|
|
144
|
+
getStore().handleChange();
|
|
145
|
+
}
|
|
146
|
+
const effectScheduler = {
|
|
147
|
+
queue(cb) {
|
|
148
|
+
const store = getStore();
|
|
149
|
+
const { index } = store;
|
|
150
|
+
store.hooksEffect.push(() => {
|
|
151
|
+
store.hooksCleanup[index]?.();
|
|
152
|
+
const cleanFn = cb(readline$1());
|
|
153
|
+
if (cleanFn != null && typeof cleanFn !== "function") throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
|
|
154
|
+
store.hooksCleanup[index] = cleanFn;
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
run() {
|
|
158
|
+
const store = getStore();
|
|
159
|
+
withUpdates(() => {
|
|
160
|
+
store.hooksEffect.forEach((effect) => {
|
|
161
|
+
effect();
|
|
162
|
+
});
|
|
163
|
+
store.hooksEffect.length = 0;
|
|
164
|
+
})();
|
|
165
|
+
},
|
|
166
|
+
clearAll() {
|
|
167
|
+
const store = getStore();
|
|
168
|
+
store.hooksCleanup.forEach((cleanFn) => {
|
|
169
|
+
cleanFn?.();
|
|
170
|
+
});
|
|
171
|
+
store.hooksEffect.length = 0;
|
|
172
|
+
store.hooksCleanup.length = 0;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
178
|
+
function isFactory(value) {
|
|
179
|
+
return typeof value === "function";
|
|
180
|
+
}
|
|
181
|
+
function isReducer(value) {
|
|
182
|
+
return typeof value === "function";
|
|
183
|
+
}
|
|
184
|
+
function useState(defaultValue) {
|
|
185
|
+
return withPointer((pointer) => {
|
|
186
|
+
const setState = AsyncResource.bind(function setState(newValue) {
|
|
187
|
+
const currentValue = pointer.get();
|
|
188
|
+
const nextValue = isReducer(newValue) ? newValue(currentValue) : newValue;
|
|
189
|
+
if (!Object.is(currentValue, nextValue)) {
|
|
190
|
+
pointer.set(nextValue);
|
|
191
|
+
handleChange();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
if (pointer.initialized) return [pointer.get(), setState];
|
|
195
|
+
const value = isFactory(defaultValue) ? defaultValue() : defaultValue;
|
|
196
|
+
pointer.set(value);
|
|
197
|
+
return [value, setState];
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
203
|
+
function useEffect(cb, depArray) {
|
|
204
|
+
withPointer((pointer) => {
|
|
205
|
+
const oldDeps = pointer.get();
|
|
206
|
+
if (!Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]))) effectScheduler.queue(cb);
|
|
207
|
+
pointer.set(depArray);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../../node_modules/.pnpm/@inquirer+figures@2.0.9/node_modules/@inquirer/figures/dist/index.js
|
|
213
|
+
function isUnicodeSupported() {
|
|
214
|
+
if (!process$1.platform.startsWith("win")) return process$1.env["TERM"] !== "linux";
|
|
215
|
+
return Boolean(process$1.env["CI"]) || Boolean(process$1.env["WT_SESSION"]) || Boolean(process$1.env["TERMINUS_SUBLIME"]) || process$1.env["ConEmuTask"] === "{cmd::Cmder}" || process$1.env["TERM_PROGRAM"] === "Terminus-Sublime" || process$1.env["TERM_PROGRAM"] === "vscode" || process$1.env["TERM"] === "xterm-256color" || process$1.env["TERM"] === "alacritty" || process$1.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
|
|
216
|
+
}
|
|
217
|
+
const common = {
|
|
218
|
+
circleQuestionMark: "(?)",
|
|
219
|
+
questionMarkPrefix: "(?)",
|
|
220
|
+
square: "█",
|
|
221
|
+
squareDarkShade: "▓",
|
|
222
|
+
squareMediumShade: "▒",
|
|
223
|
+
squareLightShade: "░",
|
|
224
|
+
squareTop: "▀",
|
|
225
|
+
squareBottom: "▄",
|
|
226
|
+
squareLeft: "▌",
|
|
227
|
+
squareRight: "▐",
|
|
228
|
+
squareCenter: "■",
|
|
229
|
+
bullet: "●",
|
|
230
|
+
dot: "․",
|
|
231
|
+
ellipsis: "…",
|
|
232
|
+
pointerSmall: "›",
|
|
233
|
+
triangleUp: "▲",
|
|
234
|
+
triangleUpSmall: "▴",
|
|
235
|
+
triangleDown: "▼",
|
|
236
|
+
triangleDownSmall: "▾",
|
|
237
|
+
triangleLeftSmall: "◂",
|
|
238
|
+
triangleRightSmall: "▸",
|
|
239
|
+
home: "⌂",
|
|
240
|
+
heart: "♥",
|
|
241
|
+
musicNote: "♪",
|
|
242
|
+
musicNoteBeamed: "♫",
|
|
243
|
+
arrowUp: "↑",
|
|
244
|
+
arrowDown: "↓",
|
|
245
|
+
arrowLeft: "←",
|
|
246
|
+
arrowRight: "→",
|
|
247
|
+
arrowLeftRight: "↔",
|
|
248
|
+
arrowUpDown: "↕",
|
|
249
|
+
almostEqual: "≈",
|
|
250
|
+
notEqual: "≠",
|
|
251
|
+
lessOrEqual: "≤",
|
|
252
|
+
greaterOrEqual: "≥",
|
|
253
|
+
identical: "≡",
|
|
254
|
+
infinity: "∞",
|
|
255
|
+
subscriptZero: "₀",
|
|
256
|
+
subscriptOne: "₁",
|
|
257
|
+
subscriptTwo: "₂",
|
|
258
|
+
subscriptThree: "₃",
|
|
259
|
+
subscriptFour: "₄",
|
|
260
|
+
subscriptFive: "₅",
|
|
261
|
+
subscriptSix: "₆",
|
|
262
|
+
subscriptSeven: "₇",
|
|
263
|
+
subscriptEight: "₈",
|
|
264
|
+
subscriptNine: "₉",
|
|
265
|
+
oneHalf: "½",
|
|
266
|
+
oneThird: "⅓",
|
|
267
|
+
oneQuarter: "¼",
|
|
268
|
+
oneFifth: "⅕",
|
|
269
|
+
oneSixth: "⅙",
|
|
270
|
+
oneEighth: "⅛",
|
|
271
|
+
twoThirds: "⅔",
|
|
272
|
+
twoFifths: "⅖",
|
|
273
|
+
threeQuarters: "¾",
|
|
274
|
+
threeFifths: "⅗",
|
|
275
|
+
threeEighths: "⅜",
|
|
276
|
+
fourFifths: "⅘",
|
|
277
|
+
fiveSixths: "⅚",
|
|
278
|
+
fiveEighths: "⅝",
|
|
279
|
+
sevenEighths: "⅞",
|
|
280
|
+
line: "─",
|
|
281
|
+
lineBold: "━",
|
|
282
|
+
lineDouble: "═",
|
|
283
|
+
lineDashed0: "┄",
|
|
284
|
+
lineDashed1: "┅",
|
|
285
|
+
lineDashed2: "┈",
|
|
286
|
+
lineDashed3: "┉",
|
|
287
|
+
lineDashed4: "╌",
|
|
288
|
+
lineDashed5: "╍",
|
|
289
|
+
lineDashed6: "╴",
|
|
290
|
+
lineDashed7: "╶",
|
|
291
|
+
lineDashed8: "╸",
|
|
292
|
+
lineDashed9: "╺",
|
|
293
|
+
lineDashed10: "╼",
|
|
294
|
+
lineDashed11: "╾",
|
|
295
|
+
lineDashed12: "−",
|
|
296
|
+
lineDashed13: "–",
|
|
297
|
+
lineDashed14: "‐",
|
|
298
|
+
lineDashed15: "⁃",
|
|
299
|
+
lineVertical: "│",
|
|
300
|
+
lineVerticalBold: "┃",
|
|
301
|
+
lineVerticalDouble: "║",
|
|
302
|
+
lineVerticalDashed0: "┆",
|
|
303
|
+
lineVerticalDashed1: "┇",
|
|
304
|
+
lineVerticalDashed2: "┊",
|
|
305
|
+
lineVerticalDashed3: "┋",
|
|
306
|
+
lineVerticalDashed4: "╎",
|
|
307
|
+
lineVerticalDashed5: "╏",
|
|
308
|
+
lineVerticalDashed6: "╵",
|
|
309
|
+
lineVerticalDashed7: "╷",
|
|
310
|
+
lineVerticalDashed8: "╹",
|
|
311
|
+
lineVerticalDashed9: "╻",
|
|
312
|
+
lineVerticalDashed10: "╽",
|
|
313
|
+
lineVerticalDashed11: "╿",
|
|
314
|
+
lineDownLeft: "┐",
|
|
315
|
+
lineDownLeftArc: "╮",
|
|
316
|
+
lineDownBoldLeftBold: "┓",
|
|
317
|
+
lineDownBoldLeft: "┒",
|
|
318
|
+
lineDownLeftBold: "┑",
|
|
319
|
+
lineDownDoubleLeftDouble: "╗",
|
|
320
|
+
lineDownDoubleLeft: "╖",
|
|
321
|
+
lineDownLeftDouble: "╕",
|
|
322
|
+
lineDownRight: "┌",
|
|
323
|
+
lineDownRightArc: "╭",
|
|
324
|
+
lineDownBoldRightBold: "┏",
|
|
325
|
+
lineDownBoldRight: "┎",
|
|
326
|
+
lineDownRightBold: "┍",
|
|
327
|
+
lineDownDoubleRightDouble: "╔",
|
|
328
|
+
lineDownDoubleRight: "╓",
|
|
329
|
+
lineDownRightDouble: "╒",
|
|
330
|
+
lineUpLeft: "┘",
|
|
331
|
+
lineUpLeftArc: "╯",
|
|
332
|
+
lineUpBoldLeftBold: "┛",
|
|
333
|
+
lineUpBoldLeft: "┚",
|
|
334
|
+
lineUpLeftBold: "┙",
|
|
335
|
+
lineUpDoubleLeftDouble: "╝",
|
|
336
|
+
lineUpDoubleLeft: "╜",
|
|
337
|
+
lineUpLeftDouble: "╛",
|
|
338
|
+
lineUpRight: "└",
|
|
339
|
+
lineUpRightArc: "╰",
|
|
340
|
+
lineUpBoldRightBold: "┗",
|
|
341
|
+
lineUpBoldRight: "┖",
|
|
342
|
+
lineUpRightBold: "┕",
|
|
343
|
+
lineUpDoubleRightDouble: "╚",
|
|
344
|
+
lineUpDoubleRight: "╙",
|
|
345
|
+
lineUpRightDouble: "╘",
|
|
346
|
+
lineUpDownLeft: "┤",
|
|
347
|
+
lineUpBoldDownBoldLeftBold: "┫",
|
|
348
|
+
lineUpBoldDownBoldLeft: "┨",
|
|
349
|
+
lineUpDownLeftBold: "┥",
|
|
350
|
+
lineUpBoldDownLeftBold: "┩",
|
|
351
|
+
lineUpDownBoldLeftBold: "┪",
|
|
352
|
+
lineUpDownBoldLeft: "┧",
|
|
353
|
+
lineUpBoldDownLeft: "┦",
|
|
354
|
+
lineUpDoubleDownDoubleLeftDouble: "╣",
|
|
355
|
+
lineUpDoubleDownDoubleLeft: "╢",
|
|
356
|
+
lineUpDownLeftDouble: "╡",
|
|
357
|
+
lineUpDownRight: "├",
|
|
358
|
+
lineUpBoldDownBoldRightBold: "┣",
|
|
359
|
+
lineUpBoldDownBoldRight: "┠",
|
|
360
|
+
lineUpDownRightBold: "┝",
|
|
361
|
+
lineUpBoldDownRightBold: "┡",
|
|
362
|
+
lineUpDownBoldRightBold: "┢",
|
|
363
|
+
lineUpDownBoldRight: "┟",
|
|
364
|
+
lineUpBoldDownRight: "┞",
|
|
365
|
+
lineUpDoubleDownDoubleRightDouble: "╠",
|
|
366
|
+
lineUpDoubleDownDoubleRight: "╟",
|
|
367
|
+
lineUpDownRightDouble: "╞",
|
|
368
|
+
lineDownLeftRight: "┬",
|
|
369
|
+
lineDownBoldLeftBoldRightBold: "┳",
|
|
370
|
+
lineDownLeftBoldRightBold: "┯",
|
|
371
|
+
lineDownBoldLeftRight: "┰",
|
|
372
|
+
lineDownBoldLeftBoldRight: "┱",
|
|
373
|
+
lineDownBoldLeftRightBold: "┲",
|
|
374
|
+
lineDownLeftRightBold: "┮",
|
|
375
|
+
lineDownLeftBoldRight: "┭",
|
|
376
|
+
lineDownDoubleLeftDoubleRightDouble: "╦",
|
|
377
|
+
lineDownDoubleLeftRight: "╥",
|
|
378
|
+
lineDownLeftDoubleRightDouble: "╤",
|
|
379
|
+
lineUpLeftRight: "┴",
|
|
380
|
+
lineUpBoldLeftBoldRightBold: "┻",
|
|
381
|
+
lineUpLeftBoldRightBold: "┷",
|
|
382
|
+
lineUpBoldLeftRight: "┸",
|
|
383
|
+
lineUpBoldLeftBoldRight: "┹",
|
|
384
|
+
lineUpBoldLeftRightBold: "┺",
|
|
385
|
+
lineUpLeftRightBold: "┶",
|
|
386
|
+
lineUpLeftBoldRight: "┵",
|
|
387
|
+
lineUpDoubleLeftDoubleRightDouble: "╩",
|
|
388
|
+
lineUpDoubleLeftRight: "╨",
|
|
389
|
+
lineUpLeftDoubleRightDouble: "╧",
|
|
390
|
+
lineUpDownLeftRight: "┼",
|
|
391
|
+
lineUpBoldDownBoldLeftBoldRightBold: "╋",
|
|
392
|
+
lineUpDownBoldLeftBoldRightBold: "╈",
|
|
393
|
+
lineUpBoldDownLeftBoldRightBold: "╇",
|
|
394
|
+
lineUpBoldDownBoldLeftRightBold: "╊",
|
|
395
|
+
lineUpBoldDownBoldLeftBoldRight: "╉",
|
|
396
|
+
lineUpBoldDownLeftRight: "╀",
|
|
397
|
+
lineUpDownBoldLeftRight: "╁",
|
|
398
|
+
lineUpDownLeftBoldRight: "┽",
|
|
399
|
+
lineUpDownLeftRightBold: "┾",
|
|
400
|
+
lineUpBoldDownBoldLeftRight: "╂",
|
|
401
|
+
lineUpDownLeftBoldRightBold: "┿",
|
|
402
|
+
lineUpBoldDownLeftBoldRight: "╃",
|
|
403
|
+
lineUpBoldDownLeftRightBold: "╄",
|
|
404
|
+
lineUpDownBoldLeftBoldRight: "╅",
|
|
405
|
+
lineUpDownBoldLeftRightBold: "╆",
|
|
406
|
+
lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
|
|
407
|
+
lineUpDoubleDownDoubleLeftRight: "╫",
|
|
408
|
+
lineUpDownLeftDoubleRightDouble: "╪",
|
|
409
|
+
lineCross: "╳",
|
|
410
|
+
lineBackslash: "╲",
|
|
411
|
+
lineSlash: "╱"
|
|
412
|
+
};
|
|
413
|
+
const specialMainSymbols = {
|
|
414
|
+
tick: "✔",
|
|
415
|
+
info: "ℹ",
|
|
416
|
+
warning: "⚠",
|
|
417
|
+
cross: "✘",
|
|
418
|
+
squareSmall: "◻",
|
|
419
|
+
squareSmallFilled: "◼",
|
|
420
|
+
circle: "◯",
|
|
421
|
+
circleFilled: "◉",
|
|
422
|
+
circleDotted: "◌",
|
|
423
|
+
circleDouble: "◎",
|
|
424
|
+
circleCircle: "ⓞ",
|
|
425
|
+
circleCross: "ⓧ",
|
|
426
|
+
circlePipe: "Ⓘ",
|
|
427
|
+
radioOn: "◉",
|
|
428
|
+
radioOff: "◯",
|
|
429
|
+
checkboxOn: "☒",
|
|
430
|
+
checkboxOff: "☐",
|
|
431
|
+
checkboxCircleOn: "ⓧ",
|
|
432
|
+
checkboxCircleOff: "Ⓘ",
|
|
433
|
+
pointer: "❯",
|
|
434
|
+
triangleUpOutline: "△",
|
|
435
|
+
triangleLeft: "◀",
|
|
436
|
+
triangleRight: "▶",
|
|
437
|
+
lozenge: "◆",
|
|
438
|
+
lozengeOutline: "◇",
|
|
439
|
+
hamburger: "☰",
|
|
440
|
+
smiley: "㋡",
|
|
441
|
+
mustache: "෴",
|
|
442
|
+
star: "★",
|
|
443
|
+
play: "▶",
|
|
444
|
+
nodejs: "⬢",
|
|
445
|
+
oneSeventh: "⅐",
|
|
446
|
+
oneNinth: "⅑",
|
|
447
|
+
oneTenth: "⅒"
|
|
448
|
+
};
|
|
449
|
+
const specialFallbackSymbols = {
|
|
450
|
+
tick: "√",
|
|
451
|
+
info: "i",
|
|
452
|
+
warning: "‼",
|
|
453
|
+
cross: "×",
|
|
454
|
+
squareSmall: "□",
|
|
455
|
+
squareSmallFilled: "■",
|
|
456
|
+
circle: "( )",
|
|
457
|
+
circleFilled: "(*)",
|
|
458
|
+
circleDotted: "( )",
|
|
459
|
+
circleDouble: "( )",
|
|
460
|
+
circleCircle: "(○)",
|
|
461
|
+
circleCross: "(×)",
|
|
462
|
+
circlePipe: "(│)",
|
|
463
|
+
radioOn: "(*)",
|
|
464
|
+
radioOff: "( )",
|
|
465
|
+
checkboxOn: "[×]",
|
|
466
|
+
checkboxOff: "[ ]",
|
|
467
|
+
checkboxCircleOn: "(×)",
|
|
468
|
+
checkboxCircleOff: "( )",
|
|
469
|
+
pointer: ">",
|
|
470
|
+
triangleUpOutline: "∆",
|
|
471
|
+
triangleLeft: "◄",
|
|
472
|
+
triangleRight: "►",
|
|
473
|
+
lozenge: "♦",
|
|
474
|
+
lozengeOutline: "◊",
|
|
475
|
+
hamburger: "≡",
|
|
476
|
+
smiley: "☺",
|
|
477
|
+
mustache: "┌─┐",
|
|
478
|
+
star: "✶",
|
|
479
|
+
play: "►",
|
|
480
|
+
nodejs: "♦",
|
|
481
|
+
oneSeventh: "1/7",
|
|
482
|
+
oneNinth: "1/9",
|
|
483
|
+
oneTenth: "1/10"
|
|
484
|
+
};
|
|
485
|
+
const mainSymbols = {
|
|
486
|
+
...common,
|
|
487
|
+
...specialMainSymbols
|
|
488
|
+
};
|
|
489
|
+
const fallbackSymbols = {
|
|
490
|
+
...common,
|
|
491
|
+
...specialFallbackSymbols
|
|
492
|
+
};
|
|
493
|
+
const shouldUseMain = isUnicodeSupported();
|
|
494
|
+
const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
495
|
+
const replacements = Object.entries(specialMainSymbols);
|
|
496
|
+
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/theme.js
|
|
499
|
+
const defaultTheme = {
|
|
500
|
+
prefix: {
|
|
501
|
+
idle: styleText("blue", "?"),
|
|
502
|
+
done: styleText("green", figures.tick)
|
|
503
|
+
},
|
|
504
|
+
spinner: {
|
|
505
|
+
interval: 80,
|
|
506
|
+
frames: [
|
|
507
|
+
"⠋",
|
|
508
|
+
"⠙",
|
|
509
|
+
"⠹",
|
|
510
|
+
"⠸",
|
|
511
|
+
"⠼",
|
|
512
|
+
"⠴",
|
|
513
|
+
"⠦",
|
|
514
|
+
"⠧",
|
|
515
|
+
"⠇",
|
|
516
|
+
"⠏"
|
|
517
|
+
].map((frame) => styleText("yellow", frame))
|
|
518
|
+
},
|
|
519
|
+
keybindings: [],
|
|
520
|
+
style: {
|
|
521
|
+
answer: (text) => styleText("cyan", text),
|
|
522
|
+
message: (text) => styleText("bold", text),
|
|
523
|
+
error: (text) => styleText("red", `> ${text}`),
|
|
524
|
+
defaultAnswer: (text) => styleText("dim", `(${text})`),
|
|
525
|
+
help: (text) => styleText("dim", text),
|
|
526
|
+
highlight: (text) => styleText("cyan", text),
|
|
527
|
+
key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
function getDefaultTheme() {
|
|
531
|
+
return {
|
|
532
|
+
...defaultTheme,
|
|
533
|
+
keybindings: getDefaultKeybindings()
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
539
|
+
function isPlainObject(value) {
|
|
540
|
+
if (typeof value !== "object" || value === null) return false;
|
|
541
|
+
let proto = value;
|
|
542
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
543
|
+
return Object.getPrototypeOf(value) === proto;
|
|
544
|
+
}
|
|
545
|
+
function deepMerge(...objects) {
|
|
546
|
+
const output = {};
|
|
547
|
+
for (const obj of objects) for (const [key, value] of Object.entries(obj)) {
|
|
548
|
+
const prevValue = output[key];
|
|
549
|
+
output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
|
|
550
|
+
}
|
|
551
|
+
return output;
|
|
552
|
+
}
|
|
553
|
+
function makeTheme(...themes) {
|
|
554
|
+
return deepMerge(...[getDefaultTheme(), ...themes.filter((theme) => theme != null)]);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
//#endregion
|
|
558
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
559
|
+
function usePrefix({ status = "idle", theme }) {
|
|
560
|
+
const [showLoader, setShowLoader] = useState(false);
|
|
561
|
+
const [tick, setTick] = useState(0);
|
|
562
|
+
const { prefix, spinner } = makeTheme(theme);
|
|
563
|
+
useEffect(() => {
|
|
564
|
+
if (status === "loading") {
|
|
565
|
+
let tickInterval;
|
|
566
|
+
let inc = -1;
|
|
567
|
+
const delayTimeout = setTimeout(() => {
|
|
568
|
+
setShowLoader(true);
|
|
569
|
+
tickInterval = setInterval(() => {
|
|
570
|
+
inc = inc + 1;
|
|
571
|
+
setTick(inc % spinner.frames.length);
|
|
572
|
+
}, spinner.interval);
|
|
573
|
+
}, 300);
|
|
574
|
+
return () => {
|
|
575
|
+
clearTimeout(delayTimeout);
|
|
576
|
+
clearInterval(tickInterval);
|
|
577
|
+
};
|
|
578
|
+
} else setShowLoader(false);
|
|
579
|
+
}, [status]);
|
|
580
|
+
if (showLoader) return spinner.frames[tick];
|
|
581
|
+
return typeof prefix === "string" ? prefix : prefix[status === "loading" ? "idle" : status] ?? prefix["idle"];
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
//#endregion
|
|
585
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
586
|
+
function useMemo(fn, dependencies) {
|
|
587
|
+
return withPointer((pointer) => {
|
|
588
|
+
const prev = pointer.get();
|
|
589
|
+
if (!pointer.initialized || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
|
|
590
|
+
const value = fn();
|
|
591
|
+
pointer.set({
|
|
592
|
+
value,
|
|
593
|
+
dependencies
|
|
594
|
+
});
|
|
595
|
+
return value;
|
|
596
|
+
}
|
|
597
|
+
return prev.value;
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
603
|
+
function useRef(val) {
|
|
604
|
+
return useState({ current: val })[0];
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
609
|
+
function useKeypress(userHandler) {
|
|
610
|
+
const signal = useRef(userHandler);
|
|
611
|
+
signal.current = userHandler;
|
|
612
|
+
useEffect((rl) => {
|
|
613
|
+
let ignore = false;
|
|
614
|
+
const handler = withUpdates((_input, event) => {
|
|
615
|
+
if (ignore) return;
|
|
616
|
+
signal.current(event, rl);
|
|
617
|
+
});
|
|
618
|
+
rl.input.on("keypress", handler);
|
|
619
|
+
return () => {
|
|
620
|
+
ignore = true;
|
|
621
|
+
rl.input.removeListener("keypress", handler);
|
|
622
|
+
};
|
|
623
|
+
}, []);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region ../../node_modules/.pnpm/cli-width@4.1.0/node_modules/cli-width/index.js
|
|
628
|
+
var require_cli_width = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
629
|
+
module.exports = cliWidth;
|
|
630
|
+
function normalizeOpts(options) {
|
|
631
|
+
const defaultOpts = {
|
|
632
|
+
defaultWidth: 0,
|
|
633
|
+
output: process.stdout,
|
|
634
|
+
tty: __require("tty")
|
|
635
|
+
};
|
|
636
|
+
if (!options) return defaultOpts;
|
|
637
|
+
Object.keys(defaultOpts).forEach(function(key) {
|
|
638
|
+
if (!options[key]) options[key] = defaultOpts[key];
|
|
639
|
+
});
|
|
640
|
+
return options;
|
|
641
|
+
}
|
|
642
|
+
function cliWidth(options) {
|
|
643
|
+
const opts = normalizeOpts(options);
|
|
644
|
+
if (opts.output.getWindowSize) return opts.output.getWindowSize()[0] || opts.defaultWidth;
|
|
645
|
+
if (opts.tty.getWindowSize) return opts.tty.getWindowSize()[1] || opts.defaultWidth;
|
|
646
|
+
if (opts.output.columns) return opts.output.columns;
|
|
647
|
+
if (process.env.CLI_WIDTH) {
|
|
648
|
+
const width = parseInt(process.env.CLI_WIDTH, 10);
|
|
649
|
+
if (!isNaN(width) && width !== 0) return width;
|
|
650
|
+
}
|
|
651
|
+
return opts.defaultWidth;
|
|
652
|
+
}
|
|
653
|
+
}));
|
|
654
|
+
|
|
655
|
+
//#endregion
|
|
656
|
+
//#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
657
|
+
const getCodePointsLength = (() => {
|
|
658
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
659
|
+
return (input) => {
|
|
660
|
+
let surrogatePairsNr = 0;
|
|
661
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
662
|
+
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
663
|
+
return input.length - surrogatePairsNr;
|
|
664
|
+
};
|
|
665
|
+
})();
|
|
666
|
+
const isFullWidth = (x) => {
|
|
667
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
668
|
+
};
|
|
669
|
+
const isWideNotCJKTNotEmoji = (x) => {
|
|
670
|
+
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;
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
//#endregion
|
|
674
|
+
//#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
675
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
676
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
677
|
+
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
|
|
678
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
679
|
+
const 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?))*/uy;
|
|
680
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
681
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
682
|
+
const NO_TRUNCATION$1 = {
|
|
683
|
+
limit: Infinity,
|
|
684
|
+
ellipsis: ""
|
|
685
|
+
};
|
|
686
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
687
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
688
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
689
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
690
|
+
const ANSI_WIDTH = 0;
|
|
691
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
692
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
693
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
694
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
695
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
696
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
697
|
+
const PARSE_BLOCKS = [
|
|
698
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
699
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
700
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
701
|
+
[TAB_RE, TAB_WIDTH],
|
|
702
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
703
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
704
|
+
];
|
|
705
|
+
let indexPrev = 0;
|
|
706
|
+
let index = 0;
|
|
707
|
+
let length = input.length;
|
|
708
|
+
let lengthExtra = 0;
|
|
709
|
+
let truncationEnabled = false;
|
|
710
|
+
let truncationIndex = length;
|
|
711
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
712
|
+
let unmatchedStart = 0;
|
|
713
|
+
let unmatchedEnd = 0;
|
|
714
|
+
let width = 0;
|
|
715
|
+
let widthExtra = 0;
|
|
716
|
+
outer: while (true) {
|
|
717
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
718
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
719
|
+
lengthExtra = 0;
|
|
720
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
721
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
722
|
+
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
723
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
724
|
+
else widthExtra = REGULAR_WIDTH;
|
|
725
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
726
|
+
if (width + widthExtra > LIMIT) {
|
|
727
|
+
truncationEnabled = true;
|
|
728
|
+
break outer;
|
|
729
|
+
}
|
|
730
|
+
lengthExtra += char.length;
|
|
731
|
+
width += widthExtra;
|
|
732
|
+
}
|
|
733
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
734
|
+
}
|
|
735
|
+
if (index >= length) break outer;
|
|
736
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
737
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
738
|
+
BLOCK_RE.lastIndex = index;
|
|
739
|
+
if (BLOCK_RE.test(input)) {
|
|
740
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
741
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
742
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
743
|
+
if (width + widthExtra > LIMIT) {
|
|
744
|
+
truncationEnabled = true;
|
|
745
|
+
break outer;
|
|
746
|
+
}
|
|
747
|
+
width += widthExtra;
|
|
748
|
+
unmatchedStart = indexPrev;
|
|
749
|
+
unmatchedEnd = index;
|
|
750
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
751
|
+
continue outer;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
index += 1;
|
|
755
|
+
}
|
|
756
|
+
return {
|
|
757
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
758
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
759
|
+
truncated: truncationEnabled,
|
|
760
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
761
|
+
};
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
//#endregion
|
|
765
|
+
//#region ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
766
|
+
const NO_TRUNCATION = {
|
|
767
|
+
limit: Infinity,
|
|
768
|
+
ellipsis: "",
|
|
769
|
+
ellipsisWidth: 0
|
|
770
|
+
};
|
|
771
|
+
const fastStringWidth = (input, options = {}) => {
|
|
772
|
+
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
//#endregion
|
|
776
|
+
//#region ../../node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
777
|
+
const ESC$1 = "\x1B";
|
|
778
|
+
const CSI = "";
|
|
779
|
+
const END_CODE = 39;
|
|
780
|
+
const ANSI_ESCAPE_BELL = "\x07";
|
|
781
|
+
const ANSI_CSI = "[";
|
|
782
|
+
const ANSI_OSC = "]";
|
|
783
|
+
const ANSI_SGR_TERMINATOR = "m";
|
|
784
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
785
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
786
|
+
const getClosingCode = (openingCode) => {
|
|
787
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
788
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
789
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
790
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
791
|
+
if (openingCode === 1 || openingCode === 2) return 22;
|
|
792
|
+
if (openingCode === 3) return 23;
|
|
793
|
+
if (openingCode === 4) return 24;
|
|
794
|
+
if (openingCode === 7) return 27;
|
|
795
|
+
if (openingCode === 8) return 28;
|
|
796
|
+
if (openingCode === 9) return 29;
|
|
797
|
+
if (openingCode === 0) return 0;
|
|
798
|
+
};
|
|
799
|
+
const wrapAnsiCode = (code) => `${ESC$1}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
800
|
+
const wrapAnsiHyperlink = (url) => `${ESC$1}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
801
|
+
const wrapWord = (rows, word, columns) => {
|
|
802
|
+
const characters = word[Symbol.iterator]();
|
|
803
|
+
let isInsideEscape = false;
|
|
804
|
+
let isInsideLinkEscape = false;
|
|
805
|
+
let lastRow = rows.at(-1);
|
|
806
|
+
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
807
|
+
let currentCharacter = characters.next();
|
|
808
|
+
let nextCharacter = characters.next();
|
|
809
|
+
let rawCharacterIndex = 0;
|
|
810
|
+
while (!currentCharacter.done) {
|
|
811
|
+
const character = currentCharacter.value;
|
|
812
|
+
const characterLength = fastStringWidth(character);
|
|
813
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
814
|
+
else {
|
|
815
|
+
rows.push(character);
|
|
816
|
+
visible = 0;
|
|
817
|
+
}
|
|
818
|
+
if (character === ESC$1 || character === CSI) {
|
|
819
|
+
isInsideEscape = true;
|
|
820
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
821
|
+
}
|
|
822
|
+
if (isInsideEscape) {
|
|
823
|
+
if (isInsideLinkEscape) {
|
|
824
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
825
|
+
isInsideEscape = false;
|
|
826
|
+
isInsideLinkEscape = false;
|
|
827
|
+
}
|
|
828
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
829
|
+
} else {
|
|
830
|
+
visible += characterLength;
|
|
831
|
+
if (visible === columns && !nextCharacter.done) {
|
|
832
|
+
rows.push("");
|
|
833
|
+
visible = 0;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
currentCharacter = nextCharacter;
|
|
837
|
+
nextCharacter = characters.next();
|
|
838
|
+
rawCharacterIndex += character.length;
|
|
839
|
+
}
|
|
840
|
+
lastRow = rows.at(-1);
|
|
841
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
842
|
+
};
|
|
843
|
+
const stringVisibleTrimSpacesRight = (string) => {
|
|
844
|
+
const words = string.split(" ");
|
|
845
|
+
let last = words.length;
|
|
846
|
+
while (last) {
|
|
847
|
+
if (fastStringWidth(words[last - 1])) break;
|
|
848
|
+
last--;
|
|
849
|
+
}
|
|
850
|
+
if (last === words.length) return string;
|
|
851
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
852
|
+
};
|
|
853
|
+
const exec = (string, columns, options = {}) => {
|
|
854
|
+
if (options.trim !== false && string.trim() === "") return "";
|
|
855
|
+
let returnValue = "";
|
|
856
|
+
let escapeCode;
|
|
857
|
+
let escapeUrl;
|
|
858
|
+
const words = string.split(" ");
|
|
859
|
+
let rows = [""];
|
|
860
|
+
let rowLength = 0;
|
|
861
|
+
for (let index = 0; index < words.length; index++) {
|
|
862
|
+
const word = words[index];
|
|
863
|
+
if (options.trim !== false) {
|
|
864
|
+
const row = rows.at(-1) ?? "";
|
|
865
|
+
const trimmed = row.trimStart();
|
|
866
|
+
if (row.length !== trimmed.length) {
|
|
867
|
+
rows[rows.length - 1] = trimmed;
|
|
868
|
+
rowLength = fastStringWidth(trimmed);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
if (index !== 0) {
|
|
872
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
873
|
+
rows.push("");
|
|
874
|
+
rowLength = 0;
|
|
875
|
+
}
|
|
876
|
+
if (rowLength || options.trim === false) {
|
|
877
|
+
rows[rows.length - 1] += " ";
|
|
878
|
+
rowLength++;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
const wordLength = fastStringWidth(word);
|
|
882
|
+
if (options.hard && wordLength > columns) {
|
|
883
|
+
const remainingColumns = columns - rowLength;
|
|
884
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
885
|
+
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
886
|
+
wrapWord(rows, word, columns);
|
|
887
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
891
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
892
|
+
wrapWord(rows, word, columns);
|
|
893
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
rows.push("");
|
|
897
|
+
rowLength = 0;
|
|
898
|
+
}
|
|
899
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
900
|
+
wrapWord(rows, word, columns);
|
|
901
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
rows[rows.length - 1] += word;
|
|
905
|
+
rowLength += wordLength;
|
|
906
|
+
}
|
|
907
|
+
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
908
|
+
const preString = rows.join("\n");
|
|
909
|
+
let inSurrogate = false;
|
|
910
|
+
for (let i = 0; i < preString.length; i++) {
|
|
911
|
+
const character = preString[i];
|
|
912
|
+
returnValue += character;
|
|
913
|
+
if (!inSurrogate) {
|
|
914
|
+
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
915
|
+
if (inSurrogate) continue;
|
|
916
|
+
} else inSurrogate = false;
|
|
917
|
+
if (character === ESC$1 || character === CSI) {
|
|
918
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
919
|
+
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
920
|
+
if (groups?.code !== void 0) {
|
|
921
|
+
const code = Number.parseFloat(groups.code);
|
|
922
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
923
|
+
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
924
|
+
}
|
|
925
|
+
if (preString[i + 1] === "\n") {
|
|
926
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
927
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
928
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
929
|
+
} else if (character === "\n") {
|
|
930
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
931
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return returnValue;
|
|
935
|
+
};
|
|
936
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
937
|
+
function wrapAnsi(string, columns, options) {
|
|
938
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/utils.js
|
|
943
|
+
var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
|
|
944
|
+
/**
|
|
945
|
+
* Force line returns at specific width. This function is ANSI code friendly and it'll
|
|
946
|
+
* ignore invisible codes during width calculation.
|
|
947
|
+
* @param {string} content
|
|
948
|
+
* @param {number} width
|
|
949
|
+
* @return {string}
|
|
950
|
+
*/
|
|
951
|
+
function breakLines(content, width) {
|
|
952
|
+
return content.split("\n").flatMap((line) => wrapAnsi(line, width, {
|
|
953
|
+
trim: false,
|
|
954
|
+
wordWrap: false
|
|
955
|
+
}).split("\n").map((str) => str.trimEnd())).join("\n");
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Returns the width of the active readline, or 80 as default value.
|
|
959
|
+
* @returns {number}
|
|
960
|
+
*/
|
|
961
|
+
function readlineWidth() {
|
|
962
|
+
return (0, import_cli_width.default)({
|
|
963
|
+
defaultWidth: 80,
|
|
964
|
+
output: readline$1().output
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
//#endregion
|
|
969
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
970
|
+
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
971
|
+
const state = useRef({
|
|
972
|
+
lastPointer: active,
|
|
973
|
+
lastActive: void 0
|
|
974
|
+
});
|
|
975
|
+
const { lastPointer, lastActive } = state.current;
|
|
976
|
+
const middle = Math.floor(pageSize / 2);
|
|
977
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
978
|
+
const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
|
|
979
|
+
let pointer = defaultPointerPosition;
|
|
980
|
+
if (renderedLength > pageSize) {
|
|
981
|
+
if (loop) {
|
|
982
|
+
/**
|
|
983
|
+
* Creates the next position for the pointer considering an infinitely
|
|
984
|
+
* looping list of items to be rendered on the page.
|
|
985
|
+
*
|
|
986
|
+
* The goal is to progressively move the cursor to the middle position as the user move down, and then keep
|
|
987
|
+
* the cursor there. When the user move up, maintain the cursor position.
|
|
988
|
+
*/
|
|
989
|
+
pointer = lastPointer;
|
|
990
|
+
if (lastActive != null && lastActive < active && active - lastActive < pageSize) pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
|
|
991
|
+
} else {
|
|
992
|
+
/**
|
|
993
|
+
* Creates the next position for the pointer considering a finite list of
|
|
994
|
+
* items to be rendered on a page.
|
|
995
|
+
*
|
|
996
|
+
* The goal is to keep the pointer in the middle of the page whenever possible, until
|
|
997
|
+
* we reach the bounds of the list (top or bottom). In which case, the cursor moves progressively
|
|
998
|
+
* to the bottom or top of the list.
|
|
999
|
+
*/
|
|
1000
|
+
const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
|
|
1001
|
+
pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
state.current.lastPointer = pointer;
|
|
1005
|
+
state.current.lastActive = active;
|
|
1006
|
+
return pointer;
|
|
1007
|
+
}
|
|
1008
|
+
function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
1009
|
+
const width = readlineWidth();
|
|
1010
|
+
const bound = (num) => (num % items.length + items.length) % items.length;
|
|
1011
|
+
const renderedItems = items.map((item, index) => {
|
|
1012
|
+
if (item == null) return [];
|
|
1013
|
+
return breakLines(renderItem({
|
|
1014
|
+
item,
|
|
1015
|
+
index,
|
|
1016
|
+
isActive: index === active
|
|
1017
|
+
}), width).split("\n");
|
|
1018
|
+
});
|
|
1019
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
1020
|
+
const renderItemAtIndex = (index) => renderedItems[index] ?? [];
|
|
1021
|
+
const pointer = usePointerPosition({
|
|
1022
|
+
active,
|
|
1023
|
+
renderedItems,
|
|
1024
|
+
pageSize,
|
|
1025
|
+
loop
|
|
1026
|
+
});
|
|
1027
|
+
const activeItem = renderItemAtIndex(active).slice(0, pageSize);
|
|
1028
|
+
const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
|
|
1029
|
+
const pageBuffer = Array.from({ length: pageSize });
|
|
1030
|
+
pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
|
|
1031
|
+
const itemVisited = /* @__PURE__ */ new Set([active]);
|
|
1032
|
+
let bufferPointer = activeItemPosition + activeItem.length;
|
|
1033
|
+
let itemPointer = bound(active + 1);
|
|
1034
|
+
while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
|
|
1035
|
+
const linesToAdd = renderItemAtIndex(itemPointer).slice(0, pageSize - bufferPointer);
|
|
1036
|
+
pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
|
|
1037
|
+
itemVisited.add(itemPointer);
|
|
1038
|
+
bufferPointer += linesToAdd.length;
|
|
1039
|
+
itemPointer = bound(itemPointer + 1);
|
|
1040
|
+
}
|
|
1041
|
+
bufferPointer = activeItemPosition - 1;
|
|
1042
|
+
itemPointer = bound(active - 1);
|
|
1043
|
+
while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
|
|
1044
|
+
const lines = renderItemAtIndex(itemPointer);
|
|
1045
|
+
const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
|
|
1046
|
+
pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
|
|
1047
|
+
itemVisited.add(itemPointer);
|
|
1048
|
+
bufferPointer -= linesToAdd.length;
|
|
1049
|
+
itemPointer = bound(itemPointer - 1);
|
|
1050
|
+
}
|
|
1051
|
+
return pageBuffer.filter((line) => typeof line === "string").join("\n");
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
//#endregion
|
|
1055
|
+
//#region ../../node_modules/.pnpm/@inquirer+type@4.2.0_@types+node@26.6.5/node_modules/@inquirer/type/dist/utils.js
|
|
1056
|
+
/**
|
|
1057
|
+
* Create a promise and get access to its `resolve` and `reject` functions.
|
|
1058
|
+
*
|
|
1059
|
+
* Mirrors `Promise.withResolvers()`, available starting from Node 22.
|
|
1060
|
+
* TODO: Remove once Node 22 becomes the minimum supported version.
|
|
1061
|
+
*/
|
|
1062
|
+
function withResolver() {
|
|
1063
|
+
let resolve;
|
|
1064
|
+
let reject;
|
|
1065
|
+
return {
|
|
1066
|
+
promise: new Promise((res, rej) => {
|
|
1067
|
+
resolve = res;
|
|
1068
|
+
reject = rej;
|
|
1069
|
+
}),
|
|
1070
|
+
resolve,
|
|
1071
|
+
reject
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region ../../node_modules/.pnpm/mute-stream@3.0.0/node_modules/mute-stream/lib/index.js
|
|
1077
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1078
|
+
const Stream = __require("stream");
|
|
1079
|
+
var MuteStream = class extends Stream {
|
|
1080
|
+
#isTTY = null;
|
|
1081
|
+
constructor(opts = {}) {
|
|
1082
|
+
super(opts);
|
|
1083
|
+
this.writable = this.readable = true;
|
|
1084
|
+
this.muted = false;
|
|
1085
|
+
this.on("pipe", this._onpipe);
|
|
1086
|
+
this.replace = opts.replace;
|
|
1087
|
+
this._prompt = opts.prompt || null;
|
|
1088
|
+
this._hadControl = false;
|
|
1089
|
+
}
|
|
1090
|
+
#destSrc(key, def) {
|
|
1091
|
+
if (this._dest) return this._dest[key];
|
|
1092
|
+
if (this._src) return this._src[key];
|
|
1093
|
+
return def;
|
|
1094
|
+
}
|
|
1095
|
+
#proxy(method, ...args) {
|
|
1096
|
+
if (typeof this._dest?.[method] === "function") this._dest[method](...args);
|
|
1097
|
+
if (typeof this._src?.[method] === "function") this._src[method](...args);
|
|
1098
|
+
}
|
|
1099
|
+
get isTTY() {
|
|
1100
|
+
if (this.#isTTY !== null) return this.#isTTY;
|
|
1101
|
+
return this.#destSrc("isTTY", false);
|
|
1102
|
+
}
|
|
1103
|
+
set isTTY(val) {
|
|
1104
|
+
this.#isTTY = val;
|
|
1105
|
+
}
|
|
1106
|
+
get rows() {
|
|
1107
|
+
return this.#destSrc("rows");
|
|
1108
|
+
}
|
|
1109
|
+
get columns() {
|
|
1110
|
+
return this.#destSrc("columns");
|
|
1111
|
+
}
|
|
1112
|
+
mute() {
|
|
1113
|
+
this.muted = true;
|
|
1114
|
+
}
|
|
1115
|
+
unmute() {
|
|
1116
|
+
this.muted = false;
|
|
1117
|
+
}
|
|
1118
|
+
_onpipe(src) {
|
|
1119
|
+
this._src = src;
|
|
1120
|
+
}
|
|
1121
|
+
pipe(dest, options) {
|
|
1122
|
+
this._dest = dest;
|
|
1123
|
+
return super.pipe(dest, options);
|
|
1124
|
+
}
|
|
1125
|
+
pause() {
|
|
1126
|
+
if (this._src) return this._src.pause();
|
|
1127
|
+
}
|
|
1128
|
+
resume() {
|
|
1129
|
+
if (this._src) return this._src.resume();
|
|
1130
|
+
}
|
|
1131
|
+
write(c) {
|
|
1132
|
+
if (this.muted) {
|
|
1133
|
+
if (!this.replace) return true;
|
|
1134
|
+
if (c.match(/^\u001b/)) {
|
|
1135
|
+
if (c.indexOf(this._prompt) === 0) {
|
|
1136
|
+
c = c.slice(this._prompt.length);
|
|
1137
|
+
c = c.replace(/./g, this.replace);
|
|
1138
|
+
c = this._prompt + c;
|
|
1139
|
+
}
|
|
1140
|
+
this._hadControl = true;
|
|
1141
|
+
return this.emit("data", c);
|
|
1142
|
+
} else {
|
|
1143
|
+
if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
|
|
1144
|
+
this._hadControl = false;
|
|
1145
|
+
this.emit("data", this._prompt);
|
|
1146
|
+
c = c.slice(this._prompt.length);
|
|
1147
|
+
}
|
|
1148
|
+
c = c.toString().replace(/./g, this.replace);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
this.emit("data", c);
|
|
1152
|
+
}
|
|
1153
|
+
end(c) {
|
|
1154
|
+
if (this.muted) {
|
|
1155
|
+
if (c && this.replace) c = c.toString().replace(/./g, this.replace);
|
|
1156
|
+
else c = null;
|
|
1157
|
+
}
|
|
1158
|
+
if (c) this.emit("data", c);
|
|
1159
|
+
this.emit("end");
|
|
1160
|
+
}
|
|
1161
|
+
destroy(...args) {
|
|
1162
|
+
return this.#proxy("destroy", ...args);
|
|
1163
|
+
}
|
|
1164
|
+
destroySoon(...args) {
|
|
1165
|
+
return this.#proxy("destroySoon", ...args);
|
|
1166
|
+
}
|
|
1167
|
+
close(...args) {
|
|
1168
|
+
return this.#proxy("close", ...args);
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
module.exports = MuteStream;
|
|
1172
|
+
}));
|
|
1173
|
+
|
|
1174
|
+
//#endregion
|
|
1175
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
1176
|
+
/**
|
|
1177
|
+
* This is not the set of all possible signals.
|
|
1178
|
+
*
|
|
1179
|
+
* It IS, however, the set of all signals that trigger
|
|
1180
|
+
* an exit on either Linux or BSD systems. Linux is a
|
|
1181
|
+
* superset of the signal names supported on BSD, and
|
|
1182
|
+
* the unknown signals just fail to register, so we can
|
|
1183
|
+
* catch that easily enough.
|
|
1184
|
+
*
|
|
1185
|
+
* Windows signals are a different set, since there are
|
|
1186
|
+
* signals that terminate Windows processes, but don't
|
|
1187
|
+
* terminate (or don't even exist) on Posix systems.
|
|
1188
|
+
*
|
|
1189
|
+
* Don't bother with SIGKILL. It's uncatchable, which
|
|
1190
|
+
* means that we can't fire any callbacks anyway.
|
|
1191
|
+
*
|
|
1192
|
+
* If a user does happen to register a handler on a non-
|
|
1193
|
+
* fatal signal like SIGWINCH or something, and then
|
|
1194
|
+
* exit, it'll end up firing `process.emit('exit')`, so
|
|
1195
|
+
* the handler will be fired anyway.
|
|
1196
|
+
*
|
|
1197
|
+
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
1198
|
+
* artificially, inherently leave the process in a
|
|
1199
|
+
* state from which it is not safe to try and enter JS
|
|
1200
|
+
* listeners.
|
|
1201
|
+
*/
|
|
1202
|
+
const signals = [];
|
|
1203
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
1204
|
+
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
1205
|
+
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
1206
|
+
|
|
1207
|
+
//#endregion
|
|
1208
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
1209
|
+
const processOk = (process) => !!process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
|
|
1210
|
+
const kExitEmitter = Symbol.for("signal-exit emitter");
|
|
1211
|
+
const global = globalThis;
|
|
1212
|
+
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
1213
|
+
var Emitter = class {
|
|
1214
|
+
emitted = {
|
|
1215
|
+
afterExit: false,
|
|
1216
|
+
exit: false
|
|
1217
|
+
};
|
|
1218
|
+
listeners = {
|
|
1219
|
+
afterExit: [],
|
|
1220
|
+
exit: []
|
|
1221
|
+
};
|
|
1222
|
+
count = 0;
|
|
1223
|
+
id = Math.random();
|
|
1224
|
+
constructor() {
|
|
1225
|
+
if (global[kExitEmitter]) return global[kExitEmitter];
|
|
1226
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
1227
|
+
value: this,
|
|
1228
|
+
writable: false,
|
|
1229
|
+
enumerable: false,
|
|
1230
|
+
configurable: false
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
on(ev, fn) {
|
|
1234
|
+
this.listeners[ev].push(fn);
|
|
1235
|
+
}
|
|
1236
|
+
removeListener(ev, fn) {
|
|
1237
|
+
const list = this.listeners[ev];
|
|
1238
|
+
const i = list.indexOf(fn);
|
|
1239
|
+
/* c8 ignore start */
|
|
1240
|
+
if (i === -1) return;
|
|
1241
|
+
/* c8 ignore stop */
|
|
1242
|
+
if (i === 0 && list.length === 1) list.length = 0;
|
|
1243
|
+
else list.splice(i, 1);
|
|
1244
|
+
}
|
|
1245
|
+
emit(ev, code, signal) {
|
|
1246
|
+
if (this.emitted[ev]) return false;
|
|
1247
|
+
this.emitted[ev] = true;
|
|
1248
|
+
let ret = false;
|
|
1249
|
+
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
|
|
1250
|
+
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
|
|
1251
|
+
return ret;
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
var SignalExitBase = class {};
|
|
1255
|
+
const signalExitWrap = (handler) => {
|
|
1256
|
+
return {
|
|
1257
|
+
onExit(cb, opts) {
|
|
1258
|
+
return handler.onExit(cb, opts);
|
|
1259
|
+
},
|
|
1260
|
+
load() {
|
|
1261
|
+
return handler.load();
|
|
1262
|
+
},
|
|
1263
|
+
unload() {
|
|
1264
|
+
return handler.unload();
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
};
|
|
1268
|
+
var SignalExitFallback = class extends SignalExitBase {
|
|
1269
|
+
onExit() {
|
|
1270
|
+
return () => {};
|
|
1271
|
+
}
|
|
1272
|
+
load() {}
|
|
1273
|
+
unload() {}
|
|
1274
|
+
};
|
|
1275
|
+
var SignalExit = class extends SignalExitBase {
|
|
1276
|
+
/* c8 ignore start */
|
|
1277
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
1278
|
+
/* c8 ignore stop */
|
|
1279
|
+
#emitter = new Emitter();
|
|
1280
|
+
#process;
|
|
1281
|
+
#originalProcessEmit;
|
|
1282
|
+
#originalProcessReallyExit;
|
|
1283
|
+
#sigListeners = {};
|
|
1284
|
+
#loaded = false;
|
|
1285
|
+
constructor(process) {
|
|
1286
|
+
super();
|
|
1287
|
+
this.#process = process;
|
|
1288
|
+
this.#sigListeners = {};
|
|
1289
|
+
for (const sig of signals) this.#sigListeners[sig] = () => {
|
|
1290
|
+
const listeners = this.#process.listeners(sig);
|
|
1291
|
+
let { count } = this.#emitter;
|
|
1292
|
+
/* c8 ignore start */
|
|
1293
|
+
const p = process;
|
|
1294
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
|
|
1295
|
+
/* c8 ignore stop */
|
|
1296
|
+
if (listeners.length === count) {
|
|
1297
|
+
this.unload();
|
|
1298
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
1299
|
+
/* c8 ignore start */
|
|
1300
|
+
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
1301
|
+
if (!ret) process.kill(process.pid, s);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
this.#originalProcessReallyExit = process.reallyExit;
|
|
1305
|
+
this.#originalProcessEmit = process.emit;
|
|
1306
|
+
}
|
|
1307
|
+
onExit(cb, opts) {
|
|
1308
|
+
/* c8 ignore start */
|
|
1309
|
+
if (!processOk(this.#process)) return () => {};
|
|
1310
|
+
/* c8 ignore stop */
|
|
1311
|
+
if (this.#loaded === false) this.load();
|
|
1312
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
1313
|
+
this.#emitter.on(ev, cb);
|
|
1314
|
+
return () => {
|
|
1315
|
+
this.#emitter.removeListener(ev, cb);
|
|
1316
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
load() {
|
|
1320
|
+
if (this.#loaded) return;
|
|
1321
|
+
this.#loaded = true;
|
|
1322
|
+
this.#emitter.count += 1;
|
|
1323
|
+
for (const sig of signals) try {
|
|
1324
|
+
const fn = this.#sigListeners[sig];
|
|
1325
|
+
if (fn) this.#process.on(sig, fn);
|
|
1326
|
+
} catch (_) {}
|
|
1327
|
+
this.#process.emit = (ev, ...a) => {
|
|
1328
|
+
return this.#processEmit(ev, ...a);
|
|
1329
|
+
};
|
|
1330
|
+
this.#process.reallyExit = (code) => {
|
|
1331
|
+
return this.#processReallyExit(code);
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
unload() {
|
|
1335
|
+
if (!this.#loaded) return;
|
|
1336
|
+
this.#loaded = false;
|
|
1337
|
+
signals.forEach((sig) => {
|
|
1338
|
+
const listener = this.#sigListeners[sig];
|
|
1339
|
+
/* c8 ignore start */
|
|
1340
|
+
if (!listener) throw new Error("Listener not defined for signal: " + sig);
|
|
1341
|
+
/* c8 ignore stop */
|
|
1342
|
+
try {
|
|
1343
|
+
this.#process.removeListener(sig, listener);
|
|
1344
|
+
} catch (_) {}
|
|
1345
|
+
/* c8 ignore stop */
|
|
1346
|
+
});
|
|
1347
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
1348
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
1349
|
+
this.#emitter.count -= 1;
|
|
1350
|
+
}
|
|
1351
|
+
#processReallyExit(code) {
|
|
1352
|
+
/* c8 ignore start */
|
|
1353
|
+
if (!processOk(this.#process)) return 0;
|
|
1354
|
+
this.#process.exitCode = code || 0;
|
|
1355
|
+
/* c8 ignore stop */
|
|
1356
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1357
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
1358
|
+
}
|
|
1359
|
+
#processEmit(ev, ...args) {
|
|
1360
|
+
const og = this.#originalProcessEmit;
|
|
1361
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
1362
|
+
if (typeof args[0] === "number") this.#process.exitCode = args[0];
|
|
1363
|
+
/* c8 ignore start */
|
|
1364
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
1365
|
+
/* c8 ignore start */
|
|
1366
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1367
|
+
/* c8 ignore stop */
|
|
1368
|
+
return ret;
|
|
1369
|
+
} else return og.call(this.#process, ev, ...args);
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
const process$2 = globalThis.process;
|
|
1373
|
+
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
1374
|
+
|
|
1375
|
+
//#endregion
|
|
1376
|
+
//#region ../../node_modules/.pnpm/@inquirer+ansi@2.0.9/node_modules/@inquirer/ansi/dist/index.js
|
|
1377
|
+
const ESC = "\x1B[";
|
|
1378
|
+
/** Hide the cursor */
|
|
1379
|
+
const cursorHide = "\x1B[?25l";
|
|
1380
|
+
/** Show the cursor */
|
|
1381
|
+
const cursorShow = "\x1B[?25h";
|
|
1382
|
+
/** Move cursor up by count rows */
|
|
1383
|
+
const cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
|
|
1384
|
+
/** Move cursor down by count rows */
|
|
1385
|
+
const cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
|
|
1386
|
+
/** Move cursor to position (x, y) */
|
|
1387
|
+
const cursorTo = (x, y) => {
|
|
1388
|
+
if (typeof y === "number" && !Number.isNaN(y)) return `${ESC}${y + 1};${x + 1}H`;
|
|
1389
|
+
return `${ESC}${x + 1}G`;
|
|
1390
|
+
};
|
|
1391
|
+
const eraseLine = "\x1B[2K";
|
|
1392
|
+
/** Erase the specified number of lines above the cursor */
|
|
1393
|
+
const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
|
|
1394
|
+
|
|
1395
|
+
//#endregion
|
|
1396
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
1397
|
+
const height = (content) => content.split("\n").length;
|
|
1398
|
+
const lastLine = (content) => content.split("\n").pop() ?? "";
|
|
1399
|
+
var ScreenManager = class {
|
|
1400
|
+
height = 0;
|
|
1401
|
+
extraLinesUnderPrompt = 0;
|
|
1402
|
+
cursorPos;
|
|
1403
|
+
rl;
|
|
1404
|
+
constructor(rl) {
|
|
1405
|
+
this.rl = rl;
|
|
1406
|
+
this.cursorPos = rl.getCursorPos();
|
|
1407
|
+
}
|
|
1408
|
+
write(content) {
|
|
1409
|
+
this.rl.output.unmute();
|
|
1410
|
+
this.rl.output.write(content);
|
|
1411
|
+
this.rl.output.mute();
|
|
1412
|
+
}
|
|
1413
|
+
render(content, bottomContent = "") {
|
|
1414
|
+
const promptLine = lastLine(content);
|
|
1415
|
+
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
1416
|
+
let prompt = rawPromptLine;
|
|
1417
|
+
if (this.rl.line.length > 0) prompt = prompt.slice(0, -this.rl.line.length);
|
|
1418
|
+
this.rl.setPrompt(prompt);
|
|
1419
|
+
this.cursorPos = this.rl.getCursorPos();
|
|
1420
|
+
const width = readlineWidth();
|
|
1421
|
+
content = breakLines(content, width);
|
|
1422
|
+
bottomContent = breakLines(bottomContent, width);
|
|
1423
|
+
if (rawPromptLine.length % width === 0) content += "\n";
|
|
1424
|
+
let output = content + (bottomContent ? "\n" + bottomContent : "");
|
|
1425
|
+
const bottomContentHeight = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows + (bottomContent ? height(bottomContent) : 0);
|
|
1426
|
+
if (bottomContentHeight > 0) output += cursorUp(bottomContentHeight);
|
|
1427
|
+
output += cursorTo(this.cursorPos.cols);
|
|
1428
|
+
/**
|
|
1429
|
+
* Render and store state for future re-rendering
|
|
1430
|
+
*/
|
|
1431
|
+
this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
|
|
1432
|
+
this.extraLinesUnderPrompt = bottomContentHeight;
|
|
1433
|
+
this.height = height(output);
|
|
1434
|
+
}
|
|
1435
|
+
checkCursorPos() {
|
|
1436
|
+
const cursorPos = this.rl.getCursorPos();
|
|
1437
|
+
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
1438
|
+
this.write(cursorTo(cursorPos.cols));
|
|
1439
|
+
this.cursorPos = cursorPos;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
done({ clearContent }) {
|
|
1443
|
+
this.rl.setPrompt("");
|
|
1444
|
+
let output = cursorDown(this.extraLinesUnderPrompt);
|
|
1445
|
+
output += clearContent ? eraseLines(this.height) : "\n";
|
|
1446
|
+
output += "\x1B[G";
|
|
1447
|
+
output += cursorShow;
|
|
1448
|
+
this.write(output);
|
|
1449
|
+
this.rl.close();
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
|
|
1453
|
+
//#endregion
|
|
1454
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
1455
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
1456
|
+
const nativeSetImmediate = globalThis.setImmediate;
|
|
1457
|
+
/**
|
|
1458
|
+
* Register an event listener and return its disposer, so registrations collapse
|
|
1459
|
+
* into a single statement: `cleanups.add(listenTo(rl, 'close', handler))`.
|
|
1460
|
+
*/
|
|
1461
|
+
function listenTo(target, event, listener) {
|
|
1462
|
+
if ("on" in target) {
|
|
1463
|
+
target.on(event, listener);
|
|
1464
|
+
return () => target.removeListener(event, listener);
|
|
1465
|
+
}
|
|
1466
|
+
target.addEventListener(event, listener);
|
|
1467
|
+
return () => target.removeEventListener(event, listener);
|
|
1468
|
+
}
|
|
1469
|
+
function getCallSites() {
|
|
1470
|
+
const savedPrepareStackTrace = Error.prepareStackTrace;
|
|
1471
|
+
let result = [];
|
|
1472
|
+
try {
|
|
1473
|
+
Error.prepareStackTrace = (_, callSites) => {
|
|
1474
|
+
const callSitesWithoutCurrent = callSites.slice(1);
|
|
1475
|
+
result = callSitesWithoutCurrent;
|
|
1476
|
+
return callSitesWithoutCurrent;
|
|
1477
|
+
};
|
|
1478
|
+
(/* @__PURE__ */ new Error()).stack;
|
|
1479
|
+
} catch {
|
|
1480
|
+
return result;
|
|
1481
|
+
}
|
|
1482
|
+
Error.prepareStackTrace = savedPrepareStackTrace;
|
|
1483
|
+
return result;
|
|
1484
|
+
}
|
|
1485
|
+
function createPrompt(view) {
|
|
1486
|
+
const callSites = getCallSites();
|
|
1487
|
+
const prompt = (config, context = {}) => {
|
|
1488
|
+
const { input = process.stdin, signal } = context;
|
|
1489
|
+
const cleanups = /* @__PURE__ */ new Set();
|
|
1490
|
+
const output = new import_lib.default();
|
|
1491
|
+
output.pipe(context.output ?? process.stdout);
|
|
1492
|
+
const rl = readline.createInterface({
|
|
1493
|
+
terminal: true,
|
|
1494
|
+
input,
|
|
1495
|
+
output
|
|
1496
|
+
});
|
|
1497
|
+
output.mute();
|
|
1498
|
+
const screen = new ScreenManager(rl);
|
|
1499
|
+
const { promise, resolve, reject } = withResolver();
|
|
1500
|
+
return withHooks(rl, (cycle) => {
|
|
1501
|
+
const clearEffects = AsyncResource.bind(() => effectScheduler.clearAll());
|
|
1502
|
+
const settlePrompt = (settle) => {
|
|
1503
|
+
try {
|
|
1504
|
+
clearEffects();
|
|
1505
|
+
settle();
|
|
1506
|
+
} catch (error) {
|
|
1507
|
+
reject(error);
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
const resolvePrompt = (value) => settlePrompt(() => resolve(value));
|
|
1511
|
+
const rejectPrompt = (error) => settlePrompt(() => reject(error));
|
|
1512
|
+
const promptPromise = Object.assign(promise.finally(() => {
|
|
1513
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
1514
|
+
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
1515
|
+
output.end();
|
|
1516
|
+
}).then(() => promise), { cancel: () => rejectPrompt(new CancelPromptError()) });
|
|
1517
|
+
if (signal) {
|
|
1518
|
+
const abort = () => rejectPrompt(new AbortPromptError({ cause: signal.reason }));
|
|
1519
|
+
if (signal.aborted) {
|
|
1520
|
+
abort();
|
|
1521
|
+
return promptPromise;
|
|
1522
|
+
}
|
|
1523
|
+
cleanups.add(listenTo(signal, "abort", abort));
|
|
1524
|
+
}
|
|
1525
|
+
cleanups.add(onExit((code, signal) => {
|
|
1526
|
+
rejectPrompt(new ExitPromptError(`User force closed the prompt with ${code} ${signal}`));
|
|
1527
|
+
}));
|
|
1528
|
+
cleanups.add(listenTo(rl, "SIGINT", () => rejectPrompt(new ExitPromptError(`User force closed the prompt with SIGINT`))));
|
|
1529
|
+
cleanups.add(listenTo(rl, "close", clearEffects));
|
|
1530
|
+
const startCycle = () => {
|
|
1531
|
+
cleanups.add(listenTo(rl.input, "keypress", () => screen.checkCursorPos()));
|
|
1532
|
+
let pendingDone = null;
|
|
1533
|
+
cycle(() => {
|
|
1534
|
+
let effectsSettled = false;
|
|
1535
|
+
try {
|
|
1536
|
+
const nextView = view(config, (value) => {
|
|
1537
|
+
if (effectsSettled) resolvePrompt(value);
|
|
1538
|
+
else pendingDone = { value };
|
|
1539
|
+
});
|
|
1540
|
+
if (nextView === void 0) {
|
|
1541
|
+
let callerFilename = callSites[1]?.getFileName();
|
|
1542
|
+
if (callerFilename && !callerFilename.startsWith("file://")) callerFilename = path.resolve(callerFilename);
|
|
1543
|
+
throw new Error(`Prompt functions must return a string.\n at ${callerFilename}`);
|
|
1544
|
+
}
|
|
1545
|
+
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
1546
|
+
screen.render(content, bottomContent);
|
|
1547
|
+
effectScheduler.run();
|
|
1548
|
+
} catch (error) {
|
|
1549
|
+
rejectPrompt(error);
|
|
1550
|
+
}
|
|
1551
|
+
effectsSettled = true;
|
|
1552
|
+
if (pendingDone !== null) {
|
|
1553
|
+
const { value } = pendingDone;
|
|
1554
|
+
pendingDone = null;
|
|
1555
|
+
resolvePrompt(value);
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
};
|
|
1559
|
+
if ("readableFlowing" in input) nativeSetImmediate(startCycle);
|
|
1560
|
+
else startCycle();
|
|
1561
|
+
return promptPromise;
|
|
1562
|
+
});
|
|
1563
|
+
};
|
|
1564
|
+
return prompt;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
//#endregion
|
|
1568
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/Separator.js
|
|
1569
|
+
/**
|
|
1570
|
+
* Separator object
|
|
1571
|
+
* Used to space/separate choices group
|
|
1572
|
+
*/
|
|
1573
|
+
var Separator = class {
|
|
1574
|
+
separator = styleText("dim", Array.from({ length: 15 }).join(figures.line));
|
|
1575
|
+
type = "separator";
|
|
1576
|
+
constructor(separator) {
|
|
1577
|
+
if (separator) this.separator = separator;
|
|
1578
|
+
}
|
|
1579
|
+
static isSeparator(choice) {
|
|
1580
|
+
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
//#endregion
|
|
1585
|
+
//#region ../../node_modules/.pnpm/@inquirer+checkbox@5.2.6_@types+node@26.6.5/node_modules/@inquirer/checkbox/dist/index.js
|
|
1586
|
+
const checkboxTheme = {
|
|
1587
|
+
icon: {
|
|
1588
|
+
checked: styleText("green", figures.circleFilled),
|
|
1589
|
+
unchecked: figures.circle,
|
|
1590
|
+
cursor: figures.pointer,
|
|
1591
|
+
disabledChecked: styleText("green", figures.circleDouble),
|
|
1592
|
+
disabledUnchecked: "-"
|
|
1593
|
+
},
|
|
1594
|
+
style: {
|
|
1595
|
+
disabled: (text) => styleText("dim", text),
|
|
1596
|
+
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", "),
|
|
1597
|
+
description: (text) => styleText("cyan", text),
|
|
1598
|
+
keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText("bold", key)} ${styleText("dim", action)}`).join(styleText("dim", " • "))
|
|
1599
|
+
},
|
|
1600
|
+
i18n: { disabledError: "This option is disabled and cannot be toggled." }
|
|
1601
|
+
};
|
|
1602
|
+
function isSelectable$1(item) {
|
|
1603
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
|
1604
|
+
}
|
|
1605
|
+
function isNavigable$1(item) {
|
|
1606
|
+
return !Separator.isSeparator(item);
|
|
1607
|
+
}
|
|
1608
|
+
function isChecked(item) {
|
|
1609
|
+
return !Separator.isSeparator(item) && item.checked;
|
|
1610
|
+
}
|
|
1611
|
+
function toggle(item) {
|
|
1612
|
+
return isSelectable$1(item) ? {
|
|
1613
|
+
...item,
|
|
1614
|
+
checked: !item.checked
|
|
1615
|
+
} : item;
|
|
1616
|
+
}
|
|
1617
|
+
function check(checked) {
|
|
1618
|
+
return function(item) {
|
|
1619
|
+
return isSelectable$1(item) ? {
|
|
1620
|
+
...item,
|
|
1621
|
+
checked
|
|
1622
|
+
} : item;
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
function normalizeChoices$1(choices) {
|
|
1626
|
+
return choices.map((choice) => {
|
|
1627
|
+
if (Separator.isSeparator(choice)) return choice;
|
|
1628
|
+
if (typeof choice !== "object" || choice === null || !("value" in choice)) {
|
|
1629
|
+
const name = String(choice);
|
|
1630
|
+
return {
|
|
1631
|
+
value: choice,
|
|
1632
|
+
name,
|
|
1633
|
+
short: name,
|
|
1634
|
+
checkedName: name,
|
|
1635
|
+
disabled: false,
|
|
1636
|
+
checked: false
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
const name = choice.name ?? String(choice.value);
|
|
1640
|
+
const normalizedChoice = {
|
|
1641
|
+
value: choice.value,
|
|
1642
|
+
name,
|
|
1643
|
+
short: choice.short ?? name,
|
|
1644
|
+
checkedName: choice.checkedName ?? name,
|
|
1645
|
+
disabled: choice.disabled ?? false,
|
|
1646
|
+
checked: choice.checked ?? false
|
|
1647
|
+
};
|
|
1648
|
+
if (choice.description) normalizedChoice.description = choice.description;
|
|
1649
|
+
return normalizedChoice;
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
var dist_default$3 = createPrompt((config, done) => {
|
|
1653
|
+
const { pageSize = 7, loop = true, required, validate = () => true } = config;
|
|
1654
|
+
const shortcuts = {
|
|
1655
|
+
all: "a",
|
|
1656
|
+
invert: "i",
|
|
1657
|
+
...config.shortcuts
|
|
1658
|
+
};
|
|
1659
|
+
const theme = makeTheme(checkboxTheme, config.theme);
|
|
1660
|
+
const { keybindings } = theme;
|
|
1661
|
+
const [status, setStatus] = useState("idle");
|
|
1662
|
+
const prefix = usePrefix({
|
|
1663
|
+
status,
|
|
1664
|
+
theme
|
|
1665
|
+
});
|
|
1666
|
+
const [items, setItems] = useState(normalizeChoices$1(config.choices));
|
|
1667
|
+
const bounds = useMemo(() => {
|
|
1668
|
+
const first = items.findIndex(isNavigable$1);
|
|
1669
|
+
const last = items.findLastIndex(isNavigable$1);
|
|
1670
|
+
if (first === -1) throw new ValidationError("[checkbox prompt] No selectable choices. All choices are disabled.");
|
|
1671
|
+
return {
|
|
1672
|
+
first,
|
|
1673
|
+
last
|
|
1674
|
+
};
|
|
1675
|
+
}, [items]);
|
|
1676
|
+
const [active, setActive] = useState(bounds.first);
|
|
1677
|
+
const [errorMsg, setError] = useState();
|
|
1678
|
+
useKeypress(async (key) => {
|
|
1679
|
+
if (isEnterKey(key)) {
|
|
1680
|
+
const selection = items.filter(isChecked);
|
|
1681
|
+
const isValid = await validate([...selection]);
|
|
1682
|
+
if (required && !selection.length) setError("At least one choice must be selected");
|
|
1683
|
+
else if (isValid === true) {
|
|
1684
|
+
setStatus("done");
|
|
1685
|
+
done(selection.map((choice) => choice.value));
|
|
1686
|
+
} else setError(isValid || "You must select a valid value");
|
|
1687
|
+
} else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
|
|
1688
|
+
if (errorMsg) setError(void 0);
|
|
1689
|
+
if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
|
|
1690
|
+
const offset = isUpKey(key, keybindings) ? -1 : 1;
|
|
1691
|
+
let next = active;
|
|
1692
|
+
do
|
|
1693
|
+
next = (next + offset + items.length) % items.length;
|
|
1694
|
+
while (!isNavigable$1(items[next]));
|
|
1695
|
+
setActive(next);
|
|
1696
|
+
}
|
|
1697
|
+
} else if (isSpaceKey(key)) {
|
|
1698
|
+
const activeItem = items[active];
|
|
1699
|
+
if (activeItem && !Separator.isSeparator(activeItem)) {
|
|
1700
|
+
if (activeItem.disabled) setError(theme.i18n.disabledError);
|
|
1701
|
+
else {
|
|
1702
|
+
setError(void 0);
|
|
1703
|
+
setItems(items.map((choice, i) => i === active ? toggle(choice) : choice));
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
} else if (key.name === shortcuts.all) {
|
|
1707
|
+
const selectAll = items.some((choice) => isSelectable$1(choice) && !choice.checked);
|
|
1708
|
+
setItems(items.map(check(selectAll)));
|
|
1709
|
+
} else if (key.name === shortcuts.invert) setItems(items.map(toggle));
|
|
1710
|
+
else if (isNumberKey(key)) {
|
|
1711
|
+
const selectedIndex = Number(key.name) - 1;
|
|
1712
|
+
let selectableIndex = -1;
|
|
1713
|
+
const position = items.findIndex((item) => {
|
|
1714
|
+
if (Separator.isSeparator(item)) return false;
|
|
1715
|
+
selectableIndex++;
|
|
1716
|
+
return selectableIndex === selectedIndex;
|
|
1717
|
+
});
|
|
1718
|
+
const selectedItem = items[position];
|
|
1719
|
+
if (selectedItem && isSelectable$1(selectedItem)) {
|
|
1720
|
+
setActive(position);
|
|
1721
|
+
setItems(items.map((choice, i) => i === position ? toggle(choice) : choice));
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
const message = theme.style.message(config.message, status);
|
|
1726
|
+
let description;
|
|
1727
|
+
const page = usePagination({
|
|
1728
|
+
items,
|
|
1729
|
+
active,
|
|
1730
|
+
renderItem({ item, isActive }) {
|
|
1731
|
+
if (Separator.isSeparator(item)) return ` ${item.separator}`;
|
|
1732
|
+
const cursor = isActive ? theme.icon.cursor : " ";
|
|
1733
|
+
if (item.disabled) {
|
|
1734
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
1735
|
+
const checkbox = item.checked ? theme.icon.disabledChecked : theme.icon.disabledUnchecked;
|
|
1736
|
+
return theme.style.disabled(`${cursor}${checkbox} ${item.name} ${disabledLabel}`);
|
|
1737
|
+
}
|
|
1738
|
+
if (isActive) description = item.description;
|
|
1739
|
+
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
|
1740
|
+
const name = item.checked ? item.checkedName : item.name;
|
|
1741
|
+
return (isActive ? theme.style.highlight : (x) => x)(`${cursor}${checkbox} ${name}`);
|
|
1742
|
+
},
|
|
1743
|
+
pageSize,
|
|
1744
|
+
loop
|
|
1745
|
+
});
|
|
1746
|
+
if (status === "done") {
|
|
1747
|
+
const selection = items.filter(isChecked);
|
|
1748
|
+
return [
|
|
1749
|
+
prefix,
|
|
1750
|
+
message,
|
|
1751
|
+
theme.style.answer(theme.style.renderSelectedChoices(selection, items))
|
|
1752
|
+
].filter(Boolean).join(" ");
|
|
1753
|
+
}
|
|
1754
|
+
const keys = [["↑↓", "navigate"], ["space", "select"]];
|
|
1755
|
+
if (shortcuts.all) keys.push([shortcuts.all, "all"]);
|
|
1756
|
+
if (shortcuts.invert) keys.push([shortcuts.invert, "invert"]);
|
|
1757
|
+
keys.push(["⏎", "submit"]);
|
|
1758
|
+
const helpLine = theme.style.keysHelpTip(keys);
|
|
1759
|
+
return `${[
|
|
1760
|
+
[prefix, message].filter(Boolean).join(" "),
|
|
1761
|
+
page,
|
|
1762
|
+
" ",
|
|
1763
|
+
description ? theme.style.description(description) : "",
|
|
1764
|
+
errorMsg ? theme.style.error(errorMsg) : "",
|
|
1765
|
+
helpLine
|
|
1766
|
+
].filter(Boolean).join("\n").trimEnd()}${cursorHide}`;
|
|
1767
|
+
});
|
|
1768
|
+
|
|
1769
|
+
//#endregion
|
|
1770
|
+
//#region ../../node_modules/.pnpm/@inquirer+confirm@6.3.3_@types+node@26.6.5/node_modules/@inquirer/confirm/dist/index.js
|
|
1771
|
+
const confirmTheme = {
|
|
1772
|
+
keywords: {
|
|
1773
|
+
yes: "Yes",
|
|
1774
|
+
no: "No",
|
|
1775
|
+
error: ({ yes, no }) => `You must answer with "${yes}" or "${no}"`
|
|
1776
|
+
},
|
|
1777
|
+
style: { confirmDefault: (text) => {
|
|
1778
|
+
const first = text[0] ?? "";
|
|
1779
|
+
if (first.toLowerCase() === first.toUpperCase()) return styleText("cyan", text);
|
|
1780
|
+
return first.toUpperCase() + text.slice(1);
|
|
1781
|
+
} }
|
|
1782
|
+
};
|
|
1783
|
+
var dist_default$2 = createPrompt((config, done) => {
|
|
1784
|
+
const [status, setStatus] = useState("idle");
|
|
1785
|
+
const [value, setValue] = useState("");
|
|
1786
|
+
const [errorMsg, setError] = useState();
|
|
1787
|
+
const theme = makeTheme(confirmTheme, config.theme);
|
|
1788
|
+
const prefix = usePrefix({
|
|
1789
|
+
status,
|
|
1790
|
+
theme
|
|
1791
|
+
});
|
|
1792
|
+
const { yes, no } = theme.keywords;
|
|
1793
|
+
const yesHint = (yes[0] ?? "").toLowerCase();
|
|
1794
|
+
const noHint = (no[0] ?? "").toLowerCase();
|
|
1795
|
+
const hint = config.default === false ? `${yesHint}/${theme.style.confirmDefault(noHint)}` : `${theme.style.confirmDefault(yesHint)}/${noHint}`;
|
|
1796
|
+
function boolToString(value) {
|
|
1797
|
+
return value ? yes : no;
|
|
1798
|
+
}
|
|
1799
|
+
const { transformer = boolToString } = config;
|
|
1800
|
+
function getBooleanValue(value) {
|
|
1801
|
+
const v = value.trim().toLowerCase();
|
|
1802
|
+
if (v === "") return config.default !== false;
|
|
1803
|
+
if (yes.toLowerCase().startsWith(v)) return true;
|
|
1804
|
+
if (no.toLowerCase().startsWith(v)) return false;
|
|
1805
|
+
if ("yes".startsWith(v)) return true;
|
|
1806
|
+
if ("no".startsWith(v)) return false;
|
|
1807
|
+
}
|
|
1808
|
+
useKeypress((key, rl) => {
|
|
1809
|
+
if (status !== "idle") return;
|
|
1810
|
+
if (isEnterKey(key)) {
|
|
1811
|
+
const answer = getBooleanValue(value);
|
|
1812
|
+
if (answer === void 0) {
|
|
1813
|
+
rl.write(value);
|
|
1814
|
+
setError(theme.keywords.error({
|
|
1815
|
+
yes,
|
|
1816
|
+
no
|
|
1817
|
+
}));
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
setValue(transformer(answer));
|
|
1821
|
+
setStatus("done");
|
|
1822
|
+
done(answer);
|
|
1823
|
+
} else if (isTabKey(key)) {
|
|
1824
|
+
const answer = boolToString(!(getBooleanValue(value) ?? config.default !== false));
|
|
1825
|
+
rl.clearLine(0);
|
|
1826
|
+
rl.write(answer);
|
|
1827
|
+
setValue(answer);
|
|
1828
|
+
} else {
|
|
1829
|
+
setValue(rl.line);
|
|
1830
|
+
setError(void 0);
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
let formattedValue = value;
|
|
1834
|
+
let defaultValue = "";
|
|
1835
|
+
if (status === "done") formattedValue = theme.style.answer(value);
|
|
1836
|
+
else defaultValue = ` ${theme.style.defaultAnswer(hint)}`;
|
|
1837
|
+
const message = theme.style.message(config.message, status);
|
|
1838
|
+
let error = "";
|
|
1839
|
+
if (errorMsg) error = theme.style.error(errorMsg);
|
|
1840
|
+
return [`${prefix} ${message}${defaultValue} ${formattedValue}`, error];
|
|
1841
|
+
});
|
|
1842
|
+
|
|
1843
|
+
//#endregion
|
|
1844
|
+
//#region ../../node_modules/.pnpm/@inquirer+input@5.1.7_@types+node@26.6.5/node_modules/@inquirer/input/dist/index.js
|
|
1845
|
+
const inputTheme = { validationFailureMode: "keep" };
|
|
1846
|
+
var dist_default$1 = createPrompt((config, done) => {
|
|
1847
|
+
const { prefill = "tab" } = config;
|
|
1848
|
+
const theme = makeTheme(inputTheme, config.theme);
|
|
1849
|
+
const [status, setStatus] = useState("idle");
|
|
1850
|
+
const [defaultValue, setDefaultValue] = useState(String(config.default ?? ""));
|
|
1851
|
+
const [errorMsg, setError] = useState();
|
|
1852
|
+
const [value, setValue] = useState("");
|
|
1853
|
+
const prefix = usePrefix({
|
|
1854
|
+
status,
|
|
1855
|
+
theme
|
|
1856
|
+
});
|
|
1857
|
+
async function validate(value) {
|
|
1858
|
+
const { required, pattern, patternError = "Invalid input" } = config;
|
|
1859
|
+
if (required && !value) return "You must provide a value";
|
|
1860
|
+
if (pattern && !pattern.test(value)) return patternError;
|
|
1861
|
+
if (typeof config.validate === "function") return await config.validate(value) || "You must provide a valid value";
|
|
1862
|
+
return true;
|
|
1863
|
+
}
|
|
1864
|
+
useKeypress(async (key, rl) => {
|
|
1865
|
+
if (status !== "idle") return;
|
|
1866
|
+
if (isEnterKey(key)) {
|
|
1867
|
+
const answer = value || defaultValue;
|
|
1868
|
+
setStatus("loading");
|
|
1869
|
+
const isValid = await validate(answer);
|
|
1870
|
+
if (isValid === true) {
|
|
1871
|
+
setValue(answer);
|
|
1872
|
+
setStatus("done");
|
|
1873
|
+
done(answer);
|
|
1874
|
+
} else {
|
|
1875
|
+
if (theme.validationFailureMode === "clear") setValue("");
|
|
1876
|
+
else rl.write(value);
|
|
1877
|
+
setError(isValid);
|
|
1878
|
+
setStatus("idle");
|
|
1879
|
+
}
|
|
1880
|
+
} else if (isBackspaceKey(key) && !value) setDefaultValue("");
|
|
1881
|
+
else if (isTabKey(key) && !value) {
|
|
1882
|
+
setDefaultValue("");
|
|
1883
|
+
rl.clearLine(0);
|
|
1884
|
+
rl.write(defaultValue);
|
|
1885
|
+
setValue(defaultValue);
|
|
1886
|
+
} else {
|
|
1887
|
+
setValue(rl.line);
|
|
1888
|
+
setError(void 0);
|
|
1889
|
+
}
|
|
1890
|
+
});
|
|
1891
|
+
useEffect((rl) => {
|
|
1892
|
+
if (prefill === "editable" && defaultValue) {
|
|
1893
|
+
rl.write(defaultValue);
|
|
1894
|
+
setValue(defaultValue);
|
|
1895
|
+
}
|
|
1896
|
+
}, []);
|
|
1897
|
+
const message = theme.style.message(config.message, status);
|
|
1898
|
+
let formattedValue = value;
|
|
1899
|
+
if (typeof config.transformer === "function") formattedValue = config.transformer(value, { isFinal: status === "done" });
|
|
1900
|
+
else if (status === "done") formattedValue = theme.style.answer(value);
|
|
1901
|
+
let defaultStr;
|
|
1902
|
+
if (defaultValue && status !== "done" && !value) defaultStr = theme.style.defaultAnswer(defaultValue);
|
|
1903
|
+
let error = "";
|
|
1904
|
+
if (errorMsg) error = theme.style.error(errorMsg);
|
|
1905
|
+
return [[
|
|
1906
|
+
prefix,
|
|
1907
|
+
message,
|
|
1908
|
+
defaultStr,
|
|
1909
|
+
formattedValue
|
|
1910
|
+
].filter((v) => v !== void 0).join(" "), error];
|
|
1911
|
+
});
|
|
1912
|
+
|
|
1913
|
+
//#endregion
|
|
1914
|
+
//#region ../../node_modules/.pnpm/@inquirer+select@5.2.6_@types+node@26.6.5/node_modules/@inquirer/select/dist/index.js
|
|
1915
|
+
const selectTheme = {
|
|
1916
|
+
icon: { cursor: figures.pointer },
|
|
1917
|
+
style: {
|
|
1918
|
+
disabled: (text) => styleText("dim", text),
|
|
1919
|
+
description: (text) => styleText("cyan", text),
|
|
1920
|
+
keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText("bold", key)} ${styleText("dim", action)}`).join(styleText("dim", " • "))
|
|
1921
|
+
},
|
|
1922
|
+
i18n: { disabledError: "This option is disabled and cannot be selected." },
|
|
1923
|
+
indexMode: "hidden"
|
|
1924
|
+
};
|
|
1925
|
+
function isSelectable(item) {
|
|
1926
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
|
1927
|
+
}
|
|
1928
|
+
function isNavigable(item) {
|
|
1929
|
+
return !Separator.isSeparator(item);
|
|
1930
|
+
}
|
|
1931
|
+
function normalizeChoices(choices) {
|
|
1932
|
+
return choices.map((choice) => {
|
|
1933
|
+
if (Separator.isSeparator(choice)) return choice;
|
|
1934
|
+
if (typeof choice !== "object" || choice === null || !("value" in choice)) {
|
|
1935
|
+
const name = String(choice);
|
|
1936
|
+
return {
|
|
1937
|
+
value: choice,
|
|
1938
|
+
name,
|
|
1939
|
+
short: name,
|
|
1940
|
+
disabled: false
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
const name = choice.name ?? String(choice.value);
|
|
1944
|
+
const normalizedChoice = {
|
|
1945
|
+
value: choice.value,
|
|
1946
|
+
name,
|
|
1947
|
+
short: choice.short ?? name,
|
|
1948
|
+
disabled: choice.disabled ?? false
|
|
1949
|
+
};
|
|
1950
|
+
if (choice.description) normalizedChoice.description = choice.description;
|
|
1951
|
+
return normalizedChoice;
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
var dist_default = createPrompt((config, done) => {
|
|
1955
|
+
const { loop = true, pageSize = 7 } = config;
|
|
1956
|
+
const theme = makeTheme(selectTheme, config.theme);
|
|
1957
|
+
const { keybindings } = theme;
|
|
1958
|
+
const [status, setStatus] = useState("idle");
|
|
1959
|
+
const prefix = usePrefix({
|
|
1960
|
+
status,
|
|
1961
|
+
theme
|
|
1962
|
+
});
|
|
1963
|
+
const searchTimeoutRef = useRef();
|
|
1964
|
+
const searchEnabled = !keybindings.includes("vim");
|
|
1965
|
+
const items = useMemo(() => normalizeChoices(config.choices), [config.choices]);
|
|
1966
|
+
const bounds = useMemo(() => {
|
|
1967
|
+
const first = items.findIndex(isNavigable);
|
|
1968
|
+
const last = items.findLastIndex(isNavigable);
|
|
1969
|
+
if (first === -1) throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
|
|
1970
|
+
return {
|
|
1971
|
+
first,
|
|
1972
|
+
last
|
|
1973
|
+
};
|
|
1974
|
+
}, [items]);
|
|
1975
|
+
const defaultItemIndex = useMemo(() => {
|
|
1976
|
+
if (!("default" in config)) return -1;
|
|
1977
|
+
return items.findIndex((item) => isSelectable(item) && item.value === config.default);
|
|
1978
|
+
}, [config.default, items]);
|
|
1979
|
+
const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
|
|
1980
|
+
const selectedChoice = items[active];
|
|
1981
|
+
if (selectedChoice == null || Separator.isSeparator(selectedChoice)) throw new Error("Active index does not point to a choice");
|
|
1982
|
+
const [errorMsg, setError] = useState();
|
|
1983
|
+
useKeypress((key, rl) => {
|
|
1984
|
+
clearTimeout(searchTimeoutRef.current);
|
|
1985
|
+
if (errorMsg) setError(void 0);
|
|
1986
|
+
if (isEnterKey(key)) {
|
|
1987
|
+
if (selectedChoice.disabled) setError(theme.i18n.disabledError);
|
|
1988
|
+
else {
|
|
1989
|
+
setStatus("done");
|
|
1990
|
+
done(selectedChoice.value);
|
|
1991
|
+
}
|
|
1992
|
+
} else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
|
|
1993
|
+
rl.clearLine(0);
|
|
1994
|
+
if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
|
|
1995
|
+
const offset = isUpKey(key, keybindings) ? -1 : 1;
|
|
1996
|
+
let next = active;
|
|
1997
|
+
do
|
|
1998
|
+
next = (next + offset + items.length) % items.length;
|
|
1999
|
+
while (!isNavigable(items[next]));
|
|
2000
|
+
setActive(next);
|
|
2001
|
+
}
|
|
2002
|
+
} else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
|
|
2003
|
+
const selectedIndex = Number(rl.line) - 1;
|
|
2004
|
+
let selectableIndex = -1;
|
|
2005
|
+
const position = items.findIndex((item) => {
|
|
2006
|
+
if (Separator.isSeparator(item)) return false;
|
|
2007
|
+
selectableIndex++;
|
|
2008
|
+
return selectableIndex === selectedIndex;
|
|
2009
|
+
});
|
|
2010
|
+
const item = items[position];
|
|
2011
|
+
if (item != null && isSelectable(item)) setActive(position);
|
|
2012
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
2013
|
+
rl.clearLine(0);
|
|
2014
|
+
}, 700);
|
|
2015
|
+
} else if (isBackspaceKey(key)) rl.clearLine(0);
|
|
2016
|
+
else if (searchEnabled) {
|
|
2017
|
+
const searchTerm = rl.line.toLowerCase();
|
|
2018
|
+
const matchIndex = items.findIndex((item) => {
|
|
2019
|
+
if (Separator.isSeparator(item) || !isSelectable(item)) return false;
|
|
2020
|
+
return item.name.toLowerCase().startsWith(searchTerm);
|
|
2021
|
+
});
|
|
2022
|
+
if (matchIndex !== -1) setActive(matchIndex);
|
|
2023
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
2024
|
+
rl.clearLine(0);
|
|
2025
|
+
}, 700);
|
|
2026
|
+
}
|
|
2027
|
+
});
|
|
2028
|
+
useEffect(() => () => {
|
|
2029
|
+
clearTimeout(searchTimeoutRef.current);
|
|
2030
|
+
}, []);
|
|
2031
|
+
const message = theme.style.message(config.message, status);
|
|
2032
|
+
const helpLine = theme.style.keysHelpTip([["↑↓", "navigate"], ["⏎", "select"]]);
|
|
2033
|
+
let separatorCount = 0;
|
|
2034
|
+
const page = usePagination({
|
|
2035
|
+
items,
|
|
2036
|
+
active,
|
|
2037
|
+
renderItem({ item, isActive, index }) {
|
|
2038
|
+
if (Separator.isSeparator(item)) {
|
|
2039
|
+
separatorCount++;
|
|
2040
|
+
return ` ${item.separator}`;
|
|
2041
|
+
}
|
|
2042
|
+
const cursor = isActive ? theme.icon.cursor : " ";
|
|
2043
|
+
const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
|
|
2044
|
+
if (item.disabled) {
|
|
2045
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
2046
|
+
const disabledCursor = isActive ? theme.icon.cursor : "-";
|
|
2047
|
+
return theme.style.disabled(`${disabledCursor} ${indexLabel}${item.name} ${disabledLabel}`);
|
|
2048
|
+
}
|
|
2049
|
+
return (isActive ? theme.style.highlight : (x) => x)(`${cursor} ${indexLabel}${item.name}`);
|
|
2050
|
+
},
|
|
2051
|
+
pageSize,
|
|
2052
|
+
loop
|
|
2053
|
+
});
|
|
2054
|
+
if (status === "done") return [
|
|
2055
|
+
prefix,
|
|
2056
|
+
message,
|
|
2057
|
+
theme.style.answer(selectedChoice.short)
|
|
2058
|
+
].filter(Boolean).join(" ");
|
|
2059
|
+
const { description } = selectedChoice;
|
|
2060
|
+
return `${[
|
|
2061
|
+
[prefix, message].filter(Boolean).join(" "),
|
|
2062
|
+
page,
|
|
2063
|
+
" ",
|
|
2064
|
+
description ? theme.style.description(description) : "",
|
|
2065
|
+
errorMsg ? theme.style.error(errorMsg) : "",
|
|
2066
|
+
helpLine
|
|
2067
|
+
].filter(Boolean).join("\n").trimEnd()}${cursorHide}`;
|
|
2068
|
+
});
|
|
2069
|
+
|
|
2070
|
+
//#endregion
|
|
2071
|
+
//#region src/cli/init/repl.ts
|
|
2072
|
+
function validPort(v) {
|
|
2073
|
+
try {
|
|
2074
|
+
parsePort("port", v);
|
|
2075
|
+
return true;
|
|
2076
|
+
} catch (err) {
|
|
2077
|
+
return err.message;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
async function runRepl(seed) {
|
|
2081
|
+
process.stdout.write("substrate init — interactive setup. Ctrl-C to abort.\n\n");
|
|
2082
|
+
const targetDir = seed.targetDir ?? await dist_default$1({
|
|
2083
|
+
message: "Target directory:",
|
|
2084
|
+
default: "./substrate-runtime",
|
|
2085
|
+
validate: (v) => v.length > 0 || "required"
|
|
2086
|
+
});
|
|
2087
|
+
let plugins;
|
|
2088
|
+
if (seed.plugins !== void 0) plugins = [...seed.plugins];
|
|
2089
|
+
else {
|
|
2090
|
+
const persona = await dist_default({
|
|
2091
|
+
message: "Plugin set:",
|
|
2092
|
+
choices: [
|
|
2093
|
+
{
|
|
2094
|
+
name: "minimal — no app plugins (the bundled ones only)",
|
|
2095
|
+
value: "minimal"
|
|
2096
|
+
},
|
|
2097
|
+
{
|
|
2098
|
+
name: "agent-context — cortext, an agent coordination store",
|
|
2099
|
+
value: "agent-context"
|
|
2100
|
+
},
|
|
2101
|
+
{
|
|
2102
|
+
name: "full — every known mnmal-ai plugin",
|
|
2103
|
+
value: "full"
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
name: "custom — pick individually",
|
|
2107
|
+
value: "custom"
|
|
2108
|
+
}
|
|
2109
|
+
]
|
|
2110
|
+
});
|
|
2111
|
+
if (persona === "custom") {
|
|
2112
|
+
plugins = await dist_default$3({
|
|
2113
|
+
message: "Plugins to install:",
|
|
2114
|
+
choices: KNOWN_PLUGINS.map((p) => ({
|
|
2115
|
+
name: `${p.name} — ${p.description}`,
|
|
2116
|
+
value: p.name,
|
|
2117
|
+
checked: false
|
|
2118
|
+
}))
|
|
2119
|
+
});
|
|
2120
|
+
const extra = await dist_default$1({
|
|
2121
|
+
message: "Additional plugins (csv of npm names, blank for none):",
|
|
2122
|
+
default: ""
|
|
2123
|
+
});
|
|
2124
|
+
if (extra.trim().length > 0) plugins.push(...extra.split(",").map((s) => s.trim()).filter(Boolean));
|
|
2125
|
+
} else plugins = [...defaultPluginsForPersona(persona)];
|
|
2126
|
+
}
|
|
2127
|
+
const store = seed.store ?? await dist_default({
|
|
2128
|
+
message: "Storage backend:",
|
|
2129
|
+
choices: [{
|
|
2130
|
+
name: "postgres — bundled compose (recommended)",
|
|
2131
|
+
value: "postgres"
|
|
2132
|
+
}, {
|
|
2133
|
+
name: "memory — ephemeral, data vanishes on restart",
|
|
2134
|
+
value: "memory"
|
|
2135
|
+
}]
|
|
2136
|
+
});
|
|
2137
|
+
const port = seed.port ?? parsePort("port", await dist_default$1({
|
|
2138
|
+
message: "Listen port:",
|
|
2139
|
+
default: "3100",
|
|
2140
|
+
validate: (v) => validPort(v)
|
|
2141
|
+
}));
|
|
2142
|
+
const pgPort = seed.pgPort ?? parsePort("pg-port", await dist_default$1({
|
|
2143
|
+
message: "Postgres port (host-side):",
|
|
2144
|
+
default: "5433",
|
|
2145
|
+
validate: (v) => validPort(v)
|
|
2146
|
+
}));
|
|
2147
|
+
const embedder = seed.embedder ?? await dist_default({
|
|
2148
|
+
message: "Semantic recall embedder:",
|
|
2149
|
+
default: "minilm",
|
|
2150
|
+
choices: [
|
|
2151
|
+
{
|
|
2152
|
+
name: "minilm — all-MiniLM-L6-v2, in-process (recommended)",
|
|
2153
|
+
value: "minilm"
|
|
2154
|
+
},
|
|
2155
|
+
{
|
|
2156
|
+
name: "bge-base — bge-base-en-v1.5, in-process, slower and stronger",
|
|
2157
|
+
value: "bge-base"
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
name: "ollama — bge-m3 via local Ollama",
|
|
2161
|
+
value: "ollama"
|
|
2162
|
+
},
|
|
2163
|
+
{
|
|
2164
|
+
name: "none — no semantic recall",
|
|
2165
|
+
value: "none"
|
|
2166
|
+
}
|
|
2167
|
+
]
|
|
2168
|
+
});
|
|
2169
|
+
const tls = seed.tls || await dist_default$2({
|
|
2170
|
+
message: "Terminate TLS in the binary (HTTPS)?",
|
|
2171
|
+
default: false
|
|
2172
|
+
});
|
|
2173
|
+
let tlsCertPath;
|
|
2174
|
+
let tlsKeyPath;
|
|
2175
|
+
if (tls) {
|
|
2176
|
+
tlsCertPath = seed.tlsCertPath ?? await dist_default$1({
|
|
2177
|
+
message: "TLS cert path (PEM):",
|
|
2178
|
+
default: `${process.env.HOME ?? "~"}/.substrate/certs/fullchain.pem`,
|
|
2179
|
+
validate: (v) => v.length > 0 || "required"
|
|
2180
|
+
});
|
|
2181
|
+
tlsKeyPath = seed.tlsKeyPath ?? await dist_default$1({
|
|
2182
|
+
message: "TLS key path (PEM):",
|
|
2183
|
+
default: `${process.env.HOME ?? "~"}/.substrate/certs/privkey.pem`,
|
|
2184
|
+
validate: (v) => v.length > 0 || "required"
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
const substrateUrl = seed.substrateUrl ?? await dist_default$1({
|
|
2188
|
+
message: "Public URL clients (MCP/CLI) use to reach this instance:",
|
|
2189
|
+
default: `${tls ? "https" : "http"}://localhost:${port}`,
|
|
2190
|
+
validate: (v) => v.length > 0 || "required"
|
|
2191
|
+
});
|
|
2192
|
+
const force = seed.force || await dist_default$2({
|
|
2193
|
+
message: `Scaffold to ${targetDir}? (Will refuse if it already exists unless you confirm overwrite.)`,
|
|
2194
|
+
default: true
|
|
2195
|
+
});
|
|
2196
|
+
return {
|
|
2197
|
+
targetDir,
|
|
2198
|
+
store,
|
|
2199
|
+
port,
|
|
2200
|
+
pgPort,
|
|
2201
|
+
plugins,
|
|
2202
|
+
embedder,
|
|
2203
|
+
substrateUrl,
|
|
2204
|
+
tls,
|
|
2205
|
+
tlsCertPath,
|
|
2206
|
+
tlsKeyPath,
|
|
2207
|
+
yes: true,
|
|
2208
|
+
force
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
//#endregion
|
|
2213
|
+
export { runRepl };
|