@cortexkit/aft 0.40.3 → 0.42.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/dist/index.js +1233 -942
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10131,29 +10131,46 @@ var init_adapters = __esm(() => {
|
|
|
10131
10131
|
ALL = [new OpenCodeAdapter, new PiAdapter];
|
|
10132
10132
|
});
|
|
10133
10133
|
|
|
10134
|
-
// ../../node_modules/.bun/fast-string-truncated-width@
|
|
10135
|
-
var
|
|
10136
|
-
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;
|
|
10137
|
-
}, isFullWidth = (x) => {
|
|
10134
|
+
// ../../node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
10135
|
+
var getCodePointsLength, isFullWidth = (x) => {
|
|
10138
10136
|
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
10139
|
-
},
|
|
10140
|
-
return x
|
|
10137
|
+
}, isWideNotCJKTNotEmoji = (x) => {
|
|
10138
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
10141
10139
|
};
|
|
10142
|
-
var init_utils = () => {
|
|
10140
|
+
var init_utils = __esm(() => {
|
|
10141
|
+
getCodePointsLength = (() => {
|
|
10142
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
10143
|
+
return (input) => {
|
|
10144
|
+
let surrogatePairsNr = 0;
|
|
10145
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
10146
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
10147
|
+
surrogatePairsNr += 1;
|
|
10148
|
+
}
|
|
10149
|
+
return input.length - surrogatePairsNr;
|
|
10150
|
+
};
|
|
10151
|
+
})();
|
|
10152
|
+
});
|
|
10143
10153
|
|
|
10144
|
-
// ../../node_modules/.bun/fast-string-truncated-width@
|
|
10145
|
-
var ANSI_RE, CONTROL_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
10154
|
+
// ../../node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
10155
|
+
var ANSI_RE, CONTROL_RE, CJKT_WIDE_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
10146
10156
|
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
10147
10157
|
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
10148
10158
|
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
10149
|
-
const ANSI_WIDTH =
|
|
10159
|
+
const ANSI_WIDTH = 0;
|
|
10150
10160
|
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
10151
10161
|
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
10152
|
-
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
10153
10162
|
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
10154
|
-
const FULL_WIDTH_WIDTH =
|
|
10163
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
10155
10164
|
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
10156
|
-
const WIDE_WIDTH = widthOptions.wideWidth ??
|
|
10165
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
10166
|
+
const PARSE_BLOCKS = [
|
|
10167
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
10168
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
10169
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
10170
|
+
[TAB_RE, TAB_WIDTH],
|
|
10171
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
10172
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
10173
|
+
];
|
|
10157
10174
|
let indexPrev = 0;
|
|
10158
10175
|
let index = 0;
|
|
10159
10176
|
let length = input.length;
|
|
@@ -10174,10 +10191,8 @@ var ANSI_RE, CONTROL_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION,
|
|
|
10174
10191
|
const codePoint = char.codePointAt(0) || 0;
|
|
10175
10192
|
if (isFullWidth(codePoint)) {
|
|
10176
10193
|
widthExtra = FULL_WIDTH_WIDTH;
|
|
10177
|
-
} else if (
|
|
10194
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
10178
10195
|
widthExtra = WIDE_WIDTH;
|
|
10179
|
-
} else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
|
|
10180
|
-
widthExtra = AMBIGUOUS_WIDTH;
|
|
10181
10196
|
} else {
|
|
10182
10197
|
widthExtra = REGULAR_WIDTH;
|
|
10183
10198
|
}
|
|
@@ -10193,88 +10208,28 @@ var ANSI_RE, CONTROL_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION,
|
|
|
10193
10208
|
}
|
|
10194
10209
|
unmatchedStart = unmatchedEnd = 0;
|
|
10195
10210
|
}
|
|
10196
|
-
if (index >= length)
|
|
10197
|
-
break;
|
|
10198
|
-
LATIN_RE.lastIndex = index;
|
|
10199
|
-
if (LATIN_RE.test(input)) {
|
|
10200
|
-
lengthExtra = LATIN_RE.lastIndex - index;
|
|
10201
|
-
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
10202
|
-
if (width + widthExtra > truncationLimit) {
|
|
10203
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
10204
|
-
}
|
|
10205
|
-
if (width + widthExtra > LIMIT) {
|
|
10206
|
-
truncationEnabled = true;
|
|
10207
|
-
break;
|
|
10208
|
-
}
|
|
10209
|
-
width += widthExtra;
|
|
10210
|
-
unmatchedStart = indexPrev;
|
|
10211
|
-
unmatchedEnd = index;
|
|
10212
|
-
index = indexPrev = LATIN_RE.lastIndex;
|
|
10213
|
-
continue;
|
|
10214
|
-
}
|
|
10215
|
-
ANSI_RE.lastIndex = index;
|
|
10216
|
-
if (ANSI_RE.test(input)) {
|
|
10217
|
-
if (width + ANSI_WIDTH > truncationLimit) {
|
|
10218
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
10219
|
-
}
|
|
10220
|
-
if (width + ANSI_WIDTH > LIMIT) {
|
|
10221
|
-
truncationEnabled = true;
|
|
10222
|
-
break;
|
|
10223
|
-
}
|
|
10224
|
-
width += ANSI_WIDTH;
|
|
10225
|
-
unmatchedStart = indexPrev;
|
|
10226
|
-
unmatchedEnd = index;
|
|
10227
|
-
index = indexPrev = ANSI_RE.lastIndex;
|
|
10228
|
-
continue;
|
|
10229
|
-
}
|
|
10230
|
-
CONTROL_RE.lastIndex = index;
|
|
10231
|
-
if (CONTROL_RE.test(input)) {
|
|
10232
|
-
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
10233
|
-
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
10234
|
-
if (width + widthExtra > truncationLimit) {
|
|
10235
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
10236
|
-
}
|
|
10237
|
-
if (width + widthExtra > LIMIT) {
|
|
10238
|
-
truncationEnabled = true;
|
|
10239
|
-
break;
|
|
10240
|
-
}
|
|
10241
|
-
width += widthExtra;
|
|
10242
|
-
unmatchedStart = indexPrev;
|
|
10243
|
-
unmatchedEnd = index;
|
|
10244
|
-
index = indexPrev = CONTROL_RE.lastIndex;
|
|
10245
|
-
continue;
|
|
10246
|
-
}
|
|
10247
|
-
TAB_RE.lastIndex = index;
|
|
10248
|
-
if (TAB_RE.test(input)) {
|
|
10249
|
-
lengthExtra = TAB_RE.lastIndex - index;
|
|
10250
|
-
widthExtra = lengthExtra * TAB_WIDTH;
|
|
10251
|
-
if (width + widthExtra > truncationLimit) {
|
|
10252
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
10253
|
-
}
|
|
10254
|
-
if (width + widthExtra > LIMIT) {
|
|
10255
|
-
truncationEnabled = true;
|
|
10256
|
-
break;
|
|
10257
|
-
}
|
|
10258
|
-
width += widthExtra;
|
|
10259
|
-
unmatchedStart = indexPrev;
|
|
10260
|
-
unmatchedEnd = index;
|
|
10261
|
-
index = indexPrev = TAB_RE.lastIndex;
|
|
10262
|
-
continue;
|
|
10211
|
+
if (index >= length) {
|
|
10212
|
+
break outer;
|
|
10263
10213
|
}
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10214
|
+
for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
|
|
10215
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
10216
|
+
BLOCK_RE.lastIndex = index;
|
|
10217
|
+
if (BLOCK_RE.test(input)) {
|
|
10218
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
10219
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
10220
|
+
if (width + widthExtra > truncationLimit) {
|
|
10221
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
10222
|
+
}
|
|
10223
|
+
if (width + widthExtra > LIMIT) {
|
|
10224
|
+
truncationEnabled = true;
|
|
10225
|
+
break outer;
|
|
10226
|
+
}
|
|
10227
|
+
width += widthExtra;
|
|
10228
|
+
unmatchedStart = indexPrev;
|
|
10229
|
+
unmatchedEnd = index;
|
|
10230
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
10231
|
+
continue outer;
|
|
10272
10232
|
}
|
|
10273
|
-
width += EMOJI_WIDTH;
|
|
10274
|
-
unmatchedStart = indexPrev;
|
|
10275
|
-
unmatchedEnd = index;
|
|
10276
|
-
index = indexPrev = EMOJI_RE.lastIndex;
|
|
10277
|
-
continue;
|
|
10278
10233
|
}
|
|
10279
10234
|
index += 1;
|
|
10280
10235
|
}
|
|
@@ -10287,8 +10242,9 @@ var ANSI_RE, CONTROL_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION,
|
|
|
10287
10242
|
}, dist_default;
|
|
10288
10243
|
var init_dist2 = __esm(() => {
|
|
10289
10244
|
init_utils();
|
|
10290
|
-
ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
10245
|
+
ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
10291
10246
|
CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
10247
|
+
CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
10292
10248
|
TAB_RE = /\t{1,1000}/y;
|
|
10293
10249
|
EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
10294
10250
|
LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
@@ -10297,7 +10253,7 @@ var init_dist2 = __esm(() => {
|
|
|
10297
10253
|
dist_default = getStringTruncatedWidth;
|
|
10298
10254
|
});
|
|
10299
10255
|
|
|
10300
|
-
// ../../node_modules/.bun/fast-string-width@
|
|
10256
|
+
// ../../node_modules/.bun/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
10301
10257
|
var NO_TRUNCATION2, fastStringWidth = (input, options = {}) => {
|
|
10302
10258
|
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
10303
10259
|
}, dist_default2;
|
|
@@ -10311,7 +10267,7 @@ var init_dist3 = __esm(() => {
|
|
|
10311
10267
|
dist_default2 = fastStringWidth;
|
|
10312
10268
|
});
|
|
10313
10269
|
|
|
10314
|
-
// ../../node_modules/.bun/fast-wrap-ansi@0.
|
|
10270
|
+
// ../../node_modules/.bun/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
10315
10271
|
function wrapAnsi(string, columns, options) {
|
|
10316
10272
|
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
|
|
10317
10273
|
`);
|
|
@@ -10469,8 +10425,11 @@ var ESC = "\x1B", CSI = "", END_CODE = 39, ANSI_ESCAPE_BELL = "\x07", ANSI_CSI
|
|
|
10469
10425
|
returnValue += character;
|
|
10470
10426
|
if (!inSurrogate) {
|
|
10471
10427
|
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
10428
|
+
if (inSurrogate) {
|
|
10429
|
+
continue;
|
|
10430
|
+
}
|
|
10472
10431
|
} else {
|
|
10473
|
-
|
|
10432
|
+
inSurrogate = false;
|
|
10474
10433
|
}
|
|
10475
10434
|
if (character === ESC || character === CSI) {
|
|
10476
10435
|
GROUP_REGEX.lastIndex = i + 1;
|
|
@@ -10569,96 +10528,88 @@ var require_src3 = __commonJS((exports, module) => {
|
|
|
10569
10528
|
module.exports = { cursor, scroll, erase, beep };
|
|
10570
10529
|
});
|
|
10571
10530
|
|
|
10572
|
-
// ../../node_modules/.bun/@clack+core@1.2
|
|
10573
|
-
import { styleText
|
|
10574
|
-
import { stdout
|
|
10575
|
-
import
|
|
10576
|
-
function
|
|
10577
|
-
if (!
|
|
10578
|
-
return
|
|
10579
|
-
const
|
|
10580
|
-
return e
|
|
10581
|
-
}
|
|
10582
|
-
function
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10531
|
+
// ../../node_modules/.bun/@clack+core@1.4.2/node_modules/@clack/core/dist/index.mjs
|
|
10532
|
+
import { styleText } from "node:util";
|
|
10533
|
+
import { stdout, stdin } from "node:process";
|
|
10534
|
+
import l__default from "node:readline";
|
|
10535
|
+
function findCursor(s, o, l) {
|
|
10536
|
+
if (!l.some((r) => !r.disabled))
|
|
10537
|
+
return s;
|
|
10538
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
10539
|
+
return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
10540
|
+
}
|
|
10541
|
+
function findTextCursor(s, o, l, i) {
|
|
10542
|
+
const t = i.split(`
|
|
10543
|
+
`);
|
|
10544
|
+
let n = 0, e = s;
|
|
10545
|
+
for (const r of t) {
|
|
10546
|
+
if (e <= r.length)
|
|
10547
|
+
break;
|
|
10548
|
+
e -= r.length + 1, n++;
|
|
10549
|
+
}
|
|
10550
|
+
for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + o;e < 0 && n > 0; )
|
|
10551
|
+
n--, e += t[n].length + 1;
|
|
10552
|
+
for (;e > t[n].length && n < t.length - 1; )
|
|
10553
|
+
e -= t[n].length + 1, n++;
|
|
10554
|
+
e = Math.max(0, Math.min(t[n].length, e));
|
|
10555
|
+
let h = 0;
|
|
10556
|
+
for (let r = 0;r < n; r++)
|
|
10557
|
+
h += t[r].length + 1;
|
|
10558
|
+
return h + e;
|
|
10559
|
+
}
|
|
10560
|
+
function isActionKey(n, e) {
|
|
10561
|
+
if (typeof n == "string")
|
|
10562
|
+
return settings.aliases.get(n) === e;
|
|
10563
|
+
for (const s of n)
|
|
10564
|
+
if (s !== undefined && isActionKey(s, e))
|
|
10587
10565
|
return true;
|
|
10588
10566
|
return false;
|
|
10589
10567
|
}
|
|
10590
|
-
function
|
|
10591
|
-
if (
|
|
10592
|
-
return;
|
|
10593
|
-
const e = r.split(`
|
|
10594
|
-
`), s = t.split(`
|
|
10595
|
-
`), i = Math.max(e.length, s.length), n = [];
|
|
10596
|
-
for (let o = 0;o < i; o++)
|
|
10597
|
-
e[o] !== s[o] && n.push(o);
|
|
10598
|
-
return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
|
|
10599
|
-
}
|
|
10600
|
-
function q(r) {
|
|
10601
|
-
return r === C;
|
|
10602
|
-
}
|
|
10603
|
-
function w(r, t) {
|
|
10604
|
-
const e = r;
|
|
10605
|
-
e.isTTY && e.setRawMode(t);
|
|
10606
|
-
}
|
|
10607
|
-
function R(r, t, e, s = e) {
|
|
10608
|
-
const i = O(r ?? S);
|
|
10609
|
-
return wrapAnsi(t, i - e.length, { hard: true, trim: false }).split(`
|
|
10610
|
-
`).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
|
|
10611
|
-
`);
|
|
10612
|
-
}
|
|
10613
|
-
function W(r, t) {
|
|
10614
|
-
if (r === undefined || t.length === 0)
|
|
10615
|
-
return 0;
|
|
10616
|
-
const e = t.findIndex((s) => s.value === r);
|
|
10617
|
-
return e !== -1 ? e : 0;
|
|
10618
|
-
}
|
|
10619
|
-
function B(r, t) {
|
|
10620
|
-
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
10621
|
-
}
|
|
10622
|
-
function J(r, t) {
|
|
10623
|
-
if (t)
|
|
10624
|
-
return r ? t : t[0];
|
|
10625
|
-
}
|
|
10626
|
-
function L(r) {
|
|
10627
|
-
return [...r].map((t) => X[t]);
|
|
10628
|
-
}
|
|
10629
|
-
function Z(r) {
|
|
10630
|
-
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
|
|
10631
|
-
let s = "/";
|
|
10632
|
-
for (const i of t)
|
|
10633
|
-
i.type === "literal" ? s = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && e.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
|
|
10634
|
-
return { segments: e, separator: s };
|
|
10635
|
-
}
|
|
10636
|
-
function k(r) {
|
|
10637
|
-
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
10638
|
-
}
|
|
10639
|
-
function I(r) {
|
|
10640
|
-
return { year: k(r.year), month: k(r.month), day: k(r.day) };
|
|
10641
|
-
}
|
|
10642
|
-
function T(r, t) {
|
|
10643
|
-
return new Date(r || 2001, t || 1, 0).getDate();
|
|
10644
|
-
}
|
|
10645
|
-
function F(r) {
|
|
10646
|
-
const { year: t, month: e, day: s } = I(r);
|
|
10647
|
-
if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
|
|
10568
|
+
function diffLines(i, s) {
|
|
10569
|
+
if (i === s)
|
|
10648
10570
|
return;
|
|
10649
|
-
const
|
|
10650
|
-
|
|
10651
|
-
|
|
10571
|
+
const e = i.split(`
|
|
10572
|
+
`), t2 = s.split(`
|
|
10573
|
+
`), r = Math.max(e.length, t2.length), f = [];
|
|
10574
|
+
for (let n = 0;n < r; n++)
|
|
10575
|
+
e[n] !== t2[n] && f.push(n);
|
|
10576
|
+
return {
|
|
10577
|
+
lines: f,
|
|
10578
|
+
numLinesBefore: e.length,
|
|
10579
|
+
numLinesAfter: t2.length,
|
|
10580
|
+
numLines: r
|
|
10581
|
+
};
|
|
10652
10582
|
}
|
|
10653
|
-
function
|
|
10654
|
-
|
|
10655
|
-
|
|
10583
|
+
function isCancel(e) {
|
|
10584
|
+
return e === CANCEL_SYMBOL;
|
|
10585
|
+
}
|
|
10586
|
+
function setRawMode(e, r) {
|
|
10587
|
+
const o = e;
|
|
10588
|
+
o.isTTY && o.setRawMode(r);
|
|
10589
|
+
}
|
|
10590
|
+
function wrapTextWithPrefix(e, r, o, t2 = o, s = o, n) {
|
|
10591
|
+
const f = getColumns(e ?? stdout);
|
|
10592
|
+
return wrapAnsi(r, f - o.length, {
|
|
10593
|
+
hard: true,
|
|
10594
|
+
trim: false
|
|
10595
|
+
}).split(`
|
|
10596
|
+
`).map((c, i, m) => {
|
|
10597
|
+
const d = n ? n(c, i) : c;
|
|
10598
|
+
return i === 0 ? `${t2}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
10599
|
+
}).join(`
|
|
10600
|
+
`);
|
|
10656
10601
|
}
|
|
10657
|
-
function
|
|
10658
|
-
|
|
10659
|
-
|
|
10602
|
+
function runValidation(e, n) {
|
|
10603
|
+
if ("~standard" in e) {
|
|
10604
|
+
const a = e["~standard"].validate(n);
|
|
10605
|
+
if (a instanceof Promise)
|
|
10606
|
+
throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
10607
|
+
return a.issues?.at(0)?.message;
|
|
10608
|
+
}
|
|
10609
|
+
return e(n);
|
|
10660
10610
|
}
|
|
10661
|
-
|
|
10611
|
+
|
|
10612
|
+
class V {
|
|
10662
10613
|
input;
|
|
10663
10614
|
output;
|
|
10664
10615
|
_abortSignal;
|
|
@@ -10667,399 +10618,541 @@ var import_sisteransi, E, G, u, Y, C, O = (r) => ("columns" in r) && typeof r.co
|
|
|
10667
10618
|
_render;
|
|
10668
10619
|
_track = false;
|
|
10669
10620
|
_prevFrame = "";
|
|
10670
|
-
_subscribers = new Map;
|
|
10621
|
+
_subscribers = /* @__PURE__ */ new Map;
|
|
10671
10622
|
_cursor = 0;
|
|
10672
10623
|
state = "initial";
|
|
10673
10624
|
error = "";
|
|
10674
10625
|
value;
|
|
10675
10626
|
userInput = "";
|
|
10676
|
-
constructor(
|
|
10677
|
-
const { input:
|
|
10678
|
-
this.opts =
|
|
10627
|
+
constructor(t2, e = true) {
|
|
10628
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t2;
|
|
10629
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
10679
10630
|
}
|
|
10680
10631
|
unsubscribe() {
|
|
10681
10632
|
this._subscribers.clear();
|
|
10682
10633
|
}
|
|
10683
|
-
setSubscriber(
|
|
10684
|
-
const
|
|
10685
|
-
|
|
10634
|
+
setSubscriber(t2, e) {
|
|
10635
|
+
const i = this._subscribers.get(t2) ?? [];
|
|
10636
|
+
i.push(e), this._subscribers.set(t2, i);
|
|
10686
10637
|
}
|
|
10687
|
-
on(
|
|
10688
|
-
this.setSubscriber(
|
|
10638
|
+
on(t2, e) {
|
|
10639
|
+
this.setSubscriber(t2, { cb: e });
|
|
10689
10640
|
}
|
|
10690
|
-
once(
|
|
10691
|
-
this.setSubscriber(
|
|
10641
|
+
once(t2, e) {
|
|
10642
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
10692
10643
|
}
|
|
10693
|
-
emit(
|
|
10694
|
-
const
|
|
10695
|
-
for (const
|
|
10696
|
-
|
|
10697
|
-
for (const
|
|
10698
|
-
|
|
10644
|
+
emit(t2, ...e) {
|
|
10645
|
+
const i = this._subscribers.get(t2) ?? [], n = [];
|
|
10646
|
+
for (const s of i)
|
|
10647
|
+
s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
10648
|
+
for (const s of n)
|
|
10649
|
+
s();
|
|
10699
10650
|
}
|
|
10700
10651
|
prompt() {
|
|
10701
|
-
return new Promise((
|
|
10652
|
+
return new Promise((t2) => {
|
|
10702
10653
|
if (this._abortSignal) {
|
|
10703
10654
|
if (this._abortSignal.aborted)
|
|
10704
|
-
return this.state = "cancel", this.close(),
|
|
10655
|
+
return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
|
|
10705
10656
|
this._abortSignal.addEventListener("abort", () => {
|
|
10706
10657
|
this.state = "cancel", this.close();
|
|
10707
10658
|
}, { once: true });
|
|
10708
10659
|
}
|
|
10709
|
-
this.rl =
|
|
10710
|
-
|
|
10660
|
+
this.rl = l__default.createInterface({
|
|
10661
|
+
input: this.input,
|
|
10662
|
+
tabSize: 2,
|
|
10663
|
+
prompt: "",
|
|
10664
|
+
escapeCodeTimeout: 50,
|
|
10665
|
+
terminal: true
|
|
10666
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
10667
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
10711
10668
|
}), this.once("cancel", () => {
|
|
10712
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render),
|
|
10669
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
10713
10670
|
});
|
|
10714
10671
|
});
|
|
10715
10672
|
}
|
|
10716
|
-
_isActionKey(
|
|
10717
|
-
return
|
|
10673
|
+
_isActionKey(t2, e) {
|
|
10674
|
+
return t2 === "\t";
|
|
10718
10675
|
}
|
|
10719
|
-
|
|
10720
|
-
|
|
10676
|
+
_shouldSubmit(t2, e) {
|
|
10677
|
+
return true;
|
|
10678
|
+
}
|
|
10679
|
+
_setValue(t2) {
|
|
10680
|
+
this.value = t2, this.emit("value", this.value);
|
|
10721
10681
|
}
|
|
10722
|
-
_setUserInput(
|
|
10723
|
-
this.userInput =
|
|
10682
|
+
_setUserInput(t2, e) {
|
|
10683
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
10724
10684
|
}
|
|
10725
10685
|
_clearUserInput() {
|
|
10726
10686
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
10727
10687
|
}
|
|
10728
|
-
onKeypress(
|
|
10729
|
-
if (this._track && e.name !== "return" && (e.name && this._isActionKey(
|
|
10688
|
+
onKeypress(t2, e) {
|
|
10689
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
|
|
10730
10690
|
if (this.opts.validate) {
|
|
10731
|
-
const
|
|
10732
|
-
|
|
10691
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
10692
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
10733
10693
|
}
|
|
10734
10694
|
this.state !== "error" && (this.state = "submit");
|
|
10735
10695
|
}
|
|
10736
|
-
|
|
10696
|
+
isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
10737
10697
|
}
|
|
10738
10698
|
close() {
|
|
10739
10699
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
10740
|
-
`),
|
|
10700
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
10741
10701
|
}
|
|
10742
10702
|
restoreCursor() {
|
|
10743
|
-
const
|
|
10703
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
10744
10704
|
`).length - 1;
|
|
10745
|
-
this.output.write(import_sisteransi.cursor.move(-999,
|
|
10705
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
10746
10706
|
}
|
|
10747
10707
|
render() {
|
|
10748
|
-
const
|
|
10749
|
-
|
|
10708
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
10709
|
+
hard: true,
|
|
10710
|
+
trim: false
|
|
10711
|
+
});
|
|
10712
|
+
if (t2 !== this._prevFrame) {
|
|
10750
10713
|
if (this.state === "initial")
|
|
10751
10714
|
this.output.write(import_sisteransi.cursor.hide);
|
|
10752
10715
|
else {
|
|
10753
|
-
const e =
|
|
10716
|
+
const e = diffLines(this._prevFrame, t2), i = getRows(this.output);
|
|
10754
10717
|
if (this.restoreCursor(), e) {
|
|
10755
|
-
const
|
|
10756
|
-
let
|
|
10757
|
-
if (
|
|
10758
|
-
this._prevFrame =
|
|
10718
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
10719
|
+
let r = e.lines.find((o) => o >= n);
|
|
10720
|
+
if (r === undefined) {
|
|
10721
|
+
this._prevFrame = t2;
|
|
10759
10722
|
return;
|
|
10760
10723
|
}
|
|
10761
10724
|
if (e.lines.length === 1) {
|
|
10762
|
-
this.output.write(import_sisteransi.cursor.move(0,
|
|
10763
|
-
const
|
|
10725
|
+
this.output.write(import_sisteransi.cursor.move(0, r - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
10726
|
+
const o = t2.split(`
|
|
10764
10727
|
`);
|
|
10765
|
-
this.output.write(
|
|
10728
|
+
this.output.write(o[r]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - r - 1));
|
|
10766
10729
|
return;
|
|
10767
10730
|
} else if (e.lines.length > 1) {
|
|
10768
|
-
if (
|
|
10769
|
-
|
|
10731
|
+
if (n < s)
|
|
10732
|
+
r = n;
|
|
10770
10733
|
else {
|
|
10771
|
-
const h =
|
|
10734
|
+
const h = r - s;
|
|
10772
10735
|
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
10773
10736
|
}
|
|
10774
10737
|
this.output.write(import_sisteransi.erase.down());
|
|
10775
|
-
const
|
|
10776
|
-
`).slice(
|
|
10777
|
-
this.output.write(
|
|
10778
|
-
`)), this._prevFrame =
|
|
10738
|
+
const f = t2.split(`
|
|
10739
|
+
`).slice(r);
|
|
10740
|
+
this.output.write(f.join(`
|
|
10741
|
+
`)), this._prevFrame = t2;
|
|
10779
10742
|
return;
|
|
10780
10743
|
}
|
|
10781
10744
|
}
|
|
10782
10745
|
this.output.write(import_sisteransi.erase.down());
|
|
10783
10746
|
}
|
|
10784
|
-
this.output.write(
|
|
10747
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
10785
10748
|
}
|
|
10786
10749
|
}
|
|
10787
|
-
}
|
|
10750
|
+
}
|
|
10751
|
+
function p$1(l, e) {
|
|
10752
|
+
if (l === undefined || e.length === 0)
|
|
10753
|
+
return 0;
|
|
10754
|
+
const i = e.findIndex((s) => s.value === l);
|
|
10755
|
+
return i !== -1 ? i : 0;
|
|
10756
|
+
}
|
|
10757
|
+
function g(l, e) {
|
|
10758
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
|
|
10759
|
+
}
|
|
10760
|
+
function m(l, e) {
|
|
10761
|
+
if (e)
|
|
10762
|
+
return l ? e : e[0];
|
|
10763
|
+
}
|
|
10764
|
+
function M(r2) {
|
|
10765
|
+
return [...r2].map((t2) => _[t2]);
|
|
10766
|
+
}
|
|
10767
|
+
function P(r2) {
|
|
10768
|
+
const i = new Intl.DateTimeFormat(r2, {
|
|
10769
|
+
year: "numeric",
|
|
10770
|
+
month: "2-digit",
|
|
10771
|
+
day: "2-digit"
|
|
10772
|
+
}).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
10773
|
+
let n = "/";
|
|
10774
|
+
for (const e of i)
|
|
10775
|
+
e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
|
|
10776
|
+
return { segments: s, separator: n };
|
|
10777
|
+
}
|
|
10778
|
+
function p(r2) {
|
|
10779
|
+
return Number.parseInt((r2 || "0").replace(/_/g, "0"), 10) || 0;
|
|
10780
|
+
}
|
|
10781
|
+
function f(r2) {
|
|
10782
|
+
return {
|
|
10783
|
+
year: p(r2.year),
|
|
10784
|
+
month: p(r2.month),
|
|
10785
|
+
day: p(r2.day)
|
|
10786
|
+
};
|
|
10787
|
+
}
|
|
10788
|
+
function c(r2, t2) {
|
|
10789
|
+
return new Date(r2 || 2001, t2 || 1, 0).getDate();
|
|
10790
|
+
}
|
|
10791
|
+
function b(r2) {
|
|
10792
|
+
const { year: t2, month: i, day: s } = f(r2);
|
|
10793
|
+
if (!t2 || t2 < 0 || t2 > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
|
|
10794
|
+
return;
|
|
10795
|
+
const n = new Date(Date.UTC(t2, i - 1, s));
|
|
10796
|
+
if (!(n.getUTCFullYear() !== t2 || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
10797
|
+
return { year: t2, month: i, day: s };
|
|
10798
|
+
}
|
|
10799
|
+
function C(r2) {
|
|
10800
|
+
const t2 = b(r2);
|
|
10801
|
+
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
|
|
10802
|
+
}
|
|
10803
|
+
function T2(r2, t2, i, s) {
|
|
10804
|
+
const n = i ? {
|
|
10805
|
+
year: i.getUTCFullYear(),
|
|
10806
|
+
month: i.getUTCMonth() + 1,
|
|
10807
|
+
day: i.getUTCDate()
|
|
10808
|
+
} : null, e = s ? {
|
|
10809
|
+
year: s.getUTCFullYear(),
|
|
10810
|
+
month: s.getUTCMonth() + 1,
|
|
10811
|
+
day: s.getUTCDate()
|
|
10812
|
+
} : null;
|
|
10813
|
+
return r2 === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r2 === "month" ? {
|
|
10814
|
+
min: n && t2.year === n.year ? n.month : 1,
|
|
10815
|
+
max: e && t2.year === e.year ? e.month : 12
|
|
10816
|
+
} : {
|
|
10817
|
+
min: n && t2.year === n.year && t2.month === n.month ? n.day : 1,
|
|
10818
|
+
max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
|
|
10819
|
+
};
|
|
10820
|
+
}
|
|
10821
|
+
var import_sisteransi, a$2, t, settings, R, CANCEL_SYMBOL, getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20, T$1, r, _, U, u$1, o$1, h, a$1, a2, n;
|
|
10788
10822
|
var init_dist4 = __esm(() => {
|
|
10789
10823
|
init_main();
|
|
10790
10824
|
import_sisteransi = __toESM(require_src3(), 1);
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10825
|
+
a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
10826
|
+
t = [
|
|
10827
|
+
"January",
|
|
10828
|
+
"February",
|
|
10829
|
+
"March",
|
|
10830
|
+
"April",
|
|
10831
|
+
"May",
|
|
10832
|
+
"June",
|
|
10833
|
+
"July",
|
|
10834
|
+
"August",
|
|
10835
|
+
"September",
|
|
10836
|
+
"October",
|
|
10837
|
+
"November",
|
|
10838
|
+
"December"
|
|
10839
|
+
];
|
|
10840
|
+
settings = {
|
|
10841
|
+
actions: new Set(a$2),
|
|
10842
|
+
aliases: /* @__PURE__ */ new Map([
|
|
10843
|
+
["k", "up"],
|
|
10844
|
+
["j", "down"],
|
|
10845
|
+
["h", "left"],
|
|
10846
|
+
["l", "right"],
|
|
10847
|
+
["\x03", "cancel"],
|
|
10848
|
+
["escape", "cancel"]
|
|
10849
|
+
]),
|
|
10850
|
+
messages: {
|
|
10851
|
+
cancel: "Canceled",
|
|
10852
|
+
error: "Something went wrong"
|
|
10853
|
+
},
|
|
10854
|
+
withGuide: true,
|
|
10855
|
+
date: {
|
|
10856
|
+
monthNames: [...t],
|
|
10857
|
+
messages: {
|
|
10858
|
+
required: "Please enter a valid date",
|
|
10859
|
+
invalidMonth: "There are only 12 months in a year",
|
|
10860
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
10861
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
10862
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
10863
|
+
}
|
|
10864
|
+
}
|
|
10865
|
+
};
|
|
10866
|
+
R = globalThis.process.platform.startsWith("win");
|
|
10867
|
+
CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
10868
|
+
T$1 = class T extends V {
|
|
10797
10869
|
filteredOptions;
|
|
10798
10870
|
multiple;
|
|
10799
10871
|
isNavigating = false;
|
|
10800
10872
|
selectedValues = [];
|
|
10801
10873
|
focusedValue;
|
|
10802
10874
|
#e = 0;
|
|
10803
|
-
#
|
|
10875
|
+
#s = "";
|
|
10804
10876
|
#t;
|
|
10877
|
+
#i;
|
|
10805
10878
|
#n;
|
|
10806
|
-
#a;
|
|
10807
10879
|
get cursor() {
|
|
10808
10880
|
return this.#e;
|
|
10809
10881
|
}
|
|
10810
10882
|
get userInputWithCursor() {
|
|
10811
10883
|
if (!this.userInput)
|
|
10812
|
-
return
|
|
10884
|
+
return styleText(["inverse", "hidden"], "_");
|
|
10813
10885
|
if (this._cursor >= this.userInput.length)
|
|
10814
10886
|
return `${this.userInput}█`;
|
|
10815
|
-
const
|
|
10816
|
-
return `${
|
|
10887
|
+
const e = this.userInput.slice(0, this._cursor), [t2, ...i] = this.userInput.slice(this._cursor);
|
|
10888
|
+
return `${e}${styleText("inverse", t2)}${i.join("")}`;
|
|
10817
10889
|
}
|
|
10818
10890
|
get options() {
|
|
10819
|
-
return typeof this.#
|
|
10820
|
-
}
|
|
10821
|
-
constructor(
|
|
10822
|
-
super(
|
|
10823
|
-
const
|
|
10824
|
-
this.filteredOptions = [...
|
|
10825
|
-
let
|
|
10826
|
-
if (
|
|
10827
|
-
for (const
|
|
10828
|
-
const n =
|
|
10829
|
-
n !== -1 && (this.toggleSelected(
|
|
10891
|
+
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
10892
|
+
}
|
|
10893
|
+
constructor(e) {
|
|
10894
|
+
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
10895
|
+
const t2 = this.options;
|
|
10896
|
+
this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
|
|
10897
|
+
let i;
|
|
10898
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i)
|
|
10899
|
+
for (const s of i) {
|
|
10900
|
+
const n = t2.findIndex((o) => o.value === s);
|
|
10901
|
+
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
10830
10902
|
}
|
|
10831
|
-
this.focusedValue = this.options[this.#e]?.value, this.on("key", (
|
|
10903
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
10832
10904
|
}
|
|
10833
|
-
_isActionKey(
|
|
10834
|
-
return
|
|
10905
|
+
_isActionKey(e, t2) {
|
|
10906
|
+
return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
|
|
10835
10907
|
}
|
|
10836
|
-
#
|
|
10837
|
-
const
|
|
10838
|
-
if (
|
|
10839
|
-
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(
|
|
10908
|
+
#l(e, t2) {
|
|
10909
|
+
const i = t2.name === "up", s = t2.name === "down", n = t2.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#n, h = this.options, f = u !== undefined && u !== "" && h.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
|
|
10910
|
+
if (t2.name === "tab" && o && f) {
|
|
10911
|
+
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
10840
10912
|
return;
|
|
10841
10913
|
}
|
|
10842
|
-
|
|
10914
|
+
i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
10843
10915
|
}
|
|
10844
10916
|
deselectAll() {
|
|
10845
10917
|
this.selectedValues = [];
|
|
10846
10918
|
}
|
|
10847
|
-
toggleSelected(
|
|
10848
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(
|
|
10919
|
+
toggleSelected(e) {
|
|
10920
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
10849
10921
|
}
|
|
10850
|
-
#
|
|
10851
|
-
if (
|
|
10852
|
-
this.#
|
|
10853
|
-
const
|
|
10854
|
-
|
|
10855
|
-
const
|
|
10856
|
-
this.#e =
|
|
10857
|
-
const
|
|
10858
|
-
|
|
10922
|
+
#u(e) {
|
|
10923
|
+
if (e !== this.#s) {
|
|
10924
|
+
this.#s = e;
|
|
10925
|
+
const t2 = this.options;
|
|
10926
|
+
e && this.#t ? this.filteredOptions = t2.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t2];
|
|
10927
|
+
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
10928
|
+
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
10929
|
+
const s = this.filteredOptions[this.#e];
|
|
10930
|
+
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
10859
10931
|
}
|
|
10860
10932
|
}
|
|
10861
10933
|
};
|
|
10862
|
-
|
|
10934
|
+
r = class r extends V {
|
|
10863
10935
|
get cursor() {
|
|
10864
10936
|
return this.value ? 0 : 1;
|
|
10865
10937
|
}
|
|
10866
10938
|
get _value() {
|
|
10867
10939
|
return this.cursor === 0;
|
|
10868
10940
|
}
|
|
10869
|
-
constructor(
|
|
10870
|
-
super(
|
|
10941
|
+
constructor(t2) {
|
|
10942
|
+
super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
|
|
10871
10943
|
this.value = this._value;
|
|
10872
|
-
}), this.on("confirm", (
|
|
10873
|
-
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value =
|
|
10944
|
+
}), this.on("confirm", (i) => {
|
|
10945
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
10874
10946
|
}), this.on("cursor", () => {
|
|
10875
10947
|
this.value = !this.value;
|
|
10876
10948
|
});
|
|
10877
10949
|
}
|
|
10878
10950
|
};
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10951
|
+
_ = {
|
|
10952
|
+
Y: { type: "year", len: 4 },
|
|
10953
|
+
M: { type: "month", len: 2 },
|
|
10954
|
+
D: { type: "day", len: 2 }
|
|
10955
|
+
};
|
|
10956
|
+
U = class U extends V {
|
|
10957
|
+
#i;
|
|
10882
10958
|
#o;
|
|
10883
10959
|
#t;
|
|
10884
|
-
#
|
|
10885
|
-
#
|
|
10886
|
-
#
|
|
10887
|
-
#
|
|
10888
|
-
#
|
|
10960
|
+
#h;
|
|
10961
|
+
#u;
|
|
10962
|
+
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
10963
|
+
#n = true;
|
|
10964
|
+
#s = null;
|
|
10889
10965
|
inlineError = "";
|
|
10890
10966
|
get segmentCursor() {
|
|
10891
|
-
return { ...this.#
|
|
10967
|
+
return { ...this.#e };
|
|
10892
10968
|
}
|
|
10893
10969
|
get segmentValues() {
|
|
10894
10970
|
return { ...this.#t };
|
|
10895
10971
|
}
|
|
10896
10972
|
get segments() {
|
|
10897
|
-
return this.#
|
|
10973
|
+
return this.#i;
|
|
10898
10974
|
}
|
|
10899
10975
|
get separator() {
|
|
10900
10976
|
return this.#o;
|
|
10901
10977
|
}
|
|
10902
10978
|
get formattedValue() {
|
|
10903
|
-
return this.#
|
|
10904
|
-
}
|
|
10905
|
-
#
|
|
10906
|
-
return this.#
|
|
10907
|
-
}
|
|
10908
|
-
#
|
|
10909
|
-
this._setUserInput(this.#
|
|
10910
|
-
}
|
|
10911
|
-
constructor(
|
|
10912
|
-
const
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
const
|
|
10927
|
-
|
|
10979
|
+
return this.#l(this.#t);
|
|
10980
|
+
}
|
|
10981
|
+
#l(t2) {
|
|
10982
|
+
return this.#i.map((i) => t2[i.type]).join(this.#o);
|
|
10983
|
+
}
|
|
10984
|
+
#r() {
|
|
10985
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
|
|
10986
|
+
}
|
|
10987
|
+
constructor(t2) {
|
|
10988
|
+
const i = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i.separator, n = t2.format ? M(t2.format) : i.segments, e = t2.initialValue ?? t2.defaultValue, m2 = e ? {
|
|
10989
|
+
year: String(e.getUTCFullYear()).padStart(4, "0"),
|
|
10990
|
+
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
10991
|
+
day: String(e.getUTCDate()).padStart(2, "0")
|
|
10992
|
+
} : { year: "____", month: "__", day: "__" }, o = n.map((a) => m2[a.type]).join(s);
|
|
10993
|
+
super({ ...t2, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m2, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t2));
|
|
10994
|
+
}
|
|
10995
|
+
#a() {
|
|
10996
|
+
const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t2];
|
|
10997
|
+
if (i)
|
|
10998
|
+
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), { segment: i, index: t2 };
|
|
10999
|
+
}
|
|
11000
|
+
#m(t2) {
|
|
11001
|
+
this.inlineError = "", this.#s = null;
|
|
11002
|
+
const i = this.#a();
|
|
11003
|
+
i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
|
|
11004
|
+
}
|
|
11005
|
+
#d(t2) {
|
|
11006
|
+
const i = this.#a();
|
|
11007
|
+
if (!i)
|
|
10928
11008
|
return;
|
|
10929
|
-
const { segment: s } =
|
|
10930
|
-
let
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
11009
|
+
const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m2 = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f(this.#t), this.#h, this.#u);
|
|
11010
|
+
let a;
|
|
11011
|
+
e ? a = t2 === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m2 + t2), o.min), this.#t = {
|
|
11012
|
+
...this.#t,
|
|
11013
|
+
[s.type]: a.toString().padStart(s.len, "0")
|
|
11014
|
+
}, this.#n = true, this.#s = null, this.#r();
|
|
11015
|
+
}
|
|
11016
|
+
#f(t2) {
|
|
11017
|
+
if (t2)
|
|
11018
|
+
switch (t2) {
|
|
10936
11019
|
case "right":
|
|
10937
|
-
return this.#
|
|
11020
|
+
return this.#m(1);
|
|
10938
11021
|
case "left":
|
|
10939
|
-
return this.#
|
|
11022
|
+
return this.#m(-1);
|
|
10940
11023
|
case "up":
|
|
10941
|
-
return this.#
|
|
11024
|
+
return this.#d(1);
|
|
10942
11025
|
case "down":
|
|
10943
|
-
return this.#
|
|
11026
|
+
return this.#d(-1);
|
|
10944
11027
|
}
|
|
10945
11028
|
}
|
|
10946
|
-
#
|
|
10947
|
-
if (
|
|
11029
|
+
#y(t2, i) {
|
|
11030
|
+
if (i?.name === "backspace" || i?.sequence === "" || i?.sequence === "\b" || t2 === "" || t2 === "\b") {
|
|
10948
11031
|
this.inlineError = "";
|
|
10949
|
-
const
|
|
10950
|
-
if (!
|
|
11032
|
+
const n = this.#a();
|
|
11033
|
+
if (!n)
|
|
10951
11034
|
return;
|
|
10952
|
-
if (!this.#t[
|
|
10953
|
-
this.#
|
|
11035
|
+
if (!this.#t[n.segment.type].replace(/_/g, "")) {
|
|
11036
|
+
this.#m(-1);
|
|
10954
11037
|
return;
|
|
10955
11038
|
}
|
|
10956
|
-
this.#t[
|
|
11039
|
+
this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
|
|
10957
11040
|
return;
|
|
10958
11041
|
}
|
|
10959
|
-
if (
|
|
11042
|
+
if (i?.name === "tab") {
|
|
10960
11043
|
this.inlineError = "";
|
|
10961
|
-
const
|
|
10962
|
-
if (!
|
|
11044
|
+
const n = this.#a();
|
|
11045
|
+
if (!n)
|
|
10963
11046
|
return;
|
|
10964
|
-
const
|
|
10965
|
-
|
|
11047
|
+
const e = i.shift ? -1 : 1, m2 = n.index + e;
|
|
11048
|
+
m2 >= 0 && m2 < this.#i.length && (this.#e.segmentIndex = m2, this.#e.positionInSegment = 0, this.#n = true);
|
|
10966
11049
|
return;
|
|
10967
11050
|
}
|
|
10968
|
-
if (
|
|
10969
|
-
const
|
|
10970
|
-
if (!
|
|
11051
|
+
if (t2 && /^[0-9]$/.test(t2)) {
|
|
11052
|
+
const n = this.#a();
|
|
11053
|
+
if (!n)
|
|
10971
11054
|
return;
|
|
10972
|
-
const { segment:
|
|
10973
|
-
if (this.#
|
|
10974
|
-
const
|
|
10975
|
-
if (
|
|
10976
|
-
this.inlineError =
|
|
11055
|
+
const { segment: e } = n, m2 = !this.#t[e.type].replace(/_/g, "");
|
|
11056
|
+
if (this.#n && this.#s !== null && !m2) {
|
|
11057
|
+
const h = this.#s + t2, d = { ...this.#t, [e.type]: h }, g2 = this.#g(d, e);
|
|
11058
|
+
if (g2) {
|
|
11059
|
+
this.inlineError = g2, this.#s = null, this.#n = false;
|
|
10977
11060
|
return;
|
|
10978
11061
|
}
|
|
10979
|
-
this.inlineError = "", this.#t[
|
|
11062
|
+
this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
|
|
10980
11063
|
return;
|
|
10981
11064
|
}
|
|
10982
|
-
this.#
|
|
10983
|
-
const o = this.#t[
|
|
10984
|
-
if (
|
|
11065
|
+
this.#n && !m2 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
11066
|
+
const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
|
|
11067
|
+
if (u < 0 || u >= e.len)
|
|
10985
11068
|
return;
|
|
10986
|
-
let l = o.slice(0,
|
|
10987
|
-
if (
|
|
10988
|
-
const
|
|
10989
|
-
l = `0${
|
|
11069
|
+
let l = o.slice(0, u) + t2 + o.slice(u + 1), D = false;
|
|
11070
|
+
if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
|
|
11071
|
+
const h = Number.parseInt(t2, 10);
|
|
11072
|
+
l = `0${t2}`, D = h <= (e.type === "month" ? 1 : 2);
|
|
10990
11073
|
}
|
|
10991
|
-
if (
|
|
10992
|
-
const
|
|
10993
|
-
if (
|
|
10994
|
-
this.inlineError =
|
|
11074
|
+
if (e.type === "year" && (l = (o.replace(/_/g, "") + t2).padStart(e.len, "_")), !l.includes("_")) {
|
|
11075
|
+
const h = { ...this.#t, [e.type]: l }, d = this.#g(h, e);
|
|
11076
|
+
if (d) {
|
|
11077
|
+
this.inlineError = d;
|
|
10995
11078
|
return;
|
|
10996
11079
|
}
|
|
10997
11080
|
}
|
|
10998
|
-
this.inlineError = "", this.#t[
|
|
10999
|
-
const
|
|
11000
|
-
if (
|
|
11001
|
-
const { year:
|
|
11002
|
-
this.#t = {
|
|
11081
|
+
this.inlineError = "", this.#t[e.type] = l;
|
|
11082
|
+
const y = l.includes("_") ? undefined : b(this.#t);
|
|
11083
|
+
if (y) {
|
|
11084
|
+
const { year: h, month: d } = y, g2 = c(h, d);
|
|
11085
|
+
this.#t = {
|
|
11086
|
+
year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
|
|
11087
|
+
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
11088
|
+
day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
|
|
11089
|
+
};
|
|
11003
11090
|
}
|
|
11004
|
-
this.#
|
|
11005
|
-
const
|
|
11006
|
-
|
|
11007
|
-
}
|
|
11008
|
-
}
|
|
11009
|
-
#
|
|
11010
|
-
const { month: s, day:
|
|
11011
|
-
if (
|
|
11012
|
-
return
|
|
11013
|
-
if (
|
|
11014
|
-
return
|
|
11015
|
-
}
|
|
11016
|
-
#
|
|
11017
|
-
const { year:
|
|
11018
|
-
if (
|
|
11019
|
-
const
|
|
11020
|
-
this.#t = {
|
|
11091
|
+
this.#r();
|
|
11092
|
+
const S = l.indexOf("_");
|
|
11093
|
+
D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
|
|
11094
|
+
}
|
|
11095
|
+
}
|
|
11096
|
+
#g(t2, i) {
|
|
11097
|
+
const { month: s, day: n } = f(t2);
|
|
11098
|
+
if (i.type === "month" && (s < 0 || s > 12))
|
|
11099
|
+
return settings.date.messages.invalidMonth;
|
|
11100
|
+
if (i.type === "day" && (n < 0 || n > 31))
|
|
11101
|
+
return settings.date.messages.invalidDay(31, "any month");
|
|
11102
|
+
}
|
|
11103
|
+
#p(t2) {
|
|
11104
|
+
const { year: i, month: s, day: n } = f(this.#t);
|
|
11105
|
+
if (i && s && n) {
|
|
11106
|
+
const e = c(i, s);
|
|
11107
|
+
this.#t = {
|
|
11108
|
+
...this.#t,
|
|
11109
|
+
day: String(Math.min(n, e)).padStart(2, "0")
|
|
11110
|
+
};
|
|
11021
11111
|
}
|
|
11022
|
-
this.value =
|
|
11112
|
+
this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
|
|
11023
11113
|
}
|
|
11024
11114
|
};
|
|
11025
|
-
|
|
11115
|
+
u$1 = class u extends V {
|
|
11026
11116
|
options;
|
|
11027
11117
|
cursor = 0;
|
|
11028
|
-
#
|
|
11029
|
-
getGroupItems(
|
|
11030
|
-
return this.options.filter((
|
|
11118
|
+
#t;
|
|
11119
|
+
getGroupItems(t2) {
|
|
11120
|
+
return this.options.filter((r2) => r2.group === t2);
|
|
11031
11121
|
}
|
|
11032
|
-
isGroupSelected(
|
|
11033
|
-
const
|
|
11034
|
-
return
|
|
11122
|
+
isGroupSelected(t2) {
|
|
11123
|
+
const r2 = this.getGroupItems(t2), e = this.value;
|
|
11124
|
+
return e === undefined ? false : r2.every((s) => e.includes(s.value));
|
|
11035
11125
|
}
|
|
11036
11126
|
toggleValue() {
|
|
11037
|
-
const
|
|
11038
|
-
if (this.value === undefined && (this.value = []),
|
|
11039
|
-
const
|
|
11040
|
-
this.isGroupSelected(
|
|
11127
|
+
const t2 = this.options[this.cursor];
|
|
11128
|
+
if (this.value === undefined && (this.value = []), t2.group === true) {
|
|
11129
|
+
const r2 = t2.value, e = this.getGroupItems(r2);
|
|
11130
|
+
this.isGroupSelected(r2) ? this.value = this.value.filter((s) => e.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
11041
11131
|
} else {
|
|
11042
|
-
const
|
|
11043
|
-
this.value =
|
|
11044
|
-
}
|
|
11045
|
-
}
|
|
11046
|
-
constructor(
|
|
11047
|
-
super(
|
|
11048
|
-
const { options:
|
|
11049
|
-
this.#
|
|
11050
|
-
|
|
11132
|
+
const r2 = this.value.includes(t2.value);
|
|
11133
|
+
this.value = r2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
|
|
11134
|
+
}
|
|
11135
|
+
}
|
|
11136
|
+
constructor(t2) {
|
|
11137
|
+
super(t2, false);
|
|
11138
|
+
const { options: r2 } = t2;
|
|
11139
|
+
this.#t = t2.selectableGroups !== false, this.options = Object.entries(r2).flatMap(([e, s]) => [
|
|
11140
|
+
{ value: e, group: true, label: e },
|
|
11141
|
+
...s.map((i) => ({ ...i, group: e }))
|
|
11142
|
+
]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
|
|
11143
|
+
switch (e) {
|
|
11051
11144
|
case "left":
|
|
11052
11145
|
case "up": {
|
|
11053
11146
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
11054
|
-
const
|
|
11055
|
-
!this.#
|
|
11147
|
+
const s = this.options[this.cursor]?.group === true;
|
|
11148
|
+
!this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
11056
11149
|
break;
|
|
11057
11150
|
}
|
|
11058
11151
|
case "down":
|
|
11059
11152
|
case "right": {
|
|
11060
11153
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
11061
|
-
const
|
|
11062
|
-
!this.#
|
|
11154
|
+
const s = this.options[this.cursor]?.group === true;
|
|
11155
|
+
!this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
11063
11156
|
break;
|
|
11064
11157
|
}
|
|
11065
11158
|
case "space":
|
|
@@ -11069,45 +11162,129 @@ var init_dist4 = __esm(() => {
|
|
|
11069
11162
|
});
|
|
11070
11163
|
}
|
|
11071
11164
|
};
|
|
11072
|
-
|
|
11165
|
+
o$1 = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
11166
|
+
h = class h extends V {
|
|
11167
|
+
#t = false;
|
|
11168
|
+
#s;
|
|
11169
|
+
focused = "editor";
|
|
11170
|
+
get userInputWithCursor() {
|
|
11171
|
+
if (this.state === "submit")
|
|
11172
|
+
return this.userInput;
|
|
11173
|
+
const t2 = this.userInput;
|
|
11174
|
+
if (this.cursor >= t2.length)
|
|
11175
|
+
return `${t2}█`;
|
|
11176
|
+
const s = t2.slice(0, this.cursor), r2 = t2[this.cursor], i = t2.slice(this.cursor + 1);
|
|
11177
|
+
return r2 === `
|
|
11178
|
+
` ? `${s}█
|
|
11179
|
+
${i}` : `${s}${styleText("inverse", r2)}${i}`;
|
|
11180
|
+
}
|
|
11181
|
+
get cursor() {
|
|
11182
|
+
return this._cursor;
|
|
11183
|
+
}
|
|
11184
|
+
#r(t2) {
|
|
11185
|
+
if (this.userInput.length === 0) {
|
|
11186
|
+
this._setUserInput(t2);
|
|
11187
|
+
return;
|
|
11188
|
+
}
|
|
11189
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
|
|
11190
|
+
}
|
|
11191
|
+
#i(t2) {
|
|
11192
|
+
const s = this.value ?? "";
|
|
11193
|
+
switch (t2) {
|
|
11194
|
+
case "up":
|
|
11195
|
+
this._cursor = findTextCursor(this._cursor, 0, -1, s);
|
|
11196
|
+
return;
|
|
11197
|
+
case "down":
|
|
11198
|
+
this._cursor = findTextCursor(this._cursor, 0, 1, s);
|
|
11199
|
+
return;
|
|
11200
|
+
case "left":
|
|
11201
|
+
this._cursor = findTextCursor(this._cursor, -1, 0, s);
|
|
11202
|
+
return;
|
|
11203
|
+
case "right":
|
|
11204
|
+
this._cursor = findTextCursor(this._cursor, 1, 0, s);
|
|
11205
|
+
return;
|
|
11206
|
+
}
|
|
11207
|
+
}
|
|
11208
|
+
_shouldSubmit(t2, s) {
|
|
11209
|
+
if (this.#s)
|
|
11210
|
+
return this.focused === "submit" ? true : (this.#r(`
|
|
11211
|
+
`), this._cursor++, false);
|
|
11212
|
+
const r2 = this.#t;
|
|
11213
|
+
return this.#t = true, r2 && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
|
|
11214
|
+
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
|
|
11215
|
+
`), this._cursor++, false);
|
|
11216
|
+
}
|
|
11217
|
+
constructor(t2) {
|
|
11218
|
+
const s = t2.initialUserInput ?? t2.initialValue;
|
|
11219
|
+
super({
|
|
11220
|
+
...t2,
|
|
11221
|
+
initialUserInput: s
|
|
11222
|
+
}, false), s !== undefined && (this._cursor = s.length), this.#s = t2.showSubmit ?? false, this.on("key", (r2, i) => {
|
|
11223
|
+
if (i?.name && o$1.has(i.name)) {
|
|
11224
|
+
this.#t = false, this.#i(i.name);
|
|
11225
|
+
return;
|
|
11226
|
+
}
|
|
11227
|
+
if (r2 === "\t" && this.#s) {
|
|
11228
|
+
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
11229
|
+
return;
|
|
11230
|
+
}
|
|
11231
|
+
if (i?.name !== "return") {
|
|
11232
|
+
if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
|
|
11233
|
+
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
11234
|
+
return;
|
|
11235
|
+
}
|
|
11236
|
+
if (i?.name === "delete" && this.cursor < this.userInput.length) {
|
|
11237
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
11238
|
+
return;
|
|
11239
|
+
}
|
|
11240
|
+
r2 && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r2 ?? ""), this._cursor++);
|
|
11241
|
+
}
|
|
11242
|
+
}), this.on("userInput", (r2) => {
|
|
11243
|
+
this._setValue(r2);
|
|
11244
|
+
}), this.on("finalize", () => {
|
|
11245
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
11246
|
+
});
|
|
11247
|
+
}
|
|
11248
|
+
};
|
|
11249
|
+
a$1 = class a extends V {
|
|
11073
11250
|
options;
|
|
11074
11251
|
cursor = 0;
|
|
11075
11252
|
get _value() {
|
|
11076
11253
|
return this.options[this.cursor].value;
|
|
11077
11254
|
}
|
|
11078
11255
|
get _enabledOptions() {
|
|
11079
|
-
return this.options.filter((
|
|
11256
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
11080
11257
|
}
|
|
11081
11258
|
toggleAll() {
|
|
11082
|
-
const
|
|
11083
|
-
this.value =
|
|
11259
|
+
const e = this._enabledOptions, i = this.value !== undefined && this.value.length === e.length;
|
|
11260
|
+
this.value = i ? [] : e.map((t2) => t2.value);
|
|
11084
11261
|
}
|
|
11085
11262
|
toggleInvert() {
|
|
11086
|
-
const
|
|
11087
|
-
if (!
|
|
11263
|
+
const e = this.value;
|
|
11264
|
+
if (!e)
|
|
11088
11265
|
return;
|
|
11089
|
-
const
|
|
11090
|
-
this.value =
|
|
11266
|
+
const i = this._enabledOptions.filter((t2) => !e.includes(t2.value));
|
|
11267
|
+
this.value = i.map((t2) => t2.value);
|
|
11091
11268
|
}
|
|
11092
11269
|
toggleValue() {
|
|
11093
11270
|
this.value === undefined && (this.value = []);
|
|
11094
|
-
const
|
|
11095
|
-
this.value =
|
|
11096
|
-
}
|
|
11097
|
-
constructor(
|
|
11098
|
-
super(
|
|
11099
|
-
const
|
|
11100
|
-
this.cursor = this.options[
|
|
11101
|
-
|
|
11102
|
-
}), this.on("cursor", (
|
|
11103
|
-
switch (
|
|
11271
|
+
const e = this.value.includes(this._value);
|
|
11272
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
11273
|
+
}
|
|
11274
|
+
constructor(e) {
|
|
11275
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
11276
|
+
const i = Math.max(this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt), 0);
|
|
11277
|
+
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t2, l) => {
|
|
11278
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
11279
|
+
}), this.on("cursor", (t2) => {
|
|
11280
|
+
switch (t2) {
|
|
11104
11281
|
case "left":
|
|
11105
11282
|
case "up":
|
|
11106
|
-
this.cursor =
|
|
11283
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
11107
11284
|
break;
|
|
11108
11285
|
case "down":
|
|
11109
11286
|
case "right":
|
|
11110
|
-
this.cursor =
|
|
11287
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
11111
11288
|
break;
|
|
11112
11289
|
case "space":
|
|
11113
11290
|
this.toggleValue();
|
|
@@ -11116,7 +11293,7 @@ var init_dist4 = __esm(() => {
|
|
|
11116
11293
|
});
|
|
11117
11294
|
}
|
|
11118
11295
|
};
|
|
11119
|
-
|
|
11296
|
+
a2 = class a2 extends V {
|
|
11120
11297
|
options;
|
|
11121
11298
|
cursor = 0;
|
|
11122
11299
|
get _selectedValue() {
|
|
@@ -11125,361 +11302,475 @@ var init_dist4 = __esm(() => {
|
|
|
11125
11302
|
changeValue() {
|
|
11126
11303
|
this.value = this._selectedValue.value;
|
|
11127
11304
|
}
|
|
11128
|
-
constructor(
|
|
11129
|
-
super(
|
|
11130
|
-
const
|
|
11131
|
-
this.cursor = this.options[
|
|
11132
|
-
switch (
|
|
11305
|
+
constructor(t2) {
|
|
11306
|
+
super(t2, false), this.options = t2.options;
|
|
11307
|
+
const i = this.options.findIndex(({ value: s }) => s === t2.initialValue), e = i === -1 ? 0 : i;
|
|
11308
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
11309
|
+
switch (s) {
|
|
11133
11310
|
case "left":
|
|
11134
11311
|
case "up":
|
|
11135
|
-
this.cursor =
|
|
11312
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
11136
11313
|
break;
|
|
11137
11314
|
case "down":
|
|
11138
11315
|
case "right":
|
|
11139
|
-
this.cursor =
|
|
11316
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
11140
11317
|
break;
|
|
11141
11318
|
}
|
|
11142
11319
|
this.changeValue();
|
|
11143
11320
|
});
|
|
11144
11321
|
}
|
|
11145
11322
|
};
|
|
11146
|
-
|
|
11323
|
+
n = class n extends V {
|
|
11147
11324
|
get userInputWithCursor() {
|
|
11148
11325
|
if (this.state === "submit")
|
|
11149
11326
|
return this.userInput;
|
|
11150
|
-
const
|
|
11151
|
-
if (this.cursor >=
|
|
11327
|
+
const t2 = this.userInput;
|
|
11328
|
+
if (this.cursor >= t2.length)
|
|
11152
11329
|
return `${this.userInput}█`;
|
|
11153
|
-
const e =
|
|
11154
|
-
return `${e}${
|
|
11330
|
+
const e = t2.slice(0, this.cursor), [s, ...r2] = t2.slice(this.cursor);
|
|
11331
|
+
return `${e}${styleText("inverse", s)}${r2.join("")}`;
|
|
11155
11332
|
}
|
|
11156
11333
|
get cursor() {
|
|
11157
11334
|
return this._cursor;
|
|
11158
11335
|
}
|
|
11159
|
-
constructor(
|
|
11160
|
-
super({
|
|
11336
|
+
constructor(t2) {
|
|
11337
|
+
super({
|
|
11338
|
+
...t2,
|
|
11339
|
+
initialUserInput: t2.initialUserInput ?? t2.initialValue
|
|
11340
|
+
}), this.on("userInput", (e) => {
|
|
11161
11341
|
this._setValue(e);
|
|
11162
11342
|
}), this.on("finalize", () => {
|
|
11163
|
-
this.value || (this.value =
|
|
11343
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
11164
11344
|
});
|
|
11165
11345
|
}
|
|
11166
11346
|
};
|
|
11167
11347
|
});
|
|
11168
11348
|
|
|
11169
|
-
// ../../node_modules/.bun/@clack+prompts@1.
|
|
11170
|
-
import { styleText as
|
|
11171
|
-
import
|
|
11172
|
-
function
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11349
|
+
// ../../node_modules/.bun/@clack+prompts@1.6.0/node_modules/@clack/prompts/dist/index.mjs
|
|
11350
|
+
import { styleText as styleText2, stripVTControlCharacters } from "node:util";
|
|
11351
|
+
import process$1 from "node:process";
|
|
11352
|
+
function isUnicodeSupported() {
|
|
11353
|
+
if (process$1.platform !== "win32") {
|
|
11354
|
+
return process$1.env.TERM !== "linux";
|
|
11355
|
+
}
|
|
11356
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
11357
|
+
}
|
|
11358
|
+
function formatInstructionFooter(o2, e) {
|
|
11359
|
+
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" • ")}`];
|
|
11360
|
+
return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
|
|
11361
|
+
}
|
|
11362
|
+
var import_sisteransi2, unicode, unicodeOr = (o2, e) => unicode ? o2 : e, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR_START, S_BAR, S_BAR_END, S_BAR_START_RIGHT, S_BAR_END_RIGHT, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, S_PASSWORD_MASK, S_BAR_H, S_CORNER_TOP_RIGHT, S_CONNECT_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_BOTTOM_LEFT, S_CORNER_TOP_LEFT, S_INFO, S_SUCCESS, S_WARN, S_ERROR, symbol = (o2) => {
|
|
11363
|
+
switch (o2) {
|
|
11177
11364
|
case "initial":
|
|
11178
11365
|
case "active":
|
|
11179
|
-
return
|
|
11366
|
+
return styleText2("cyan", S_STEP_ACTIVE);
|
|
11180
11367
|
case "cancel":
|
|
11181
|
-
return
|
|
11368
|
+
return styleText2("red", S_STEP_CANCEL);
|
|
11182
11369
|
case "error":
|
|
11183
|
-
return
|
|
11370
|
+
return styleText2("yellow", S_STEP_ERROR);
|
|
11184
11371
|
case "submit":
|
|
11185
|
-
return
|
|
11372
|
+
return styleText2("green", S_STEP_SUBMIT);
|
|
11186
11373
|
}
|
|
11187
|
-
},
|
|
11188
|
-
switch (
|
|
11374
|
+
}, symbolBar = (o2) => {
|
|
11375
|
+
switch (o2) {
|
|
11189
11376
|
case "initial":
|
|
11190
11377
|
case "active":
|
|
11191
|
-
return
|
|
11378
|
+
return styleText2("cyan", S_BAR);
|
|
11192
11379
|
case "cancel":
|
|
11193
|
-
return
|
|
11380
|
+
return styleText2("red", S_BAR);
|
|
11194
11381
|
case "error":
|
|
11195
|
-
return
|
|
11382
|
+
return styleText2("yellow", S_BAR);
|
|
11196
11383
|
case "submit":
|
|
11197
|
-
return
|
|
11198
|
-
}
|
|
11199
|
-
},
|
|
11200
|
-
let
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11384
|
+
return styleText2("green", S_BAR);
|
|
11385
|
+
}
|
|
11386
|
+
}, E$1 = (l, o2, g2, c2, h2, O = false) => {
|
|
11387
|
+
let r2 = o2, w = 0;
|
|
11388
|
+
if (O)
|
|
11389
|
+
for (let i = c2 - 1;i >= g2 && (r2 -= l[i].length, w++, !(r2 <= h2)); i--)
|
|
11390
|
+
;
|
|
11391
|
+
else
|
|
11392
|
+
for (let i = g2;i < c2 && (r2 -= l[i].length, w++, !(r2 <= h2)); i++)
|
|
11393
|
+
;
|
|
11394
|
+
return { lineCount: r2, removals: w };
|
|
11395
|
+
}, limitOptions = ({
|
|
11396
|
+
cursor: l,
|
|
11397
|
+
options: o2,
|
|
11398
|
+
style: g2,
|
|
11399
|
+
output: c2 = process.stdout,
|
|
11400
|
+
maxItems: h2 = Number.POSITIVE_INFINITY,
|
|
11401
|
+
columnPadding: O = 0,
|
|
11402
|
+
rowPadding: r2 = 4
|
|
11403
|
+
}) => {
|
|
11404
|
+
const i = getColumns(c2) - O, I = getRows(c2), C2 = styleText2("dim", "..."), x = Math.max(I - r2, 0), m2 = Math.max(Math.min(h2, x), 5);
|
|
11209
11405
|
let p2 = 0;
|
|
11210
|
-
|
|
11211
|
-
let
|
|
11212
|
-
const
|
|
11213
|
-
let
|
|
11214
|
-
|
|
11215
|
-
const v = p2 + (
|
|
11216
|
-
for (let
|
|
11217
|
-
const
|
|
11406
|
+
l >= m2 - 3 && (p2 = Math.max(Math.min(l - m2 + 3, o2.length - m2), 0));
|
|
11407
|
+
let f2 = m2 < o2.length && p2 > 0, u3 = m2 < o2.length && p2 + m2 < o2.length;
|
|
11408
|
+
const W = Math.min(p2 + m2, o2.length), e = [];
|
|
11409
|
+
let d = 0;
|
|
11410
|
+
f2 && d++, u3 && d++;
|
|
11411
|
+
const v = p2 + (f2 ? 1 : 0), P2 = W - (u3 ? 1 : 0);
|
|
11412
|
+
for (let t2 = v;t2 < P2; t2++) {
|
|
11413
|
+
const n2 = wrapAnsi(g2(o2[t2], t2 === l), i, {
|
|
11414
|
+
hard: true,
|
|
11415
|
+
trim: false
|
|
11416
|
+
}).split(`
|
|
11218
11417
|
`);
|
|
11219
|
-
|
|
11220
|
-
}
|
|
11221
|
-
if (
|
|
11222
|
-
let
|
|
11223
|
-
const M2 =
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11418
|
+
e.push(n2), d += n2.length;
|
|
11419
|
+
}
|
|
11420
|
+
if (d > x) {
|
|
11421
|
+
let t2 = 0, n2 = 0, s = d;
|
|
11422
|
+
const M2 = l - v;
|
|
11423
|
+
let a3 = x;
|
|
11424
|
+
const T3 = () => E$1(e, s, 0, M2, a3), L = () => E$1(e, s, M2 + 1, e.length, a3, true);
|
|
11425
|
+
f2 ? ({ lineCount: s, removals: t2 } = T3(), s > a3 && (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L())) : (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L(), s > a3 && (a3 -= 1, { lineCount: s, removals: t2 } = T3())), t2 > 0 && (f2 = true, e.splice(0, t2)), n2 > 0 && (u3 = true, e.splice(e.length - n2, n2));
|
|
11426
|
+
}
|
|
11427
|
+
const b2 = [];
|
|
11428
|
+
f2 && b2.push(C2);
|
|
11429
|
+
for (const t2 of e)
|
|
11430
|
+
for (const n2 of t2)
|
|
11431
|
+
b2.push(n2);
|
|
11432
|
+
return u3 && b2.push(C2), b2;
|
|
11433
|
+
}, confirm = (i) => {
|
|
11434
|
+
const a3 = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
11435
|
+
return new r({
|
|
11436
|
+
active: a3,
|
|
11437
|
+
inactive: s,
|
|
11438
|
+
signal: i.signal,
|
|
11439
|
+
input: i.input,
|
|
11440
|
+
output: i.output,
|
|
11441
|
+
initialValue: i.initialValue ?? true,
|
|
11442
|
+
render() {
|
|
11443
|
+
const e = i.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l = e ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(i.output, i.message, l, u3), o2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
11444
|
+
` : ""}${f2}
|
|
11445
|
+
`, c2 = this.value ? a3 : s;
|
|
11446
|
+
switch (this.state) {
|
|
11447
|
+
case "submit": {
|
|
11448
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
11449
|
+
return `${o2}${r2}${styleText2("dim", c2)}`;
|
|
11450
|
+
}
|
|
11451
|
+
case "cancel": {
|
|
11452
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
11453
|
+
return `${o2}${r2}${styleText2(["strikethrough", "dim"], c2)}${e ? `
|
|
11454
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
11455
|
+
}
|
|
11456
|
+
default: {
|
|
11457
|
+
const r2 = e ? `${styleText2("cyan", S_BAR)} ` : "", g2 = e ? styleText2("cyan", S_BAR_END) : "";
|
|
11458
|
+
return `${o2}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a3}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a3)}`}${i.vertical ? e ? `
|
|
11459
|
+
${styleText2("cyan", S_BAR)} ` : `
|
|
11460
|
+
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", s)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${s}`}
|
|
11461
|
+
${g2}
|
|
11254
11462
|
`;
|
|
11463
|
+
}
|
|
11255
11464
|
}
|
|
11256
11465
|
}
|
|
11257
|
-
}
|
|
11258
|
-
},
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
`)
|
|
11304
|
-
`),
|
|
11305
|
-
`).length, y2 = l.split(`
|
|
11466
|
+
}).prompt();
|
|
11467
|
+
}, MULTISELECT_INSTRUCTIONS, m2 = (n2, o2) => n2.split(`
|
|
11468
|
+
`).map((d) => o2(d)).join(`
|
|
11469
|
+
`), multiselect = (n2) => {
|
|
11470
|
+
const o2 = (t2, a3) => {
|
|
11471
|
+
const r2 = t2.label ?? String(t2.value);
|
|
11472
|
+
return a3 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m2(r2, (l) => styleText2(["strikethrough", "gray"], l))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a3 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a3 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m2(r2, (l) => styleText2("dim", l))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a3 === "cancelled" ? `${m2(r2, (l) => styleText2(["strikethrough", "dim"], l))}` : a3 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a3 === "submitted" ? `${m2(r2, (l) => styleText2("dim", l))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m2(r2, (l) => styleText2("dim", l))}`;
|
|
11473
|
+
}, d = n2.required ?? true;
|
|
11474
|
+
return new a$1({
|
|
11475
|
+
options: n2.options,
|
|
11476
|
+
signal: n2.signal,
|
|
11477
|
+
input: n2.input,
|
|
11478
|
+
output: n2.output,
|
|
11479
|
+
initialValues: n2.initialValues,
|
|
11480
|
+
required: d,
|
|
11481
|
+
cursorAt: n2.cursorAt,
|
|
11482
|
+
validate(t2) {
|
|
11483
|
+
if (d && (t2 === undefined || t2.length === 0))
|
|
11484
|
+
return `Please select at least one option.
|
|
11485
|
+
${styleText2("reset", styleText2("dim", `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2("gray", styleText2("bgWhite", styleText2("inverse", " enter ")))} to submit`))}`;
|
|
11486
|
+
},
|
|
11487
|
+
render() {
|
|
11488
|
+
const t2 = n2.withGuide ?? settings.withGuide, a3 = wrapTextWithPrefix(n2.output, n2.message, t2 ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
11489
|
+
` : ""}${a3}
|
|
11490
|
+
`, l = this.value ?? [], p2 = (i, u3) => {
|
|
11491
|
+
if (i.disabled)
|
|
11492
|
+
return o2(i, "disabled");
|
|
11493
|
+
const s = l.includes(i.value);
|
|
11494
|
+
return u3 && s ? o2(i, "active-selected") : s ? o2(i, "selected") : o2(i, u3 ? "active" : "inactive");
|
|
11495
|
+
};
|
|
11496
|
+
switch (this.state) {
|
|
11497
|
+
case "submit": {
|
|
11498
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => o2(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), u3 = wrapTextWithPrefix(n2.output, i, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
11499
|
+
return `${r2}${u3}`;
|
|
11500
|
+
}
|
|
11501
|
+
case "cancel": {
|
|
11502
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => o2(s, "cancelled")).join(styleText2("dim", ", "));
|
|
11503
|
+
if (i.trim() === "")
|
|
11504
|
+
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
11505
|
+
const u3 = wrapTextWithPrefix(n2.output, i, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
11506
|
+
return `${r2}${u3}${t2 ? `
|
|
11507
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
11508
|
+
}
|
|
11509
|
+
case "error": {
|
|
11510
|
+
const i = t2 ? `${styleText2("yellow", S_BAR)} ` : "", u3 = this.error.split(`
|
|
11511
|
+
`).map(($, x) => x === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`).join(`
|
|
11512
|
+
`), s = r2.split(`
|
|
11513
|
+
`).length, g2 = u3.split(`
|
|
11306
11514
|
`).length + 1;
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11515
|
+
return `${r2}${i}${limitOptions({
|
|
11516
|
+
output: n2.output,
|
|
11517
|
+
options: this.options,
|
|
11518
|
+
cursor: this.cursor,
|
|
11519
|
+
maxItems: n2.maxItems,
|
|
11520
|
+
columnPadding: i.length,
|
|
11521
|
+
rowPadding: s + g2,
|
|
11522
|
+
style: p2
|
|
11523
|
+
}).join(`
|
|
11524
|
+
${i}`)}
|
|
11525
|
+
${u3}
|
|
11310
11526
|
`;
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
`).length,
|
|
11315
|
-
|
|
11316
|
-
${
|
|
11317
|
-
|
|
11527
|
+
}
|
|
11528
|
+
default: {
|
|
11529
|
+
const i = t2 ? `${styleText2("cyan", S_BAR)} ` : "", u3 = r2.split(`
|
|
11530
|
+
`).length, s = formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2), g2 = s.join(`
|
|
11531
|
+
`), $ = s.length + 1;
|
|
11532
|
+
return `${r2}${i}${limitOptions({
|
|
11533
|
+
output: n2.output,
|
|
11534
|
+
options: this.options,
|
|
11535
|
+
cursor: this.cursor,
|
|
11536
|
+
maxItems: n2.maxItems,
|
|
11537
|
+
columnPadding: i.length,
|
|
11538
|
+
rowPadding: u3 + $,
|
|
11539
|
+
style: p2
|
|
11540
|
+
}).join(`
|
|
11541
|
+
${i}`)}
|
|
11542
|
+
${g2}
|
|
11318
11543
|
`;
|
|
11544
|
+
}
|
|
11319
11545
|
}
|
|
11320
11546
|
}
|
|
11321
|
-
}
|
|
11322
|
-
},
|
|
11323
|
-
const
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
},
|
|
11327
|
-
const
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11547
|
+
}).prompt();
|
|
11548
|
+
}, log2, intro = (o2 = "", t2) => {
|
|
11549
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
11550
|
+
i.write(`${e}${o2}
|
|
11551
|
+
`);
|
|
11552
|
+
}, outro = (o2 = "", t2) => {
|
|
11553
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
11554
|
+
${styleText2("gray", S_BAR_END)} ` : "";
|
|
11555
|
+
i.write(`${e}${o2}
|
|
11556
|
+
|
|
11557
|
+
`);
|
|
11558
|
+
}, W$1 = (o2) => o2, C2 = (o2, e, s) => {
|
|
11559
|
+
const a3 = {
|
|
11560
|
+
hard: true,
|
|
11561
|
+
trim: false
|
|
11562
|
+
}, i = wrapAnsi(o2, e, a3).split(`
|
|
11563
|
+
`), c2 = i.reduce((n2, t2) => Math.max(dist_default2(t2), n2), 0), u3 = i.map(s).reduce((n2, t2) => Math.max(dist_default2(t2), n2), 0), g2 = e - (u3 - c2);
|
|
11564
|
+
return wrapAnsi(o2, g2, a3);
|
|
11565
|
+
}, note = (o2 = "", e = "", s) => {
|
|
11566
|
+
const a3 = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c2 = s?.format ?? W$1, g2 = ["", ...C2(o2, getColumns(a3) - 6, c2).split(`
|
|
11567
|
+
`).map(c2), ""], n2 = dist_default2(e), t2 = Math.max(g2.reduce((m3, F) => {
|
|
11568
|
+
const O = dist_default2(F);
|
|
11569
|
+
return O > m3 ? O : m3;
|
|
11570
|
+
}, 0), n2) + 2, h2 = g2.map((m3) => `${styleText2("gray", S_BAR)} ${m3}${" ".repeat(t2 - dist_default2(m3))}${styleText2("gray", S_BAR)}`).join(`
|
|
11571
|
+
`), T3 = i ? `${styleText2("gray", S_BAR)}
|
|
11572
|
+
` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
11573
|
+
a3.write(`${T3}${styleText2("green", S_STEP_SUBMIT)} ${styleText2("reset", e)} ${styleText2("gray", S_BAR_H.repeat(Math.max(t2 - n2 - 1, 1)) + S_CORNER_TOP_RIGHT)}
|
|
11574
|
+
${h2}
|
|
11575
|
+
${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
11337
11576
|
`);
|
|
11338
|
-
},
|
|
11339
|
-
`) ?
|
|
11340
|
-
`).map((
|
|
11341
|
-
`) :
|
|
11342
|
-
const
|
|
11343
|
-
const
|
|
11344
|
-
switch (
|
|
11577
|
+
}, u3, SELECT_INSTRUCTIONS, c2 = (t2, a3) => t2.includes(`
|
|
11578
|
+
`) ? t2.split(`
|
|
11579
|
+
`).map((i) => a3(i)).join(`
|
|
11580
|
+
`) : a3(t2), select = (t2) => {
|
|
11581
|
+
const a3 = (i, m3) => {
|
|
11582
|
+
const s = i.label ?? String(i.value);
|
|
11583
|
+
switch (m3) {
|
|
11345
11584
|
case "disabled":
|
|
11346
|
-
return `${
|
|
11585
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("gray", n2))}${i.hint ? ` ${styleText2("dim", `(${i.hint ?? "disabled"})`)}` : ""}`;
|
|
11347
11586
|
case "selected":
|
|
11348
|
-
return `${
|
|
11587
|
+
return `${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
11349
11588
|
case "active":
|
|
11350
|
-
return `${
|
|
11589
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${i.hint ? ` ${styleText2("dim", `(${i.hint})`)}` : ""}`;
|
|
11351
11590
|
case "cancelled":
|
|
11352
|
-
return `${
|
|
11591
|
+
return `${c2(s, (n2) => styleText2(["strikethrough", "dim"], n2))}`;
|
|
11353
11592
|
default:
|
|
11354
|
-
return `${
|
|
11593
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
11355
11594
|
}
|
|
11356
11595
|
};
|
|
11357
|
-
return new
|
|
11358
|
-
|
|
11359
|
-
|
|
11596
|
+
return new a2({
|
|
11597
|
+
options: t2.options,
|
|
11598
|
+
signal: t2.signal,
|
|
11599
|
+
input: t2.input,
|
|
11600
|
+
output: t2.output,
|
|
11601
|
+
initialValue: t2.initialValue,
|
|
11602
|
+
render() {
|
|
11603
|
+
const i = t2.withGuide ?? settings.withGuide, m3 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n2 = wrapTextWithPrefix(t2.output, t2.message, s, m3), u4 = `${i ? `${styleText2("gray", S_BAR)}
|
|
11604
|
+
` : ""}${n2}
|
|
11360
11605
|
`;
|
|
11606
|
+
switch (this.state) {
|
|
11607
|
+
case "submit": {
|
|
11608
|
+
const r2 = i ? `${styleText2("gray", S_BAR)} ` : "", o2 = wrapTextWithPrefix(t2.output, a3(this.options[this.cursor], "selected"), r2);
|
|
11609
|
+
return `${u4}${o2}`;
|
|
11610
|
+
}
|
|
11611
|
+
case "cancel": {
|
|
11612
|
+
const r2 = i ? `${styleText2("gray", S_BAR)} ` : "", o2 = wrapTextWithPrefix(t2.output, a3(this.options[this.cursor], "cancelled"), r2);
|
|
11613
|
+
return `${u4}${o2}${i ? `
|
|
11614
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
11615
|
+
}
|
|
11616
|
+
default: {
|
|
11617
|
+
const r2 = i ? `${styleText2("cyan", S_BAR)} ` : "", o2 = u4.split(`
|
|
11618
|
+
`).length, $ = formatInstructionFooter(SELECT_INSTRUCTIONS, i), h2 = $.join(`
|
|
11619
|
+
`), b2 = $.length + 1;
|
|
11620
|
+
return `${u4}${r2}${limitOptions({
|
|
11621
|
+
output: t2.output,
|
|
11622
|
+
cursor: this.cursor,
|
|
11623
|
+
options: this.options,
|
|
11624
|
+
maxItems: t2.maxItems,
|
|
11625
|
+
columnPadding: r2.length,
|
|
11626
|
+
rowPadding: o2 + b2,
|
|
11627
|
+
style: (p2, x) => a3(p2, p2.disabled ? "disabled" : x ? "active" : "inactive")
|
|
11628
|
+
}).join(`
|
|
11629
|
+
${r2}`)}
|
|
11630
|
+
${h2}
|
|
11631
|
+
`;
|
|
11632
|
+
}
|
|
11633
|
+
}
|
|
11634
|
+
}
|
|
11635
|
+
}).prompt();
|
|
11636
|
+
}, i, text = (t2) => new n({
|
|
11637
|
+
validate: t2.validate,
|
|
11638
|
+
placeholder: t2.placeholder,
|
|
11639
|
+
defaultValue: t2.defaultValue,
|
|
11640
|
+
initialValue: t2.initialValue,
|
|
11641
|
+
output: t2.output,
|
|
11642
|
+
signal: t2.signal,
|
|
11643
|
+
input: t2.input,
|
|
11644
|
+
render() {
|
|
11645
|
+
const i2 = t2?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${styleText2("gray", S_BAR)}
|
|
11646
|
+
` : ""}${symbol(this.state)} `}${t2.message}
|
|
11647
|
+
`, c3 = t2.placeholder ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : c3, a3 = this.value ?? "";
|
|
11361
11648
|
switch (this.state) {
|
|
11649
|
+
case "error": {
|
|
11650
|
+
const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i2 ? `${styleText2("yellow", S_BAR)} ` : "", d = i2 ? styleText2("yellow", S_BAR_END) : "";
|
|
11651
|
+
return `${s.trim()}
|
|
11652
|
+
${r2}${o2}
|
|
11653
|
+
${d}${n2}
|
|
11654
|
+
`;
|
|
11655
|
+
}
|
|
11362
11656
|
case "submit": {
|
|
11363
|
-
const
|
|
11364
|
-
return `${
|
|
11657
|
+
const n2 = a3 ? ` ${styleText2("dim", a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
11658
|
+
return `${s}${r2}${n2}`;
|
|
11365
11659
|
}
|
|
11366
11660
|
case "cancel": {
|
|
11367
|
-
const
|
|
11368
|
-
return `${
|
|
11369
|
-
${
|
|
11661
|
+
const n2 = a3 ? ` ${styleText2(["strikethrough", "dim"], a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
11662
|
+
return `${s}${r2}${n2}${a3.trim() ? `
|
|
11663
|
+
${r2}` : ""}`;
|
|
11370
11664
|
}
|
|
11371
11665
|
default: {
|
|
11372
|
-
const
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
${c2}`)}
|
|
11376
|
-
${a}
|
|
11666
|
+
const n2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "";
|
|
11667
|
+
return `${s}${n2}${o2}
|
|
11668
|
+
${r2}
|
|
11377
11669
|
`;
|
|
11378
11670
|
}
|
|
11379
11671
|
}
|
|
11380
|
-
} }).prompt();
|
|
11381
|
-
}, je, Ot = (e) => new at({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
|
|
11382
|
-
const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${t("gray", d2)}
|
|
11383
|
-
` : ""}${V2(this.state)} `}${e.message}
|
|
11384
|
-
`, r = e.placeholder ? t("inverse", e.placeholder[0]) + t("dim", e.placeholder.slice(1)) : t(["inverse", "hidden"], "_"), u2 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
11385
|
-
switch (this.state) {
|
|
11386
|
-
case "error": {
|
|
11387
|
-
const o = this.error ? ` ${t("yellow", this.error)}` : "", c2 = i ? `${t("yellow", d2)} ` : "", a = i ? t("yellow", E2) : "";
|
|
11388
|
-
return `${s.trim()}
|
|
11389
|
-
${c2}${u2}
|
|
11390
|
-
${a}${o}
|
|
11391
|
-
`;
|
|
11392
|
-
}
|
|
11393
|
-
case "submit": {
|
|
11394
|
-
const o = n ? ` ${t("dim", n)}` : "", c2 = i ? t("gray", d2) : "";
|
|
11395
|
-
return `${s}${c2}${o}`;
|
|
11396
|
-
}
|
|
11397
|
-
case "cancel": {
|
|
11398
|
-
const o = n ? ` ${t(["strikethrough", "dim"], n)}` : "", c2 = i ? t("gray", d2) : "";
|
|
11399
|
-
return `${s}${c2}${o}${n.trim() ? `
|
|
11400
|
-
${c2}` : ""}`;
|
|
11401
|
-
}
|
|
11402
|
-
default: {
|
|
11403
|
-
const o = i ? `${t("cyan", d2)} ` : "", c2 = i ? t("cyan", E2) : "";
|
|
11404
|
-
return `${s}${o}${u2}
|
|
11405
|
-
${c2}
|
|
11406
|
-
`;
|
|
11407
|
-
}
|
|
11408
11672
|
}
|
|
11409
|
-
}
|
|
11673
|
+
}).prompt();
|
|
11410
11674
|
var init_dist5 = __esm(() => {
|
|
11411
11675
|
init_dist4();
|
|
11412
11676
|
init_dist4();
|
|
11413
11677
|
init_main();
|
|
11414
11678
|
init_dist3();
|
|
11415
11679
|
import_sisteransi2 = __toESM(require_src3(), 1);
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11680
|
+
unicode = isUnicodeSupported();
|
|
11681
|
+
S_STEP_ACTIVE = unicodeOr("◆", "*");
|
|
11682
|
+
S_STEP_CANCEL = unicodeOr("■", "x");
|
|
11683
|
+
S_STEP_ERROR = unicodeOr("▲", "x");
|
|
11684
|
+
S_STEP_SUBMIT = unicodeOr("◇", "o");
|
|
11685
|
+
S_BAR_START = unicodeOr("┌", "T");
|
|
11686
|
+
S_BAR = unicodeOr("│", "|");
|
|
11687
|
+
S_BAR_END = unicodeOr("└", "—");
|
|
11688
|
+
S_BAR_START_RIGHT = unicodeOr("┐", "T");
|
|
11689
|
+
S_BAR_END_RIGHT = unicodeOr("┘", "—");
|
|
11690
|
+
S_RADIO_ACTIVE = unicodeOr("●", ">");
|
|
11691
|
+
S_RADIO_INACTIVE = unicodeOr("○", " ");
|
|
11692
|
+
S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
|
|
11693
|
+
S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
|
|
11694
|
+
S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
|
|
11695
|
+
S_PASSWORD_MASK = unicodeOr("▪", "•");
|
|
11696
|
+
S_BAR_H = unicodeOr("─", "-");
|
|
11697
|
+
S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
|
|
11698
|
+
S_CONNECT_LEFT = unicodeOr("├", "+");
|
|
11699
|
+
S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
|
|
11700
|
+
S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
|
|
11701
|
+
S_CORNER_TOP_LEFT = unicodeOr("╭", "+");
|
|
11702
|
+
S_INFO = unicodeOr("●", "•");
|
|
11703
|
+
S_SUCCESS = unicodeOr("◆", "*");
|
|
11704
|
+
S_WARN = unicodeOr("▲", "!");
|
|
11705
|
+
S_ERROR = unicodeOr("■", "x");
|
|
11706
|
+
MULTISELECT_INSTRUCTIONS = [
|
|
11707
|
+
`${styleText2("dim", "↑/↓")} to navigate`,
|
|
11708
|
+
`${styleText2("dim", "Space:")} select`,
|
|
11709
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
11710
|
+
];
|
|
11711
|
+
log2 = {
|
|
11712
|
+
message: (s = [], {
|
|
11713
|
+
symbol: e = styleText2("gray", S_BAR),
|
|
11714
|
+
secondarySymbol: r2 = styleText2("gray", S_BAR),
|
|
11715
|
+
output: m3 = process.stdout,
|
|
11716
|
+
spacing: l = 1,
|
|
11717
|
+
withGuide: c2
|
|
11718
|
+
} = {}) => {
|
|
11719
|
+
const t2 = [], o2 = c2 ?? settings.withGuide, f2 = o2 ? r2 : "", O = o2 ? `${e} ` : "", u3 = o2 ? `${r2} ` : "";
|
|
11720
|
+
for (let i = 0;i < l; i++)
|
|
11721
|
+
t2.push(f2);
|
|
11722
|
+
const g2 = Array.isArray(s) ? s : s.split(`
|
|
11447
11723
|
`);
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11724
|
+
if (g2.length > 0) {
|
|
11725
|
+
const [i, ...y] = g2;
|
|
11726
|
+
i.length > 0 ? t2.push(`${O}${i}`) : t2.push(o2 ? e : "");
|
|
11727
|
+
for (const p2 of y)
|
|
11728
|
+
p2.length > 0 ? t2.push(`${u3}${p2}`) : t2.push(o2 ? r2 : "");
|
|
11729
|
+
}
|
|
11730
|
+
m3.write(`${t2.join(`
|
|
11455
11731
|
`)}
|
|
11456
11732
|
`);
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11733
|
+
},
|
|
11734
|
+
info: (s, e) => {
|
|
11735
|
+
log2.message(s, { ...e, symbol: styleText2("blue", S_INFO) });
|
|
11736
|
+
},
|
|
11737
|
+
success: (s, e) => {
|
|
11738
|
+
log2.message(s, { ...e, symbol: styleText2("green", S_SUCCESS) });
|
|
11739
|
+
},
|
|
11740
|
+
step: (s, e) => {
|
|
11741
|
+
log2.message(s, { ...e, symbol: styleText2("green", S_STEP_SUBMIT) });
|
|
11742
|
+
},
|
|
11743
|
+
warn: (s, e) => {
|
|
11744
|
+
log2.message(s, { ...e, symbol: styleText2("yellow", S_WARN) });
|
|
11745
|
+
},
|
|
11746
|
+
warning: (s, e) => {
|
|
11747
|
+
log2.warn(s, e);
|
|
11748
|
+
},
|
|
11749
|
+
error: (s, e) => {
|
|
11750
|
+
log2.message(s, { ...e, symbol: styleText2("red", S_ERROR) });
|
|
11751
|
+
}
|
|
11752
|
+
};
|
|
11753
|
+
u3 = {
|
|
11754
|
+
light: unicodeOr("─", "-"),
|
|
11755
|
+
heavy: unicodeOr("━", "="),
|
|
11756
|
+
block: unicodeOr("█", "#")
|
|
11757
|
+
};
|
|
11758
|
+
SELECT_INSTRUCTIONS = [
|
|
11759
|
+
`${styleText2("dim", "↑/↓")} to navigate`,
|
|
11760
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
11761
|
+
];
|
|
11762
|
+
i = `${styleText2("gray", S_BAR)} `;
|
|
11472
11763
|
});
|
|
11473
11764
|
|
|
11474
11765
|
// src/lib/prompts.ts
|
|
11475
11766
|
function handleCancel(value, message = "Cancelled.") {
|
|
11476
|
-
if (
|
|
11477
|
-
|
|
11767
|
+
if (isCancel(value)) {
|
|
11768
|
+
log2.warn(message);
|
|
11478
11769
|
process.exit(0);
|
|
11479
11770
|
}
|
|
11480
11771
|
}
|
|
11481
|
-
async function
|
|
11482
|
-
const result = await
|
|
11772
|
+
async function confirm2(message, defaultYes = true) {
|
|
11773
|
+
const result = await confirm({
|
|
11483
11774
|
message,
|
|
11484
11775
|
initialValue: defaultYes
|
|
11485
11776
|
});
|
|
@@ -11492,13 +11783,13 @@ async function selectOne(message, options) {
|
|
|
11492
11783
|
const label = option.recommended ? `${option.label} (recommended)` : option.label;
|
|
11493
11784
|
return hint === undefined ? { label, value: option.value } : { label, value: option.value, hint };
|
|
11494
11785
|
});
|
|
11495
|
-
const result = await
|
|
11786
|
+
const result = await select({ message, options: clackOptions });
|
|
11496
11787
|
handleCancel(result);
|
|
11497
11788
|
return result;
|
|
11498
11789
|
}
|
|
11499
11790
|
async function selectMany(message, options, initialValues, required = true) {
|
|
11500
11791
|
const clackOptions = options.map((option) => option.hint === undefined ? { label: option.label, value: option.value } : { label: option.label, value: option.value, hint: option.hint });
|
|
11501
|
-
const result = await
|
|
11792
|
+
const result = await multiselect({
|
|
11502
11793
|
message,
|
|
11503
11794
|
options: clackOptions,
|
|
11504
11795
|
...initialValues ? { initialValues } : {},
|
|
@@ -11507,7 +11798,7 @@ async function selectMany(message, options, initialValues, required = true) {
|
|
|
11507
11798
|
handleCancel(result);
|
|
11508
11799
|
return result;
|
|
11509
11800
|
}
|
|
11510
|
-
async function
|
|
11801
|
+
async function text2(message, options = {}) {
|
|
11511
11802
|
const promptOptions = {
|
|
11512
11803
|
message,
|
|
11513
11804
|
...options.placeholder ? { placeholder: options.placeholder } : {},
|
|
@@ -11516,7 +11807,7 @@ async function text(message, options = {}) {
|
|
|
11516
11807
|
validate: (value) => options.validate?.(value ?? "")
|
|
11517
11808
|
} : {}
|
|
11518
11809
|
};
|
|
11519
|
-
const result = await
|
|
11810
|
+
const result = await text(promptOptions);
|
|
11520
11811
|
handleCancel(result);
|
|
11521
11812
|
return result;
|
|
11522
11813
|
}
|
|
@@ -11540,7 +11831,7 @@ async function resolveAdaptersForCommand(argv, options) {
|
|
|
11540
11831
|
return [getAdapter(flag)];
|
|
11541
11832
|
const installed = getInstalledAdapters();
|
|
11542
11833
|
if (installed.length === 0) {
|
|
11543
|
-
|
|
11834
|
+
log2.warn("No supported harness was detected on PATH (opencode, pi).");
|
|
11544
11835
|
const pick = await selectOne("Which harness do you want to configure?", [
|
|
11545
11836
|
{
|
|
11546
11837
|
label: "OpenCode",
|
|
@@ -11556,7 +11847,7 @@ async function resolveAdaptersForCommand(argv, options) {
|
|
|
11556
11847
|
return [getAdapter(pick)];
|
|
11557
11848
|
}
|
|
11558
11849
|
if (installed.length === 1) {
|
|
11559
|
-
|
|
11850
|
+
log2.info(`Detected ${installed[0].displayName} — using it for ${options.verb}.`);
|
|
11560
11851
|
return installed;
|
|
11561
11852
|
}
|
|
11562
11853
|
if (!options.allowMulti) {
|
|
@@ -11571,7 +11862,7 @@ async function resolveAdaptersForCommand(argv, options) {
|
|
|
11571
11862
|
label: adapter.displayName,
|
|
11572
11863
|
value: adapter.kind,
|
|
11573
11864
|
hint: adapter.pluginPackageName
|
|
11574
|
-
})), installed.map((
|
|
11865
|
+
})), installed.map((a3) => a3.kind));
|
|
11575
11866
|
return picks.map((kind) => getAdapter(kind));
|
|
11576
11867
|
}
|
|
11577
11868
|
function getAllRegistryAdapters() {
|
|
@@ -11633,57 +11924,57 @@ __export(exports_setup, {
|
|
|
11633
11924
|
runSetup: () => runSetup
|
|
11634
11925
|
});
|
|
11635
11926
|
async function runSetup(argv) {
|
|
11636
|
-
|
|
11927
|
+
intro("AFT setup");
|
|
11637
11928
|
const adapters = await resolveAdaptersForCommand(argv, {
|
|
11638
11929
|
allowMulti: true,
|
|
11639
11930
|
verb: "setup"
|
|
11640
11931
|
});
|
|
11641
11932
|
let anyFailure = false;
|
|
11642
11933
|
for (const adapter of adapters) {
|
|
11643
|
-
|
|
11934
|
+
log2.info(`${adapter.displayName}: configuring ${adapter.pluginPackageName}…`);
|
|
11644
11935
|
if (!adapter.isInstalled()) {
|
|
11645
|
-
|
|
11936
|
+
log2.warn(`${adapter.displayName} host not found on PATH. ${adapter.getInstallHint()} and rerun \`aft setup\`.`);
|
|
11646
11937
|
anyFailure = true;
|
|
11647
11938
|
continue;
|
|
11648
11939
|
}
|
|
11649
11940
|
const result = await adapter.ensurePluginEntry();
|
|
11650
11941
|
if (!result.ok) {
|
|
11651
|
-
|
|
11942
|
+
log2.error(`${adapter.displayName}: ${result.message}`);
|
|
11652
11943
|
anyFailure = true;
|
|
11653
11944
|
continue;
|
|
11654
11945
|
}
|
|
11655
11946
|
switch (result.action) {
|
|
11656
11947
|
case "already_present":
|
|
11657
|
-
|
|
11948
|
+
log2.success(`${adapter.displayName}: already set up (${result.configPath})`);
|
|
11658
11949
|
break;
|
|
11659
11950
|
case "added":
|
|
11660
11951
|
case "updated":
|
|
11661
|
-
|
|
11952
|
+
log2.success(`${adapter.displayName}: ${result.message}`);
|
|
11662
11953
|
break;
|
|
11663
11954
|
default:
|
|
11664
|
-
|
|
11955
|
+
log2.info(`${adapter.displayName}: ${result.message}`);
|
|
11665
11956
|
}
|
|
11666
11957
|
try {
|
|
11667
11958
|
const { aftConfig, aftConfigFormat } = adapter.detectConfigPaths();
|
|
11668
11959
|
const schemaResult = ensureAftSchemaUrl(aftConfig, aftConfigFormat);
|
|
11669
11960
|
if (schemaResult.action === "added" || schemaResult.action === "updated") {
|
|
11670
|
-
|
|
11961
|
+
log2.success(`${adapter.displayName}: ${schemaResult.message}`);
|
|
11671
11962
|
}
|
|
11672
11963
|
} catch (error2) {
|
|
11673
|
-
|
|
11964
|
+
log2.warn(`${adapter.displayName}: could not set $schema on aft.jsonc: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
11674
11965
|
}
|
|
11675
11966
|
printNextSteps(adapter);
|
|
11676
11967
|
}
|
|
11677
11968
|
if (anyFailure) {
|
|
11678
|
-
|
|
11969
|
+
outro("Setup finished with warnings — see above.");
|
|
11679
11970
|
return 1;
|
|
11680
11971
|
}
|
|
11681
|
-
|
|
11972
|
+
outro("Done.");
|
|
11682
11973
|
return 0;
|
|
11683
11974
|
}
|
|
11684
11975
|
function printNextSteps(adapter) {
|
|
11685
11976
|
if (adapter.kind === "opencode") {
|
|
11686
|
-
|
|
11977
|
+
note([
|
|
11687
11978
|
"Restart OpenCode (or reload your session) so the plugin loads.",
|
|
11688
11979
|
"Verify with: `npx @cortexkit/aft doctor`."
|
|
11689
11980
|
].join(`
|
|
@@ -11691,7 +11982,7 @@ function printNextSteps(adapter) {
|
|
|
11691
11982
|
return;
|
|
11692
11983
|
}
|
|
11693
11984
|
if (adapter.kind === "pi") {
|
|
11694
|
-
|
|
11985
|
+
note([
|
|
11695
11986
|
"Restart your Pi session so the extension registers.",
|
|
11696
11987
|
"Verify with: `npx @cortexkit/aft doctor`."
|
|
11697
11988
|
].join(`
|
|
@@ -11722,7 +12013,7 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
11722
12013
|
});
|
|
11723
12014
|
const responses = [];
|
|
11724
12015
|
const noiseLines = [];
|
|
11725
|
-
let
|
|
12016
|
+
let stdout2 = "";
|
|
11726
12017
|
let stderr = "";
|
|
11727
12018
|
let settled = false;
|
|
11728
12019
|
const finish = (fn) => {
|
|
@@ -11758,14 +12049,14 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
11758
12049
|
};
|
|
11759
12050
|
child.stdout.setEncoding("utf-8");
|
|
11760
12051
|
child.stdout.on("data", (chunk) => {
|
|
11761
|
-
|
|
12052
|
+
stdout2 += chunk;
|
|
11762
12053
|
while (true) {
|
|
11763
|
-
const newline =
|
|
12054
|
+
const newline = stdout2.indexOf(`
|
|
11764
12055
|
`);
|
|
11765
12056
|
if (newline === -1)
|
|
11766
12057
|
break;
|
|
11767
|
-
const line =
|
|
11768
|
-
|
|
12058
|
+
const line = stdout2.slice(0, newline).trim();
|
|
12059
|
+
stdout2 = stdout2.slice(newline + 1);
|
|
11769
12060
|
handleLine(line);
|
|
11770
12061
|
if (settled)
|
|
11771
12062
|
break;
|
|
@@ -11868,13 +12159,13 @@ async function runLspDoctor(options) {
|
|
|
11868
12159
|
});
|
|
11869
12160
|
const adapter = adapters[0];
|
|
11870
12161
|
if (!adapter) {
|
|
11871
|
-
|
|
12162
|
+
log2.error("No harness selected.");
|
|
11872
12163
|
return 1;
|
|
11873
12164
|
}
|
|
11874
12165
|
const findBinary2 = options.findBinary ?? findAftBinary;
|
|
11875
12166
|
const binary = findBinary2(getSelfVersion());
|
|
11876
12167
|
if (!binary) {
|
|
11877
|
-
|
|
12168
|
+
log2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
11878
12169
|
return 1;
|
|
11879
12170
|
}
|
|
11880
12171
|
const resolvedFile = resolve5(file);
|
|
@@ -11888,16 +12179,16 @@ async function runLspDoctor(options) {
|
|
|
11888
12179
|
const responses = options.sendRequests ? await options.sendRequests(binary, [config, inspectRequest]) : options.sendRequest ? [await options.sendRequest(binary, inspectRequest)] : await sendAftRequests(binary, [config, inspectRequest]);
|
|
11889
12180
|
const configure = responses.length > 1 ? responses[0] : undefined;
|
|
11890
12181
|
if (configure && !configure.success) {
|
|
11891
|
-
|
|
12182
|
+
log2.error(configure.message ?? configure.code ?? "configure failed");
|
|
11892
12183
|
return 1;
|
|
11893
12184
|
}
|
|
11894
12185
|
const inspect = responses[responses.length - 1];
|
|
11895
12186
|
if (!inspect) {
|
|
11896
|
-
|
|
12187
|
+
log2.error("aft exited before returning lsp_inspect response");
|
|
11897
12188
|
return 1;
|
|
11898
12189
|
}
|
|
11899
12190
|
if (!inspect.success) {
|
|
11900
|
-
|
|
12191
|
+
log2.error(inspect.message ?? inspect.code ?? "lsp_inspect failed");
|
|
11901
12192
|
return 1;
|
|
11902
12193
|
}
|
|
11903
12194
|
console.log(renderLspInspection(file, inspect));
|
|
@@ -11949,10 +12240,10 @@ function renderLspInspection(inputFile, response) {
|
|
|
11949
12240
|
`);
|
|
11950
12241
|
}
|
|
11951
12242
|
function parseFileArg(argv) {
|
|
11952
|
-
for (let
|
|
11953
|
-
const arg = argv[
|
|
12243
|
+
for (let i2 = 0;i2 < argv.length; i2 += 1) {
|
|
12244
|
+
const arg = argv[i2];
|
|
11954
12245
|
if (arg === "--harness") {
|
|
11955
|
-
|
|
12246
|
+
i2 += 1;
|
|
11956
12247
|
continue;
|
|
11957
12248
|
}
|
|
11958
12249
|
if (arg.startsWith("--"))
|
|
@@ -12095,19 +12386,19 @@ async function runDoctorFilters(options) {
|
|
|
12095
12386
|
});
|
|
12096
12387
|
const adapter = adapters[0];
|
|
12097
12388
|
if (!adapter) {
|
|
12098
|
-
|
|
12389
|
+
log2.error("No harness selected.");
|
|
12099
12390
|
return 1;
|
|
12100
12391
|
}
|
|
12101
12392
|
const findBinary2 = options.findBinary ?? findAftBinary;
|
|
12102
12393
|
const binary = findBinary2(getSelfVersion());
|
|
12103
12394
|
if (!binary) {
|
|
12104
|
-
|
|
12395
|
+
log2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
12105
12396
|
return 1;
|
|
12106
12397
|
}
|
|
12107
12398
|
const projectRoot = resolve6(process.cwd());
|
|
12108
12399
|
const list = await listFilters(binary, adapter, projectRoot, options.sendRequests ?? sendAftRequests);
|
|
12109
12400
|
if (!list.success) {
|
|
12110
|
-
|
|
12401
|
+
log2.error(list.message ?? list.code ?? "list_filters failed");
|
|
12111
12402
|
return 1;
|
|
12112
12403
|
}
|
|
12113
12404
|
list.project_dir_exists = list.project_dir ? existsSync9(list.project_dir) : false;
|
|
@@ -12118,7 +12409,7 @@ async function runDoctorFilters(options) {
|
|
|
12118
12409
|
if (mode.kind === "show") {
|
|
12119
12410
|
const rendered = renderFilterShow(list, mode.name, projectRoot);
|
|
12120
12411
|
if (!rendered) {
|
|
12121
|
-
|
|
12412
|
+
log2.error(`Filter not found: ${mode.name}`);
|
|
12122
12413
|
return 1;
|
|
12123
12414
|
}
|
|
12124
12415
|
console.log(rendered);
|
|
@@ -12177,7 +12468,7 @@ async function runTrustFlow(binary, list, adapter, projectRoot, options) {
|
|
|
12177
12468
|
]);
|
|
12178
12469
|
const trust = responses[responses.length - 1];
|
|
12179
12470
|
if (!trust?.success) {
|
|
12180
|
-
|
|
12471
|
+
log2.error(trust?.message ?? trust?.code ?? "trust_filter_project failed");
|
|
12181
12472
|
return 1;
|
|
12182
12473
|
}
|
|
12183
12474
|
console.log("Trusted 1 project(s). Restart AFT (or reconfigure) for filters to take effect.");
|
|
@@ -12206,7 +12497,7 @@ async function runUntrustFlow(binary, list, adapter, projectRoot, options) {
|
|
|
12206
12497
|
const responses = await (options.sendRequests ?? sendAftRequests)(binary, requests);
|
|
12207
12498
|
const failures = responses.slice(1).filter((response) => !response.success);
|
|
12208
12499
|
if (failures.length > 0) {
|
|
12209
|
-
|
|
12500
|
+
log2.error(failures[0]?.message ?? failures[0]?.code ?? "untrust_filter_project failed");
|
|
12210
12501
|
return 1;
|
|
12211
12502
|
}
|
|
12212
12503
|
console.log(`Untrusted ${selected.length} project(s). Restart AFT (or reconfigure) for filters to take effect.`);
|
|
@@ -12523,11 +12814,11 @@ function aggregateBridgeToolFailures(logText) {
|
|
|
12523
12814
|
}
|
|
12524
12815
|
return counts;
|
|
12525
12816
|
}
|
|
12526
|
-
function sortFailureKeys(
|
|
12527
|
-
const countDiff = (counts.get(
|
|
12817
|
+
function sortFailureKeys(a3, b2, counts) {
|
|
12818
|
+
const countDiff = (counts.get(b2) ?? 0) - (counts.get(a3) ?? 0);
|
|
12528
12819
|
if (countDiff !== 0)
|
|
12529
12820
|
return countDiff;
|
|
12530
|
-
return
|
|
12821
|
+
return a3.localeCompare(b2);
|
|
12531
12822
|
}
|
|
12532
12823
|
function formatRecentAftToolFailuresSection(counts, options) {
|
|
12533
12824
|
const maxClasses = options?.maxClasses ?? MAX_TOOL_FAILURE_CLASSES;
|
|
@@ -12536,7 +12827,7 @@ function formatRecentAftToolFailuresSection(counts, options) {
|
|
|
12536
12827
|
return `${heading}
|
|
12537
12828
|
No recent AFT tool failures recorded.`;
|
|
12538
12829
|
}
|
|
12539
|
-
const sorted = [...counts.keys()].sort((
|
|
12830
|
+
const sorted = [...counts.keys()].sort((a3, b2) => sortFailureKeys(a3, b2, counts));
|
|
12540
12831
|
const shown = sorted.slice(0, maxClasses);
|
|
12541
12832
|
const hidden = sorted.length - shown.length;
|
|
12542
12833
|
const bullets = shown.map((key) => {
|
|
@@ -12592,7 +12883,7 @@ function inspectDir(path) {
|
|
|
12592
12883
|
totalSize += size;
|
|
12593
12884
|
} catch {}
|
|
12594
12885
|
}
|
|
12595
|
-
entries.sort((
|
|
12886
|
+
entries.sort((a3, b2) => b2.size - a3.size);
|
|
12596
12887
|
return { entries, totalSize };
|
|
12597
12888
|
}
|
|
12598
12889
|
function getLspCacheReport() {
|
|
@@ -12648,20 +12939,20 @@ function getOnnxLibraryName() {
|
|
|
12648
12939
|
}
|
|
12649
12940
|
function getManualInstallHint2() {
|
|
12650
12941
|
const p2 = process.platform;
|
|
12651
|
-
const
|
|
12942
|
+
const a3 = process.arch;
|
|
12652
12943
|
if (p2 === "darwin") {
|
|
12653
|
-
if (
|
|
12944
|
+
if (a3 === "arm64")
|
|
12654
12945
|
return "brew install onnxruntime (Apple Silicon)";
|
|
12655
12946
|
return "Intel Mac requires manual install — see docs";
|
|
12656
12947
|
}
|
|
12657
12948
|
if (p2 === "linux") {
|
|
12658
|
-
if (
|
|
12949
|
+
if (a3 === "x64" || a3 === "arm64") {
|
|
12659
12950
|
return "AFT auto-downloads ONNX Runtime on supported Linux (glibc)";
|
|
12660
12951
|
}
|
|
12661
12952
|
return "manual install required for this Linux arch";
|
|
12662
12953
|
}
|
|
12663
12954
|
if (p2 === "win32") {
|
|
12664
|
-
if (
|
|
12955
|
+
if (a3 === "x64" || a3 === "arm64")
|
|
12665
12956
|
return "AFT auto-downloads ONNX Runtime on Windows";
|
|
12666
12957
|
return "manual install required for this Windows arch";
|
|
12667
12958
|
}
|
|
@@ -12922,42 +13213,42 @@ function renderDiagnosticsMarkdown(report) {
|
|
|
12922
13213
|
lines.push(`- **${issue.severity.toUpperCase()}** ${issue.scope}: ${issue.message} Remediation: ${issue.remediation}`);
|
|
12923
13214
|
}
|
|
12924
13215
|
}
|
|
12925
|
-
for (const
|
|
13216
|
+
for (const h2 of report.harnesses) {
|
|
12926
13217
|
lines.push("");
|
|
12927
|
-
lines.push(`### ${
|
|
12928
|
-
lines.push(`- Host installed: ${
|
|
12929
|
-
lines.push(`- Host version: ${
|
|
12930
|
-
lines.push(`- Plugin registered: ${
|
|
12931
|
-
lines.push(`- Plugin version: ${
|
|
12932
|
-
lines.push(`- AFT config parse error: ${
|
|
13218
|
+
lines.push(`### ${h2.displayName}`);
|
|
13219
|
+
lines.push(`- Host installed: ${h2.hostInstalled}`);
|
|
13220
|
+
lines.push(`- Host version: ${h2.hostVersion ?? "unknown"}`);
|
|
13221
|
+
lines.push(`- Plugin registered: ${h2.pluginRegistered}`);
|
|
13222
|
+
lines.push(`- Plugin version: ${h2.pluginCache.cached ?? "not installed"}`);
|
|
13223
|
+
lines.push(`- AFT config parse error: ${h2.aftConfig.parseError ?? "none"}`);
|
|
12933
13224
|
lines.push("");
|
|
12934
13225
|
lines.push("#### Config paths");
|
|
12935
13226
|
lines.push("```json");
|
|
12936
|
-
lines.push(JSON.stringify(
|
|
13227
|
+
lines.push(JSON.stringify(h2.configPaths, null, 2));
|
|
12937
13228
|
lines.push("```");
|
|
12938
13229
|
lines.push("");
|
|
12939
13230
|
lines.push("#### AFT flags");
|
|
12940
13231
|
lines.push("```json");
|
|
12941
|
-
lines.push(JSON.stringify(
|
|
13232
|
+
lines.push(JSON.stringify(h2.aftConfig.flags, null, 2));
|
|
12942
13233
|
lines.push("```");
|
|
12943
13234
|
lines.push("");
|
|
12944
13235
|
lines.push("#### Plugin cache");
|
|
12945
13236
|
lines.push("```json");
|
|
12946
|
-
lines.push(JSON.stringify(
|
|
13237
|
+
lines.push(JSON.stringify(h2.pluginCache, null, 2));
|
|
12947
13238
|
lines.push("```");
|
|
12948
13239
|
lines.push("");
|
|
12949
13240
|
lines.push("#### Storage");
|
|
12950
13241
|
lines.push("```json");
|
|
12951
|
-
lines.push(JSON.stringify(
|
|
13242
|
+
lines.push(JSON.stringify(h2.storageDir, null, 2));
|
|
12952
13243
|
lines.push("```");
|
|
12953
13244
|
lines.push("");
|
|
12954
13245
|
lines.push("#### ONNX Runtime");
|
|
12955
13246
|
lines.push("```json");
|
|
12956
|
-
lines.push(JSON.stringify(
|
|
13247
|
+
lines.push(JSON.stringify(h2.onnxRuntime, null, 2));
|
|
12957
13248
|
lines.push("```");
|
|
12958
13249
|
lines.push("");
|
|
12959
13250
|
lines.push(`#### Log file`);
|
|
12960
|
-
lines.push(`\`${
|
|
13251
|
+
lines.push(`\`${h2.logFile.path}\` (${h2.logFile.exists ? `${h2.logFile.sizeKb} KB` : "missing"})`);
|
|
12961
13252
|
}
|
|
12962
13253
|
lines.push("");
|
|
12963
13254
|
lines.push("### Binary cache");
|
|
@@ -12975,12 +13266,12 @@ function renderDiagnosticsMarkdown(report) {
|
|
|
12975
13266
|
function normalizeVersion(version) {
|
|
12976
13267
|
return version.trim().replace(/^v/, "");
|
|
12977
13268
|
}
|
|
12978
|
-
function compareLooseSemver(
|
|
12979
|
-
const aParts = normalizeVersion(
|
|
12980
|
-
const bParts = normalizeVersion(
|
|
12981
|
-
for (let
|
|
12982
|
-
const av = Number.isFinite(aParts[
|
|
12983
|
-
const bv = Number.isFinite(bParts[
|
|
13269
|
+
function compareLooseSemver(a3, b2) {
|
|
13270
|
+
const aParts = normalizeVersion(a3).split(/[.-]/).slice(0, 3).map((part) => Number.parseInt(part, 10));
|
|
13271
|
+
const bParts = normalizeVersion(b2).split(/[.-]/).slice(0, 3).map((part) => Number.parseInt(part, 10));
|
|
13272
|
+
for (let i2 = 0;i2 < 3; i2 += 1) {
|
|
13273
|
+
const av = Number.isFinite(aParts[i2]) ? aParts[i2] : 0;
|
|
13274
|
+
const bv = Number.isFinite(bParts[i2]) ? bParts[i2] : 0;
|
|
12984
13275
|
if (av !== bv)
|
|
12985
13276
|
return av - bv;
|
|
12986
13277
|
}
|
|
@@ -13018,63 +13309,63 @@ function collectDiagnosticIssues(report) {
|
|
|
13018
13309
|
remediation: "Run `aft doctor --fix` to download the matching binary, or start an AFT-enabled session to trigger plugin-side install."
|
|
13019
13310
|
});
|
|
13020
13311
|
}
|
|
13021
|
-
for (const
|
|
13022
|
-
if (!
|
|
13312
|
+
for (const h2 of report.harnesses) {
|
|
13313
|
+
if (!h2.hostInstalled) {
|
|
13023
13314
|
issues.push({
|
|
13024
13315
|
code: "host_missing",
|
|
13025
13316
|
severity: "high",
|
|
13026
|
-
scope:
|
|
13317
|
+
scope: h2.displayName,
|
|
13027
13318
|
message: "Host CLI is not installed or is not on PATH.",
|
|
13028
|
-
remediation: `Install ${
|
|
13319
|
+
remediation: `Install ${h2.displayName} and rerun \`aft doctor\`.`
|
|
13029
13320
|
});
|
|
13030
13321
|
continue;
|
|
13031
13322
|
}
|
|
13032
|
-
if (!
|
|
13323
|
+
if (!h2.pluginRegistered) {
|
|
13033
13324
|
issues.push({
|
|
13034
13325
|
code: "plugin_missing",
|
|
13035
13326
|
severity: "medium",
|
|
13036
|
-
scope:
|
|
13327
|
+
scope: h2.displayName,
|
|
13037
13328
|
message: "AFT plugin is not registered with this harness.",
|
|
13038
13329
|
remediation: "Run `aft setup` or `aft doctor --fix` to register the plugin."
|
|
13039
13330
|
});
|
|
13040
13331
|
}
|
|
13041
|
-
if (
|
|
13332
|
+
if (h2.aftConfig.parseError) {
|
|
13042
13333
|
issues.push({
|
|
13043
13334
|
code: "config_parse_error",
|
|
13044
13335
|
severity: "high",
|
|
13045
|
-
scope:
|
|
13046
|
-
message: `AFT config parse error: ${
|
|
13047
|
-
remediation: `Fix JSON/JSONC syntax in ${
|
|
13336
|
+
scope: h2.displayName,
|
|
13337
|
+
message: `AFT config parse error: ${h2.aftConfig.parseError}`,
|
|
13338
|
+
remediation: `Fix JSON/JSONC syntax in ${h2.configPaths.aftConfig}.`
|
|
13048
13339
|
});
|
|
13049
13340
|
}
|
|
13050
|
-
const skewIssue = pluginVersionSkewIssue(
|
|
13341
|
+
const skewIssue = pluginVersionSkewIssue(h2, report.cliVersion);
|
|
13051
13342
|
if (skewIssue)
|
|
13052
13343
|
issues.push(skewIssue);
|
|
13053
|
-
if (
|
|
13054
|
-
if (!
|
|
13344
|
+
if (h2.onnxRuntime.required) {
|
|
13345
|
+
if (!h2.onnxRuntime.cachedPath && !h2.onnxRuntime.systemPath) {
|
|
13055
13346
|
issues.push({
|
|
13056
13347
|
code: "onnx_missing",
|
|
13057
13348
|
severity: "medium",
|
|
13058
|
-
scope:
|
|
13349
|
+
scope: h2.displayName,
|
|
13059
13350
|
message: "ONNX Runtime is required for semantic search but was not detected.",
|
|
13060
|
-
remediation: `Run \`aft doctor --fix\` or install ONNX Runtime manually (${
|
|
13351
|
+
remediation: `Run \`aft doctor --fix\` or install ONNX Runtime manually (${h2.onnxRuntime.installHint}).`
|
|
13061
13352
|
});
|
|
13062
13353
|
}
|
|
13063
|
-
if (
|
|
13354
|
+
if (h2.onnxRuntime.cachedCompatible === false) {
|
|
13064
13355
|
issues.push({
|
|
13065
13356
|
code: "onnx_incompatible",
|
|
13066
13357
|
severity: "medium",
|
|
13067
|
-
scope:
|
|
13068
|
-
message: `Cached ONNX Runtime ${
|
|
13358
|
+
scope: h2.displayName,
|
|
13359
|
+
message: `Cached ONNX Runtime ${h2.onnxRuntime.cachedVersion ?? "unknown"} is incompatible (requires ${h2.onnxRuntime.requirement}).`,
|
|
13069
13360
|
remediation: "Run `aft doctor --fix` to refresh AFT-managed ONNX Runtime state."
|
|
13070
13361
|
});
|
|
13071
13362
|
}
|
|
13072
|
-
if (
|
|
13363
|
+
if (h2.onnxRuntime.systemCompatible === false) {
|
|
13073
13364
|
issues.push({
|
|
13074
13365
|
code: "onnx_incompatible",
|
|
13075
13366
|
severity: "medium",
|
|
13076
|
-
scope:
|
|
13077
|
-
message: `System ONNX Runtime ${
|
|
13367
|
+
scope: h2.displayName,
|
|
13368
|
+
message: `System ONNX Runtime ${h2.onnxRuntime.systemVersion ?? "unknown"} is incompatible (requires ${h2.onnxRuntime.requirement}).`,
|
|
13078
13369
|
remediation: "Install a compatible ONNX Runtime or let AFT use its managed runtime."
|
|
13079
13370
|
});
|
|
13080
13371
|
}
|
|
@@ -13116,8 +13407,8 @@ function tailLogFile(path, lines) {
|
|
|
13116
13407
|
const bytesRead = readSync3(fd, buffer, 0, readLength, position);
|
|
13117
13408
|
const chunk = bytesRead === readLength ? buffer : buffer.subarray(0, bytesRead);
|
|
13118
13409
|
chunks.unshift(chunk);
|
|
13119
|
-
for (let
|
|
13120
|
-
if (chunk[
|
|
13410
|
+
for (let i2 = chunk.length - 1;i2 >= 0; i2 -= 1) {
|
|
13411
|
+
if (chunk[i2] === 10)
|
|
13121
13412
|
newlineCount += 1;
|
|
13122
13413
|
}
|
|
13123
13414
|
}
|
|
@@ -13196,9 +13487,9 @@ function isErrorLogLine(line) {
|
|
|
13196
13487
|
function extractRecentErrors(sanitized, limit = 20) {
|
|
13197
13488
|
const matches = [];
|
|
13198
13489
|
const lines = sanitized.split(/\r?\n/);
|
|
13199
|
-
for (let
|
|
13200
|
-
if (isErrorLogLine(lines[
|
|
13201
|
-
matches.push(lines[
|
|
13490
|
+
for (let i2 = lines.length - 1;i2 >= 0 && matches.length < limit; i2 -= 1) {
|
|
13491
|
+
if (isErrorLogLine(lines[i2])) {
|
|
13492
|
+
matches.push(lines[i2]);
|
|
13202
13493
|
}
|
|
13203
13494
|
}
|
|
13204
13495
|
return matches.reverse();
|
|
@@ -13224,7 +13515,7 @@ function capBodyToGithubLimit(body, maxBytes = MAX_GITHUB_BODY_BYTES) {
|
|
|
13224
13515
|
const logBlockStart = headingEol + 1;
|
|
13225
13516
|
const logBlockEnd = nextSectionIdx === -1 ? body.length : nextSectionIdx;
|
|
13226
13517
|
const head = body.slice(0, logBlockStart);
|
|
13227
|
-
const
|
|
13518
|
+
const log3 = body.slice(logBlockStart, logBlockEnd);
|
|
13228
13519
|
const tail = body.slice(logBlockEnd);
|
|
13229
13520
|
const overheadBytes = Buffer.byteLength(head, "utf8") + Buffer.byteLength(tail, "utf8");
|
|
13230
13521
|
const truncationMarker = `[truncated for GitHub 64KB limit — older log lines dropped]
|
|
@@ -13234,7 +13525,7 @@ function capBodyToGithubLimit(body, maxBytes = MAX_GITHUB_BODY_BYTES) {
|
|
|
13234
13525
|
if (logBudget <= 0) {
|
|
13235
13526
|
return `${head}${truncationMarker}${tail}`;
|
|
13236
13527
|
}
|
|
13237
|
-
const lines =
|
|
13528
|
+
const lines = log3.split(`
|
|
13238
13529
|
`);
|
|
13239
13530
|
let keepLines = lines;
|
|
13240
13531
|
let kept = keepLines.join(`
|
|
@@ -13321,42 +13612,42 @@ async function runOnnxFix(adapters, report, options = {}) {
|
|
|
13321
13612
|
if (candidates.length === 0) {
|
|
13322
13613
|
return null;
|
|
13323
13614
|
}
|
|
13324
|
-
|
|
13325
|
-
for (const
|
|
13326
|
-
|
|
13327
|
-
if (
|
|
13328
|
-
|
|
13615
|
+
log2.warn(`Found ${candidates.length} ONNX Runtime issue(s) that --fix can address by clearing AFT-managed cache:`);
|
|
13616
|
+
for (const c3 of candidates) {
|
|
13617
|
+
log2.info(` • ${c3.harness.displayName}: ${c3.reason}`);
|
|
13618
|
+
if (c3.storageOnnxBytes > 0) {
|
|
13619
|
+
log2.info(` will delete: ${c3.storageOnnxDir} (${formatBytes(c3.storageOnnxBytes)})`);
|
|
13329
13620
|
} else {
|
|
13330
|
-
|
|
13621
|
+
log2.info(` no AFT-managed ONNX cache to delete; nothing to reclaim`);
|
|
13331
13622
|
}
|
|
13332
13623
|
}
|
|
13333
|
-
|
|
13334
|
-
const confirmFn = options.confirmFn ??
|
|
13624
|
+
note("This NEVER touches system paths like /usr/lib. It only deletes AFT's own ONNX download cache. " + "On next bridge start, AFT will re-download ONNX Runtime v1.24 and use that instead of the " + "incompatible system library.", "Safe operation");
|
|
13625
|
+
const confirmFn = options.confirmFn ?? confirm2;
|
|
13335
13626
|
const proceed = options.yes ? true : await confirmFn("Proceed with the fixes above?", true);
|
|
13336
13627
|
if (!proceed) {
|
|
13337
|
-
|
|
13628
|
+
log2.info("Skipped — no changes made.");
|
|
13338
13629
|
return null;
|
|
13339
13630
|
}
|
|
13340
13631
|
const result = { cleared: 0, bytesReclaimed: 0, errors: [] };
|
|
13341
13632
|
const rmFn = options.rmFn ?? rmSync3;
|
|
13342
|
-
for (const
|
|
13343
|
-
if (!existsSync15(
|
|
13344
|
-
|
|
13633
|
+
for (const c3 of candidates) {
|
|
13634
|
+
if (!existsSync15(c3.storageOnnxDir)) {
|
|
13635
|
+
log2.success(`${c3.harness.displayName}: no cached state to clear; restart your harness to trigger a fresh ONNX download`);
|
|
13345
13636
|
continue;
|
|
13346
13637
|
}
|
|
13347
13638
|
try {
|
|
13348
|
-
rmFn(
|
|
13639
|
+
rmFn(c3.storageOnnxDir, { recursive: true, force: true });
|
|
13349
13640
|
result.cleared += 1;
|
|
13350
|
-
result.bytesReclaimed +=
|
|
13351
|
-
|
|
13641
|
+
result.bytesReclaimed += c3.storageOnnxBytes;
|
|
13642
|
+
log2.success(`${c3.harness.displayName}: cleared ${c3.storageOnnxDir} (reclaimed ${formatBytes(c3.storageOnnxBytes)})`);
|
|
13352
13643
|
} catch (err) {
|
|
13353
13644
|
const message = err.message ?? "unknown error";
|
|
13354
|
-
|
|
13355
|
-
result.errors.push({ path:
|
|
13645
|
+
log2.error(`${c3.harness.displayName}: failed to clear ${c3.storageOnnxDir}: ${message}`);
|
|
13646
|
+
result.errors.push({ path: c3.storageOnnxDir, error: message });
|
|
13356
13647
|
}
|
|
13357
13648
|
}
|
|
13358
|
-
if (result.cleared > 0 || candidates.some((
|
|
13359
|
-
|
|
13649
|
+
if (result.cleared > 0 || candidates.some((c3) => c3.storageOnnxBytes === 0)) {
|
|
13650
|
+
note("Restart your AFT-using harness (OpenCode / Pi) to trigger a fresh ONNX Runtime download. " + "Watch the TUI sidebar — the Semantic Index status should move from 'failed' → 'building' → 'ready'.", "Next step");
|
|
13360
13651
|
}
|
|
13361
13652
|
return result;
|
|
13362
13653
|
}
|
|
@@ -13395,7 +13686,7 @@ function mapOpenCodeSessionRows(rows) {
|
|
|
13395
13686
|
title: row.title,
|
|
13396
13687
|
lastActivity
|
|
13397
13688
|
};
|
|
13398
|
-
}).filter((session) => session !== null).sort((
|
|
13689
|
+
}).filter((session) => session !== null).sort((a3, b2) => b2.lastActivity - a3.lastActivity).slice(0, MAX_RECENT_SESSIONS);
|
|
13399
13690
|
}
|
|
13400
13691
|
function listRecentOpenCodeSessions() {
|
|
13401
13692
|
const dbPath = join15(getXdgDataHome(), "opencode", "opencode.db");
|
|
@@ -13438,7 +13729,7 @@ function listPiSessionsFromDir(sessionsDir) {
|
|
|
13438
13729
|
} catch {
|
|
13439
13730
|
return null;
|
|
13440
13731
|
}
|
|
13441
|
-
}).filter((entry) => entry !== null).sort((
|
|
13732
|
+
}).filter((entry) => entry !== null).sort((a3, b2) => b2.mtimeMs - a3.mtimeMs).slice(0, MAX_RECENT_SESSIONS * 4);
|
|
13442
13733
|
const sessions = [];
|
|
13443
13734
|
for (const file of files) {
|
|
13444
13735
|
const parsed = parsePiSessionJsonl(readFileSync5(file.filePath, "utf8"), basename2(file.filePath));
|
|
@@ -13531,7 +13822,7 @@ function extractTextFromContent(content) {
|
|
|
13531
13822
|
return "";
|
|
13532
13823
|
const partRecord = part;
|
|
13533
13824
|
return partRecord.type === "text" && typeof partRecord.text === "string" ? partRecord.text : "";
|
|
13534
|
-
}).filter((
|
|
13825
|
+
}).filter((text3) => text3.trim().length > 0);
|
|
13535
13826
|
const joined = parts.join(" ").trim();
|
|
13536
13827
|
return joined.length > 0 ? joined : null;
|
|
13537
13828
|
}
|
|
@@ -13582,7 +13873,7 @@ async function runDoctor(options) {
|
|
|
13582
13873
|
if (options.issue) {
|
|
13583
13874
|
return runIssueFlow(options.argv);
|
|
13584
13875
|
}
|
|
13585
|
-
|
|
13876
|
+
intro("AFT doctor");
|
|
13586
13877
|
if (options.fix) {
|
|
13587
13878
|
return runFixFlow(options.argv);
|
|
13588
13879
|
}
|
|
@@ -13594,70 +13885,70 @@ async function runDoctor(options) {
|
|
|
13594
13885
|
verb: "diagnose"
|
|
13595
13886
|
});
|
|
13596
13887
|
const report = await collectDiagnostics(adapters);
|
|
13597
|
-
|
|
13888
|
+
log2.info(`AFT CLI v${report.cliVersion}, AFT binary ${report.binaryVersion ?? "unknown"}`);
|
|
13598
13889
|
if (!report.binaryVersion) {
|
|
13599
|
-
|
|
13890
|
+
log2.warn(" no matching aft binary detected — run `aft doctor --fix` to download, or it will install automatically when an AFT-enabled session makes its first tool call");
|
|
13600
13891
|
logUnmatchedBinaryCandidates(report.cliVersion);
|
|
13601
13892
|
}
|
|
13602
|
-
|
|
13893
|
+
log2.info(`Binary cache: ${report.binaryCache.versions.length} version(s), ${formatBytes(report.binaryCache.totalSize)} at ${report.binaryCache.path}`);
|
|
13603
13894
|
const npmCount = report.lspCache.npm.entries.length;
|
|
13604
13895
|
const ghCount = report.lspCache.github.entries.length;
|
|
13605
13896
|
if (npmCount + ghCount > 0) {
|
|
13606
|
-
|
|
13897
|
+
log2.info(`LSP cache: ${npmCount} npm + ${ghCount} github install(s), ${formatBytes(report.lspCache.totalSize)} total`);
|
|
13607
13898
|
}
|
|
13608
13899
|
const hadProblems = hasDoctorProblems(report);
|
|
13609
|
-
for (const
|
|
13610
|
-
|
|
13611
|
-
if (!
|
|
13612
|
-
|
|
13900
|
+
for (const h2 of report.harnesses) {
|
|
13901
|
+
log2.step(`${h2.displayName}`);
|
|
13902
|
+
if (!h2.hostInstalled) {
|
|
13903
|
+
log2.warn(` host not installed — install from: ${describeAdapterInstallHint(h2.kind)}`);
|
|
13613
13904
|
continue;
|
|
13614
13905
|
}
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
if (!
|
|
13619
|
-
|
|
13620
|
-
}
|
|
13621
|
-
|
|
13622
|
-
if (
|
|
13623
|
-
|
|
13624
|
-
} else if (
|
|
13625
|
-
const { value } = readJsoncFile(
|
|
13906
|
+
log2.info(` host: ${h2.hostVersion ?? "unknown version"}`);
|
|
13907
|
+
log2.info(` plugin registered: ${h2.pluginRegistered ? "yes" : "no"}`);
|
|
13908
|
+
log2.info(` plugin version: ${h2.pluginCache.cached ?? "not installed"}`);
|
|
13909
|
+
if (!h2.pluginRegistered) {
|
|
13910
|
+
log2.warn(" plugin registration can be fixed with `aft setup` or `aft doctor --fix`");
|
|
13911
|
+
}
|
|
13912
|
+
log2.info(` aft config: ${h2.aftConfig.exists ? h2.configPaths.aftConfig : "(not set)"}`);
|
|
13913
|
+
if (h2.aftConfig.parseError) {
|
|
13914
|
+
log2.error(` aft config parse error: ${h2.aftConfig.parseError}`);
|
|
13915
|
+
} else if (h2.aftConfig.exists) {
|
|
13916
|
+
const { value } = readJsoncFile(h2.configPaths.aftConfig);
|
|
13626
13917
|
const schemaSet = value?.$schema === AFT_SCHEMA_URL;
|
|
13627
|
-
|
|
13918
|
+
log2.info(` aft config $schema: ${schemaSet ? "set" : "not set — run `aft doctor --fix` for editor autocomplete"}`);
|
|
13628
13919
|
}
|
|
13629
|
-
|
|
13630
|
-
if (
|
|
13920
|
+
log2.info(` storage: ${formatDoctorStorageStatus(h2)}`);
|
|
13921
|
+
if (h2.onnxRuntime.required) {
|
|
13631
13922
|
const parts = [];
|
|
13632
|
-
parts.push(`required: yes (${
|
|
13633
|
-
if (
|
|
13634
|
-
parts.push(`cached: ${
|
|
13923
|
+
parts.push(`required: yes (${h2.onnxRuntime.platform})`);
|
|
13924
|
+
if (h2.onnxRuntime.cachedPath) {
|
|
13925
|
+
parts.push(`cached: ${h2.onnxRuntime.cachedVersion ?? "unknown"}${h2.onnxRuntime.cachedCompatible === false ? " (incompatible)" : ""}`);
|
|
13635
13926
|
}
|
|
13636
|
-
if (
|
|
13637
|
-
parts.push(`system: ${
|
|
13927
|
+
if (h2.onnxRuntime.systemPath) {
|
|
13928
|
+
parts.push(`system: ${h2.onnxRuntime.systemVersion ?? "unknown"}${h2.onnxRuntime.systemCompatible === false ? " (incompatible)" : ""}`);
|
|
13638
13929
|
}
|
|
13639
|
-
if (!
|
|
13640
|
-
parts.push(`not installed — ${
|
|
13930
|
+
if (!h2.onnxRuntime.cachedPath && !h2.onnxRuntime.systemPath) {
|
|
13931
|
+
parts.push(`not installed — ${h2.onnxRuntime.installHint}`);
|
|
13641
13932
|
}
|
|
13642
|
-
if (
|
|
13933
|
+
if (h2.onnxRuntime.cachedCompatible === false || h2.onnxRuntime.systemCompatible === false) {
|
|
13643
13934
|
parts.push("needs reinstall — run `aft doctor --fix`");
|
|
13644
13935
|
}
|
|
13645
|
-
|
|
13936
|
+
log2.info(` onnx runtime: ${parts.join(" · ")}`);
|
|
13646
13937
|
} else {
|
|
13647
|
-
|
|
13938
|
+
log2.info(" onnx runtime: not required (semantic search disabled; ignoring ONNX status)");
|
|
13648
13939
|
}
|
|
13649
|
-
|
|
13940
|
+
log2.info(` log: ${h2.logFile.exists ? `${h2.logFile.path} (${h2.logFile.sizeKb} KB)` : "(not written yet)"}`);
|
|
13650
13941
|
}
|
|
13651
13942
|
if (options.force) {
|
|
13652
13943
|
await clearDoctorCaches(adapters, DOCTOR_FORCE_CLEAR_TARGETS, { includePluginBytes: false });
|
|
13653
13944
|
}
|
|
13654
13945
|
if (hadProblems) {
|
|
13655
13946
|
logDoctorIssues(report);
|
|
13656
|
-
|
|
13657
|
-
|
|
13947
|
+
note("Run `aft setup` or `aft doctor --fix` to register AFT with any harness showing `plugin registered: no`. Run `aft doctor --fix` for ONNX Runtime issues or to download a missing aft binary.", "Tips");
|
|
13948
|
+
outro("Done — some issues found.");
|
|
13658
13949
|
return 1;
|
|
13659
13950
|
}
|
|
13660
|
-
|
|
13951
|
+
outro("Everything looks good.");
|
|
13661
13952
|
return 0;
|
|
13662
13953
|
}
|
|
13663
13954
|
function hasDoctorProblems(report) {
|
|
@@ -13666,8 +13957,8 @@ function hasDoctorProblems(report) {
|
|
|
13666
13957
|
async function runClearFlow(argv) {
|
|
13667
13958
|
const targets = await selectMany("What do you want to clear?", DOCTOR_CLEAR_TARGET_OPTIONS, undefined, false);
|
|
13668
13959
|
if (targets.length === 0) {
|
|
13669
|
-
|
|
13670
|
-
|
|
13960
|
+
log2.info("No cache categories selected; nothing to clear.");
|
|
13961
|
+
outro("Done.");
|
|
13671
13962
|
return 0;
|
|
13672
13963
|
}
|
|
13673
13964
|
const adapters = targets.includes("plugin-cache") ? await resolveAdaptersForCommand(argv, {
|
|
@@ -13675,7 +13966,7 @@ async function runClearFlow(argv) {
|
|
|
13675
13966
|
verb: "clear plugin cache for"
|
|
13676
13967
|
}) : [];
|
|
13677
13968
|
const summary = await clearDoctorCaches(adapters, targets);
|
|
13678
|
-
|
|
13969
|
+
outro(summary.hadErrors ? "Done — some cache entries could not be cleared." : "Done.");
|
|
13679
13970
|
return summary.hadErrors ? 1 : 0;
|
|
13680
13971
|
}
|
|
13681
13972
|
async function clearDoctorCaches(adapters, targets, options = {}) {
|
|
@@ -13732,12 +14023,12 @@ function clearOldBinaries() {
|
|
|
13732
14023
|
keptVersion: keepTag
|
|
13733
14024
|
};
|
|
13734
14025
|
if (!existsSync17(info.path)) {
|
|
13735
|
-
|
|
14026
|
+
log2.info(`Binary cache: nothing to clear at ${info.path}`);
|
|
13736
14027
|
return result;
|
|
13737
14028
|
}
|
|
13738
14029
|
const stale = info.versions.filter((v) => v !== keepTag);
|
|
13739
14030
|
if (stale.length === 0) {
|
|
13740
|
-
|
|
14031
|
+
log2.info(`Binary cache: only the active version (${keepTag}) is present at ${info.path}; nothing to clear`);
|
|
13741
14032
|
return result;
|
|
13742
14033
|
}
|
|
13743
14034
|
for (const version of stale) {
|
|
@@ -13752,20 +14043,20 @@ function clearOldBinaries() {
|
|
|
13752
14043
|
rmSync4(dir, { recursive: true, force: true });
|
|
13753
14044
|
result.cleared += 1;
|
|
13754
14045
|
result.bytesReclaimed += bytes;
|
|
13755
|
-
|
|
14046
|
+
log2.success(`Binary cache: cleared ${dir} (reclaimed ${formatBytes(bytes)})`);
|
|
13756
14047
|
} catch (err) {
|
|
13757
14048
|
const message = err.message ?? "unknown error";
|
|
13758
|
-
|
|
14049
|
+
log2.error(`Binary cache: failed to remove ${dir}: ${message}`);
|
|
13759
14050
|
result.errors.push({ path: dir, error: message });
|
|
13760
14051
|
}
|
|
13761
14052
|
}
|
|
13762
14053
|
if (result.cleared > 0) {
|
|
13763
|
-
|
|
14054
|
+
log2.success(`Binary cache: kept ${keepTag}, removed ${result.cleared} old version(s), reclaimed ${formatBytes(result.bytesReclaimed)}`);
|
|
13764
14055
|
}
|
|
13765
14056
|
return result;
|
|
13766
14057
|
}
|
|
13767
14058
|
function findPluginUpdateTargets(adapters, report) {
|
|
13768
|
-
const adaptersByKind = new Map(adapters.map((
|
|
14059
|
+
const adaptersByKind = new Map(adapters.map((a3) => [a3.kind, a3]));
|
|
13769
14060
|
const targets = [];
|
|
13770
14061
|
for (const harness of report.harnesses) {
|
|
13771
14062
|
if (harness.kind !== "opencode")
|
|
@@ -13816,7 +14107,7 @@ async function applyPluginUpdates(targets) {
|
|
|
13816
14107
|
const npm = resolveNpm();
|
|
13817
14108
|
if (!npm) {
|
|
13818
14109
|
errors += targets.length;
|
|
13819
|
-
|
|
14110
|
+
log2.error("Could not find npm on PATH or in known version-manager locations, so the plugin cannot be updated automatically. Install Node/npm, or launch your editor from a shell where npm is available.");
|
|
13820
14111
|
return { updated, errors };
|
|
13821
14112
|
}
|
|
13822
14113
|
for (const target of targets) {
|
|
@@ -13828,11 +14119,11 @@ async function applyPluginUpdates(targets) {
|
|
|
13828
14119
|
timeout: 120000
|
|
13829
14120
|
});
|
|
13830
14121
|
updated += 1;
|
|
13831
|
-
|
|
14122
|
+
log2.success(`${target.adapter.displayName}: plugin updated ${target.cached} → ${target.latest} (restart ${target.adapter.displayName} to apply)`);
|
|
13832
14123
|
} catch (err) {
|
|
13833
14124
|
errors += 1;
|
|
13834
14125
|
const message = err instanceof Error ? err.message : String(err);
|
|
13835
|
-
|
|
14126
|
+
log2.error(`${target.adapter.displayName}: plugin update failed: ${message}`);
|
|
13836
14127
|
}
|
|
13837
14128
|
}
|
|
13838
14129
|
return { updated, errors };
|
|
@@ -13845,11 +14136,11 @@ function applySchemaFixes(targets) {
|
|
|
13845
14136
|
const result = ensureAftSchemaUrl(target.aftConfig, target.aftConfigFormat);
|
|
13846
14137
|
if (result.action === "added" || result.action === "updated") {
|
|
13847
14138
|
changed += 1;
|
|
13848
|
-
|
|
14139
|
+
log2.success(`${target.adapter.displayName}: ${result.message}`);
|
|
13849
14140
|
}
|
|
13850
14141
|
} catch (error2) {
|
|
13851
14142
|
errors += 1;
|
|
13852
|
-
|
|
14143
|
+
log2.warn(`${target.adapter.displayName}: could not set $schema on ${target.aftConfig}: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
13853
14144
|
}
|
|
13854
14145
|
}
|
|
13855
14146
|
return { changed, errors };
|
|
@@ -13936,7 +14227,7 @@ async function confirmDoctorFixPlan(plan, argv) {
|
|
|
13936
14227
|
return true;
|
|
13937
14228
|
if (shouldSkipDoctorFixConfirmation(argv))
|
|
13938
14229
|
return true;
|
|
13939
|
-
return
|
|
14230
|
+
return confirm2("Apply the planned doctor --fix changes?", false);
|
|
13940
14231
|
}
|
|
13941
14232
|
function logUnmatchedBinaryCandidates(expectedVersion) {
|
|
13942
14233
|
const probe = probeAftBinary(expectedVersion);
|
|
@@ -13944,9 +14235,9 @@ function logUnmatchedBinaryCandidates(expectedVersion) {
|
|
|
13944
14235
|
if (unmatched.length === 0)
|
|
13945
14236
|
return;
|
|
13946
14237
|
const expected = probe.expectedMajorMinor ? `${probe.expectedMajorMinor}.x` : probe.expectedVersion;
|
|
13947
|
-
|
|
14238
|
+
log2.warn(` found unmatched aft binary candidate(s); expected ${expected}:`);
|
|
13948
14239
|
for (const candidate of unmatched) {
|
|
13949
|
-
|
|
14240
|
+
log2.warn(` unmatched: ${candidate.path} reported v${candidate.version ?? "unknown"}`);
|
|
13950
14241
|
}
|
|
13951
14242
|
}
|
|
13952
14243
|
async function runFixFlow(argv) {
|
|
@@ -13954,20 +14245,20 @@ async function runFixFlow(argv) {
|
|
|
13954
14245
|
allowMulti: false,
|
|
13955
14246
|
verb: "auto-fix issues for"
|
|
13956
14247
|
});
|
|
13957
|
-
|
|
14248
|
+
log2.info("Running diagnostics to identify auto-fixable issues…");
|
|
13958
14249
|
const report = await collectDiagnostics(adapters);
|
|
13959
14250
|
if (!report.binaryVersion) {
|
|
13960
14251
|
logUnmatchedBinaryCandidates(report.cliVersion);
|
|
13961
14252
|
}
|
|
13962
14253
|
const plan = buildDoctorFixPlan(adapters, report);
|
|
13963
14254
|
if (plan.length > 0) {
|
|
13964
|
-
|
|
14255
|
+
log2.warn("Planned changes:");
|
|
13965
14256
|
for (const item of plan) {
|
|
13966
|
-
|
|
14257
|
+
log2.info(` • ${item.message}`);
|
|
13967
14258
|
}
|
|
13968
14259
|
if (!await confirmDoctorFixPlan(plan, argv)) {
|
|
13969
|
-
|
|
13970
|
-
|
|
14260
|
+
log2.info("Skipped — no changes made.");
|
|
14261
|
+
outro("Done.");
|
|
13971
14262
|
return 0;
|
|
13972
14263
|
}
|
|
13973
14264
|
}
|
|
@@ -13983,81 +14274,81 @@ async function runFixFlow(argv) {
|
|
|
13983
14274
|
if (!shouldDownload) {
|
|
13984
14275
|
binaryDownloadSkipped = true;
|
|
13985
14276
|
} else {
|
|
13986
|
-
|
|
14277
|
+
log2.info("AFT binary not found. Downloading…");
|
|
13987
14278
|
try {
|
|
13988
14279
|
const bridgePackageName = "@cortexkit/aft-bridge";
|
|
13989
14280
|
const { ensureBinary: ensureBinary2 } = await import(bridgePackageName);
|
|
13990
14281
|
const path = await ensureBinary2(`v${report.cliVersion}`);
|
|
13991
14282
|
if (path) {
|
|
13992
|
-
|
|
14283
|
+
log2.success(`AFT binary installed at ${path}`);
|
|
13993
14284
|
binaryDownloaded = true;
|
|
13994
14285
|
} else {
|
|
13995
|
-
|
|
14286
|
+
log2.error("AFT binary download failed — no matching release asset on GitHub. " + "Try opening any AFT-enabled session to trigger plugin-side download instead.");
|
|
13996
14287
|
binaryDownloadError = "no matching release asset";
|
|
13997
14288
|
}
|
|
13998
14289
|
} catch (err) {
|
|
13999
14290
|
const message = err instanceof Error ? err.message : String(err);
|
|
14000
|
-
|
|
14291
|
+
log2.error(`AFT binary download failed: ${message}`);
|
|
14001
14292
|
binaryDownloadError = message;
|
|
14002
14293
|
}
|
|
14003
14294
|
}
|
|
14004
14295
|
}
|
|
14005
14296
|
const onnxResult = await runOnnxFix(adapters, report, { yes: true });
|
|
14006
14297
|
if (onnxResult === null && !binaryDownloaded && !binaryDownloadSkipped && !binaryDownloadError && storageSummary.created === 0 && storageSummary.errors === 0 && schemaSummary.changed === 0 && schemaSummary.errors === 0 && pluginUpdateSummary.updated === 0 && pluginUpdateSummary.errors === 0) {
|
|
14007
|
-
|
|
14008
|
-
|
|
14298
|
+
log2.info("No auto-fixable issues detected.");
|
|
14299
|
+
note("If you're still seeing 'Semantic Index: failed' in the TUI sidebar, run `aft doctor` (without --fix) for a full diagnostic dump.", "Tip");
|
|
14009
14300
|
const afterReport2 = await collectDiagnostics(adapters);
|
|
14010
14301
|
const stillHasProblems2 = hasDoctorProblems(afterReport2);
|
|
14011
|
-
|
|
14302
|
+
outro(stillHasProblems2 ? "Done — some issues remain." : "Done.");
|
|
14012
14303
|
return stillHasProblems2 ? 1 : 0;
|
|
14013
14304
|
}
|
|
14014
14305
|
const hadErrors = (onnxResult?.errors.length ?? 0) > 0 || binaryDownloadError !== null || storageSummary.errors > 0 || schemaSummary.errors > 0 || pluginUpdateSummary.errors > 0;
|
|
14015
14306
|
const afterReport = await collectDiagnostics(adapters);
|
|
14016
14307
|
const stillHasProblems = hasDoctorProblems(afterReport);
|
|
14017
|
-
|
|
14308
|
+
outro(hadErrors ? "Done — some fixes failed." : stillHasProblems ? "Done — some issues remain." : "Done.");
|
|
14018
14309
|
return hadErrors || stillHasProblems ? 1 : 0;
|
|
14019
14310
|
}
|
|
14020
14311
|
function logDoctorIssues(report) {
|
|
14021
14312
|
const lines = formatDiagnosticIssuesSection(report);
|
|
14022
14313
|
if (lines.length === 0)
|
|
14023
14314
|
return;
|
|
14024
|
-
|
|
14025
|
-
for (let
|
|
14026
|
-
const issue = lines[
|
|
14027
|
-
const remediation = lines[
|
|
14315
|
+
log2.warn(lines[0]);
|
|
14316
|
+
for (let i2 = 1;i2 < lines.length; i2 += 2) {
|
|
14317
|
+
const issue = lines[i2];
|
|
14318
|
+
const remediation = lines[i2 + 1];
|
|
14028
14319
|
if (issue.startsWith("[HIGH]")) {
|
|
14029
|
-
|
|
14320
|
+
log2.error(issue);
|
|
14030
14321
|
} else {
|
|
14031
|
-
|
|
14322
|
+
log2.warn(issue);
|
|
14032
14323
|
}
|
|
14033
14324
|
if (remediation)
|
|
14034
|
-
|
|
14325
|
+
log2.warn(remediation);
|
|
14035
14326
|
}
|
|
14036
14327
|
}
|
|
14037
|
-
function formatDoctorStorageStatus(
|
|
14038
|
-
const state =
|
|
14039
|
-
return `${state} (${formatStorageSizes(
|
|
14328
|
+
function formatDoctorStorageStatus(h2) {
|
|
14329
|
+
const state = h2.storageDir.exists ? h2.storageDir.path : `${h2.storageDir.path} (${h2.pluginRegistered ? "not yet created (lazy — created on first tool call)" : "not created"})`;
|
|
14330
|
+
return `${state} (${formatStorageSizes(h2.storageDir.sizesByKey)})`;
|
|
14040
14331
|
}
|
|
14041
14332
|
async function confirmBinaryDownloadDespitePluginSkew(report, argv) {
|
|
14042
14333
|
const skews = findPluginCliVersionSkews(report);
|
|
14043
14334
|
if (skews.length === 0)
|
|
14044
14335
|
return true;
|
|
14045
|
-
|
|
14336
|
+
log2.warn("Plugin/CLI version mismatch detected before binary download:");
|
|
14046
14337
|
for (const skew of skews) {
|
|
14047
|
-
|
|
14048
|
-
|
|
14338
|
+
log2.warn(` ${skew.scope}: ${skew.message}`);
|
|
14339
|
+
log2.warn(` ${skew.remediation}`);
|
|
14049
14340
|
}
|
|
14050
|
-
|
|
14341
|
+
log2.warn("A newly cached binary will not be used by the older plugin until the plugin is updated.");
|
|
14051
14342
|
const decision = doctorSkewBinaryDownloadDecision(argv);
|
|
14052
14343
|
if (decision === "proceed") {
|
|
14053
|
-
|
|
14344
|
+
log2.info("Proceeding because --yes/-y was provided.");
|
|
14054
14345
|
return true;
|
|
14055
14346
|
}
|
|
14056
14347
|
if (decision === "skip") {
|
|
14057
|
-
|
|
14348
|
+
log2.info("Skipped binary download. Update the plugin to @latest, then rerun `aft doctor --fix`.");
|
|
14058
14349
|
return false;
|
|
14059
14350
|
}
|
|
14060
|
-
return
|
|
14351
|
+
return confirm2("Download/cache the CLI-matching binary anyway for after you update the plugin?", false);
|
|
14061
14352
|
}
|
|
14062
14353
|
function ensureStorageDirsForRegisteredPlugins(adapters) {
|
|
14063
14354
|
const summary = { created: 0, errors: 0 };
|
|
@@ -14070,10 +14361,10 @@ function ensureStorageDirsForRegisteredPlugins(adapters) {
|
|
|
14070
14361
|
continue;
|
|
14071
14362
|
mkdirSync3(storageDir, { recursive: true });
|
|
14072
14363
|
summary.created += 1;
|
|
14073
|
-
|
|
14364
|
+
log2.success(`${adapter.displayName}: created AFT storage directory at ${storageDir}`);
|
|
14074
14365
|
} catch (err) {
|
|
14075
14366
|
summary.errors += 1;
|
|
14076
|
-
|
|
14367
|
+
log2.error(`${adapter.displayName}: failed to create AFT storage directory: ${err instanceof Error ? err.message : String(err)}`);
|
|
14077
14368
|
}
|
|
14078
14369
|
}
|
|
14079
14370
|
return summary;
|
|
@@ -14084,31 +14375,31 @@ async function clearPluginCache(adapter, includeBytes) {
|
|
|
14084
14375
|
const result = await adapter.clearPluginCache(true);
|
|
14085
14376
|
if (result.action === "cleared") {
|
|
14086
14377
|
const suffix = includeBytes ? `, reclaimed ${formatBytes(bytes)}` : "";
|
|
14087
|
-
|
|
14378
|
+
log2.success(`${adapter.displayName}: cleared plugin cache at ${result.path}${suffix}`);
|
|
14088
14379
|
return { action: "cleared", bytes };
|
|
14089
14380
|
}
|
|
14090
14381
|
if (result.action === "not_applicable") {
|
|
14091
|
-
|
|
14382
|
+
log2.info(`${adapter.displayName}: no user-managed plugin cache to clear`);
|
|
14092
14383
|
return { action: "not_applicable", bytes: 0 };
|
|
14093
14384
|
}
|
|
14094
14385
|
if (result.action === "not_found") {
|
|
14095
|
-
|
|
14386
|
+
log2.info(`${adapter.displayName}: no plugin cache found at ${result.path}`);
|
|
14096
14387
|
return { action: "not_found", bytes: 0 };
|
|
14097
14388
|
}
|
|
14098
14389
|
if (result.action === "error") {
|
|
14099
|
-
|
|
14390
|
+
log2.error(`${adapter.displayName}: cache clear failed: ${result.error ?? "unknown"}`);
|
|
14100
14391
|
return { action: "error", bytes: 0 };
|
|
14101
14392
|
}
|
|
14102
14393
|
return { action: "not_found", bytes: 0 };
|
|
14103
14394
|
}
|
|
14104
14395
|
function reportLspCacheClear(cleanup) {
|
|
14105
14396
|
if (cleanup.cleared.length === 0) {
|
|
14106
|
-
|
|
14397
|
+
log2.info("LSP install cache: nothing to clear, reclaimed 0 B");
|
|
14107
14398
|
} else {
|
|
14108
|
-
|
|
14399
|
+
log2.success(`LSP install cache: cleared ${cleanup.cleared.length} install(s), reclaimed ${formatBytes(cleanup.totalBytes)}`);
|
|
14109
14400
|
}
|
|
14110
14401
|
for (const err of cleanup.errors) {
|
|
14111
|
-
|
|
14402
|
+
log2.error(`LSP install cache: failed to remove ${err.path}: ${err.error}`);
|
|
14112
14403
|
}
|
|
14113
14404
|
}
|
|
14114
14405
|
async function fixPluginEntries(adapters) {
|
|
@@ -14118,12 +14409,12 @@ async function fixPluginEntries(adapters) {
|
|
|
14118
14409
|
}
|
|
14119
14410
|
async function maybeFixPlugin(adapter) {
|
|
14120
14411
|
if (!adapter.hasPluginEntry() && adapter.isInstalled()) {
|
|
14121
|
-
|
|
14122
|
-
const
|
|
14123
|
-
if (
|
|
14124
|
-
|
|
14412
|
+
log2.info(`${adapter.displayName}: attempting to register plugin…`);
|
|
14413
|
+
const r2 = await adapter.ensurePluginEntry();
|
|
14414
|
+
if (r2.ok) {
|
|
14415
|
+
log2.success(`${adapter.displayName}: ${r2.message}`);
|
|
14125
14416
|
} else {
|
|
14126
|
-
|
|
14417
|
+
log2.error(`${adapter.displayName}: ${r2.message}`);
|
|
14127
14418
|
}
|
|
14128
14419
|
}
|
|
14129
14420
|
}
|
|
@@ -14146,8 +14437,8 @@ function issueDescriptionSummaryFromBody(body) {
|
|
|
14146
14437
|
const descriptionStart = lines.findIndex((line) => line.trim() === "## Description");
|
|
14147
14438
|
if (descriptionStart !== -1) {
|
|
14148
14439
|
const parts = [];
|
|
14149
|
-
for (let
|
|
14150
|
-
const trimmed = lines[
|
|
14440
|
+
for (let i2 = descriptionStart + 1;i2 < lines.length; i2 += 1) {
|
|
14441
|
+
const trimmed = lines[i2].trim();
|
|
14151
14442
|
if (trimmed.startsWith("## "))
|
|
14152
14443
|
break;
|
|
14153
14444
|
if (!trimmed)
|
|
@@ -14183,7 +14474,7 @@ function writeIssueReviewFile(body) {
|
|
|
14183
14474
|
rmSync4(reviewDir, { recursive: true, force: true });
|
|
14184
14475
|
} catch {}
|
|
14185
14476
|
}
|
|
14186
|
-
|
|
14477
|
+
log2.error(`Failed to write sanitized issue report: ${err instanceof Error ? err.message : String(err)}`);
|
|
14187
14478
|
return null;
|
|
14188
14479
|
}
|
|
14189
14480
|
}
|
|
@@ -14191,12 +14482,12 @@ function readReviewedIssueFile(reviewFile) {
|
|
|
14191
14482
|
try {
|
|
14192
14483
|
const realPath = realpathSync4(reviewFile.path);
|
|
14193
14484
|
if (realPath !== reviewFile.realPath) {
|
|
14194
|
-
|
|
14485
|
+
log2.error(`Review file path changed before filing; refusing to read ${reviewFile.path}.`);
|
|
14195
14486
|
return null;
|
|
14196
14487
|
}
|
|
14197
14488
|
return readFileSync6(reviewFile.path, "utf8");
|
|
14198
14489
|
} catch (err) {
|
|
14199
|
-
|
|
14490
|
+
log2.error(`Failed to read reviewed issue report: ${err instanceof Error ? err.message : String(err)}`);
|
|
14200
14491
|
return null;
|
|
14201
14492
|
}
|
|
14202
14493
|
}
|
|
@@ -14222,17 +14513,17 @@ function shortSessionId(id) {
|
|
|
14222
14513
|
return bareId.length <= 12 ? bareId : bareId.slice(0, 12);
|
|
14223
14514
|
}
|
|
14224
14515
|
async function runIssueFlow(argv) {
|
|
14225
|
-
|
|
14516
|
+
intro("AFT doctor --issue");
|
|
14226
14517
|
if (!isInteractiveTerminal()) {
|
|
14227
|
-
|
|
14228
|
-
|
|
14518
|
+
note("Non-interactive terminal — not collecting or filing automatically. Run `aft doctor --issue` from an interactive terminal so you can describe and review the report before filing.", "Manual filing");
|
|
14519
|
+
outro("Done.");
|
|
14229
14520
|
return 0;
|
|
14230
14521
|
}
|
|
14231
14522
|
const adapters = await resolveAdaptersForCommand(argv, {
|
|
14232
14523
|
allowMulti: false,
|
|
14233
14524
|
verb: "include in the issue"
|
|
14234
14525
|
});
|
|
14235
|
-
const description = await
|
|
14526
|
+
const description = await text2("Describe the problem you're running into:", {
|
|
14236
14527
|
placeholder: "What happened? What did you expect? Steps to reproduce…",
|
|
14237
14528
|
validate: (value) => value.trim().length === 0 ? "Please enter a short description." : undefined
|
|
14238
14529
|
});
|
|
@@ -14290,46 +14581,46 @@ ${scopedTail || "<no log output>"}
|
|
|
14290
14581
|
const body = capBodyToGithubLimit(sanitizeContent(rawBody));
|
|
14291
14582
|
const reviewFile = writeIssueReviewFile(body);
|
|
14292
14583
|
if (!reviewFile) {
|
|
14293
|
-
|
|
14584
|
+
outro("Done — could not write the issue report.");
|
|
14294
14585
|
return 1;
|
|
14295
14586
|
}
|
|
14296
14587
|
const outPath = reviewFile.path;
|
|
14297
|
-
|
|
14298
|
-
|
|
14588
|
+
log2.success(`Wrote sanitized issue body to ${outPath}`);
|
|
14589
|
+
note(`Open and review the report before filing:
|
|
14299
14590
|
${outPath}
|
|
14300
14591
|
|
|
14301
14592
|
Home paths and your username have been stripped, but it still contains log lines and file paths from your project. Edit the file to remove anything you don't want public — your edits are used when you confirm below.`, "Review before filing");
|
|
14302
|
-
const proceed = await
|
|
14593
|
+
const proceed = await confirm2("Have you reviewed the report above? File it as a GitHub issue now?", false);
|
|
14303
14594
|
if (!proceed) {
|
|
14304
|
-
|
|
14595
|
+
note(`No issue filed. When ready, file manually at
|
|
14305
14596
|
https://github.com/cortexkit/aft/issues/new and paste the contents of ${outPath}.`, "Skipped");
|
|
14306
|
-
|
|
14597
|
+
outro("Done.");
|
|
14307
14598
|
return 0;
|
|
14308
14599
|
}
|
|
14309
14600
|
const reviewedBody = readReviewedIssueFile(reviewFile);
|
|
14310
14601
|
if (reviewedBody === null) {
|
|
14311
|
-
|
|
14312
|
-
|
|
14602
|
+
note("No issue filed. Please review the report path above and file manually if needed.", "Skipped");
|
|
14603
|
+
outro("Done.");
|
|
14313
14604
|
return 1;
|
|
14314
14605
|
}
|
|
14315
14606
|
const finalBody = capBodyToGithubLimit(sanitizeContent(reviewedBody));
|
|
14316
14607
|
const finalTitle = deriveIssueTitleFromBody(finalBody);
|
|
14317
14608
|
if (isGhInstalled()) {
|
|
14318
|
-
|
|
14609
|
+
log2.info("Opening GitHub issue via `gh`…");
|
|
14319
14610
|
const result = createGitHubIssue("cortexkit/aft", finalTitle, finalBody);
|
|
14320
14611
|
if (result.url) {
|
|
14321
|
-
|
|
14612
|
+
log2.success(`Issue filed: ${result.url}`);
|
|
14322
14613
|
openBrowser(result.url);
|
|
14323
|
-
|
|
14614
|
+
outro("Done.");
|
|
14324
14615
|
return 0;
|
|
14325
14616
|
}
|
|
14326
|
-
|
|
14617
|
+
log2.warn(`gh failed: ${result.stderr ?? "unknown error"}. Falling back to browser.`);
|
|
14327
14618
|
}
|
|
14328
14619
|
const fallback = `https://github.com/cortexkit/aft/issues/new?title=${encodeURIComponent(finalTitle)}&body=${encodeURIComponent(finalBody)}`;
|
|
14329
|
-
|
|
14620
|
+
log2.info("Opening GitHub issue form in your browser…");
|
|
14330
14621
|
openBrowser(fallback);
|
|
14331
|
-
|
|
14332
|
-
|
|
14622
|
+
note(`If the browser didn't open, the sanitized body is at ${outPath}. Copy it into a new issue at https://github.com/cortexkit/aft/issues/new.`, "Fallback");
|
|
14623
|
+
outro("Done.");
|
|
14333
14624
|
return 0;
|
|
14334
14625
|
}
|
|
14335
14626
|
var DOCTOR_CLEAR_TARGET_OPTIONS, DOCTOR_FORCE_CLEAR_TARGETS;
|