@buiducnhat/agent-skills 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/README.vi.md +9 -0
- package/dist/index.js +1384 -1312
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import fs, { existsSync, lstatSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
|
|
4
4
|
import os, { tmpdir } from "node:os";
|
|
5
5
|
import path, { dirname, join } from "node:path";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import { stripVTControlCharacters, styleText } from "node:util";
|
|
7
|
+
import P, { stdin, stdout } from "node:process";
|
|
8
|
+
import * as _ from "node:readline";
|
|
9
|
+
import P$1 from "node:readline";
|
|
9
10
|
import { ReadStream } from "node:tty";
|
|
10
|
-
import { stripVTControlCharacters } from "node:util";
|
|
11
11
|
import { execSync, spawn } from "node:child_process";
|
|
12
12
|
|
|
13
13
|
//#region \0rolldown/runtime.js
|
|
@@ -38,73 +38,328 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
}) : target, mod));
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region ../../node_modules/.bun/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
41
|
+
//#region ../../node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/utils.js
|
|
42
|
+
const isAmbiguous = (x) => {
|
|
43
|
+
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
44
|
+
};
|
|
45
|
+
const isFullWidth = (x) => {
|
|
46
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
47
|
+
};
|
|
48
|
+
const isWide = (x) => {
|
|
49
|
+
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region ../../node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/index.js
|
|
54
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
55
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
56
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
57
|
+
const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
|
|
58
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
59
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
60
|
+
const NO_TRUNCATION$1 = {
|
|
61
|
+
limit: Infinity,
|
|
62
|
+
ellipsis: ""
|
|
63
|
+
};
|
|
64
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
65
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
66
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
67
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
68
|
+
const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
|
|
69
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
70
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
71
|
+
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
72
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
73
|
+
const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
|
|
74
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
75
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
|
|
76
|
+
let indexPrev = 0;
|
|
77
|
+
let index = 0;
|
|
78
|
+
let length = input.length;
|
|
79
|
+
let lengthExtra = 0;
|
|
80
|
+
let truncationEnabled = false;
|
|
81
|
+
let truncationIndex = length;
|
|
82
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
83
|
+
let unmatchedStart = 0;
|
|
84
|
+
let unmatchedEnd = 0;
|
|
85
|
+
let width = 0;
|
|
86
|
+
let widthExtra = 0;
|
|
87
|
+
outer: while (true) {
|
|
88
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
89
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
90
|
+
lengthExtra = 0;
|
|
91
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
92
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
93
|
+
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
94
|
+
else if (isWide(codePoint)) widthExtra = WIDE_WIDTH;
|
|
95
|
+
else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) widthExtra = AMBIGUOUS_WIDTH;
|
|
96
|
+
else widthExtra = REGULAR_WIDTH;
|
|
97
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
98
|
+
if (width + widthExtra > LIMIT) {
|
|
99
|
+
truncationEnabled = true;
|
|
100
|
+
break outer;
|
|
101
|
+
}
|
|
102
|
+
lengthExtra += char.length;
|
|
103
|
+
width += widthExtra;
|
|
104
|
+
}
|
|
105
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
106
|
+
}
|
|
107
|
+
if (index >= length) break;
|
|
108
|
+
LATIN_RE.lastIndex = index;
|
|
109
|
+
if (LATIN_RE.test(input)) {
|
|
110
|
+
lengthExtra = LATIN_RE.lastIndex - index;
|
|
111
|
+
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
112
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
113
|
+
if (width + widthExtra > LIMIT) {
|
|
114
|
+
truncationEnabled = true;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
width += widthExtra;
|
|
118
|
+
unmatchedStart = indexPrev;
|
|
119
|
+
unmatchedEnd = index;
|
|
120
|
+
index = indexPrev = LATIN_RE.lastIndex;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
ANSI_RE.lastIndex = index;
|
|
124
|
+
if (ANSI_RE.test(input)) {
|
|
125
|
+
if (width + ANSI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
126
|
+
if (width + ANSI_WIDTH > LIMIT) {
|
|
127
|
+
truncationEnabled = true;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
width += ANSI_WIDTH;
|
|
131
|
+
unmatchedStart = indexPrev;
|
|
132
|
+
unmatchedEnd = index;
|
|
133
|
+
index = indexPrev = ANSI_RE.lastIndex;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
CONTROL_RE.lastIndex = index;
|
|
137
|
+
if (CONTROL_RE.test(input)) {
|
|
138
|
+
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
139
|
+
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
140
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
141
|
+
if (width + widthExtra > LIMIT) {
|
|
142
|
+
truncationEnabled = true;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
width += widthExtra;
|
|
146
|
+
unmatchedStart = indexPrev;
|
|
147
|
+
unmatchedEnd = index;
|
|
148
|
+
index = indexPrev = CONTROL_RE.lastIndex;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
TAB_RE.lastIndex = index;
|
|
152
|
+
if (TAB_RE.test(input)) {
|
|
153
|
+
lengthExtra = TAB_RE.lastIndex - index;
|
|
154
|
+
widthExtra = lengthExtra * TAB_WIDTH;
|
|
155
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
156
|
+
if (width + widthExtra > LIMIT) {
|
|
157
|
+
truncationEnabled = true;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
width += widthExtra;
|
|
161
|
+
unmatchedStart = indexPrev;
|
|
162
|
+
unmatchedEnd = index;
|
|
163
|
+
index = indexPrev = TAB_RE.lastIndex;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
EMOJI_RE.lastIndex = index;
|
|
167
|
+
if (EMOJI_RE.test(input)) {
|
|
168
|
+
if (width + EMOJI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
169
|
+
if (width + EMOJI_WIDTH > LIMIT) {
|
|
170
|
+
truncationEnabled = true;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
width += EMOJI_WIDTH;
|
|
174
|
+
unmatchedStart = indexPrev;
|
|
175
|
+
unmatchedEnd = index;
|
|
176
|
+
index = indexPrev = EMOJI_RE.lastIndex;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
index += 1;
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
183
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
184
|
+
truncated: truncationEnabled,
|
|
185
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
104
186
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region ../../node_modules/.bun/fast-string-width@1.1.0/node_modules/fast-string-width/dist/index.js
|
|
191
|
+
const NO_TRUNCATION = {
|
|
192
|
+
limit: Infinity,
|
|
193
|
+
ellipsis: "",
|
|
194
|
+
ellipsisWidth: 0
|
|
195
|
+
};
|
|
196
|
+
const fastStringWidth = (input, options = {}) => {
|
|
197
|
+
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region ../../node_modules/.bun/fast-wrap-ansi@0.1.6/node_modules/fast-wrap-ansi/lib/main.js
|
|
202
|
+
const ESC = "\x1B";
|
|
203
|
+
const CSI = "";
|
|
204
|
+
const END_CODE = 39;
|
|
205
|
+
const ANSI_ESCAPE_BELL = "\x07";
|
|
206
|
+
const ANSI_CSI = "[";
|
|
207
|
+
const ANSI_OSC = "]";
|
|
208
|
+
const ANSI_SGR_TERMINATOR = "m";
|
|
209
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
210
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
211
|
+
const getClosingCode = (openingCode) => {
|
|
212
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
213
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
214
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
215
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
216
|
+
if (openingCode === 1 || openingCode === 2) return 22;
|
|
217
|
+
if (openingCode === 3) return 23;
|
|
218
|
+
if (openingCode === 4) return 24;
|
|
219
|
+
if (openingCode === 7) return 27;
|
|
220
|
+
if (openingCode === 8) return 28;
|
|
221
|
+
if (openingCode === 9) return 29;
|
|
222
|
+
if (openingCode === 0) return 0;
|
|
223
|
+
};
|
|
224
|
+
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
225
|
+
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
226
|
+
const wrapWord = (rows, word, columns) => {
|
|
227
|
+
const characters = word[Symbol.iterator]();
|
|
228
|
+
let isInsideEscape = false;
|
|
229
|
+
let isInsideLinkEscape = false;
|
|
230
|
+
let lastRow = rows.at(-1);
|
|
231
|
+
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
232
|
+
let currentCharacter = characters.next();
|
|
233
|
+
let nextCharacter = characters.next();
|
|
234
|
+
let rawCharacterIndex = 0;
|
|
235
|
+
while (!currentCharacter.done) {
|
|
236
|
+
const character = currentCharacter.value;
|
|
237
|
+
const characterLength = fastStringWidth(character);
|
|
238
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
239
|
+
else {
|
|
240
|
+
rows.push(character);
|
|
241
|
+
visible = 0;
|
|
242
|
+
}
|
|
243
|
+
if (character === ESC || character === CSI) {
|
|
244
|
+
isInsideEscape = true;
|
|
245
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
246
|
+
}
|
|
247
|
+
if (isInsideEscape) {
|
|
248
|
+
if (isInsideLinkEscape) {
|
|
249
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
250
|
+
isInsideEscape = false;
|
|
251
|
+
isInsideLinkEscape = false;
|
|
252
|
+
}
|
|
253
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
254
|
+
} else {
|
|
255
|
+
visible += characterLength;
|
|
256
|
+
if (visible === columns && !nextCharacter.done) {
|
|
257
|
+
rows.push("");
|
|
258
|
+
visible = 0;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
currentCharacter = nextCharacter;
|
|
262
|
+
nextCharacter = characters.next();
|
|
263
|
+
rawCharacterIndex += character.length;
|
|
264
|
+
}
|
|
265
|
+
lastRow = rows.at(-1);
|
|
266
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
267
|
+
};
|
|
268
|
+
const stringVisibleTrimSpacesRight = (string) => {
|
|
269
|
+
const words = string.split(" ");
|
|
270
|
+
let last = words.length;
|
|
271
|
+
while (last) {
|
|
272
|
+
if (fastStringWidth(words[last - 1])) break;
|
|
273
|
+
last--;
|
|
274
|
+
}
|
|
275
|
+
if (last === words.length) return string;
|
|
276
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
277
|
+
};
|
|
278
|
+
const exec = (string, columns, options = {}) => {
|
|
279
|
+
if (options.trim !== false && string.trim() === "") return "";
|
|
280
|
+
let returnValue = "";
|
|
281
|
+
let escapeCode;
|
|
282
|
+
let escapeUrl;
|
|
283
|
+
const words = string.split(" ");
|
|
284
|
+
let rows = [""];
|
|
285
|
+
let rowLength = 0;
|
|
286
|
+
for (let index = 0; index < words.length; index++) {
|
|
287
|
+
const word = words[index];
|
|
288
|
+
if (options.trim !== false) {
|
|
289
|
+
const row = rows.at(-1) ?? "";
|
|
290
|
+
const trimmed = row.trimStart();
|
|
291
|
+
if (row.length !== trimmed.length) {
|
|
292
|
+
rows[rows.length - 1] = trimmed;
|
|
293
|
+
rowLength = fastStringWidth(trimmed);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (index !== 0) {
|
|
297
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
298
|
+
rows.push("");
|
|
299
|
+
rowLength = 0;
|
|
300
|
+
}
|
|
301
|
+
if (rowLength || options.trim === false) {
|
|
302
|
+
rows[rows.length - 1] += " ";
|
|
303
|
+
rowLength++;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const wordLength = fastStringWidth(word);
|
|
307
|
+
if (options.hard && wordLength > columns) {
|
|
308
|
+
const remainingColumns = columns - rowLength;
|
|
309
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
310
|
+
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
311
|
+
wrapWord(rows, word, columns);
|
|
312
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
316
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
317
|
+
wrapWord(rows, word, columns);
|
|
318
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
rows.push("");
|
|
322
|
+
rowLength = 0;
|
|
323
|
+
}
|
|
324
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
325
|
+
wrapWord(rows, word, columns);
|
|
326
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
rows[rows.length - 1] += word;
|
|
330
|
+
rowLength += wordLength;
|
|
331
|
+
}
|
|
332
|
+
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
333
|
+
const preString = rows.join("\n");
|
|
334
|
+
let inSurrogate = false;
|
|
335
|
+
for (let i = 0; i < preString.length; i++) {
|
|
336
|
+
const character = preString[i];
|
|
337
|
+
returnValue += character;
|
|
338
|
+
if (!inSurrogate) inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
339
|
+
else continue;
|
|
340
|
+
if (character === ESC || character === CSI) {
|
|
341
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
342
|
+
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
343
|
+
if (groups?.code !== void 0) {
|
|
344
|
+
const code = Number.parseFloat(groups.code);
|
|
345
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
346
|
+
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
347
|
+
}
|
|
348
|
+
if (preString[i + 1] === "\n") {
|
|
349
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
350
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
351
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
352
|
+
} else if (character === "\n") {
|
|
353
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
354
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return returnValue;
|
|
358
|
+
};
|
|
359
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
360
|
+
function wrapAnsi(string, columns, options) {
|
|
361
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
362
|
+
}
|
|
108
363
|
|
|
109
364
|
//#endregion
|
|
110
365
|
//#region ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
@@ -164,165 +419,14 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
164
419
|
}));
|
|
165
420
|
|
|
166
421
|
//#endregion
|
|
167
|
-
//#region ../../node_modules/.bun/@clack+core@1.0
|
|
168
|
-
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
422
|
+
//#region ../../node_modules/.bun/@clack+core@1.2.0/node_modules/@clack/core/dist/index.mjs
|
|
169
423
|
var import_src = require_src();
|
|
170
|
-
function
|
|
171
|
-
if (!
|
|
172
|
-
const
|
|
173
|
-
return
|
|
174
|
-
}
|
|
175
|
-
const at$1 = (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, lt$1 = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht$1 = (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, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L = /\t{1,1000}/y, 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?))*/uy, M$1 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct$1 = /\p{M}+/gu, ft$1 = {
|
|
176
|
-
limit: Infinity,
|
|
177
|
-
ellipsis: ""
|
|
178
|
-
}, X$1 = (t, e = {}, s = {}) => {
|
|
179
|
-
const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$1, 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;
|
|
180
|
-
let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
|
|
181
|
-
t: for (;;) {
|
|
182
|
-
if (w > C || o >= p && o > h) {
|
|
183
|
-
const ut = t.slice(C, w) || t.slice(h, o);
|
|
184
|
-
v = 0;
|
|
185
|
-
for (const Y of ut.replaceAll(ct$1, "")) {
|
|
186
|
-
const $ = Y.codePointAt(0) || 0;
|
|
187
|
-
if (lt$1($) ? f = m : ht$1($) ? f = V : E !== A && at$1($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
|
|
188
|
-
F = !0;
|
|
189
|
-
break t;
|
|
190
|
-
}
|
|
191
|
-
v += Y.length, c += f;
|
|
192
|
-
}
|
|
193
|
-
C = w = 0;
|
|
194
|
-
}
|
|
195
|
-
if (o >= p) break;
|
|
196
|
-
if (M$1.lastIndex = o, M$1.test(t)) {
|
|
197
|
-
if (v = M$1.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
|
|
198
|
-
F = !0;
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
c += f, C = h, w = o, o = h = M$1.lastIndex;
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
if (O.lastIndex = o, O.test(t)) {
|
|
205
|
-
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
|
|
206
|
-
F = !0;
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
c += u, C = h, w = o, o = h = O.lastIndex;
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (y.lastIndex = o, y.test(t)) {
|
|
213
|
-
if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
|
|
214
|
-
F = !0;
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
c += f, C = h, w = o, o = h = y.lastIndex;
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (L.lastIndex = o, L.test(t)) {
|
|
221
|
-
if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
|
|
222
|
-
F = !0;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
c += f, C = h, w = o, o = h = L.lastIndex;
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
if (P.lastIndex = o, P.test(t)) {
|
|
229
|
-
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
|
|
230
|
-
F = !0;
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
c += g, C = h, w = o, o = h = P.lastIndex;
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
o += 1;
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
width: F ? b : c,
|
|
240
|
-
index: F ? d : p,
|
|
241
|
-
truncated: F,
|
|
242
|
-
ellipsed: F && i >= n
|
|
243
|
-
};
|
|
244
|
-
}, pt$1 = {
|
|
245
|
-
limit: Infinity,
|
|
246
|
-
ellipsis: "",
|
|
247
|
-
ellipsisWidth: 0
|
|
248
|
-
}, S = (t, e = {}) => X$1(t, pt$1, e).width, W$1 = "\x1B", Z$1 = "", Ft$1 = 39, j = "\x07", Q$1 = "[", dt$1 = "]", tt = "m", U$1 = `${dt$1}8;;`, et$1 = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$1}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
|
|
249
|
-
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
250
|
-
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
251
|
-
if (t === 1 || t === 2) return 22;
|
|
252
|
-
if (t === 3) return 23;
|
|
253
|
-
if (t === 4) return 24;
|
|
254
|
-
if (t === 7) return 27;
|
|
255
|
-
if (t === 8) return 28;
|
|
256
|
-
if (t === 9) return 29;
|
|
257
|
-
if (t === 0) return 0;
|
|
258
|
-
}, st$1 = (t) => `${W$1}${Q$1}${t}${tt}`, it$1 = (t) => `${W$1}${U$1}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G = (t, e, s) => {
|
|
259
|
-
const i = e[Symbol.iterator]();
|
|
260
|
-
let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
261
|
-
for (; !l.done;) {
|
|
262
|
-
const m = l.value, A = S(m);
|
|
263
|
-
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W$1 || m === Z$1) && (r = !0, n = e.startsWith(U$1, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
264
|
-
}
|
|
265
|
-
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
266
|
-
}, vt$1 = (t) => {
|
|
267
|
-
const e = t.split(" ");
|
|
268
|
-
let s = e.length;
|
|
269
|
-
for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
|
|
270
|
-
return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
|
|
271
|
-
}, Et$1 = (t, e, s = {}) => {
|
|
272
|
-
if (s.trim !== !1 && t.trim() === "") return "";
|
|
273
|
-
let i = "", r, n;
|
|
274
|
-
const u = t.split(" "), a = gt$1(u);
|
|
275
|
-
let l = [""];
|
|
276
|
-
for (const [h, o] of u.entries()) {
|
|
277
|
-
s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
278
|
-
let p = S(l.at(-1) ?? "");
|
|
279
|
-
if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
|
|
280
|
-
const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
|
|
281
|
-
Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
if (p + a[h] > e && p > 0 && a[h] > 0) {
|
|
285
|
-
if (s.wordWrap === !1 && p < e) {
|
|
286
|
-
G(l, o, e);
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
l.push("");
|
|
290
|
-
}
|
|
291
|
-
if (p + a[h] > e && s.wordWrap === !1) {
|
|
292
|
-
G(l, o, e);
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
l[l.length - 1] += o;
|
|
296
|
-
}
|
|
297
|
-
s.trim !== !1 && (l = l.map((h) => vt$1(h)));
|
|
298
|
-
const E = l.join(`
|
|
299
|
-
`), g = E[Symbol.iterator]();
|
|
300
|
-
let m = g.next(), A = g.next(), V = 0;
|
|
301
|
-
for (; !m.done;) {
|
|
302
|
-
const h = m.value, o = A.value;
|
|
303
|
-
if (i += h, h === W$1 || h === Z$1) {
|
|
304
|
-
et$1.lastIndex = V + 1;
|
|
305
|
-
const F = et$1.exec(E)?.groups;
|
|
306
|
-
if (F?.code !== void 0) {
|
|
307
|
-
const d = Number.parseFloat(F.code);
|
|
308
|
-
r = d === Ft$1 ? void 0 : d;
|
|
309
|
-
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
310
|
-
}
|
|
311
|
-
const p = r ? mt$1(r) : void 0;
|
|
312
|
-
o === `
|
|
313
|
-
` ? (n && (i += it$1("")), r && p && (i += st$1(p))) : h === `
|
|
314
|
-
` && (r && p && (i += st$1(r)), n && (i += it$1(n))), V += h.length, m = A, A = g.next();
|
|
315
|
-
}
|
|
316
|
-
return i;
|
|
317
|
-
};
|
|
318
|
-
function K$1(t, e, s) {
|
|
319
|
-
return String(t).normalize().replaceAll(`\r
|
|
320
|
-
`, `
|
|
321
|
-
`).split(`
|
|
322
|
-
`).map((i) => Et$1(i, e, s)).join(`
|
|
323
|
-
`);
|
|
424
|
+
function d$1(r, t, e) {
|
|
425
|
+
if (!e.some((o) => !o.disabled)) return r;
|
|
426
|
+
const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
|
|
427
|
+
return e[n].disabled ? d$1(n, t < 0 ? -1 : 1, e) : n;
|
|
324
428
|
}
|
|
325
|
-
const
|
|
429
|
+
const u = {
|
|
326
430
|
actions: new Set([
|
|
327
431
|
"up",
|
|
328
432
|
"down",
|
|
@@ -344,73 +448,96 @@ const _ = {
|
|
|
344
448
|
cancel: "Canceled",
|
|
345
449
|
error: "Something went wrong"
|
|
346
450
|
},
|
|
347
|
-
withGuide: !0
|
|
451
|
+
withGuide: !0,
|
|
452
|
+
date: {
|
|
453
|
+
monthNames: [...[
|
|
454
|
+
"January",
|
|
455
|
+
"February",
|
|
456
|
+
"March",
|
|
457
|
+
"April",
|
|
458
|
+
"May",
|
|
459
|
+
"June",
|
|
460
|
+
"July",
|
|
461
|
+
"August",
|
|
462
|
+
"September",
|
|
463
|
+
"October",
|
|
464
|
+
"November",
|
|
465
|
+
"December"
|
|
466
|
+
]],
|
|
467
|
+
messages: {
|
|
468
|
+
required: "Please enter a valid date",
|
|
469
|
+
invalidMonth: "There are only 12 months in a year",
|
|
470
|
+
invalidDay: (r, t) => `There are only ${r} days in ${t}`,
|
|
471
|
+
afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`,
|
|
472
|
+
beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}`
|
|
473
|
+
}
|
|
474
|
+
}
|
|
348
475
|
};
|
|
349
|
-
function
|
|
350
|
-
if (typeof
|
|
351
|
-
for (const
|
|
476
|
+
function V$1(r, t) {
|
|
477
|
+
if (typeof r == "string") return u.aliases.get(r) === t;
|
|
478
|
+
for (const e of r) if (e !== void 0 && V$1(e, t)) return !0;
|
|
352
479
|
return !1;
|
|
353
480
|
}
|
|
354
|
-
function
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
357
|
-
`),
|
|
358
|
-
`),
|
|
359
|
-
for (let
|
|
481
|
+
function j(r, t) {
|
|
482
|
+
if (r === t) return;
|
|
483
|
+
const e = r.split(`
|
|
484
|
+
`), s = t.split(`
|
|
485
|
+
`), i = Math.max(e.length, s.length), n = [];
|
|
486
|
+
for (let o = 0; o < i; o++) e[o] !== s[o] && n.push(o);
|
|
360
487
|
return {
|
|
361
488
|
lines: n,
|
|
362
|
-
numLinesBefore:
|
|
363
|
-
numLinesAfter:
|
|
364
|
-
numLines:
|
|
489
|
+
numLinesBefore: e.length,
|
|
490
|
+
numLinesAfter: s.length,
|
|
491
|
+
numLines: i
|
|
365
492
|
};
|
|
366
493
|
}
|
|
367
|
-
const
|
|
368
|
-
function
|
|
369
|
-
return
|
|
494
|
+
const Y$1 = globalThis.process.platform.startsWith("win"), C = Symbol("clack:cancel");
|
|
495
|
+
function q(r) {
|
|
496
|
+
return r === C;
|
|
370
497
|
}
|
|
371
|
-
function
|
|
372
|
-
const
|
|
373
|
-
|
|
498
|
+
function w$1(r, t) {
|
|
499
|
+
const e = r;
|
|
500
|
+
e.isTTY && e.setRawMode(t);
|
|
374
501
|
}
|
|
375
|
-
function
|
|
376
|
-
const
|
|
377
|
-
input:
|
|
378
|
-
output:
|
|
502
|
+
function z$1({ input: r = stdin, output: t = stdout, overwrite: e = !0, hideCursor: s = !0 } = {}) {
|
|
503
|
+
const i = _.createInterface({
|
|
504
|
+
input: r,
|
|
505
|
+
output: t,
|
|
379
506
|
prompt: "",
|
|
380
507
|
tabSize: 1
|
|
381
508
|
});
|
|
382
|
-
|
|
383
|
-
const n = (
|
|
384
|
-
if (
|
|
385
|
-
String(
|
|
509
|
+
_.emitKeypressEvents(r, i), r instanceof ReadStream && r.isTTY && r.setRawMode(!0);
|
|
510
|
+
const n = (o, { name: a, sequence: h }) => {
|
|
511
|
+
if (V$1([
|
|
512
|
+
String(o),
|
|
386
513
|
a,
|
|
387
|
-
|
|
514
|
+
h
|
|
388
515
|
], "cancel")) {
|
|
389
|
-
|
|
516
|
+
s && t.write(import_src.cursor.show), process.exit(0);
|
|
390
517
|
return;
|
|
391
518
|
}
|
|
392
|
-
if (!
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
519
|
+
if (!e) return;
|
|
520
|
+
const f = a === "return" ? 0 : -1, v = a === "return" ? -1 : 0;
|
|
521
|
+
_.moveCursor(t, f, v, () => {
|
|
522
|
+
_.clearLine(t, 1, () => {
|
|
523
|
+
r.once("keypress", n);
|
|
397
524
|
});
|
|
398
525
|
});
|
|
399
526
|
};
|
|
400
|
-
return
|
|
401
|
-
|
|
527
|
+
return s && t.write(import_src.cursor.hide), r.once("keypress", n), () => {
|
|
528
|
+
r.off("keypress", n), s && t.write(import_src.cursor.show), r instanceof ReadStream && r.isTTY && !Y$1 && r.setRawMode(!1), i.terminal = !1, i.close();
|
|
402
529
|
};
|
|
403
530
|
}
|
|
404
|
-
const
|
|
405
|
-
function
|
|
406
|
-
return
|
|
531
|
+
const O$1 = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80, A = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
|
|
532
|
+
function R(r, t, e, s = e) {
|
|
533
|
+
return wrapAnsi(t, O$1(r ?? stdout) - e.length, {
|
|
407
534
|
hard: !0,
|
|
408
535
|
trim: !1
|
|
409
536
|
}).split(`
|
|
410
|
-
`).map((n,
|
|
537
|
+
`).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
|
|
411
538
|
`);
|
|
412
539
|
}
|
|
413
|
-
|
|
540
|
+
let p = class {
|
|
414
541
|
input;
|
|
415
542
|
output;
|
|
416
543
|
_abortSignal;
|
|
@@ -425,60 +552,60 @@ var x$1 = class {
|
|
|
425
552
|
error = "";
|
|
426
553
|
value;
|
|
427
554
|
userInput = "";
|
|
428
|
-
constructor(
|
|
429
|
-
const { input:
|
|
430
|
-
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 =
|
|
555
|
+
constructor(t, e = !0) {
|
|
556
|
+
const { input: s = stdin, output: i = stdout, render: n, signal: o, ...a } = t;
|
|
557
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = e, this._abortSignal = o, this.input = s, this.output = i;
|
|
431
558
|
}
|
|
432
559
|
unsubscribe() {
|
|
433
560
|
this._subscribers.clear();
|
|
434
561
|
}
|
|
435
|
-
setSubscriber(
|
|
436
|
-
const
|
|
437
|
-
|
|
562
|
+
setSubscriber(t, e) {
|
|
563
|
+
const s = this._subscribers.get(t) ?? [];
|
|
564
|
+
s.push(e), this._subscribers.set(t, s);
|
|
438
565
|
}
|
|
439
|
-
on(
|
|
440
|
-
this.setSubscriber(
|
|
566
|
+
on(t, e) {
|
|
567
|
+
this.setSubscriber(t, { cb: e });
|
|
441
568
|
}
|
|
442
|
-
once(
|
|
443
|
-
this.setSubscriber(
|
|
444
|
-
cb:
|
|
569
|
+
once(t, e) {
|
|
570
|
+
this.setSubscriber(t, {
|
|
571
|
+
cb: e,
|
|
445
572
|
once: !0
|
|
446
573
|
});
|
|
447
574
|
}
|
|
448
|
-
emit(
|
|
449
|
-
const
|
|
450
|
-
for (const n of
|
|
451
|
-
for (const n of
|
|
575
|
+
emit(t, ...e) {
|
|
576
|
+
const s = this._subscribers.get(t) ?? [], i = [];
|
|
577
|
+
for (const n of s) n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
|
|
578
|
+
for (const n of i) n();
|
|
452
579
|
}
|
|
453
580
|
prompt() {
|
|
454
|
-
return new Promise((
|
|
581
|
+
return new Promise((t) => {
|
|
455
582
|
if (this._abortSignal) {
|
|
456
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(),
|
|
583
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(C);
|
|
457
584
|
this._abortSignal.addEventListener("abort", () => {
|
|
458
585
|
this.state = "cancel", this.close();
|
|
459
586
|
}, { once: !0 });
|
|
460
587
|
}
|
|
461
|
-
this.rl =
|
|
588
|
+
this.rl = P$1.createInterface({
|
|
462
589
|
input: this.input,
|
|
463
590
|
tabSize: 2,
|
|
464
591
|
prompt: "",
|
|
465
592
|
escapeCodeTimeout: 50,
|
|
466
593
|
terminal: !0
|
|
467
|
-
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress),
|
|
468
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
594
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
595
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(this.value);
|
|
469
596
|
}), this.once("cancel", () => {
|
|
470
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
597
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(C);
|
|
471
598
|
});
|
|
472
599
|
});
|
|
473
600
|
}
|
|
474
|
-
_isActionKey(
|
|
475
|
-
return
|
|
601
|
+
_isActionKey(t, e) {
|
|
602
|
+
return t === " ";
|
|
476
603
|
}
|
|
477
|
-
_setValue(
|
|
478
|
-
this.value =
|
|
604
|
+
_setValue(t) {
|
|
605
|
+
this.value = t, this.emit("value", this.value);
|
|
479
606
|
}
|
|
480
|
-
_setUserInput(
|
|
481
|
-
this.userInput =
|
|
607
|
+
_setUserInput(t, e) {
|
|
608
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
482
609
|
}
|
|
483
610
|
_clearUserInput() {
|
|
484
611
|
this.rl?.write(null, {
|
|
@@ -486,204 +613,192 @@ var x$1 = class {
|
|
|
486
613
|
name: "u"
|
|
487
614
|
}), this._setUserInput("");
|
|
488
615
|
}
|
|
489
|
-
onKeypress(
|
|
490
|
-
if (this._track &&
|
|
616
|
+
onKeypress(t, e) {
|
|
617
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
491
618
|
ctrl: !0,
|
|
492
619
|
name: "h"
|
|
493
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"),
|
|
620
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
|
|
494
621
|
if (this.opts.validate) {
|
|
495
|
-
const
|
|
496
|
-
|
|
622
|
+
const s = this.opts.validate(this.value);
|
|
623
|
+
s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
|
|
497
624
|
}
|
|
498
625
|
this.state !== "error" && (this.state = "submit");
|
|
499
626
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
627
|
+
V$1([
|
|
628
|
+
t,
|
|
629
|
+
e?.name,
|
|
630
|
+
e?.sequence
|
|
504
631
|
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
505
632
|
}
|
|
506
633
|
close() {
|
|
507
634
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
508
|
-
`),
|
|
635
|
+
`), w$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
509
636
|
}
|
|
510
637
|
restoreCursor() {
|
|
511
|
-
const
|
|
638
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
512
639
|
hard: !0,
|
|
513
640
|
trim: !1
|
|
514
641
|
}).split(`
|
|
515
642
|
`).length - 1;
|
|
516
|
-
this.output.write(import_src.cursor.move(-999,
|
|
643
|
+
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
517
644
|
}
|
|
518
645
|
render() {
|
|
519
|
-
const
|
|
646
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
520
647
|
hard: !0,
|
|
521
648
|
trim: !1
|
|
522
649
|
});
|
|
523
|
-
if (
|
|
650
|
+
if (t !== this._prevFrame) {
|
|
524
651
|
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
525
652
|
else {
|
|
526
|
-
const
|
|
527
|
-
if (this.restoreCursor(),
|
|
528
|
-
const
|
|
529
|
-
let
|
|
530
|
-
if (
|
|
531
|
-
this._prevFrame =
|
|
653
|
+
const e = j(this._prevFrame, t), s = A(this.output);
|
|
654
|
+
if (this.restoreCursor(), e) {
|
|
655
|
+
const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
|
|
656
|
+
let o = e.lines.find((a) => a >= i);
|
|
657
|
+
if (o === void 0) {
|
|
658
|
+
this._prevFrame = t;
|
|
532
659
|
return;
|
|
533
660
|
}
|
|
534
|
-
if (
|
|
535
|
-
this.output.write(import_src.cursor.move(0,
|
|
536
|
-
const a =
|
|
661
|
+
if (e.lines.length === 1) {
|
|
662
|
+
this.output.write(import_src.cursor.move(0, o - n)), this.output.write(import_src.erase.lines(1));
|
|
663
|
+
const a = t.split(`
|
|
537
664
|
`);
|
|
538
|
-
this.output.write(a[
|
|
665
|
+
this.output.write(a[o]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, a.length - o - 1));
|
|
539
666
|
return;
|
|
540
|
-
} else if (
|
|
541
|
-
if (
|
|
667
|
+
} else if (e.lines.length > 1) {
|
|
668
|
+
if (i < n) o = i;
|
|
542
669
|
else {
|
|
543
|
-
const
|
|
544
|
-
|
|
670
|
+
const h = o - n;
|
|
671
|
+
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
545
672
|
}
|
|
546
673
|
this.output.write(import_src.erase.down());
|
|
547
|
-
const a =
|
|
548
|
-
`).slice(
|
|
674
|
+
const a = t.split(`
|
|
675
|
+
`).slice(o);
|
|
549
676
|
this.output.write(a.join(`
|
|
550
|
-
`)), this._prevFrame =
|
|
677
|
+
`)), this._prevFrame = t;
|
|
551
678
|
return;
|
|
552
679
|
}
|
|
553
680
|
}
|
|
554
681
|
this.output.write(import_src.erase.down());
|
|
555
682
|
}
|
|
556
|
-
this.output.write(
|
|
683
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
557
684
|
}
|
|
558
685
|
}
|
|
559
686
|
};
|
|
560
|
-
function
|
|
561
|
-
if (
|
|
562
|
-
const
|
|
563
|
-
return
|
|
687
|
+
function W(r, t) {
|
|
688
|
+
if (r === void 0 || t.length === 0) return 0;
|
|
689
|
+
const e = t.findIndex((s) => s.value === r);
|
|
690
|
+
return e !== -1 ? e : 0;
|
|
564
691
|
}
|
|
565
|
-
function
|
|
566
|
-
return (
|
|
692
|
+
function B(r, t) {
|
|
693
|
+
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
567
694
|
}
|
|
568
|
-
function
|
|
569
|
-
if (
|
|
695
|
+
function J$1(r, t) {
|
|
696
|
+
if (t) return r ? t : t[0];
|
|
570
697
|
}
|
|
571
|
-
|
|
698
|
+
let H$1 = class extends p {
|
|
572
699
|
filteredOptions;
|
|
573
700
|
multiple;
|
|
574
701
|
isNavigating = !1;
|
|
575
702
|
selectedValues = [];
|
|
576
703
|
focusedValue;
|
|
577
|
-
#
|
|
578
|
-
#
|
|
579
|
-
#
|
|
580
|
-
#
|
|
704
|
+
#e = 0;
|
|
705
|
+
#o = "";
|
|
706
|
+
#t;
|
|
707
|
+
#n;
|
|
708
|
+
#a;
|
|
581
709
|
get cursor() {
|
|
582
|
-
return this.#
|
|
710
|
+
return this.#e;
|
|
583
711
|
}
|
|
584
712
|
get userInputWithCursor() {
|
|
585
|
-
if (!this.userInput) return
|
|
713
|
+
if (!this.userInput) return styleText(["inverse", "hidden"], "_");
|
|
586
714
|
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
587
|
-
const
|
|
588
|
-
return `${
|
|
715
|
+
const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
|
|
716
|
+
return `${t}${styleText("inverse", e)}${s.join("")}`;
|
|
589
717
|
}
|
|
590
718
|
get options() {
|
|
591
|
-
return typeof this.#
|
|
592
|
-
}
|
|
593
|
-
constructor(
|
|
594
|
-
super(
|
|
595
|
-
const
|
|
596
|
-
this.filteredOptions = [...
|
|
597
|
-
let
|
|
598
|
-
if (
|
|
599
|
-
const n =
|
|
600
|
-
n !== -1 && (this.toggleSelected(
|
|
719
|
+
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
720
|
+
}
|
|
721
|
+
constructor(t) {
|
|
722
|
+
super(t), this.#n = t.options, this.#a = t.placeholder;
|
|
723
|
+
const e = this.options;
|
|
724
|
+
this.filteredOptions = [...e], this.multiple = t.multiple === !0, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
|
|
725
|
+
let s;
|
|
726
|
+
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s) for (const i of s) {
|
|
727
|
+
const n = e.findIndex((o) => o.value === i);
|
|
728
|
+
n !== -1 && (this.toggleSelected(i), this.#e = n);
|
|
601
729
|
}
|
|
602
|
-
this.focusedValue = this.options[this.#
|
|
730
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
603
731
|
}
|
|
604
|
-
_isActionKey(
|
|
605
|
-
return
|
|
732
|
+
_isActionKey(t, e) {
|
|
733
|
+
return t === " " || this.multiple && this.isNavigating && e.name === "space" && t !== void 0 && t !== "";
|
|
606
734
|
}
|
|
607
|
-
#
|
|
608
|
-
const
|
|
609
|
-
|
|
735
|
+
#s(t, e) {
|
|
736
|
+
const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === " ", a = this.#a, h = this.options, l = a !== void 0 && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : !0));
|
|
737
|
+
if (e.name === "tab" && o && l) {
|
|
738
|
+
this.userInput === " " && this._clearUserInput(), this._setUserInput(a, !0), this.isNavigating = !1;
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
s || i ? (this.#e = d$1(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = J$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
|
|
610
742
|
}
|
|
611
743
|
deselectAll() {
|
|
612
744
|
this.selectedValues = [];
|
|
613
745
|
}
|
|
614
|
-
toggleSelected(
|
|
615
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(
|
|
616
|
-
}
|
|
617
|
-
#
|
|
618
|
-
if (
|
|
619
|
-
this.#
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
this.#
|
|
623
|
-
const
|
|
624
|
-
|
|
746
|
+
toggleSelected(t) {
|
|
747
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e) => e !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
|
|
748
|
+
}
|
|
749
|
+
#i(t) {
|
|
750
|
+
if (t !== this.#o) {
|
|
751
|
+
this.#o = t;
|
|
752
|
+
const e = this.options;
|
|
753
|
+
t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
|
|
754
|
+
this.#e = d$1(W(this.focusedValue, this.filteredOptions), 0, this.filteredOptions);
|
|
755
|
+
const i = this.filteredOptions[this.#e];
|
|
756
|
+
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
625
757
|
}
|
|
626
758
|
}
|
|
627
759
|
};
|
|
628
|
-
var
|
|
629
|
-
get cursor() {
|
|
630
|
-
return this.value ? 0 : 1;
|
|
631
|
-
}
|
|
632
|
-
get _value() {
|
|
633
|
-
return this.cursor === 0;
|
|
634
|
-
}
|
|
635
|
-
constructor(e) {
|
|
636
|
-
super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
|
|
637
|
-
this.value = this._value;
|
|
638
|
-
}), this.on("confirm", (s) => {
|
|
639
|
-
this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
640
|
-
}), this.on("cursor", () => {
|
|
641
|
-
this.value = !this.value;
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
var yt$1 = class extends x$1 {
|
|
760
|
+
var st$1 = class extends p {
|
|
646
761
|
options;
|
|
647
762
|
cursor = 0;
|
|
648
|
-
#
|
|
649
|
-
getGroupItems(
|
|
650
|
-
return this.options.filter((
|
|
763
|
+
#e;
|
|
764
|
+
getGroupItems(t) {
|
|
765
|
+
return this.options.filter((e) => e.group === t);
|
|
651
766
|
}
|
|
652
|
-
isGroupSelected(
|
|
653
|
-
const
|
|
654
|
-
return
|
|
767
|
+
isGroupSelected(t) {
|
|
768
|
+
const e = this.getGroupItems(t), s = this.value;
|
|
769
|
+
return s === void 0 ? !1 : e.every((i) => s.includes(i.value));
|
|
655
770
|
}
|
|
656
771
|
toggleValue() {
|
|
657
|
-
const
|
|
658
|
-
if (this.value === void 0 && (this.value = []),
|
|
659
|
-
const
|
|
660
|
-
this.isGroupSelected(
|
|
661
|
-
} else this.value = this.value.includes(
|
|
662
|
-
}
|
|
663
|
-
constructor(
|
|
664
|
-
super(
|
|
665
|
-
const { options:
|
|
666
|
-
this.#
|
|
667
|
-
value:
|
|
772
|
+
const t = this.options[this.cursor];
|
|
773
|
+
if (this.value === void 0 && (this.value = []), t.group === !0) {
|
|
774
|
+
const e = t.value, s = this.getGroupItems(e);
|
|
775
|
+
this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
|
|
776
|
+
} else this.value = this.value.includes(t.value) ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
|
|
777
|
+
}
|
|
778
|
+
constructor(t) {
|
|
779
|
+
super(t, !1);
|
|
780
|
+
const { options: e } = t;
|
|
781
|
+
this.#e = t.selectableGroups !== !1, this.options = Object.entries(e).flatMap(([s, i]) => [{
|
|
782
|
+
value: s,
|
|
668
783
|
group: !0,
|
|
669
|
-
label:
|
|
670
|
-
}, ...
|
|
784
|
+
label: s
|
|
785
|
+
}, ...i.map((n) => ({
|
|
671
786
|
...n,
|
|
672
|
-
group:
|
|
673
|
-
}))]), this.value = [...
|
|
674
|
-
switch (
|
|
787
|
+
group: s
|
|
788
|
+
}))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
|
|
789
|
+
switch (s) {
|
|
675
790
|
case "left":
|
|
676
791
|
case "up": {
|
|
677
792
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
678
|
-
const
|
|
679
|
-
!this.#
|
|
793
|
+
const i = this.options[this.cursor]?.group === !0;
|
|
794
|
+
!this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
680
795
|
break;
|
|
681
796
|
}
|
|
682
797
|
case "down":
|
|
683
798
|
case "right": {
|
|
684
799
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
685
|
-
const
|
|
686
|
-
!this.#
|
|
800
|
+
const i = this.options[this.cursor]?.group === !0;
|
|
801
|
+
!this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
687
802
|
break;
|
|
688
803
|
}
|
|
689
804
|
case "space":
|
|
@@ -693,42 +808,42 @@ var yt$1 = class extends x$1 {
|
|
|
693
808
|
});
|
|
694
809
|
}
|
|
695
810
|
};
|
|
696
|
-
|
|
811
|
+
let it$1 = class extends p {
|
|
697
812
|
options;
|
|
698
813
|
cursor = 0;
|
|
699
814
|
get _value() {
|
|
700
815
|
return this.options[this.cursor].value;
|
|
701
816
|
}
|
|
702
817
|
get _enabledOptions() {
|
|
703
|
-
return this.options.filter((
|
|
818
|
+
return this.options.filter((t) => t.disabled !== !0);
|
|
704
819
|
}
|
|
705
820
|
toggleAll() {
|
|
706
|
-
const
|
|
707
|
-
this.value = this.value !== void 0 && this.value.length ===
|
|
821
|
+
const t = this._enabledOptions;
|
|
822
|
+
this.value = this.value !== void 0 && this.value.length === t.length ? [] : t.map((s) => s.value);
|
|
708
823
|
}
|
|
709
824
|
toggleInvert() {
|
|
710
|
-
const
|
|
711
|
-
if (!
|
|
712
|
-
this.value = this._enabledOptions.filter((
|
|
825
|
+
const t = this.value;
|
|
826
|
+
if (!t) return;
|
|
827
|
+
this.value = this._enabledOptions.filter((s) => !t.includes(s.value)).map((s) => s.value);
|
|
713
828
|
}
|
|
714
829
|
toggleValue() {
|
|
715
830
|
this.value === void 0 && (this.value = []);
|
|
716
|
-
this.value = this.value.includes(this._value) ? this.value.filter((
|
|
717
|
-
}
|
|
718
|
-
constructor(
|
|
719
|
-
super(
|
|
720
|
-
const
|
|
721
|
-
this.cursor = this.options[
|
|
722
|
-
|
|
723
|
-
}), this.on("cursor", (
|
|
724
|
-
switch (
|
|
831
|
+
this.value = this.value.includes(this._value) ? this.value.filter((e) => e !== this._value) : [...this.value, this._value];
|
|
832
|
+
}
|
|
833
|
+
constructor(t) {
|
|
834
|
+
super(t, !1), this.options = t.options, this.value = [...t.initialValues ?? []];
|
|
835
|
+
const e = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), 0);
|
|
836
|
+
this.cursor = this.options[e].disabled ? d$1(e, 1, this.options) : e, this.on("key", (s) => {
|
|
837
|
+
s === "a" && this.toggleAll(), s === "i" && this.toggleInvert();
|
|
838
|
+
}), this.on("cursor", (s) => {
|
|
839
|
+
switch (s) {
|
|
725
840
|
case "left":
|
|
726
841
|
case "up":
|
|
727
|
-
this.cursor =
|
|
842
|
+
this.cursor = d$1(this.cursor, -1, this.options);
|
|
728
843
|
break;
|
|
729
844
|
case "down":
|
|
730
845
|
case "right":
|
|
731
|
-
this.cursor =
|
|
846
|
+
this.cursor = d$1(this.cursor, 1, this.options);
|
|
732
847
|
break;
|
|
733
848
|
case "space":
|
|
734
849
|
this.toggleValue();
|
|
@@ -737,7 +852,7 @@ var Lt$1 = class extends x$1 {
|
|
|
737
852
|
});
|
|
738
853
|
}
|
|
739
854
|
};
|
|
740
|
-
|
|
855
|
+
var rt$1 = class extends p {
|
|
741
856
|
_mask = "•";
|
|
742
857
|
get cursor() {
|
|
743
858
|
return this._cursor;
|
|
@@ -747,21 +862,21 @@ let Mt$1 = class extends x$1 {
|
|
|
747
862
|
}
|
|
748
863
|
get userInputWithCursor() {
|
|
749
864
|
if (this.state === "submit" || this.state === "cancel") return this.masked;
|
|
750
|
-
const
|
|
751
|
-
if (this.cursor >=
|
|
752
|
-
const
|
|
753
|
-
return `${
|
|
865
|
+
const t = this.userInput;
|
|
866
|
+
if (this.cursor >= t.length) return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
|
|
867
|
+
const e = this.masked, s = e.slice(0, this.cursor), i = e.slice(this.cursor);
|
|
868
|
+
return `${s}${styleText("inverse", i[0])}${i.slice(1)}`;
|
|
754
869
|
}
|
|
755
870
|
clear() {
|
|
756
871
|
this._clearUserInput();
|
|
757
872
|
}
|
|
758
|
-
constructor({ mask:
|
|
759
|
-
super(
|
|
760
|
-
this._setValue(
|
|
873
|
+
constructor({ mask: t, ...e }) {
|
|
874
|
+
super(e), this._mask = t ?? "•", this.on("userInput", (s) => {
|
|
875
|
+
this._setValue(s);
|
|
761
876
|
});
|
|
762
877
|
}
|
|
763
878
|
};
|
|
764
|
-
var
|
|
879
|
+
var nt = class extends p {
|
|
765
880
|
options;
|
|
766
881
|
cursor = 0;
|
|
767
882
|
get _selectedValue() {
|
|
@@ -770,391 +885,243 @@ var Wt$1 = class extends x$1 {
|
|
|
770
885
|
changeValue() {
|
|
771
886
|
this.value = this._selectedValue.value;
|
|
772
887
|
}
|
|
773
|
-
constructor(
|
|
774
|
-
super(
|
|
775
|
-
const
|
|
776
|
-
this.cursor = this.options[
|
|
777
|
-
switch (
|
|
888
|
+
constructor(t) {
|
|
889
|
+
super(t, !1), this.options = t.options;
|
|
890
|
+
const e = this.options.findIndex(({ value: i }) => i === t.initialValue), s = e === -1 ? 0 : e;
|
|
891
|
+
this.cursor = this.options[s].disabled ? d$1(s, 1, this.options) : s, this.changeValue(), this.on("cursor", (i) => {
|
|
892
|
+
switch (i) {
|
|
778
893
|
case "left":
|
|
779
894
|
case "up":
|
|
780
|
-
this.cursor =
|
|
895
|
+
this.cursor = d$1(this.cursor, -1, this.options);
|
|
781
896
|
break;
|
|
782
897
|
case "down":
|
|
783
898
|
case "right":
|
|
784
|
-
this.cursor =
|
|
899
|
+
this.cursor = d$1(this.cursor, 1, this.options);
|
|
785
900
|
break;
|
|
786
901
|
}
|
|
787
902
|
this.changeValue();
|
|
788
903
|
});
|
|
789
904
|
}
|
|
790
905
|
};
|
|
791
|
-
var
|
|
906
|
+
var ot = class extends p {
|
|
792
907
|
options;
|
|
793
908
|
cursor = 0;
|
|
794
|
-
constructor(
|
|
795
|
-
super(
|
|
796
|
-
const
|
|
797
|
-
this.cursor = Math.max(
|
|
798
|
-
if (!
|
|
799
|
-
const
|
|
800
|
-
if (!
|
|
801
|
-
const a = this.options.find(({ value: [
|
|
909
|
+
constructor(t) {
|
|
910
|
+
super(t, !1), this.options = t.options;
|
|
911
|
+
const e = t.caseSensitive === !0, s = this.options.map(({ value: [i] }) => e ? i : i?.toLowerCase());
|
|
912
|
+
this.cursor = Math.max(s.indexOf(t.initialValue), 0), this.on("key", (i, n) => {
|
|
913
|
+
if (!i) return;
|
|
914
|
+
const o = e && n.shift ? i.toUpperCase() : i;
|
|
915
|
+
if (!s.includes(o)) return;
|
|
916
|
+
const a = this.options.find(({ value: [h] }) => e ? h === o : h?.toLowerCase() === i);
|
|
802
917
|
a && (this.value = a.value, this.state = "submit", this.emit("submit"));
|
|
803
918
|
});
|
|
804
919
|
}
|
|
805
920
|
};
|
|
806
|
-
var
|
|
921
|
+
var at = class extends p {
|
|
807
922
|
get userInputWithCursor() {
|
|
808
923
|
if (this.state === "submit") return this.userInput;
|
|
809
|
-
const
|
|
810
|
-
if (this.cursor >=
|
|
811
|
-
const
|
|
812
|
-
return `${
|
|
924
|
+
const t = this.userInput;
|
|
925
|
+
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
926
|
+
const e = t.slice(0, this.cursor), [s, ...i] = t.slice(this.cursor);
|
|
927
|
+
return `${e}${styleText("inverse", s)}${i.join("")}`;
|
|
813
928
|
}
|
|
814
929
|
get cursor() {
|
|
815
930
|
return this._cursor;
|
|
816
931
|
}
|
|
817
|
-
constructor(
|
|
932
|
+
constructor(t) {
|
|
818
933
|
super({
|
|
819
|
-
...
|
|
820
|
-
initialUserInput:
|
|
821
|
-
}), this.on("userInput", (
|
|
822
|
-
this._setValue(
|
|
934
|
+
...t,
|
|
935
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
936
|
+
}), this.on("userInput", (e) => {
|
|
937
|
+
this._setValue(e);
|
|
823
938
|
}), this.on("finalize", () => {
|
|
824
|
-
this.value || (this.value =
|
|
939
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
825
940
|
});
|
|
826
941
|
}
|
|
827
942
|
};
|
|
828
943
|
|
|
829
944
|
//#endregion
|
|
830
|
-
//#region ../../node_modules/.bun/@clack+prompts@1.0
|
|
831
|
-
function
|
|
832
|
-
return
|
|
945
|
+
//#region ../../node_modules/.bun/@clack+prompts@1.2.0/node_modules/@clack/prompts/dist/index.mjs
|
|
946
|
+
function Ze() {
|
|
947
|
+
return P.platform !== "win32" ? P.env.TERM !== "linux" : !!P.env.CI || !!P.env.WT_SESSION || !!P.env.TERMINUS_SUBLIME || P.env.ConEmuTask === "{cmd::Cmder}" || P.env.TERM_PROGRAM === "Terminus-Sublime" || P.env.TERM_PROGRAM === "vscode" || P.env.TERM === "xterm-256color" || P.env.TERM === "alacritty" || P.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
833
948
|
}
|
|
834
|
-
const
|
|
835
|
-
switch (
|
|
949
|
+
const ee = Ze(), ae = () => process.env.CI === "true", Te = (e) => e.isTTY === !0, w = (e, i) => ee ? e : i, _e = w("◆", "*"), oe = w("■", "x"), ue = w("▲", "x"), F = w("◇", "o"), le = w("┌", "T"), d = w("│", "|"), E = w("└", "—"), Ie = w("┐", "T"), Ee = w("┘", "—"), z = w("●", ">"), H = w("○", " "), te = w("◻", "[•]"), U = w("◼", "[+]"), J = w("◻", "[ ]"), xe = w("▪", "•"), se = w("─", "-"), ce = w("╮", "+"), Ge = w("├", "+"), $e = w("╯", "+"), de = w("╰", "+"), Oe = w("╭", "+"), he = w("●", "•"), pe = w("◆", "*"), me = w("▲", "!"), ge = w("■", "x"), V = (e) => {
|
|
950
|
+
switch (e) {
|
|
836
951
|
case "initial":
|
|
837
|
-
case "active": return
|
|
838
|
-
case "cancel": return
|
|
839
|
-
case "error": return
|
|
840
|
-
case "submit": return
|
|
952
|
+
case "active": return styleText("cyan", _e);
|
|
953
|
+
case "cancel": return styleText("red", oe);
|
|
954
|
+
case "error": return styleText("yellow", ue);
|
|
955
|
+
case "submit": return styleText("green", F);
|
|
841
956
|
}
|
|
842
|
-
},
|
|
843
|
-
switch (
|
|
957
|
+
}, ye = (e) => {
|
|
958
|
+
switch (e) {
|
|
844
959
|
case "initial":
|
|
845
|
-
case "active": return
|
|
846
|
-
case "cancel": return
|
|
847
|
-
case "error": return
|
|
848
|
-
case "submit": return
|
|
849
|
-
}
|
|
850
|
-
}, pe = (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, ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, fe = (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, At = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, it = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, nt = /\t{1,1000}/y, wt = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, at = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, Fe = /\p{M}+/gu, ye = {
|
|
851
|
-
limit: Infinity,
|
|
852
|
-
ellipsis: ""
|
|
853
|
-
}, jt = (t, r = {}, s = {}) => {
|
|
854
|
-
const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
855
|
-
let $ = 0, m = 0, h = t.length, y = 0, f = !1, v = h, S = Math.max(0, i - o), I = 0, B = 0, A = 0, w = 0;
|
|
856
|
-
t: for (;;) {
|
|
857
|
-
if (B > I || m >= h && m > $) {
|
|
858
|
-
const _ = t.slice(I, B) || t.slice($, m);
|
|
859
|
-
y = 0;
|
|
860
|
-
for (const D of _.replaceAll(Fe, "")) {
|
|
861
|
-
const T = D.codePointAt(0) || 0;
|
|
862
|
-
if (ge(T) ? w = F : fe(T) ? w = E : c !== p && pe(T) ? w = c : w = p, A + w > S && (v = Math.min(v, Math.max(I, $) + y)), A + w > i) {
|
|
863
|
-
f = !0;
|
|
864
|
-
break t;
|
|
865
|
-
}
|
|
866
|
-
y += D.length, A += w;
|
|
867
|
-
}
|
|
868
|
-
I = B = 0;
|
|
869
|
-
}
|
|
870
|
-
if (m >= h) break;
|
|
871
|
-
if (at.lastIndex = m, at.test(t)) {
|
|
872
|
-
if (y = at.lastIndex - m, w = y * p, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / p))), A + w > i) {
|
|
873
|
-
f = !0;
|
|
874
|
-
break;
|
|
875
|
-
}
|
|
876
|
-
A += w, I = $, B = m, m = $ = at.lastIndex;
|
|
877
|
-
continue;
|
|
878
|
-
}
|
|
879
|
-
if (At.lastIndex = m, At.test(t)) {
|
|
880
|
-
if (A + u > S && (v = Math.min(v, m)), A + u > i) {
|
|
881
|
-
f = !0;
|
|
882
|
-
break;
|
|
883
|
-
}
|
|
884
|
-
A += u, I = $, B = m, m = $ = At.lastIndex;
|
|
885
|
-
continue;
|
|
886
|
-
}
|
|
887
|
-
if (it.lastIndex = m, it.test(t)) {
|
|
888
|
-
if (y = it.lastIndex - m, w = y * l, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / l))), A + w > i) {
|
|
889
|
-
f = !0;
|
|
890
|
-
break;
|
|
891
|
-
}
|
|
892
|
-
A += w, I = $, B = m, m = $ = it.lastIndex;
|
|
893
|
-
continue;
|
|
894
|
-
}
|
|
895
|
-
if (nt.lastIndex = m, nt.test(t)) {
|
|
896
|
-
if (y = nt.lastIndex - m, w = y * n, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / n))), A + w > i) {
|
|
897
|
-
f = !0;
|
|
898
|
-
break;
|
|
899
|
-
}
|
|
900
|
-
A += w, I = $, B = m, m = $ = nt.lastIndex;
|
|
901
|
-
continue;
|
|
902
|
-
}
|
|
903
|
-
if (wt.lastIndex = m, wt.test(t)) {
|
|
904
|
-
if (A + g > S && (v = Math.min(v, m)), A + g > i) {
|
|
905
|
-
f = !0;
|
|
906
|
-
break;
|
|
907
|
-
}
|
|
908
|
-
A += g, I = $, B = m, m = $ = wt.lastIndex;
|
|
909
|
-
continue;
|
|
910
|
-
}
|
|
911
|
-
m += 1;
|
|
912
|
-
}
|
|
913
|
-
return {
|
|
914
|
-
width: f ? S : A,
|
|
915
|
-
index: f ? v : h,
|
|
916
|
-
truncated: f,
|
|
917
|
-
ellipsed: f && i >= o
|
|
918
|
-
};
|
|
919
|
-
}, Ee = {
|
|
920
|
-
limit: Infinity,
|
|
921
|
-
ellipsis: "",
|
|
922
|
-
ellipsisWidth: 0
|
|
923
|
-
}, M = (t, r = {}) => jt(t, Ee, r).width, ot$1 = "\x1B", Gt = "", ve = 39, Ct = "\x07", kt = "[", Ae = "]", Vt = "m", St = `${Ae}8;;`, Ht = new RegExp(`(?:\\${kt}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct})`, "y"), we = (t) => {
|
|
924
|
-
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
925
|
-
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
926
|
-
if (t === 1 || t === 2) return 22;
|
|
927
|
-
if (t === 3) return 23;
|
|
928
|
-
if (t === 4) return 24;
|
|
929
|
-
if (t === 7) return 27;
|
|
930
|
-
if (t === 8) return 28;
|
|
931
|
-
if (t === 9) return 29;
|
|
932
|
-
if (t === 0) return 0;
|
|
933
|
-
}, Ut = (t) => `${ot$1}${kt}${t}${Vt}`, Kt = (t) => `${ot$1}${St}${t}${Ct}`, Ce = (t) => t.map((r) => M(r)), It = (t, r, s) => {
|
|
934
|
-
const i = r[Symbol.iterator]();
|
|
935
|
-
let a = !1, o = !1, u = t.at(-1), l = u === void 0 ? 0 : M(u), n = i.next(), c = i.next(), g = 0;
|
|
936
|
-
for (; !n.done;) {
|
|
937
|
-
const F = n.value, p = M(F);
|
|
938
|
-
l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot$1 || F === Gt) && (a = !0, o = r.startsWith(St, g + 1)), a ? o ? F === Ct && (a = !1, o = !1) : F === Vt && (a = !1) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
|
|
939
|
-
}
|
|
940
|
-
u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
941
|
-
}, Se = (t) => {
|
|
942
|
-
const r = t.split(" ");
|
|
943
|
-
let s = r.length;
|
|
944
|
-
for (; s > 0 && !(M(r[s - 1]) > 0);) s--;
|
|
945
|
-
return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
946
|
-
}, Ie = (t, r, s = {}) => {
|
|
947
|
-
if (s.trim !== !1 && t.trim() === "") return "";
|
|
948
|
-
let i = "", a, o;
|
|
949
|
-
const u = t.split(" "), l = Ce(u);
|
|
950
|
-
let n = [""];
|
|
951
|
-
for (const [$, m] of u.entries()) {
|
|
952
|
-
s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
953
|
-
let h = M(n.at(-1) ?? "");
|
|
954
|
-
if ($ !== 0 && (h >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), h = 0), (h > 0 || s.trim === !1) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
|
|
955
|
-
const y = r - h, f = 1 + Math.floor((l[$] - y - 1) / r);
|
|
956
|
-
Math.floor((l[$] - 1) / r) < f && n.push(""), It(n, m, r);
|
|
957
|
-
continue;
|
|
958
|
-
}
|
|
959
|
-
if (h + l[$] > r && h > 0 && l[$] > 0) {
|
|
960
|
-
if (s.wordWrap === !1 && h < r) {
|
|
961
|
-
It(n, m, r);
|
|
962
|
-
continue;
|
|
963
|
-
}
|
|
964
|
-
n.push("");
|
|
965
|
-
}
|
|
966
|
-
if (h + l[$] > r && s.wordWrap === !1) {
|
|
967
|
-
It(n, m, r);
|
|
968
|
-
continue;
|
|
969
|
-
}
|
|
970
|
-
n[n.length - 1] += m;
|
|
971
|
-
}
|
|
972
|
-
s.trim !== !1 && (n = n.map(($) => Se($)));
|
|
973
|
-
const c = n.join(`
|
|
974
|
-
`), g = c[Symbol.iterator]();
|
|
975
|
-
let F = g.next(), p = g.next(), E = 0;
|
|
976
|
-
for (; !F.done;) {
|
|
977
|
-
const $ = F.value, m = p.value;
|
|
978
|
-
if (i += $, $ === ot$1 || $ === Gt) {
|
|
979
|
-
Ht.lastIndex = E + 1;
|
|
980
|
-
const f = Ht.exec(c)?.groups;
|
|
981
|
-
if (f?.code !== void 0) {
|
|
982
|
-
const v = Number.parseFloat(f.code);
|
|
983
|
-
a = v === ve ? void 0 : v;
|
|
984
|
-
} else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
|
|
985
|
-
}
|
|
986
|
-
const h = a ? we(a) : void 0;
|
|
987
|
-
m === `
|
|
988
|
-
` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
|
|
989
|
-
` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
|
|
960
|
+
case "active": return styleText("cyan", d);
|
|
961
|
+
case "cancel": return styleText("red", d);
|
|
962
|
+
case "error": return styleText("yellow", d);
|
|
963
|
+
case "submit": return styleText("green", d);
|
|
990
964
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
`).split(`
|
|
997
|
-
`).map((i) => Ie(i, r, s)).join(`
|
|
998
|
-
`);
|
|
999
|
-
}
|
|
1000
|
-
const be = (t, r, s, i, a) => {
|
|
1001
|
-
let o = r, u = 0;
|
|
1002
|
-
for (let l = s; l < i; l++) {
|
|
1003
|
-
const n = t[l];
|
|
1004
|
-
if (o = o - n.length, u++, o <= a) break;
|
|
965
|
+
}, et = (e, i, s, r, u) => {
|
|
966
|
+
let n = i, o = 0;
|
|
967
|
+
for (let c = s; c < r; c++) {
|
|
968
|
+
const a = e[c];
|
|
969
|
+
if (n = n - a.length, o++, n <= u) break;
|
|
1005
970
|
}
|
|
1006
971
|
return {
|
|
1007
|
-
lineCount:
|
|
1008
|
-
removals:
|
|
972
|
+
lineCount: n,
|
|
973
|
+
removals: o
|
|
1009
974
|
};
|
|
1010
|
-
},
|
|
1011
|
-
const
|
|
1012
|
-
let
|
|
1013
|
-
|
|
1014
|
-
let m =
|
|
1015
|
-
const
|
|
1016
|
-
let
|
|
1017
|
-
m &&
|
|
1018
|
-
const
|
|
1019
|
-
for (let
|
|
1020
|
-
const
|
|
975
|
+
}, Y = ({ cursor: e, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
|
|
976
|
+
const c = O$1(r) - n, a = A(r), l = styleText("dim", "..."), $ = Math.max(a - o, 0), y = Math.max(Math.min(u, $), 5);
|
|
977
|
+
let p = 0;
|
|
978
|
+
e >= y - 3 && (p = Math.max(Math.min(e - y + 3, i.length - y), 0));
|
|
979
|
+
let m = y < i.length && p > 0, g = y < i.length && p + y < i.length;
|
|
980
|
+
const S = Math.min(p + y, i.length), h = [];
|
|
981
|
+
let f = 0;
|
|
982
|
+
m && f++, g && f++;
|
|
983
|
+
const v = p + (m ? 1 : 0), T = S - (g ? 1 : 0);
|
|
984
|
+
for (let b = v; b < T; b++) {
|
|
985
|
+
const x = wrapAnsi(s(i[b], b === e), c, {
|
|
1021
986
|
hard: !0,
|
|
1022
987
|
trim: !1
|
|
1023
988
|
}).split(`
|
|
1024
989
|
`);
|
|
1025
|
-
|
|
990
|
+
h.push(x), f += x.length;
|
|
1026
991
|
}
|
|
1027
|
-
if (
|
|
1028
|
-
let
|
|
1029
|
-
const
|
|
1030
|
-
m ? ({lineCount:
|
|
992
|
+
if (f > $) {
|
|
993
|
+
let b = 0, x = 0, G = f;
|
|
994
|
+
const M = e - v, R = (j, D) => et(h, G, j, D, $);
|
|
995
|
+
m ? ({lineCount: G, removals: b} = R(0, M), G > $ && ({lineCount: G, removals: x} = R(M + 1, h.length))) : ({lineCount: G, removals: x} = R(M + 1, h.length), G > $ && ({lineCount: G, removals: b} = R(0, M))), b > 0 && (m = !0, h.splice(0, b)), x > 0 && (g = !0, h.splice(h.length - x, x));
|
|
1031
996
|
}
|
|
1032
|
-
const
|
|
1033
|
-
m &&
|
|
1034
|
-
for (const
|
|
1035
|
-
return
|
|
997
|
+
const C = [];
|
|
998
|
+
m && C.push(l);
|
|
999
|
+
for (const b of h) for (const x of b) C.push(x);
|
|
1000
|
+
return g && C.push(l), C;
|
|
1036
1001
|
};
|
|
1037
|
-
function
|
|
1038
|
-
return
|
|
1002
|
+
function Me(e) {
|
|
1003
|
+
return e.label ?? String(e.value ?? "");
|
|
1039
1004
|
}
|
|
1040
|
-
function
|
|
1041
|
-
if (!
|
|
1042
|
-
const s = (
|
|
1043
|
-
return s.includes(
|
|
1005
|
+
function Re(e, i) {
|
|
1006
|
+
if (!e) return !0;
|
|
1007
|
+
const s = (i.label ?? String(i.value ?? "")).toLowerCase(), r = (i.hint ?? "").toLowerCase(), u = String(i.value).toLowerCase(), n = e.toLowerCase();
|
|
1008
|
+
return s.includes(n) || r.includes(n) || u.includes(n);
|
|
1044
1009
|
}
|
|
1045
|
-
function
|
|
1010
|
+
function tt(e, i) {
|
|
1046
1011
|
const s = [];
|
|
1047
|
-
for (const
|
|
1012
|
+
for (const r of i) e.includes(r.value) && s.push(r);
|
|
1048
1013
|
return s;
|
|
1049
1014
|
}
|
|
1050
|
-
const
|
|
1051
|
-
options:
|
|
1052
|
-
initialValue:
|
|
1053
|
-
initialUserInput:
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1015
|
+
const Ae = (e) => new H$1({
|
|
1016
|
+
options: e.options,
|
|
1017
|
+
initialValue: e.initialValue ? [e.initialValue] : void 0,
|
|
1018
|
+
initialUserInput: e.initialUserInput,
|
|
1019
|
+
placeholder: e.placeholder,
|
|
1020
|
+
filter: e.filter ?? ((i, s) => Re(i, s)),
|
|
1021
|
+
signal: e.signal,
|
|
1022
|
+
input: e.input,
|
|
1023
|
+
output: e.output,
|
|
1024
|
+
validate: e.validate,
|
|
1059
1025
|
render() {
|
|
1060
|
-
const
|
|
1061
|
-
const
|
|
1062
|
-
switch (
|
|
1063
|
-
case "active": return `${
|
|
1064
|
-
case "inactive": return `${
|
|
1065
|
-
case "disabled": return `${
|
|
1026
|
+
const i = e.withGuide ?? u.withGuide, s = i ? [`${styleText("gray", d)}`, `${V(this.state)} ${e.message}`] : [`${V(this.state)} ${e.message}`], r = this.userInput, u$1 = this.options, n = e.placeholder, o = r === "" && n !== void 0, c = (a, l) => {
|
|
1027
|
+
const $ = Me(a), y = a.hint && a.value === this.focusedValue ? styleText("dim", ` (${a.hint})`) : "";
|
|
1028
|
+
switch (l) {
|
|
1029
|
+
case "active": return `${styleText("green", z)} ${$}${y}`;
|
|
1030
|
+
case "inactive": return `${styleText("dim", H)} ${styleText("dim", $)}`;
|
|
1031
|
+
case "disabled": return `${styleText("gray", H)} ${styleText(["strikethrough", "gray"], $)}`;
|
|
1066
1032
|
}
|
|
1067
1033
|
};
|
|
1068
1034
|
switch (this.state) {
|
|
1069
1035
|
case "submit": {
|
|
1070
|
-
const
|
|
1036
|
+
const a = tt(this.selectedValues, u$1), l = a.length > 0 ? ` ${styleText("dim", a.map(Me).join(", "))}` : "", $ = i ? styleText("gray", d) : "";
|
|
1071
1037
|
return `${s.join(`
|
|
1072
1038
|
`)}
|
|
1073
|
-
${
|
|
1039
|
+
${$}${l}`;
|
|
1074
1040
|
}
|
|
1075
1041
|
case "cancel": {
|
|
1076
|
-
const
|
|
1042
|
+
const a = r ? ` ${styleText(["strikethrough", "dim"], r)}` : "", l = i ? styleText("gray", d) : "";
|
|
1077
1043
|
return `${s.join(`
|
|
1078
1044
|
`)}
|
|
1079
|
-
${
|
|
1045
|
+
${l}${a}`;
|
|
1080
1046
|
}
|
|
1081
1047
|
default: {
|
|
1082
|
-
const
|
|
1083
|
-
let
|
|
1084
|
-
if (this.isNavigating ||
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
} else
|
|
1088
|
-
const p = this.filteredOptions.length !==
|
|
1089
|
-
|
|
1090
|
-
const h = [`${
|
|
1091
|
-
`${
|
|
1092
|
-
`${
|
|
1093
|
-
`${
|
|
1094
|
-
].join(" • ")}`,
|
|
1048
|
+
const a = this.state === "error" ? "yellow" : "cyan", l = i ? `${styleText(a, d)} ` : "", $ = i ? styleText(a, E) : "";
|
|
1049
|
+
let y = "";
|
|
1050
|
+
if (this.isNavigating || o) {
|
|
1051
|
+
const v = o ? n : r;
|
|
1052
|
+
y = v !== "" ? ` ${styleText("dim", v)}` : "";
|
|
1053
|
+
} else y = ` ${this.userInputWithCursor}`;
|
|
1054
|
+
const p = this.filteredOptions.length !== u$1.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", m = this.filteredOptions.length === 0 && r ? [`${l}${styleText("yellow", "No matches found")}`] : [], g = this.state === "error" ? [`${l}${styleText("yellow", this.error)}`] : [];
|
|
1055
|
+
i && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${y}${p}`, ...m, ...g);
|
|
1056
|
+
const h = [`${l}${[
|
|
1057
|
+
`${styleText("dim", "↑/↓")} to select`,
|
|
1058
|
+
`${styleText("dim", "Enter:")} confirm`,
|
|
1059
|
+
`${styleText("dim", "Type:")} to search`
|
|
1060
|
+
].join(" • ")}`, $], f = this.filteredOptions.length === 0 ? [] : Y({
|
|
1095
1061
|
cursor: this.cursor,
|
|
1096
1062
|
options: this.filteredOptions,
|
|
1097
|
-
columnPadding:
|
|
1063
|
+
columnPadding: i ? 3 : 0,
|
|
1098
1064
|
rowPadding: s.length + h.length,
|
|
1099
|
-
style: (
|
|
1100
|
-
maxItems:
|
|
1101
|
-
output:
|
|
1065
|
+
style: (v, T) => c(v, v.disabled ? "disabled" : T ? "active" : "inactive"),
|
|
1066
|
+
maxItems: e.maxItems,
|
|
1067
|
+
output: e.output
|
|
1102
1068
|
});
|
|
1103
1069
|
return [
|
|
1104
1070
|
...s,
|
|
1105
|
-
...
|
|
1071
|
+
...f.map((v) => `${l}${v}`),
|
|
1106
1072
|
...h
|
|
1107
1073
|
].join(`
|
|
1108
1074
|
`);
|
|
1109
1075
|
}
|
|
1110
1076
|
}
|
|
1111
1077
|
}
|
|
1112
|
-
}).prompt(),
|
|
1113
|
-
const
|
|
1114
|
-
const
|
|
1115
|
-
return
|
|
1116
|
-
}, s = new
|
|
1117
|
-
options:
|
|
1078
|
+
}).prompt(), st = (e) => {
|
|
1079
|
+
const i = (r, u, n, o) => {
|
|
1080
|
+
const c = n.includes(r.value), a = r.label ?? String(r.value ?? ""), l = r.hint && o !== void 0 && r.value === o ? styleText("dim", ` (${r.hint})`) : "", $ = c ? styleText("green", U) : styleText("dim", J);
|
|
1081
|
+
return r.disabled ? `${styleText("gray", J)} ${styleText(["strikethrough", "gray"], a)}` : u ? `${$} ${a}${l}` : `${$} ${styleText("dim", a)}`;
|
|
1082
|
+
}, s = new H$1({
|
|
1083
|
+
options: e.options,
|
|
1118
1084
|
multiple: !0,
|
|
1119
|
-
|
|
1085
|
+
placeholder: e.placeholder,
|
|
1086
|
+
filter: e.filter ?? ((r, u) => Re(r, u)),
|
|
1120
1087
|
validate: () => {
|
|
1121
|
-
if (
|
|
1088
|
+
if (e.required && s.selectedValues.length === 0) return "Please select at least one item";
|
|
1122
1089
|
},
|
|
1123
|
-
initialValue:
|
|
1124
|
-
signal:
|
|
1125
|
-
input:
|
|
1126
|
-
output:
|
|
1090
|
+
initialValue: e.initialValues,
|
|
1091
|
+
signal: e.signal,
|
|
1092
|
+
input: e.input,
|
|
1093
|
+
output: e.output,
|
|
1127
1094
|
render() {
|
|
1128
|
-
const
|
|
1129
|
-
${
|
|
1130
|
-
`,
|
|
1095
|
+
const r = e.withGuide ?? u.withGuide, u$2 = `${r ? `${styleText("gray", d)}
|
|
1096
|
+
` : ""}${V(this.state)} ${e.message}
|
|
1097
|
+
`, n = this.userInput, o = e.placeholder, c = n === "" && o !== void 0, a = this.isNavigating || c ? styleText("dim", c ? o : n) : this.userInputWithCursor, l = this.options, $ = this.filteredOptions.length !== l.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
1131
1098
|
switch (this.state) {
|
|
1132
|
-
case "submit": return `${
|
|
1133
|
-
case "cancel": return `${
|
|
1099
|
+
case "submit": return `${u$2}${r ? `${styleText("gray", d)} ` : ""}${styleText("dim", `${this.selectedValues.length} items selected`)}`;
|
|
1100
|
+
case "cancel": return `${u$2}${r ? `${styleText("gray", d)} ` : ""}${styleText(["strikethrough", "dim"], n)}`;
|
|
1134
1101
|
default: {
|
|
1135
|
-
const
|
|
1136
|
-
`${
|
|
1137
|
-
`${
|
|
1138
|
-
`${
|
|
1139
|
-
`${
|
|
1140
|
-
],
|
|
1141
|
-
...`${
|
|
1102
|
+
const y = this.state === "error" ? "yellow" : "cyan", p = r ? `${styleText(y, d)} ` : "", m = r ? styleText(y, E) : "", g = [
|
|
1103
|
+
`${styleText("dim", "↑/↓")} to navigate`,
|
|
1104
|
+
`${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
1105
|
+
`${styleText("dim", "Enter:")} confirm`,
|
|
1106
|
+
`${styleText("dim", "Type:")} to search`
|
|
1107
|
+
], S = this.filteredOptions.length === 0 && n ? [`${p}${styleText("yellow", "No matches found")}`] : [], h = this.state === "error" ? [`${p}${styleText("yellow", this.error)}`] : [], f = [
|
|
1108
|
+
...`${u$2}${r ? styleText(y, d) : ""}`.split(`
|
|
1142
1109
|
`),
|
|
1143
|
-
`${
|
|
1144
|
-
...
|
|
1145
|
-
...
|
|
1146
|
-
],
|
|
1110
|
+
`${p}${styleText("dim", "Search:")} ${a}${$}`,
|
|
1111
|
+
...S,
|
|
1112
|
+
...h
|
|
1113
|
+
], v = [`${p}${g.join(" • ")}`, m], T = Y({
|
|
1147
1114
|
cursor: this.cursor,
|
|
1148
1115
|
options: this.filteredOptions,
|
|
1149
|
-
style: (
|
|
1150
|
-
maxItems:
|
|
1151
|
-
output:
|
|
1152
|
-
rowPadding:
|
|
1116
|
+
style: (C, b) => i(C, b, this.selectedValues, this.focusedValue),
|
|
1117
|
+
maxItems: e.maxItems,
|
|
1118
|
+
output: e.output,
|
|
1119
|
+
rowPadding: f.length + v.length
|
|
1153
1120
|
});
|
|
1154
1121
|
return [
|
|
1155
|
-
|
|
1156
|
-
...
|
|
1157
|
-
...
|
|
1122
|
+
...f,
|
|
1123
|
+
...T.map((C) => `${p}${C}`),
|
|
1124
|
+
...v
|
|
1158
1125
|
].join(`
|
|
1159
1126
|
`);
|
|
1160
1127
|
}
|
|
@@ -1162,385 +1129,340 @@ ${W(this.state)} ${t.message}
|
|
|
1162
1129
|
}
|
|
1163
1130
|
});
|
|
1164
1131
|
return s.prompt();
|
|
1165
|
-
},
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
],
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1132
|
+
}, rt = [
|
|
1133
|
+
Oe,
|
|
1134
|
+
ce,
|
|
1135
|
+
de,
|
|
1136
|
+
$e
|
|
1137
|
+
], it = [
|
|
1138
|
+
le,
|
|
1139
|
+
Ie,
|
|
1140
|
+
E,
|
|
1141
|
+
Ee
|
|
1175
1142
|
];
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
`);
|
|
1186
|
-
let D = m + u * 2;
|
|
1187
|
-
for (const Y of _) {
|
|
1188
|
-
const L = M(Y) + l * 2;
|
|
1189
|
-
L > D && (D = L);
|
|
1190
|
-
}
|
|
1191
|
-
const T = D + o;
|
|
1192
|
-
T < y && (y = T);
|
|
1193
|
-
}
|
|
1194
|
-
y % 2 !== 0 && (y < h ? y++ : y--);
|
|
1195
|
-
const f = y - o, v = f - u * 2, S = m > v ? `${r.slice(0, v - 3)}...` : r, [I, B] = Yt(M(S), f, u, s?.titleAlign), A = J(t, f - l * 2, {
|
|
1196
|
-
hard: !0,
|
|
1197
|
-
trim: !1
|
|
1198
|
-
});
|
|
1199
|
-
i.write(`${c}${F[0]}${p.repeat(I)}${S}${p.repeat(B)}${F[1]}
|
|
1200
|
-
`);
|
|
1201
|
-
const w = A.split(`
|
|
1202
|
-
`);
|
|
1203
|
-
for (const _ of w) {
|
|
1204
|
-
const [D, T] = Yt(M(_), f, l, s?.contentAlign);
|
|
1205
|
-
i.write(`${c}${E}${" ".repeat(D)}${_}${" ".repeat(T)}${E}
|
|
1206
|
-
`);
|
|
1207
|
-
}
|
|
1208
|
-
i.write(`${c}${F[2]}${p.repeat(f)}${F[3]}
|
|
1209
|
-
`);
|
|
1210
|
-
}, Re = (t) => {
|
|
1211
|
-
const r = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
1212
|
-
return new kt$1({
|
|
1213
|
-
active: r,
|
|
1214
|
-
inactive: s,
|
|
1215
|
-
signal: t.signal,
|
|
1216
|
-
input: t.input,
|
|
1217
|
-
output: t.output,
|
|
1218
|
-
initialValue: t.initialValue ?? !0,
|
|
1219
|
-
render() {
|
|
1220
|
-
const i = t.withGuide ?? _.withGuide, a = `${i ? `${import_picocolors.default.gray(d)}
|
|
1221
|
-
` : ""}${W(this.state)} ${t.message}
|
|
1222
|
-
`, o = this.value ? r : s;
|
|
1223
|
-
switch (this.state) {
|
|
1224
|
-
case "submit": return `${a}${i ? `${import_picocolors.default.gray(d)} ` : ""}${import_picocolors.default.dim(o)}`;
|
|
1225
|
-
case "cancel": return `${a}${i ? `${import_picocolors.default.gray(d)} ` : ""}${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}${i ? `
|
|
1226
|
-
${import_picocolors.default.gray(d)}` : ""}`;
|
|
1227
|
-
default: {
|
|
1228
|
-
const u = i ? `${import_picocolors.default.cyan(d)} ` : "", l = i ? import_picocolors.default.cyan(x) : "";
|
|
1229
|
-
return `${a}${u}${this.value ? `${import_picocolors.default.green(Q)} ${r}` : `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(r)}`}${t.vertical ? i ? `
|
|
1230
|
-
${import_picocolors.default.cyan(d)} ` : `
|
|
1231
|
-
` : ` ${import_picocolors.default.dim("/")} `}${this.value ? `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(s)}` : `${import_picocolors.default.green(Q)} ${s}`}
|
|
1232
|
-
${l}
|
|
1233
|
-
`;
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
}).prompt();
|
|
1238
|
-
}, Oe = async (t, r) => {
|
|
1239
|
-
const s = {}, i = Object.keys(t);
|
|
1240
|
-
for (const a of i) {
|
|
1241
|
-
const o = t[a], u = await o({ results: s })?.catch((l) => {
|
|
1242
|
-
throw l;
|
|
1143
|
+
const $t = {
|
|
1144
|
+
year: "yyyy",
|
|
1145
|
+
month: "mm",
|
|
1146
|
+
day: "dd"
|
|
1147
|
+
}, dt = async (e, i) => {
|
|
1148
|
+
const s = {}, r = Object.keys(e);
|
|
1149
|
+
for (const u of r) {
|
|
1150
|
+
const n = e[u], o = await n({ results: s })?.catch((c) => {
|
|
1151
|
+
throw c;
|
|
1243
1152
|
});
|
|
1244
|
-
if (typeof
|
|
1245
|
-
s[
|
|
1153
|
+
if (typeof i?.onCancel == "function" && q(o)) {
|
|
1154
|
+
s[u] = "canceled", i.onCancel({ results: s });
|
|
1246
1155
|
continue;
|
|
1247
1156
|
}
|
|
1248
|
-
s[
|
|
1157
|
+
s[u] = o;
|
|
1249
1158
|
}
|
|
1250
1159
|
return s;
|
|
1251
|
-
},
|
|
1252
|
-
const { selectableGroups:
|
|
1253
|
-
const
|
|
1254
|
-
let
|
|
1255
|
-
if (s > 0 && !
|
|
1256
|
-
const
|
|
1257
|
-
${
|
|
1258
|
-
|
|
1160
|
+
}, ht = (e) => {
|
|
1161
|
+
const { selectableGroups: i = !0, groupSpacing: s = 0 } = e, r = (n, o, c = []) => {
|
|
1162
|
+
const a = n.label ?? String(n.value), l = typeof n.group == "string", $ = l && (c[c.indexOf(n) + 1] ?? { group: !0 }), y = l && $ && $.group === !0, p = l ? i ? `${y ? E : d} ` : " " : "";
|
|
1163
|
+
let m = "";
|
|
1164
|
+
if (s > 0 && !l) {
|
|
1165
|
+
const S = `
|
|
1166
|
+
${styleText("cyan", d)}`;
|
|
1167
|
+
m = `${S.repeat(s - 1)}${S} `;
|
|
1259
1168
|
}
|
|
1260
|
-
if (
|
|
1261
|
-
if (
|
|
1262
|
-
if (
|
|
1263
|
-
if (
|
|
1264
|
-
const
|
|
1265
|
-
return `${
|
|
1169
|
+
if (o === "active") return `${m}${styleText("dim", p)}${styleText("cyan", te)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1170
|
+
if (o === "group-active") return `${m}${p}${styleText("cyan", te)} ${styleText("dim", a)}`;
|
|
1171
|
+
if (o === "group-active-selected") return `${m}${p}${styleText("green", U)} ${styleText("dim", a)}`;
|
|
1172
|
+
if (o === "selected") {
|
|
1173
|
+
const S = l || i ? styleText("green", U) : "";
|
|
1174
|
+
return `${m}${styleText("dim", p)}${S} ${styleText("dim", a)}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1266
1175
|
}
|
|
1267
|
-
if (
|
|
1268
|
-
if (
|
|
1269
|
-
if (
|
|
1270
|
-
const
|
|
1271
|
-
return `${
|
|
1272
|
-
},
|
|
1273
|
-
return new
|
|
1274
|
-
options:
|
|
1275
|
-
signal:
|
|
1276
|
-
input:
|
|
1277
|
-
output:
|
|
1278
|
-
initialValues:
|
|
1279
|
-
required:
|
|
1280
|
-
cursorAt:
|
|
1281
|
-
selectableGroups:
|
|
1282
|
-
validate(
|
|
1283
|
-
if (
|
|
1284
|
-
${
|
|
1176
|
+
if (o === "cancelled") return `${styleText(["strikethrough", "dim"], a)}`;
|
|
1177
|
+
if (o === "active-selected") return `${m}${styleText("dim", p)}${styleText("green", U)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1178
|
+
if (o === "submitted") return `${styleText("dim", a)}`;
|
|
1179
|
+
const g = l || i ? styleText("dim", J) : "";
|
|
1180
|
+
return `${m}${styleText("dim", p)}${g} ${styleText("dim", a)}`;
|
|
1181
|
+
}, u$6 = e.required ?? !0;
|
|
1182
|
+
return new st$1({
|
|
1183
|
+
options: e.options,
|
|
1184
|
+
signal: e.signal,
|
|
1185
|
+
input: e.input,
|
|
1186
|
+
output: e.output,
|
|
1187
|
+
initialValues: e.initialValues,
|
|
1188
|
+
required: u$6,
|
|
1189
|
+
cursorAt: e.cursorAt,
|
|
1190
|
+
selectableGroups: i,
|
|
1191
|
+
validate(n) {
|
|
1192
|
+
if (u$6 && (n === void 0 || n.length === 0)) return `Please select at least one option.
|
|
1193
|
+
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1194
|
+
"gray",
|
|
1195
|
+
"bgWhite",
|
|
1196
|
+
"inverse"
|
|
1197
|
+
], " space ")} to select, ${styleText("gray", styleText(["bgWhite", "inverse"], " enter "))} to submit`))}`;
|
|
1285
1198
|
},
|
|
1286
1199
|
render() {
|
|
1287
|
-
const o = `${
|
|
1288
|
-
${
|
|
1289
|
-
`,
|
|
1200
|
+
const n = e.withGuide ?? u.withGuide, o = `${n ? `${styleText("gray", d)}
|
|
1201
|
+
` : ""}${V(this.state)} ${e.message}
|
|
1202
|
+
`, c = this.value ?? [];
|
|
1290
1203
|
switch (this.state) {
|
|
1291
1204
|
case "submit": {
|
|
1292
|
-
const
|
|
1293
|
-
return `${o}${
|
|
1205
|
+
const a = this.options.filter(({ value: $ }) => c.includes($)).map(($) => r($, "submitted")), l = a.length === 0 ? "" : ` ${a.join(styleText("dim", ", "))}`;
|
|
1206
|
+
return `${o}${n ? styleText("gray", d) : ""}${l}`;
|
|
1294
1207
|
}
|
|
1295
1208
|
case "cancel": {
|
|
1296
|
-
const
|
|
1297
|
-
return `${o}${
|
|
1298
|
-
${
|
|
1209
|
+
const a = this.options.filter(({ value: l }) => c.includes(l)).map((l) => r(l, "cancelled")).join(styleText("dim", ", "));
|
|
1210
|
+
return `${o}${n ? `${styleText("gray", d)} ` : ""}${a.trim() ? `${a}${n ? `
|
|
1211
|
+
${styleText("gray", d)}` : ""}` : ""}`;
|
|
1299
1212
|
}
|
|
1300
1213
|
case "error": {
|
|
1301
|
-
const
|
|
1302
|
-
`).map((
|
|
1214
|
+
const a = this.error.split(`
|
|
1215
|
+
`).map((l, $) => $ === 0 ? `${n ? `${styleText("yellow", E)} ` : ""}${styleText("yellow", l)}` : ` ${l}`).join(`
|
|
1303
1216
|
`);
|
|
1304
|
-
return `${o}${
|
|
1305
|
-
const
|
|
1306
|
-
return !
|
|
1217
|
+
return `${o}${n ? `${styleText("yellow", d)} ` : ""}${this.options.map((l, $, y) => {
|
|
1218
|
+
const p = c.includes(l.value) || l.group === !0 && this.isGroupSelected(`${l.value}`), m = $ === this.cursor;
|
|
1219
|
+
return !m && typeof l.group == "string" && this.options[this.cursor].value === l.group ? r(l, p ? "group-active-selected" : "group-active", y) : m && p ? r(l, "active-selected", y) : p ? r(l, "selected", y) : r(l, m ? "active" : "inactive", y);
|
|
1307
1220
|
}).join(`
|
|
1308
|
-
${
|
|
1309
|
-
${
|
|
1221
|
+
${n ? `${styleText("yellow", d)} ` : ""}`)}
|
|
1222
|
+
${a}
|
|
1310
1223
|
`;
|
|
1311
1224
|
}
|
|
1312
1225
|
default: {
|
|
1313
|
-
const
|
|
1314
|
-
const
|
|
1315
|
-
let
|
|
1316
|
-
return
|
|
1317
|
-
`) ? " " : ""}${
|
|
1226
|
+
const a = this.options.map(($, y, p) => {
|
|
1227
|
+
const m = c.includes($.value) || $.group === !0 && this.isGroupSelected(`${$.value}`), g = y === this.cursor, S = !g && typeof $.group == "string" && this.options[this.cursor].value === $.group;
|
|
1228
|
+
let h = "";
|
|
1229
|
+
return S ? h = r($, m ? "group-active-selected" : "group-active", p) : g && m ? h = r($, "active-selected", p) : m ? h = r($, "selected", p) : h = r($, g ? "active" : "inactive", p), `${y !== 0 && !h.startsWith(`
|
|
1230
|
+
`) ? " " : ""}${h}`;
|
|
1318
1231
|
}).join(`
|
|
1319
|
-
${
|
|
1232
|
+
${n ? styleText("cyan", d) : ""}`), l = a.startsWith(`
|
|
1320
1233
|
`) ? "" : " ";
|
|
1321
|
-
return `${o}${
|
|
1322
|
-
${
|
|
1234
|
+
return `${o}${n ? styleText("cyan", d) : ""}${l}${a}
|
|
1235
|
+
${n ? styleText("cyan", E) : ""}
|
|
1323
1236
|
`;
|
|
1324
1237
|
}
|
|
1325
1238
|
}
|
|
1326
1239
|
}
|
|
1327
1240
|
}).prompt();
|
|
1328
|
-
},
|
|
1329
|
-
message: (
|
|
1330
|
-
const
|
|
1331
|
-
for (let p = 0; p <
|
|
1332
|
-
const
|
|
1241
|
+
}, O = {
|
|
1242
|
+
message: (e = [], { symbol: i = styleText("gray", d), secondarySymbol: s = styleText("gray", d), output: r = process.stdout, spacing: u$7 = 1, withGuide: n } = {}) => {
|
|
1243
|
+
const o = [], c = n ?? u.withGuide, a = c ? s : "", l = c ? `${i} ` : "", $ = c ? `${s} ` : "";
|
|
1244
|
+
for (let p = 0; p < u$7; p++) o.push(a);
|
|
1245
|
+
const y = Array.isArray(e) ? e : e.split(`
|
|
1333
1246
|
`);
|
|
1334
|
-
if (
|
|
1335
|
-
const [p, ...
|
|
1336
|
-
p.length > 0 ?
|
|
1337
|
-
for (const
|
|
1247
|
+
if (y.length > 0) {
|
|
1248
|
+
const [p, ...m] = y;
|
|
1249
|
+
p.length > 0 ? o.push(`${l}${p}`) : o.push(c ? i : "");
|
|
1250
|
+
for (const g of m) g.length > 0 ? o.push(`${$}${g}`) : o.push(c ? s : "");
|
|
1338
1251
|
}
|
|
1339
|
-
|
|
1252
|
+
r.write(`${o.join(`
|
|
1340
1253
|
`)}
|
|
1341
1254
|
`);
|
|
1342
1255
|
},
|
|
1343
|
-
info: (
|
|
1344
|
-
|
|
1345
|
-
...
|
|
1346
|
-
symbol:
|
|
1256
|
+
info: (e, i) => {
|
|
1257
|
+
O.message(e, {
|
|
1258
|
+
...i,
|
|
1259
|
+
symbol: styleText("blue", he)
|
|
1347
1260
|
});
|
|
1348
1261
|
},
|
|
1349
|
-
success: (
|
|
1350
|
-
|
|
1351
|
-
...
|
|
1352
|
-
symbol:
|
|
1262
|
+
success: (e, i) => {
|
|
1263
|
+
O.message(e, {
|
|
1264
|
+
...i,
|
|
1265
|
+
symbol: styleText("green", pe)
|
|
1353
1266
|
});
|
|
1354
1267
|
},
|
|
1355
|
-
step: (
|
|
1356
|
-
|
|
1357
|
-
...
|
|
1358
|
-
symbol:
|
|
1268
|
+
step: (e, i) => {
|
|
1269
|
+
O.message(e, {
|
|
1270
|
+
...i,
|
|
1271
|
+
symbol: styleText("green", F)
|
|
1359
1272
|
});
|
|
1360
1273
|
},
|
|
1361
|
-
warn: (
|
|
1362
|
-
|
|
1363
|
-
...
|
|
1364
|
-
symbol:
|
|
1274
|
+
warn: (e, i) => {
|
|
1275
|
+
O.message(e, {
|
|
1276
|
+
...i,
|
|
1277
|
+
symbol: styleText("yellow", me)
|
|
1365
1278
|
});
|
|
1366
1279
|
},
|
|
1367
|
-
warning: (
|
|
1368
|
-
|
|
1280
|
+
warning: (e, i) => {
|
|
1281
|
+
O.warn(e, i);
|
|
1369
1282
|
},
|
|
1370
|
-
error: (
|
|
1371
|
-
|
|
1372
|
-
...
|
|
1373
|
-
symbol:
|
|
1283
|
+
error: (e, i) => {
|
|
1284
|
+
O.message(e, {
|
|
1285
|
+
...i,
|
|
1286
|
+
symbol: styleText("red", ge)
|
|
1374
1287
|
});
|
|
1375
1288
|
}
|
|
1376
|
-
},
|
|
1377
|
-
|
|
1289
|
+
}, pt = (e = "", i) => {
|
|
1290
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${styleText("gray", E)} ` : "";
|
|
1291
|
+
s.write(`${r}${styleText("red", e)}
|
|
1378
1292
|
|
|
1379
1293
|
`);
|
|
1380
|
-
},
|
|
1381
|
-
|
|
1294
|
+
}, mt = (e = "", i) => {
|
|
1295
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${styleText("gray", le)} ` : "";
|
|
1296
|
+
s.write(`${r}${e}
|
|
1382
1297
|
`);
|
|
1383
|
-
},
|
|
1384
|
-
|
|
1385
|
-
${
|
|
1298
|
+
}, gt = (e = "", i) => {
|
|
1299
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${styleText("gray", d)}
|
|
1300
|
+
${styleText("gray", E)} ` : "";
|
|
1301
|
+
s.write(`${r}${e}
|
|
1386
1302
|
|
|
1387
1303
|
`);
|
|
1388
|
-
},
|
|
1389
|
-
`).map((s) =>
|
|
1390
|
-
`),
|
|
1391
|
-
const
|
|
1392
|
-
const
|
|
1393
|
-
return
|
|
1394
|
-
}, s =
|
|
1395
|
-
return new
|
|
1396
|
-
options:
|
|
1397
|
-
signal:
|
|
1398
|
-
input:
|
|
1399
|
-
output:
|
|
1400
|
-
initialValues:
|
|
1304
|
+
}, Q = (e, i) => e.split(`
|
|
1305
|
+
`).map((s) => i(s)).join(`
|
|
1306
|
+
`), yt = (e) => {
|
|
1307
|
+
const i = (r, u) => {
|
|
1308
|
+
const n = r.label ?? String(r.value);
|
|
1309
|
+
return u === "disabled" ? `${styleText("gray", J)} ${Q(n, (o) => styleText(["strikethrough", "gray"], o))}${r.hint ? ` ${styleText("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${styleText("cyan", te)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "selected" ? `${styleText("green", U)} ${Q(n, (o) => styleText("dim", o))}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "cancelled" ? `${Q(n, (o) => styleText(["strikethrough", "dim"], o))}` : u === "active-selected" ? `${styleText("green", U)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : u === "submitted" ? `${Q(n, (o) => styleText("dim", o))}` : `${styleText("dim", J)} ${Q(n, (o) => styleText("dim", o))}`;
|
|
1310
|
+
}, s = e.required ?? !0;
|
|
1311
|
+
return new it$1({
|
|
1312
|
+
options: e.options,
|
|
1313
|
+
signal: e.signal,
|
|
1314
|
+
input: e.input,
|
|
1315
|
+
output: e.output,
|
|
1316
|
+
initialValues: e.initialValues,
|
|
1401
1317
|
required: s,
|
|
1402
|
-
cursorAt:
|
|
1403
|
-
validate(
|
|
1404
|
-
if (s && (
|
|
1405
|
-
${
|
|
1318
|
+
cursorAt: e.cursorAt,
|
|
1319
|
+
validate(r) {
|
|
1320
|
+
if (s && (r === void 0 || r.length === 0)) return `Please select at least one option.
|
|
1321
|
+
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1322
|
+
"gray",
|
|
1323
|
+
"bgWhite",
|
|
1324
|
+
"inverse"
|
|
1325
|
+
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
1406
1326
|
},
|
|
1407
1327
|
render() {
|
|
1408
|
-
const
|
|
1409
|
-
${
|
|
1410
|
-
`, o = this.value ?? [],
|
|
1411
|
-
if (
|
|
1412
|
-
const
|
|
1413
|
-
return
|
|
1328
|
+
const r = e.withGuide ?? u.withGuide, u$8 = R(e.output, e.message, r ? `${ye(this.state)} ` : "", `${V(this.state)} `), n = `${r ? `${styleText("gray", d)}
|
|
1329
|
+
` : ""}${u$8}
|
|
1330
|
+
`, o = this.value ?? [], c = (a, l) => {
|
|
1331
|
+
if (a.disabled) return i(a, "disabled");
|
|
1332
|
+
const $ = o.includes(a.value);
|
|
1333
|
+
return l && $ ? i(a, "active-selected") : $ ? i(a, "selected") : i(a, l ? "active" : "inactive");
|
|
1414
1334
|
};
|
|
1415
1335
|
switch (this.state) {
|
|
1416
1336
|
case "submit": {
|
|
1417
|
-
const
|
|
1418
|
-
return `${
|
|
1337
|
+
const a = this.options.filter(({ value: $ }) => o.includes($)).map(($) => i($, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
|
|
1338
|
+
return `${n}${R(e.output, a, r ? `${styleText("gray", d)} ` : "")}`;
|
|
1419
1339
|
}
|
|
1420
1340
|
case "cancel": {
|
|
1421
|
-
const
|
|
1422
|
-
if (
|
|
1423
|
-
return `${
|
|
1424
|
-
${
|
|
1341
|
+
const a = this.options.filter(({ value: $ }) => o.includes($)).map(($) => i($, "cancelled")).join(styleText("dim", ", "));
|
|
1342
|
+
if (a.trim() === "") return `${n}${styleText("gray", d)}`;
|
|
1343
|
+
return `${n}${R(e.output, a, r ? `${styleText("gray", d)} ` : "")}${r ? `
|
|
1344
|
+
${styleText("gray", d)}` : ""}`;
|
|
1425
1345
|
}
|
|
1426
1346
|
case "error": {
|
|
1427
|
-
const
|
|
1428
|
-
`).map((
|
|
1429
|
-
`),
|
|
1430
|
-
`).length,
|
|
1347
|
+
const a = r ? `${styleText("yellow", d)} ` : "", l = this.error.split(`
|
|
1348
|
+
`).map((p, m) => m === 0 ? `${r ? `${styleText("yellow", E)} ` : ""}${styleText("yellow", p)}` : ` ${p}`).join(`
|
|
1349
|
+
`), $ = n.split(`
|
|
1350
|
+
`).length, y = l.split(`
|
|
1431
1351
|
`).length + 1;
|
|
1432
|
-
return `${
|
|
1433
|
-
output:
|
|
1352
|
+
return `${n}${a}${Y({
|
|
1353
|
+
output: e.output,
|
|
1434
1354
|
options: this.options,
|
|
1435
1355
|
cursor: this.cursor,
|
|
1436
|
-
maxItems:
|
|
1437
|
-
columnPadding:
|
|
1438
|
-
rowPadding:
|
|
1439
|
-
style:
|
|
1356
|
+
maxItems: e.maxItems,
|
|
1357
|
+
columnPadding: a.length,
|
|
1358
|
+
rowPadding: $ + y,
|
|
1359
|
+
style: c
|
|
1440
1360
|
}).join(`
|
|
1441
|
-
${
|
|
1442
|
-
${
|
|
1361
|
+
${a}`)}
|
|
1362
|
+
${l}
|
|
1443
1363
|
`;
|
|
1444
1364
|
}
|
|
1445
1365
|
default: {
|
|
1446
|
-
const
|
|
1447
|
-
`).length;
|
|
1448
|
-
return `${
|
|
1449
|
-
output:
|
|
1366
|
+
const a = r ? `${styleText("cyan", d)} ` : "", l = n.split(`
|
|
1367
|
+
`).length, $ = r ? 2 : 1;
|
|
1368
|
+
return `${n}${a}${Y({
|
|
1369
|
+
output: e.output,
|
|
1450
1370
|
options: this.options,
|
|
1451
1371
|
cursor: this.cursor,
|
|
1452
|
-
maxItems:
|
|
1453
|
-
columnPadding:
|
|
1454
|
-
rowPadding:
|
|
1455
|
-
style:
|
|
1372
|
+
maxItems: e.maxItems,
|
|
1373
|
+
columnPadding: a.length,
|
|
1374
|
+
rowPadding: l + $,
|
|
1375
|
+
style: c
|
|
1456
1376
|
}).join(`
|
|
1457
|
-
${
|
|
1458
|
-
${
|
|
1377
|
+
${a}`)}
|
|
1378
|
+
${r ? styleText("cyan", E) : ""}
|
|
1459
1379
|
`;
|
|
1460
1380
|
}
|
|
1461
1381
|
}
|
|
1462
1382
|
}
|
|
1463
1383
|
}).prompt();
|
|
1464
|
-
},
|
|
1465
|
-
const
|
|
1384
|
+
}, ft = (e) => styleText("dim", e), vt = (e, i, s) => {
|
|
1385
|
+
const r = {
|
|
1466
1386
|
hard: !0,
|
|
1467
1387
|
trim: !1
|
|
1468
|
-
},
|
|
1469
|
-
`),
|
|
1470
|
-
return
|
|
1471
|
-
},
|
|
1472
|
-
const
|
|
1388
|
+
}, u = wrapAnsi(e, i, r).split(`
|
|
1389
|
+
`), n = u.reduce((a, l) => Math.max(fastStringWidth(l), a), 0);
|
|
1390
|
+
return wrapAnsi(e, i - (u.map(s).reduce((a, l) => Math.max(fastStringWidth(l), a), 0) - n), r);
|
|
1391
|
+
}, wt = (e = "", i = "", s) => {
|
|
1392
|
+
const r = s?.output ?? P.stdout, u$9 = s?.withGuide ?? u.withGuide, n = s?.format ?? ft, o = [
|
|
1473
1393
|
"",
|
|
1474
|
-
...
|
|
1475
|
-
`).map(
|
|
1394
|
+
...vt(e, O$1(r) - 6, n).split(`
|
|
1395
|
+
`).map(n),
|
|
1476
1396
|
""
|
|
1477
|
-
],
|
|
1478
|
-
const
|
|
1479
|
-
return
|
|
1480
|
-
}, 0),
|
|
1481
|
-
`),
|
|
1482
|
-
` : "",
|
|
1483
|
-
|
|
1484
|
-
${
|
|
1485
|
-
${
|
|
1397
|
+
], c = fastStringWidth(i), a = Math.max(o.reduce((p, m) => {
|
|
1398
|
+
const g = fastStringWidth(m);
|
|
1399
|
+
return g > p ? g : p;
|
|
1400
|
+
}, 0), c) + 2, l = o.map((p) => `${styleText("gray", d)} ${p}${" ".repeat(a - fastStringWidth(p))}${styleText("gray", d)}`).join(`
|
|
1401
|
+
`), $ = u$9 ? `${styleText("gray", d)}
|
|
1402
|
+
` : "", y = u$9 ? Ge : de;
|
|
1403
|
+
r.write(`${$}${styleText("green", F)} ${styleText("reset", i)} ${styleText("gray", se.repeat(Math.max(a - c - 1, 1)) + ce)}
|
|
1404
|
+
${l}
|
|
1405
|
+
${styleText("gray", y + se.repeat(a + 2) + $e)}
|
|
1486
1406
|
`);
|
|
1487
|
-
},
|
|
1488
|
-
validate:
|
|
1489
|
-
mask:
|
|
1490
|
-
signal:
|
|
1491
|
-
input:
|
|
1492
|
-
output:
|
|
1407
|
+
}, bt = (e) => new rt$1({
|
|
1408
|
+
validate: e.validate,
|
|
1409
|
+
mask: e.mask ?? xe,
|
|
1410
|
+
signal: e.signal,
|
|
1411
|
+
input: e.input,
|
|
1412
|
+
output: e.output,
|
|
1493
1413
|
render() {
|
|
1494
|
-
const
|
|
1495
|
-
` : ""}${
|
|
1496
|
-
`,
|
|
1414
|
+
const i = e.withGuide ?? u.withGuide, s = `${i ? `${styleText("gray", d)}
|
|
1415
|
+
` : ""}${V(this.state)} ${e.message}
|
|
1416
|
+
`, r = this.userInputWithCursor, u$10 = this.masked;
|
|
1497
1417
|
switch (this.state) {
|
|
1498
1418
|
case "error": {
|
|
1499
|
-
const
|
|
1500
|
-
return
|
|
1501
|
-
${
|
|
1502
|
-
${
|
|
1419
|
+
const n = i ? `${styleText("yellow", d)} ` : "", o = i ? `${styleText("yellow", E)} ` : "", c = u$10 ?? "";
|
|
1420
|
+
return e.clearOnError && this.clear(), `${s.trim()}
|
|
1421
|
+
${n}${c}
|
|
1422
|
+
${o}${styleText("yellow", this.error)}
|
|
1503
1423
|
`;
|
|
1504
1424
|
}
|
|
1505
|
-
case "submit": return `${s}${
|
|
1506
|
-
case "cancel": return `${s}${
|
|
1507
|
-
${
|
|
1508
|
-
default: return `${s}${
|
|
1509
|
-
${
|
|
1425
|
+
case "submit": return `${s}${i ? `${styleText("gray", d)} ` : ""}${u$10 ? styleText("dim", u$10) : ""}`;
|
|
1426
|
+
case "cancel": return `${s}${i ? `${styleText("gray", d)} ` : ""}${u$10 ? styleText(["strikethrough", "dim"], u$10) : ""}${u$10 && i ? `
|
|
1427
|
+
${styleText("gray", d)}` : ""}`;
|
|
1428
|
+
default: return `${s}${i ? `${styleText("cyan", d)} ` : ""}${r}
|
|
1429
|
+
${i ? styleText("cyan", E) : ""}
|
|
1510
1430
|
`;
|
|
1511
1431
|
}
|
|
1512
1432
|
}
|
|
1513
|
-
}).prompt(),
|
|
1514
|
-
const
|
|
1515
|
-
return
|
|
1516
|
-
...
|
|
1517
|
-
initialUserInput:
|
|
1433
|
+
}).prompt(), St = (e) => {
|
|
1434
|
+
const i = e.validate;
|
|
1435
|
+
return Ae({
|
|
1436
|
+
...e,
|
|
1437
|
+
initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
|
|
1518
1438
|
maxItems: 5,
|
|
1519
1439
|
validate(s) {
|
|
1520
1440
|
if (!Array.isArray(s)) {
|
|
1521
1441
|
if (!s) return "Please select a path";
|
|
1522
|
-
if (
|
|
1442
|
+
if (i) return i(s);
|
|
1523
1443
|
}
|
|
1524
1444
|
},
|
|
1525
1445
|
options() {
|
|
1526
1446
|
const s = this.userInput;
|
|
1527
1447
|
if (s === "") return [];
|
|
1528
1448
|
try {
|
|
1529
|
-
let
|
|
1530
|
-
|
|
1531
|
-
|
|
1449
|
+
let r;
|
|
1450
|
+
existsSync(s) ? lstatSync(s).isDirectory() && (!e.directory || s.endsWith("/")) ? r = s : r = dirname(s) : r = dirname(s);
|
|
1451
|
+
const u = s.length > 1 && s.endsWith("/") ? s.slice(0, -1) : s;
|
|
1452
|
+
return readdirSync(r).map((n) => {
|
|
1453
|
+
const o = join(r, n);
|
|
1532
1454
|
return {
|
|
1533
|
-
name:
|
|
1455
|
+
name: n,
|
|
1534
1456
|
path: o,
|
|
1535
1457
|
isDirectory: lstatSync(o).isDirectory()
|
|
1536
1458
|
};
|
|
1537
|
-
}).filter(({ path:
|
|
1459
|
+
}).filter(({ path: n, isDirectory: o }) => n.startsWith(u) && (o || !e.directory)).map((n) => ({ value: n.path }));
|
|
1538
1460
|
} catch {
|
|
1539
1461
|
return [];
|
|
1540
1462
|
}
|
|
1541
1463
|
}
|
|
1542
1464
|
});
|
|
1543
|
-
},
|
|
1465
|
+
}, Ct = (e) => styleText("magenta", e), fe = ({ indicator: e = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u$11, frames: n = ee ? [
|
|
1544
1466
|
"◒",
|
|
1545
1467
|
"◐",
|
|
1546
1468
|
"◓",
|
|
@@ -1550,353 +1472,427 @@ ${r ? import_picocolors.default.cyan(x) : ""}
|
|
|
1550
1472
|
"o",
|
|
1551
1473
|
"O",
|
|
1552
1474
|
"0"
|
|
1553
|
-
], delay:
|
|
1554
|
-
const
|
|
1555
|
-
let
|
|
1556
|
-
const
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1559
|
-
},
|
|
1560
|
-
process.on("uncaughtExceptionMonitor",
|
|
1561
|
-
},
|
|
1562
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1563
|
-
},
|
|
1564
|
-
if (
|
|
1565
|
-
|
|
1475
|
+
], delay: o = ee ? 80 : 120, signal: c, ...a } = {}) => {
|
|
1476
|
+
const l = ae();
|
|
1477
|
+
let $, y, p = !1, m = !1, g = "", S, h = performance.now();
|
|
1478
|
+
const f = O$1(s), v = a?.styleFrame ?? Ct, T = (_) => {
|
|
1479
|
+
const A = _ > 1 ? u$11 ?? u.messages.error : r ?? u.messages.cancel;
|
|
1480
|
+
m = _ === 1, p && (W(A, _), m && typeof i == "function" && i());
|
|
1481
|
+
}, C = () => T(2), b = () => T(1), x = () => {
|
|
1482
|
+
process.on("uncaughtExceptionMonitor", C), process.on("unhandledRejection", C), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", T), c && c.addEventListener("abort", b);
|
|
1483
|
+
}, G = () => {
|
|
1484
|
+
process.removeListener("uncaughtExceptionMonitor", C), process.removeListener("unhandledRejection", C), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", T), c && c.removeEventListener("abort", b);
|
|
1485
|
+
}, M = () => {
|
|
1486
|
+
if (S === void 0) return;
|
|
1487
|
+
l && s.write(`
|
|
1566
1488
|
`);
|
|
1567
|
-
const
|
|
1489
|
+
const _ = wrapAnsi(S, f, {
|
|
1568
1490
|
hard: !0,
|
|
1569
1491
|
trim: !1
|
|
1570
1492
|
}).split(`
|
|
1571
1493
|
`);
|
|
1572
|
-
|
|
1573
|
-
},
|
|
1574
|
-
const
|
|
1575
|
-
return
|
|
1576
|
-
},
|
|
1577
|
-
p = !0,
|
|
1494
|
+
_.length > 1 && s.write(import_src.cursor.up(_.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
|
|
1495
|
+
}, R = (_) => _.replace(/\.+$/, ""), j = (_) => {
|
|
1496
|
+
const A = (performance.now() - _) / 1e3, k = Math.floor(A / 60), L = Math.floor(A % 60);
|
|
1497
|
+
return k > 0 ? `[${k}m ${L}s]` : `[${L}s]`;
|
|
1498
|
+
}, D = a.withGuide ?? u.withGuide, ie = (_ = "") => {
|
|
1499
|
+
p = !0, $ = z$1({ output: s }), g = R(_), h = performance.now(), D && s.write(`${styleText("gray", d)}
|
|
1578
1500
|
`);
|
|
1579
|
-
let
|
|
1580
|
-
|
|
1581
|
-
if (
|
|
1582
|
-
|
|
1583
|
-
const
|
|
1584
|
-
let
|
|
1585
|
-
if (
|
|
1586
|
-
else if (
|
|
1501
|
+
let A = 0, k = 0;
|
|
1502
|
+
x(), y = setInterval(() => {
|
|
1503
|
+
if (l && g === S) return;
|
|
1504
|
+
M(), S = g;
|
|
1505
|
+
const L = v(n[A]);
|
|
1506
|
+
let Z;
|
|
1507
|
+
if (l) Z = `${L} ${g}...`;
|
|
1508
|
+
else if (e === "timer") Z = `${L} ${g} ${j(h)}`;
|
|
1587
1509
|
else {
|
|
1588
|
-
const
|
|
1589
|
-
|
|
1510
|
+
const Be = ".".repeat(Math.floor(k)).slice(0, 3);
|
|
1511
|
+
Z = `${L} ${g}${Be}`;
|
|
1590
1512
|
}
|
|
1591
|
-
const
|
|
1513
|
+
const Ne = wrapAnsi(Z, f, {
|
|
1592
1514
|
hard: !0,
|
|
1593
1515
|
trim: !1
|
|
1594
1516
|
});
|
|
1595
|
-
s.write(
|
|
1596
|
-
},
|
|
1597
|
-
},
|
|
1517
|
+
s.write(Ne), A = A + 1 < n.length ? A + 1 : 0, k = k < 4 ? k + .125 : 0;
|
|
1518
|
+
}, o);
|
|
1519
|
+
}, W = (_ = "", A = 0, k = !1) => {
|
|
1598
1520
|
if (!p) return;
|
|
1599
|
-
p = !1, clearInterval(
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
`) : s.write(`${
|
|
1603
|
-
`)),
|
|
1521
|
+
p = !1, clearInterval(y), M();
|
|
1522
|
+
const L = A === 0 ? styleText("green", F) : A === 1 ? styleText("red", oe) : styleText("red", ue);
|
|
1523
|
+
g = _ ?? g, k || (e === "timer" ? s.write(`${L} ${g} ${j(h)}
|
|
1524
|
+
`) : s.write(`${L} ${g}
|
|
1525
|
+
`)), G(), $();
|
|
1604
1526
|
};
|
|
1605
1527
|
return {
|
|
1606
|
-
start:
|
|
1607
|
-
stop: (
|
|
1608
|
-
message: (
|
|
1609
|
-
|
|
1528
|
+
start: ie,
|
|
1529
|
+
stop: (_ = "") => W(_, 0),
|
|
1530
|
+
message: (_ = "") => {
|
|
1531
|
+
g = R(_ ?? g);
|
|
1610
1532
|
},
|
|
1611
|
-
cancel: (
|
|
1612
|
-
error: (
|
|
1613
|
-
clear: () =>
|
|
1533
|
+
cancel: (_ = "") => W(_, 1),
|
|
1534
|
+
error: (_ = "") => W(_, 2),
|
|
1535
|
+
clear: () => W("", 0, !0),
|
|
1614
1536
|
get isCancelled() {
|
|
1615
|
-
return
|
|
1537
|
+
return m;
|
|
1616
1538
|
}
|
|
1617
1539
|
};
|
|
1618
|
-
},
|
|
1619
|
-
light:
|
|
1620
|
-
heavy:
|
|
1621
|
-
block:
|
|
1540
|
+
}, Ve = {
|
|
1541
|
+
light: w("─", "-"),
|
|
1542
|
+
heavy: w("━", "="),
|
|
1543
|
+
block: w("█", "#")
|
|
1622
1544
|
};
|
|
1623
|
-
const
|
|
1624
|
-
`) ?
|
|
1625
|
-
`).map((s) =>
|
|
1626
|
-
`) :
|
|
1627
|
-
const
|
|
1628
|
-
const
|
|
1629
|
-
switch (
|
|
1630
|
-
case "disabled": return `${
|
|
1631
|
-
case "selected": return `${
|
|
1632
|
-
case "active": return `${
|
|
1633
|
-
case "cancelled": return `${
|
|
1634
|
-
default: return `${
|
|
1545
|
+
const re = (e, i) => e.includes(`
|
|
1546
|
+
`) ? e.split(`
|
|
1547
|
+
`).map((s) => i(s)).join(`
|
|
1548
|
+
`) : i(e), _t = (e) => {
|
|
1549
|
+
const i = (s, r) => {
|
|
1550
|
+
const u = s.label ?? String(s.value);
|
|
1551
|
+
switch (r) {
|
|
1552
|
+
case "disabled": return `${styleText("gray", H)} ${re(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1553
|
+
case "selected": return `${re(u, (n) => styleText("dim", n))}`;
|
|
1554
|
+
case "active": return `${styleText("green", z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
|
|
1555
|
+
case "cancelled": return `${re(u, (n) => styleText(["strikethrough", "dim"], n))}`;
|
|
1556
|
+
default: return `${styleText("dim", H)} ${re(u, (n) => styleText("dim", n))}`;
|
|
1635
1557
|
}
|
|
1636
1558
|
};
|
|
1637
|
-
return new
|
|
1638
|
-
options:
|
|
1639
|
-
signal:
|
|
1640
|
-
input:
|
|
1641
|
-
output:
|
|
1642
|
-
initialValue:
|
|
1559
|
+
return new nt({
|
|
1560
|
+
options: e.options,
|
|
1561
|
+
signal: e.signal,
|
|
1562
|
+
input: e.input,
|
|
1563
|
+
output: e.output,
|
|
1564
|
+
initialValue: e.initialValue,
|
|
1643
1565
|
render() {
|
|
1644
|
-
const s =
|
|
1645
|
-
` : ""}${
|
|
1566
|
+
const s = e.withGuide ?? u.withGuide, r = `${V(this.state)} `, u$12 = `${ye(this.state)} `, n = R(e.output, e.message, u$12, r), o = `${s ? `${styleText("gray", d)}
|
|
1567
|
+
` : ""}${n}
|
|
1646
1568
|
`;
|
|
1647
1569
|
switch (this.state) {
|
|
1648
1570
|
case "submit": {
|
|
1649
|
-
const
|
|
1650
|
-
return `${
|
|
1571
|
+
const c = s ? `${styleText("gray", d)} ` : "";
|
|
1572
|
+
return `${o}${R(e.output, i(this.options[this.cursor], "selected"), c)}`;
|
|
1651
1573
|
}
|
|
1652
1574
|
case "cancel": {
|
|
1653
|
-
const
|
|
1654
|
-
return `${
|
|
1655
|
-
${
|
|
1575
|
+
const c = s ? `${styleText("gray", d)} ` : "";
|
|
1576
|
+
return `${o}${R(e.output, i(this.options[this.cursor], "cancelled"), c)}${s ? `
|
|
1577
|
+
${styleText("gray", d)}` : ""}`;
|
|
1656
1578
|
}
|
|
1657
1579
|
default: {
|
|
1658
|
-
const
|
|
1659
|
-
`).length,
|
|
1660
|
-
return `${
|
|
1661
|
-
output:
|
|
1580
|
+
const c = s ? `${styleText("cyan", d)} ` : "", a = s ? styleText("cyan", E) : "", l = o.split(`
|
|
1581
|
+
`).length, $ = s ? 2 : 1;
|
|
1582
|
+
return `${o}${c}${Y({
|
|
1583
|
+
output: e.output,
|
|
1662
1584
|
cursor: this.cursor,
|
|
1663
1585
|
options: this.options,
|
|
1664
|
-
maxItems:
|
|
1665
|
-
columnPadding:
|
|
1666
|
-
rowPadding:
|
|
1667
|
-
style: (
|
|
1586
|
+
maxItems: e.maxItems,
|
|
1587
|
+
columnPadding: c.length,
|
|
1588
|
+
rowPadding: l + $,
|
|
1589
|
+
style: (y, p) => i(y, y.disabled ? "disabled" : p ? "active" : "inactive")
|
|
1668
1590
|
}).join(`
|
|
1669
|
-
${
|
|
1670
|
-
${
|
|
1591
|
+
${c}`)}
|
|
1592
|
+
${a}
|
|
1671
1593
|
`;
|
|
1672
1594
|
}
|
|
1673
1595
|
}
|
|
1674
1596
|
}
|
|
1675
1597
|
}).prompt();
|
|
1676
|
-
},
|
|
1677
|
-
const
|
|
1678
|
-
const
|
|
1679
|
-
return
|
|
1598
|
+
}, It = (e) => {
|
|
1599
|
+
const i = (s, r = "inactive") => {
|
|
1600
|
+
const u = s.label ?? String(s.value);
|
|
1601
|
+
return r === "selected" ? `${styleText("dim", u)}` : r === "cancelled" ? `${styleText(["strikethrough", "dim"], u)}` : r === "active" ? `${styleText(["bgCyan", "gray"], ` ${s.value} `)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}` : `${styleText([
|
|
1602
|
+
"gray",
|
|
1603
|
+
"bgWhite",
|
|
1604
|
+
"inverse"
|
|
1605
|
+
], ` ${s.value} `)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
|
|
1680
1606
|
};
|
|
1681
|
-
return new
|
|
1682
|
-
options:
|
|
1683
|
-
signal:
|
|
1684
|
-
input:
|
|
1685
|
-
output:
|
|
1686
|
-
initialValue:
|
|
1687
|
-
caseSensitive:
|
|
1607
|
+
return new ot({
|
|
1608
|
+
options: e.options,
|
|
1609
|
+
signal: e.signal,
|
|
1610
|
+
input: e.input,
|
|
1611
|
+
output: e.output,
|
|
1612
|
+
initialValue: e.initialValue,
|
|
1613
|
+
caseSensitive: e.caseSensitive,
|
|
1688
1614
|
render() {
|
|
1689
|
-
const s =
|
|
1690
|
-
` : ""}${
|
|
1615
|
+
const s = e.withGuide ?? u.withGuide, r = `${s ? `${styleText("gray", d)}
|
|
1616
|
+
` : ""}${V(this.state)} ${e.message}
|
|
1691
1617
|
`;
|
|
1692
1618
|
switch (this.state) {
|
|
1693
1619
|
case "submit": {
|
|
1694
|
-
const
|
|
1695
|
-
return `${
|
|
1620
|
+
const u = s ? `${styleText("gray", d)} ` : "", n = this.options.find((c) => c.value === this.value) ?? e.options[0];
|
|
1621
|
+
return `${r}${R(e.output, i(n, "selected"), u)}`;
|
|
1696
1622
|
}
|
|
1697
1623
|
case "cancel": {
|
|
1698
|
-
const
|
|
1699
|
-
return `${
|
|
1700
|
-
${
|
|
1624
|
+
const u = s ? `${styleText("gray", d)} ` : "";
|
|
1625
|
+
return `${r}${R(e.output, i(this.options[0], "cancelled"), u)}${s ? `
|
|
1626
|
+
${styleText("gray", d)}` : ""}`;
|
|
1701
1627
|
}
|
|
1702
1628
|
default: {
|
|
1703
|
-
const
|
|
1704
|
-
return `${
|
|
1629
|
+
const u = s ? `${styleText("cyan", d)} ` : "", n = s ? styleText("cyan", E) : "";
|
|
1630
|
+
return `${r}${this.options.map((c, a) => R(e.output, i(c, a === this.cursor ? "active" : "inactive"), u)).join(`
|
|
1705
1631
|
`)}
|
|
1706
|
-
${
|
|
1632
|
+
${n}
|
|
1707
1633
|
`;
|
|
1708
1634
|
}
|
|
1709
1635
|
}
|
|
1710
1636
|
}
|
|
1711
1637
|
}).prompt();
|
|
1712
|
-
},
|
|
1713
|
-
message: async (
|
|
1714
|
-
process.stdout.write(`${
|
|
1715
|
-
${
|
|
1638
|
+
}, je = `${styleText("gray", d)} `, K = {
|
|
1639
|
+
message: async (e, { symbol: i = styleText("gray", d) } = {}) => {
|
|
1640
|
+
process.stdout.write(`${styleText("gray", d)}
|
|
1641
|
+
${i} `);
|
|
1716
1642
|
let s = 3;
|
|
1717
|
-
for await (let
|
|
1718
|
-
|
|
1719
|
-
${
|
|
1720
|
-
`) && (s = 3 + stripVTControlCharacters(
|
|
1643
|
+
for await (let r of e) {
|
|
1644
|
+
r = r.replace(/\n/g, `
|
|
1645
|
+
${je}`), r.includes(`
|
|
1646
|
+
`) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
|
|
1721
1647
|
`))).length);
|
|
1722
|
-
const
|
|
1723
|
-
s +
|
|
1724
|
-
${
|
|
1648
|
+
const u = stripVTControlCharacters(r).length;
|
|
1649
|
+
s + u < process.stdout.columns ? (s += u, process.stdout.write(r)) : (process.stdout.write(`
|
|
1650
|
+
${je}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
|
|
1725
1651
|
}
|
|
1726
1652
|
process.stdout.write(`
|
|
1727
1653
|
`);
|
|
1728
1654
|
},
|
|
1729
|
-
info: (
|
|
1730
|
-
success: (
|
|
1731
|
-
step: (
|
|
1732
|
-
warn: (
|
|
1733
|
-
warning: (
|
|
1734
|
-
error: (
|
|
1735
|
-
},
|
|
1736
|
-
for (const s of
|
|
1655
|
+
info: (e) => K.message(e, { symbol: styleText("blue", he) }),
|
|
1656
|
+
success: (e) => K.message(e, { symbol: styleText("green", pe) }),
|
|
1657
|
+
step: (e) => K.message(e, { symbol: styleText("green", F) }),
|
|
1658
|
+
warn: (e) => K.message(e, { symbol: styleText("yellow", me) }),
|
|
1659
|
+
warning: (e) => K.warn(e),
|
|
1660
|
+
error: (e) => K.message(e, { symbol: styleText("red", ge) })
|
|
1661
|
+
}, Et = async (e, i) => {
|
|
1662
|
+
for (const s of e) {
|
|
1737
1663
|
if (s.enabled === !1) continue;
|
|
1738
|
-
const
|
|
1739
|
-
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1742
|
-
}
|
|
1743
|
-
},
|
|
1744
|
-
const
|
|
1745
|
-
|
|
1746
|
-
`),
|
|
1664
|
+
const r = fe(i);
|
|
1665
|
+
r.start(s.title);
|
|
1666
|
+
const u = await s.task(r.message);
|
|
1667
|
+
r.stop(u || s.title);
|
|
1668
|
+
}
|
|
1669
|
+
}, xt = (e) => e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Gt = (e) => {
|
|
1670
|
+
const i = e.output ?? process.stdout, s = O$1(i), r = styleText("gray", d), u = e.spacing ?? 1, n = 3, o = e.retainLog === !0, c = !ae() && Te(i);
|
|
1671
|
+
i.write(`${r}
|
|
1672
|
+
`), i.write(`${styleText("green", F)} ${e.title}
|
|
1747
1673
|
`);
|
|
1748
|
-
for (let h = 0; h <
|
|
1674
|
+
for (let h = 0; h < u; h++) i.write(`${r}
|
|
1749
1675
|
`);
|
|
1750
|
-
const
|
|
1676
|
+
const a = [{
|
|
1751
1677
|
value: "",
|
|
1752
1678
|
full: ""
|
|
1753
1679
|
}];
|
|
1754
|
-
let
|
|
1755
|
-
const
|
|
1756
|
-
if (
|
|
1757
|
-
let
|
|
1758
|
-
h && (
|
|
1759
|
-
for (const
|
|
1760
|
-
const { value:
|
|
1761
|
-
let
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1764
|
-
${
|
|
1765
|
-
const
|
|
1766
|
-
`).reduce((
|
|
1767
|
-
|
|
1680
|
+
let l = !1;
|
|
1681
|
+
const $ = (h) => {
|
|
1682
|
+
if (a.length === 0) return;
|
|
1683
|
+
let f = 0;
|
|
1684
|
+
h && (f += u + 2);
|
|
1685
|
+
for (const v of a) {
|
|
1686
|
+
const { value: T, result: C } = v;
|
|
1687
|
+
let b = C?.message ?? T;
|
|
1688
|
+
if (b.length === 0) continue;
|
|
1689
|
+
C === void 0 && v.header !== void 0 && v.header !== "" && (b += `
|
|
1690
|
+
${v.header}`);
|
|
1691
|
+
const x = b.split(`
|
|
1692
|
+
`).reduce((G, M) => M === "" ? G + 1 : G + Math.ceil((M.length + n) / s), 0);
|
|
1693
|
+
f += x;
|
|
1768
1694
|
}
|
|
1769
|
-
|
|
1770
|
-
},
|
|
1771
|
-
const
|
|
1695
|
+
f > 0 && (f += 1, i.write(import_src.erase.lines(f)));
|
|
1696
|
+
}, y = (h, f, v) => {
|
|
1697
|
+
const T = v ? `${h.full}
|
|
1772
1698
|
${h.value}` : h.value;
|
|
1773
|
-
h.header !== void 0 && h.header !== "" &&
|
|
1774
|
-
`).map(
|
|
1775
|
-
output:
|
|
1776
|
-
secondarySymbol:
|
|
1777
|
-
symbol:
|
|
1699
|
+
h.header !== void 0 && h.header !== "" && O.message(h.header.split(`
|
|
1700
|
+
`).map((C) => styleText("bold", C)), {
|
|
1701
|
+
output: i,
|
|
1702
|
+
secondarySymbol: r,
|
|
1703
|
+
symbol: r,
|
|
1778
1704
|
spacing: 0
|
|
1779
|
-
}),
|
|
1780
|
-
`).map(
|
|
1781
|
-
output:
|
|
1782
|
-
secondarySymbol:
|
|
1783
|
-
symbol:
|
|
1784
|
-
spacing:
|
|
1705
|
+
}), O.message(T.split(`
|
|
1706
|
+
`).map((C) => styleText("dim", C)), {
|
|
1707
|
+
output: i,
|
|
1708
|
+
secondarySymbol: r,
|
|
1709
|
+
symbol: r,
|
|
1710
|
+
spacing: f ?? u
|
|
1785
1711
|
});
|
|
1786
1712
|
}, p = () => {
|
|
1787
|
-
for (const h of
|
|
1788
|
-
const { header:
|
|
1789
|
-
(
|
|
1713
|
+
for (const h of a) {
|
|
1714
|
+
const { header: f, value: v, full: T } = h;
|
|
1715
|
+
(f === void 0 || f.length === 0) && v.length === 0 || y(h, void 0, o === !0 && T.length > 0);
|
|
1790
1716
|
}
|
|
1791
|
-
},
|
|
1792
|
-
if (
|
|
1793
|
-
`), h.value +=
|
|
1794
|
-
const
|
|
1795
|
-
`),
|
|
1796
|
-
if (
|
|
1797
|
-
const
|
|
1798
|
-
|
|
1799
|
-
`) +
|
|
1717
|
+
}, m = (h, f, v) => {
|
|
1718
|
+
if ($(!1), (v?.raw !== !0 || !l) && h.value !== "" && (h.value += `
|
|
1719
|
+
`), h.value += xt(f), l = v?.raw === !0, e.limit !== void 0) {
|
|
1720
|
+
const T = h.value.split(`
|
|
1721
|
+
`), C = T.length - e.limit;
|
|
1722
|
+
if (C > 0) {
|
|
1723
|
+
const b = T.splice(0, C);
|
|
1724
|
+
o && (h.full += (h.full === "" ? "" : `
|
|
1725
|
+
`) + b.join(`
|
|
1800
1726
|
`));
|
|
1801
1727
|
}
|
|
1802
|
-
h.value =
|
|
1728
|
+
h.value = T.join(`
|
|
1803
1729
|
`);
|
|
1804
1730
|
}
|
|
1805
|
-
|
|
1806
|
-
},
|
|
1807
|
-
for (const h of
|
|
1808
|
-
output:
|
|
1809
|
-
secondarySymbol:
|
|
1731
|
+
c && g();
|
|
1732
|
+
}, g = () => {
|
|
1733
|
+
for (const h of a) h.result ? h.result.status === "error" ? O.error(h.result.message, {
|
|
1734
|
+
output: i,
|
|
1735
|
+
secondarySymbol: r,
|
|
1810
1736
|
spacing: 0
|
|
1811
|
-
}) :
|
|
1812
|
-
output:
|
|
1813
|
-
secondarySymbol:
|
|
1737
|
+
}) : O.success(h.result.message, {
|
|
1738
|
+
output: i,
|
|
1739
|
+
secondarySymbol: r,
|
|
1814
1740
|
spacing: 0
|
|
1815
|
-
}) : h.value !== "" &&
|
|
1816
|
-
},
|
|
1817
|
-
|
|
1741
|
+
}) : h.value !== "" && y(h, 0);
|
|
1742
|
+
}, S = (h, f) => {
|
|
1743
|
+
$(!1), h.result = f, c && g();
|
|
1818
1744
|
};
|
|
1819
1745
|
return {
|
|
1820
|
-
message(h,
|
|
1821
|
-
|
|
1746
|
+
message(h, f) {
|
|
1747
|
+
m(a[0], h, f);
|
|
1822
1748
|
},
|
|
1823
1749
|
group(h) {
|
|
1824
|
-
const
|
|
1750
|
+
const f = {
|
|
1825
1751
|
header: h,
|
|
1826
1752
|
value: "",
|
|
1827
1753
|
full: ""
|
|
1828
1754
|
};
|
|
1829
|
-
return
|
|
1830
|
-
message(
|
|
1831
|
-
|
|
1755
|
+
return a.push(f), {
|
|
1756
|
+
message(v, T) {
|
|
1757
|
+
m(f, v, T);
|
|
1832
1758
|
},
|
|
1833
|
-
error(
|
|
1834
|
-
|
|
1759
|
+
error(v) {
|
|
1760
|
+
S(f, {
|
|
1835
1761
|
status: "error",
|
|
1836
|
-
message:
|
|
1762
|
+
message: v
|
|
1837
1763
|
});
|
|
1838
1764
|
},
|
|
1839
|
-
success(
|
|
1840
|
-
|
|
1765
|
+
success(v) {
|
|
1766
|
+
S(f, {
|
|
1841
1767
|
status: "success",
|
|
1842
|
-
message:
|
|
1768
|
+
message: v
|
|
1843
1769
|
});
|
|
1844
1770
|
}
|
|
1845
1771
|
};
|
|
1846
1772
|
},
|
|
1847
|
-
error(h,
|
|
1848
|
-
|
|
1849
|
-
output:
|
|
1850
|
-
secondarySymbol:
|
|
1773
|
+
error(h, f) {
|
|
1774
|
+
$(!0), O.error(h, {
|
|
1775
|
+
output: i,
|
|
1776
|
+
secondarySymbol: r,
|
|
1851
1777
|
spacing: 1
|
|
1852
|
-
}),
|
|
1778
|
+
}), f?.showLog !== !1 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
1853
1779
|
},
|
|
1854
|
-
success(h,
|
|
1855
|
-
|
|
1856
|
-
output:
|
|
1857
|
-
secondarySymbol:
|
|
1780
|
+
success(h, f) {
|
|
1781
|
+
$(!0), O.success(h, {
|
|
1782
|
+
output: i,
|
|
1783
|
+
secondarySymbol: r,
|
|
1858
1784
|
spacing: 1
|
|
1859
|
-
}),
|
|
1785
|
+
}), f?.showLog === !0 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
1860
1786
|
}
|
|
1861
1787
|
};
|
|
1862
|
-
},
|
|
1863
|
-
validate:
|
|
1864
|
-
placeholder:
|
|
1865
|
-
defaultValue:
|
|
1866
|
-
initialValue:
|
|
1867
|
-
output:
|
|
1868
|
-
signal:
|
|
1869
|
-
input:
|
|
1788
|
+
}, Ot = (e) => new at({
|
|
1789
|
+
validate: e.validate,
|
|
1790
|
+
placeholder: e.placeholder,
|
|
1791
|
+
defaultValue: e.defaultValue,
|
|
1792
|
+
initialValue: e.initialValue,
|
|
1793
|
+
output: e.output,
|
|
1794
|
+
signal: e.signal,
|
|
1795
|
+
input: e.input,
|
|
1870
1796
|
render() {
|
|
1871
|
-
const
|
|
1872
|
-
` : ""}${
|
|
1873
|
-
`,
|
|
1797
|
+
const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${styleText("gray", d)}
|
|
1798
|
+
` : ""}${V(this.state)} `}${e.message}
|
|
1799
|
+
`, r = e.placeholder ? styleText("inverse", e.placeholder[0]) + styleText("dim", e.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u$13 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
1874
1800
|
switch (this.state) {
|
|
1875
1801
|
case "error": {
|
|
1876
|
-
const
|
|
1802
|
+
const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c = i ? `${styleText("yellow", d)} ` : "", a = i ? styleText("yellow", E) : "";
|
|
1877
1803
|
return `${s.trim()}
|
|
1878
|
-
${
|
|
1879
|
-
${
|
|
1804
|
+
${c}${u$13}
|
|
1805
|
+
${a}${o}
|
|
1880
1806
|
`;
|
|
1881
1807
|
}
|
|
1882
1808
|
case "submit": {
|
|
1883
|
-
const
|
|
1884
|
-
return `${s}${
|
|
1809
|
+
const o = n ? ` ${styleText("dim", n)}` : "";
|
|
1810
|
+
return `${s}${i ? styleText("gray", d) : ""}${o}`;
|
|
1885
1811
|
}
|
|
1886
1812
|
case "cancel": {
|
|
1887
|
-
const
|
|
1888
|
-
return `${s}${
|
|
1889
|
-
${
|
|
1813
|
+
const o = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c = i ? styleText("gray", d) : "";
|
|
1814
|
+
return `${s}${c}${o}${n.trim() ? `
|
|
1815
|
+
${c}` : ""}`;
|
|
1890
1816
|
}
|
|
1891
|
-
default: return `${s}${
|
|
1892
|
-
${
|
|
1817
|
+
default: return `${s}${i ? `${styleText("cyan", d)} ` : ""}${u$13}
|
|
1818
|
+
${i ? styleText("cyan", E) : ""}
|
|
1893
1819
|
`;
|
|
1894
1820
|
}
|
|
1895
1821
|
}
|
|
1896
1822
|
}).prompt();
|
|
1897
1823
|
|
|
1824
|
+
//#endregion
|
|
1825
|
+
//#region ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
1826
|
+
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1827
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
1828
|
+
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
1829
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
1830
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
1831
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
1832
|
+
};
|
|
1833
|
+
let replaceClose = (string, close, replace, index) => {
|
|
1834
|
+
let result = "", cursor = 0;
|
|
1835
|
+
do {
|
|
1836
|
+
result += string.substring(cursor, index) + replace;
|
|
1837
|
+
cursor = index + close.length;
|
|
1838
|
+
index = string.indexOf(close, cursor);
|
|
1839
|
+
} while (~index);
|
|
1840
|
+
return result + string.substring(cursor);
|
|
1841
|
+
};
|
|
1842
|
+
let createColors = (enabled = isColorSupported) => {
|
|
1843
|
+
let f = enabled ? formatter : () => String;
|
|
1844
|
+
return {
|
|
1845
|
+
isColorSupported: enabled,
|
|
1846
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
1847
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
1848
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
1849
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
1850
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
1851
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
1852
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
1853
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
1854
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
1855
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
1856
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
1857
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
1858
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
1859
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
1860
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
1861
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
1862
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
1863
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
1864
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
1865
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
1866
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
1867
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
1868
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
1869
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
1870
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
1871
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
1872
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
1873
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
1874
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
1875
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
1876
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
1877
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
1878
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
1879
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
1880
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
1881
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
1882
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
1883
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
1884
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
1885
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
1886
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
1887
|
+
};
|
|
1888
|
+
};
|
|
1889
|
+
module.exports = createColors();
|
|
1890
|
+
module.exports.createColors = createColors;
|
|
1891
|
+
}));
|
|
1892
|
+
|
|
1898
1893
|
//#endregion
|
|
1899
1894
|
//#region src/constants.ts
|
|
1895
|
+
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
1900
1896
|
const REPO_URL = "https://github.com/buiducnhat/agent-skills.git";
|
|
1901
1897
|
const REPO_BRANCH = "main";
|
|
1902
1898
|
const SUPPORTED_AGENTS = [
|
|
@@ -2156,7 +2152,7 @@ const RULES_MARKER_END = "<!-- END agent-skills rules -->";
|
|
|
2156
2152
|
//#endregion
|
|
2157
2153
|
//#region src/fetch.ts
|
|
2158
2154
|
async function fetchTemplates() {
|
|
2159
|
-
const s =
|
|
2155
|
+
const s = fe();
|
|
2160
2156
|
s.start("Downloading agent skills from GitHub...");
|
|
2161
2157
|
const tempDir = mkdtempSync(path.join(tmpdir(), "agent-skills-"));
|
|
2162
2158
|
try {
|
|
@@ -2270,27 +2266,47 @@ function parseArgs(argv) {
|
|
|
2270
2266
|
help: false,
|
|
2271
2267
|
version: false,
|
|
2272
2268
|
copy: false,
|
|
2273
|
-
global: false
|
|
2269
|
+
global: false,
|
|
2270
|
+
agents: [],
|
|
2271
|
+
agentErrors: []
|
|
2274
2272
|
};
|
|
2275
|
-
for (let i = 0; i < argv.length; i++)
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2273
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2274
|
+
const token = argv[i];
|
|
2275
|
+
switch (token) {
|
|
2276
|
+
case "--non-interactive":
|
|
2277
|
+
args.nonInteractive = true;
|
|
2278
|
+
break;
|
|
2279
|
+
case "--agent":
|
|
2280
|
+
case "-a": {
|
|
2281
|
+
let consumedValue = false;
|
|
2282
|
+
while (i + 1 < argv.length && !argv[i + 1].startsWith("-")) {
|
|
2283
|
+
const value = argv[++i];
|
|
2284
|
+
if (value.length === 0) {
|
|
2285
|
+
args.agentErrors.push(`Empty agent value provided for ${token}. Use ${token} <agent> with a non-empty value.`);
|
|
2286
|
+
continue;
|
|
2287
|
+
}
|
|
2288
|
+
args.agents.push(value);
|
|
2289
|
+
consumedValue = true;
|
|
2290
|
+
}
|
|
2291
|
+
if (!consumedValue) args.agentErrors.push(`Missing value after ${token}. Use ${token} <agent> and repeat the flag for multiple agents.`);
|
|
2292
|
+
break;
|
|
2293
|
+
}
|
|
2294
|
+
case "--help":
|
|
2295
|
+
case "-h":
|
|
2296
|
+
args.help = true;
|
|
2297
|
+
break;
|
|
2298
|
+
case "--version":
|
|
2299
|
+
case "-v":
|
|
2300
|
+
args.version = true;
|
|
2301
|
+
break;
|
|
2302
|
+
case "--copy":
|
|
2303
|
+
args.copy = true;
|
|
2304
|
+
break;
|
|
2305
|
+
case "--global":
|
|
2306
|
+
case "-g":
|
|
2307
|
+
args.global = true;
|
|
2308
|
+
break;
|
|
2309
|
+
}
|
|
2294
2310
|
}
|
|
2295
2311
|
return args;
|
|
2296
2312
|
}
|
|
@@ -2309,6 +2325,7 @@ function printHelp() {
|
|
|
2309
2325
|
Usage: npx @buiducnhat/agent-skills [options]
|
|
2310
2326
|
|
|
2311
2327
|
Options:
|
|
2328
|
+
-a, --agent <agents...> Target specific agents. Repeat for each agent.
|
|
2312
2329
|
--non-interactive Skip interactive prompts (installs all skills to all agents)
|
|
2313
2330
|
--copy Copy skill files instead of symlinking. Use this
|
|
2314
2331
|
when your environment doesn’t support symlinks or you
|
|
@@ -2321,30 +2338,34 @@ function printHelp() {
|
|
|
2321
2338
|
|
|
2322
2339
|
Examples:
|
|
2323
2340
|
npx @buiducnhat/agent-skills
|
|
2341
|
+
npx @buiducnhat/agent-skills -a claude-code -a cursor
|
|
2342
|
+
npx @buiducnhat/agent-skills --agent claude-code cursor
|
|
2324
2343
|
npx @buiducnhat/agent-skills --non-interactive
|
|
2325
2344
|
npx @buiducnhat/agent-skills --copy
|
|
2326
2345
|
npx @buiducnhat/agent-skills --global
|
|
2327
2346
|
npx @buiducnhat/agent-skills --global --non-interactive
|
|
2347
|
+
npx @buiducnhat/agent-skills --non-interactive --agent claude-code
|
|
2328
2348
|
`);
|
|
2329
2349
|
}
|
|
2330
2350
|
function printSummary(agents, results) {
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
for (const result of results) if (result.action !== "skipped")
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
for (const agent of agents)
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2351
|
+
O.success("Installation complete!");
|
|
2352
|
+
O.message("");
|
|
2353
|
+
O.message("What was set up:");
|
|
2354
|
+
O.message(" .claude/ - Claude Code settings");
|
|
2355
|
+
for (const result of results) if (result.action !== "skipped") O.message(` ${result.rulesFile} - ${result.action}`);
|
|
2356
|
+
O.message("");
|
|
2357
|
+
O.message("Agent configurations updated for:");
|
|
2358
|
+
for (const agent of agents) O.message(` - ${agent}`);
|
|
2359
|
+
O.message("");
|
|
2360
|
+
O.message("Next steps:");
|
|
2361
|
+
O.message(" 1. Review the updated agent rules files");
|
|
2362
|
+
O.message(" 2. Commit the generated files to your repository");
|
|
2343
2363
|
}
|
|
2344
2364
|
|
|
2345
2365
|
//#endregion
|
|
2346
2366
|
//#region src/index.ts
|
|
2347
2367
|
const require = createRequire(import.meta.url);
|
|
2368
|
+
const SUPPORTED_AGENT_IDS = new Set(SUPPORTED_AGENTS.map((agent) => agent.id));
|
|
2348
2369
|
function getCliVersion() {
|
|
2349
2370
|
try {
|
|
2350
2371
|
return require("../package.json").version ?? "unknown";
|
|
@@ -2352,6 +2373,16 @@ function getCliVersion() {
|
|
|
2352
2373
|
return "unknown";
|
|
2353
2374
|
}
|
|
2354
2375
|
}
|
|
2376
|
+
function getInvalidAgents(agents) {
|
|
2377
|
+
const invalidAgents = [];
|
|
2378
|
+
const seenAgents = /* @__PURE__ */ new Set();
|
|
2379
|
+
for (const agent of agents) {
|
|
2380
|
+
if (seenAgents.has(agent)) continue;
|
|
2381
|
+
seenAgents.add(agent);
|
|
2382
|
+
if (!SUPPORTED_AGENT_IDS.has(agent)) invalidAgents.push(agent);
|
|
2383
|
+
}
|
|
2384
|
+
return invalidAgents;
|
|
2385
|
+
}
|
|
2355
2386
|
async function main() {
|
|
2356
2387
|
const args = parseArgs(process.argv.slice(2));
|
|
2357
2388
|
if (args.help) {
|
|
@@ -2362,26 +2393,64 @@ async function main() {
|
|
|
2362
2393
|
console.log(getCliVersion());
|
|
2363
2394
|
process.exit(0);
|
|
2364
2395
|
}
|
|
2365
|
-
|
|
2396
|
+
if (args.agentErrors.length > 0) {
|
|
2397
|
+
pt(import_picocolors.default.red(args.agentErrors.join("\n")));
|
|
2398
|
+
process.exit(1);
|
|
2399
|
+
}
|
|
2400
|
+
const requestedAgents = args.agents;
|
|
2401
|
+
const invalidAgents = getInvalidAgents(requestedAgents);
|
|
2402
|
+
if (invalidAgents.length > 0) {
|
|
2403
|
+
pt(import_picocolors.default.red(`Unsupported agent id(s): ${invalidAgents.join(", ")}. Supported agents: ${SUPPORTED_AGENTS.map((agent) => agent.id).join(", ")}`));
|
|
2404
|
+
process.exit(1);
|
|
2405
|
+
}
|
|
2406
|
+
mt(import_picocolors.default.bold(import_picocolors.default.cyan(" Agent Skills Installer ")));
|
|
2366
2407
|
const cwd = process.cwd();
|
|
2367
2408
|
const baseDir = args.global ? os.homedir() : cwd;
|
|
2368
|
-
if (args.global)
|
|
2409
|
+
if (args.global) O.info(`Global mode: installing to ${import_picocolors.default.cyan(os.homedir())}`);
|
|
2369
2410
|
let selectedAgents;
|
|
2370
2411
|
if (args.nonInteractive) {
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2412
|
+
const agentsToInstall = requestedAgents.length > 0 ? requestedAgents : [];
|
|
2413
|
+
const installMessage = agentsToInstall.length > 0 ? "Installing skills for selected agents (non-interactive)..." : "Installing skills to all agents (non-interactive)...";
|
|
2414
|
+
O.step(installMessage);
|
|
2415
|
+
if (!(await runSkillsAdd(cwd, agentsToInstall, args.copy, args.global)).success) {
|
|
2416
|
+
pt(import_picocolors.default.red(agentsToInstall.length > 0 ? "Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' -a <agent> -y" : "Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' --all -y"));
|
|
2374
2417
|
process.exit(1);
|
|
2375
2418
|
}
|
|
2376
|
-
selectedAgents = detectAgentsFromFilesystem(baseDir);
|
|
2377
|
-
if (selectedAgents.length === 0) {
|
|
2378
|
-
|
|
2379
|
-
|
|
2419
|
+
selectedAgents = agentsToInstall.length > 0 ? agentsToInstall : detectAgentsFromFilesystem(baseDir);
|
|
2420
|
+
if (selectedAgents.length === 0 && agentsToInstall.length === 0) {
|
|
2421
|
+
O.warn("No agents detected from filesystem. Skills may have been installed but rules injection was skipped.");
|
|
2422
|
+
gt(import_picocolors.default.yellow("Done. No agent rules files were updated."));
|
|
2380
2423
|
process.exit(0);
|
|
2381
2424
|
}
|
|
2425
|
+
} else if (requestedAgents.length > 0) {
|
|
2426
|
+
selectedAgents = requestedAgents;
|
|
2427
|
+
let copyFlag = args.copy;
|
|
2428
|
+
if (!args.copy) {
|
|
2429
|
+
const installMode = await _t({
|
|
2430
|
+
message: "How should the skills be installed?",
|
|
2431
|
+
options: [{
|
|
2432
|
+
label: "Symlink (recommended)",
|
|
2433
|
+
value: "symlink"
|
|
2434
|
+
}, {
|
|
2435
|
+
label: "Copy",
|
|
2436
|
+
value: "copy"
|
|
2437
|
+
}],
|
|
2438
|
+
initialValue: "symlink"
|
|
2439
|
+
});
|
|
2440
|
+
if (q(installMode)) {
|
|
2441
|
+
pt("Installation cancelled.");
|
|
2442
|
+
process.exit(0);
|
|
2443
|
+
}
|
|
2444
|
+
copyFlag = installMode === "copy";
|
|
2445
|
+
}
|
|
2446
|
+
O.step("Installing skills via skills CLI...");
|
|
2447
|
+
if (!(await runSkillsAdd(cwd, selectedAgents, copyFlag, args.global)).success) {
|
|
2448
|
+
pt(import_picocolors.default.red("Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' -a <agent> -y"));
|
|
2449
|
+
process.exit(1);
|
|
2450
|
+
}
|
|
2382
2451
|
} else {
|
|
2383
2452
|
const preSelected = detectAgentsFromFilesystem(baseDir);
|
|
2384
|
-
const selection = await
|
|
2453
|
+
const selection = await yt({
|
|
2385
2454
|
message: "Select agents to install skills for:",
|
|
2386
2455
|
options: SUPPORTED_AGENTS.map((a) => ({
|
|
2387
2456
|
value: a.id,
|
|
@@ -2390,48 +2459,51 @@ async function main() {
|
|
|
2390
2459
|
initialValues: preSelected,
|
|
2391
2460
|
required: false
|
|
2392
2461
|
});
|
|
2393
|
-
if (
|
|
2394
|
-
|
|
2462
|
+
if (q(selection)) {
|
|
2463
|
+
pt("Installation cancelled.");
|
|
2395
2464
|
process.exit(0);
|
|
2396
2465
|
}
|
|
2397
2466
|
selectedAgents = selection;
|
|
2398
2467
|
if (selectedAgents.length === 0) {
|
|
2399
|
-
|
|
2468
|
+
gt(import_picocolors.default.yellow("No agents selected. Nothing to install."));
|
|
2400
2469
|
process.exit(0);
|
|
2401
2470
|
}
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2471
|
+
let copyFlag = args.copy;
|
|
2472
|
+
if (!args.copy) {
|
|
2473
|
+
const installMode = await _t({
|
|
2474
|
+
message: "How should the skills be installed?",
|
|
2475
|
+
options: [{
|
|
2476
|
+
label: "Symlink (recommended)",
|
|
2477
|
+
value: "symlink"
|
|
2478
|
+
}, {
|
|
2479
|
+
label: "Copy",
|
|
2480
|
+
value: "copy"
|
|
2481
|
+
}],
|
|
2482
|
+
initialValue: "symlink"
|
|
2483
|
+
});
|
|
2484
|
+
if (q(installMode)) {
|
|
2485
|
+
pt("Installation cancelled.");
|
|
2486
|
+
process.exit(0);
|
|
2487
|
+
}
|
|
2488
|
+
copyFlag = installMode === "copy";
|
|
2416
2489
|
}
|
|
2417
|
-
|
|
2418
|
-
R.step("Installing skills via skills CLI...");
|
|
2490
|
+
O.step("Installing skills via skills CLI...");
|
|
2419
2491
|
if (!(await runSkillsAdd(cwd, selectedAgents, copyFlag, args.global)).success) {
|
|
2420
|
-
|
|
2492
|
+
pt(import_picocolors.default.red("Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' -a <agent> -y"));
|
|
2421
2493
|
process.exit(1);
|
|
2422
2494
|
}
|
|
2423
2495
|
}
|
|
2424
|
-
|
|
2496
|
+
O.info(`Configuring agents: ${selectedAgents.join(", ")}`);
|
|
2425
2497
|
let tempDir;
|
|
2426
2498
|
try {
|
|
2427
2499
|
tempDir = await fetchTemplates();
|
|
2428
2500
|
const agentsContent = fs.readFileSync(path.join(tempDir, "templates", "AGENTS.md"), "utf-8");
|
|
2429
2501
|
const results = injectRules(baseDir, selectedAgents, agentsContent);
|
|
2430
2502
|
printSummary(selectedAgents, results);
|
|
2431
|
-
|
|
2503
|
+
gt(import_picocolors.default.green("Done! Your AI agent skills are ready."));
|
|
2432
2504
|
} catch (err) {
|
|
2433
2505
|
const message = err instanceof Error ? err.message : String(err);
|
|
2434
|
-
|
|
2506
|
+
pt(import_picocolors.default.red(`Error: ${message}`));
|
|
2435
2507
|
process.exit(1);
|
|
2436
2508
|
} finally {
|
|
2437
2509
|
if (tempDir) cleanupTemp(tempDir);
|