@cortexkit/opencode-magic-context 0.2.3 → 0.2.4

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/cli.js CHANGED
@@ -1,4 +1,93 @@
1
1
  #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+
34
+ // node_modules/sisteransi/src/index.js
35
+ var require_src = __commonJS((exports, module) => {
36
+ var ESC = "\x1B";
37
+ var CSI = `${ESC}[`;
38
+ var beep = "\x07";
39
+ var cursor = {
40
+ to(x, y) {
41
+ if (!y)
42
+ return `${CSI}${x + 1}G`;
43
+ return `${CSI}${y + 1};${x + 1}H`;
44
+ },
45
+ move(x, y) {
46
+ let ret = "";
47
+ if (x < 0)
48
+ ret += `${CSI}${-x}D`;
49
+ else if (x > 0)
50
+ ret += `${CSI}${x}C`;
51
+ if (y < 0)
52
+ ret += `${CSI}${-y}A`;
53
+ else if (y > 0)
54
+ ret += `${CSI}${y}B`;
55
+ return ret;
56
+ },
57
+ up: (count = 1) => `${CSI}${count}A`,
58
+ down: (count = 1) => `${CSI}${count}B`,
59
+ forward: (count = 1) => `${CSI}${count}C`,
60
+ backward: (count = 1) => `${CSI}${count}D`,
61
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
62
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
63
+ left: `${CSI}G`,
64
+ hide: `${CSI}?25l`,
65
+ show: `${CSI}?25h`,
66
+ save: `${ESC}7`,
67
+ restore: `${ESC}8`
68
+ };
69
+ var scroll = {
70
+ up: (count = 1) => `${CSI}S`.repeat(count),
71
+ down: (count = 1) => `${CSI}T`.repeat(count)
72
+ };
73
+ var erase = {
74
+ screen: `${CSI}2J`,
75
+ up: (count = 1) => `${CSI}1J`.repeat(count),
76
+ down: (count = 1) => `${CSI}J`.repeat(count),
77
+ line: `${CSI}2K`,
78
+ lineEnd: `${CSI}K`,
79
+ lineStart: `${CSI}1K`,
80
+ lines(count) {
81
+ let clear = "";
82
+ for (let i = 0;i < count; i++)
83
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
84
+ if (count)
85
+ clear += cursor.left;
86
+ return clear;
87
+ }
88
+ };
89
+ module.exports = { cursor, scroll, erase, beep };
90
+ });
2
91
 
3
92
  // src/cli/setup.ts
4
93
  import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -152,67 +241,1053 @@ function buildModelSelection(allModels, role) {
152
241
  return result;
153
242
  }
154
243
 
155
- // src/cli/prompts.ts
156
- import { createReadStream } from "node:fs";
157
- import { createInterface } from "node:readline";
158
- function getInput() {
159
- if (!process.stdin.isTTY) {
160
- try {
161
- return createReadStream("/dev/tty");
162
- } catch {}
163
- }
164
- return process.stdin;
165
- }
166
- var rl = createInterface({ input: getInput(), output: process.stdout });
167
- function ask(question) {
168
- return new Promise((resolve) => {
169
- rl.question(question, (answer) => resolve(answer.trim()));
170
- });
244
+ // node_modules/@clack/core/dist/index.mjs
245
+ var import_sisteransi = __toESM(require_src(), 1);
246
+ import { styleText as D } from "node:util";
247
+ import { stdout as R, stdin as q } from "node:process";
248
+ import * as k from "node:readline";
249
+ import ot from "node:readline";
250
+ import { ReadStream as J } from "node:tty";
251
+ function x(t, e, s) {
252
+ if (!s.some((u) => !u.disabled))
253
+ return t;
254
+ const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
255
+ return s[n].disabled ? x(n, e < 0 ? -1 : 1, s) : n;
171
256
  }
172
- function closePrompts() {
173
- rl.close();
257
+ var at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
258
+ var lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
259
+ var ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
260
+ var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
261
+ var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
262
+ var L = /\t{1,1000}/y;
263
+ var P = /[\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;
264
+ var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
265
+ var ct = /\p{M}+/gu;
266
+ var ft = { limit: 1 / 0, ellipsis: "" };
267
+ var X = (t, e = {}, s = {}) => {
268
+ const i = e.limit ?? 1 / 0, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
269
+ let h = 0, o = 0, p = t.length, v = 0, F = false, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
270
+ t:
271
+ for (;; ) {
272
+ if (w > C || o >= p && o > h) {
273
+ const ut = t.slice(C, w) || t.slice(h, o);
274
+ v = 0;
275
+ for (const Y of ut.replaceAll(ct, "")) {
276
+ const $ = Y.codePointAt(0) || 0;
277
+ if (lt($) ? f = m : ht($) ? f = V : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
278
+ F = true;
279
+ break t;
280
+ }
281
+ v += Y.length, c += f;
282
+ }
283
+ C = w = 0;
284
+ }
285
+ if (o >= p)
286
+ break;
287
+ if (M.lastIndex = o, M.test(t)) {
288
+ if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
289
+ F = true;
290
+ break;
291
+ }
292
+ c += f, C = h, w = o, o = h = M.lastIndex;
293
+ continue;
294
+ }
295
+ if (O.lastIndex = o, O.test(t)) {
296
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
297
+ F = true;
298
+ break;
299
+ }
300
+ c += u, C = h, w = o, o = h = O.lastIndex;
301
+ continue;
302
+ }
303
+ if (y.lastIndex = o, y.test(t)) {
304
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
305
+ F = true;
306
+ break;
307
+ }
308
+ c += f, C = h, w = o, o = h = y.lastIndex;
309
+ continue;
310
+ }
311
+ if (L.lastIndex = o, L.test(t)) {
312
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
313
+ F = true;
314
+ break;
315
+ }
316
+ c += f, C = h, w = o, o = h = L.lastIndex;
317
+ continue;
318
+ }
319
+ if (P.lastIndex = o, P.test(t)) {
320
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
321
+ F = true;
322
+ break;
323
+ }
324
+ c += g, C = h, w = o, o = h = P.lastIndex;
325
+ continue;
326
+ }
327
+ o += 1;
328
+ }
329
+ return { width: F ? b : c, index: F ? d : p, truncated: F, ellipsed: F && i >= n };
330
+ };
331
+ var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
332
+ var S = (t, e = {}) => X(t, pt, e).width;
333
+ var T = "\x1B";
334
+ var Z = "›";
335
+ var Ft = 39;
336
+ var j = "\x07";
337
+ var Q = "[";
338
+ var dt = "]";
339
+ var tt = "m";
340
+ var U = `${dt}8;;`;
341
+ var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
342
+ var mt = (t) => {
343
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97)
344
+ return 39;
345
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107)
346
+ return 49;
347
+ if (t === 1 || t === 2)
348
+ return 22;
349
+ if (t === 3)
350
+ return 23;
351
+ if (t === 4)
352
+ return 24;
353
+ if (t === 7)
354
+ return 27;
355
+ if (t === 8)
356
+ return 28;
357
+ if (t === 9)
358
+ return 29;
359
+ if (t === 0)
360
+ return 0;
361
+ };
362
+ var st = (t) => `${T}${Q}${t}${tt}`;
363
+ var it = (t) => `${T}${U}${t}${j}`;
364
+ var gt = (t) => t.map((e) => S(e));
365
+ var G = (t, e, s) => {
366
+ const i = e[Symbol.iterator]();
367
+ let r = false, n = false, u = t.at(-1), a = u === undefined ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
368
+ for (;!l.done; ) {
369
+ const m = l.value, A = S(m);
370
+ a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === T || m === Z) && (r = true, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
371
+ }
372
+ u = t.at(-1), !a && u !== undefined && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
373
+ };
374
+ var vt = (t) => {
375
+ const e = t.split(" ");
376
+ let s = e.length;
377
+ for (;s > 0 && !(S(e[s - 1]) > 0); )
378
+ s--;
379
+ return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
380
+ };
381
+ var Et = (t, e, s = {}) => {
382
+ if (s.trim !== false && t.trim() === "")
383
+ return "";
384
+ let i = "", r, n;
385
+ const u = t.split(" "), a = gt(u);
386
+ let l = [""];
387
+ for (const [h, o] of u.entries()) {
388
+ s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
389
+ let p = S(l.at(-1) ?? "");
390
+ if (h !== 0 && (p >= e && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
391
+ const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
392
+ Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
393
+ continue;
394
+ }
395
+ if (p + a[h] > e && p > 0 && a[h] > 0) {
396
+ if (s.wordWrap === false && p < e) {
397
+ G(l, o, e);
398
+ continue;
399
+ }
400
+ l.push("");
401
+ }
402
+ if (p + a[h] > e && s.wordWrap === false) {
403
+ G(l, o, e);
404
+ continue;
405
+ }
406
+ l[l.length - 1] += o;
407
+ }
408
+ s.trim !== false && (l = l.map((h) => vt(h)));
409
+ const E = l.join(`
410
+ `), g = E[Symbol.iterator]();
411
+ let m = g.next(), A = g.next(), V = 0;
412
+ for (;!m.done; ) {
413
+ const h = m.value, o = A.value;
414
+ if (i += h, h === T || h === Z) {
415
+ et.lastIndex = V + 1;
416
+ const F = et.exec(E)?.groups;
417
+ if (F?.code !== undefined) {
418
+ const d = Number.parseFloat(F.code);
419
+ r = d === Ft ? undefined : d;
420
+ } else
421
+ F?.uri !== undefined && (n = F.uri.length === 0 ? undefined : F.uri);
422
+ }
423
+ const p = r ? mt(r) : undefined;
424
+ o === `
425
+ ` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
426
+ ` && (r && p && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
427
+ }
428
+ return i;
429
+ };
430
+ function K(t, e, s) {
431
+ return String(t).normalize().replaceAll(`\r
432
+ `, `
433
+ `).split(`
434
+ `).map((i) => Et(i, e, s)).join(`
435
+ `);
174
436
  }
175
- async function confirm(message, defaultYes = true) {
176
- const hint = defaultYes ? "Y/n" : "y/N";
177
- const answer = await ask(` ${message} [${hint}] `);
178
- if (answer === "")
179
- return defaultYes;
180
- return answer.toLowerCase().startsWith("y");
437
+ var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
438
+ var _ = { actions: new Set(At), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true };
439
+ function H(t, e) {
440
+ if (typeof t == "string")
441
+ return _.aliases.get(t) === e;
442
+ for (const s of t)
443
+ if (s !== undefined && H(s, e))
444
+ return true;
445
+ return false;
181
446
  }
182
- async function selectOne(message, options) {
183
- console.log(` ${message}`);
184
- console.log("");
185
- for (let i = 0;i < options.length; i++) {
186
- const opt = options[i];
187
- const rec = opt.recommended ? " (recommended)" : "";
188
- const num = `${i + 1}`.padStart(3);
189
- console.log(` ${num}) ${opt.label}${rec}`);
447
+ function _t(t, e) {
448
+ if (t === e)
449
+ return;
450
+ const s = t.split(`
451
+ `), i = e.split(`
452
+ `), r = Math.max(s.length, i.length), n = [];
453
+ for (let u = 0;u < r; u++)
454
+ s[u] !== i[u] && n.push(u);
455
+ return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
456
+ }
457
+ var bt = globalThis.process.platform.startsWith("win");
458
+ var z = Symbol("clack:cancel");
459
+ function Ct(t) {
460
+ return t === z;
461
+ }
462
+ function W(t, e) {
463
+ const s = t;
464
+ s.isTTY && s.setRawMode(e);
465
+ }
466
+ function xt({ input: t = q, output: e = R, overwrite: s = true, hideCursor: i = true } = {}) {
467
+ const r = k.createInterface({ input: t, output: e, prompt: "", tabSize: 1 });
468
+ k.emitKeypressEvents(t, r), t instanceof J && t.isTTY && t.setRawMode(true);
469
+ const n = (u, { name: a, sequence: l }) => {
470
+ const E = String(u);
471
+ if (H([E, a, l], "cancel")) {
472
+ i && e.write(import_sisteransi.cursor.show), process.exit(0);
473
+ return;
474
+ }
475
+ if (!s)
476
+ return;
477
+ const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
478
+ k.moveCursor(e, g, m, () => {
479
+ k.clearLine(e, 1, () => {
480
+ t.once("keypress", n);
481
+ });
482
+ });
483
+ };
484
+ return i && e.write(import_sisteransi.cursor.hide), t.once("keypress", n), () => {
485
+ t.off("keypress", n), i && e.write(import_sisteransi.cursor.show), t instanceof J && t.isTTY && !bt && t.setRawMode(false), r.terminal = false, r.close();
486
+ };
487
+ }
488
+ var rt = (t) => ("columns" in t) && typeof t.columns == "number" ? t.columns : 80;
489
+ var nt = (t) => ("rows" in t) && typeof t.rows == "number" ? t.rows : 20;
490
+ function Bt(t, e, s, i = s) {
491
+ const r = rt(t ?? R);
492
+ return K(e, r - s.length, { hard: true, trim: false }).split(`
493
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
494
+ `);
495
+ }
496
+
497
+ class B {
498
+ input;
499
+ output;
500
+ _abortSignal;
501
+ rl;
502
+ opts;
503
+ _render;
504
+ _track = false;
505
+ _prevFrame = "";
506
+ _subscribers = new Map;
507
+ _cursor = 0;
508
+ state = "initial";
509
+ error = "";
510
+ value;
511
+ userInput = "";
512
+ constructor(e, s = true) {
513
+ const { input: i = q, output: r = R, render: n, signal: u, ...a } = e;
514
+ this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
190
515
  }
191
- console.log("");
192
- while (true) {
193
- const answer = await ask(" Enter number: ");
194
- const idx = Number.parseInt(answer, 10) - 1;
195
- if (idx >= 0 && idx < options.length) {
196
- return options[idx].value;
516
+ unsubscribe() {
517
+ this._subscribers.clear();
518
+ }
519
+ setSubscriber(e, s) {
520
+ const i = this._subscribers.get(e) ?? [];
521
+ i.push(s), this._subscribers.set(e, i);
522
+ }
523
+ on(e, s) {
524
+ this.setSubscriber(e, { cb: s });
525
+ }
526
+ once(e, s) {
527
+ this.setSubscriber(e, { cb: s, once: true });
528
+ }
529
+ emit(e, ...s) {
530
+ const i = this._subscribers.get(e) ?? [], r = [];
531
+ for (const n of i)
532
+ n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
533
+ for (const n of r)
534
+ n();
535
+ }
536
+ prompt() {
537
+ return new Promise((e) => {
538
+ if (this._abortSignal) {
539
+ if (this._abortSignal.aborted)
540
+ return this.state = "cancel", this.close(), e(z);
541
+ this._abortSignal.addEventListener("abort", () => {
542
+ this.state = "cancel", this.close();
543
+ }, { once: true });
544
+ }
545
+ this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), W(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
546
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(this.value);
547
+ }), this.once("cancel", () => {
548
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(z);
549
+ });
550
+ });
551
+ }
552
+ _isActionKey(e, s) {
553
+ return e === "\t";
554
+ }
555
+ _setValue(e) {
556
+ this.value = e, this.emit("value", this.value);
557
+ }
558
+ _setUserInput(e, s) {
559
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
560
+ }
561
+ _clearUserInput() {
562
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
563
+ }
564
+ onKeypress(e, s) {
565
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
566
+ if (this.opts.validate) {
567
+ const i = this.opts.validate(this.value);
568
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
569
+ }
570
+ this.state !== "error" && (this.state = "submit");
197
571
  }
198
- console.log(" Invalid selection, try again.");
572
+ H([e, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
573
+ }
574
+ close() {
575
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
576
+ `), W(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
577
+ }
578
+ restoreCursor() {
579
+ const e = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
580
+ `).length - 1;
581
+ this.output.write(import_sisteransi.cursor.move(-999, e * -1));
199
582
  }
583
+ render() {
584
+ const e = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
585
+ if (e !== this._prevFrame) {
586
+ if (this.state === "initial")
587
+ this.output.write(import_sisteransi.cursor.hide);
588
+ else {
589
+ const s = _t(this._prevFrame, e), i = nt(this.output);
590
+ if (this.restoreCursor(), s) {
591
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
592
+ let u = s.lines.find((a) => a >= r);
593
+ if (u === undefined) {
594
+ this._prevFrame = e;
595
+ return;
596
+ }
597
+ if (s.lines.length === 1) {
598
+ this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
599
+ const a = e.split(`
600
+ `);
601
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
602
+ return;
603
+ } else if (s.lines.length > 1) {
604
+ if (r < n)
605
+ u = r;
606
+ else {
607
+ const l = u - n;
608
+ l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
609
+ }
610
+ this.output.write(import_sisteransi.erase.down());
611
+ const a = e.split(`
612
+ `).slice(u);
613
+ this.output.write(a.join(`
614
+ `)), this._prevFrame = e;
615
+ return;
616
+ }
617
+ }
618
+ this.output.write(import_sisteransi.erase.down());
619
+ }
620
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
621
+ }
622
+ }
623
+ }
624
+ function wt(t, e) {
625
+ if (t === undefined || e.length === 0)
626
+ return 0;
627
+ const s = e.findIndex((i) => i.value === t);
628
+ return s !== -1 ? s : 0;
629
+ }
630
+ function Dt(t, e) {
631
+ return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
632
+ }
633
+ function St(t, e) {
634
+ if (e)
635
+ return t ? e : e[0];
200
636
  }
201
637
 
202
- // src/cli/setup.ts
203
- var PLUGIN_NAME = "@cortexkit/opencode-magic-context";
204
- function printStep(step, total, message) {
205
- console.log(` [${step}/${total}] ${message}`);
638
+ class Vt extends B {
639
+ filteredOptions;
640
+ multiple;
641
+ isNavigating = false;
642
+ selectedValues = [];
643
+ focusedValue;
644
+ #t = 0;
645
+ #s = "";
646
+ #i;
647
+ #e;
648
+ get cursor() {
649
+ return this.#t;
650
+ }
651
+ get userInputWithCursor() {
652
+ if (!this.userInput)
653
+ return D(["inverse", "hidden"], "_");
654
+ if (this._cursor >= this.userInput.length)
655
+ return `${this.userInput}█`;
656
+ const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
657
+ return `${e}${D("inverse", s)}${i.join("")}`;
658
+ }
659
+ get options() {
660
+ return typeof this.#e == "function" ? this.#e() : this.#e;
661
+ }
662
+ constructor(e) {
663
+ super(e), this.#e = e.options;
664
+ const s = this.options;
665
+ this.filteredOptions = [...s], this.multiple = e.multiple === true, this.#i = e.filter ?? Dt;
666
+ let i;
667
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i)
668
+ for (const r of i) {
669
+ const n = s.findIndex((u) => u.value === r);
670
+ n !== -1 && (this.toggleSelected(r), this.#t = n);
671
+ }
672
+ this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
673
+ }
674
+ _isActionKey(e, s) {
675
+ return e === "\t" || this.multiple && this.isNavigating && s.name === "space" && e !== undefined && e !== "";
676
+ }
677
+ #r(e, s) {
678
+ const i = s.name === "up", r = s.name === "down", n = s.name === "return";
679
+ i || r ? (this.#t = x(this.#t, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = St(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
680
+ }
681
+ deselectAll() {
682
+ this.selectedValues = [];
683
+ }
684
+ toggleSelected(e) {
685
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
686
+ }
687
+ #n(e) {
688
+ if (e !== this.#s) {
689
+ this.#s = e;
690
+ const s = this.options;
691
+ e ? this.filteredOptions = s.filter((n) => this.#i(e, n)) : this.filteredOptions = [...s];
692
+ const i = wt(this.focusedValue, this.filteredOptions);
693
+ this.#t = x(i, 0, this.filteredOptions);
694
+ const r = this.filteredOptions[this.#t];
695
+ r && !r.disabled ? this.focusedValue = r.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
696
+ }
697
+ }
698
+ }
699
+
700
+ class kt extends B {
701
+ get cursor() {
702
+ return this.value ? 0 : 1;
703
+ }
704
+ get _value() {
705
+ return this.cursor === 0;
706
+ }
707
+ constructor(e) {
708
+ super(e, false), this.value = !!e.initialValue, this.on("userInput", () => {
709
+ this.value = this._value;
710
+ }), this.on("confirm", (s) => {
711
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
712
+ }), this.on("cursor", () => {
713
+ this.value = !this.value;
714
+ });
715
+ }
716
+ }
717
+
718
+ class yt extends B {
719
+ options;
720
+ cursor = 0;
721
+ #t;
722
+ getGroupItems(e) {
723
+ return this.options.filter((s) => s.group === e);
724
+ }
725
+ isGroupSelected(e) {
726
+ const s = this.getGroupItems(e), i = this.value;
727
+ return i === undefined ? false : s.every((r) => i.includes(r.value));
728
+ }
729
+ toggleValue() {
730
+ const e = this.options[this.cursor];
731
+ if (this.value === undefined && (this.value = []), e.group === true) {
732
+ const s = e.value, i = this.getGroupItems(s);
733
+ this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
734
+ } else {
735
+ const s = this.value.includes(e.value);
736
+ this.value = s ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
737
+ }
738
+ }
739
+ constructor(e) {
740
+ super(e, false);
741
+ const { options: s } = e;
742
+ this.#t = e.selectableGroups !== false, this.options = Object.entries(s).flatMap(([i, r]) => [{ value: i, group: true, label: i }, ...r.map((n) => ({ ...n, group: i }))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
743
+ switch (i) {
744
+ case "left":
745
+ case "up": {
746
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
747
+ const r = this.options[this.cursor]?.group === true;
748
+ !this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
749
+ break;
750
+ }
751
+ case "down":
752
+ case "right": {
753
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
754
+ const r = this.options[this.cursor]?.group === true;
755
+ !this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
756
+ break;
757
+ }
758
+ case "space":
759
+ this.toggleValue();
760
+ break;
761
+ }
762
+ });
763
+ }
206
764
  }
207
- function printSuccess(message) {
208
- console.log(` ✓ ${message}`);
765
+ class Tt extends B {
766
+ options;
767
+ cursor = 0;
768
+ get _selectedValue() {
769
+ return this.options[this.cursor];
770
+ }
771
+ changeValue() {
772
+ this.value = this._selectedValue.value;
773
+ }
774
+ constructor(e) {
775
+ super(e, false), this.options = e.options;
776
+ const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
777
+ this.cursor = this.options[i].disabled ? x(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
778
+ switch (r) {
779
+ case "left":
780
+ case "up":
781
+ this.cursor = x(this.cursor, -1, this.options);
782
+ break;
783
+ case "down":
784
+ case "right":
785
+ this.cursor = x(this.cursor, 1, this.options);
786
+ break;
787
+ }
788
+ this.changeValue();
789
+ });
790
+ }
209
791
  }
210
- function printWarning(message) {
211
- console.log(` ⚠ ${message}`);
792
+
793
+ // node_modules/@clack/prompts/dist/index.mjs
794
+ import { styleText as t, stripVTControlCharacters as ue } from "node:util";
795
+ import N2 from "node:process";
796
+ var import_sisteransi2 = __toESM(require_src(), 1);
797
+ function pt2() {
798
+ return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
212
799
  }
213
- function printInfo(message) {
214
- console.log(` → ${message}`);
800
+ var ee = pt2();
801
+ var ce = () => process.env.CI === "true";
802
+ var I2 = (e, r) => ee ? e : r;
803
+ var Re = I2("◆", "*");
804
+ var $e = I2("■", "x");
805
+ var de = I2("▲", "x");
806
+ var V = I2("◇", "o");
807
+ var he = I2("┌", "T");
808
+ var h = I2("│", "|");
809
+ var x2 = I2("└", "—");
810
+ var Oe = I2("┐", "T");
811
+ var Pe = I2("┘", "—");
812
+ var z2 = I2("●", ">");
813
+ var H2 = I2("○", " ");
814
+ var te = I2("◻", "[•]");
815
+ var U2 = I2("◼", "[+]");
816
+ var q2 = I2("◻", "[ ]");
817
+ var Ne = I2("▪", "•");
818
+ var se = I2("─", "-");
819
+ var pe = I2("╮", "+");
820
+ var We = I2("├", "+");
821
+ var me = I2("╯", "+");
822
+ var ge = I2("╰", "+");
823
+ var Ge = I2("╭", "+");
824
+ var fe = I2("●", "•");
825
+ var Fe = I2("◆", "*");
826
+ var ye = I2("▲", "!");
827
+ var Ee = I2("■", "x");
828
+ var W2 = (e) => {
829
+ switch (e) {
830
+ case "initial":
831
+ case "active":
832
+ return t("cyan", Re);
833
+ case "cancel":
834
+ return t("red", $e);
835
+ case "error":
836
+ return t("yellow", de);
837
+ case "submit":
838
+ return t("green", V);
839
+ }
840
+ };
841
+ var ve = (e) => {
842
+ switch (e) {
843
+ case "initial":
844
+ case "active":
845
+ return t("cyan", h);
846
+ case "cancel":
847
+ return t("red", h);
848
+ case "error":
849
+ return t("yellow", h);
850
+ case "submit":
851
+ return t("green", h);
852
+ }
853
+ };
854
+ var mt2 = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109;
855
+ var gt2 = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510;
856
+ var ft2 = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141;
857
+ var we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
858
+ var re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
859
+ var ie = /\t{1,1000}/y;
860
+ var Ae = /[\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;
861
+ var ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
862
+ var Ft2 = /\p{M}+/gu;
863
+ var yt2 = { limit: 1 / 0, ellipsis: "" };
864
+ var Le = (e, r = {}, s = {}) => {
865
+ const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt2, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
866
+ let $ = 0, m = 0, d = e.length, F = 0, y2 = false, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S2 = 0;
867
+ e:
868
+ for (;; ) {
869
+ if (b > A || m >= d && m > $) {
870
+ const T2 = e.slice(A, b) || e.slice($, m);
871
+ F = 0;
872
+ for (const M2 of T2.replaceAll(Ft2, "")) {
873
+ const O2 = M2.codePointAt(0) || 0;
874
+ if (gt2(O2) ? S2 = f : ft2(O2) ? S2 = E : c !== g && mt2(O2) ? S2 = c : S2 = g, w + S2 > C && (v = Math.min(v, Math.max(A, $) + F)), w + S2 > i) {
875
+ y2 = true;
876
+ break e;
877
+ }
878
+ F += M2.length, w += S2;
879
+ }
880
+ A = b = 0;
881
+ }
882
+ if (m >= d)
883
+ break;
884
+ if (ne.lastIndex = m, ne.test(e)) {
885
+ if (F = ne.lastIndex - m, S2 = F * g, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S2 > i) {
886
+ y2 = true;
887
+ break;
888
+ }
889
+ w += S2, A = $, b = m, m = $ = ne.lastIndex;
890
+ continue;
891
+ }
892
+ if (we.lastIndex = m, we.test(e)) {
893
+ if (w + u > C && (v = Math.min(v, m)), w + u > i) {
894
+ y2 = true;
895
+ break;
896
+ }
897
+ w += u, A = $, b = m, m = $ = we.lastIndex;
898
+ continue;
899
+ }
900
+ if (re.lastIndex = m, re.test(e)) {
901
+ if (F = re.lastIndex - m, S2 = F * l, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S2 > i) {
902
+ y2 = true;
903
+ break;
904
+ }
905
+ w += S2, A = $, b = m, m = $ = re.lastIndex;
906
+ continue;
907
+ }
908
+ if (ie.lastIndex = m, ie.test(e)) {
909
+ if (F = ie.lastIndex - m, S2 = F * n, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S2 > i) {
910
+ y2 = true;
911
+ break;
912
+ }
913
+ w += S2, A = $, b = m, m = $ = ie.lastIndex;
914
+ continue;
915
+ }
916
+ if (Ae.lastIndex = m, Ae.test(e)) {
917
+ if (w + p > C && (v = Math.min(v, m)), w + p > i) {
918
+ y2 = true;
919
+ break;
920
+ }
921
+ w += p, A = $, b = m, m = $ = Ae.lastIndex;
922
+ continue;
923
+ }
924
+ m += 1;
925
+ }
926
+ return { width: y2 ? C : w, index: y2 ? v : d, truncated: y2, ellipsed: y2 && i >= o };
927
+ };
928
+ var Et2 = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
929
+ var D2 = (e, r = {}) => Le(e, Et2, r).width;
930
+ var ae = "\x1B";
931
+ var je = "›";
932
+ var vt2 = 39;
933
+ var Ce = "\x07";
934
+ var ke = "[";
935
+ var wt2 = "]";
936
+ var Ve = "m";
937
+ var Se = `${wt2}8;;`;
938
+ var He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y");
939
+ var At2 = (e) => {
940
+ if (e >= 30 && e <= 37 || e >= 90 && e <= 97)
941
+ return 39;
942
+ if (e >= 40 && e <= 47 || e >= 100 && e <= 107)
943
+ return 49;
944
+ if (e === 1 || e === 2)
945
+ return 22;
946
+ if (e === 3)
947
+ return 23;
948
+ if (e === 4)
949
+ return 24;
950
+ if (e === 7)
951
+ return 27;
952
+ if (e === 8)
953
+ return 28;
954
+ if (e === 9)
955
+ return 29;
956
+ if (e === 0)
957
+ return 0;
958
+ };
959
+ var Ue = (e) => `${ae}${ke}${e}${Ve}`;
960
+ var Ke = (e) => `${ae}${Se}${e}${Ce}`;
961
+ var Ct2 = (e) => e.map((r) => D2(r));
962
+ var Ie = (e, r, s) => {
963
+ const i = r[Symbol.iterator]();
964
+ let a = false, o = false, u = e.at(-1), l = u === undefined ? 0 : D2(u), n = i.next(), c = i.next(), p = 0;
965
+ for (;!n.done; ) {
966
+ const f = n.value, g = D2(f);
967
+ l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = true, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = false, o = false) : f === Ve && (a = false) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
968
+ }
969
+ u = e.at(-1), !l && u !== undefined && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
970
+ };
971
+ var St2 = (e) => {
972
+ const r = e.split(" ");
973
+ let s = r.length;
974
+ for (;s > 0 && !(D2(r[s - 1]) > 0); )
975
+ s--;
976
+ return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
977
+ };
978
+ var It2 = (e, r, s = {}) => {
979
+ if (s.trim !== false && e.trim() === "")
980
+ return "";
981
+ let i = "", a, o;
982
+ const u = e.split(" "), l = Ct2(u);
983
+ let n = [""];
984
+ for (const [$, m] of u.entries()) {
985
+ s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
986
+ let d = D2(n.at(-1) ?? "");
987
+ if ($ !== 0 && (d >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), d = 0), (d > 0 || s.trim === false) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
988
+ const F = r - d, y2 = 1 + Math.floor((l[$] - F - 1) / r);
989
+ Math.floor((l[$] - 1) / r) < y2 && n.push(""), Ie(n, m, r);
990
+ continue;
991
+ }
992
+ if (d + l[$] > r && d > 0 && l[$] > 0) {
993
+ if (s.wordWrap === false && d < r) {
994
+ Ie(n, m, r);
995
+ continue;
996
+ }
997
+ n.push("");
998
+ }
999
+ if (d + l[$] > r && s.wordWrap === false) {
1000
+ Ie(n, m, r);
1001
+ continue;
1002
+ }
1003
+ n[n.length - 1] += m;
1004
+ }
1005
+ s.trim !== false && (n = n.map(($) => St2($)));
1006
+ const c = n.join(`
1007
+ `), p = c[Symbol.iterator]();
1008
+ let f = p.next(), g = p.next(), E = 0;
1009
+ for (;!f.done; ) {
1010
+ const $ = f.value, m = g.value;
1011
+ if (i += $, $ === ae || $ === je) {
1012
+ He.lastIndex = E + 1;
1013
+ const y2 = He.exec(c)?.groups;
1014
+ if (y2?.code !== undefined) {
1015
+ const v = Number.parseFloat(y2.code);
1016
+ a = v === vt2 ? undefined : v;
1017
+ } else
1018
+ y2?.uri !== undefined && (o = y2.uri.length === 0 ? undefined : y2.uri);
1019
+ }
1020
+ const d = a ? At2(a) : undefined;
1021
+ m === `
1022
+ ` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
1023
+ ` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
1024
+ }
1025
+ return i;
1026
+ };
1027
+ function J2(e, r, s) {
1028
+ return String(e).normalize().replaceAll(`\r
1029
+ `, `
1030
+ `).split(`
1031
+ `).map((i) => It2(i, r, s)).join(`
1032
+ `);
215
1033
  }
1034
+ var bt2 = (e, r, s, i, a) => {
1035
+ let o = r, u = 0;
1036
+ for (let l = s;l < i; l++) {
1037
+ const n = e[l];
1038
+ if (o = o - n.length, u++, o <= a)
1039
+ break;
1040
+ }
1041
+ return { lineCount: o, removals: u };
1042
+ };
1043
+ var X2 = ({ cursor: e, options: r, style: s, output: i = process.stdout, maxItems: a = Number.POSITIVE_INFINITY, columnPadding: o = 0, rowPadding: u = 4 }) => {
1044
+ const l = rt(i) - o, n = nt(i), c = t("dim", "..."), p = Math.max(n - u, 0), f = Math.max(Math.min(a, p), 5);
1045
+ let g = 0;
1046
+ e >= f - 3 && (g = Math.max(Math.min(e - f + 3, r.length - f), 0));
1047
+ let E = f < r.length && g > 0, $ = f < r.length && g + f < r.length;
1048
+ const m = Math.min(g + f, r.length), d = [];
1049
+ let F = 0;
1050
+ E && F++, $ && F++;
1051
+ const y2 = g + (E ? 1 : 0), v = m - ($ ? 1 : 0);
1052
+ for (let A = y2;A < v; A++) {
1053
+ const b = J2(s(r[A], A === e), l, { hard: true, trim: false }).split(`
1054
+ `);
1055
+ d.push(b), F += b.length;
1056
+ }
1057
+ if (F > p) {
1058
+ let A = 0, b = 0, w = F;
1059
+ const S2 = e - y2, T2 = (M2, O2) => bt2(d, w, M2, O2, p);
1060
+ E ? ({ lineCount: w, removals: A } = T2(0, S2), w > p && ({ lineCount: w, removals: b } = T2(S2 + 1, d.length))) : ({ lineCount: w, removals: b } = T2(S2 + 1, d.length), w > p && ({ lineCount: w, removals: A } = T2(0, S2))), A > 0 && (E = true, d.splice(0, A)), b > 0 && ($ = true, d.splice(d.length - b, b));
1061
+ }
1062
+ const C = [];
1063
+ E && C.push(c);
1064
+ for (const A of d)
1065
+ for (const b of A)
1066
+ C.push(b);
1067
+ return $ && C.push(c), C;
1068
+ };
1069
+ var Rt = (e) => {
1070
+ const r = e.active ?? "Yes", s = e.inactive ?? "No";
1071
+ return new kt({ active: r, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
1072
+ const i = e.withGuide ?? _.withGuide, a = `${i ? `${t("gray", h)}
1073
+ ` : ""}${W2(this.state)} ${e.message}
1074
+ `, o = this.value ? r : s;
1075
+ switch (this.state) {
1076
+ case "submit": {
1077
+ const u = i ? `${t("gray", h)} ` : "";
1078
+ return `${a}${u}${t("dim", o)}`;
1079
+ }
1080
+ case "cancel": {
1081
+ const u = i ? `${t("gray", h)} ` : "";
1082
+ return `${a}${u}${t(["strikethrough", "dim"], o)}${i ? `
1083
+ ${t("gray", h)}` : ""}`;
1084
+ }
1085
+ default: {
1086
+ const u = i ? `${t("cyan", h)} ` : "", l = i ? t("cyan", x2) : "";
1087
+ return `${a}${u}${this.value ? `${t("green", z2)} ${r}` : `${t("dim", H2)} ${t("dim", r)}`}${e.vertical ? i ? `
1088
+ ${t("cyan", h)} ` : `
1089
+ ` : ` ${t("dim", "/")} `}${this.value ? `${t("dim", H2)} ${t("dim", s)}` : `${t("green", z2)} ${s}`}
1090
+ ${l}
1091
+ `;
1092
+ }
1093
+ }
1094
+ } }).prompt();
1095
+ };
1096
+ var R2 = { message: (e = [], { symbol: r = t("gray", h), secondarySymbol: s = t("gray", h), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
1097
+ const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", p = l ? `${s} ` : "";
1098
+ for (let g = 0;g < a; g++)
1099
+ u.push(n);
1100
+ const f = Array.isArray(e) ? e : e.split(`
1101
+ `);
1102
+ if (f.length > 0) {
1103
+ const [g, ...E] = f;
1104
+ g.length > 0 ? u.push(`${c}${g}`) : u.push(l ? r : "");
1105
+ for (const $ of E)
1106
+ $.length > 0 ? u.push(`${p}${$}`) : u.push(l ? s : "");
1107
+ }
1108
+ i.write(`${u.join(`
1109
+ `)}
1110
+ `);
1111
+ }, info: (e, r) => {
1112
+ R2.message(e, { ...r, symbol: t("blue", fe) });
1113
+ }, success: (e, r) => {
1114
+ R2.message(e, { ...r, symbol: t("green", Fe) });
1115
+ }, step: (e, r) => {
1116
+ R2.message(e, { ...r, symbol: t("green", V) });
1117
+ }, warn: (e, r) => {
1118
+ R2.message(e, { ...r, symbol: t("yellow", ye) });
1119
+ }, warning: (e, r) => {
1120
+ R2.warn(e, r);
1121
+ }, error: (e, r) => {
1122
+ R2.message(e, { ...r, symbol: t("red", Ee) });
1123
+ } };
1124
+ var Wt2 = (e = "", r) => {
1125
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${t("gray", he)} ` : "";
1126
+ s.write(`${i}${e}
1127
+ `);
1128
+ };
1129
+ var Gt = (e = "", r) => {
1130
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${t("gray", h)}
1131
+ ${t("gray", x2)} ` : "";
1132
+ s.write(`${i}${e}
1133
+
1134
+ `);
1135
+ };
1136
+ var jt = (e) => t("dim", e);
1137
+ var kt2 = (e, r, s) => {
1138
+ const i = { hard: true, trim: false }, a = J2(e, r, i).split(`
1139
+ `), o = a.reduce((n, c) => Math.max(D2(c), n), 0), u = a.map(s).reduce((n, c) => Math.max(D2(c), n), 0), l = r - (u - o);
1140
+ return J2(e, l, i);
1141
+ };
1142
+ var Vt2 = (e = "", r = "", s) => {
1143
+ const i = s?.output ?? N2.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? jt, u = ["", ...kt2(e, rt(i) - 6, o).split(`
1144
+ `).map(o), ""], l = D2(r), n = Math.max(u.reduce((g, E) => {
1145
+ const $ = D2(E);
1146
+ return $ > g ? $ : g;
1147
+ }, 0), l) + 2, c = u.map((g) => `${t("gray", h)} ${g}${" ".repeat(n - D2(g))}${t("gray", h)}`).join(`
1148
+ `), p = a ? `${t("gray", h)}
1149
+ ` : "", f = a ? We : ge;
1150
+ i.write(`${p}${t("green", V)} ${t("reset", r)} ${t("gray", se.repeat(Math.max(n - l - 1, 1)) + pe)}
1151
+ ${c}
1152
+ ${t("gray", f + se.repeat(n + 2) + me)}
1153
+ `);
1154
+ };
1155
+ var Kt = (e) => t("magenta", e);
1156
+ var be = ({ indicator: e = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: a, frames: o = ee ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], delay: u = ee ? 80 : 120, signal: l, ...n } = {}) => {
1157
+ const c = ce();
1158
+ let p, f, g = false, E = false, $ = "", m, d = performance.now();
1159
+ const F = rt(s), y2 = n?.styleFrame ?? Kt, v = (B2) => {
1160
+ const P2 = B2 > 1 ? a ?? _.messages.error : i ?? _.messages.cancel;
1161
+ E = B2 === 1, g && (k2(P2, B2), E && typeof r == "function" && r());
1162
+ }, C = () => v(2), A = () => v(1), b = () => {
1163
+ process.on("uncaughtExceptionMonitor", C), process.on("unhandledRejection", C), process.on("SIGINT", A), process.on("SIGTERM", A), process.on("exit", v), l && l.addEventListener("abort", A);
1164
+ }, w = () => {
1165
+ process.removeListener("uncaughtExceptionMonitor", C), process.removeListener("unhandledRejection", C), process.removeListener("SIGINT", A), process.removeListener("SIGTERM", A), process.removeListener("exit", v), l && l.removeEventListener("abort", A);
1166
+ }, S2 = () => {
1167
+ if (m === undefined)
1168
+ return;
1169
+ c && s.write(`
1170
+ `);
1171
+ const B2 = J2(m, F, { hard: true, trim: false }).split(`
1172
+ `);
1173
+ B2.length > 1 && s.write(import_sisteransi2.cursor.up(B2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
1174
+ }, T2 = (B2) => B2.replace(/\.+$/, ""), M2 = (B2) => {
1175
+ const P2 = (performance.now() - B2) / 1000, G2 = Math.floor(P2 / 60), L2 = Math.floor(P2 % 60);
1176
+ return G2 > 0 ? `[${G2}m ${L2}s]` : `[${L2}s]`;
1177
+ }, O2 = n.withGuide ?? _.withGuide, le = (B2 = "") => {
1178
+ g = true, p = xt({ output: s }), $ = T2(B2), d = performance.now(), O2 && s.write(`${t("gray", h)}
1179
+ `);
1180
+ let P2 = 0, G2 = 0;
1181
+ b(), f = setInterval(() => {
1182
+ if (c && $ === m)
1183
+ return;
1184
+ S2(), m = $;
1185
+ const L2 = y2(o[P2]);
1186
+ let Z2;
1187
+ if (c)
1188
+ Z2 = `${L2} ${$}...`;
1189
+ else if (e === "timer")
1190
+ Z2 = `${L2} ${$} ${M2(d)}`;
1191
+ else {
1192
+ const et2 = ".".repeat(Math.floor(G2)).slice(0, 3);
1193
+ Z2 = `${L2} ${$}${et2}`;
1194
+ }
1195
+ const Ze = J2(Z2, F, { hard: true, trim: false });
1196
+ s.write(Ze), P2 = P2 + 1 < o.length ? P2 + 1 : 0, G2 = G2 < 4 ? G2 + 0.125 : 0;
1197
+ }, u);
1198
+ }, k2 = (B2 = "", P2 = 0, G2 = false) => {
1199
+ if (!g)
1200
+ return;
1201
+ g = false, clearInterval(f), S2();
1202
+ const L2 = P2 === 0 ? t("green", V) : P2 === 1 ? t("red", $e) : t("red", de);
1203
+ $ = B2 ?? $, G2 || (e === "timer" ? s.write(`${L2} ${$} ${M2(d)}
1204
+ `) : s.write(`${L2} ${$}
1205
+ `)), w(), p();
1206
+ };
1207
+ return { start: le, stop: (B2 = "") => k2(B2, 0), message: (B2 = "") => {
1208
+ $ = T2(B2 ?? $);
1209
+ }, cancel: (B2 = "") => k2(B2, 1), error: (B2 = "") => k2(B2, 2), clear: () => k2("", 0, true), get isCancelled() {
1210
+ return E;
1211
+ } };
1212
+ };
1213
+ var ze = { light: I2("─", "-"), heavy: I2("━", "="), block: I2("█", "#") };
1214
+ var oe = (e, r) => e.includes(`
1215
+ `) ? e.split(`
1216
+ `).map((s) => r(s)).join(`
1217
+ `) : r(e);
1218
+ var Jt = (e) => {
1219
+ const r = (s, i) => {
1220
+ const a = s.label ?? String(s.value);
1221
+ switch (i) {
1222
+ case "disabled":
1223
+ return `${t("gray", H2)} ${oe(a, (o) => t("gray", o))}${s.hint ? ` ${t("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
1224
+ case "selected":
1225
+ return `${oe(a, (o) => t("dim", o))}`;
1226
+ case "active":
1227
+ return `${t("green", z2)} ${a}${s.hint ? ` ${t("dim", `(${s.hint})`)}` : ""}`;
1228
+ case "cancelled":
1229
+ return `${oe(a, (o) => t(["strikethrough", "dim"], o))}`;
1230
+ default:
1231
+ return `${t("dim", H2)} ${oe(a, (o) => t("dim", o))}`;
1232
+ }
1233
+ };
1234
+ return new Tt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
1235
+ const s = e.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${ve(this.state)} `, o = Bt(e.output, e.message, a, i), u = `${s ? `${t("gray", h)}
1236
+ ` : ""}${o}
1237
+ `;
1238
+ switch (this.state) {
1239
+ case "submit": {
1240
+ const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "selected"), l);
1241
+ return `${u}${n}`;
1242
+ }
1243
+ case "cancel": {
1244
+ const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "cancelled"), l);
1245
+ return `${u}${n}${s ? `
1246
+ ${t("gray", h)}` : ""}`;
1247
+ }
1248
+ default: {
1249
+ const l = s ? `${t("cyan", h)} ` : "", n = s ? t("cyan", x2) : "", c = u.split(`
1250
+ `).length, p = s ? 2 : 1;
1251
+ return `${u}${l}${X2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: l.length, rowPadding: c + p, style: (f, g) => r(f, f.disabled ? "disabled" : g ? "active" : "inactive") }).join(`
1252
+ ${l}`)}
1253
+ ${n}
1254
+ `;
1255
+ }
1256
+ }
1257
+ } }).prompt();
1258
+ };
1259
+ var Qe = `${t("gray", h)} `;
1260
+
1261
+ // src/cli/prompts.ts
1262
+ function handleCancel(value) {
1263
+ if (Ct(value)) {
1264
+ R2.warn("Setup cancelled.");
1265
+ process.exit(0);
1266
+ }
1267
+ }
1268
+ async function confirm(message, defaultYes = true) {
1269
+ const result = await Rt({
1270
+ message,
1271
+ initialValue: defaultYes
1272
+ });
1273
+ handleCancel(result);
1274
+ return result;
1275
+ }
1276
+ async function selectOne(message, options) {
1277
+ const result = await Jt({
1278
+ message,
1279
+ options: options.map((opt) => ({
1280
+ label: opt.recommended ? `${opt.label} (recommended)` : opt.label,
1281
+ value: opt.value,
1282
+ hint: opt.recommended ? "recommended" : undefined
1283
+ }))
1284
+ });
1285
+ handleCancel(result);
1286
+ return result;
1287
+ }
1288
+
1289
+ // src/cli/setup.ts
1290
+ var PLUGIN_NAME = "@cortexkit/opencode-magic-context";
216
1291
  function ensureDir(dir) {
217
1292
  if (!existsSync2(dir)) {
218
1293
  mkdirSync(dir, { recursive: true });
@@ -230,7 +1305,7 @@ function readJsonc(path) {
230
1305
  }
231
1306
  }
232
1307
  function writeJsonc(path, data) {
233
- writeFileSync(path, JSON.stringify(data, null, 2) + `
1308
+ writeFileSync(path, `${JSON.stringify(data, null, 2)}
234
1309
  `);
235
1310
  }
236
1311
  function addPluginToOpenCodeConfig(configPath, format) {
@@ -296,94 +1371,75 @@ function disableOmoHooks(omoConfigPath) {
296
1371
  writeJsonc(omoConfigPath, config);
297
1372
  }
298
1373
  async function runSetup() {
299
- console.log("");
300
- console.log(" ✨ Magic Context — Setup Wizard");
301
- console.log(" ═══════════════════════════════");
302
- console.log("");
303
- const totalSteps = 8;
304
- let step = 1;
305
- printStep(step++, totalSteps, "Checking OpenCode installation...");
1374
+ Wt2("Magic Context — Setup");
1375
+ const s = be();
1376
+ s.start("Checking OpenCode installation");
306
1377
  const installed = isOpenCodeInstalled();
307
1378
  if (!installed) {
308
- printWarning("OpenCode not found on PATH.");
309
- const shouldContinue = await confirm("Continue setup anyway?", false);
1379
+ s.stop("OpenCode not found");
1380
+ const shouldContinue = await confirm("OpenCode not found on PATH. Continue setup anyway?", false);
310
1381
  if (!shouldContinue) {
311
- console.log("");
312
- printInfo("Install OpenCode: https://opencode.ai");
313
- console.log("");
314
- closePrompts();
1382
+ R2.info("Install OpenCode: https://opencode.ai");
1383
+ Gt("Setup cancelled");
315
1384
  return 1;
316
1385
  }
317
1386
  } else {
318
1387
  const version = getOpenCodeVersion();
319
- printSuccess(`OpenCode ${version ?? ""} detected`);
1388
+ s.stop(`OpenCode ${version ?? ""} detected`);
320
1389
  }
321
- console.log("");
322
- printStep(step++, totalSteps, "Fetching available models...");
1390
+ s.start("Fetching available models");
323
1391
  const allModels = installed ? getAvailableModels() : [];
324
1392
  if (allModels.length > 0) {
325
- printSuccess(`Found ${allModels.length} models`);
1393
+ s.stop(`Found ${allModels.length} models`);
326
1394
  } else {
327
- printWarning("No models found (OpenCode not installed or no providers configured)");
328
- printInfo("You can configure models manually in magic-context.jsonc later");
1395
+ s.stop("No models found");
1396
+ R2.warn("You can configure models manually in magic-context.jsonc later");
329
1397
  }
330
- console.log("");
331
1398
  const paths = detectConfigPaths();
332
- printStep(step++, totalSteps, "Configuring OpenCode...");
333
1399
  addPluginToOpenCodeConfig(paths.opencodeConfig, paths.opencodeConfigFormat);
334
- printSuccess(`Plugin added to ${paths.opencodeConfig}`);
335
- printInfo("Disabled built-in compaction (auto=false, prune=false)");
336
- printInfo("Magic Context handles context management — built-in compaction would interfere");
337
- console.log("");
338
- printStep(step++, totalSteps, "Configure historian (background context compressor)...");
339
- console.log("");
1400
+ R2.success(`Plugin added to ${paths.opencodeConfig}`);
1401
+ R2.info("Disabled built-in compaction (auto=false, prune=false)");
1402
+ R2.message("Magic Context handles context management — built-in compaction would interfere");
340
1403
  let historianModel = null;
341
1404
  if (allModels.length > 0) {
342
1405
  const historianOptions = buildModelSelection(allModels, "historian");
343
1406
  if (historianOptions.length > 0) {
344
- historianModel = await selectOne("Select a model for historian (compresses conversation history):", historianOptions);
345
- printSuccess(`Historian model: ${historianModel}`);
1407
+ historianModel = await selectOne("Select a model for historian (background context compressor)", historianOptions);
1408
+ R2.success(`Historian: ${historianModel}`);
346
1409
  } else {
347
- printInfo("No suitable historian models found. Using built-in fallback chain.");
1410
+ R2.info("No suitable historian models found using built-in fallback chain");
348
1411
  }
349
1412
  } else {
350
- printInfo("Skipping model selection (no models available). Using built-in fallback chain.");
1413
+ R2.info("Skipping model selection using built-in fallback chain");
351
1414
  }
352
- console.log("");
353
- printStep(step++, totalSteps, "Configure dreamer (overnight memory maintenance)...");
354
- console.log("");
355
- printInfo("The dreamer runs overnight to consolidate, verify, and maintain project memories.");
1415
+ R2.message("The dreamer runs overnight to consolidate and maintain project memories.");
356
1416
  const dreamerEnabled = await confirm("Enable dreamer?", true);
357
1417
  let dreamerModel = null;
358
1418
  if (dreamerEnabled && allModels.length > 0) {
359
1419
  const dreamerOptions = buildModelSelection(allModels, "dreamer");
360
1420
  if (dreamerOptions.length > 0) {
361
- dreamerModel = await selectOne("Select a model for dreamer (runs in background, local LLMs ideal):", dreamerOptions);
362
- printSuccess(`Dreamer model: ${dreamerModel}`);
1421
+ dreamerModel = await selectOne("Select a model for dreamer (runs in background, local LLMs ideal)", dreamerOptions);
1422
+ R2.success(`Dreamer: ${dreamerModel}`);
363
1423
  } else {
364
- printInfo("No suitable dreamer models found. Using built-in fallback chain.");
1424
+ R2.info("No suitable dreamer models using built-in fallback chain");
365
1425
  }
366
1426
  } else if (dreamerEnabled) {
367
- printInfo("Using built-in fallback chain for dreamer.");
1427
+ R2.info("Using built-in fallback chain for dreamer");
368
1428
  }
369
- console.log("");
370
- printStep(step++, totalSteps, "Configure sidekick (on-demand prompt augmentation)...");
371
- console.log("");
372
- printInfo("Sidekick augments prompts with project context via /ctx-aug command.");
1429
+ R2.message("Sidekick augments prompts with project context via /ctx-aug command.");
373
1430
  const sidekickEnabled = await confirm("Enable sidekick?", false);
374
1431
  let sidekickModel = null;
375
1432
  if (sidekickEnabled && allModels.length > 0) {
376
1433
  const sidekickOptions = buildModelSelection(allModels, "sidekick");
377
1434
  if (sidekickOptions.length > 0) {
378
- sidekickModel = await selectOne("Select a model for sidekick (fast models preferred):", sidekickOptions);
379
- printSuccess(`Sidekick model: ${sidekickModel}`);
1435
+ sidekickModel = await selectOne("Select a model for sidekick (fast models preferred)", sidekickOptions);
1436
+ R2.success(`Sidekick: ${sidekickModel}`);
380
1437
  } else {
381
- printInfo("No suitable sidekick models found. Using built-in fallback chain.");
1438
+ R2.info("No suitable sidekick models using built-in fallback chain");
382
1439
  }
383
1440
  } else if (sidekickEnabled) {
384
- printInfo("Using built-in fallback chain for sidekick.");
1441
+ R2.info("Using built-in fallback chain for sidekick");
385
1442
  }
386
- console.log("");
387
1443
  writeMagicContextConfig(paths.magicContextConfig, {
388
1444
  historianModel,
389
1445
  dreamerEnabled,
@@ -391,43 +1447,31 @@ async function runSetup() {
391
1447
  sidekickEnabled,
392
1448
  sidekickModel
393
1449
  });
394
- printSuccess(`Config written to ${paths.magicContextConfig}`);
395
- console.log("");
396
- printStep(step++, totalSteps, "Checking for oh-my-opencode...");
1450
+ R2.success(`Config written to ${paths.magicContextConfig}`);
397
1451
  if (paths.omoConfig) {
398
- printWarning(`Found oh-my-opencode config: ${paths.omoConfig}`);
399
- printInfo("The following hooks may interfere with Magic Context:");
400
- console.log(" • context-window-monitor");
401
- console.log(" • preemptive-compaction");
402
- console.log(" • anthropic-context-window-limit-recovery");
403
- console.log("");
1452
+ R2.warn(`Found oh-my-opencode config: ${paths.omoConfig}`);
1453
+ R2.message(`These hooks may conflict:
1454
+ ` + ` • context-window-monitor
1455
+ ` + ` • preemptive-compaction
1456
+ ` + " • anthropic-context-window-limit-recovery");
404
1457
  const shouldDisable = await confirm("Disable these hooks in oh-my-opencode?", true);
405
1458
  if (shouldDisable) {
406
1459
  disableOmoHooks(paths.omoConfig);
407
- printSuccess("Hooks disabled in oh-my-opencode config");
1460
+ R2.success("Hooks disabled in oh-my-opencode config");
408
1461
  } else {
409
- printWarning("Skipped — you may experience context management conflicts");
1462
+ R2.warn("Skipped — you may experience context management conflicts");
410
1463
  }
411
- } else {
412
- printSuccess("No oh-my-opencode config found (no conflicts)");
413
1464
  }
414
- console.log("");
415
- console.log(" ═══════════════════════════════");
416
- console.log(" Setup complete!");
417
- console.log("");
418
- console.log(" What was configured:");
419
- console.log(` Plugin: ${PLUGIN_NAME}`);
420
- console.log(` • Compaction: disabled (Magic Context manages context)`);
421
- if (historianModel)
422
- console.log(` • Historian: ${historianModel}`);
423
- if (dreamerEnabled)
424
- console.log(` • Dreamer: enabled${dreamerModel ? ` (${dreamerModel})` : ""}`);
425
- if (sidekickEnabled)
426
- console.log(` • Sidekick: enabled${sidekickModel ? ` (${sidekickModel})` : ""}`);
427
- console.log("");
428
- console.log(" Run 'opencode' to start!");
429
- console.log("");
430
- closePrompts();
1465
+ const summary = [
1466
+ `Plugin: ${PLUGIN_NAME}`,
1467
+ "Compaction: disabled",
1468
+ historianModel ? `Historian: ${historianModel}` : "Historian: fallback chain",
1469
+ dreamerEnabled ? `Dreamer: enabled${dreamerModel ? ` (${dreamerModel})` : ""}` : "Dreamer: disabled",
1470
+ sidekickEnabled ? `Sidekick: enabled${sidekickModel ? ` (${sidekickModel})` : ""}` : "Sidekick: disabled"
1471
+ ].join(`
1472
+ `);
1473
+ Vt2(summary, "Configuration");
1474
+ Gt("Run 'opencode' to start!");
431
1475
  return 0;
432
1476
  }
433
1477