@openacp/cli 0.2.4 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-I6KXISAR.js +1481 -0
- package/dist/chunk-I6KXISAR.js.map +1 -0
- package/dist/{chunk-M5ZYTPZY.js → chunk-KADEDKIM.js} +4 -4
- package/dist/chunk-KADEDKIM.js.map +1 -0
- package/dist/cli.js +3 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/dist/{main-GIN2OHQV.js → main-L5JD5STD.js} +8 -17
- package/dist/main-L5JD5STD.js.map +1 -0
- package/dist/setup-2UVU4YYA.js +284 -0
- package/dist/setup-2UVU4YYA.js.map +1 -0
- package/package.json +3 -3
- package/dist/chunk-6YLIH7L5.js +0 -669
- package/dist/chunk-6YLIH7L5.js.map +0 -1
- package/dist/chunk-LZOMFHX3.js +0 -38
- package/dist/chunk-LZOMFHX3.js.map +0 -1
- package/dist/chunk-M5ZYTPZY.js.map +0 -1
- package/dist/main-GIN2OHQV.js.map +0 -1
- package/dist/setup-KOMX6WTE.js +0 -2200
- package/dist/setup-KOMX6WTE.js.map +0 -1
package/dist/setup-KOMX6WTE.js
DELETED
|
@@ -1,2200 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS,
|
|
3
|
-
__require,
|
|
4
|
-
__toESM
|
|
5
|
-
} from "./chunk-LZOMFHX3.js";
|
|
6
|
-
|
|
7
|
-
// node_modules/.pnpm/cli-width@4.1.0/node_modules/cli-width/index.js
|
|
8
|
-
var require_cli_width = __commonJS({
|
|
9
|
-
"node_modules/.pnpm/cli-width@4.1.0/node_modules/cli-width/index.js"(exports, module) {
|
|
10
|
-
"use strict";
|
|
11
|
-
module.exports = cliWidth2;
|
|
12
|
-
function normalizeOpts(options) {
|
|
13
|
-
const defaultOpts = {
|
|
14
|
-
defaultWidth: 0,
|
|
15
|
-
output: process.stdout,
|
|
16
|
-
tty: __require("tty")
|
|
17
|
-
};
|
|
18
|
-
if (!options) {
|
|
19
|
-
return defaultOpts;
|
|
20
|
-
}
|
|
21
|
-
Object.keys(defaultOpts).forEach(function(key) {
|
|
22
|
-
if (!options[key]) {
|
|
23
|
-
options[key] = defaultOpts[key];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return options;
|
|
27
|
-
}
|
|
28
|
-
function cliWidth2(options) {
|
|
29
|
-
const opts = normalizeOpts(options);
|
|
30
|
-
if (opts.output.getWindowSize) {
|
|
31
|
-
return opts.output.getWindowSize()[0] || opts.defaultWidth;
|
|
32
|
-
}
|
|
33
|
-
if (opts.tty.getWindowSize) {
|
|
34
|
-
return opts.tty.getWindowSize()[1] || opts.defaultWidth;
|
|
35
|
-
}
|
|
36
|
-
if (opts.output.columns) {
|
|
37
|
-
return opts.output.columns;
|
|
38
|
-
}
|
|
39
|
-
if (process.env.CLI_WIDTH) {
|
|
40
|
-
const width = parseInt(process.env.CLI_WIDTH, 10);
|
|
41
|
-
if (!isNaN(width) && width !== 0) {
|
|
42
|
-
return width;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return opts.defaultWidth;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// node_modules/.pnpm/mute-stream@3.0.0/node_modules/mute-stream/lib/index.js
|
|
51
|
-
var require_lib = __commonJS({
|
|
52
|
-
"node_modules/.pnpm/mute-stream@3.0.0/node_modules/mute-stream/lib/index.js"(exports, module) {
|
|
53
|
-
var Stream = __require("stream");
|
|
54
|
-
var MuteStream2 = class extends Stream {
|
|
55
|
-
#isTTY = null;
|
|
56
|
-
constructor(opts = {}) {
|
|
57
|
-
super(opts);
|
|
58
|
-
this.writable = this.readable = true;
|
|
59
|
-
this.muted = false;
|
|
60
|
-
this.on("pipe", this._onpipe);
|
|
61
|
-
this.replace = opts.replace;
|
|
62
|
-
this._prompt = opts.prompt || null;
|
|
63
|
-
this._hadControl = false;
|
|
64
|
-
}
|
|
65
|
-
#destSrc(key, def) {
|
|
66
|
-
if (this._dest) {
|
|
67
|
-
return this._dest[key];
|
|
68
|
-
}
|
|
69
|
-
if (this._src) {
|
|
70
|
-
return this._src[key];
|
|
71
|
-
}
|
|
72
|
-
return def;
|
|
73
|
-
}
|
|
74
|
-
#proxy(method, ...args) {
|
|
75
|
-
if (typeof this._dest?.[method] === "function") {
|
|
76
|
-
this._dest[method](...args);
|
|
77
|
-
}
|
|
78
|
-
if (typeof this._src?.[method] === "function") {
|
|
79
|
-
this._src[method](...args);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
get isTTY() {
|
|
83
|
-
if (this.#isTTY !== null) {
|
|
84
|
-
return this.#isTTY;
|
|
85
|
-
}
|
|
86
|
-
return this.#destSrc("isTTY", false);
|
|
87
|
-
}
|
|
88
|
-
// basically just get replace the getter/setter with a regular value
|
|
89
|
-
set isTTY(val) {
|
|
90
|
-
this.#isTTY = val;
|
|
91
|
-
}
|
|
92
|
-
get rows() {
|
|
93
|
-
return this.#destSrc("rows");
|
|
94
|
-
}
|
|
95
|
-
get columns() {
|
|
96
|
-
return this.#destSrc("columns");
|
|
97
|
-
}
|
|
98
|
-
mute() {
|
|
99
|
-
this.muted = true;
|
|
100
|
-
}
|
|
101
|
-
unmute() {
|
|
102
|
-
this.muted = false;
|
|
103
|
-
}
|
|
104
|
-
_onpipe(src) {
|
|
105
|
-
this._src = src;
|
|
106
|
-
}
|
|
107
|
-
pipe(dest, options) {
|
|
108
|
-
this._dest = dest;
|
|
109
|
-
return super.pipe(dest, options);
|
|
110
|
-
}
|
|
111
|
-
pause() {
|
|
112
|
-
if (this._src) {
|
|
113
|
-
return this._src.pause();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
resume() {
|
|
117
|
-
if (this._src) {
|
|
118
|
-
return this._src.resume();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
write(c) {
|
|
122
|
-
if (this.muted) {
|
|
123
|
-
if (!this.replace) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
if (c.match(/^\u001b/)) {
|
|
127
|
-
if (c.indexOf(this._prompt) === 0) {
|
|
128
|
-
c = c.slice(this._prompt.length);
|
|
129
|
-
c = c.replace(/./g, this.replace);
|
|
130
|
-
c = this._prompt + c;
|
|
131
|
-
}
|
|
132
|
-
this._hadControl = true;
|
|
133
|
-
return this.emit("data", c);
|
|
134
|
-
} else {
|
|
135
|
-
if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
|
|
136
|
-
this._hadControl = false;
|
|
137
|
-
this.emit("data", this._prompt);
|
|
138
|
-
c = c.slice(this._prompt.length);
|
|
139
|
-
}
|
|
140
|
-
c = c.toString().replace(/./g, this.replace);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
this.emit("data", c);
|
|
144
|
-
}
|
|
145
|
-
end(c) {
|
|
146
|
-
if (this.muted) {
|
|
147
|
-
if (c && this.replace) {
|
|
148
|
-
c = c.toString().replace(/./g, this.replace);
|
|
149
|
-
} else {
|
|
150
|
-
c = null;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (c) {
|
|
154
|
-
this.emit("data", c);
|
|
155
|
-
}
|
|
156
|
-
this.emit("end");
|
|
157
|
-
}
|
|
158
|
-
destroy(...args) {
|
|
159
|
-
return this.#proxy("destroy", ...args);
|
|
160
|
-
}
|
|
161
|
-
destroySoon(...args) {
|
|
162
|
-
return this.#proxy("destroySoon", ...args);
|
|
163
|
-
}
|
|
164
|
-
close(...args) {
|
|
165
|
-
return this.#proxy("close", ...args);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
module.exports = MuteStream2;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// packages/core/src/setup.ts
|
|
173
|
-
import { execFileSync } from "child_process";
|
|
174
|
-
import * as fs from "fs";
|
|
175
|
-
import * as path from "path";
|
|
176
|
-
|
|
177
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
178
|
-
var isUpKey = (key, keybindings = []) => (
|
|
179
|
-
// The up key
|
|
180
|
-
key.name === "up" || // Vim keybinding: hjkl keys map to left/down/up/right
|
|
181
|
-
keybindings.includes("vim") && key.name === "k" || // Emacs keybinding: Ctrl+P means "previous" in Emacs navigation conventions
|
|
182
|
-
keybindings.includes("emacs") && key.ctrl && key.name === "p"
|
|
183
|
-
);
|
|
184
|
-
var isDownKey = (key, keybindings = []) => (
|
|
185
|
-
// The down key
|
|
186
|
-
key.name === "down" || // Vim keybinding: hjkl keys map to left/down/up/right
|
|
187
|
-
keybindings.includes("vim") && key.name === "j" || // Emacs keybinding: Ctrl+N means "next" in Emacs navigation conventions
|
|
188
|
-
keybindings.includes("emacs") && key.ctrl && key.name === "n"
|
|
189
|
-
);
|
|
190
|
-
var isBackspaceKey = (key) => key.name === "backspace";
|
|
191
|
-
var isTabKey = (key) => key.name === "tab";
|
|
192
|
-
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
193
|
-
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
194
|
-
|
|
195
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/errors.js
|
|
196
|
-
var AbortPromptError = class extends Error {
|
|
197
|
-
name = "AbortPromptError";
|
|
198
|
-
message = "Prompt was aborted";
|
|
199
|
-
constructor(options) {
|
|
200
|
-
super();
|
|
201
|
-
this.cause = options?.cause;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
var CancelPromptError = class extends Error {
|
|
205
|
-
name = "CancelPromptError";
|
|
206
|
-
message = "Prompt was canceled";
|
|
207
|
-
};
|
|
208
|
-
var ExitPromptError = class extends Error {
|
|
209
|
-
name = "ExitPromptError";
|
|
210
|
-
};
|
|
211
|
-
var HookError = class extends Error {
|
|
212
|
-
name = "HookError";
|
|
213
|
-
};
|
|
214
|
-
var ValidationError = class extends Error {
|
|
215
|
-
name = "ValidationError";
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
219
|
-
import { AsyncResource as AsyncResource2 } from "async_hooks";
|
|
220
|
-
|
|
221
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
222
|
-
import { AsyncLocalStorage, AsyncResource } from "async_hooks";
|
|
223
|
-
var hookStorage = new AsyncLocalStorage();
|
|
224
|
-
function createStore(rl) {
|
|
225
|
-
const store = {
|
|
226
|
-
rl,
|
|
227
|
-
hooks: [],
|
|
228
|
-
hooksCleanup: [],
|
|
229
|
-
hooksEffect: [],
|
|
230
|
-
index: 0,
|
|
231
|
-
handleChange() {
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
return store;
|
|
235
|
-
}
|
|
236
|
-
function withHooks(rl, cb) {
|
|
237
|
-
const store = createStore(rl);
|
|
238
|
-
return hookStorage.run(store, () => {
|
|
239
|
-
function cycle(render) {
|
|
240
|
-
store.handleChange = () => {
|
|
241
|
-
store.index = 0;
|
|
242
|
-
render();
|
|
243
|
-
};
|
|
244
|
-
store.handleChange();
|
|
245
|
-
}
|
|
246
|
-
return cb(cycle);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
function getStore() {
|
|
250
|
-
const store = hookStorage.getStore();
|
|
251
|
-
if (!store) {
|
|
252
|
-
throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
|
|
253
|
-
}
|
|
254
|
-
return store;
|
|
255
|
-
}
|
|
256
|
-
function readline() {
|
|
257
|
-
return getStore().rl;
|
|
258
|
-
}
|
|
259
|
-
function withUpdates(fn) {
|
|
260
|
-
const wrapped = (...args) => {
|
|
261
|
-
const store = getStore();
|
|
262
|
-
let shouldUpdate = false;
|
|
263
|
-
const oldHandleChange = store.handleChange;
|
|
264
|
-
store.handleChange = () => {
|
|
265
|
-
shouldUpdate = true;
|
|
266
|
-
};
|
|
267
|
-
const returnValue = fn(...args);
|
|
268
|
-
if (shouldUpdate) {
|
|
269
|
-
oldHandleChange();
|
|
270
|
-
}
|
|
271
|
-
store.handleChange = oldHandleChange;
|
|
272
|
-
return returnValue;
|
|
273
|
-
};
|
|
274
|
-
return AsyncResource.bind(wrapped);
|
|
275
|
-
}
|
|
276
|
-
function withPointer(cb) {
|
|
277
|
-
const store = getStore();
|
|
278
|
-
const { index } = store;
|
|
279
|
-
const pointer = {
|
|
280
|
-
get() {
|
|
281
|
-
return store.hooks[index];
|
|
282
|
-
},
|
|
283
|
-
set(value) {
|
|
284
|
-
store.hooks[index] = value;
|
|
285
|
-
},
|
|
286
|
-
initialized: index in store.hooks
|
|
287
|
-
};
|
|
288
|
-
const returnValue = cb(pointer);
|
|
289
|
-
store.index++;
|
|
290
|
-
return returnValue;
|
|
291
|
-
}
|
|
292
|
-
function handleChange() {
|
|
293
|
-
getStore().handleChange();
|
|
294
|
-
}
|
|
295
|
-
var effectScheduler = {
|
|
296
|
-
queue(cb) {
|
|
297
|
-
const store = getStore();
|
|
298
|
-
const { index } = store;
|
|
299
|
-
store.hooksEffect.push(() => {
|
|
300
|
-
store.hooksCleanup[index]?.();
|
|
301
|
-
const cleanFn = cb(readline());
|
|
302
|
-
if (cleanFn != null && typeof cleanFn !== "function") {
|
|
303
|
-
throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
|
|
304
|
-
}
|
|
305
|
-
store.hooksCleanup[index] = cleanFn;
|
|
306
|
-
});
|
|
307
|
-
},
|
|
308
|
-
run() {
|
|
309
|
-
const store = getStore();
|
|
310
|
-
withUpdates(() => {
|
|
311
|
-
store.hooksEffect.forEach((effect) => {
|
|
312
|
-
effect();
|
|
313
|
-
});
|
|
314
|
-
store.hooksEffect.length = 0;
|
|
315
|
-
})();
|
|
316
|
-
},
|
|
317
|
-
clearAll() {
|
|
318
|
-
const store = getStore();
|
|
319
|
-
store.hooksCleanup.forEach((cleanFn) => {
|
|
320
|
-
cleanFn?.();
|
|
321
|
-
});
|
|
322
|
-
store.hooksEffect.length = 0;
|
|
323
|
-
store.hooksCleanup.length = 0;
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
328
|
-
function useState(defaultValue) {
|
|
329
|
-
return withPointer((pointer) => {
|
|
330
|
-
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
331
|
-
if (pointer.get() !== newValue) {
|
|
332
|
-
pointer.set(newValue);
|
|
333
|
-
handleChange();
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
if (pointer.initialized) {
|
|
337
|
-
return [pointer.get(), setState];
|
|
338
|
-
}
|
|
339
|
-
const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
340
|
-
pointer.set(value);
|
|
341
|
-
return [value, setState];
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
346
|
-
function useEffect(cb, depArray) {
|
|
347
|
-
withPointer((pointer) => {
|
|
348
|
-
const oldDeps = pointer.get();
|
|
349
|
-
const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
|
|
350
|
-
if (hasChanged) {
|
|
351
|
-
effectScheduler.queue(cb);
|
|
352
|
-
}
|
|
353
|
-
pointer.set(depArray);
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
358
|
-
import { styleText } from "util";
|
|
359
|
-
|
|
360
|
-
// node_modules/.pnpm/@inquirer+figures@2.0.4/node_modules/@inquirer/figures/dist/index.js
|
|
361
|
-
import process2 from "process";
|
|
362
|
-
function isUnicodeSupported() {
|
|
363
|
-
if (process2.platform !== "win32") {
|
|
364
|
-
return process2.env["TERM"] !== "linux";
|
|
365
|
-
}
|
|
366
|
-
return Boolean(process2.env["WT_SESSION"]) || // Windows Terminal
|
|
367
|
-
Boolean(process2.env["TERMINUS_SUBLIME"]) || // Terminus (<0.2.27)
|
|
368
|
-
process2.env["ConEmuTask"] === "{cmd::Cmder}" || // ConEmu and cmder
|
|
369
|
-
process2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process2.env["TERM_PROGRAM"] === "vscode" || process2.env["TERM"] === "xterm-256color" || process2.env["TERM"] === "alacritty" || process2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
|
|
370
|
-
}
|
|
371
|
-
var common = {
|
|
372
|
-
circleQuestionMark: "(?)",
|
|
373
|
-
questionMarkPrefix: "(?)",
|
|
374
|
-
square: "\u2588",
|
|
375
|
-
squareDarkShade: "\u2593",
|
|
376
|
-
squareMediumShade: "\u2592",
|
|
377
|
-
squareLightShade: "\u2591",
|
|
378
|
-
squareTop: "\u2580",
|
|
379
|
-
squareBottom: "\u2584",
|
|
380
|
-
squareLeft: "\u258C",
|
|
381
|
-
squareRight: "\u2590",
|
|
382
|
-
squareCenter: "\u25A0",
|
|
383
|
-
bullet: "\u25CF",
|
|
384
|
-
dot: "\u2024",
|
|
385
|
-
ellipsis: "\u2026",
|
|
386
|
-
pointerSmall: "\u203A",
|
|
387
|
-
triangleUp: "\u25B2",
|
|
388
|
-
triangleUpSmall: "\u25B4",
|
|
389
|
-
triangleDown: "\u25BC",
|
|
390
|
-
triangleDownSmall: "\u25BE",
|
|
391
|
-
triangleLeftSmall: "\u25C2",
|
|
392
|
-
triangleRightSmall: "\u25B8",
|
|
393
|
-
home: "\u2302",
|
|
394
|
-
heart: "\u2665",
|
|
395
|
-
musicNote: "\u266A",
|
|
396
|
-
musicNoteBeamed: "\u266B",
|
|
397
|
-
arrowUp: "\u2191",
|
|
398
|
-
arrowDown: "\u2193",
|
|
399
|
-
arrowLeft: "\u2190",
|
|
400
|
-
arrowRight: "\u2192",
|
|
401
|
-
arrowLeftRight: "\u2194",
|
|
402
|
-
arrowUpDown: "\u2195",
|
|
403
|
-
almostEqual: "\u2248",
|
|
404
|
-
notEqual: "\u2260",
|
|
405
|
-
lessOrEqual: "\u2264",
|
|
406
|
-
greaterOrEqual: "\u2265",
|
|
407
|
-
identical: "\u2261",
|
|
408
|
-
infinity: "\u221E",
|
|
409
|
-
subscriptZero: "\u2080",
|
|
410
|
-
subscriptOne: "\u2081",
|
|
411
|
-
subscriptTwo: "\u2082",
|
|
412
|
-
subscriptThree: "\u2083",
|
|
413
|
-
subscriptFour: "\u2084",
|
|
414
|
-
subscriptFive: "\u2085",
|
|
415
|
-
subscriptSix: "\u2086",
|
|
416
|
-
subscriptSeven: "\u2087",
|
|
417
|
-
subscriptEight: "\u2088",
|
|
418
|
-
subscriptNine: "\u2089",
|
|
419
|
-
oneHalf: "\xBD",
|
|
420
|
-
oneThird: "\u2153",
|
|
421
|
-
oneQuarter: "\xBC",
|
|
422
|
-
oneFifth: "\u2155",
|
|
423
|
-
oneSixth: "\u2159",
|
|
424
|
-
oneEighth: "\u215B",
|
|
425
|
-
twoThirds: "\u2154",
|
|
426
|
-
twoFifths: "\u2156",
|
|
427
|
-
threeQuarters: "\xBE",
|
|
428
|
-
threeFifths: "\u2157",
|
|
429
|
-
threeEighths: "\u215C",
|
|
430
|
-
fourFifths: "\u2158",
|
|
431
|
-
fiveSixths: "\u215A",
|
|
432
|
-
fiveEighths: "\u215D",
|
|
433
|
-
sevenEighths: "\u215E",
|
|
434
|
-
line: "\u2500",
|
|
435
|
-
lineBold: "\u2501",
|
|
436
|
-
lineDouble: "\u2550",
|
|
437
|
-
lineDashed0: "\u2504",
|
|
438
|
-
lineDashed1: "\u2505",
|
|
439
|
-
lineDashed2: "\u2508",
|
|
440
|
-
lineDashed3: "\u2509",
|
|
441
|
-
lineDashed4: "\u254C",
|
|
442
|
-
lineDashed5: "\u254D",
|
|
443
|
-
lineDashed6: "\u2574",
|
|
444
|
-
lineDashed7: "\u2576",
|
|
445
|
-
lineDashed8: "\u2578",
|
|
446
|
-
lineDashed9: "\u257A",
|
|
447
|
-
lineDashed10: "\u257C",
|
|
448
|
-
lineDashed11: "\u257E",
|
|
449
|
-
lineDashed12: "\u2212",
|
|
450
|
-
lineDashed13: "\u2013",
|
|
451
|
-
lineDashed14: "\u2010",
|
|
452
|
-
lineDashed15: "\u2043",
|
|
453
|
-
lineVertical: "\u2502",
|
|
454
|
-
lineVerticalBold: "\u2503",
|
|
455
|
-
lineVerticalDouble: "\u2551",
|
|
456
|
-
lineVerticalDashed0: "\u2506",
|
|
457
|
-
lineVerticalDashed1: "\u2507",
|
|
458
|
-
lineVerticalDashed2: "\u250A",
|
|
459
|
-
lineVerticalDashed3: "\u250B",
|
|
460
|
-
lineVerticalDashed4: "\u254E",
|
|
461
|
-
lineVerticalDashed5: "\u254F",
|
|
462
|
-
lineVerticalDashed6: "\u2575",
|
|
463
|
-
lineVerticalDashed7: "\u2577",
|
|
464
|
-
lineVerticalDashed8: "\u2579",
|
|
465
|
-
lineVerticalDashed9: "\u257B",
|
|
466
|
-
lineVerticalDashed10: "\u257D",
|
|
467
|
-
lineVerticalDashed11: "\u257F",
|
|
468
|
-
lineDownLeft: "\u2510",
|
|
469
|
-
lineDownLeftArc: "\u256E",
|
|
470
|
-
lineDownBoldLeftBold: "\u2513",
|
|
471
|
-
lineDownBoldLeft: "\u2512",
|
|
472
|
-
lineDownLeftBold: "\u2511",
|
|
473
|
-
lineDownDoubleLeftDouble: "\u2557",
|
|
474
|
-
lineDownDoubleLeft: "\u2556",
|
|
475
|
-
lineDownLeftDouble: "\u2555",
|
|
476
|
-
lineDownRight: "\u250C",
|
|
477
|
-
lineDownRightArc: "\u256D",
|
|
478
|
-
lineDownBoldRightBold: "\u250F",
|
|
479
|
-
lineDownBoldRight: "\u250E",
|
|
480
|
-
lineDownRightBold: "\u250D",
|
|
481
|
-
lineDownDoubleRightDouble: "\u2554",
|
|
482
|
-
lineDownDoubleRight: "\u2553",
|
|
483
|
-
lineDownRightDouble: "\u2552",
|
|
484
|
-
lineUpLeft: "\u2518",
|
|
485
|
-
lineUpLeftArc: "\u256F",
|
|
486
|
-
lineUpBoldLeftBold: "\u251B",
|
|
487
|
-
lineUpBoldLeft: "\u251A",
|
|
488
|
-
lineUpLeftBold: "\u2519",
|
|
489
|
-
lineUpDoubleLeftDouble: "\u255D",
|
|
490
|
-
lineUpDoubleLeft: "\u255C",
|
|
491
|
-
lineUpLeftDouble: "\u255B",
|
|
492
|
-
lineUpRight: "\u2514",
|
|
493
|
-
lineUpRightArc: "\u2570",
|
|
494
|
-
lineUpBoldRightBold: "\u2517",
|
|
495
|
-
lineUpBoldRight: "\u2516",
|
|
496
|
-
lineUpRightBold: "\u2515",
|
|
497
|
-
lineUpDoubleRightDouble: "\u255A",
|
|
498
|
-
lineUpDoubleRight: "\u2559",
|
|
499
|
-
lineUpRightDouble: "\u2558",
|
|
500
|
-
lineUpDownLeft: "\u2524",
|
|
501
|
-
lineUpBoldDownBoldLeftBold: "\u252B",
|
|
502
|
-
lineUpBoldDownBoldLeft: "\u2528",
|
|
503
|
-
lineUpDownLeftBold: "\u2525",
|
|
504
|
-
lineUpBoldDownLeftBold: "\u2529",
|
|
505
|
-
lineUpDownBoldLeftBold: "\u252A",
|
|
506
|
-
lineUpDownBoldLeft: "\u2527",
|
|
507
|
-
lineUpBoldDownLeft: "\u2526",
|
|
508
|
-
lineUpDoubleDownDoubleLeftDouble: "\u2563",
|
|
509
|
-
lineUpDoubleDownDoubleLeft: "\u2562",
|
|
510
|
-
lineUpDownLeftDouble: "\u2561",
|
|
511
|
-
lineUpDownRight: "\u251C",
|
|
512
|
-
lineUpBoldDownBoldRightBold: "\u2523",
|
|
513
|
-
lineUpBoldDownBoldRight: "\u2520",
|
|
514
|
-
lineUpDownRightBold: "\u251D",
|
|
515
|
-
lineUpBoldDownRightBold: "\u2521",
|
|
516
|
-
lineUpDownBoldRightBold: "\u2522",
|
|
517
|
-
lineUpDownBoldRight: "\u251F",
|
|
518
|
-
lineUpBoldDownRight: "\u251E",
|
|
519
|
-
lineUpDoubleDownDoubleRightDouble: "\u2560",
|
|
520
|
-
lineUpDoubleDownDoubleRight: "\u255F",
|
|
521
|
-
lineUpDownRightDouble: "\u255E",
|
|
522
|
-
lineDownLeftRight: "\u252C",
|
|
523
|
-
lineDownBoldLeftBoldRightBold: "\u2533",
|
|
524
|
-
lineDownLeftBoldRightBold: "\u252F",
|
|
525
|
-
lineDownBoldLeftRight: "\u2530",
|
|
526
|
-
lineDownBoldLeftBoldRight: "\u2531",
|
|
527
|
-
lineDownBoldLeftRightBold: "\u2532",
|
|
528
|
-
lineDownLeftRightBold: "\u252E",
|
|
529
|
-
lineDownLeftBoldRight: "\u252D",
|
|
530
|
-
lineDownDoubleLeftDoubleRightDouble: "\u2566",
|
|
531
|
-
lineDownDoubleLeftRight: "\u2565",
|
|
532
|
-
lineDownLeftDoubleRightDouble: "\u2564",
|
|
533
|
-
lineUpLeftRight: "\u2534",
|
|
534
|
-
lineUpBoldLeftBoldRightBold: "\u253B",
|
|
535
|
-
lineUpLeftBoldRightBold: "\u2537",
|
|
536
|
-
lineUpBoldLeftRight: "\u2538",
|
|
537
|
-
lineUpBoldLeftBoldRight: "\u2539",
|
|
538
|
-
lineUpBoldLeftRightBold: "\u253A",
|
|
539
|
-
lineUpLeftRightBold: "\u2536",
|
|
540
|
-
lineUpLeftBoldRight: "\u2535",
|
|
541
|
-
lineUpDoubleLeftDoubleRightDouble: "\u2569",
|
|
542
|
-
lineUpDoubleLeftRight: "\u2568",
|
|
543
|
-
lineUpLeftDoubleRightDouble: "\u2567",
|
|
544
|
-
lineUpDownLeftRight: "\u253C",
|
|
545
|
-
lineUpBoldDownBoldLeftBoldRightBold: "\u254B",
|
|
546
|
-
lineUpDownBoldLeftBoldRightBold: "\u2548",
|
|
547
|
-
lineUpBoldDownLeftBoldRightBold: "\u2547",
|
|
548
|
-
lineUpBoldDownBoldLeftRightBold: "\u254A",
|
|
549
|
-
lineUpBoldDownBoldLeftBoldRight: "\u2549",
|
|
550
|
-
lineUpBoldDownLeftRight: "\u2540",
|
|
551
|
-
lineUpDownBoldLeftRight: "\u2541",
|
|
552
|
-
lineUpDownLeftBoldRight: "\u253D",
|
|
553
|
-
lineUpDownLeftRightBold: "\u253E",
|
|
554
|
-
lineUpBoldDownBoldLeftRight: "\u2542",
|
|
555
|
-
lineUpDownLeftBoldRightBold: "\u253F",
|
|
556
|
-
lineUpBoldDownLeftBoldRight: "\u2543",
|
|
557
|
-
lineUpBoldDownLeftRightBold: "\u2544",
|
|
558
|
-
lineUpDownBoldLeftBoldRight: "\u2545",
|
|
559
|
-
lineUpDownBoldLeftRightBold: "\u2546",
|
|
560
|
-
lineUpDoubleDownDoubleLeftDoubleRightDouble: "\u256C",
|
|
561
|
-
lineUpDoubleDownDoubleLeftRight: "\u256B",
|
|
562
|
-
lineUpDownLeftDoubleRightDouble: "\u256A",
|
|
563
|
-
lineCross: "\u2573",
|
|
564
|
-
lineBackslash: "\u2572",
|
|
565
|
-
lineSlash: "\u2571"
|
|
566
|
-
};
|
|
567
|
-
var specialMainSymbols = {
|
|
568
|
-
tick: "\u2714",
|
|
569
|
-
info: "\u2139",
|
|
570
|
-
warning: "\u26A0",
|
|
571
|
-
cross: "\u2718",
|
|
572
|
-
squareSmall: "\u25FB",
|
|
573
|
-
squareSmallFilled: "\u25FC",
|
|
574
|
-
circle: "\u25EF",
|
|
575
|
-
circleFilled: "\u25C9",
|
|
576
|
-
circleDotted: "\u25CC",
|
|
577
|
-
circleDouble: "\u25CE",
|
|
578
|
-
circleCircle: "\u24DE",
|
|
579
|
-
circleCross: "\u24E7",
|
|
580
|
-
circlePipe: "\u24BE",
|
|
581
|
-
radioOn: "\u25C9",
|
|
582
|
-
radioOff: "\u25EF",
|
|
583
|
-
checkboxOn: "\u2612",
|
|
584
|
-
checkboxOff: "\u2610",
|
|
585
|
-
checkboxCircleOn: "\u24E7",
|
|
586
|
-
checkboxCircleOff: "\u24BE",
|
|
587
|
-
pointer: "\u276F",
|
|
588
|
-
triangleUpOutline: "\u25B3",
|
|
589
|
-
triangleLeft: "\u25C0",
|
|
590
|
-
triangleRight: "\u25B6",
|
|
591
|
-
lozenge: "\u25C6",
|
|
592
|
-
lozengeOutline: "\u25C7",
|
|
593
|
-
hamburger: "\u2630",
|
|
594
|
-
smiley: "\u32E1",
|
|
595
|
-
mustache: "\u0DF4",
|
|
596
|
-
star: "\u2605",
|
|
597
|
-
play: "\u25B6",
|
|
598
|
-
nodejs: "\u2B22",
|
|
599
|
-
oneSeventh: "\u2150",
|
|
600
|
-
oneNinth: "\u2151",
|
|
601
|
-
oneTenth: "\u2152"
|
|
602
|
-
};
|
|
603
|
-
var specialFallbackSymbols = {
|
|
604
|
-
tick: "\u221A",
|
|
605
|
-
info: "i",
|
|
606
|
-
warning: "\u203C",
|
|
607
|
-
cross: "\xD7",
|
|
608
|
-
squareSmall: "\u25A1",
|
|
609
|
-
squareSmallFilled: "\u25A0",
|
|
610
|
-
circle: "( )",
|
|
611
|
-
circleFilled: "(*)",
|
|
612
|
-
circleDotted: "( )",
|
|
613
|
-
circleDouble: "( )",
|
|
614
|
-
circleCircle: "(\u25CB)",
|
|
615
|
-
circleCross: "(\xD7)",
|
|
616
|
-
circlePipe: "(\u2502)",
|
|
617
|
-
radioOn: "(*)",
|
|
618
|
-
radioOff: "( )",
|
|
619
|
-
checkboxOn: "[\xD7]",
|
|
620
|
-
checkboxOff: "[ ]",
|
|
621
|
-
checkboxCircleOn: "(\xD7)",
|
|
622
|
-
checkboxCircleOff: "( )",
|
|
623
|
-
pointer: ">",
|
|
624
|
-
triangleUpOutline: "\u2206",
|
|
625
|
-
triangleLeft: "\u25C4",
|
|
626
|
-
triangleRight: "\u25BA",
|
|
627
|
-
lozenge: "\u2666",
|
|
628
|
-
lozengeOutline: "\u25CA",
|
|
629
|
-
hamburger: "\u2261",
|
|
630
|
-
smiley: "\u263A",
|
|
631
|
-
mustache: "\u250C\u2500\u2510",
|
|
632
|
-
star: "\u2736",
|
|
633
|
-
play: "\u25BA",
|
|
634
|
-
nodejs: "\u2666",
|
|
635
|
-
oneSeventh: "1/7",
|
|
636
|
-
oneNinth: "1/9",
|
|
637
|
-
oneTenth: "1/10"
|
|
638
|
-
};
|
|
639
|
-
var mainSymbols = {
|
|
640
|
-
...common,
|
|
641
|
-
...specialMainSymbols
|
|
642
|
-
};
|
|
643
|
-
var fallbackSymbols = {
|
|
644
|
-
...common,
|
|
645
|
-
...specialFallbackSymbols
|
|
646
|
-
};
|
|
647
|
-
var shouldUseMain = isUnicodeSupported();
|
|
648
|
-
var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
649
|
-
var dist_default = figures;
|
|
650
|
-
var replacements = Object.entries(specialMainSymbols);
|
|
651
|
-
|
|
652
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
653
|
-
var defaultTheme = {
|
|
654
|
-
prefix: {
|
|
655
|
-
idle: styleText("blue", "?"),
|
|
656
|
-
done: styleText("green", dist_default.tick)
|
|
657
|
-
},
|
|
658
|
-
spinner: {
|
|
659
|
-
interval: 80,
|
|
660
|
-
frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"].map((frame) => styleText("yellow", frame))
|
|
661
|
-
},
|
|
662
|
-
style: {
|
|
663
|
-
answer: (text) => styleText("cyan", text),
|
|
664
|
-
message: (text) => styleText("bold", text),
|
|
665
|
-
error: (text) => styleText("red", `> ${text}`),
|
|
666
|
-
defaultAnswer: (text) => styleText("dim", `(${text})`),
|
|
667
|
-
help: (text) => styleText("dim", text),
|
|
668
|
-
highlight: (text) => styleText("cyan", text),
|
|
669
|
-
key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
674
|
-
function isPlainObject(value) {
|
|
675
|
-
if (typeof value !== "object" || value === null)
|
|
676
|
-
return false;
|
|
677
|
-
let proto = value;
|
|
678
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
679
|
-
proto = Object.getPrototypeOf(proto);
|
|
680
|
-
}
|
|
681
|
-
return Object.getPrototypeOf(value) === proto;
|
|
682
|
-
}
|
|
683
|
-
function deepMerge(...objects) {
|
|
684
|
-
const output = {};
|
|
685
|
-
for (const obj of objects) {
|
|
686
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
687
|
-
const prevValue = output[key];
|
|
688
|
-
output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
return output;
|
|
692
|
-
}
|
|
693
|
-
function makeTheme(...themes) {
|
|
694
|
-
const themesToMerge = [
|
|
695
|
-
defaultTheme,
|
|
696
|
-
...themes.filter((theme) => theme != null)
|
|
697
|
-
];
|
|
698
|
-
return deepMerge(...themesToMerge);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
702
|
-
function usePrefix({ status = "idle", theme }) {
|
|
703
|
-
const [showLoader, setShowLoader] = useState(false);
|
|
704
|
-
const [tick, setTick] = useState(0);
|
|
705
|
-
const { prefix, spinner } = makeTheme(theme);
|
|
706
|
-
useEffect(() => {
|
|
707
|
-
if (status === "loading") {
|
|
708
|
-
let tickInterval;
|
|
709
|
-
let inc = -1;
|
|
710
|
-
const delayTimeout = setTimeout(() => {
|
|
711
|
-
setShowLoader(true);
|
|
712
|
-
tickInterval = setInterval(() => {
|
|
713
|
-
inc = inc + 1;
|
|
714
|
-
setTick(inc % spinner.frames.length);
|
|
715
|
-
}, spinner.interval);
|
|
716
|
-
}, 300);
|
|
717
|
-
return () => {
|
|
718
|
-
clearTimeout(delayTimeout);
|
|
719
|
-
clearInterval(tickInterval);
|
|
720
|
-
};
|
|
721
|
-
} else {
|
|
722
|
-
setShowLoader(false);
|
|
723
|
-
}
|
|
724
|
-
}, [status]);
|
|
725
|
-
if (showLoader) {
|
|
726
|
-
return spinner.frames[tick];
|
|
727
|
-
}
|
|
728
|
-
const iconName = status === "loading" ? "idle" : status;
|
|
729
|
-
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
733
|
-
function useMemo(fn, dependencies) {
|
|
734
|
-
return withPointer((pointer) => {
|
|
735
|
-
const prev = pointer.get();
|
|
736
|
-
if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
|
|
737
|
-
const value = fn();
|
|
738
|
-
pointer.set({ value, dependencies });
|
|
739
|
-
return value;
|
|
740
|
-
}
|
|
741
|
-
return prev.value;
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
746
|
-
function useRef(val) {
|
|
747
|
-
return useState({ current: val })[0];
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
751
|
-
function useKeypress(userHandler) {
|
|
752
|
-
const signal = useRef(userHandler);
|
|
753
|
-
signal.current = userHandler;
|
|
754
|
-
useEffect((rl) => {
|
|
755
|
-
let ignore = false;
|
|
756
|
-
const handler = withUpdates((_input, event) => {
|
|
757
|
-
if (ignore)
|
|
758
|
-
return;
|
|
759
|
-
void signal.current(event, rl);
|
|
760
|
-
});
|
|
761
|
-
rl.input.on("keypress", handler);
|
|
762
|
-
return () => {
|
|
763
|
-
ignore = true;
|
|
764
|
-
rl.input.removeListener("keypress", handler);
|
|
765
|
-
};
|
|
766
|
-
}, []);
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
770
|
-
var import_cli_width = __toESM(require_cli_width(), 1);
|
|
771
|
-
|
|
772
|
-
// node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
773
|
-
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
774
|
-
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
775
|
-
return (input) => {
|
|
776
|
-
let surrogatePairsNr = 0;
|
|
777
|
-
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
778
|
-
while (SURROGATE_PAIR_RE.test(input)) {
|
|
779
|
-
surrogatePairsNr += 1;
|
|
780
|
-
}
|
|
781
|
-
return input.length - surrogatePairsNr;
|
|
782
|
-
};
|
|
783
|
-
})();
|
|
784
|
-
var isFullWidth = (x) => {
|
|
785
|
-
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
786
|
-
};
|
|
787
|
-
var isWideNotCJKTNotEmoji = (x) => {
|
|
788
|
-
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;
|
|
789
|
-
};
|
|
790
|
-
|
|
791
|
-
// node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
792
|
-
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
793
|
-
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
794
|
-
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
795
|
-
var TAB_RE = /\t{1,1000}/y;
|
|
796
|
-
var EMOJI_RE = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
797
|
-
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
798
|
-
var MODIFIER_RE = new RegExp("\\p{M}+", "gu");
|
|
799
|
-
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
800
|
-
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
801
|
-
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
802
|
-
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
803
|
-
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
804
|
-
const ANSI_WIDTH = 0;
|
|
805
|
-
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
806
|
-
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
807
|
-
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
808
|
-
const FULL_WIDTH_WIDTH = 2;
|
|
809
|
-
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
810
|
-
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
811
|
-
const PARSE_BLOCKS = [
|
|
812
|
-
[LATIN_RE, REGULAR_WIDTH],
|
|
813
|
-
[ANSI_RE, ANSI_WIDTH],
|
|
814
|
-
[CONTROL_RE, CONTROL_WIDTH],
|
|
815
|
-
[TAB_RE, TAB_WIDTH],
|
|
816
|
-
[EMOJI_RE, EMOJI_WIDTH],
|
|
817
|
-
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
818
|
-
];
|
|
819
|
-
let indexPrev = 0;
|
|
820
|
-
let index = 0;
|
|
821
|
-
let length = input.length;
|
|
822
|
-
let lengthExtra = 0;
|
|
823
|
-
let truncationEnabled = false;
|
|
824
|
-
let truncationIndex = length;
|
|
825
|
-
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
826
|
-
let unmatchedStart = 0;
|
|
827
|
-
let unmatchedEnd = 0;
|
|
828
|
-
let width = 0;
|
|
829
|
-
let widthExtra = 0;
|
|
830
|
-
outer: while (true) {
|
|
831
|
-
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
832
|
-
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
833
|
-
lengthExtra = 0;
|
|
834
|
-
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
835
|
-
const codePoint = char.codePointAt(0) || 0;
|
|
836
|
-
if (isFullWidth(codePoint)) {
|
|
837
|
-
widthExtra = FULL_WIDTH_WIDTH;
|
|
838
|
-
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
839
|
-
widthExtra = WIDE_WIDTH;
|
|
840
|
-
} else {
|
|
841
|
-
widthExtra = REGULAR_WIDTH;
|
|
842
|
-
}
|
|
843
|
-
if (width + widthExtra > truncationLimit) {
|
|
844
|
-
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
845
|
-
}
|
|
846
|
-
if (width + widthExtra > LIMIT) {
|
|
847
|
-
truncationEnabled = true;
|
|
848
|
-
break outer;
|
|
849
|
-
}
|
|
850
|
-
lengthExtra += char.length;
|
|
851
|
-
width += widthExtra;
|
|
852
|
-
}
|
|
853
|
-
unmatchedStart = unmatchedEnd = 0;
|
|
854
|
-
}
|
|
855
|
-
if (index >= length) {
|
|
856
|
-
break outer;
|
|
857
|
-
}
|
|
858
|
-
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
859
|
-
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
860
|
-
BLOCK_RE.lastIndex = index;
|
|
861
|
-
if (BLOCK_RE.test(input)) {
|
|
862
|
-
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
863
|
-
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
864
|
-
if (width + widthExtra > truncationLimit) {
|
|
865
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
866
|
-
}
|
|
867
|
-
if (width + widthExtra > LIMIT) {
|
|
868
|
-
truncationEnabled = true;
|
|
869
|
-
break outer;
|
|
870
|
-
}
|
|
871
|
-
width += widthExtra;
|
|
872
|
-
unmatchedStart = indexPrev;
|
|
873
|
-
unmatchedEnd = index;
|
|
874
|
-
index = indexPrev = BLOCK_RE.lastIndex;
|
|
875
|
-
continue outer;
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
index += 1;
|
|
879
|
-
}
|
|
880
|
-
return {
|
|
881
|
-
width: truncationEnabled ? truncationLimit : width,
|
|
882
|
-
index: truncationEnabled ? truncationIndex : length,
|
|
883
|
-
truncated: truncationEnabled,
|
|
884
|
-
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
885
|
-
};
|
|
886
|
-
};
|
|
887
|
-
var dist_default2 = getStringTruncatedWidth;
|
|
888
|
-
|
|
889
|
-
// node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
890
|
-
var NO_TRUNCATION2 = {
|
|
891
|
-
limit: Infinity,
|
|
892
|
-
ellipsis: "",
|
|
893
|
-
ellipsisWidth: 0
|
|
894
|
-
};
|
|
895
|
-
var fastStringWidth = (input, options = {}) => {
|
|
896
|
-
return dist_default2(input, NO_TRUNCATION2, options).width;
|
|
897
|
-
};
|
|
898
|
-
var dist_default3 = fastStringWidth;
|
|
899
|
-
|
|
900
|
-
// node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js
|
|
901
|
-
var ESC = "\x1B";
|
|
902
|
-
var CSI = "\x9B";
|
|
903
|
-
var END_CODE = 39;
|
|
904
|
-
var ANSI_ESCAPE_BELL = "\x07";
|
|
905
|
-
var ANSI_CSI = "[";
|
|
906
|
-
var ANSI_OSC = "]";
|
|
907
|
-
var ANSI_SGR_TERMINATOR = "m";
|
|
908
|
-
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
909
|
-
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
910
|
-
var getClosingCode = (openingCode) => {
|
|
911
|
-
if (openingCode >= 30 && openingCode <= 37)
|
|
912
|
-
return 39;
|
|
913
|
-
if (openingCode >= 90 && openingCode <= 97)
|
|
914
|
-
return 39;
|
|
915
|
-
if (openingCode >= 40 && openingCode <= 47)
|
|
916
|
-
return 49;
|
|
917
|
-
if (openingCode >= 100 && openingCode <= 107)
|
|
918
|
-
return 49;
|
|
919
|
-
if (openingCode === 1 || openingCode === 2)
|
|
920
|
-
return 22;
|
|
921
|
-
if (openingCode === 3)
|
|
922
|
-
return 23;
|
|
923
|
-
if (openingCode === 4)
|
|
924
|
-
return 24;
|
|
925
|
-
if (openingCode === 7)
|
|
926
|
-
return 27;
|
|
927
|
-
if (openingCode === 8)
|
|
928
|
-
return 28;
|
|
929
|
-
if (openingCode === 9)
|
|
930
|
-
return 29;
|
|
931
|
-
if (openingCode === 0)
|
|
932
|
-
return 0;
|
|
933
|
-
return void 0;
|
|
934
|
-
};
|
|
935
|
-
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
936
|
-
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
937
|
-
var wrapWord = (rows, word, columns) => {
|
|
938
|
-
const characters = word[Symbol.iterator]();
|
|
939
|
-
let isInsideEscape = false;
|
|
940
|
-
let isInsideLinkEscape = false;
|
|
941
|
-
let lastRow = rows.at(-1);
|
|
942
|
-
let visible = lastRow === void 0 ? 0 : dist_default3(lastRow);
|
|
943
|
-
let currentCharacter = characters.next();
|
|
944
|
-
let nextCharacter = characters.next();
|
|
945
|
-
let rawCharacterIndex = 0;
|
|
946
|
-
while (!currentCharacter.done) {
|
|
947
|
-
const character = currentCharacter.value;
|
|
948
|
-
const characterLength = dist_default3(character);
|
|
949
|
-
if (visible + characterLength <= columns) {
|
|
950
|
-
rows[rows.length - 1] += character;
|
|
951
|
-
} else {
|
|
952
|
-
rows.push(character);
|
|
953
|
-
visible = 0;
|
|
954
|
-
}
|
|
955
|
-
if (character === ESC || character === CSI) {
|
|
956
|
-
isInsideEscape = true;
|
|
957
|
-
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
958
|
-
}
|
|
959
|
-
if (isInsideEscape) {
|
|
960
|
-
if (isInsideLinkEscape) {
|
|
961
|
-
if (character === ANSI_ESCAPE_BELL) {
|
|
962
|
-
isInsideEscape = false;
|
|
963
|
-
isInsideLinkEscape = false;
|
|
964
|
-
}
|
|
965
|
-
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
966
|
-
isInsideEscape = false;
|
|
967
|
-
}
|
|
968
|
-
} else {
|
|
969
|
-
visible += characterLength;
|
|
970
|
-
if (visible === columns && !nextCharacter.done) {
|
|
971
|
-
rows.push("");
|
|
972
|
-
visible = 0;
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
currentCharacter = nextCharacter;
|
|
976
|
-
nextCharacter = characters.next();
|
|
977
|
-
rawCharacterIndex += character.length;
|
|
978
|
-
}
|
|
979
|
-
lastRow = rows.at(-1);
|
|
980
|
-
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) {
|
|
981
|
-
rows[rows.length - 2] += rows.pop();
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
var stringVisibleTrimSpacesRight = (string) => {
|
|
985
|
-
const words = string.split(" ");
|
|
986
|
-
let last = words.length;
|
|
987
|
-
while (last) {
|
|
988
|
-
if (dist_default3(words[last - 1])) {
|
|
989
|
-
break;
|
|
990
|
-
}
|
|
991
|
-
last--;
|
|
992
|
-
}
|
|
993
|
-
if (last === words.length) {
|
|
994
|
-
return string;
|
|
995
|
-
}
|
|
996
|
-
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
997
|
-
};
|
|
998
|
-
var exec = (string, columns, options = {}) => {
|
|
999
|
-
if (options.trim !== false && string.trim() === "") {
|
|
1000
|
-
return "";
|
|
1001
|
-
}
|
|
1002
|
-
let returnValue = "";
|
|
1003
|
-
let escapeCode;
|
|
1004
|
-
let escapeUrl;
|
|
1005
|
-
const words = string.split(" ");
|
|
1006
|
-
let rows = [""];
|
|
1007
|
-
let rowLength = 0;
|
|
1008
|
-
for (let index = 0; index < words.length; index++) {
|
|
1009
|
-
const word = words[index];
|
|
1010
|
-
if (options.trim !== false) {
|
|
1011
|
-
const row = rows.at(-1) ?? "";
|
|
1012
|
-
const trimmed = row.trimStart();
|
|
1013
|
-
if (row.length !== trimmed.length) {
|
|
1014
|
-
rows[rows.length - 1] = trimmed;
|
|
1015
|
-
rowLength = dist_default3(trimmed);
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
if (index !== 0) {
|
|
1019
|
-
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
1020
|
-
rows.push("");
|
|
1021
|
-
rowLength = 0;
|
|
1022
|
-
}
|
|
1023
|
-
if (rowLength || options.trim === false) {
|
|
1024
|
-
rows[rows.length - 1] += " ";
|
|
1025
|
-
rowLength++;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
const wordLength = dist_default3(word);
|
|
1029
|
-
if (options.hard && wordLength > columns) {
|
|
1030
|
-
const remainingColumns = columns - rowLength;
|
|
1031
|
-
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
1032
|
-
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
1033
|
-
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
1034
|
-
rows.push("");
|
|
1035
|
-
}
|
|
1036
|
-
wrapWord(rows, word, columns);
|
|
1037
|
-
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
1038
|
-
continue;
|
|
1039
|
-
}
|
|
1040
|
-
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
1041
|
-
if (options.wordWrap === false && rowLength < columns) {
|
|
1042
|
-
wrapWord(rows, word, columns);
|
|
1043
|
-
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
1044
|
-
continue;
|
|
1045
|
-
}
|
|
1046
|
-
rows.push("");
|
|
1047
|
-
rowLength = 0;
|
|
1048
|
-
}
|
|
1049
|
-
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
1050
|
-
wrapWord(rows, word, columns);
|
|
1051
|
-
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
1052
|
-
continue;
|
|
1053
|
-
}
|
|
1054
|
-
rows[rows.length - 1] += word;
|
|
1055
|
-
rowLength += wordLength;
|
|
1056
|
-
}
|
|
1057
|
-
if (options.trim !== false) {
|
|
1058
|
-
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
1059
|
-
}
|
|
1060
|
-
const preString = rows.join("\n");
|
|
1061
|
-
let inSurrogate = false;
|
|
1062
|
-
for (let i = 0; i < preString.length; i++) {
|
|
1063
|
-
const character = preString[i];
|
|
1064
|
-
returnValue += character;
|
|
1065
|
-
if (!inSurrogate) {
|
|
1066
|
-
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
1067
|
-
if (inSurrogate) {
|
|
1068
|
-
continue;
|
|
1069
|
-
}
|
|
1070
|
-
} else {
|
|
1071
|
-
inSurrogate = false;
|
|
1072
|
-
}
|
|
1073
|
-
if (character === ESC || character === CSI) {
|
|
1074
|
-
GROUP_REGEX.lastIndex = i + 1;
|
|
1075
|
-
const groupsResult = GROUP_REGEX.exec(preString);
|
|
1076
|
-
const groups = groupsResult?.groups;
|
|
1077
|
-
if (groups?.code !== void 0) {
|
|
1078
|
-
const code = Number.parseFloat(groups.code);
|
|
1079
|
-
escapeCode = code === END_CODE ? void 0 : code;
|
|
1080
|
-
} else if (groups?.uri !== void 0) {
|
|
1081
|
-
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
if (preString[i + 1] === "\n") {
|
|
1085
|
-
if (escapeUrl) {
|
|
1086
|
-
returnValue += wrapAnsiHyperlink("");
|
|
1087
|
-
}
|
|
1088
|
-
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
1089
|
-
if (escapeCode && closingCode) {
|
|
1090
|
-
returnValue += wrapAnsiCode(closingCode);
|
|
1091
|
-
}
|
|
1092
|
-
} else if (character === "\n") {
|
|
1093
|
-
if (escapeCode && getClosingCode(escapeCode)) {
|
|
1094
|
-
returnValue += wrapAnsiCode(escapeCode);
|
|
1095
|
-
}
|
|
1096
|
-
if (escapeUrl) {
|
|
1097
|
-
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
return returnValue;
|
|
1102
|
-
};
|
|
1103
|
-
var CRLF_OR_LF = /\r?\n/;
|
|
1104
|
-
function wrapAnsi(string, columns, options) {
|
|
1105
|
-
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
1109
|
-
function breakLines(content, width) {
|
|
1110
|
-
return content.split("\n").flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split("\n").map((str) => str.trimEnd())).join("\n");
|
|
1111
|
-
}
|
|
1112
|
-
function readlineWidth() {
|
|
1113
|
-
return (0, import_cli_width.default)({ defaultWidth: 80, output: readline().output });
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
1117
|
-
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
1118
|
-
const state = useRef({
|
|
1119
|
-
lastPointer: active,
|
|
1120
|
-
lastActive: void 0
|
|
1121
|
-
});
|
|
1122
|
-
const { lastPointer, lastActive } = state.current;
|
|
1123
|
-
const middle = Math.floor(pageSize / 2);
|
|
1124
|
-
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
1125
|
-
const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
|
|
1126
|
-
let pointer = defaultPointerPosition;
|
|
1127
|
-
if (renderedLength > pageSize) {
|
|
1128
|
-
if (loop) {
|
|
1129
|
-
pointer = lastPointer;
|
|
1130
|
-
if (
|
|
1131
|
-
// First render, skip this logic.
|
|
1132
|
-
lastActive != null && // Only move the pointer down when the user moves down.
|
|
1133
|
-
lastActive < active && // Check user didn't move up across page boundary.
|
|
1134
|
-
active - lastActive < pageSize
|
|
1135
|
-
) {
|
|
1136
|
-
pointer = Math.min(
|
|
1137
|
-
// Furthest allowed position for the pointer is the middle of the list
|
|
1138
|
-
middle,
|
|
1139
|
-
Math.abs(active - lastActive) === 1 ? Math.min(
|
|
1140
|
-
// Move the pointer at most the height of the last active item.
|
|
1141
|
-
lastPointer + (renderedItems[lastActive]?.length ?? 0),
|
|
1142
|
-
// If the user moved by one item, move the pointer to the natural position of the active item as
|
|
1143
|
-
// long as it doesn't move the cursor up.
|
|
1144
|
-
Math.max(defaultPointerPosition, lastPointer)
|
|
1145
|
-
) : (
|
|
1146
|
-
// Otherwise, move the pointer down by the difference between the active and last active item.
|
|
1147
|
-
lastPointer + active - lastActive
|
|
1148
|
-
)
|
|
1149
|
-
);
|
|
1150
|
-
}
|
|
1151
|
-
} else {
|
|
1152
|
-
const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
|
|
1153
|
-
pointer = spaceUnderActive < pageSize - middle ? (
|
|
1154
|
-
// If the active item is near the end of the list, progressively move the cursor towards the end.
|
|
1155
|
-
pageSize - spaceUnderActive
|
|
1156
|
-
) : (
|
|
1157
|
-
// Otherwise, progressively move the pointer to the middle of the list.
|
|
1158
|
-
Math.min(defaultPointerPosition, middle)
|
|
1159
|
-
);
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
state.current.lastPointer = pointer;
|
|
1163
|
-
state.current.lastActive = active;
|
|
1164
|
-
return pointer;
|
|
1165
|
-
}
|
|
1166
|
-
function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
1167
|
-
const width = readlineWidth();
|
|
1168
|
-
const bound = (num) => (num % items.length + items.length) % items.length;
|
|
1169
|
-
const renderedItems = items.map((item, index) => {
|
|
1170
|
-
if (item == null)
|
|
1171
|
-
return [];
|
|
1172
|
-
return breakLines(renderItem({ item, index, isActive: index === active }), width).split("\n");
|
|
1173
|
-
});
|
|
1174
|
-
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
1175
|
-
const renderItemAtIndex = (index) => renderedItems[index] ?? [];
|
|
1176
|
-
const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
|
|
1177
|
-
const activeItem = renderItemAtIndex(active).slice(0, pageSize);
|
|
1178
|
-
const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
|
|
1179
|
-
const pageBuffer = Array.from({ length: pageSize });
|
|
1180
|
-
pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
|
|
1181
|
-
const itemVisited = /* @__PURE__ */ new Set([active]);
|
|
1182
|
-
let bufferPointer = activeItemPosition + activeItem.length;
|
|
1183
|
-
let itemPointer = bound(active + 1);
|
|
1184
|
-
while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
|
|
1185
|
-
const lines = renderItemAtIndex(itemPointer);
|
|
1186
|
-
const linesToAdd = lines.slice(0, pageSize - bufferPointer);
|
|
1187
|
-
pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
|
|
1188
|
-
itemVisited.add(itemPointer);
|
|
1189
|
-
bufferPointer += linesToAdd.length;
|
|
1190
|
-
itemPointer = bound(itemPointer + 1);
|
|
1191
|
-
}
|
|
1192
|
-
bufferPointer = activeItemPosition - 1;
|
|
1193
|
-
itemPointer = bound(active - 1);
|
|
1194
|
-
while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
|
|
1195
|
-
const lines = renderItemAtIndex(itemPointer);
|
|
1196
|
-
const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
|
|
1197
|
-
pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
|
|
1198
|
-
itemVisited.add(itemPointer);
|
|
1199
|
-
bufferPointer -= linesToAdd.length;
|
|
1200
|
-
itemPointer = bound(itemPointer - 1);
|
|
1201
|
-
}
|
|
1202
|
-
return pageBuffer.filter((line) => typeof line === "string").join("\n");
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
1206
|
-
var import_mute_stream = __toESM(require_lib(), 1);
|
|
1207
|
-
import * as readline2 from "readline";
|
|
1208
|
-
import { AsyncResource as AsyncResource3 } from "async_hooks";
|
|
1209
|
-
|
|
1210
|
-
// node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
1211
|
-
var signals = [];
|
|
1212
|
-
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
1213
|
-
if (process.platform !== "win32") {
|
|
1214
|
-
signals.push(
|
|
1215
|
-
"SIGALRM",
|
|
1216
|
-
"SIGABRT",
|
|
1217
|
-
"SIGVTALRM",
|
|
1218
|
-
"SIGXCPU",
|
|
1219
|
-
"SIGXFSZ",
|
|
1220
|
-
"SIGUSR2",
|
|
1221
|
-
"SIGTRAP",
|
|
1222
|
-
"SIGSYS",
|
|
1223
|
-
"SIGQUIT",
|
|
1224
|
-
"SIGIOT"
|
|
1225
|
-
// should detect profiler and enable/disable accordingly.
|
|
1226
|
-
// see #21
|
|
1227
|
-
// 'SIGPROF'
|
|
1228
|
-
);
|
|
1229
|
-
}
|
|
1230
|
-
if (process.platform === "linux") {
|
|
1231
|
-
signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
// node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
1235
|
-
var processOk = (process4) => !!process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
|
|
1236
|
-
var kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
|
|
1237
|
-
var global = globalThis;
|
|
1238
|
-
var ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
1239
|
-
var Emitter = class {
|
|
1240
|
-
emitted = {
|
|
1241
|
-
afterExit: false,
|
|
1242
|
-
exit: false
|
|
1243
|
-
};
|
|
1244
|
-
listeners = {
|
|
1245
|
-
afterExit: [],
|
|
1246
|
-
exit: []
|
|
1247
|
-
};
|
|
1248
|
-
count = 0;
|
|
1249
|
-
id = Math.random();
|
|
1250
|
-
constructor() {
|
|
1251
|
-
if (global[kExitEmitter]) {
|
|
1252
|
-
return global[kExitEmitter];
|
|
1253
|
-
}
|
|
1254
|
-
ObjectDefineProperty(global, kExitEmitter, {
|
|
1255
|
-
value: this,
|
|
1256
|
-
writable: false,
|
|
1257
|
-
enumerable: false,
|
|
1258
|
-
configurable: false
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
on(ev, fn) {
|
|
1262
|
-
this.listeners[ev].push(fn);
|
|
1263
|
-
}
|
|
1264
|
-
removeListener(ev, fn) {
|
|
1265
|
-
const list = this.listeners[ev];
|
|
1266
|
-
const i = list.indexOf(fn);
|
|
1267
|
-
if (i === -1) {
|
|
1268
|
-
return;
|
|
1269
|
-
}
|
|
1270
|
-
if (i === 0 && list.length === 1) {
|
|
1271
|
-
list.length = 0;
|
|
1272
|
-
} else {
|
|
1273
|
-
list.splice(i, 1);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
emit(ev, code, signal) {
|
|
1277
|
-
if (this.emitted[ev]) {
|
|
1278
|
-
return false;
|
|
1279
|
-
}
|
|
1280
|
-
this.emitted[ev] = true;
|
|
1281
|
-
let ret = false;
|
|
1282
|
-
for (const fn of this.listeners[ev]) {
|
|
1283
|
-
ret = fn(code, signal) === true || ret;
|
|
1284
|
-
}
|
|
1285
|
-
if (ev === "exit") {
|
|
1286
|
-
ret = this.emit("afterExit", code, signal) || ret;
|
|
1287
|
-
}
|
|
1288
|
-
return ret;
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1291
|
-
var SignalExitBase = class {
|
|
1292
|
-
};
|
|
1293
|
-
var signalExitWrap = (handler) => {
|
|
1294
|
-
return {
|
|
1295
|
-
onExit(cb, opts) {
|
|
1296
|
-
return handler.onExit(cb, opts);
|
|
1297
|
-
},
|
|
1298
|
-
load() {
|
|
1299
|
-
return handler.load();
|
|
1300
|
-
},
|
|
1301
|
-
unload() {
|
|
1302
|
-
return handler.unload();
|
|
1303
|
-
}
|
|
1304
|
-
};
|
|
1305
|
-
};
|
|
1306
|
-
var SignalExitFallback = class extends SignalExitBase {
|
|
1307
|
-
onExit() {
|
|
1308
|
-
return () => {
|
|
1309
|
-
};
|
|
1310
|
-
}
|
|
1311
|
-
load() {
|
|
1312
|
-
}
|
|
1313
|
-
unload() {
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
var SignalExit = class extends SignalExitBase {
|
|
1317
|
-
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
|
1318
|
-
// so use a supported signal instead
|
|
1319
|
-
/* c8 ignore start */
|
|
1320
|
-
#hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
1321
|
-
/* c8 ignore stop */
|
|
1322
|
-
#emitter = new Emitter();
|
|
1323
|
-
#process;
|
|
1324
|
-
#originalProcessEmit;
|
|
1325
|
-
#originalProcessReallyExit;
|
|
1326
|
-
#sigListeners = {};
|
|
1327
|
-
#loaded = false;
|
|
1328
|
-
constructor(process4) {
|
|
1329
|
-
super();
|
|
1330
|
-
this.#process = process4;
|
|
1331
|
-
this.#sigListeners = {};
|
|
1332
|
-
for (const sig of signals) {
|
|
1333
|
-
this.#sigListeners[sig] = () => {
|
|
1334
|
-
const listeners = this.#process.listeners(sig);
|
|
1335
|
-
let { count } = this.#emitter;
|
|
1336
|
-
const p = process4;
|
|
1337
|
-
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
|
|
1338
|
-
count += p.__signal_exit_emitter__.count;
|
|
1339
|
-
}
|
|
1340
|
-
if (listeners.length === count) {
|
|
1341
|
-
this.unload();
|
|
1342
|
-
const ret = this.#emitter.emit("exit", null, sig);
|
|
1343
|
-
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
1344
|
-
if (!ret)
|
|
1345
|
-
process4.kill(process4.pid, s);
|
|
1346
|
-
}
|
|
1347
|
-
};
|
|
1348
|
-
}
|
|
1349
|
-
this.#originalProcessReallyExit = process4.reallyExit;
|
|
1350
|
-
this.#originalProcessEmit = process4.emit;
|
|
1351
|
-
}
|
|
1352
|
-
onExit(cb, opts) {
|
|
1353
|
-
if (!processOk(this.#process)) {
|
|
1354
|
-
return () => {
|
|
1355
|
-
};
|
|
1356
|
-
}
|
|
1357
|
-
if (this.#loaded === false) {
|
|
1358
|
-
this.load();
|
|
1359
|
-
}
|
|
1360
|
-
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
1361
|
-
this.#emitter.on(ev, cb);
|
|
1362
|
-
return () => {
|
|
1363
|
-
this.#emitter.removeListener(ev, cb);
|
|
1364
|
-
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
|
|
1365
|
-
this.unload();
|
|
1366
|
-
}
|
|
1367
|
-
};
|
|
1368
|
-
}
|
|
1369
|
-
load() {
|
|
1370
|
-
if (this.#loaded) {
|
|
1371
|
-
return;
|
|
1372
|
-
}
|
|
1373
|
-
this.#loaded = true;
|
|
1374
|
-
this.#emitter.count += 1;
|
|
1375
|
-
for (const sig of signals) {
|
|
1376
|
-
try {
|
|
1377
|
-
const fn = this.#sigListeners[sig];
|
|
1378
|
-
if (fn)
|
|
1379
|
-
this.#process.on(sig, fn);
|
|
1380
|
-
} catch (_) {
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
this.#process.emit = (ev, ...a) => {
|
|
1384
|
-
return this.#processEmit(ev, ...a);
|
|
1385
|
-
};
|
|
1386
|
-
this.#process.reallyExit = (code) => {
|
|
1387
|
-
return this.#processReallyExit(code);
|
|
1388
|
-
};
|
|
1389
|
-
}
|
|
1390
|
-
unload() {
|
|
1391
|
-
if (!this.#loaded) {
|
|
1392
|
-
return;
|
|
1393
|
-
}
|
|
1394
|
-
this.#loaded = false;
|
|
1395
|
-
signals.forEach((sig) => {
|
|
1396
|
-
const listener = this.#sigListeners[sig];
|
|
1397
|
-
if (!listener) {
|
|
1398
|
-
throw new Error("Listener not defined for signal: " + sig);
|
|
1399
|
-
}
|
|
1400
|
-
try {
|
|
1401
|
-
this.#process.removeListener(sig, listener);
|
|
1402
|
-
} catch (_) {
|
|
1403
|
-
}
|
|
1404
|
-
});
|
|
1405
|
-
this.#process.emit = this.#originalProcessEmit;
|
|
1406
|
-
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
1407
|
-
this.#emitter.count -= 1;
|
|
1408
|
-
}
|
|
1409
|
-
#processReallyExit(code) {
|
|
1410
|
-
if (!processOk(this.#process)) {
|
|
1411
|
-
return 0;
|
|
1412
|
-
}
|
|
1413
|
-
this.#process.exitCode = code || 0;
|
|
1414
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1415
|
-
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
1416
|
-
}
|
|
1417
|
-
#processEmit(ev, ...args) {
|
|
1418
|
-
const og = this.#originalProcessEmit;
|
|
1419
|
-
if (ev === "exit" && processOk(this.#process)) {
|
|
1420
|
-
if (typeof args[0] === "number") {
|
|
1421
|
-
this.#process.exitCode = args[0];
|
|
1422
|
-
}
|
|
1423
|
-
const ret = og.call(this.#process, ev, ...args);
|
|
1424
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1425
|
-
return ret;
|
|
1426
|
-
} else {
|
|
1427
|
-
return og.call(this.#process, ev, ...args);
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
};
|
|
1431
|
-
var process3 = globalThis.process;
|
|
1432
|
-
var {
|
|
1433
|
-
/**
|
|
1434
|
-
* Called when the process is exiting, whether via signal, explicit
|
|
1435
|
-
* exit, or running out of stuff to do.
|
|
1436
|
-
*
|
|
1437
|
-
* If the global process object is not suitable for instrumentation,
|
|
1438
|
-
* then this will be a no-op.
|
|
1439
|
-
*
|
|
1440
|
-
* Returns a function that may be used to unload signal-exit.
|
|
1441
|
-
*/
|
|
1442
|
-
onExit,
|
|
1443
|
-
/**
|
|
1444
|
-
* Load the listeners. Likely you never need to call this, unless
|
|
1445
|
-
* doing a rather deep integration with signal-exit functionality.
|
|
1446
|
-
* Mostly exposed for the benefit of testing.
|
|
1447
|
-
*
|
|
1448
|
-
* @internal
|
|
1449
|
-
*/
|
|
1450
|
-
load,
|
|
1451
|
-
/**
|
|
1452
|
-
* Unload the listeners. Likely you never need to call this, unless
|
|
1453
|
-
* doing a rather deep integration with signal-exit functionality.
|
|
1454
|
-
* Mostly exposed for the benefit of testing.
|
|
1455
|
-
*
|
|
1456
|
-
* @internal
|
|
1457
|
-
*/
|
|
1458
|
-
unload
|
|
1459
|
-
} = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback());
|
|
1460
|
-
|
|
1461
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
1462
|
-
import { stripVTControlCharacters } from "util";
|
|
1463
|
-
|
|
1464
|
-
// node_modules/.pnpm/@inquirer+ansi@2.0.4/node_modules/@inquirer/ansi/dist/index.js
|
|
1465
|
-
var ESC2 = "\x1B[";
|
|
1466
|
-
var cursorLeft = ESC2 + "G";
|
|
1467
|
-
var cursorHide = ESC2 + "?25l";
|
|
1468
|
-
var cursorShow = ESC2 + "?25h";
|
|
1469
|
-
var cursorUp = (rows = 1) => rows > 0 ? `${ESC2}${rows}A` : "";
|
|
1470
|
-
var cursorDown = (rows = 1) => rows > 0 ? `${ESC2}${rows}B` : "";
|
|
1471
|
-
var cursorTo = (x, y) => {
|
|
1472
|
-
if (typeof y === "number" && !Number.isNaN(y)) {
|
|
1473
|
-
return `${ESC2}${y + 1};${x + 1}H`;
|
|
1474
|
-
}
|
|
1475
|
-
return `${ESC2}${x + 1}G`;
|
|
1476
|
-
};
|
|
1477
|
-
var eraseLine = ESC2 + "2K";
|
|
1478
|
-
var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
1479
|
-
|
|
1480
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
1481
|
-
var height = (content) => content.split("\n").length;
|
|
1482
|
-
var lastLine = (content) => content.split("\n").pop() ?? "";
|
|
1483
|
-
var ScreenManager = class {
|
|
1484
|
-
// These variables are keeping information to allow correct prompt re-rendering
|
|
1485
|
-
height = 0;
|
|
1486
|
-
extraLinesUnderPrompt = 0;
|
|
1487
|
-
cursorPos;
|
|
1488
|
-
rl;
|
|
1489
|
-
constructor(rl) {
|
|
1490
|
-
this.rl = rl;
|
|
1491
|
-
this.cursorPos = rl.getCursorPos();
|
|
1492
|
-
}
|
|
1493
|
-
write(content) {
|
|
1494
|
-
this.rl.output.unmute();
|
|
1495
|
-
this.rl.output.write(content);
|
|
1496
|
-
this.rl.output.mute();
|
|
1497
|
-
}
|
|
1498
|
-
render(content, bottomContent = "") {
|
|
1499
|
-
const promptLine = lastLine(content);
|
|
1500
|
-
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
1501
|
-
let prompt = rawPromptLine;
|
|
1502
|
-
if (this.rl.line.length > 0) {
|
|
1503
|
-
prompt = prompt.slice(0, -this.rl.line.length);
|
|
1504
|
-
}
|
|
1505
|
-
this.rl.setPrompt(prompt);
|
|
1506
|
-
this.cursorPos = this.rl.getCursorPos();
|
|
1507
|
-
const width = readlineWidth();
|
|
1508
|
-
content = breakLines(content, width);
|
|
1509
|
-
bottomContent = breakLines(bottomContent, width);
|
|
1510
|
-
if (rawPromptLine.length % width === 0) {
|
|
1511
|
-
content += "\n";
|
|
1512
|
-
}
|
|
1513
|
-
let output = content + (bottomContent ? "\n" + bottomContent : "");
|
|
1514
|
-
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
|
|
1515
|
-
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
|
|
1516
|
-
if (bottomContentHeight > 0)
|
|
1517
|
-
output += cursorUp(bottomContentHeight);
|
|
1518
|
-
output += cursorTo(this.cursorPos.cols);
|
|
1519
|
-
this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
|
|
1520
|
-
this.extraLinesUnderPrompt = bottomContentHeight;
|
|
1521
|
-
this.height = height(output);
|
|
1522
|
-
}
|
|
1523
|
-
checkCursorPos() {
|
|
1524
|
-
const cursorPos = this.rl.getCursorPos();
|
|
1525
|
-
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
1526
|
-
this.write(cursorTo(cursorPos.cols));
|
|
1527
|
-
this.cursorPos = cursorPos;
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
done({ clearContent }) {
|
|
1531
|
-
this.rl.setPrompt("");
|
|
1532
|
-
let output = cursorDown(this.extraLinesUnderPrompt);
|
|
1533
|
-
output += clearContent ? eraseLines(this.height) : "\n";
|
|
1534
|
-
output += cursorShow;
|
|
1535
|
-
this.write(output);
|
|
1536
|
-
this.rl.close();
|
|
1537
|
-
}
|
|
1538
|
-
};
|
|
1539
|
-
|
|
1540
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
1541
|
-
var PromisePolyfill = class extends Promise {
|
|
1542
|
-
// Available starting from Node 22
|
|
1543
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
1544
|
-
static withResolver() {
|
|
1545
|
-
let resolve;
|
|
1546
|
-
let reject;
|
|
1547
|
-
const promise = new Promise((res, rej) => {
|
|
1548
|
-
resolve = res;
|
|
1549
|
-
reject = rej;
|
|
1550
|
-
});
|
|
1551
|
-
return { promise, resolve, reject };
|
|
1552
|
-
}
|
|
1553
|
-
};
|
|
1554
|
-
|
|
1555
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
1556
|
-
var nativeSetImmediate = globalThis.setImmediate;
|
|
1557
|
-
function getCallSites() {
|
|
1558
|
-
const _prepareStackTrace = Error.prepareStackTrace;
|
|
1559
|
-
let result = [];
|
|
1560
|
-
try {
|
|
1561
|
-
Error.prepareStackTrace = (_, callSites) => {
|
|
1562
|
-
const callSitesWithoutCurrent = callSites.slice(1);
|
|
1563
|
-
result = callSitesWithoutCurrent;
|
|
1564
|
-
return callSitesWithoutCurrent;
|
|
1565
|
-
};
|
|
1566
|
-
new Error().stack;
|
|
1567
|
-
} catch {
|
|
1568
|
-
return result;
|
|
1569
|
-
}
|
|
1570
|
-
Error.prepareStackTrace = _prepareStackTrace;
|
|
1571
|
-
return result;
|
|
1572
|
-
}
|
|
1573
|
-
function createPrompt(view) {
|
|
1574
|
-
const callSites = getCallSites();
|
|
1575
|
-
const prompt = (config, context = {}) => {
|
|
1576
|
-
const { input = process.stdin, signal } = context;
|
|
1577
|
-
const cleanups = /* @__PURE__ */ new Set();
|
|
1578
|
-
const output = new import_mute_stream.default();
|
|
1579
|
-
output.pipe(context.output ?? process.stdout);
|
|
1580
|
-
output.mute();
|
|
1581
|
-
const rl = readline2.createInterface({
|
|
1582
|
-
terminal: true,
|
|
1583
|
-
input,
|
|
1584
|
-
output
|
|
1585
|
-
});
|
|
1586
|
-
const screen = new ScreenManager(rl);
|
|
1587
|
-
const { promise, resolve, reject } = PromisePolyfill.withResolver();
|
|
1588
|
-
const cancel = () => reject(new CancelPromptError());
|
|
1589
|
-
if (signal) {
|
|
1590
|
-
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
1591
|
-
if (signal.aborted) {
|
|
1592
|
-
abort();
|
|
1593
|
-
return Object.assign(promise, { cancel });
|
|
1594
|
-
}
|
|
1595
|
-
signal.addEventListener("abort", abort);
|
|
1596
|
-
cleanups.add(() => signal.removeEventListener("abort", abort));
|
|
1597
|
-
}
|
|
1598
|
-
cleanups.add(onExit((code, signal2) => {
|
|
1599
|
-
reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
|
|
1600
|
-
}));
|
|
1601
|
-
const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
|
|
1602
|
-
rl.on("SIGINT", sigint);
|
|
1603
|
-
cleanups.add(() => rl.removeListener("SIGINT", sigint));
|
|
1604
|
-
return withHooks(rl, (cycle) => {
|
|
1605
|
-
const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
1606
|
-
rl.on("close", hooksCleanup);
|
|
1607
|
-
cleanups.add(() => rl.removeListener("close", hooksCleanup));
|
|
1608
|
-
const startCycle = () => {
|
|
1609
|
-
const checkCursorPos = () => screen.checkCursorPos();
|
|
1610
|
-
rl.input.on("keypress", checkCursorPos);
|
|
1611
|
-
cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
|
|
1612
|
-
cycle(() => {
|
|
1613
|
-
try {
|
|
1614
|
-
const nextView = view(config, (value) => {
|
|
1615
|
-
setImmediate(() => resolve(value));
|
|
1616
|
-
});
|
|
1617
|
-
if (nextView === void 0) {
|
|
1618
|
-
const callerFilename = callSites[1]?.getFileName();
|
|
1619
|
-
throw new Error(`Prompt functions must return a string.
|
|
1620
|
-
at ${callerFilename}`);
|
|
1621
|
-
}
|
|
1622
|
-
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
1623
|
-
screen.render(content, bottomContent);
|
|
1624
|
-
effectScheduler.run();
|
|
1625
|
-
} catch (error) {
|
|
1626
|
-
reject(error);
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
};
|
|
1630
|
-
if ("readableFlowing" in input) {
|
|
1631
|
-
nativeSetImmediate(startCycle);
|
|
1632
|
-
} else {
|
|
1633
|
-
startCycle();
|
|
1634
|
-
}
|
|
1635
|
-
return Object.assign(promise.then((answer) => {
|
|
1636
|
-
effectScheduler.clearAll();
|
|
1637
|
-
return answer;
|
|
1638
|
-
}, (error) => {
|
|
1639
|
-
effectScheduler.clearAll();
|
|
1640
|
-
throw error;
|
|
1641
|
-
}).finally(() => {
|
|
1642
|
-
cleanups.forEach((cleanup) => cleanup());
|
|
1643
|
-
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
1644
|
-
output.end();
|
|
1645
|
-
}).then(() => promise), { cancel });
|
|
1646
|
-
});
|
|
1647
|
-
};
|
|
1648
|
-
return prompt;
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
// node_modules/.pnpm/@inquirer+core@11.1.7_@types+node@25.5.0/node_modules/@inquirer/core/dist/lib/Separator.js
|
|
1652
|
-
import { styleText as styleText2 } from "util";
|
|
1653
|
-
var Separator = class {
|
|
1654
|
-
separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
|
|
1655
|
-
type = "separator";
|
|
1656
|
-
constructor(separator) {
|
|
1657
|
-
if (separator) {
|
|
1658
|
-
this.separator = separator;
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
static isSeparator(choice) {
|
|
1662
|
-
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
1663
|
-
}
|
|
1664
|
-
};
|
|
1665
|
-
|
|
1666
|
-
// node_modules/.pnpm/@inquirer+input@5.0.10_@types+node@25.5.0/node_modules/@inquirer/input/dist/index.js
|
|
1667
|
-
var inputTheme = {
|
|
1668
|
-
validationFailureMode: "keep"
|
|
1669
|
-
};
|
|
1670
|
-
var dist_default4 = createPrompt((config, done) => {
|
|
1671
|
-
const { prefill = "tab" } = config;
|
|
1672
|
-
const theme = makeTheme(inputTheme, config.theme);
|
|
1673
|
-
const [status, setStatus] = useState("idle");
|
|
1674
|
-
const [defaultValue, setDefaultValue] = useState(String(config.default ?? ""));
|
|
1675
|
-
const [errorMsg, setError] = useState();
|
|
1676
|
-
const [value, setValue] = useState("");
|
|
1677
|
-
const prefix = usePrefix({ status, theme });
|
|
1678
|
-
async function validate(value2) {
|
|
1679
|
-
const { required, pattern, patternError = "Invalid input" } = config;
|
|
1680
|
-
if (required && !value2) {
|
|
1681
|
-
return "You must provide a value";
|
|
1682
|
-
}
|
|
1683
|
-
if (pattern && !pattern.test(value2)) {
|
|
1684
|
-
return patternError;
|
|
1685
|
-
}
|
|
1686
|
-
if (typeof config.validate === "function") {
|
|
1687
|
-
return await config.validate(value2) || "You must provide a valid value";
|
|
1688
|
-
}
|
|
1689
|
-
return true;
|
|
1690
|
-
}
|
|
1691
|
-
useKeypress(async (key, rl) => {
|
|
1692
|
-
if (status !== "idle") {
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
if (isEnterKey(key)) {
|
|
1696
|
-
const answer = value || defaultValue;
|
|
1697
|
-
setStatus("loading");
|
|
1698
|
-
const isValid = await validate(answer);
|
|
1699
|
-
if (isValid === true) {
|
|
1700
|
-
setValue(answer);
|
|
1701
|
-
setStatus("done");
|
|
1702
|
-
done(answer);
|
|
1703
|
-
} else {
|
|
1704
|
-
if (theme.validationFailureMode === "clear") {
|
|
1705
|
-
setValue("");
|
|
1706
|
-
} else {
|
|
1707
|
-
rl.write(value);
|
|
1708
|
-
}
|
|
1709
|
-
setError(isValid);
|
|
1710
|
-
setStatus("idle");
|
|
1711
|
-
}
|
|
1712
|
-
} else if (isBackspaceKey(key) && !value) {
|
|
1713
|
-
setDefaultValue("");
|
|
1714
|
-
} else if (isTabKey(key) && !value) {
|
|
1715
|
-
setDefaultValue("");
|
|
1716
|
-
rl.clearLine(0);
|
|
1717
|
-
rl.write(defaultValue);
|
|
1718
|
-
setValue(defaultValue);
|
|
1719
|
-
} else {
|
|
1720
|
-
setValue(rl.line);
|
|
1721
|
-
setError(void 0);
|
|
1722
|
-
}
|
|
1723
|
-
});
|
|
1724
|
-
useEffect((rl) => {
|
|
1725
|
-
if (prefill === "editable" && defaultValue) {
|
|
1726
|
-
rl.write(defaultValue);
|
|
1727
|
-
setValue(defaultValue);
|
|
1728
|
-
}
|
|
1729
|
-
}, []);
|
|
1730
|
-
const message = theme.style.message(config.message, status);
|
|
1731
|
-
let formattedValue = value;
|
|
1732
|
-
if (typeof config.transformer === "function") {
|
|
1733
|
-
formattedValue = config.transformer(value, { isFinal: status === "done" });
|
|
1734
|
-
} else if (status === "done") {
|
|
1735
|
-
formattedValue = theme.style.answer(value);
|
|
1736
|
-
}
|
|
1737
|
-
let defaultStr;
|
|
1738
|
-
if (defaultValue && status !== "done" && !value) {
|
|
1739
|
-
defaultStr = theme.style.defaultAnswer(defaultValue);
|
|
1740
|
-
}
|
|
1741
|
-
let error = "";
|
|
1742
|
-
if (errorMsg) {
|
|
1743
|
-
error = theme.style.error(errorMsg);
|
|
1744
|
-
}
|
|
1745
|
-
return [
|
|
1746
|
-
[prefix, message, defaultStr, formattedValue].filter((v) => v !== void 0).join(" "),
|
|
1747
|
-
error
|
|
1748
|
-
];
|
|
1749
|
-
});
|
|
1750
|
-
|
|
1751
|
-
// node_modules/.pnpm/@inquirer+select@5.1.2_@types+node@25.5.0/node_modules/@inquirer/select/dist/index.js
|
|
1752
|
-
import { styleText as styleText3 } from "util";
|
|
1753
|
-
var selectTheme = {
|
|
1754
|
-
icon: { cursor: dist_default.pointer },
|
|
1755
|
-
style: {
|
|
1756
|
-
disabled: (text) => styleText3("dim", text),
|
|
1757
|
-
description: (text) => styleText3("cyan", text),
|
|
1758
|
-
keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " \u2022 "))
|
|
1759
|
-
},
|
|
1760
|
-
i18n: { disabledError: "This option is disabled and cannot be selected." },
|
|
1761
|
-
indexMode: "hidden",
|
|
1762
|
-
keybindings: []
|
|
1763
|
-
};
|
|
1764
|
-
function isSelectable(item) {
|
|
1765
|
-
return !Separator.isSeparator(item) && !item.disabled;
|
|
1766
|
-
}
|
|
1767
|
-
function isNavigable(item) {
|
|
1768
|
-
return !Separator.isSeparator(item);
|
|
1769
|
-
}
|
|
1770
|
-
function normalizeChoices(choices) {
|
|
1771
|
-
return choices.map((choice) => {
|
|
1772
|
-
if (Separator.isSeparator(choice))
|
|
1773
|
-
return choice;
|
|
1774
|
-
if (typeof choice !== "object" || choice === null || !("value" in choice)) {
|
|
1775
|
-
const name2 = String(choice);
|
|
1776
|
-
return {
|
|
1777
|
-
value: choice,
|
|
1778
|
-
name: name2,
|
|
1779
|
-
short: name2,
|
|
1780
|
-
disabled: false
|
|
1781
|
-
};
|
|
1782
|
-
}
|
|
1783
|
-
const name = choice.name ?? String(choice.value);
|
|
1784
|
-
const normalizedChoice = {
|
|
1785
|
-
value: choice.value,
|
|
1786
|
-
name,
|
|
1787
|
-
short: choice.short ?? name,
|
|
1788
|
-
disabled: choice.disabled ?? false
|
|
1789
|
-
};
|
|
1790
|
-
if (choice.description) {
|
|
1791
|
-
normalizedChoice.description = choice.description;
|
|
1792
|
-
}
|
|
1793
|
-
return normalizedChoice;
|
|
1794
|
-
});
|
|
1795
|
-
}
|
|
1796
|
-
var dist_default5 = createPrompt((config, done) => {
|
|
1797
|
-
const { loop = true, pageSize = 7 } = config;
|
|
1798
|
-
const theme = makeTheme(selectTheme, config.theme);
|
|
1799
|
-
const { keybindings } = theme;
|
|
1800
|
-
const [status, setStatus] = useState("idle");
|
|
1801
|
-
const prefix = usePrefix({ status, theme });
|
|
1802
|
-
const searchTimeoutRef = useRef();
|
|
1803
|
-
const searchEnabled = !keybindings.includes("vim");
|
|
1804
|
-
const items = useMemo(() => normalizeChoices(config.choices), [config.choices]);
|
|
1805
|
-
const bounds = useMemo(() => {
|
|
1806
|
-
const first = items.findIndex(isNavigable);
|
|
1807
|
-
const last = items.findLastIndex(isNavigable);
|
|
1808
|
-
if (first === -1) {
|
|
1809
|
-
throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
|
|
1810
|
-
}
|
|
1811
|
-
return { first, last };
|
|
1812
|
-
}, [items]);
|
|
1813
|
-
const defaultItemIndex = useMemo(() => {
|
|
1814
|
-
if (!("default" in config))
|
|
1815
|
-
return -1;
|
|
1816
|
-
return items.findIndex((item) => isSelectable(item) && item.value === config.default);
|
|
1817
|
-
}, [config.default, items]);
|
|
1818
|
-
const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
|
|
1819
|
-
const selectedChoice = items[active];
|
|
1820
|
-
const [errorMsg, setError] = useState();
|
|
1821
|
-
useKeypress((key, rl) => {
|
|
1822
|
-
clearTimeout(searchTimeoutRef.current);
|
|
1823
|
-
if (errorMsg) {
|
|
1824
|
-
setError(void 0);
|
|
1825
|
-
}
|
|
1826
|
-
if (isEnterKey(key)) {
|
|
1827
|
-
if (selectedChoice.disabled) {
|
|
1828
|
-
setError(theme.i18n.disabledError);
|
|
1829
|
-
} else {
|
|
1830
|
-
setStatus("done");
|
|
1831
|
-
done(selectedChoice.value);
|
|
1832
|
-
}
|
|
1833
|
-
} else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
|
|
1834
|
-
rl.clearLine(0);
|
|
1835
|
-
if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
|
|
1836
|
-
const offset = isUpKey(key, keybindings) ? -1 : 1;
|
|
1837
|
-
let next = active;
|
|
1838
|
-
do {
|
|
1839
|
-
next = (next + offset + items.length) % items.length;
|
|
1840
|
-
} while (!isNavigable(items[next]));
|
|
1841
|
-
setActive(next);
|
|
1842
|
-
}
|
|
1843
|
-
} else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
|
|
1844
|
-
const selectedIndex = Number(rl.line) - 1;
|
|
1845
|
-
let selectableIndex = -1;
|
|
1846
|
-
const position = items.findIndex((item2) => {
|
|
1847
|
-
if (Separator.isSeparator(item2))
|
|
1848
|
-
return false;
|
|
1849
|
-
selectableIndex++;
|
|
1850
|
-
return selectableIndex === selectedIndex;
|
|
1851
|
-
});
|
|
1852
|
-
const item = items[position];
|
|
1853
|
-
if (item != null && isSelectable(item)) {
|
|
1854
|
-
setActive(position);
|
|
1855
|
-
}
|
|
1856
|
-
searchTimeoutRef.current = setTimeout(() => {
|
|
1857
|
-
rl.clearLine(0);
|
|
1858
|
-
}, 700);
|
|
1859
|
-
} else if (isBackspaceKey(key)) {
|
|
1860
|
-
rl.clearLine(0);
|
|
1861
|
-
} else if (searchEnabled) {
|
|
1862
|
-
const searchTerm = rl.line.toLowerCase();
|
|
1863
|
-
const matchIndex = items.findIndex((item) => {
|
|
1864
|
-
if (Separator.isSeparator(item) || !isSelectable(item))
|
|
1865
|
-
return false;
|
|
1866
|
-
return item.name.toLowerCase().startsWith(searchTerm);
|
|
1867
|
-
});
|
|
1868
|
-
if (matchIndex !== -1) {
|
|
1869
|
-
setActive(matchIndex);
|
|
1870
|
-
}
|
|
1871
|
-
searchTimeoutRef.current = setTimeout(() => {
|
|
1872
|
-
rl.clearLine(0);
|
|
1873
|
-
}, 700);
|
|
1874
|
-
}
|
|
1875
|
-
});
|
|
1876
|
-
useEffect(() => () => {
|
|
1877
|
-
clearTimeout(searchTimeoutRef.current);
|
|
1878
|
-
}, []);
|
|
1879
|
-
const message = theme.style.message(config.message, status);
|
|
1880
|
-
const helpLine = theme.style.keysHelpTip([
|
|
1881
|
-
["\u2191\u2193", "navigate"],
|
|
1882
|
-
["\u23CE", "select"]
|
|
1883
|
-
]);
|
|
1884
|
-
let separatorCount = 0;
|
|
1885
|
-
const page = usePagination({
|
|
1886
|
-
items,
|
|
1887
|
-
active,
|
|
1888
|
-
renderItem({ item, isActive, index }) {
|
|
1889
|
-
if (Separator.isSeparator(item)) {
|
|
1890
|
-
separatorCount++;
|
|
1891
|
-
return ` ${item.separator}`;
|
|
1892
|
-
}
|
|
1893
|
-
const cursor = isActive ? theme.icon.cursor : " ";
|
|
1894
|
-
const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
|
|
1895
|
-
if (item.disabled) {
|
|
1896
|
-
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
1897
|
-
const disabledCursor = isActive ? theme.icon.cursor : "-";
|
|
1898
|
-
return theme.style.disabled(`${disabledCursor} ${indexLabel}${item.name} ${disabledLabel}`);
|
|
1899
|
-
}
|
|
1900
|
-
const color = isActive ? theme.style.highlight : (x) => x;
|
|
1901
|
-
return color(`${cursor} ${indexLabel}${item.name}`);
|
|
1902
|
-
},
|
|
1903
|
-
pageSize,
|
|
1904
|
-
loop
|
|
1905
|
-
});
|
|
1906
|
-
if (status === "done") {
|
|
1907
|
-
return [prefix, message, theme.style.answer(selectedChoice.short)].filter(Boolean).join(" ");
|
|
1908
|
-
}
|
|
1909
|
-
const { description } = selectedChoice;
|
|
1910
|
-
const lines = [
|
|
1911
|
-
[prefix, message].filter(Boolean).join(" "),
|
|
1912
|
-
page,
|
|
1913
|
-
" ",
|
|
1914
|
-
description ? theme.style.description(description) : "",
|
|
1915
|
-
errorMsg ? theme.style.error(errorMsg) : "",
|
|
1916
|
-
helpLine
|
|
1917
|
-
].filter(Boolean).join("\n").trimEnd();
|
|
1918
|
-
return `${lines}${cursorHide}`;
|
|
1919
|
-
});
|
|
1920
|
-
|
|
1921
|
-
// packages/core/src/setup.ts
|
|
1922
|
-
async function validateBotToken(token) {
|
|
1923
|
-
try {
|
|
1924
|
-
const res = await fetch(`https://api.telegram.org/bot${token}/getMe`);
|
|
1925
|
-
const data = await res.json();
|
|
1926
|
-
if (data.ok && data.result) {
|
|
1927
|
-
return { ok: true, botName: data.result.first_name, botUsername: data.result.username };
|
|
1928
|
-
}
|
|
1929
|
-
return { ok: false, error: data.description || "Invalid token" };
|
|
1930
|
-
} catch (err) {
|
|
1931
|
-
return { ok: false, error: err.message };
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
async function validateChatId(token, chatId) {
|
|
1935
|
-
try {
|
|
1936
|
-
const res = await fetch(`https://api.telegram.org/bot${token}/getChat`, {
|
|
1937
|
-
method: "POST",
|
|
1938
|
-
headers: { "Content-Type": "application/json" },
|
|
1939
|
-
body: JSON.stringify({ chat_id: chatId })
|
|
1940
|
-
});
|
|
1941
|
-
const data = await res.json();
|
|
1942
|
-
if (!data.ok || !data.result) {
|
|
1943
|
-
return { ok: false, error: data.description || "Invalid chat ID" };
|
|
1944
|
-
}
|
|
1945
|
-
if (data.result.type !== "supergroup") {
|
|
1946
|
-
return { ok: false, error: `Chat is "${data.result.type}", must be a supergroup` };
|
|
1947
|
-
}
|
|
1948
|
-
return { ok: true, title: data.result.title, isForum: data.result.is_forum === true };
|
|
1949
|
-
} catch (err) {
|
|
1950
|
-
return { ok: false, error: err.message };
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
var KNOWN_AGENTS = [
|
|
1954
|
-
{ name: "claude", commands: ["claude-agent-acp", "claude-code", "claude"] },
|
|
1955
|
-
{ name: "codex", commands: ["codex"] }
|
|
1956
|
-
];
|
|
1957
|
-
function commandExists(cmd) {
|
|
1958
|
-
try {
|
|
1959
|
-
execFileSync("which", [cmd], { stdio: "pipe" });
|
|
1960
|
-
return true;
|
|
1961
|
-
} catch {
|
|
1962
|
-
}
|
|
1963
|
-
let dir = process.cwd();
|
|
1964
|
-
while (true) {
|
|
1965
|
-
const binPath = path.join(dir, "node_modules", ".bin", cmd);
|
|
1966
|
-
if (fs.existsSync(binPath)) return true;
|
|
1967
|
-
const parent = path.dirname(dir);
|
|
1968
|
-
if (parent === dir) break;
|
|
1969
|
-
dir = parent;
|
|
1970
|
-
}
|
|
1971
|
-
return false;
|
|
1972
|
-
}
|
|
1973
|
-
async function detectAgents() {
|
|
1974
|
-
const found = [];
|
|
1975
|
-
for (const agent of KNOWN_AGENTS) {
|
|
1976
|
-
const available = [];
|
|
1977
|
-
for (const cmd of agent.commands) {
|
|
1978
|
-
if (commandExists(cmd)) {
|
|
1979
|
-
available.push(cmd);
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
if (available.length > 0) {
|
|
1983
|
-
const preferred = available[0];
|
|
1984
|
-
found.push({ name: agent.name, command: preferred });
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
return found;
|
|
1988
|
-
}
|
|
1989
|
-
async function validateAgentCommand(command) {
|
|
1990
|
-
try {
|
|
1991
|
-
execFileSync("which", [command], { stdio: "pipe" });
|
|
1992
|
-
return true;
|
|
1993
|
-
} catch {
|
|
1994
|
-
return false;
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
async function setupTelegram() {
|
|
1998
|
-
console.log("\n--- Step 1: Telegram Setup ---\n");
|
|
1999
|
-
let botToken = "";
|
|
2000
|
-
let botUsername = "";
|
|
2001
|
-
let botName = "";
|
|
2002
|
-
while (true) {
|
|
2003
|
-
botToken = await dist_default4({
|
|
2004
|
-
message: "Telegram bot token (from @BotFather):",
|
|
2005
|
-
validate: (val) => val.trim().length > 0 || "Token cannot be empty"
|
|
2006
|
-
});
|
|
2007
|
-
botToken = botToken.trim();
|
|
2008
|
-
console.log("Validating bot token...");
|
|
2009
|
-
const result = await validateBotToken(botToken);
|
|
2010
|
-
if (result.ok) {
|
|
2011
|
-
botUsername = result.botUsername;
|
|
2012
|
-
botName = result.botName;
|
|
2013
|
-
console.log(`\u2713 Bot "${botName}" (@${botUsername}) connected`);
|
|
2014
|
-
break;
|
|
2015
|
-
}
|
|
2016
|
-
console.log(`\u2717 Validation failed: ${result.error}`);
|
|
2017
|
-
const action = await dist_default5({
|
|
2018
|
-
message: "What would you like to do?",
|
|
2019
|
-
choices: [
|
|
2020
|
-
{ name: "Re-enter token", value: "retry" },
|
|
2021
|
-
{ name: "Skip validation (use token as-is)", value: "skip" }
|
|
2022
|
-
]
|
|
2023
|
-
});
|
|
2024
|
-
if (action === "skip") break;
|
|
2025
|
-
}
|
|
2026
|
-
let chatId = 0;
|
|
2027
|
-
while (true) {
|
|
2028
|
-
const chatIdStr = await dist_default4({
|
|
2029
|
-
message: "Telegram supergroup chat ID (e.g. -1001234567890):",
|
|
2030
|
-
validate: (val) => {
|
|
2031
|
-
const n = Number(val.trim());
|
|
2032
|
-
if (isNaN(n) || !Number.isInteger(n)) return "Chat ID must be an integer";
|
|
2033
|
-
return true;
|
|
2034
|
-
}
|
|
2035
|
-
});
|
|
2036
|
-
chatId = Number(chatIdStr.trim());
|
|
2037
|
-
console.log("Validating chat ID...");
|
|
2038
|
-
const result = await validateChatId(botToken, chatId);
|
|
2039
|
-
if (result.ok) {
|
|
2040
|
-
if (!result.isForum) {
|
|
2041
|
-
console.log(`\u26A0 Warning: "${result.title}" does not have Topics enabled.`);
|
|
2042
|
-
console.log(" Please enable Topics in group settings \u2192 Topics \u2192 Enable.");
|
|
2043
|
-
} else {
|
|
2044
|
-
console.log(`\u2713 Connected to "${result.title}" (Topics enabled)`);
|
|
2045
|
-
}
|
|
2046
|
-
break;
|
|
2047
|
-
}
|
|
2048
|
-
console.log(`\u2717 Validation failed: ${result.error}`);
|
|
2049
|
-
if (result.error.includes("must be a supergroup")) {
|
|
2050
|
-
console.log(" Tip: Create a Supergroup in Telegram, then enable Topics in group settings.");
|
|
2051
|
-
}
|
|
2052
|
-
const action = await dist_default5({
|
|
2053
|
-
message: "What would you like to do?",
|
|
2054
|
-
choices: [
|
|
2055
|
-
{ name: "Re-enter chat ID", value: "retry" },
|
|
2056
|
-
{ name: "Skip validation (use chat ID as-is)", value: "skip" }
|
|
2057
|
-
]
|
|
2058
|
-
});
|
|
2059
|
-
if (action === "skip") break;
|
|
2060
|
-
}
|
|
2061
|
-
return {
|
|
2062
|
-
enabled: true,
|
|
2063
|
-
botToken,
|
|
2064
|
-
chatId,
|
|
2065
|
-
notificationTopicId: null,
|
|
2066
|
-
assistantTopicId: null
|
|
2067
|
-
};
|
|
2068
|
-
}
|
|
2069
|
-
async function setupAgents() {
|
|
2070
|
-
console.log("\n--- Step 2: Agent Setup ---\n");
|
|
2071
|
-
console.log("Detecting agents in PATH...");
|
|
2072
|
-
const detected = await detectAgents();
|
|
2073
|
-
const agents = {};
|
|
2074
|
-
if (detected.length > 0) {
|
|
2075
|
-
for (const agent of detected) {
|
|
2076
|
-
agents[agent.name] = { command: agent.command, args: [], env: {} };
|
|
2077
|
-
}
|
|
2078
|
-
console.log(`Found: ${detected.map((a) => `${a.name} (${a.command})`).join(", ")}`);
|
|
2079
|
-
} else {
|
|
2080
|
-
agents["claude"] = { command: "claude-agent-acp", args: [], env: {} };
|
|
2081
|
-
console.log("No agents detected. Using default: claude (claude-agent-acp)");
|
|
2082
|
-
}
|
|
2083
|
-
const defaultAgent = Object.keys(agents)[0];
|
|
2084
|
-
console.log(`Default agent: ${defaultAgent}`);
|
|
2085
|
-
return { agents, defaultAgent };
|
|
2086
|
-
}
|
|
2087
|
-
async function setupWorkspace() {
|
|
2088
|
-
console.log("\n--- Step 3: Workspace Setup ---\n");
|
|
2089
|
-
const baseDir = await dist_default4({
|
|
2090
|
-
message: "Workspace base directory:",
|
|
2091
|
-
default: "~/openacp-workspace",
|
|
2092
|
-
validate: (val) => val.trim().length > 0 || "Path cannot be empty"
|
|
2093
|
-
});
|
|
2094
|
-
return { baseDir: baseDir.trim() };
|
|
2095
|
-
}
|
|
2096
|
-
async function setupSecurity() {
|
|
2097
|
-
console.log("\n--- Step 4: Security Setup ---\n");
|
|
2098
|
-
const userIdsStr = await dist_default4({
|
|
2099
|
-
message: "Allowed Telegram user IDs (comma-separated, or leave empty to allow all):",
|
|
2100
|
-
default: ""
|
|
2101
|
-
});
|
|
2102
|
-
const allowedUserIds = userIdsStr.trim() ? userIdsStr.split(",").map((id) => id.trim()).filter((id) => id.length > 0) : [];
|
|
2103
|
-
const maxConcurrentStr = await dist_default4({
|
|
2104
|
-
message: "Max concurrent sessions:",
|
|
2105
|
-
default: "5",
|
|
2106
|
-
validate: (val) => {
|
|
2107
|
-
const n = Number(val);
|
|
2108
|
-
return !isNaN(n) && Number.isInteger(n) && n > 0 || "Must be a positive integer";
|
|
2109
|
-
}
|
|
2110
|
-
});
|
|
2111
|
-
const timeoutStr = await dist_default4({
|
|
2112
|
-
message: "Session timeout (minutes):",
|
|
2113
|
-
default: "60",
|
|
2114
|
-
validate: (val) => {
|
|
2115
|
-
const n = Number(val);
|
|
2116
|
-
return !isNaN(n) && Number.isInteger(n) && n > 0 || "Must be a positive integer";
|
|
2117
|
-
}
|
|
2118
|
-
});
|
|
2119
|
-
return {
|
|
2120
|
-
allowedUserIds,
|
|
2121
|
-
maxConcurrentSessions: Number(maxConcurrentStr),
|
|
2122
|
-
sessionTimeoutMinutes: Number(timeoutStr)
|
|
2123
|
-
};
|
|
2124
|
-
}
|
|
2125
|
-
function printWelcomeBanner() {
|
|
2126
|
-
console.log(`
|
|
2127
|
-
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
|
|
2128
|
-
\u2502 \u2502
|
|
2129
|
-
\u2502 Welcome to OpenACP! \u2502
|
|
2130
|
-
\u2502 \u2502
|
|
2131
|
-
\u2502 Let's set up your configuration. \u2502
|
|
2132
|
-
\u2502 \u2502
|
|
2133
|
-
\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
2134
|
-
`);
|
|
2135
|
-
}
|
|
2136
|
-
function printConfigSummary(config) {
|
|
2137
|
-
console.log("\n--- Configuration Summary ---\n");
|
|
2138
|
-
console.log("Telegram:");
|
|
2139
|
-
const tg = config.channels.telegram;
|
|
2140
|
-
if (tg) {
|
|
2141
|
-
const token = String(tg.botToken || "");
|
|
2142
|
-
console.log(` Bot token: ${token.slice(0, 8)}...${token.slice(-4)}`);
|
|
2143
|
-
console.log(` Chat ID: ${tg.chatId}`);
|
|
2144
|
-
}
|
|
2145
|
-
console.log("\nAgents:");
|
|
2146
|
-
for (const [name, agent] of Object.entries(config.agents)) {
|
|
2147
|
-
const marker = name === config.defaultAgent ? " (default)" : "";
|
|
2148
|
-
console.log(` ${name}: ${agent.command}${marker}`);
|
|
2149
|
-
}
|
|
2150
|
-
console.log(`
|
|
2151
|
-
Workspace: ${config.workspace.baseDir}`);
|
|
2152
|
-
}
|
|
2153
|
-
async function runSetup(configManager) {
|
|
2154
|
-
printWelcomeBanner();
|
|
2155
|
-
try {
|
|
2156
|
-
const telegram = await setupTelegram();
|
|
2157
|
-
const { agents, defaultAgent } = await setupAgents();
|
|
2158
|
-
const workspace = await setupWorkspace();
|
|
2159
|
-
const security = { allowedUserIds: [], maxConcurrentSessions: 5, sessionTimeoutMinutes: 60 };
|
|
2160
|
-
const config = {
|
|
2161
|
-
channels: { telegram },
|
|
2162
|
-
agents,
|
|
2163
|
-
defaultAgent,
|
|
2164
|
-
workspace,
|
|
2165
|
-
security
|
|
2166
|
-
};
|
|
2167
|
-
printConfigSummary(config);
|
|
2168
|
-
try {
|
|
2169
|
-
await configManager.writeNew(config);
|
|
2170
|
-
} catch (writeErr) {
|
|
2171
|
-
console.error(`
|
|
2172
|
-
\u2717 Failed to write config to ${configManager.getConfigPath()}`);
|
|
2173
|
-
console.error(` Error: ${writeErr.message}`);
|
|
2174
|
-
console.error(" Check that you have write permissions to this path.");
|
|
2175
|
-
return false;
|
|
2176
|
-
}
|
|
2177
|
-
console.log(`
|
|
2178
|
-
\u2713 Config saved to ${configManager.getConfigPath()}`);
|
|
2179
|
-
console.log("Starting OpenACP...\n");
|
|
2180
|
-
return true;
|
|
2181
|
-
} catch (err) {
|
|
2182
|
-
if (err.name === "ExitPromptError") {
|
|
2183
|
-
console.log("\nSetup cancelled.");
|
|
2184
|
-
return false;
|
|
2185
|
-
}
|
|
2186
|
-
throw err;
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
export {
|
|
2190
|
-
detectAgents,
|
|
2191
|
-
runSetup,
|
|
2192
|
-
setupAgents,
|
|
2193
|
-
setupSecurity,
|
|
2194
|
-
setupTelegram,
|
|
2195
|
-
setupWorkspace,
|
|
2196
|
-
validateAgentCommand,
|
|
2197
|
-
validateBotToken,
|
|
2198
|
-
validateChatId
|
|
2199
|
-
};
|
|
2200
|
-
//# sourceMappingURL=setup-KOMX6WTE.js.map
|