webmux 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/backend/dist/server.js +279 -58
- package/bin/webmux.js +1469 -908
- package/frontend/dist/assets/index-CBdl44Z_.css +32 -0
- package/frontend/dist/assets/index-kg2aNK8N.js +151 -0
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/index-BRoz1T_W.js +0 -151
- package/frontend/dist/assets/index-D9R5ycW2.css +0 -32
package/bin/webmux.js
CHANGED
|
@@ -438,6 +438,8 @@ _webmux() {
|
|
|
438
438
|
'list:List worktrees and their status'
|
|
439
439
|
'open:Open an existing worktree session'
|
|
440
440
|
'close:Close a worktree session'
|
|
441
|
+
'archive:Hide a worktree from the default list'
|
|
442
|
+
'unarchive:Show an archived worktree again'
|
|
441
443
|
'remove:Remove a worktree'
|
|
442
444
|
'merge:Merge a worktree into main'
|
|
443
445
|
'send:Send a prompt to a running worktree agent'
|
|
@@ -451,7 +453,7 @@ _webmux() {
|
|
|
451
453
|
fi
|
|
452
454
|
|
|
453
455
|
case "\${words[2]}" in
|
|
454
|
-
open|close|remove|merge|send)
|
|
456
|
+
open|close|archive|unarchive|remove|merge|send)
|
|
455
457
|
if (( CURRENT == 3 )); then
|
|
456
458
|
local -a branches
|
|
457
459
|
branches=(\${(f)"$(webmux --completions "\${words[2]}" 2>/dev/null)"})
|
|
@@ -489,12 +491,12 @@ compdef _webmux webmux`, BASH_SCRIPT = `_webmux() {
|
|
|
489
491
|
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
490
492
|
|
|
491
493
|
if [[ \${COMP_CWORD} -eq 1 ]]; then
|
|
492
|
-
COMPREPLY=($(compgen -W "serve init service update add list open close remove merge send prune completion" -- "\${cur}"))
|
|
494
|
+
COMPREPLY=($(compgen -W "serve init service update add list open close archive unarchive remove merge send prune completion" -- "\${cur}"))
|
|
493
495
|
return
|
|
494
496
|
fi
|
|
495
497
|
|
|
496
498
|
case "\${COMP_WORDS[1]}" in
|
|
497
|
-
open|close|remove|merge|send)
|
|
499
|
+
open|close|archive|unarchive|remove|merge|send)
|
|
498
500
|
if [[ \${COMP_CWORD} -eq 2 ]]; then
|
|
499
501
|
local branches
|
|
500
502
|
branches=$(webmux --completions "\${COMP_WORDS[1]}" 2>/dev/null)
|
|
@@ -517,55 +519,435 @@ compdef _webmux webmux`, BASH_SCRIPT = `_webmux() {
|
|
|
517
519
|
complete -F _webmux webmux`;
|
|
518
520
|
var init_completions = __esm(() => {
|
|
519
521
|
init_git();
|
|
520
|
-
BRANCH_SUBCOMMANDS = new Set(["open", "close", "remove", "merge", "send"]);
|
|
522
|
+
BRANCH_SUBCOMMANDS = new Set(["open", "close", "archive", "unarchive", "remove", "merge", "send"]);
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/utils.js
|
|
526
|
+
var isAmbiguous = (x) => {
|
|
527
|
+
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;
|
|
528
|
+
}, isFullWidth = (x) => {
|
|
529
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
530
|
+
}, isWide = (x) => {
|
|
531
|
+
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
532
|
+
};
|
|
533
|
+
var init_utils = () => {};
|
|
534
|
+
|
|
535
|
+
// node_modules/.bun/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/index.js
|
|
536
|
+
var ANSI_RE, CONTROL_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
537
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
538
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
539
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
540
|
+
const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
|
|
541
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
542
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
543
|
+
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
544
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
545
|
+
const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
|
|
546
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
547
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
|
|
548
|
+
let indexPrev = 0;
|
|
549
|
+
let index = 0;
|
|
550
|
+
let length = input.length;
|
|
551
|
+
let lengthExtra = 0;
|
|
552
|
+
let truncationEnabled = false;
|
|
553
|
+
let truncationIndex = length;
|
|
554
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
555
|
+
let unmatchedStart = 0;
|
|
556
|
+
let unmatchedEnd = 0;
|
|
557
|
+
let width = 0;
|
|
558
|
+
let widthExtra = 0;
|
|
559
|
+
outer:
|
|
560
|
+
while (true) {
|
|
561
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
562
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
563
|
+
lengthExtra = 0;
|
|
564
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
565
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
566
|
+
if (isFullWidth(codePoint)) {
|
|
567
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
568
|
+
} else if (isWide(codePoint)) {
|
|
569
|
+
widthExtra = WIDE_WIDTH;
|
|
570
|
+
} else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
|
|
571
|
+
widthExtra = AMBIGUOUS_WIDTH;
|
|
572
|
+
} else {
|
|
573
|
+
widthExtra = REGULAR_WIDTH;
|
|
574
|
+
}
|
|
575
|
+
if (width + widthExtra > truncationLimit) {
|
|
576
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
577
|
+
}
|
|
578
|
+
if (width + widthExtra > LIMIT) {
|
|
579
|
+
truncationEnabled = true;
|
|
580
|
+
break outer;
|
|
581
|
+
}
|
|
582
|
+
lengthExtra += char.length;
|
|
583
|
+
width += widthExtra;
|
|
584
|
+
}
|
|
585
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
586
|
+
}
|
|
587
|
+
if (index >= length)
|
|
588
|
+
break;
|
|
589
|
+
LATIN_RE.lastIndex = index;
|
|
590
|
+
if (LATIN_RE.test(input)) {
|
|
591
|
+
lengthExtra = LATIN_RE.lastIndex - index;
|
|
592
|
+
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
593
|
+
if (width + widthExtra > truncationLimit) {
|
|
594
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
595
|
+
}
|
|
596
|
+
if (width + widthExtra > LIMIT) {
|
|
597
|
+
truncationEnabled = true;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
width += widthExtra;
|
|
601
|
+
unmatchedStart = indexPrev;
|
|
602
|
+
unmatchedEnd = index;
|
|
603
|
+
index = indexPrev = LATIN_RE.lastIndex;
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
ANSI_RE.lastIndex = index;
|
|
607
|
+
if (ANSI_RE.test(input)) {
|
|
608
|
+
if (width + ANSI_WIDTH > truncationLimit) {
|
|
609
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
610
|
+
}
|
|
611
|
+
if (width + ANSI_WIDTH > LIMIT) {
|
|
612
|
+
truncationEnabled = true;
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
width += ANSI_WIDTH;
|
|
616
|
+
unmatchedStart = indexPrev;
|
|
617
|
+
unmatchedEnd = index;
|
|
618
|
+
index = indexPrev = ANSI_RE.lastIndex;
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
CONTROL_RE.lastIndex = index;
|
|
622
|
+
if (CONTROL_RE.test(input)) {
|
|
623
|
+
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
624
|
+
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
625
|
+
if (width + widthExtra > truncationLimit) {
|
|
626
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
627
|
+
}
|
|
628
|
+
if (width + widthExtra > LIMIT) {
|
|
629
|
+
truncationEnabled = true;
|
|
630
|
+
break;
|
|
631
|
+
}
|
|
632
|
+
width += widthExtra;
|
|
633
|
+
unmatchedStart = indexPrev;
|
|
634
|
+
unmatchedEnd = index;
|
|
635
|
+
index = indexPrev = CONTROL_RE.lastIndex;
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
TAB_RE.lastIndex = index;
|
|
639
|
+
if (TAB_RE.test(input)) {
|
|
640
|
+
lengthExtra = TAB_RE.lastIndex - index;
|
|
641
|
+
widthExtra = lengthExtra * TAB_WIDTH;
|
|
642
|
+
if (width + widthExtra > truncationLimit) {
|
|
643
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
644
|
+
}
|
|
645
|
+
if (width + widthExtra > LIMIT) {
|
|
646
|
+
truncationEnabled = true;
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
width += widthExtra;
|
|
650
|
+
unmatchedStart = indexPrev;
|
|
651
|
+
unmatchedEnd = index;
|
|
652
|
+
index = indexPrev = TAB_RE.lastIndex;
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
EMOJI_RE.lastIndex = index;
|
|
656
|
+
if (EMOJI_RE.test(input)) {
|
|
657
|
+
if (width + EMOJI_WIDTH > truncationLimit) {
|
|
658
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
659
|
+
}
|
|
660
|
+
if (width + EMOJI_WIDTH > LIMIT) {
|
|
661
|
+
truncationEnabled = true;
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
width += EMOJI_WIDTH;
|
|
665
|
+
unmatchedStart = indexPrev;
|
|
666
|
+
unmatchedEnd = index;
|
|
667
|
+
index = indexPrev = EMOJI_RE.lastIndex;
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
index += 1;
|
|
671
|
+
}
|
|
672
|
+
return {
|
|
673
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
674
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
675
|
+
truncated: truncationEnabled,
|
|
676
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
677
|
+
};
|
|
678
|
+
}, dist_default;
|
|
679
|
+
var init_dist = __esm(() => {
|
|
680
|
+
init_utils();
|
|
681
|
+
ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
682
|
+
CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
683
|
+
TAB_RE = /\t{1,1000}/y;
|
|
684
|
+
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;
|
|
685
|
+
LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
686
|
+
MODIFIER_RE = /\p{M}+/gu;
|
|
687
|
+
NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
688
|
+
dist_default = getStringTruncatedWidth;
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
// node_modules/.bun/fast-string-width@1.1.0/node_modules/fast-string-width/dist/index.js
|
|
692
|
+
var NO_TRUNCATION2, fastStringWidth = (input, options = {}) => {
|
|
693
|
+
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
694
|
+
}, dist_default2;
|
|
695
|
+
var init_dist2 = __esm(() => {
|
|
696
|
+
init_dist();
|
|
697
|
+
NO_TRUNCATION2 = {
|
|
698
|
+
limit: Infinity,
|
|
699
|
+
ellipsis: "",
|
|
700
|
+
ellipsisWidth: 0
|
|
701
|
+
};
|
|
702
|
+
dist_default2 = fastStringWidth;
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
// node_modules/.bun/fast-wrap-ansi@0.1.6/node_modules/fast-wrap-ansi/lib/main.js
|
|
706
|
+
function wrapAnsi(string, columns, options) {
|
|
707
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
|
|
708
|
+
`);
|
|
709
|
+
}
|
|
710
|
+
var ESC = "\x1B", CSI = "\x9B", END_CODE = 39, ANSI_ESCAPE_BELL = "\x07", ANSI_CSI = "[", ANSI_OSC = "]", ANSI_SGR_TERMINATOR = "m", ANSI_ESCAPE_LINK, GROUP_REGEX, getClosingCode = (openingCode) => {
|
|
711
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
712
|
+
return 39;
|
|
713
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
714
|
+
return 39;
|
|
715
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
716
|
+
return 49;
|
|
717
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
718
|
+
return 49;
|
|
719
|
+
if (openingCode === 1 || openingCode === 2)
|
|
720
|
+
return 22;
|
|
721
|
+
if (openingCode === 3)
|
|
722
|
+
return 23;
|
|
723
|
+
if (openingCode === 4)
|
|
724
|
+
return 24;
|
|
725
|
+
if (openingCode === 7)
|
|
726
|
+
return 27;
|
|
727
|
+
if (openingCode === 8)
|
|
728
|
+
return 28;
|
|
729
|
+
if (openingCode === 9)
|
|
730
|
+
return 29;
|
|
731
|
+
if (openingCode === 0)
|
|
732
|
+
return 0;
|
|
733
|
+
return;
|
|
734
|
+
}, wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`, wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`, wrapWord = (rows, word, columns) => {
|
|
735
|
+
const characters = word[Symbol.iterator]();
|
|
736
|
+
let isInsideEscape = false;
|
|
737
|
+
let isInsideLinkEscape = false;
|
|
738
|
+
let lastRow = rows.at(-1);
|
|
739
|
+
let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
|
|
740
|
+
let currentCharacter = characters.next();
|
|
741
|
+
let nextCharacter = characters.next();
|
|
742
|
+
let rawCharacterIndex = 0;
|
|
743
|
+
while (!currentCharacter.done) {
|
|
744
|
+
const character = currentCharacter.value;
|
|
745
|
+
const characterLength = dist_default2(character);
|
|
746
|
+
if (visible + characterLength <= columns) {
|
|
747
|
+
rows[rows.length - 1] += character;
|
|
748
|
+
} else {
|
|
749
|
+
rows.push(character);
|
|
750
|
+
visible = 0;
|
|
751
|
+
}
|
|
752
|
+
if (character === ESC || character === CSI) {
|
|
753
|
+
isInsideEscape = true;
|
|
754
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
755
|
+
}
|
|
756
|
+
if (isInsideEscape) {
|
|
757
|
+
if (isInsideLinkEscape) {
|
|
758
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
759
|
+
isInsideEscape = false;
|
|
760
|
+
isInsideLinkEscape = false;
|
|
761
|
+
}
|
|
762
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
763
|
+
isInsideEscape = false;
|
|
764
|
+
}
|
|
765
|
+
} else {
|
|
766
|
+
visible += characterLength;
|
|
767
|
+
if (visible === columns && !nextCharacter.done) {
|
|
768
|
+
rows.push("");
|
|
769
|
+
visible = 0;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
currentCharacter = nextCharacter;
|
|
773
|
+
nextCharacter = characters.next();
|
|
774
|
+
rawCharacterIndex += character.length;
|
|
775
|
+
}
|
|
776
|
+
lastRow = rows.at(-1);
|
|
777
|
+
if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
|
|
778
|
+
rows[rows.length - 2] += rows.pop();
|
|
779
|
+
}
|
|
780
|
+
}, stringVisibleTrimSpacesRight = (string) => {
|
|
781
|
+
const words = string.split(" ");
|
|
782
|
+
let last = words.length;
|
|
783
|
+
while (last) {
|
|
784
|
+
if (dist_default2(words[last - 1])) {
|
|
785
|
+
break;
|
|
786
|
+
}
|
|
787
|
+
last--;
|
|
788
|
+
}
|
|
789
|
+
if (last === words.length) {
|
|
790
|
+
return string;
|
|
791
|
+
}
|
|
792
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
793
|
+
}, exec = (string, columns, options = {}) => {
|
|
794
|
+
if (options.trim !== false && string.trim() === "") {
|
|
795
|
+
return "";
|
|
796
|
+
}
|
|
797
|
+
let returnValue = "";
|
|
798
|
+
let escapeCode;
|
|
799
|
+
let escapeUrl;
|
|
800
|
+
const words = string.split(" ");
|
|
801
|
+
let rows = [""];
|
|
802
|
+
let rowLength = 0;
|
|
803
|
+
for (let index = 0;index < words.length; index++) {
|
|
804
|
+
const word = words[index];
|
|
805
|
+
if (options.trim !== false) {
|
|
806
|
+
const row = rows.at(-1) ?? "";
|
|
807
|
+
const trimmed = row.trimStart();
|
|
808
|
+
if (row.length !== trimmed.length) {
|
|
809
|
+
rows[rows.length - 1] = trimmed;
|
|
810
|
+
rowLength = dist_default2(trimmed);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (index !== 0) {
|
|
814
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
815
|
+
rows.push("");
|
|
816
|
+
rowLength = 0;
|
|
817
|
+
}
|
|
818
|
+
if (rowLength || options.trim === false) {
|
|
819
|
+
rows[rows.length - 1] += " ";
|
|
820
|
+
rowLength++;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
const wordLength = dist_default2(word);
|
|
824
|
+
if (options.hard && wordLength > columns) {
|
|
825
|
+
const remainingColumns = columns - rowLength;
|
|
826
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
827
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
828
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
829
|
+
rows.push("");
|
|
830
|
+
}
|
|
831
|
+
wrapWord(rows, word, columns);
|
|
832
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
836
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
837
|
+
wrapWord(rows, word, columns);
|
|
838
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
rows.push("");
|
|
842
|
+
rowLength = 0;
|
|
843
|
+
}
|
|
844
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
845
|
+
wrapWord(rows, word, columns);
|
|
846
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
847
|
+
continue;
|
|
848
|
+
}
|
|
849
|
+
rows[rows.length - 1] += word;
|
|
850
|
+
rowLength += wordLength;
|
|
851
|
+
}
|
|
852
|
+
if (options.trim !== false) {
|
|
853
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
854
|
+
}
|
|
855
|
+
const preString = rows.join(`
|
|
856
|
+
`);
|
|
857
|
+
let inSurrogate = false;
|
|
858
|
+
for (let i = 0;i < preString.length; i++) {
|
|
859
|
+
const character = preString[i];
|
|
860
|
+
returnValue += character;
|
|
861
|
+
if (!inSurrogate) {
|
|
862
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
863
|
+
} else {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
if (character === ESC || character === CSI) {
|
|
867
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
868
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
869
|
+
const groups = groupsResult?.groups;
|
|
870
|
+
if (groups?.code !== undefined) {
|
|
871
|
+
const code = Number.parseFloat(groups.code);
|
|
872
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
873
|
+
} else if (groups?.uri !== undefined) {
|
|
874
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (preString[i + 1] === `
|
|
878
|
+
`) {
|
|
879
|
+
if (escapeUrl) {
|
|
880
|
+
returnValue += wrapAnsiHyperlink("");
|
|
881
|
+
}
|
|
882
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
|
|
883
|
+
if (escapeCode && closingCode) {
|
|
884
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
885
|
+
}
|
|
886
|
+
} else if (character === `
|
|
887
|
+
`) {
|
|
888
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
889
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
890
|
+
}
|
|
891
|
+
if (escapeUrl) {
|
|
892
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
return returnValue;
|
|
897
|
+
}, CRLF_OR_LF;
|
|
898
|
+
var init_main = __esm(() => {
|
|
899
|
+
init_dist2();
|
|
900
|
+
ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
901
|
+
GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
902
|
+
CRLF_OR_LF = /\r?\n/;
|
|
521
903
|
});
|
|
522
904
|
|
|
523
905
|
// node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
524
906
|
var require_src = __commonJS((exports, module) => {
|
|
525
|
-
var
|
|
526
|
-
var
|
|
907
|
+
var ESC2 = "\x1B";
|
|
908
|
+
var CSI2 = `${ESC2}[`;
|
|
527
909
|
var beep = "\x07";
|
|
528
910
|
var cursor = {
|
|
529
911
|
to(x, y) {
|
|
530
912
|
if (!y)
|
|
531
|
-
return `${
|
|
532
|
-
return `${
|
|
913
|
+
return `${CSI2}${x + 1}G`;
|
|
914
|
+
return `${CSI2}${y + 1};${x + 1}H`;
|
|
533
915
|
},
|
|
534
916
|
move(x, y) {
|
|
535
917
|
let ret = "";
|
|
536
918
|
if (x < 0)
|
|
537
|
-
ret += `${
|
|
919
|
+
ret += `${CSI2}${-x}D`;
|
|
538
920
|
else if (x > 0)
|
|
539
|
-
ret += `${
|
|
921
|
+
ret += `${CSI2}${x}C`;
|
|
540
922
|
if (y < 0)
|
|
541
|
-
ret += `${
|
|
923
|
+
ret += `${CSI2}${-y}A`;
|
|
542
924
|
else if (y > 0)
|
|
543
|
-
ret += `${
|
|
925
|
+
ret += `${CSI2}${y}B`;
|
|
544
926
|
return ret;
|
|
545
927
|
},
|
|
546
|
-
up: (count = 1) => `${
|
|
547
|
-
down: (count = 1) => `${
|
|
548
|
-
forward: (count = 1) => `${
|
|
549
|
-
backward: (count = 1) => `${
|
|
550
|
-
nextLine: (count = 1) => `${
|
|
551
|
-
prevLine: (count = 1) => `${
|
|
552
|
-
left: `${
|
|
553
|
-
hide: `${
|
|
554
|
-
show: `${
|
|
555
|
-
save: `${
|
|
556
|
-
restore: `${
|
|
928
|
+
up: (count = 1) => `${CSI2}${count}A`,
|
|
929
|
+
down: (count = 1) => `${CSI2}${count}B`,
|
|
930
|
+
forward: (count = 1) => `${CSI2}${count}C`,
|
|
931
|
+
backward: (count = 1) => `${CSI2}${count}D`,
|
|
932
|
+
nextLine: (count = 1) => `${CSI2}E`.repeat(count),
|
|
933
|
+
prevLine: (count = 1) => `${CSI2}F`.repeat(count),
|
|
934
|
+
left: `${CSI2}G`,
|
|
935
|
+
hide: `${CSI2}?25l`,
|
|
936
|
+
show: `${CSI2}?25h`,
|
|
937
|
+
save: `${ESC2}7`,
|
|
938
|
+
restore: `${ESC2}8`
|
|
557
939
|
};
|
|
558
940
|
var scroll = {
|
|
559
|
-
up: (count = 1) => `${
|
|
560
|
-
down: (count = 1) => `${
|
|
941
|
+
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
942
|
+
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
561
943
|
};
|
|
562
944
|
var erase = {
|
|
563
|
-
screen: `${
|
|
564
|
-
up: (count = 1) => `${
|
|
565
|
-
down: (count = 1) => `${
|
|
566
|
-
line: `${
|
|
567
|
-
lineEnd: `${
|
|
568
|
-
lineStart: `${
|
|
945
|
+
screen: `${CSI2}2J`,
|
|
946
|
+
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
947
|
+
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
948
|
+
line: `${CSI2}2K`,
|
|
949
|
+
lineEnd: `${CSI2}K`,
|
|
950
|
+
lineStart: `${CSI2}1K`,
|
|
569
951
|
lines(count) {
|
|
570
952
|
let clear = "";
|
|
571
953
|
for (let i = 0;i < count; i++)
|
|
@@ -578,56 +960,96 @@ var require_src = __commonJS((exports, module) => {
|
|
|
578
960
|
module.exports = { cursor, scroll, erase, beep };
|
|
579
961
|
});
|
|
580
962
|
|
|
581
|
-
// node_modules/.bun/@clack+core@1.
|
|
582
|
-
import { styleText as
|
|
583
|
-
import { stdout as
|
|
584
|
-
import
|
|
585
|
-
function
|
|
586
|
-
if (!
|
|
587
|
-
return
|
|
588
|
-
const
|
|
589
|
-
return
|
|
590
|
-
}
|
|
591
|
-
function
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
`);
|
|
597
|
-
}
|
|
598
|
-
function H(t, e) {
|
|
599
|
-
if (typeof t == "string")
|
|
600
|
-
return _.aliases.get(t) === e;
|
|
601
|
-
for (const s of t)
|
|
602
|
-
if (s !== undefined && H(s, e))
|
|
963
|
+
// node_modules/.bun/@clack+core@1.2.0/node_modules/@clack/core/dist/index.mjs
|
|
964
|
+
import { styleText as y } from "util";
|
|
965
|
+
import { stdout as S, stdin as $ } from "process";
|
|
966
|
+
import P from "readline";
|
|
967
|
+
function d(r, t, e) {
|
|
968
|
+
if (!e.some((o) => !o.disabled))
|
|
969
|
+
return r;
|
|
970
|
+
const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
|
|
971
|
+
return e[n].disabled ? d(n, t < 0 ? -1 : 1, e) : n;
|
|
972
|
+
}
|
|
973
|
+
function V(r, t) {
|
|
974
|
+
if (typeof r == "string")
|
|
975
|
+
return u.aliases.get(r) === t;
|
|
976
|
+
for (const e of r)
|
|
977
|
+
if (e !== undefined && V(e, t))
|
|
603
978
|
return true;
|
|
604
979
|
return false;
|
|
605
980
|
}
|
|
606
|
-
function
|
|
607
|
-
if (
|
|
981
|
+
function j(r, t) {
|
|
982
|
+
if (r === t)
|
|
608
983
|
return;
|
|
609
|
-
const
|
|
610
|
-
`),
|
|
611
|
-
`),
|
|
612
|
-
for (let
|
|
613
|
-
|
|
614
|
-
return { lines: n, numLinesBefore:
|
|
615
|
-
}
|
|
616
|
-
function
|
|
617
|
-
return
|
|
618
|
-
}
|
|
619
|
-
function
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
function
|
|
624
|
-
const
|
|
625
|
-
return
|
|
626
|
-
`).map((n,
|
|
984
|
+
const e = r.split(`
|
|
985
|
+
`), s = t.split(`
|
|
986
|
+
`), i = Math.max(e.length, s.length), n = [];
|
|
987
|
+
for (let o = 0;o < i; o++)
|
|
988
|
+
e[o] !== s[o] && n.push(o);
|
|
989
|
+
return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
|
|
990
|
+
}
|
|
991
|
+
function q(r) {
|
|
992
|
+
return r === C;
|
|
993
|
+
}
|
|
994
|
+
function w(r, t) {
|
|
995
|
+
const e = r;
|
|
996
|
+
e.isTTY && e.setRawMode(t);
|
|
997
|
+
}
|
|
998
|
+
function R(r, t, e, s = e) {
|
|
999
|
+
const i = O(r ?? S);
|
|
1000
|
+
return wrapAnsi(t, i - e.length, { hard: true, trim: false }).split(`
|
|
1001
|
+
`).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
|
|
627
1002
|
`);
|
|
628
1003
|
}
|
|
629
|
-
|
|
630
|
-
|
|
1004
|
+
function W(r, t) {
|
|
1005
|
+
if (r === undefined || t.length === 0)
|
|
1006
|
+
return 0;
|
|
1007
|
+
const e = t.findIndex((s) => s.value === r);
|
|
1008
|
+
return e !== -1 ? e : 0;
|
|
1009
|
+
}
|
|
1010
|
+
function B(r, t) {
|
|
1011
|
+
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
1012
|
+
}
|
|
1013
|
+
function J(r, t) {
|
|
1014
|
+
if (t)
|
|
1015
|
+
return r ? t : t[0];
|
|
1016
|
+
}
|
|
1017
|
+
function L(r) {
|
|
1018
|
+
return [...r].map((t) => X[t]);
|
|
1019
|
+
}
|
|
1020
|
+
function Z(r) {
|
|
1021
|
+
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
|
|
1022
|
+
let s = "/";
|
|
1023
|
+
for (const i of t)
|
|
1024
|
+
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 });
|
|
1025
|
+
return { segments: e, separator: s };
|
|
1026
|
+
}
|
|
1027
|
+
function k(r) {
|
|
1028
|
+
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
1029
|
+
}
|
|
1030
|
+
function I(r) {
|
|
1031
|
+
return { year: k(r.year), month: k(r.month), day: k(r.day) };
|
|
1032
|
+
}
|
|
1033
|
+
function T(r, t) {
|
|
1034
|
+
return new Date(r || 2001, t || 1, 0).getDate();
|
|
1035
|
+
}
|
|
1036
|
+
function F(r) {
|
|
1037
|
+
const { year: t, month: e, day: s } = I(r);
|
|
1038
|
+
if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
|
|
1039
|
+
return;
|
|
1040
|
+
const i = new Date(Date.UTC(t, e - 1, s));
|
|
1041
|
+
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s))
|
|
1042
|
+
return { year: t, month: e, day: s };
|
|
1043
|
+
}
|
|
1044
|
+
function N(r) {
|
|
1045
|
+
const t = F(r);
|
|
1046
|
+
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
|
|
1047
|
+
}
|
|
1048
|
+
function tt(r, t, e, s) {
|
|
1049
|
+
const i = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null, n = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null;
|
|
1050
|
+
return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : T(t.year, t.month) };
|
|
1051
|
+
}
|
|
1052
|
+
var import_sisteransi, E, G, u, Y, C, O = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80, A = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20, p = class {
|
|
631
1053
|
input;
|
|
632
1054
|
output;
|
|
633
1055
|
_abortSignal;
|
|
@@ -642,408 +1064,393 @@ class B {
|
|
|
642
1064
|
error = "";
|
|
643
1065
|
value;
|
|
644
1066
|
userInput = "";
|
|
645
|
-
constructor(
|
|
646
|
-
const { input:
|
|
647
|
-
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track =
|
|
1067
|
+
constructor(t, e = true) {
|
|
1068
|
+
const { input: s = $, output: i = S, render: n, signal: o, ...a } = t;
|
|
1069
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = e, this._abortSignal = o, this.input = s, this.output = i;
|
|
648
1070
|
}
|
|
649
1071
|
unsubscribe() {
|
|
650
1072
|
this._subscribers.clear();
|
|
651
1073
|
}
|
|
652
|
-
setSubscriber(
|
|
653
|
-
const
|
|
654
|
-
|
|
1074
|
+
setSubscriber(t, e) {
|
|
1075
|
+
const s = this._subscribers.get(t) ?? [];
|
|
1076
|
+
s.push(e), this._subscribers.set(t, s);
|
|
655
1077
|
}
|
|
656
|
-
on(
|
|
657
|
-
this.setSubscriber(
|
|
1078
|
+
on(t, e) {
|
|
1079
|
+
this.setSubscriber(t, { cb: e });
|
|
658
1080
|
}
|
|
659
|
-
once(
|
|
660
|
-
this.setSubscriber(
|
|
1081
|
+
once(t, e) {
|
|
1082
|
+
this.setSubscriber(t, { cb: e, once: true });
|
|
661
1083
|
}
|
|
662
|
-
emit(
|
|
663
|
-
const
|
|
1084
|
+
emit(t, ...e) {
|
|
1085
|
+
const s = this._subscribers.get(t) ?? [], i = [];
|
|
1086
|
+
for (const n of s)
|
|
1087
|
+
n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
|
|
664
1088
|
for (const n of i)
|
|
665
|
-
n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
666
|
-
for (const n of r)
|
|
667
1089
|
n();
|
|
668
1090
|
}
|
|
669
1091
|
prompt() {
|
|
670
|
-
return new Promise((
|
|
1092
|
+
return new Promise((t) => {
|
|
671
1093
|
if (this._abortSignal) {
|
|
672
1094
|
if (this._abortSignal.aborted)
|
|
673
|
-
return this.state = "cancel", this.close(),
|
|
1095
|
+
return this.state = "cancel", this.close(), t(C);
|
|
674
1096
|
this._abortSignal.addEventListener("abort", () => {
|
|
675
1097
|
this.state = "cancel", this.close();
|
|
676
1098
|
}, { once: true });
|
|
677
1099
|
}
|
|
678
|
-
this.rl =
|
|
679
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render),
|
|
1100
|
+
this.rl = P.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
1101
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
|
|
680
1102
|
}), this.once("cancel", () => {
|
|
681
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render),
|
|
1103
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(C);
|
|
682
1104
|
});
|
|
683
1105
|
});
|
|
684
1106
|
}
|
|
685
|
-
_isActionKey(
|
|
686
|
-
return
|
|
1107
|
+
_isActionKey(t, e) {
|
|
1108
|
+
return t === "\t";
|
|
687
1109
|
}
|
|
688
|
-
_setValue(
|
|
689
|
-
this.value =
|
|
1110
|
+
_setValue(t) {
|
|
1111
|
+
this.value = t, this.emit("value", this.value);
|
|
690
1112
|
}
|
|
691
|
-
_setUserInput(
|
|
692
|
-
this.userInput =
|
|
1113
|
+
_setUserInput(t, e) {
|
|
1114
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
693
1115
|
}
|
|
694
1116
|
_clearUserInput() {
|
|
695
1117
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
696
1118
|
}
|
|
697
|
-
onKeypress(
|
|
698
|
-
if (this._track &&
|
|
1119
|
+
onKeypress(t, e) {
|
|
1120
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, 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 && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
|
|
699
1121
|
if (this.opts.validate) {
|
|
700
|
-
const
|
|
701
|
-
|
|
1122
|
+
const s = this.opts.validate(this.value);
|
|
1123
|
+
s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
|
|
702
1124
|
}
|
|
703
1125
|
this.state !== "error" && (this.state = "submit");
|
|
704
1126
|
}
|
|
705
|
-
|
|
1127
|
+
V([t, 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();
|
|
706
1128
|
}
|
|
707
1129
|
close() {
|
|
708
1130
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
709
|
-
`),
|
|
1131
|
+
`), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
710
1132
|
}
|
|
711
1133
|
restoreCursor() {
|
|
712
|
-
const
|
|
1134
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
713
1135
|
`).length - 1;
|
|
714
|
-
this.output.write(import_sisteransi.cursor.move(-999,
|
|
1136
|
+
this.output.write(import_sisteransi.cursor.move(-999, t * -1));
|
|
715
1137
|
}
|
|
716
1138
|
render() {
|
|
717
|
-
const
|
|
718
|
-
if (
|
|
1139
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
1140
|
+
if (t !== this._prevFrame) {
|
|
719
1141
|
if (this.state === "initial")
|
|
720
1142
|
this.output.write(import_sisteransi.cursor.hide);
|
|
721
1143
|
else {
|
|
722
|
-
const
|
|
723
|
-
if (this.restoreCursor(),
|
|
724
|
-
const
|
|
725
|
-
let
|
|
726
|
-
if (
|
|
727
|
-
this._prevFrame =
|
|
1144
|
+
const e = j(this._prevFrame, t), s = A(this.output);
|
|
1145
|
+
if (this.restoreCursor(), e) {
|
|
1146
|
+
const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
|
|
1147
|
+
let o = e.lines.find((a) => a >= i);
|
|
1148
|
+
if (o === undefined) {
|
|
1149
|
+
this._prevFrame = t;
|
|
728
1150
|
return;
|
|
729
1151
|
}
|
|
730
|
-
if (
|
|
731
|
-
this.output.write(import_sisteransi.cursor.move(0,
|
|
732
|
-
const a =
|
|
1152
|
+
if (e.lines.length === 1) {
|
|
1153
|
+
this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
1154
|
+
const a = t.split(`
|
|
733
1155
|
`);
|
|
734
|
-
this.output.write(a[
|
|
1156
|
+
this.output.write(a[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
|
|
735
1157
|
return;
|
|
736
|
-
} else if (
|
|
737
|
-
if (
|
|
738
|
-
|
|
1158
|
+
} else if (e.lines.length > 1) {
|
|
1159
|
+
if (i < n)
|
|
1160
|
+
o = i;
|
|
739
1161
|
else {
|
|
740
|
-
const
|
|
741
|
-
|
|
1162
|
+
const h = o - n;
|
|
1163
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
742
1164
|
}
|
|
743
1165
|
this.output.write(import_sisteransi.erase.down());
|
|
744
|
-
const a =
|
|
745
|
-
`).slice(
|
|
1166
|
+
const a = t.split(`
|
|
1167
|
+
`).slice(o);
|
|
746
1168
|
this.output.write(a.join(`
|
|
747
|
-
`)), this._prevFrame =
|
|
1169
|
+
`)), this._prevFrame = t;
|
|
748
1170
|
return;
|
|
749
1171
|
}
|
|
750
1172
|
}
|
|
751
1173
|
this.output.write(import_sisteransi.erase.down());
|
|
752
1174
|
}
|
|
753
|
-
this.output.write(
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
function wt(t, e) {
|
|
758
|
-
if (t === undefined || e.length === 0)
|
|
759
|
-
return 0;
|
|
760
|
-
const s = e.findIndex((i) => i.value === t);
|
|
761
|
-
return s !== -1 ? s : 0;
|
|
762
|
-
}
|
|
763
|
-
function Dt(t, e) {
|
|
764
|
-
return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
|
|
765
|
-
}
|
|
766
|
-
function St(t, e) {
|
|
767
|
-
if (e)
|
|
768
|
-
return t ? e : e[0];
|
|
769
|
-
}
|
|
770
|
-
var import_sisteransi, at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O, y, L, P, M, ct, ft, X = (t, e = {}, s = {}) => {
|
|
771
|
-
const i = e.limit ?? 1 / 0, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
|
|
772
|
-
let h = 0, o = 0, p = t.length, v = 0, F = false, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
|
|
773
|
-
t:
|
|
774
|
-
for (;; ) {
|
|
775
|
-
if (w > C || o >= p && o > h) {
|
|
776
|
-
const ut = t.slice(C, w) || t.slice(h, o);
|
|
777
|
-
v = 0;
|
|
778
|
-
for (const Y of ut.replaceAll(ct, "")) {
|
|
779
|
-
const $ = Y.codePointAt(0) || 0;
|
|
780
|
-
if (lt($) ? f = m : ht($) ? f = V : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
|
|
781
|
-
F = true;
|
|
782
|
-
break t;
|
|
783
|
-
}
|
|
784
|
-
v += Y.length, c += f;
|
|
785
|
-
}
|
|
786
|
-
C = w = 0;
|
|
787
|
-
}
|
|
788
|
-
if (o >= p)
|
|
789
|
-
break;
|
|
790
|
-
if (M.lastIndex = o, M.test(t)) {
|
|
791
|
-
if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
|
|
792
|
-
F = true;
|
|
793
|
-
break;
|
|
794
|
-
}
|
|
795
|
-
c += f, C = h, w = o, o = h = M.lastIndex;
|
|
796
|
-
continue;
|
|
797
|
-
}
|
|
798
|
-
if (O.lastIndex = o, O.test(t)) {
|
|
799
|
-
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
|
|
800
|
-
F = true;
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
c += u, C = h, w = o, o = h = O.lastIndex;
|
|
804
|
-
continue;
|
|
805
|
-
}
|
|
806
|
-
if (y.lastIndex = o, y.test(t)) {
|
|
807
|
-
if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
|
|
808
|
-
F = true;
|
|
809
|
-
break;
|
|
810
|
-
}
|
|
811
|
-
c += f, C = h, w = o, o = h = y.lastIndex;
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
if (L.lastIndex = o, L.test(t)) {
|
|
815
|
-
if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
|
|
816
|
-
F = true;
|
|
817
|
-
break;
|
|
818
|
-
}
|
|
819
|
-
c += f, C = h, w = o, o = h = L.lastIndex;
|
|
820
|
-
continue;
|
|
821
|
-
}
|
|
822
|
-
if (P.lastIndex = o, P.test(t)) {
|
|
823
|
-
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
|
|
824
|
-
F = true;
|
|
825
|
-
break;
|
|
826
|
-
}
|
|
827
|
-
c += g, C = h, w = o, o = h = P.lastIndex;
|
|
828
|
-
continue;
|
|
829
|
-
}
|
|
830
|
-
o += 1;
|
|
831
|
-
}
|
|
832
|
-
return { width: F ? b : c, index: F ? d : p, truncated: F, ellipsed: F && i >= n };
|
|
833
|
-
}, pt, S = (t, e = {}) => X(t, pt, e).width, T = "\x1B", Z = "\x9B", Ft = 39, j = "\x07", Q = "[", dt = "]", tt = "m", U, et, mt = (t) => {
|
|
834
|
-
if (t >= 30 && t <= 37 || t >= 90 && t <= 97)
|
|
835
|
-
return 39;
|
|
836
|
-
if (t >= 40 && t <= 47 || t >= 100 && t <= 107)
|
|
837
|
-
return 49;
|
|
838
|
-
if (t === 1 || t === 2)
|
|
839
|
-
return 22;
|
|
840
|
-
if (t === 3)
|
|
841
|
-
return 23;
|
|
842
|
-
if (t === 4)
|
|
843
|
-
return 24;
|
|
844
|
-
if (t === 7)
|
|
845
|
-
return 27;
|
|
846
|
-
if (t === 8)
|
|
847
|
-
return 28;
|
|
848
|
-
if (t === 9)
|
|
849
|
-
return 29;
|
|
850
|
-
if (t === 0)
|
|
851
|
-
return 0;
|
|
852
|
-
}, st = (t) => `${T}${Q}${t}${tt}`, it = (t) => `${T}${U}${t}${j}`, gt = (t) => t.map((e) => S(e)), G = (t, e, s) => {
|
|
853
|
-
const i = e[Symbol.iterator]();
|
|
854
|
-
let r = false, n = false, u = t.at(-1), a = u === undefined ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
855
|
-
for (;!l.done; ) {
|
|
856
|
-
const m = l.value, A = S(m);
|
|
857
|
-
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === T || m === Z) && (r = true, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
858
|
-
}
|
|
859
|
-
u = t.at(-1), !a && u !== undefined && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
860
|
-
}, vt = (t) => {
|
|
861
|
-
const e = t.split(" ");
|
|
862
|
-
let s = e.length;
|
|
863
|
-
for (;s > 0 && !(S(e[s - 1]) > 0); )
|
|
864
|
-
s--;
|
|
865
|
-
return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
|
|
866
|
-
}, Et = (t, e, s = {}) => {
|
|
867
|
-
if (s.trim !== false && t.trim() === "")
|
|
868
|
-
return "";
|
|
869
|
-
let i = "", r, n;
|
|
870
|
-
const u = t.split(" "), a = gt(u);
|
|
871
|
-
let l = [""];
|
|
872
|
-
for (const [h, o] of u.entries()) {
|
|
873
|
-
s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
874
|
-
let p = S(l.at(-1) ?? "");
|
|
875
|
-
if (h !== 0 && (p >= e && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
|
|
876
|
-
const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
|
|
877
|
-
Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
|
|
878
|
-
continue;
|
|
879
|
-
}
|
|
880
|
-
if (p + a[h] > e && p > 0 && a[h] > 0) {
|
|
881
|
-
if (s.wordWrap === false && p < e) {
|
|
882
|
-
G(l, o, e);
|
|
883
|
-
continue;
|
|
884
|
-
}
|
|
885
|
-
l.push("");
|
|
886
|
-
}
|
|
887
|
-
if (p + a[h] > e && s.wordWrap === false) {
|
|
888
|
-
G(l, o, e);
|
|
889
|
-
continue;
|
|
1175
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
890
1176
|
}
|
|
891
|
-
l[l.length - 1] += o;
|
|
892
|
-
}
|
|
893
|
-
s.trim !== false && (l = l.map((h) => vt(h)));
|
|
894
|
-
const E = l.join(`
|
|
895
|
-
`), g = E[Symbol.iterator]();
|
|
896
|
-
let m = g.next(), A = g.next(), V = 0;
|
|
897
|
-
for (;!m.done; ) {
|
|
898
|
-
const h = m.value, o = A.value;
|
|
899
|
-
if (i += h, h === T || h === Z) {
|
|
900
|
-
et.lastIndex = V + 1;
|
|
901
|
-
const F = et.exec(E)?.groups;
|
|
902
|
-
if (F?.code !== undefined) {
|
|
903
|
-
const d = Number.parseFloat(F.code);
|
|
904
|
-
r = d === Ft ? undefined : d;
|
|
905
|
-
} else
|
|
906
|
-
F?.uri !== undefined && (n = F.uri.length === 0 ? undefined : F.uri);
|
|
907
|
-
}
|
|
908
|
-
const p = r ? mt(r) : undefined;
|
|
909
|
-
o === `
|
|
910
|
-
` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
|
|
911
|
-
` && (r && p && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
|
|
912
1177
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1178
|
+
}, H, Q, X, et, st, nt;
|
|
1179
|
+
var init_dist3 = __esm(() => {
|
|
1180
|
+
init_main();
|
|
916
1181
|
import_sisteransi = __toESM(require_src(), 1);
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
ft = { limit: 1 / 0, ellipsis: "" };
|
|
924
|
-
pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
925
|
-
U = `${dt}8;;`;
|
|
926
|
-
et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
|
|
927
|
-
At = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
928
|
-
_ = { actions: new Set(At), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true };
|
|
929
|
-
bt = globalThis.process.platform.startsWith("win");
|
|
930
|
-
z = Symbol("clack:cancel");
|
|
931
|
-
Vt = class Vt extends B {
|
|
1182
|
+
E = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
1183
|
+
G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
1184
|
+
u = { actions: new Set(E), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...G], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
|
|
1185
|
+
Y = globalThis.process.platform.startsWith("win");
|
|
1186
|
+
C = Symbol("clack:cancel");
|
|
1187
|
+
H = class extends p {
|
|
932
1188
|
filteredOptions;
|
|
933
1189
|
multiple;
|
|
934
1190
|
isNavigating = false;
|
|
935
1191
|
selectedValues = [];
|
|
936
1192
|
focusedValue;
|
|
937
|
-
#
|
|
938
|
-
#
|
|
939
|
-
#
|
|
940
|
-
#
|
|
1193
|
+
#e = 0;
|
|
1194
|
+
#o = "";
|
|
1195
|
+
#t;
|
|
1196
|
+
#n;
|
|
1197
|
+
#a;
|
|
941
1198
|
get cursor() {
|
|
942
|
-
return this.#
|
|
1199
|
+
return this.#e;
|
|
943
1200
|
}
|
|
944
1201
|
get userInputWithCursor() {
|
|
945
1202
|
if (!this.userInput)
|
|
946
|
-
return
|
|
1203
|
+
return y(["inverse", "hidden"], "_");
|
|
947
1204
|
if (this._cursor >= this.userInput.length)
|
|
948
1205
|
return `${this.userInput}\u2588`;
|
|
949
|
-
const
|
|
950
|
-
return `${
|
|
1206
|
+
const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
|
|
1207
|
+
return `${t}${y("inverse", e)}${s.join("")}`;
|
|
951
1208
|
}
|
|
952
1209
|
get options() {
|
|
953
|
-
return typeof this.#
|
|
954
|
-
}
|
|
955
|
-
constructor(
|
|
956
|
-
super(
|
|
957
|
-
const
|
|
958
|
-
this.filteredOptions = [...
|
|
959
|
-
let
|
|
960
|
-
if (
|
|
961
|
-
for (const
|
|
962
|
-
const n =
|
|
963
|
-
n !== -1 && (this.toggleSelected(
|
|
964
|
-
}
|
|
965
|
-
this.focusedValue = this.options[this.#
|
|
966
|
-
}
|
|
967
|
-
_isActionKey(
|
|
968
|
-
return
|
|
969
|
-
}
|
|
970
|
-
#
|
|
971
|
-
const
|
|
972
|
-
|
|
1210
|
+
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
1211
|
+
}
|
|
1212
|
+
constructor(t) {
|
|
1213
|
+
super(t), this.#n = t.options, this.#a = t.placeholder;
|
|
1214
|
+
const e = this.options;
|
|
1215
|
+
this.filteredOptions = [...e], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
|
|
1216
|
+
let s;
|
|
1217
|
+
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s)
|
|
1218
|
+
for (const i of s) {
|
|
1219
|
+
const n = e.findIndex((o) => o.value === i);
|
|
1220
|
+
n !== -1 && (this.toggleSelected(i), this.#e = n);
|
|
1221
|
+
}
|
|
1222
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
1223
|
+
}
|
|
1224
|
+
_isActionKey(t, e) {
|
|
1225
|
+
return t === "\t" || this.multiple && this.isNavigating && e.name === "space" && t !== undefined && t !== "";
|
|
1226
|
+
}
|
|
1227
|
+
#s(t, e) {
|
|
1228
|
+
const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === "\t", a = this.#a, h = this.options, l = a !== undefined && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : true));
|
|
1229
|
+
if (e.name === "tab" && o && l) {
|
|
1230
|
+
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
s || i ? (this.#e = d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
973
1234
|
}
|
|
974
1235
|
deselectAll() {
|
|
975
1236
|
this.selectedValues = [];
|
|
976
1237
|
}
|
|
977
|
-
toggleSelected(
|
|
978
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(
|
|
1238
|
+
toggleSelected(t) {
|
|
1239
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e) => e !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
|
|
979
1240
|
}
|
|
980
|
-
#
|
|
981
|
-
if (
|
|
982
|
-
this.#
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
const
|
|
986
|
-
this.#
|
|
987
|
-
const
|
|
988
|
-
|
|
1241
|
+
#i(t) {
|
|
1242
|
+
if (t !== this.#o) {
|
|
1243
|
+
this.#o = t;
|
|
1244
|
+
const e = this.options;
|
|
1245
|
+
t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
|
|
1246
|
+
const s = W(this.focusedValue, this.filteredOptions);
|
|
1247
|
+
this.#e = d(s, 0, this.filteredOptions);
|
|
1248
|
+
const i = this.filteredOptions[this.#e];
|
|
1249
|
+
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
989
1250
|
}
|
|
990
1251
|
}
|
|
991
1252
|
};
|
|
992
|
-
|
|
1253
|
+
Q = class Q extends p {
|
|
993
1254
|
get cursor() {
|
|
994
1255
|
return this.value ? 0 : 1;
|
|
995
1256
|
}
|
|
996
1257
|
get _value() {
|
|
997
1258
|
return this.cursor === 0;
|
|
998
1259
|
}
|
|
999
|
-
constructor(
|
|
1000
|
-
super(
|
|
1260
|
+
constructor(t) {
|
|
1261
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
1001
1262
|
this.value = this._value;
|
|
1002
|
-
}), this.on("confirm", (
|
|
1003
|
-
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value =
|
|
1263
|
+
}), this.on("confirm", (e) => {
|
|
1264
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = e, this.state = "submit", this.close();
|
|
1004
1265
|
}), this.on("cursor", () => {
|
|
1005
1266
|
this.value = !this.value;
|
|
1006
1267
|
});
|
|
1007
1268
|
}
|
|
1008
1269
|
};
|
|
1009
|
-
|
|
1270
|
+
X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
1271
|
+
et = class et extends p {
|
|
1272
|
+
#e;
|
|
1273
|
+
#o;
|
|
1274
|
+
#t;
|
|
1275
|
+
#n;
|
|
1276
|
+
#a;
|
|
1277
|
+
#s = { segmentIndex: 0, positionInSegment: 0 };
|
|
1278
|
+
#i = true;
|
|
1279
|
+
#r = null;
|
|
1280
|
+
inlineError = "";
|
|
1281
|
+
get segmentCursor() {
|
|
1282
|
+
return { ...this.#s };
|
|
1283
|
+
}
|
|
1284
|
+
get segmentValues() {
|
|
1285
|
+
return { ...this.#t };
|
|
1286
|
+
}
|
|
1287
|
+
get segments() {
|
|
1288
|
+
return this.#e;
|
|
1289
|
+
}
|
|
1290
|
+
get separator() {
|
|
1291
|
+
return this.#o;
|
|
1292
|
+
}
|
|
1293
|
+
get formattedValue() {
|
|
1294
|
+
return this.#c(this.#t);
|
|
1295
|
+
}
|
|
1296
|
+
#c(t) {
|
|
1297
|
+
return this.#e.map((e) => t[e.type]).join(this.#o);
|
|
1298
|
+
}
|
|
1299
|
+
#h() {
|
|
1300
|
+
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
|
|
1301
|
+
}
|
|
1302
|
+
constructor(t) {
|
|
1303
|
+
const e = t.format ? { segments: L(t.format), separator: t.separator ?? "/" } : Z(t.locale), s = t.separator ?? e.separator, i = t.format ? L(t.format) : e.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, a = i.map((h) => o[h.type]).join(s);
|
|
1304
|
+
super({ ...t, initialUserInput: a }, false), this.#e = i, this.#o = s, this.#t = o, this.#n = t.minDate, this.#a = t.maxDate, this.#h(), this.on("cursor", (h) => this.#d(h)), this.on("key", (h, l) => this.#f(h, l)), this.on("finalize", () => this.#g(t));
|
|
1305
|
+
}
|
|
1306
|
+
#u() {
|
|
1307
|
+
const t = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t];
|
|
1308
|
+
if (e)
|
|
1309
|
+
return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t };
|
|
1310
|
+
}
|
|
1311
|
+
#l(t) {
|
|
1312
|
+
this.inlineError = "", this.#r = null;
|
|
1313
|
+
const e = this.#u();
|
|
1314
|
+
e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t)), this.#s.positionInSegment = 0, this.#i = true);
|
|
1315
|
+
}
|
|
1316
|
+
#p(t) {
|
|
1317
|
+
const e = this.#u();
|
|
1318
|
+
if (!e)
|
|
1319
|
+
return;
|
|
1320
|
+
const { segment: s } = e, i = this.#t[s.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, a = tt(s.type, I(this.#t), this.#n, this.#a);
|
|
1321
|
+
let h;
|
|
1322
|
+
n ? h = t === 1 ? a.min : a.max : h = Math.max(Math.min(a.max, o + t), a.min), this.#t = { ...this.#t, [s.type]: h.toString().padStart(s.len, "0") }, this.#i = true, this.#r = null, this.#h();
|
|
1323
|
+
}
|
|
1324
|
+
#d(t) {
|
|
1325
|
+
if (t)
|
|
1326
|
+
switch (t) {
|
|
1327
|
+
case "right":
|
|
1328
|
+
return this.#l(1);
|
|
1329
|
+
case "left":
|
|
1330
|
+
return this.#l(-1);
|
|
1331
|
+
case "up":
|
|
1332
|
+
return this.#p(1);
|
|
1333
|
+
case "down":
|
|
1334
|
+
return this.#p(-1);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
#f(t, e) {
|
|
1338
|
+
if (e?.name === "backspace" || e?.sequence === "\x7F" || e?.sequence === "\b" || t === "\x7F" || t === "\b") {
|
|
1339
|
+
this.inlineError = "";
|
|
1340
|
+
const s = this.#u();
|
|
1341
|
+
if (!s)
|
|
1342
|
+
return;
|
|
1343
|
+
if (!this.#t[s.segment.type].replace(/_/g, "")) {
|
|
1344
|
+
this.#l(-1);
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
if (e?.name === "tab") {
|
|
1351
|
+
this.inlineError = "";
|
|
1352
|
+
const s = this.#u();
|
|
1353
|
+
if (!s)
|
|
1354
|
+
return;
|
|
1355
|
+
const i = e.shift ? -1 : 1, n = s.index + i;
|
|
1356
|
+
n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
if (t && /^[0-9]$/.test(t)) {
|
|
1360
|
+
const s = this.#u();
|
|
1361
|
+
if (!s)
|
|
1362
|
+
return;
|
|
1363
|
+
const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
|
|
1364
|
+
if (this.#i && this.#r !== null && !n) {
|
|
1365
|
+
const m = this.#r + t, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
|
|
1366
|
+
if (b) {
|
|
1367
|
+
this.inlineError = b, this.#r = null, this.#i = false;
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
this.inlineError = "", this.#t[i.type] = m, this.#r = null, this.#i = false, this.#h(), s.index < this.#e.length - 1 && (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true);
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
|
|
1374
|
+
const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
|
|
1375
|
+
if (h < 0 || h >= i.len)
|
|
1376
|
+
return;
|
|
1377
|
+
let l = o.slice(0, h) + t + o.slice(h + 1), f = false;
|
|
1378
|
+
if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
|
|
1379
|
+
const m = Number.parseInt(t, 10);
|
|
1380
|
+
l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
|
|
1381
|
+
}
|
|
1382
|
+
if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
|
|
1383
|
+
const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
|
|
1384
|
+
if (g) {
|
|
1385
|
+
this.inlineError = g;
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
this.inlineError = "", this.#t[i.type] = l;
|
|
1390
|
+
const v = l.includes("_") ? undefined : F(this.#t);
|
|
1391
|
+
if (v) {
|
|
1392
|
+
const { year: m, month: g } = v, b = T(m, g);
|
|
1393
|
+
this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(b, v.day))).padStart(2, "0") };
|
|
1394
|
+
}
|
|
1395
|
+
this.#h();
|
|
1396
|
+
const U = l.indexOf("_");
|
|
1397
|
+
f ? (this.#i = true, this.#r = t) : U >= 0 ? this.#s.positionInSegment = U : a >= 0 && s.index < this.#e.length - 1 ? (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true) : this.#s.positionInSegment = Math.min(h + 1, i.len - 1);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
#m(t, e) {
|
|
1401
|
+
const { month: s, day: i } = I(t);
|
|
1402
|
+
if (e.type === "month" && (s < 0 || s > 12))
|
|
1403
|
+
return u.date.messages.invalidMonth;
|
|
1404
|
+
if (e.type === "day" && (i < 0 || i > 31))
|
|
1405
|
+
return u.date.messages.invalidDay(31, "any month");
|
|
1406
|
+
}
|
|
1407
|
+
#g(t) {
|
|
1408
|
+
const { year: e, month: s, day: i } = I(this.#t);
|
|
1409
|
+
if (e && s && i) {
|
|
1410
|
+
const n = T(e, s);
|
|
1411
|
+
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
1412
|
+
}
|
|
1413
|
+
this.value = N(this.#t) ?? t.defaultValue ?? undefined;
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
st = class st extends p {
|
|
1010
1417
|
options;
|
|
1011
1418
|
cursor = 0;
|
|
1012
|
-
#
|
|
1013
|
-
getGroupItems(
|
|
1014
|
-
return this.options.filter((
|
|
1419
|
+
#e;
|
|
1420
|
+
getGroupItems(t) {
|
|
1421
|
+
return this.options.filter((e) => e.group === t);
|
|
1015
1422
|
}
|
|
1016
|
-
isGroupSelected(
|
|
1017
|
-
const
|
|
1018
|
-
return
|
|
1423
|
+
isGroupSelected(t) {
|
|
1424
|
+
const e = this.getGroupItems(t), s = this.value;
|
|
1425
|
+
return s === undefined ? false : e.every((i) => s.includes(i.value));
|
|
1019
1426
|
}
|
|
1020
1427
|
toggleValue() {
|
|
1021
|
-
const
|
|
1022
|
-
if (this.value === undefined && (this.value = []),
|
|
1023
|
-
const
|
|
1024
|
-
this.isGroupSelected(
|
|
1428
|
+
const t = this.options[this.cursor];
|
|
1429
|
+
if (this.value === undefined && (this.value = []), t.group === true) {
|
|
1430
|
+
const e = t.value, s = this.getGroupItems(e);
|
|
1431
|
+
this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
|
|
1025
1432
|
} else {
|
|
1026
|
-
const
|
|
1027
|
-
this.value =
|
|
1433
|
+
const e = this.value.includes(t.value);
|
|
1434
|
+
this.value = e ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
|
|
1028
1435
|
}
|
|
1029
1436
|
}
|
|
1030
|
-
constructor(
|
|
1031
|
-
super(
|
|
1032
|
-
const { options:
|
|
1033
|
-
this.#
|
|
1034
|
-
switch (
|
|
1437
|
+
constructor(t) {
|
|
1438
|
+
super(t, false);
|
|
1439
|
+
const { options: e } = t;
|
|
1440
|
+
this.#e = t.selectableGroups !== false, this.options = Object.entries(e).flatMap(([s, i]) => [{ value: s, group: true, label: s }, ...i.map((n) => ({ ...n, group: s }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
|
|
1441
|
+
switch (s) {
|
|
1035
1442
|
case "left":
|
|
1036
1443
|
case "up": {
|
|
1037
1444
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1038
|
-
const
|
|
1039
|
-
!this.#
|
|
1445
|
+
const i = this.options[this.cursor]?.group === true;
|
|
1446
|
+
!this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1040
1447
|
break;
|
|
1041
1448
|
}
|
|
1042
1449
|
case "down":
|
|
1043
1450
|
case "right": {
|
|
1044
1451
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1045
|
-
const
|
|
1046
|
-
!this.#
|
|
1452
|
+
const i = this.options[this.cursor]?.group === true;
|
|
1453
|
+
!this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1047
1454
|
break;
|
|
1048
1455
|
}
|
|
1049
1456
|
case "space":
|
|
@@ -1053,7 +1460,7 @@ var init_dist = __esm(() => {
|
|
|
1053
1460
|
});
|
|
1054
1461
|
}
|
|
1055
1462
|
};
|
|
1056
|
-
|
|
1463
|
+
nt = class nt extends p {
|
|
1057
1464
|
options;
|
|
1058
1465
|
cursor = 0;
|
|
1059
1466
|
get _selectedValue() {
|
|
@@ -1062,18 +1469,18 @@ var init_dist = __esm(() => {
|
|
|
1062
1469
|
changeValue() {
|
|
1063
1470
|
this.value = this._selectedValue.value;
|
|
1064
1471
|
}
|
|
1065
|
-
constructor(
|
|
1066
|
-
super(
|
|
1067
|
-
const
|
|
1068
|
-
this.cursor = this.options[
|
|
1069
|
-
switch (
|
|
1472
|
+
constructor(t) {
|
|
1473
|
+
super(t, false), this.options = t.options;
|
|
1474
|
+
const e = this.options.findIndex(({ value: i }) => i === t.initialValue), s = e === -1 ? 0 : e;
|
|
1475
|
+
this.cursor = this.options[s].disabled ? d(s, 1, this.options) : s, this.changeValue(), this.on("cursor", (i) => {
|
|
1476
|
+
switch (i) {
|
|
1070
1477
|
case "left":
|
|
1071
1478
|
case "up":
|
|
1072
|
-
this.cursor =
|
|
1479
|
+
this.cursor = d(this.cursor, -1, this.options);
|
|
1073
1480
|
break;
|
|
1074
1481
|
case "down":
|
|
1075
1482
|
case "right":
|
|
1076
|
-
this.cursor =
|
|
1483
|
+
this.cursor = d(this.cursor, 1, this.options);
|
|
1077
1484
|
break;
|
|
1078
1485
|
}
|
|
1079
1486
|
this.changeValue();
|
|
@@ -1082,386 +1489,227 @@ var init_dist = __esm(() => {
|
|
|
1082
1489
|
};
|
|
1083
1490
|
});
|
|
1084
1491
|
|
|
1085
|
-
// node_modules/.bun/@clack+prompts@1.
|
|
1086
|
-
import { styleText as t, stripVTControlCharacters as
|
|
1087
|
-
import
|
|
1088
|
-
function
|
|
1089
|
-
return
|
|
1090
|
-
}
|
|
1091
|
-
function J(e, r, s) {
|
|
1092
|
-
return String(e).normalize().replaceAll(`\r
|
|
1093
|
-
`, `
|
|
1094
|
-
`).split(`
|
|
1095
|
-
`).map((i) => It2(i, r, s)).join(`
|
|
1096
|
-
`);
|
|
1492
|
+
// node_modules/.bun/@clack+prompts@1.2.0/node_modules/@clack/prompts/dist/index.mjs
|
|
1493
|
+
import { styleText as t, stripVTControlCharacters as ne } from "util";
|
|
1494
|
+
import P2 from "process";
|
|
1495
|
+
function Ze() {
|
|
1496
|
+
return P2.platform !== "win32" ? P2.env.TERM !== "linux" : !!P2.env.CI || !!P2.env.WT_SESSION || !!P2.env.TERMINUS_SUBLIME || P2.env.ConEmuTask === "{cmd::Cmder}" || P2.env.TERM_PROGRAM === "Terminus-Sublime" || P2.env.TERM_PROGRAM === "vscode" || P2.env.TERM === "xterm-256color" || P2.env.TERM === "alacritty" || P2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1097
1497
|
}
|
|
1098
|
-
var import_sisteransi2, ee,
|
|
1498
|
+
var import_sisteransi2, ee, w2 = (e, i) => ee ? e : i, _e, oe, ue, F2, le, d2, E2, Ie, Ee, z2, H2, te, U, J2, xe, se, ce, Ge, $e, de, Oe, he, pe, me, ge, V2 = (e) => {
|
|
1099
1499
|
switch (e) {
|
|
1100
1500
|
case "initial":
|
|
1101
1501
|
case "active":
|
|
1102
|
-
return t("cyan",
|
|
1502
|
+
return t("cyan", _e);
|
|
1103
1503
|
case "cancel":
|
|
1104
|
-
return t("red",
|
|
1504
|
+
return t("red", oe);
|
|
1105
1505
|
case "error":
|
|
1106
|
-
return t("yellow",
|
|
1506
|
+
return t("yellow", ue);
|
|
1107
1507
|
case "submit":
|
|
1108
|
-
return t("green",
|
|
1508
|
+
return t("green", F2);
|
|
1109
1509
|
}
|
|
1110
|
-
},
|
|
1510
|
+
}, ye = (e) => {
|
|
1111
1511
|
switch (e) {
|
|
1112
1512
|
case "initial":
|
|
1113
1513
|
case "active":
|
|
1114
|
-
return t("cyan",
|
|
1514
|
+
return t("cyan", d2);
|
|
1115
1515
|
case "cancel":
|
|
1116
|
-
return t("red",
|
|
1516
|
+
return t("red", d2);
|
|
1117
1517
|
case "error":
|
|
1118
|
-
return t("yellow",
|
|
1518
|
+
return t("yellow", d2);
|
|
1119
1519
|
case "submit":
|
|
1120
|
-
return t("green",
|
|
1121
|
-
}
|
|
1122
|
-
},
|
|
1123
|
-
|
|
1124
|
-
let
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
if (b > A || m >= d && m > $) {
|
|
1128
|
-
const T2 = e.slice(A, b) || e.slice($, m);
|
|
1129
|
-
F = 0;
|
|
1130
|
-
for (const M2 of T2.replaceAll(Ft2, "")) {
|
|
1131
|
-
const O2 = M2.codePointAt(0) || 0;
|
|
1132
|
-
if (gt2(O2) ? S2 = f : ft2(O2) ? S2 = E : c !== g && mt2(O2) ? S2 = c : S2 = g, w + S2 > C && (v = Math.min(v, Math.max(A, $) + F)), w + S2 > i) {
|
|
1133
|
-
y2 = true;
|
|
1134
|
-
break e;
|
|
1135
|
-
}
|
|
1136
|
-
F += M2.length, w += S2;
|
|
1137
|
-
}
|
|
1138
|
-
A = b = 0;
|
|
1139
|
-
}
|
|
1140
|
-
if (m >= d)
|
|
1141
|
-
break;
|
|
1142
|
-
if (ne.lastIndex = m, ne.test(e)) {
|
|
1143
|
-
if (F = ne.lastIndex - m, S2 = F * g, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S2 > i) {
|
|
1144
|
-
y2 = true;
|
|
1145
|
-
break;
|
|
1146
|
-
}
|
|
1147
|
-
w += S2, A = $, b = m, m = $ = ne.lastIndex;
|
|
1148
|
-
continue;
|
|
1149
|
-
}
|
|
1150
|
-
if (we.lastIndex = m, we.test(e)) {
|
|
1151
|
-
if (w + u > C && (v = Math.min(v, m)), w + u > i) {
|
|
1152
|
-
y2 = true;
|
|
1153
|
-
break;
|
|
1154
|
-
}
|
|
1155
|
-
w += u, A = $, b = m, m = $ = we.lastIndex;
|
|
1156
|
-
continue;
|
|
1157
|
-
}
|
|
1158
|
-
if (re.lastIndex = m, re.test(e)) {
|
|
1159
|
-
if (F = re.lastIndex - m, S2 = F * l, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S2 > i) {
|
|
1160
|
-
y2 = true;
|
|
1161
|
-
break;
|
|
1162
|
-
}
|
|
1163
|
-
w += S2, A = $, b = m, m = $ = re.lastIndex;
|
|
1164
|
-
continue;
|
|
1165
|
-
}
|
|
1166
|
-
if (ie.lastIndex = m, ie.test(e)) {
|
|
1167
|
-
if (F = ie.lastIndex - m, S2 = F * n, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S2 > i) {
|
|
1168
|
-
y2 = true;
|
|
1169
|
-
break;
|
|
1170
|
-
}
|
|
1171
|
-
w += S2, A = $, b = m, m = $ = ie.lastIndex;
|
|
1172
|
-
continue;
|
|
1173
|
-
}
|
|
1174
|
-
if (Ae.lastIndex = m, Ae.test(e)) {
|
|
1175
|
-
if (w + p > C && (v = Math.min(v, m)), w + p > i) {
|
|
1176
|
-
y2 = true;
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
w += p, A = $, b = m, m = $ = Ae.lastIndex;
|
|
1180
|
-
continue;
|
|
1181
|
-
}
|
|
1182
|
-
m += 1;
|
|
1183
|
-
}
|
|
1184
|
-
return { width: y2 ? C : w, index: y2 ? v : d, truncated: y2, ellipsed: y2 && i >= o };
|
|
1185
|
-
}, Et2, D2 = (e, r = {}) => Le(e, Et2, r).width, ae = "\x1B", je = "\x9B", vt2 = 39, Ce = "\x07", ke = "[", wt2 = "]", Ve = "m", Se, He, At2 = (e) => {
|
|
1186
|
-
if (e >= 30 && e <= 37 || e >= 90 && e <= 97)
|
|
1187
|
-
return 39;
|
|
1188
|
-
if (e >= 40 && e <= 47 || e >= 100 && e <= 107)
|
|
1189
|
-
return 49;
|
|
1190
|
-
if (e === 1 || e === 2)
|
|
1191
|
-
return 22;
|
|
1192
|
-
if (e === 3)
|
|
1193
|
-
return 23;
|
|
1194
|
-
if (e === 4)
|
|
1195
|
-
return 24;
|
|
1196
|
-
if (e === 7)
|
|
1197
|
-
return 27;
|
|
1198
|
-
if (e === 8)
|
|
1199
|
-
return 28;
|
|
1200
|
-
if (e === 9)
|
|
1201
|
-
return 29;
|
|
1202
|
-
if (e === 0)
|
|
1203
|
-
return 0;
|
|
1204
|
-
}, Ue = (e) => `${ae}${ke}${e}${Ve}`, Ke = (e) => `${ae}${Se}${e}${Ce}`, Ct2 = (e) => e.map((r) => D2(r)), Ie = (e, r, s) => {
|
|
1205
|
-
const i = r[Symbol.iterator]();
|
|
1206
|
-
let a = false, o = false, u = e.at(-1), l = u === undefined ? 0 : D2(u), n = i.next(), c = i.next(), p = 0;
|
|
1207
|
-
for (;!n.done; ) {
|
|
1208
|
-
const f = n.value, g = D2(f);
|
|
1209
|
-
l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = true, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = false, o = false) : f === Ve && (a = false) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
|
|
1210
|
-
}
|
|
1211
|
-
u = e.at(-1), !l && u !== undefined && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
|
|
1212
|
-
}, St2 = (e) => {
|
|
1213
|
-
const r = e.split(" ");
|
|
1214
|
-
let s = r.length;
|
|
1215
|
-
for (;s > 0 && !(D2(r[s - 1]) > 0); )
|
|
1216
|
-
s--;
|
|
1217
|
-
return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
1218
|
-
}, It2 = (e, r, s = {}) => {
|
|
1219
|
-
if (s.trim !== false && e.trim() === "")
|
|
1220
|
-
return "";
|
|
1221
|
-
let i = "", a, o;
|
|
1222
|
-
const u = e.split(" "), l = Ct2(u);
|
|
1223
|
-
let n = [""];
|
|
1224
|
-
for (const [$, m] of u.entries()) {
|
|
1225
|
-
s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
1226
|
-
let d = D2(n.at(-1) ?? "");
|
|
1227
|
-
if ($ !== 0 && (d >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), d = 0), (d > 0 || s.trim === false) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
|
|
1228
|
-
const F = r - d, y2 = 1 + Math.floor((l[$] - F - 1) / r);
|
|
1229
|
-
Math.floor((l[$] - 1) / r) < y2 && n.push(""), Ie(n, m, r);
|
|
1230
|
-
continue;
|
|
1231
|
-
}
|
|
1232
|
-
if (d + l[$] > r && d > 0 && l[$] > 0) {
|
|
1233
|
-
if (s.wordWrap === false && d < r) {
|
|
1234
|
-
Ie(n, m, r);
|
|
1235
|
-
continue;
|
|
1236
|
-
}
|
|
1237
|
-
n.push("");
|
|
1238
|
-
}
|
|
1239
|
-
if (d + l[$] > r && s.wordWrap === false) {
|
|
1240
|
-
Ie(n, m, r);
|
|
1241
|
-
continue;
|
|
1242
|
-
}
|
|
1243
|
-
n[n.length - 1] += m;
|
|
1244
|
-
}
|
|
1245
|
-
s.trim !== false && (n = n.map(($) => St2($)));
|
|
1246
|
-
const c = n.join(`
|
|
1247
|
-
`), p = c[Symbol.iterator]();
|
|
1248
|
-
let f = p.next(), g = p.next(), E = 0;
|
|
1249
|
-
for (;!f.done; ) {
|
|
1250
|
-
const $ = f.value, m = g.value;
|
|
1251
|
-
if (i += $, $ === ae || $ === je) {
|
|
1252
|
-
He.lastIndex = E + 1;
|
|
1253
|
-
const y2 = He.exec(c)?.groups;
|
|
1254
|
-
if (y2?.code !== undefined) {
|
|
1255
|
-
const v = Number.parseFloat(y2.code);
|
|
1256
|
-
a = v === vt2 ? undefined : v;
|
|
1257
|
-
} else
|
|
1258
|
-
y2?.uri !== undefined && (o = y2.uri.length === 0 ? undefined : y2.uri);
|
|
1259
|
-
}
|
|
1260
|
-
const d = a ? At2(a) : undefined;
|
|
1261
|
-
m === `
|
|
1262
|
-
` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
|
|
1263
|
-
` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
|
|
1264
|
-
}
|
|
1265
|
-
return i;
|
|
1266
|
-
}, bt2 = (e, r, s, i, a) => {
|
|
1267
|
-
let o = r, u = 0;
|
|
1268
|
-
for (let l = s;l < i; l++) {
|
|
1269
|
-
const n = e[l];
|
|
1270
|
-
if (o = o - n.length, u++, o <= a)
|
|
1520
|
+
return t("green", d2);
|
|
1521
|
+
}
|
|
1522
|
+
}, et2 = (e, i, s, r, u2) => {
|
|
1523
|
+
let n = i, o = 0;
|
|
1524
|
+
for (let c2 = s;c2 < r; c2++) {
|
|
1525
|
+
const a = e[c2];
|
|
1526
|
+
if (n = n - a.length, o++, n <= u2)
|
|
1271
1527
|
break;
|
|
1272
1528
|
}
|
|
1273
|
-
return { lineCount:
|
|
1274
|
-
},
|
|
1275
|
-
const
|
|
1276
|
-
let
|
|
1277
|
-
e >=
|
|
1278
|
-
let
|
|
1279
|
-
const
|
|
1280
|
-
let
|
|
1281
|
-
|
|
1282
|
-
const
|
|
1283
|
-
for (let
|
|
1284
|
-
const
|
|
1529
|
+
return { lineCount: n, removals: o };
|
|
1530
|
+
}, Y2 = ({ cursor: e, options: i, style: s, output: r = process.stdout, maxItems: u2 = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
|
|
1531
|
+
const c2 = O(r) - n, a = A(r), l = t("dim", "..."), $2 = Math.max(a - o, 0), y2 = Math.max(Math.min(u2, $2), 5);
|
|
1532
|
+
let p2 = 0;
|
|
1533
|
+
e >= y2 - 3 && (p2 = Math.max(Math.min(e - y2 + 3, i.length - y2), 0));
|
|
1534
|
+
let m = y2 < i.length && p2 > 0, g = y2 < i.length && p2 + y2 < i.length;
|
|
1535
|
+
const S2 = Math.min(p2 + y2, i.length), h = [];
|
|
1536
|
+
let f = 0;
|
|
1537
|
+
m && f++, g && f++;
|
|
1538
|
+
const v = p2 + (m ? 1 : 0), T2 = S2 - (g ? 1 : 0);
|
|
1539
|
+
for (let b = v;b < T2; b++) {
|
|
1540
|
+
const x = wrapAnsi(s(i[b], b === e), c2, { hard: true, trim: false }).split(`
|
|
1285
1541
|
`);
|
|
1286
|
-
|
|
1287
|
-
}
|
|
1288
|
-
if (
|
|
1289
|
-
let
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
}
|
|
1293
|
-
const
|
|
1294
|
-
|
|
1295
|
-
for (const
|
|
1296
|
-
for (const
|
|
1297
|
-
|
|
1298
|
-
return
|
|
1299
|
-
},
|
|
1300
|
-
const
|
|
1301
|
-
return new
|
|
1302
|
-
const
|
|
1303
|
-
` : ""}${
|
|
1304
|
-
`,
|
|
1542
|
+
h.push(x), f += x.length;
|
|
1543
|
+
}
|
|
1544
|
+
if (f > $2) {
|
|
1545
|
+
let b = 0, x = 0, G2 = f;
|
|
1546
|
+
const M2 = e - v, R2 = (j2, D) => et2(h, G2, j2, D, $2);
|
|
1547
|
+
m ? ({ lineCount: G2, removals: b } = R2(0, M2), G2 > $2 && ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length))) : ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length), G2 > $2 && ({ lineCount: G2, removals: b } = R2(0, M2))), b > 0 && (m = true, h.splice(0, b)), x > 0 && (g = true, h.splice(h.length - x, x));
|
|
1548
|
+
}
|
|
1549
|
+
const C2 = [];
|
|
1550
|
+
m && C2.push(l);
|
|
1551
|
+
for (const b of h)
|
|
1552
|
+
for (const x of b)
|
|
1553
|
+
C2.push(x);
|
|
1554
|
+
return g && C2.push(l), C2;
|
|
1555
|
+
}, ot2 = (e) => {
|
|
1556
|
+
const i = e.active ?? "Yes", s = e.inactive ?? "No";
|
|
1557
|
+
return new Q({ active: i, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
|
|
1558
|
+
const r = e.withGuide ?? u.withGuide, u2 = `${V2(this.state)} `, n = r ? `${t("gray", d2)} ` : "", o = R(e.output, e.message, n, u2), c2 = `${r ? `${t("gray", d2)}
|
|
1559
|
+
` : ""}${o}
|
|
1560
|
+
`, a = this.value ? i : s;
|
|
1305
1561
|
switch (this.state) {
|
|
1306
1562
|
case "submit": {
|
|
1307
|
-
const
|
|
1308
|
-
return `${
|
|
1563
|
+
const l = r ? `${t("gray", d2)} ` : "";
|
|
1564
|
+
return `${c2}${l}${t("dim", a)}`;
|
|
1309
1565
|
}
|
|
1310
1566
|
case "cancel": {
|
|
1311
|
-
const
|
|
1312
|
-
return `${
|
|
1313
|
-
${t("gray",
|
|
1567
|
+
const l = r ? `${t("gray", d2)} ` : "";
|
|
1568
|
+
return `${c2}${l}${t(["strikethrough", "dim"], a)}${r ? `
|
|
1569
|
+
${t("gray", d2)}` : ""}`;
|
|
1314
1570
|
}
|
|
1315
1571
|
default: {
|
|
1316
|
-
const
|
|
1317
|
-
return `${
|
|
1318
|
-
${t("cyan",
|
|
1572
|
+
const l = r ? `${t("cyan", d2)} ` : "", $2 = r ? t("cyan", E2) : "";
|
|
1573
|
+
return `${c2}${l}${this.value ? `${t("green", z2)} ${i}` : `${t("dim", H2)} ${t("dim", i)}`}${e.vertical ? r ? `
|
|
1574
|
+
${t("cyan", d2)} ` : `
|
|
1319
1575
|
` : ` ${t("dim", "/")} `}${this.value ? `${t("dim", H2)} ${t("dim", s)}` : `${t("green", z2)} ${s}`}
|
|
1320
|
-
${
|
|
1576
|
+
${$2}
|
|
1321
1577
|
`;
|
|
1322
1578
|
}
|
|
1323
1579
|
}
|
|
1324
1580
|
} }).prompt();
|
|
1325
|
-
},
|
|
1326
|
-
const s =
|
|
1327
|
-
s.write(`${
|
|
1581
|
+
}, O2, mt = (e = "", i) => {
|
|
1582
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", le)} ` : "";
|
|
1583
|
+
s.write(`${r}${e}
|
|
1328
1584
|
`);
|
|
1329
|
-
},
|
|
1330
|
-
const s =
|
|
1331
|
-
${t("gray",
|
|
1332
|
-
s.write(`${
|
|
1585
|
+
}, gt = (e = "", i) => {
|
|
1586
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", d2)}
|
|
1587
|
+
${t("gray", E2)} ` : "";
|
|
1588
|
+
s.write(`${r}${e}
|
|
1333
1589
|
|
|
1334
1590
|
`);
|
|
1335
|
-
},
|
|
1336
|
-
const
|
|
1337
|
-
`),
|
|
1338
|
-
return
|
|
1339
|
-
},
|
|
1340
|
-
const
|
|
1341
|
-
`).map(
|
|
1342
|
-
const
|
|
1343
|
-
return
|
|
1344
|
-
}, 0),
|
|
1345
|
-
`),
|
|
1346
|
-
` : "",
|
|
1347
|
-
|
|
1348
|
-
${
|
|
1349
|
-
${t("gray",
|
|
1591
|
+
}, ft = (e) => t("dim", e), vt = (e, i, s) => {
|
|
1592
|
+
const r = { hard: true, trim: false }, u2 = wrapAnsi(e, i, r).split(`
|
|
1593
|
+
`), n = u2.reduce((a, l) => Math.max(dist_default2(l), a), 0), o = u2.map(s).reduce((a, l) => Math.max(dist_default2(l), a), 0), c2 = i - (o - n);
|
|
1594
|
+
return wrapAnsi(e, c2, r);
|
|
1595
|
+
}, wt = (e = "", i = "", s) => {
|
|
1596
|
+
const r = s?.output ?? P2.stdout, u2 = s?.withGuide ?? u.withGuide, n = s?.format ?? ft, o = ["", ...vt(e, O(r) - 6, n).split(`
|
|
1597
|
+
`).map(n), ""], c2 = dist_default2(i), a = Math.max(o.reduce((p2, m) => {
|
|
1598
|
+
const g = dist_default2(m);
|
|
1599
|
+
return g > p2 ? g : p2;
|
|
1600
|
+
}, 0), c2) + 2, l = o.map((p2) => `${t("gray", d2)} ${p2}${" ".repeat(a - dist_default2(p2))}${t("gray", d2)}`).join(`
|
|
1601
|
+
`), $2 = u2 ? `${t("gray", d2)}
|
|
1602
|
+
` : "", y2 = u2 ? Ge : de;
|
|
1603
|
+
r.write(`${$2}${t("green", F2)} ${t("reset", i)} ${t("gray", se.repeat(Math.max(a - c2 - 1, 1)) + ce)}
|
|
1604
|
+
${l}
|
|
1605
|
+
${t("gray", y2 + se.repeat(a + 2) + $e)}
|
|
1350
1606
|
`);
|
|
1351
|
-
},
|
|
1607
|
+
}, Ve, re = (e, i) => e.includes(`
|
|
1352
1608
|
`) ? e.split(`
|
|
1353
|
-
`).map((s) =>
|
|
1354
|
-
`) :
|
|
1355
|
-
const
|
|
1356
|
-
const
|
|
1357
|
-
switch (
|
|
1609
|
+
`).map((s) => i(s)).join(`
|
|
1610
|
+
`) : i(e), _t = (e) => {
|
|
1611
|
+
const i = (s, r) => {
|
|
1612
|
+
const u2 = s.label ?? String(s.value);
|
|
1613
|
+
switch (r) {
|
|
1358
1614
|
case "disabled":
|
|
1359
|
-
return `${t("gray", H2)} ${
|
|
1615
|
+
return `${t("gray", H2)} ${re(u2, (n) => t("gray", n))}${s.hint ? ` ${t("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1360
1616
|
case "selected":
|
|
1361
|
-
return `${
|
|
1617
|
+
return `${re(u2, (n) => t("dim", n))}`;
|
|
1362
1618
|
case "active":
|
|
1363
|
-
return `${t("green", z2)} ${
|
|
1619
|
+
return `${t("green", z2)} ${u2}${s.hint ? ` ${t("dim", `(${s.hint})`)}` : ""}`;
|
|
1364
1620
|
case "cancelled":
|
|
1365
|
-
return `${
|
|
1621
|
+
return `${re(u2, (n) => t(["strikethrough", "dim"], n))}`;
|
|
1366
1622
|
default:
|
|
1367
|
-
return `${t("dim", H2)} ${
|
|
1623
|
+
return `${t("dim", H2)} ${re(u2, (n) => t("dim", n))}`;
|
|
1368
1624
|
}
|
|
1369
1625
|
};
|
|
1370
|
-
return new
|
|
1371
|
-
const s = e.withGuide ??
|
|
1372
|
-
` : ""}${
|
|
1626
|
+
return new nt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
|
|
1627
|
+
const s = e.withGuide ?? u.withGuide, r = `${V2(this.state)} `, u2 = `${ye(this.state)} `, n = R(e.output, e.message, u2, r), o = `${s ? `${t("gray", d2)}
|
|
1628
|
+
` : ""}${n}
|
|
1373
1629
|
`;
|
|
1374
1630
|
switch (this.state) {
|
|
1375
1631
|
case "submit": {
|
|
1376
|
-
const
|
|
1377
|
-
return `${
|
|
1632
|
+
const c2 = s ? `${t("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "selected"), c2);
|
|
1633
|
+
return `${o}${a}`;
|
|
1378
1634
|
}
|
|
1379
1635
|
case "cancel": {
|
|
1380
|
-
const
|
|
1381
|
-
return `${
|
|
1382
|
-
${t("gray",
|
|
1636
|
+
const c2 = s ? `${t("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "cancelled"), c2);
|
|
1637
|
+
return `${o}${a}${s ? `
|
|
1638
|
+
${t("gray", d2)}` : ""}`;
|
|
1383
1639
|
}
|
|
1384
1640
|
default: {
|
|
1385
|
-
const
|
|
1386
|
-
`).length,
|
|
1387
|
-
return `${
|
|
1388
|
-
${
|
|
1389
|
-
${
|
|
1641
|
+
const c2 = s ? `${t("cyan", d2)} ` : "", a = s ? t("cyan", E2) : "", l = o.split(`
|
|
1642
|
+
`).length, $2 = s ? 2 : 1;
|
|
1643
|
+
return `${o}${c2}${Y2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: c2.length, rowPadding: l + $2, style: (y2, p2) => i(y2, y2.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
|
|
1644
|
+
${c2}`)}
|
|
1645
|
+
${a}
|
|
1390
1646
|
`;
|
|
1391
1647
|
}
|
|
1392
1648
|
}
|
|
1393
1649
|
} }).prompt();
|
|
1394
|
-
},
|
|
1395
|
-
var
|
|
1396
|
-
|
|
1397
|
-
|
|
1650
|
+
}, je;
|
|
1651
|
+
var init_dist4 = __esm(() => {
|
|
1652
|
+
init_dist3();
|
|
1653
|
+
init_dist3();
|
|
1654
|
+
init_main();
|
|
1655
|
+
init_dist2();
|
|
1398
1656
|
import_sisteransi2 = __toESM(require_src(), 1);
|
|
1399
|
-
ee =
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
z2 =
|
|
1410
|
-
H2 =
|
|
1411
|
-
te =
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
se =
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
Ft2 = /\p{M}+/gu;
|
|
1431
|
-
yt2 = { limit: 1 / 0, ellipsis: "" };
|
|
1432
|
-
Et2 = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
1433
|
-
Se = `${wt2}8;;`;
|
|
1434
|
-
He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y");
|
|
1435
|
-
R2 = { message: (e = [], { symbol: r = t("gray", h), secondarySymbol: s = t("gray", h), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
|
|
1436
|
-
const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", p = l ? `${s} ` : "";
|
|
1437
|
-
for (let g = 0;g < a; g++)
|
|
1438
|
-
u.push(n);
|
|
1439
|
-
const f = Array.isArray(e) ? e : e.split(`
|
|
1657
|
+
ee = Ze();
|
|
1658
|
+
_e = w2("\u25C6", "*");
|
|
1659
|
+
oe = w2("\u25A0", "x");
|
|
1660
|
+
ue = w2("\u25B2", "x");
|
|
1661
|
+
F2 = w2("\u25C7", "o");
|
|
1662
|
+
le = w2("\u250C", "T");
|
|
1663
|
+
d2 = w2("\u2502", "|");
|
|
1664
|
+
E2 = w2("\u2514", "\u2014");
|
|
1665
|
+
Ie = w2("\u2510", "T");
|
|
1666
|
+
Ee = w2("\u2518", "\u2014");
|
|
1667
|
+
z2 = w2("\u25CF", ">");
|
|
1668
|
+
H2 = w2("\u25CB", " ");
|
|
1669
|
+
te = w2("\u25FB", "[\u2022]");
|
|
1670
|
+
U = w2("\u25FC", "[+]");
|
|
1671
|
+
J2 = w2("\u25FB", "[ ]");
|
|
1672
|
+
xe = w2("\u25AA", "\u2022");
|
|
1673
|
+
se = w2("\u2500", "-");
|
|
1674
|
+
ce = w2("\u256E", "+");
|
|
1675
|
+
Ge = w2("\u251C", "+");
|
|
1676
|
+
$e = w2("\u256F", "+");
|
|
1677
|
+
de = w2("\u2570", "+");
|
|
1678
|
+
Oe = w2("\u256D", "+");
|
|
1679
|
+
he = w2("\u25CF", "\u2022");
|
|
1680
|
+
pe = w2("\u25C6", "*");
|
|
1681
|
+
me = w2("\u25B2", "!");
|
|
1682
|
+
ge = w2("\u25A0", "x");
|
|
1683
|
+
O2 = { message: (e = [], { symbol: i = t("gray", d2), secondarySymbol: s = t("gray", d2), output: r = process.stdout, spacing: u2 = 1, withGuide: n } = {}) => {
|
|
1684
|
+
const o = [], c2 = n ?? u.withGuide, a = c2 ? s : "", l = c2 ? `${i} ` : "", $2 = c2 ? `${s} ` : "";
|
|
1685
|
+
for (let p2 = 0;p2 < u2; p2++)
|
|
1686
|
+
o.push(a);
|
|
1687
|
+
const y2 = Array.isArray(e) ? e : e.split(`
|
|
1440
1688
|
`);
|
|
1441
|
-
if (
|
|
1442
|
-
const [
|
|
1443
|
-
|
|
1444
|
-
for (const
|
|
1445
|
-
|
|
1689
|
+
if (y2.length > 0) {
|
|
1690
|
+
const [p2, ...m] = y2;
|
|
1691
|
+
p2.length > 0 ? o.push(`${l}${p2}`) : o.push(c2 ? i : "");
|
|
1692
|
+
for (const g of m)
|
|
1693
|
+
g.length > 0 ? o.push(`${$2}${g}`) : o.push(c2 ? s : "");
|
|
1446
1694
|
}
|
|
1447
|
-
|
|
1695
|
+
r.write(`${o.join(`
|
|
1448
1696
|
`)}
|
|
1449
1697
|
`);
|
|
1450
|
-
}, info: (e,
|
|
1451
|
-
|
|
1452
|
-
}, success: (e,
|
|
1453
|
-
|
|
1454
|
-
}, step: (e,
|
|
1455
|
-
|
|
1456
|
-
}, warn: (e,
|
|
1457
|
-
|
|
1458
|
-
}, warning: (e,
|
|
1459
|
-
|
|
1460
|
-
}, error: (e,
|
|
1461
|
-
|
|
1698
|
+
}, info: (e, i) => {
|
|
1699
|
+
O2.message(e, { ...i, symbol: t("blue", he) });
|
|
1700
|
+
}, success: (e, i) => {
|
|
1701
|
+
O2.message(e, { ...i, symbol: t("green", pe) });
|
|
1702
|
+
}, step: (e, i) => {
|
|
1703
|
+
O2.message(e, { ...i, symbol: t("green", F2) });
|
|
1704
|
+
}, warn: (e, i) => {
|
|
1705
|
+
O2.message(e, { ...i, symbol: t("yellow", me) });
|
|
1706
|
+
}, warning: (e, i) => {
|
|
1707
|
+
O2.warn(e, i);
|
|
1708
|
+
}, error: (e, i) => {
|
|
1709
|
+
O2.message(e, { ...i, symbol: t("red", ge) });
|
|
1462
1710
|
} };
|
|
1463
|
-
|
|
1464
|
-
|
|
1711
|
+
Ve = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
1712
|
+
je = `${t("gray", d2)} `;
|
|
1465
1713
|
});
|
|
1466
1714
|
|
|
1467
1715
|
// bin/src/shared.ts
|
|
@@ -2171,7 +2419,7 @@ function createAgentStreamPrinter(label) {
|
|
|
2171
2419
|
}
|
|
2172
2420
|
var deps, gitRoot, missing, MIN_BUN_VERSION = "1.3.5", bunVersionResult, webmuxYaml;
|
|
2173
2421
|
var init_init = __esm(async () => {
|
|
2174
|
-
|
|
2422
|
+
init_dist4();
|
|
2175
2423
|
init_shared();
|
|
2176
2424
|
init_init_helpers();
|
|
2177
2425
|
deps = [
|
|
@@ -2184,21 +2432,21 @@ var init_init = __esm(async () => {
|
|
|
2184
2432
|
{ tool: "codex", required: false, hint: "Install the Codex CLI to let Codex scaffold .webmux.yaml" },
|
|
2185
2433
|
{ tool: "docker", required: false, hint: "https://docs.docker.com/get-started/get-docker/" }
|
|
2186
2434
|
];
|
|
2187
|
-
|
|
2435
|
+
mt("webmux init");
|
|
2188
2436
|
gitRoot = getGitRoot();
|
|
2189
2437
|
if (!gitRoot) {
|
|
2190
|
-
|
|
2191
|
-
|
|
2438
|
+
O2.error("Not inside a git repository. Run this from within a project.");
|
|
2439
|
+
gt("Aborted.");
|
|
2192
2440
|
process.exit(1);
|
|
2193
2441
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2442
|
+
O2.success(`Git root: ${gitRoot}`);
|
|
2443
|
+
O2.step("Checking dependencies...");
|
|
2196
2444
|
missing = checkDeps();
|
|
2197
2445
|
if (missing.length > 0) {
|
|
2198
|
-
const lines = missing.map((
|
|
2446
|
+
const lines = missing.map((d3) => ` ${d3.tool}: ${d3.hint}`).join(`
|
|
2199
2447
|
`);
|
|
2200
|
-
|
|
2201
|
-
|
|
2448
|
+
wt(lines, "Install these required dependencies, then re-run webmux init");
|
|
2449
|
+
gt("Setup incomplete.");
|
|
2202
2450
|
process.exit(1);
|
|
2203
2451
|
}
|
|
2204
2452
|
bunVersionResult = run("bun", ["--version"]);
|
|
@@ -2208,28 +2456,28 @@ var init_init = __esm(async () => {
|
|
|
2208
2456
|
const [reqMajor, reqMinor, reqPatch] = MIN_BUN_VERSION.split(".").map(Number);
|
|
2209
2457
|
const tooOld = major < reqMajor || major === reqMajor && minor < reqMinor || major === reqMajor && minor === reqMinor && patch < reqPatch;
|
|
2210
2458
|
if (tooOld) {
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2459
|
+
O2.error(`Bun ${bunVersion} is too old. webmux requires Bun >= ${MIN_BUN_VERSION}.`);
|
|
2460
|
+
O2.info("Upgrade with: bun upgrade");
|
|
2461
|
+
gt("Setup incomplete.");
|
|
2214
2462
|
process.exit(1);
|
|
2215
2463
|
}
|
|
2216
2464
|
}
|
|
2217
2465
|
if (which("gh")) {
|
|
2218
2466
|
const ghAuth = run("gh", ["auth", "status"]);
|
|
2219
2467
|
if (!ghAuth.success) {
|
|
2220
|
-
|
|
2468
|
+
O2.warning("gh is installed but not authenticated. Run: gh auth login");
|
|
2221
2469
|
} else {
|
|
2222
|
-
|
|
2470
|
+
O2.success("gh \u2014 authenticated");
|
|
2223
2471
|
}
|
|
2224
2472
|
}
|
|
2225
|
-
|
|
2473
|
+
O2.step("Checking config files...");
|
|
2226
2474
|
webmuxYaml = join4(gitRoot, ".webmux.yaml");
|
|
2227
2475
|
if (existsSync3(webmuxYaml)) {
|
|
2228
|
-
|
|
2476
|
+
O2.info(".webmux.yaml already exists, skipping");
|
|
2229
2477
|
} else {
|
|
2230
2478
|
const claudeAvailable = which("claude");
|
|
2231
2479
|
const codexAvailable = which("codex");
|
|
2232
|
-
const choice = await
|
|
2480
|
+
const choice = await _t({
|
|
2233
2481
|
message: "No .webmux.yaml found. How should webmux create it?",
|
|
2234
2482
|
initialValue: claudeAvailable ? "claude" : codexAvailable ? "codex" : "manual",
|
|
2235
2483
|
options: [
|
|
@@ -2252,8 +2500,8 @@ var init_init = __esm(async () => {
|
|
|
2252
2500
|
}
|
|
2253
2501
|
]
|
|
2254
2502
|
});
|
|
2255
|
-
if (
|
|
2256
|
-
|
|
2503
|
+
if (q(choice)) {
|
|
2504
|
+
gt("Aborted.");
|
|
2257
2505
|
process.exit(1);
|
|
2258
2506
|
}
|
|
2259
2507
|
const selectedAgent = choice === "codex" ? "codex" : defaultTemplateAgent();
|
|
@@ -2265,7 +2513,7 @@ var init_init = __esm(async () => {
|
|
|
2265
2513
|
defaultAgent: context.defaultAgent,
|
|
2266
2514
|
packageManager: context.packageManager
|
|
2267
2515
|
}));
|
|
2268
|
-
|
|
2516
|
+
O2.success(".webmux.yaml starter template created");
|
|
2269
2517
|
} else {
|
|
2270
2518
|
const label = agentLabel(choice);
|
|
2271
2519
|
const starterTemplate = buildStarterTemplate({
|
|
@@ -2278,11 +2526,11 @@ var init_init = __esm(async () => {
|
|
|
2278
2526
|
const prompt = buildInitPromptSpec({ ...context, defaultAgent: choice });
|
|
2279
2527
|
const command = buildInitAgentCommand(choice, prompt);
|
|
2280
2528
|
const streamPrinter = createAgentStreamPrinter(label);
|
|
2281
|
-
|
|
2529
|
+
O2.step(`Running ${label} to adapt the starter .webmux.yaml...`);
|
|
2282
2530
|
const result = await runInitAgentCommand(command, gitRoot, { onEvent: streamPrinter.onEvent });
|
|
2283
2531
|
streamPrinter.finish();
|
|
2284
2532
|
if (!existsSync3(webmuxYaml)) {
|
|
2285
|
-
|
|
2533
|
+
O2.error(`${label} removed .webmux.yaml`);
|
|
2286
2534
|
const details = [
|
|
2287
2535
|
result.summary ? `Summary:
|
|
2288
2536
|
${result.summary}` : "",
|
|
@@ -2292,35 +2540,35 @@ ${result.stderr.trim()}` : ""
|
|
|
2292
2540
|
|
|
2293
2541
|
`);
|
|
2294
2542
|
if (details) {
|
|
2295
|
-
|
|
2543
|
+
wt(details, `${label} output`);
|
|
2296
2544
|
}
|
|
2297
|
-
|
|
2545
|
+
gt("Setup incomplete.");
|
|
2298
2546
|
process.exit(1);
|
|
2299
2547
|
}
|
|
2300
2548
|
const finalYaml = await Bun.file(webmuxYaml).text();
|
|
2301
2549
|
const changedTemplate = finalYaml !== starterTemplate;
|
|
2302
2550
|
if (result.exitCode === 0 && changedTemplate) {
|
|
2303
|
-
|
|
2551
|
+
O2.success(`${label} adapted .webmux.yaml`);
|
|
2304
2552
|
} else if (result.exitCode === 0) {
|
|
2305
|
-
|
|
2306
|
-
|
|
2553
|
+
O2.warning(`${label} left the starter template unchanged`);
|
|
2554
|
+
O2.warning(`${label} did not change the starter template. Review .webmux.yaml manually.`);
|
|
2307
2555
|
} else if (changedTemplate) {
|
|
2308
|
-
|
|
2309
|
-
|
|
2556
|
+
O2.warning(`${label} updated .webmux.yaml`);
|
|
2557
|
+
O2.warning(`${label} exited with code ${result.exitCode}. Review the generated file before using it.`);
|
|
2310
2558
|
} else {
|
|
2311
|
-
|
|
2312
|
-
|
|
2559
|
+
O2.warning(`${label} left the starter template in place`);
|
|
2560
|
+
O2.warning(`${label} exited with code ${result.exitCode}. The starter template is still there for manual editing.`);
|
|
2313
2561
|
}
|
|
2314
2562
|
if (result.summary && !streamPrinter.sawAssistantText()) {
|
|
2315
|
-
|
|
2563
|
+
wt(result.summary, `${label} summary`);
|
|
2316
2564
|
}
|
|
2317
2565
|
const trimmedStderr = result.stderr.trim();
|
|
2318
2566
|
if (trimmedStderr) {
|
|
2319
|
-
|
|
2567
|
+
wt(trimmedStderr, `${label} stderr`);
|
|
2320
2568
|
}
|
|
2321
2569
|
}
|
|
2322
2570
|
}
|
|
2323
|
-
|
|
2571
|
+
gt("You're all set! Next steps:");
|
|
2324
2572
|
console.log();
|
|
2325
2573
|
console.log(" 1. Review .webmux.yaml and adjust panes, ports, and profiles if needed");
|
|
2326
2574
|
console.log(" 2. Run: webmux");
|
|
@@ -2466,9 +2714,9 @@ function isInstalled(config) {
|
|
|
2466
2714
|
async function install(config) {
|
|
2467
2715
|
const filePath = serviceFilePath(config);
|
|
2468
2716
|
if (isInstalled(config)) {
|
|
2469
|
-
const reinstall = await
|
|
2470
|
-
if (
|
|
2471
|
-
|
|
2717
|
+
const reinstall = await ot2({ message: "Service is already installed. Reinstall?" });
|
|
2718
|
+
if (q(reinstall) || !reinstall) {
|
|
2719
|
+
O2.info("Aborted.");
|
|
2472
2720
|
return;
|
|
2473
2721
|
}
|
|
2474
2722
|
for (const cmd of uninstallCommands(config)) {
|
|
@@ -2477,77 +2725,77 @@ async function install(config) {
|
|
|
2477
2725
|
}
|
|
2478
2726
|
const content = generateServiceFile(config);
|
|
2479
2727
|
const commands = installCommands(config);
|
|
2480
|
-
|
|
2728
|
+
wt([
|
|
2481
2729
|
`File: ${filePath}`,
|
|
2482
2730
|
"",
|
|
2483
2731
|
"Contents:",
|
|
2484
2732
|
content,
|
|
2485
2733
|
"Commands to run:",
|
|
2486
|
-
...commands.map((
|
|
2734
|
+
...commands.map((c2) => ` $ ${formatCommand(c2)}`)
|
|
2487
2735
|
].join(`
|
|
2488
2736
|
`), "Install service");
|
|
2489
|
-
const ok = await
|
|
2490
|
-
if (
|
|
2491
|
-
|
|
2737
|
+
const ok = await ot2({ message: "Proceed?" });
|
|
2738
|
+
if (q(ok) || !ok) {
|
|
2739
|
+
O2.info("Aborted.");
|
|
2492
2740
|
return;
|
|
2493
2741
|
}
|
|
2494
2742
|
mkdirSync(filePath.substring(0, filePath.lastIndexOf("/")), { recursive: true });
|
|
2495
2743
|
await Bun.write(filePath, content);
|
|
2496
|
-
|
|
2744
|
+
O2.success(`Wrote ${filePath}`);
|
|
2497
2745
|
for (const cmd of commands) {
|
|
2498
2746
|
const result = runCommand(cmd);
|
|
2499
2747
|
if (!result.success) {
|
|
2500
|
-
|
|
2748
|
+
O2.error(`Command failed: ${formatCommand(cmd)}
|
|
2501
2749
|
${result.stderr.toString()}`);
|
|
2502
2750
|
return;
|
|
2503
2751
|
}
|
|
2504
|
-
|
|
2752
|
+
O2.success(`$ ${formatCommand(cmd)}`);
|
|
2505
2753
|
}
|
|
2506
|
-
|
|
2754
|
+
O2.success("Service installed and started!");
|
|
2507
2755
|
if (config.platform === "linux") {
|
|
2508
|
-
|
|
2756
|
+
wt(`To keep the service running after logout, run:
|
|
2509
2757
|
loginctl enable-linger $USER
|
|
2510
2758
|
|
|
2511
2759
|
(May require admin privileges on some systems.)`, "Tip");
|
|
2512
2760
|
}
|
|
2513
|
-
|
|
2514
|
-
|
|
2761
|
+
O2.info(`Check status: webmux service status`);
|
|
2762
|
+
O2.info(`View logs: webmux service logs`);
|
|
2515
2763
|
}
|
|
2516
2764
|
async function uninstall(config) {
|
|
2517
2765
|
const filePath = serviceFilePath(config);
|
|
2518
2766
|
if (!isInstalled(config)) {
|
|
2519
|
-
|
|
2767
|
+
O2.error("Service is not installed.");
|
|
2520
2768
|
return;
|
|
2521
2769
|
}
|
|
2522
2770
|
const commands = uninstallCommands(config);
|
|
2523
|
-
|
|
2771
|
+
wt([
|
|
2524
2772
|
`File to remove: ${filePath}`,
|
|
2525
2773
|
"",
|
|
2526
2774
|
"Commands to run:",
|
|
2527
|
-
...commands.map((
|
|
2775
|
+
...commands.map((c2) => ` $ ${formatCommand(c2)}`)
|
|
2528
2776
|
].join(`
|
|
2529
2777
|
`), "Uninstall service");
|
|
2530
|
-
const ok = await
|
|
2531
|
-
if (
|
|
2532
|
-
|
|
2778
|
+
const ok = await ot2({ message: "Proceed?" });
|
|
2779
|
+
if (q(ok) || !ok) {
|
|
2780
|
+
O2.info("Aborted.");
|
|
2533
2781
|
return;
|
|
2534
2782
|
}
|
|
2535
2783
|
for (const cmd of commands) {
|
|
2536
2784
|
const result = runCommand(cmd);
|
|
2537
2785
|
if (!result.success) {
|
|
2538
|
-
|
|
2786
|
+
O2.warning(`Command failed: ${formatCommand(cmd)}
|
|
2539
2787
|
${result.stderr.toString()}`);
|
|
2540
2788
|
} else {
|
|
2541
|
-
|
|
2789
|
+
O2.success(`$ ${formatCommand(cmd)}`);
|
|
2542
2790
|
}
|
|
2543
2791
|
}
|
|
2544
2792
|
unlinkSync(filePath);
|
|
2545
|
-
|
|
2546
|
-
|
|
2793
|
+
O2.success(`Removed ${filePath}`);
|
|
2794
|
+
O2.success("Service uninstalled.");
|
|
2547
2795
|
}
|
|
2548
2796
|
function status(config) {
|
|
2549
2797
|
if (!isInstalled(config)) {
|
|
2550
|
-
|
|
2798
|
+
O2.error("Service is not installed.");
|
|
2551
2799
|
return;
|
|
2552
2800
|
}
|
|
2553
2801
|
if (config.platform === "linux") {
|
|
@@ -2558,7 +2806,7 @@ function status(config) {
|
|
|
2558
2806
|
}
|
|
2559
2807
|
function logs(config) {
|
|
2560
2808
|
if (!isInstalled(config)) {
|
|
2561
|
-
|
|
2809
|
+
O2.error("Service is not installed.");
|
|
2562
2810
|
return;
|
|
2563
2811
|
}
|
|
2564
2812
|
let proc;
|
|
@@ -2567,7 +2815,7 @@ function logs(config) {
|
|
|
2567
2815
|
} else {
|
|
2568
2816
|
const logPath = join5(homedir(), "Library", "Logs", `webmux-${config.serviceName}.log`);
|
|
2569
2817
|
if (!existsSync4(logPath)) {
|
|
2570
|
-
|
|
2818
|
+
O2.error(`Log file not found: ${logPath}`);
|
|
2571
2819
|
return;
|
|
2572
2820
|
}
|
|
2573
2821
|
proc = Bun.spawn(["tail", "-f", logPath], {
|
|
@@ -2596,29 +2844,29 @@ async function service(args) {
|
|
|
2596
2844
|
return;
|
|
2597
2845
|
}
|
|
2598
2846
|
if (!["install", "uninstall", "status", "logs"].includes(action)) {
|
|
2599
|
-
|
|
2847
|
+
O2.error(`Unknown action: ${action}`);
|
|
2600
2848
|
usage();
|
|
2601
2849
|
return;
|
|
2602
2850
|
}
|
|
2603
2851
|
const platform = getPlatform();
|
|
2604
2852
|
if (!platform) {
|
|
2605
|
-
|
|
2853
|
+
O2.error(`Unsupported platform: ${process.platform}. Only linux and macOS are supported.`);
|
|
2606
2854
|
return;
|
|
2607
2855
|
}
|
|
2608
2856
|
const gitRoot2 = getGitRoot();
|
|
2609
2857
|
if (!gitRoot2) {
|
|
2610
|
-
|
|
2858
|
+
O2.error("Not inside a git repository.");
|
|
2611
2859
|
return;
|
|
2612
2860
|
}
|
|
2613
2861
|
const serviceManager = platform === "linux" ? "systemctl" : "launchctl";
|
|
2614
2862
|
const smResult = run("which", [serviceManager]);
|
|
2615
2863
|
if (!smResult.success) {
|
|
2616
|
-
|
|
2864
|
+
O2.error(`${serviceManager} not found. Cannot manage services on this system.`);
|
|
2617
2865
|
return;
|
|
2618
2866
|
}
|
|
2619
2867
|
const webmuxPath = resolveWebmuxPath();
|
|
2620
2868
|
if (!webmuxPath) {
|
|
2621
|
-
|
|
2869
|
+
O2.error("Could not find webmux in PATH.");
|
|
2622
2870
|
return;
|
|
2623
2871
|
}
|
|
2624
2872
|
let port = parseInt(process.env.PORT || "5111");
|
|
@@ -2626,7 +2874,7 @@ async function service(args) {
|
|
|
2626
2874
|
if (args[i] === "--port" && args[i + 1]) {
|
|
2627
2875
|
const parsed = parseInt(args[++i]);
|
|
2628
2876
|
if (Number.isNaN(parsed)) {
|
|
2629
|
-
|
|
2877
|
+
O2.error("--port requires a numeric value");
|
|
2630
2878
|
return;
|
|
2631
2879
|
}
|
|
2632
2880
|
port = parsed;
|
|
@@ -2658,10 +2906,13 @@ async function service(args) {
|
|
|
2658
2906
|
}
|
|
2659
2907
|
}
|
|
2660
2908
|
var init_service = __esm(() => {
|
|
2661
|
-
|
|
2909
|
+
init_dist4();
|
|
2662
2910
|
init_shared();
|
|
2663
2911
|
});
|
|
2664
2912
|
|
|
2913
|
+
// backend/src/domain/model.ts
|
|
2914
|
+
var WORKTREE_META_SCHEMA_VERSION = 1, WORKTREE_ARCHIVE_STATE_VERSION = 1;
|
|
2915
|
+
|
|
2665
2916
|
// backend/src/adapters/fs.ts
|
|
2666
2917
|
import { mkdir } from "fs/promises";
|
|
2667
2918
|
import { join as join6 } from "path";
|
|
@@ -2713,6 +2964,9 @@ function getWorktreeStoragePaths(gitDir) {
|
|
|
2713
2964
|
prsPath: join6(webmuxDir, "prs.json")
|
|
2714
2965
|
};
|
|
2715
2966
|
}
|
|
2967
|
+
function getProjectArchiveStatePath(gitDir) {
|
|
2968
|
+
return join6(gitDir, "webmux", "archive.json");
|
|
2969
|
+
}
|
|
2716
2970
|
async function ensureWorktreeStorageDirs(gitDir) {
|
|
2717
2971
|
const paths = getWorktreeStoragePaths(gitDir);
|
|
2718
2972
|
await mkdir(paths.webmuxDir, { recursive: true });
|
|
@@ -2731,6 +2985,36 @@ async function writeWorktreeMeta(gitDir, meta) {
|
|
|
2731
2985
|
await Bun.write(metaPath, JSON.stringify(meta, null, 2) + `
|
|
2732
2986
|
`);
|
|
2733
2987
|
}
|
|
2988
|
+
function isArchivedWorktreeEntry(raw) {
|
|
2989
|
+
return isRecord2(raw) && typeof raw.path === "string" && typeof raw.archivedAt === "string";
|
|
2990
|
+
}
|
|
2991
|
+
function emptyWorktreeArchiveState() {
|
|
2992
|
+
return {
|
|
2993
|
+
schemaVersion: WORKTREE_ARCHIVE_STATE_VERSION,
|
|
2994
|
+
entries: []
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
function isWorktreeArchiveState(raw) {
|
|
2998
|
+
return isRecord2(raw) && typeof raw.schemaVersion === "number" && Array.isArray(raw.entries) && raw.entries.every((entry) => isArchivedWorktreeEntry(entry));
|
|
2999
|
+
}
|
|
3000
|
+
async function readWorktreeArchiveState(gitDir) {
|
|
3001
|
+
const archivePath = getProjectArchiveStatePath(gitDir);
|
|
3002
|
+
try {
|
|
3003
|
+
const raw = await Bun.file(archivePath).json();
|
|
3004
|
+
return isWorktreeArchiveState(raw) ? {
|
|
3005
|
+
schemaVersion: raw.schemaVersion,
|
|
3006
|
+
entries: raw.entries.map((entry) => ({ ...entry }))
|
|
3007
|
+
} : emptyWorktreeArchiveState();
|
|
3008
|
+
} catch {
|
|
3009
|
+
return emptyWorktreeArchiveState();
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
async function writeWorktreeArchiveState(gitDir, state) {
|
|
3013
|
+
const archivePath = getProjectArchiveStatePath(gitDir);
|
|
3014
|
+
await ensureWorktreeStorageDirs(gitDir);
|
|
3015
|
+
await Bun.write(archivePath, JSON.stringify(state, null, 2) + `
|
|
3016
|
+
`);
|
|
3017
|
+
}
|
|
2734
3018
|
function buildRuntimeEnvMap(meta, extraEnv = {}, dotenvValues = {}) {
|
|
2735
3019
|
return {
|
|
2736
3020
|
...dotenvValues,
|
|
@@ -2953,6 +3237,38 @@ var init_policies = __esm(() => {
|
|
|
2953
3237
|
VALID_WORKTREE_NAME_RE = /^[a-z0-9][a-z0-9\-_./]*$/;
|
|
2954
3238
|
});
|
|
2955
3239
|
|
|
3240
|
+
// backend/src/services/archive-service.ts
|
|
3241
|
+
import { resolve as resolve4 } from "path";
|
|
3242
|
+
function createArchiveState(entries) {
|
|
3243
|
+
return {
|
|
3244
|
+
schemaVersion: WORKTREE_ARCHIVE_STATE_VERSION,
|
|
3245
|
+
entries: [...entries].sort((left, right) => left.path.localeCompare(right.path))
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3248
|
+
function normalizeArchivePath(path) {
|
|
3249
|
+
return resolve4(path);
|
|
3250
|
+
}
|
|
3251
|
+
function buildArchivedWorktreePathSet(state) {
|
|
3252
|
+
return new Set(state.entries.map((entry) => normalizeArchivePath(entry.path)));
|
|
3253
|
+
}
|
|
3254
|
+
function setArchivedWorktreeState(input) {
|
|
3255
|
+
const normalizedPath = normalizeArchivePath(input.path);
|
|
3256
|
+
const entries = input.state.entries.filter((entry) => normalizeArchivePath(entry.path) !== normalizedPath);
|
|
3257
|
+
if (!input.archived) {
|
|
3258
|
+
return createArchiveState(entries);
|
|
3259
|
+
}
|
|
3260
|
+
entries.push({
|
|
3261
|
+
path: normalizedPath,
|
|
3262
|
+
archivedAt: (input.now ?? (() => new Date))().toISOString()
|
|
3263
|
+
});
|
|
3264
|
+
return createArchiveState(entries);
|
|
3265
|
+
}
|
|
3266
|
+
function pruneArchivedWorktreeState(input) {
|
|
3267
|
+
const validPaths = new Set(input.paths.map((path) => normalizeArchivePath(path)));
|
|
3268
|
+
return createArchiveState(input.state.entries.filter((entry) => validPaths.has(normalizeArchivePath(entry.path))));
|
|
3269
|
+
}
|
|
3270
|
+
var init_archive_service = () => {};
|
|
3271
|
+
|
|
2956
3272
|
// node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/identity.js
|
|
2957
3273
|
var require_identity = __commonJS((exports) => {
|
|
2958
3274
|
var ALIAS = Symbol.for("yaml.alias");
|
|
@@ -3154,8 +3470,8 @@ var require_visit = __commonJS((exports) => {
|
|
|
3154
3470
|
} else if (identity.isDocument(parent)) {
|
|
3155
3471
|
parent.contents = node;
|
|
3156
3472
|
} else {
|
|
3157
|
-
const
|
|
3158
|
-
throw new Error(`Cannot replace node with ${
|
|
3473
|
+
const pt = identity.isAlias(parent) ? "alias" : "scalar";
|
|
3474
|
+
throw new Error(`Cannot replace node with ${pt} parent`);
|
|
3159
3475
|
}
|
|
3160
3476
|
}
|
|
3161
3477
|
exports.visit = visit;
|
|
@@ -3390,13 +3706,13 @@ var require_applyReviver = __commonJS((exports) => {
|
|
|
3390
3706
|
val[i] = v1;
|
|
3391
3707
|
}
|
|
3392
3708
|
} else if (val instanceof Map) {
|
|
3393
|
-
for (const
|
|
3394
|
-
const v0 = val.get(
|
|
3395
|
-
const v1 = applyReviver(reviver, val,
|
|
3709
|
+
for (const k2 of Array.from(val.keys())) {
|
|
3710
|
+
const v0 = val.get(k2);
|
|
3711
|
+
const v1 = applyReviver(reviver, val, k2, v0);
|
|
3396
3712
|
if (v1 === undefined)
|
|
3397
|
-
val.delete(
|
|
3713
|
+
val.delete(k2);
|
|
3398
3714
|
else if (v1 !== v0)
|
|
3399
|
-
val.set(
|
|
3715
|
+
val.set(k2, v1);
|
|
3400
3716
|
}
|
|
3401
3717
|
} else if (val instanceof Set) {
|
|
3402
3718
|
for (const v0 of Array.from(val)) {
|
|
@@ -3409,12 +3725,12 @@ var require_applyReviver = __commonJS((exports) => {
|
|
|
3409
3725
|
}
|
|
3410
3726
|
}
|
|
3411
3727
|
} else {
|
|
3412
|
-
for (const [
|
|
3413
|
-
const v1 = applyReviver(reviver, val,
|
|
3728
|
+
for (const [k2, v0] of Object.entries(val)) {
|
|
3729
|
+
const v1 = applyReviver(reviver, val, k2, v0);
|
|
3414
3730
|
if (v1 === undefined)
|
|
3415
|
-
delete val[
|
|
3731
|
+
delete val[k2];
|
|
3416
3732
|
else if (v1 !== v0)
|
|
3417
|
-
val[
|
|
3733
|
+
val[k2] = v1;
|
|
3418
3734
|
}
|
|
3419
3735
|
}
|
|
3420
3736
|
}
|
|
@@ -3580,9 +3896,9 @@ var require_Alias = __commonJS((exports) => {
|
|
|
3580
3896
|
} else if (identity.isCollection(node)) {
|
|
3581
3897
|
let count = 0;
|
|
3582
3898
|
for (const item of node.items) {
|
|
3583
|
-
const
|
|
3584
|
-
if (
|
|
3585
|
-
count =
|
|
3899
|
+
const c2 = getAliasCount(doc, item, anchors2);
|
|
3900
|
+
if (c2 > count)
|
|
3901
|
+
count = c2;
|
|
3586
3902
|
}
|
|
3587
3903
|
return count;
|
|
3588
3904
|
} else if (identity.isPair(node)) {
|
|
@@ -3703,13 +4019,13 @@ var require_Collection = __commonJS((exports) => {
|
|
|
3703
4019
|
function collectionFromPath(schema, path, value) {
|
|
3704
4020
|
let v = value;
|
|
3705
4021
|
for (let i = path.length - 1;i >= 0; --i) {
|
|
3706
|
-
const
|
|
3707
|
-
if (typeof
|
|
4022
|
+
const k2 = path[i];
|
|
4023
|
+
if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
|
|
3708
4024
|
const a = [];
|
|
3709
|
-
a[
|
|
4025
|
+
a[k2] = v;
|
|
3710
4026
|
v = a;
|
|
3711
4027
|
} else {
|
|
3712
|
-
v = new Map([[
|
|
4028
|
+
v = new Map([[k2, v]]);
|
|
3713
4029
|
}
|
|
3714
4030
|
}
|
|
3715
4031
|
return createNode.createNode(v, undefined, {
|
|
@@ -4660,9 +4976,9 @@ var require_Pair = __commonJS((exports) => {
|
|
|
4660
4976
|
var addPairToJSMap = require_addPairToJSMap();
|
|
4661
4977
|
var identity = require_identity();
|
|
4662
4978
|
function createPair(key, value, ctx) {
|
|
4663
|
-
const
|
|
4979
|
+
const k2 = createNode.createNode(key, undefined, ctx);
|
|
4664
4980
|
const v = createNode.createNode(value, undefined, ctx);
|
|
4665
|
-
return new Pair(
|
|
4981
|
+
return new Pair(k2, v);
|
|
4666
4982
|
}
|
|
4667
4983
|
|
|
4668
4984
|
class Pair {
|
|
@@ -4679,7 +4995,7 @@ var require_Pair = __commonJS((exports) => {
|
|
|
4679
4995
|
value = value.clone(schema);
|
|
4680
4996
|
return new Pair(key, value);
|
|
4681
4997
|
}
|
|
4682
|
-
toJSON(
|
|
4998
|
+
toJSON(_, ctx) {
|
|
4683
4999
|
const pair = ctx?.mapAsMap ? new Map : {};
|
|
4684
5000
|
return addPairToJSMap.addPairToJSMap(ctx, pair, this);
|
|
4685
5001
|
}
|
|
@@ -4852,12 +5168,12 @@ var require_YAMLMap = __commonJS((exports) => {
|
|
|
4852
5168
|
var Pair = require_Pair();
|
|
4853
5169
|
var Scalar = require_Scalar();
|
|
4854
5170
|
function findPair(items, key) {
|
|
4855
|
-
const
|
|
5171
|
+
const k2 = identity.isScalar(key) ? key.value : key;
|
|
4856
5172
|
for (const it2 of items) {
|
|
4857
5173
|
if (identity.isPair(it2)) {
|
|
4858
|
-
if (it2.key === key || it2.key ===
|
|
5174
|
+
if (it2.key === key || it2.key === k2)
|
|
4859
5175
|
return it2;
|
|
4860
|
-
if (identity.isScalar(it2.key) && it2.key.value ===
|
|
5176
|
+
if (identity.isScalar(it2.key) && it2.key.value === k2)
|
|
4861
5177
|
return it2;
|
|
4862
5178
|
}
|
|
4863
5179
|
}
|
|
@@ -4940,7 +5256,7 @@ var require_YAMLMap = __commonJS((exports) => {
|
|
|
4940
5256
|
set(key, value) {
|
|
4941
5257
|
this.add(new Pair.Pair(key, value), true);
|
|
4942
5258
|
}
|
|
4943
|
-
toJSON(
|
|
5259
|
+
toJSON(_, ctx, Type) {
|
|
4944
5260
|
const map = Type ? new Type : ctx?.mapAsMap ? new Map : {};
|
|
4945
5261
|
if (ctx?.onCreate)
|
|
4946
5262
|
ctx.onCreate(map);
|
|
@@ -5037,7 +5353,7 @@ var require_YAMLSeq = __commonJS((exports) => {
|
|
|
5037
5353
|
else
|
|
5038
5354
|
this.items[idx] = value;
|
|
5039
5355
|
}
|
|
5040
|
-
toJSON(
|
|
5356
|
+
toJSON(_, ctx) {
|
|
5041
5357
|
const seq = [];
|
|
5042
5358
|
if (ctx?.onCreate)
|
|
5043
5359
|
ctx.onCreate(seq);
|
|
@@ -5168,8 +5484,8 @@ var require_stringifyNumber = __commonJS((exports) => {
|
|
|
5168
5484
|
i = n.length;
|
|
5169
5485
|
n += ".";
|
|
5170
5486
|
}
|
|
5171
|
-
let
|
|
5172
|
-
while (
|
|
5487
|
+
let d3 = minFractionDigits - (n.length - i - 1);
|
|
5488
|
+
while (d3-- > 0)
|
|
5173
5489
|
n += "0";
|
|
5174
5490
|
}
|
|
5175
5491
|
return n;
|
|
@@ -5499,9 +5815,9 @@ var require_omap = __commonJS((exports) => {
|
|
|
5499
5815
|
this.set = YAMLMap.YAMLMap.prototype.set.bind(this);
|
|
5500
5816
|
this.tag = YAMLOMap.tag;
|
|
5501
5817
|
}
|
|
5502
|
-
toJSON(
|
|
5818
|
+
toJSON(_, ctx) {
|
|
5503
5819
|
if (!ctx)
|
|
5504
|
-
return super.toJSON(
|
|
5820
|
+
return super.toJSON(_);
|
|
5505
5821
|
const map = new Map;
|
|
5506
5822
|
if (ctx?.onCreate)
|
|
5507
5823
|
ctx.onCreate(map);
|
|
@@ -5741,8 +6057,8 @@ var require_set = __commonJS((exports) => {
|
|
|
5741
6057
|
this.items.push(new Pair.Pair(key));
|
|
5742
6058
|
}
|
|
5743
6059
|
}
|
|
5744
|
-
toJSON(
|
|
5745
|
-
return super.toJSON(
|
|
6060
|
+
toJSON(_, ctx) {
|
|
6061
|
+
return super.toJSON(_, ctx, Set);
|
|
5746
6062
|
}
|
|
5747
6063
|
toString(ctx, onComment, onChompKeep) {
|
|
5748
6064
|
if (!ctx)
|
|
@@ -5794,7 +6110,7 @@ var require_timestamp = __commonJS((exports) => {
|
|
|
5794
6110
|
const sign = str[0];
|
|
5795
6111
|
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
|
|
5796
6112
|
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
5797
|
-
const res = parts.replace(/_/g, "").split(":").reduce((res2,
|
|
6113
|
+
const res = parts.replace(/_/g, "").split(":").reduce((res2, p2) => res2 * num(60) + num(p2), num(0));
|
|
5798
6114
|
return sign === "-" ? num(-1) * res : res;
|
|
5799
6115
|
}
|
|
5800
6116
|
function stringifySexagesimal(node) {
|
|
@@ -5855,10 +6171,10 @@ var require_timestamp = __commonJS((exports) => {
|
|
|
5855
6171
|
let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
|
|
5856
6172
|
const tz = match[8];
|
|
5857
6173
|
if (tz && tz !== "Z") {
|
|
5858
|
-
let
|
|
5859
|
-
if (Math.abs(
|
|
5860
|
-
|
|
5861
|
-
date -= 60000 *
|
|
6174
|
+
let d3 = parseSexagesimal(tz, false);
|
|
6175
|
+
if (Math.abs(d3) < 30)
|
|
6176
|
+
d3 *= 60;
|
|
6177
|
+
date -= 60000 * d3;
|
|
5862
6178
|
}
|
|
5863
6179
|
return new Date(date);
|
|
5864
6180
|
},
|
|
@@ -6225,9 +6541,9 @@ var require_Document = __commonJS((exports) => {
|
|
|
6225
6541
|
return node;
|
|
6226
6542
|
}
|
|
6227
6543
|
createPair(key, value, options = {}) {
|
|
6228
|
-
const
|
|
6544
|
+
const k2 = this.createNode(key, null, options);
|
|
6229
6545
|
const v = this.createNode(value, null, options);
|
|
6230
|
-
return new Pair.Pair(
|
|
6546
|
+
return new Pair.Pair(k2, v);
|
|
6231
6547
|
}
|
|
6232
6548
|
delete(key) {
|
|
6233
6549
|
return assertCollection(this.contents) ? this.contents.delete(key) : false;
|
|
@@ -6966,16 +7282,16 @@ var require_resolve_flow_collection = __commonJS((exports) => {
|
|
|
6966
7282
|
}
|
|
6967
7283
|
}
|
|
6968
7284
|
const expectedEnd = isMap ? "}" : "]";
|
|
6969
|
-
const [
|
|
7285
|
+
const [ce2, ...ee2] = fc.end;
|
|
6970
7286
|
let cePos = offset;
|
|
6971
|
-
if (
|
|
6972
|
-
cePos =
|
|
7287
|
+
if (ce2?.source === expectedEnd)
|
|
7288
|
+
cePos = ce2.offset + ce2.source.length;
|
|
6973
7289
|
else {
|
|
6974
7290
|
const name = fcName[0].toUpperCase() + fcName.substring(1);
|
|
6975
7291
|
const msg = atRoot ? `${name} must end with a ${expectedEnd}` : `${name} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
|
|
6976
7292
|
onError(offset, atRoot ? "MISSING_CHAR" : "BAD_INDENT", msg);
|
|
6977
|
-
if (
|
|
6978
|
-
ee2.unshift(
|
|
7293
|
+
if (ce2 && ce2.source.length !== 1)
|
|
7294
|
+
ee2.unshift(ce2);
|
|
6979
7295
|
}
|
|
6980
7296
|
if (ee2.length > 0) {
|
|
6981
7297
|
const end = resolveEnd.resolveEnd(ee2, cePos, ctx.options.strict, onError);
|
|
@@ -7032,13 +7348,13 @@ var require_compose_collection = __commonJS((exports) => {
|
|
|
7032
7348
|
}
|
|
7033
7349
|
let tag = ctx.schema.tags.find((t2) => t2.tag === tagName && t2.collection === expType);
|
|
7034
7350
|
if (!tag) {
|
|
7035
|
-
const
|
|
7036
|
-
if (
|
|
7037
|
-
ctx.schema.tags.push(Object.assign({},
|
|
7038
|
-
tag =
|
|
7351
|
+
const kt = ctx.schema.knownTags[tagName];
|
|
7352
|
+
if (kt?.collection === expType) {
|
|
7353
|
+
ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
|
|
7354
|
+
tag = kt;
|
|
7039
7355
|
} else {
|
|
7040
|
-
if (
|
|
7041
|
-
onError(tagToken, "BAD_COLLECTION_TYPE", `${
|
|
7356
|
+
if (kt) {
|
|
7357
|
+
onError(tagToken, "BAD_COLLECTION_TYPE", `${kt.tag} used for ${expType} collection, but expects ${kt.collection ?? "scalar"}`, true);
|
|
7042
7358
|
} else {
|
|
7043
7359
|
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, true);
|
|
7044
7360
|
}
|
|
@@ -7520,10 +7836,10 @@ var require_compose_scalar = __commonJS((exports) => {
|
|
|
7520
7836
|
for (const tag of matchWithTest)
|
|
7521
7837
|
if (tag.test?.test(value))
|
|
7522
7838
|
return tag;
|
|
7523
|
-
const
|
|
7524
|
-
if (
|
|
7525
|
-
schema.tags.push(Object.assign({},
|
|
7526
|
-
return
|
|
7839
|
+
const kt = schema.knownTags[tagName];
|
|
7840
|
+
if (kt && !kt.collection) {
|
|
7841
|
+
schema.tags.push(Object.assign({}, kt, { default: false, test: undefined }));
|
|
7842
|
+
return kt;
|
|
7527
7843
|
}
|
|
7528
7844
|
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str");
|
|
7529
7845
|
return schema[identity.SCALAR];
|
|
@@ -8392,8 +8708,8 @@ var require_lexer = __commonJS((exports) => {
|
|
|
8392
8708
|
` || indent >= this.indentNext || !ch && !this.atEnd ? offset + indent : -1;
|
|
8393
8709
|
}
|
|
8394
8710
|
if (ch === "-" || ch === ".") {
|
|
8395
|
-
const
|
|
8396
|
-
if ((
|
|
8711
|
+
const dt = this.buffer.substr(offset, 3);
|
|
8712
|
+
if ((dt === "---" || dt === "...") && isEmpty(this.buffer[offset + 3]))
|
|
8397
8713
|
return -1;
|
|
8398
8714
|
}
|
|
8399
8715
|
return offset;
|
|
@@ -9870,7 +10186,7 @@ var require_public_api = __commonJS((exports) => {
|
|
|
9870
10186
|
|
|
9871
10187
|
// node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/index.js
|
|
9872
10188
|
var composer, Document, Schema, errors, Alias, identity, Pair, Scalar, YAMLMap, YAMLSeq, cst, lexer, lineCounter, parser, publicApi, visit, $Composer, $Document, $Schema, $YAMLError, $YAMLParseError, $YAMLWarning, $Alias, $isAlias, $isCollection, $isDocument, $isMap, $isNode, $isPair, $isScalar, $isSeq, $Pair, $Scalar, $YAMLMap, $YAMLSeq, $Lexer, $LineCounter, $Parser, $parse, $parseAllDocuments, $parseDocument, $stringify, $visit, $visitAsync;
|
|
9873
|
-
var
|
|
10189
|
+
var init_dist5 = __esm(() => {
|
|
9874
10190
|
composer = require_composer();
|
|
9875
10191
|
Document = require_Document();
|
|
9876
10192
|
Schema = require_Schema();
|
|
@@ -9919,7 +10235,7 @@ var init_dist3 = __esm(() => {
|
|
|
9919
10235
|
|
|
9920
10236
|
// backend/src/adapters/config.ts
|
|
9921
10237
|
import { readFileSync as readFileSync3 } from "fs";
|
|
9922
|
-
import { dirname as dirname2, join as join7, resolve as
|
|
10238
|
+
import { dirname as dirname2, join as join7, resolve as resolve5 } from "path";
|
|
9923
10239
|
function clonePanes(panes) {
|
|
9924
10240
|
return panes.map((pane) => ({ ...pane }));
|
|
9925
10241
|
}
|
|
@@ -10230,7 +10546,7 @@ function projectRoot(dir) {
|
|
|
10230
10546
|
if (result.exitCode !== 0)
|
|
10231
10547
|
return gitRoot2(dir);
|
|
10232
10548
|
const commonDir = new TextDecoder().decode(result.stdout).trim();
|
|
10233
|
-
return commonDir ? dirname2(
|
|
10549
|
+
return commonDir ? dirname2(resolve5(dir, commonDir)) : gitRoot2(dir);
|
|
10234
10550
|
}
|
|
10235
10551
|
function loadConfig(dir, options = {}) {
|
|
10236
10552
|
const root = options.resolvedRoot ? dir : projectRoot(dir);
|
|
@@ -10265,11 +10581,11 @@ function loadConfig(dir, options = {}) {
|
|
|
10265
10581
|
};
|
|
10266
10582
|
}
|
|
10267
10583
|
function expandTemplate(template, env) {
|
|
10268
|
-
return template.replace(/\$\{(\w+)\}/g, (
|
|
10584
|
+
return template.replace(/\$\{(\w+)\}/g, (_, key) => env[key] ?? "");
|
|
10269
10585
|
}
|
|
10270
10586
|
var DEFAULT_PANES, DEFAULT_CONFIG;
|
|
10271
10587
|
var init_config = __esm(() => {
|
|
10272
|
-
|
|
10588
|
+
init_dist5();
|
|
10273
10589
|
DEFAULT_PANES = [
|
|
10274
10590
|
{ id: "agent", kind: "agent", focus: true },
|
|
10275
10591
|
{ id: "shell", kind: "shell", split: "right", sizePct: 25 }
|
|
@@ -10349,9 +10665,9 @@ var init_log = __esm(() => {
|
|
|
10349
10665
|
|
|
10350
10666
|
// backend/src/adapters/docker.ts
|
|
10351
10667
|
import { stat } from "fs/promises";
|
|
10352
|
-
async function pathExists(
|
|
10668
|
+
async function pathExists(p2) {
|
|
10353
10669
|
try {
|
|
10354
|
-
await stat(
|
|
10670
|
+
await stat(p2);
|
|
10355
10671
|
return true;
|
|
10356
10672
|
} catch {
|
|
10357
10673
|
return false;
|
|
@@ -10528,9 +10844,9 @@ async function launchContainer(opts) {
|
|
|
10528
10844
|
...sshAuthSock ? [sshAuthSock] : []
|
|
10529
10845
|
];
|
|
10530
10846
|
const existingPaths = new Set;
|
|
10531
|
-
await Promise.all(credentialHostPaths.map(async (
|
|
10532
|
-
if (await pathExists(
|
|
10533
|
-
existingPaths.add(
|
|
10847
|
+
await Promise.all(credentialHostPaths.map(async (p2) => {
|
|
10848
|
+
if (await pathExists(p2))
|
|
10849
|
+
existingPaths.add(p2);
|
|
10534
10850
|
}));
|
|
10535
10851
|
const args = buildDockerRunArgs(opts, existingPaths, home, name, sshAuthSock, process.getuid(), process.getgid());
|
|
10536
10852
|
log.info(`[docker] launching container: ${name}`);
|
|
@@ -10676,7 +10992,7 @@ class BunPortProbe {
|
|
|
10676
10992
|
this.hostnames = hostnames;
|
|
10677
10993
|
}
|
|
10678
10994
|
isListening(port) {
|
|
10679
|
-
return new Promise((
|
|
10995
|
+
return new Promise((resolve6) => {
|
|
10680
10996
|
let settled = false;
|
|
10681
10997
|
let pending = this.hostnames.length;
|
|
10682
10998
|
const settle = (result) => {
|
|
@@ -10685,20 +11001,20 @@ class BunPortProbe {
|
|
|
10685
11001
|
if (result) {
|
|
10686
11002
|
settled = true;
|
|
10687
11003
|
clearTimeout(timer);
|
|
10688
|
-
|
|
11004
|
+
resolve6(true);
|
|
10689
11005
|
return;
|
|
10690
11006
|
}
|
|
10691
11007
|
pending--;
|
|
10692
11008
|
if (pending === 0) {
|
|
10693
11009
|
settled = true;
|
|
10694
11010
|
clearTimeout(timer);
|
|
10695
|
-
|
|
11011
|
+
resolve6(false);
|
|
10696
11012
|
}
|
|
10697
11013
|
};
|
|
10698
11014
|
const timer = setTimeout(() => {
|
|
10699
11015
|
if (!settled) {
|
|
10700
11016
|
settled = true;
|
|
10701
|
-
|
|
11017
|
+
resolve6(false);
|
|
10702
11018
|
}
|
|
10703
11019
|
}, this.timeoutMs);
|
|
10704
11020
|
for (const hostname of this.hostnames) {
|
|
@@ -10721,6 +11037,13 @@ class BunPortProbe {
|
|
|
10721
11037
|
}
|
|
10722
11038
|
}
|
|
10723
11039
|
|
|
11040
|
+
// backend/src/lib/branch-name.ts
|
|
11041
|
+
import { randomUUID } from "crypto";
|
|
11042
|
+
function generateFallbackBranchName() {
|
|
11043
|
+
return `change-${randomUUID().slice(0, 8)}`;
|
|
11044
|
+
}
|
|
11045
|
+
var init_branch_name = () => {};
|
|
11046
|
+
|
|
10724
11047
|
// backend/src/services/auto-name-service.ts
|
|
10725
11048
|
function normalizeGeneratedBranchName(raw) {
|
|
10726
11049
|
let branch = raw.trim();
|
|
@@ -10745,17 +11068,44 @@ function normalizeGeneratedBranchName(raw) {
|
|
|
10745
11068
|
function getSystemPrompt(config) {
|
|
10746
11069
|
return config.systemPrompt?.trim() || DEFAULT_SYSTEM_PROMPT;
|
|
10747
11070
|
}
|
|
10748
|
-
async function defaultSpawn(args) {
|
|
11071
|
+
async function defaultSpawn(args, options = {}) {
|
|
10749
11072
|
const proc = Bun.spawn(args, {
|
|
10750
11073
|
stdout: "pipe",
|
|
10751
11074
|
stderr: "pipe"
|
|
10752
11075
|
});
|
|
10753
|
-
const
|
|
11076
|
+
const resultPromise = Promise.all([
|
|
10754
11077
|
new Response(proc.stdout).text(),
|
|
10755
11078
|
new Response(proc.stderr).text(),
|
|
10756
11079
|
proc.exited
|
|
10757
|
-
]);
|
|
10758
|
-
|
|
11080
|
+
]).then(([stdout, stderr, exitCode]) => ({ exitCode, stdout, stderr }));
|
|
11081
|
+
if (options.timeoutMs === undefined) {
|
|
11082
|
+
return await resultPromise;
|
|
11083
|
+
}
|
|
11084
|
+
return await new Promise((resolve6, reject) => {
|
|
11085
|
+
let settled = false;
|
|
11086
|
+
const timeoutId = setTimeout(() => {
|
|
11087
|
+
if (settled)
|
|
11088
|
+
return;
|
|
11089
|
+
settled = true;
|
|
11090
|
+
try {
|
|
11091
|
+
proc.kill("SIGKILL");
|
|
11092
|
+
} catch {}
|
|
11093
|
+
reject(new AutoNameTimeoutError(options.timeoutMs));
|
|
11094
|
+
}, options.timeoutMs);
|
|
11095
|
+
resultPromise.then((result) => {
|
|
11096
|
+
if (settled)
|
|
11097
|
+
return;
|
|
11098
|
+
settled = true;
|
|
11099
|
+
clearTimeout(timeoutId);
|
|
11100
|
+
resolve6(result);
|
|
11101
|
+
}, (error) => {
|
|
11102
|
+
if (settled)
|
|
11103
|
+
return;
|
|
11104
|
+
settled = true;
|
|
11105
|
+
clearTimeout(timeoutId);
|
|
11106
|
+
reject(error);
|
|
11107
|
+
});
|
|
11108
|
+
});
|
|
10759
11109
|
}
|
|
10760
11110
|
function buildClaudeArgs(model, systemPrompt, prompt) {
|
|
10761
11111
|
const args = [
|
|
@@ -10797,8 +11147,10 @@ function buildCodexArgs(model, systemPrompt, prompt) {
|
|
|
10797
11147
|
|
|
10798
11148
|
class AutoNameService {
|
|
10799
11149
|
spawnImpl;
|
|
11150
|
+
timeoutMs;
|
|
10800
11151
|
constructor(deps2 = {}) {
|
|
10801
11152
|
this.spawnImpl = deps2.spawnImpl ?? defaultSpawn;
|
|
11153
|
+
this.timeoutMs = deps2.timeoutMs ?? AUTO_NAME_TIMEOUT_MS;
|
|
10802
11154
|
}
|
|
10803
11155
|
async generateBranchName(config, task) {
|
|
10804
11156
|
const prompt = task.trim();
|
|
@@ -10811,8 +11163,13 @@ class AutoNameService {
|
|
|
10811
11163
|
const cli = config.provider === "claude" ? "claude" : "codex";
|
|
10812
11164
|
let result;
|
|
10813
11165
|
try {
|
|
10814
|
-
result = await this.spawnImpl(args);
|
|
10815
|
-
} catch {
|
|
11166
|
+
result = await this.spawnImpl(args, { timeoutMs: this.timeoutMs });
|
|
11167
|
+
} catch (error) {
|
|
11168
|
+
if (error instanceof AutoNameTimeoutError) {
|
|
11169
|
+
const fallback = generateFallbackBranchName();
|
|
11170
|
+
log.warn(`[auto-name] ${cli} timed out after ${this.timeoutMs}ms; using fallback branch ${fallback}`);
|
|
11171
|
+
return fallback;
|
|
11172
|
+
}
|
|
10816
11173
|
throw new Error(`'${cli}' CLI not found. Install it or check your PATH.`);
|
|
10817
11174
|
}
|
|
10818
11175
|
if (result.exitCode !== 0) {
|
|
@@ -10829,9 +11186,11 @@ class AutoNameService {
|
|
|
10829
11186
|
return normalizeGeneratedBranchName(output);
|
|
10830
11187
|
}
|
|
10831
11188
|
}
|
|
10832
|
-
var MAX_BRANCH_LENGTH = 40, DEFAULT_AUTO_NAME_MODEL = "claude-haiku-4-5-20251001", DEFAULT_SYSTEM_PROMPT;
|
|
11189
|
+
var MAX_BRANCH_LENGTH = 40, DEFAULT_AUTO_NAME_MODEL = "claude-haiku-4-5-20251001", AUTO_NAME_TIMEOUT_MS = 1e4, DEFAULT_SYSTEM_PROMPT, AutoNameTimeoutError;
|
|
10833
11190
|
var init_auto_name_service = __esm(() => {
|
|
10834
11191
|
init_policies();
|
|
11192
|
+
init_branch_name();
|
|
11193
|
+
init_log();
|
|
10835
11194
|
DEFAULT_SYSTEM_PROMPT = [
|
|
10836
11195
|
"Generate a concise git branch name from the task description.",
|
|
10837
11196
|
"Return only the branch name.",
|
|
@@ -10839,6 +11198,77 @@ var init_auto_name_service = __esm(() => {
|
|
|
10839
11198
|
`Maximum ${MAX_BRANCH_LENGTH} characters.`,
|
|
10840
11199
|
"Do not include quotes, code fences, or prefixes like feature/ or fix/."
|
|
10841
11200
|
].join(" ");
|
|
11201
|
+
AutoNameTimeoutError = class AutoNameTimeoutError extends Error {
|
|
11202
|
+
timeoutMs;
|
|
11203
|
+
constructor(timeoutMs) {
|
|
11204
|
+
super(`Auto-name timed out after ${timeoutMs}ms`);
|
|
11205
|
+
this.timeoutMs = timeoutMs;
|
|
11206
|
+
}
|
|
11207
|
+
};
|
|
11208
|
+
});
|
|
11209
|
+
|
|
11210
|
+
// backend/src/services/archive-state-service.ts
|
|
11211
|
+
function archiveStatesEqual(left, right) {
|
|
11212
|
+
if (left.schemaVersion !== right.schemaVersion)
|
|
11213
|
+
return false;
|
|
11214
|
+
if (left.entries.length !== right.entries.length)
|
|
11215
|
+
return false;
|
|
11216
|
+
return left.entries.every((entry, index) => entry.path === right.entries[index]?.path && entry.archivedAt === right.entries[index]?.archivedAt);
|
|
11217
|
+
}
|
|
11218
|
+
|
|
11219
|
+
class ArchiveStateService {
|
|
11220
|
+
gitDir;
|
|
11221
|
+
mutationQueue = Promise.resolve();
|
|
11222
|
+
readState;
|
|
11223
|
+
writeState;
|
|
11224
|
+
constructor(gitDir, deps2 = {}) {
|
|
11225
|
+
this.gitDir = gitDir;
|
|
11226
|
+
this.readState = deps2.readState ?? readWorktreeArchiveState;
|
|
11227
|
+
this.writeState = deps2.writeState ?? writeWorktreeArchiveState;
|
|
11228
|
+
}
|
|
11229
|
+
async read() {
|
|
11230
|
+
return await this.readState(this.gitDir);
|
|
11231
|
+
}
|
|
11232
|
+
async setArchived(path, archived) {
|
|
11233
|
+
return await this.mutate((state) => setArchivedWorktreeState({
|
|
11234
|
+
state,
|
|
11235
|
+
path,
|
|
11236
|
+
archived
|
|
11237
|
+
}));
|
|
11238
|
+
}
|
|
11239
|
+
async prune(paths) {
|
|
11240
|
+
return await this.mutate((state) => pruneArchivedWorktreeState({
|
|
11241
|
+
state,
|
|
11242
|
+
paths
|
|
11243
|
+
}));
|
|
11244
|
+
}
|
|
11245
|
+
async mutate(transform) {
|
|
11246
|
+
return await this.withMutationLock(async () => {
|
|
11247
|
+
const state = await this.readState(this.gitDir);
|
|
11248
|
+
const nextState = await transform(state);
|
|
11249
|
+
if (!archiveStatesEqual(state, nextState)) {
|
|
11250
|
+
await this.writeState(this.gitDir, nextState);
|
|
11251
|
+
}
|
|
11252
|
+
return nextState;
|
|
11253
|
+
});
|
|
11254
|
+
}
|
|
11255
|
+
async withMutationLock(operation) {
|
|
11256
|
+
const previous = this.mutationQueue;
|
|
11257
|
+
let release = () => {};
|
|
11258
|
+
this.mutationQueue = new Promise((resolve6) => {
|
|
11259
|
+
release = resolve6;
|
|
11260
|
+
});
|
|
11261
|
+
await previous.catch(() => {});
|
|
11262
|
+
try {
|
|
11263
|
+
return await operation();
|
|
11264
|
+
} finally {
|
|
11265
|
+
release();
|
|
11266
|
+
}
|
|
11267
|
+
}
|
|
11268
|
+
}
|
|
11269
|
+
var init_archive_state_service = __esm(() => {
|
|
11270
|
+
init_fs();
|
|
11271
|
+
init_archive_service();
|
|
10842
11272
|
});
|
|
10843
11273
|
|
|
10844
11274
|
// backend/src/adapters/agent-runtime.ts
|
|
@@ -11174,7 +11604,7 @@ function buildDockerAgentPaneCommand(input) {
|
|
|
11174
11604
|
}
|
|
11175
11605
|
|
|
11176
11606
|
// backend/src/services/session-service.ts
|
|
11177
|
-
import { resolve as
|
|
11607
|
+
import { resolve as resolve6 } from "path";
|
|
11178
11608
|
function quoteShell2(value) {
|
|
11179
11609
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
11180
11610
|
}
|
|
@@ -11188,7 +11618,7 @@ function buildCommandPaneStartupCommand(template, ctx) {
|
|
|
11188
11618
|
if (!template.workingDir) {
|
|
11189
11619
|
return template.command;
|
|
11190
11620
|
}
|
|
11191
|
-
const workingDir =
|
|
11621
|
+
const workingDir = resolve6(resolvePaneCwd(template, ctx), template.workingDir);
|
|
11192
11622
|
return `cd -- ${quoteShell2(workingDir)} && ${template.command}`;
|
|
11193
11623
|
}
|
|
11194
11624
|
function resolvePaneStartupCommand(template, ctx) {
|
|
@@ -11266,11 +11696,8 @@ var init_session_service = __esm(() => {
|
|
|
11266
11696
|
init_tmux();
|
|
11267
11697
|
});
|
|
11268
11698
|
|
|
11269
|
-
// backend/src/domain/model.ts
|
|
11270
|
-
var WORKTREE_META_SCHEMA_VERSION = 1;
|
|
11271
|
-
|
|
11272
11699
|
// backend/src/services/worktree-service.ts
|
|
11273
|
-
import { randomUUID } from "crypto";
|
|
11700
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
11274
11701
|
function toErrorMessage(error) {
|
|
11275
11702
|
return error instanceof Error ? error.message : String(error);
|
|
11276
11703
|
}
|
|
@@ -11317,7 +11744,7 @@ async function initializeManagedWorktree(opts) {
|
|
|
11317
11744
|
const createdAt = (opts.now ?? (() => new Date))().toISOString();
|
|
11318
11745
|
const meta = {
|
|
11319
11746
|
schemaVersion: WORKTREE_META_SCHEMA_VERSION,
|
|
11320
|
-
worktreeId: opts.worktreeId ??
|
|
11747
|
+
worktreeId: opts.worktreeId ?? randomUUID2(),
|
|
11321
11748
|
branch: opts.branch,
|
|
11322
11749
|
...opts.baseBranch ? { baseBranch: opts.baseBranch } : {},
|
|
11323
11750
|
createdAt,
|
|
@@ -11420,12 +11847,8 @@ var init_worktree_service = __esm(() => {
|
|
|
11420
11847
|
});
|
|
11421
11848
|
|
|
11422
11849
|
// backend/src/services/lifecycle-service.ts
|
|
11423
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
11424
11850
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
11425
|
-
import { dirname as dirname5, resolve as
|
|
11426
|
-
function generateBranchName() {
|
|
11427
|
-
return `change-${randomUUID2().slice(0, 8)}`;
|
|
11428
|
-
}
|
|
11851
|
+
import { dirname as dirname5, resolve as resolve7 } from "path";
|
|
11429
11852
|
function toErrorMessage2(error) {
|
|
11430
11853
|
return error instanceof Error ? error.message : String(error);
|
|
11431
11854
|
}
|
|
@@ -11521,9 +11944,8 @@ class LifecycleService {
|
|
|
11521
11944
|
}
|
|
11522
11945
|
async closeWorktree(branch) {
|
|
11523
11946
|
try {
|
|
11524
|
-
|
|
11525
|
-
this.
|
|
11526
|
-
await this.deps.reconciliation.reconcile(this.deps.projectRoot, { force: true });
|
|
11947
|
+
await this.resolveExistingWorktree(branch);
|
|
11948
|
+
await this.closeBranchWindow(branch);
|
|
11527
11949
|
} catch (error) {
|
|
11528
11950
|
throw this.wrapOperationError(error);
|
|
11529
11951
|
}
|
|
@@ -11568,6 +11990,17 @@ class LifecycleService {
|
|
|
11568
11990
|
throw this.wrapOperationError(error);
|
|
11569
11991
|
}
|
|
11570
11992
|
}
|
|
11993
|
+
async setWorktreeArchived(branch, archived) {
|
|
11994
|
+
try {
|
|
11995
|
+
const resolved = await this.resolveExistingWorktree(branch);
|
|
11996
|
+
if (archived) {
|
|
11997
|
+
await this.closeBranchWindow(branch);
|
|
11998
|
+
}
|
|
11999
|
+
await this.updateWorktreeArchivedState(resolved.entry.path, archived);
|
|
12000
|
+
} catch (error) {
|
|
12001
|
+
throw this.wrapOperationError(error);
|
|
12002
|
+
}
|
|
12003
|
+
}
|
|
11571
12004
|
listAvailableBranches(options = {}) {
|
|
11572
12005
|
const localBranches = this.listLocalBranches().filter((branch) => isValidBranchName(branch));
|
|
11573
12006
|
const remoteBranches = options.includeRemote ? this.listRemoteBranches().filter((branch) => isValidBranchName(branch)) : [];
|
|
@@ -11580,7 +12013,7 @@ class LifecycleService {
|
|
|
11580
12013
|
}
|
|
11581
12014
|
async resolveBranch(rawBranch, prompt, mode) {
|
|
11582
12015
|
const explicitBranch = rawBranch?.trim();
|
|
11583
|
-
const branch = mode === "existing" ? explicitBranch : explicitBranch || await this.generateAutoName(prompt) ||
|
|
12016
|
+
const branch = mode === "existing" ? explicitBranch : explicitBranch || await this.generateAutoName(prompt) || generateFallbackBranchName();
|
|
11584
12017
|
if (!branch) {
|
|
11585
12018
|
throw new LifecycleError("Existing branch is required", 400);
|
|
11586
12019
|
}
|
|
@@ -11652,20 +12085,20 @@ class LifecycleService {
|
|
|
11652
12085
|
return allocateServicePorts(metas, this.deps.config.services);
|
|
11653
12086
|
}
|
|
11654
12087
|
resolveWorktreePath(branch) {
|
|
11655
|
-
return
|
|
12088
|
+
return resolve7(this.deps.projectRoot, this.deps.config.workspace.worktreeRoot, branch);
|
|
11656
12089
|
}
|
|
11657
12090
|
listLocalBranches() {
|
|
11658
|
-
return this.deps.git.listLocalBranches(
|
|
12091
|
+
return this.deps.git.listLocalBranches(resolve7(this.deps.projectRoot));
|
|
11659
12092
|
}
|
|
11660
12093
|
listRemoteBranches() {
|
|
11661
|
-
return this.deps.git.listRemoteBranches(
|
|
12094
|
+
return this.deps.git.listRemoteBranches(resolve7(this.deps.projectRoot));
|
|
11662
12095
|
}
|
|
11663
12096
|
listCheckedOutBranches() {
|
|
11664
|
-
return new Set(this.deps.git.listWorktrees(
|
|
12097
|
+
return new Set(this.deps.git.listWorktrees(resolve7(this.deps.projectRoot)).filter((entry) => !entry.bare && entry.branch !== null).map((entry) => entry.branch));
|
|
11665
12098
|
}
|
|
11666
12099
|
listProjectWorktrees() {
|
|
11667
|
-
const projectRoot2 =
|
|
11668
|
-
return this.deps.git.listWorktrees(projectRoot2).filter((entry) => !entry.bare &&
|
|
12100
|
+
const projectRoot2 = resolve7(this.deps.projectRoot);
|
|
12101
|
+
return this.deps.git.listWorktrees(projectRoot2).filter((entry) => !entry.bare && resolve7(entry.path) !== projectRoot2);
|
|
11669
12102
|
}
|
|
11670
12103
|
async readManagedMetas() {
|
|
11671
12104
|
const metas = await Promise.all(this.listProjectWorktrees().map(async (entry) => {
|
|
@@ -11738,6 +12171,13 @@ class LifecycleService {
|
|
|
11738
12171
|
controlEnv
|
|
11739
12172
|
};
|
|
11740
12173
|
}
|
|
12174
|
+
async updateWorktreeArchivedState(path, archived) {
|
|
12175
|
+
await this.deps.archiveState.setArchived(path, archived);
|
|
12176
|
+
}
|
|
12177
|
+
async closeBranchWindow(branch) {
|
|
12178
|
+
this.deps.tmux.killWindow(buildProjectSessionName(this.deps.projectRoot), buildWorktreeWindowName(branch));
|
|
12179
|
+
await this.deps.reconciliation.reconcile(this.deps.projectRoot, { force: true });
|
|
12180
|
+
}
|
|
11741
12181
|
async materializeRuntimeSession(input) {
|
|
11742
12182
|
if (input.profile.runtime === "docker") {
|
|
11743
12183
|
const dockerProfile = this.requireDockerProfile(input.profile);
|
|
@@ -11865,6 +12305,7 @@ class LifecycleService {
|
|
|
11865
12305
|
deleteBranch: true,
|
|
11866
12306
|
deleteBranchForce: true
|
|
11867
12307
|
}, this.deps.git);
|
|
12308
|
+
await this.updateWorktreeArchivedState(resolved.entry.path, false);
|
|
11868
12309
|
await this.deps.reconciliation.reconcile(this.deps.projectRoot, { force: true });
|
|
11869
12310
|
}
|
|
11870
12311
|
async runLifecycleHook(input) {
|
|
@@ -12025,6 +12466,7 @@ var init_lifecycle_service = __esm(() => {
|
|
|
12025
12466
|
init_session_service();
|
|
12026
12467
|
init_worktree_service();
|
|
12027
12468
|
init_log();
|
|
12469
|
+
init_branch_name();
|
|
12028
12470
|
LifecycleError = class LifecycleError extends Error {
|
|
12029
12471
|
status;
|
|
12030
12472
|
constructor(message, status2) {
|
|
@@ -12316,9 +12758,9 @@ async function mapWithConcurrency(items, limit, fn) {
|
|
|
12316
12758
|
}
|
|
12317
12759
|
|
|
12318
12760
|
// backend/src/services/reconciliation-service.ts
|
|
12319
|
-
import { basename as basename4, resolve as
|
|
12761
|
+
import { basename as basename4, resolve as resolve8 } from "path";
|
|
12320
12762
|
function makeUnmanagedWorktreeId(path) {
|
|
12321
|
-
return `unmanaged:${
|
|
12763
|
+
return `unmanaged:${resolve8(path)}`;
|
|
12322
12764
|
}
|
|
12323
12765
|
function isValidPort2(port) {
|
|
12324
12766
|
return port !== null && Number.isInteger(port) && port >= 1 && port <= 65535;
|
|
@@ -12375,7 +12817,7 @@ class ReconciliationService {
|
|
|
12375
12817
|
if (!options.force && this.now() - this.lastReconciledAt < this.freshnessMs) {
|
|
12376
12818
|
return;
|
|
12377
12819
|
}
|
|
12378
|
-
const normalizedRepoRoot =
|
|
12820
|
+
const normalizedRepoRoot = resolve8(repoRoot);
|
|
12379
12821
|
const reconcilePromise = this.runReconcile(normalizedRepoRoot).then(() => {
|
|
12380
12822
|
this.lastReconciledAt = this.now();
|
|
12381
12823
|
});
|
|
@@ -12394,7 +12836,7 @@ class ReconciliationService {
|
|
|
12394
12836
|
windows = [];
|
|
12395
12837
|
}
|
|
12396
12838
|
const seenWorktreeIds = new Set;
|
|
12397
|
-
const candidateEntries = worktrees.filter((entry) => !entry.bare &&
|
|
12839
|
+
const candidateEntries = worktrees.filter((entry) => !entry.bare && resolve8(entry.path) !== normalizedRepoRoot);
|
|
12398
12840
|
const reconciledStates = await mapWithConcurrency(candidateEntries, this.concurrency, async (entry) => {
|
|
12399
12841
|
const gitDir = this.deps.git.resolveWorktreeGitDir(entry.path);
|
|
12400
12842
|
const meta = await readWorktreeMeta(gitDir);
|
|
@@ -12502,6 +12944,7 @@ function createWebmuxRuntime(options = {}) {
|
|
|
12502
12944
|
const projectDir = projectRoot(options.projectDir ?? Bun.env.WEBMUX_PROJECT_DIR ?? process.cwd());
|
|
12503
12945
|
const config = loadConfig(projectDir, { resolvedRoot: true });
|
|
12504
12946
|
const git = new BunGitGateway;
|
|
12947
|
+
const archiveStateService = new ArchiveStateService(git.resolveWorktreeGitDir(projectDir));
|
|
12505
12948
|
const portProbe = new BunPortProbe;
|
|
12506
12949
|
const tmux = new BunTmuxGateway;
|
|
12507
12950
|
const docker = new BunDockerGateway;
|
|
@@ -12522,6 +12965,7 @@ function createWebmuxRuntime(options = {}) {
|
|
|
12522
12965
|
controlBaseUrl: `http://127.0.0.1:${port}`,
|
|
12523
12966
|
getControlToken: loadControlToken,
|
|
12524
12967
|
config,
|
|
12968
|
+
archiveState: archiveStateService,
|
|
12525
12969
|
git,
|
|
12526
12970
|
tmux,
|
|
12527
12971
|
docker,
|
|
@@ -12540,6 +12984,7 @@ function createWebmuxRuntime(options = {}) {
|
|
|
12540
12984
|
port,
|
|
12541
12985
|
projectDir,
|
|
12542
12986
|
config,
|
|
12987
|
+
archiveStateService,
|
|
12543
12988
|
git,
|
|
12544
12989
|
portProbe,
|
|
12545
12990
|
tmux,
|
|
@@ -12561,6 +13006,7 @@ var init_runtime = __esm(() => {
|
|
|
12561
13006
|
init_hooks();
|
|
12562
13007
|
init_tmux();
|
|
12563
13008
|
init_auto_name_service();
|
|
13009
|
+
init_archive_state_service();
|
|
12564
13010
|
init_lifecycle_service();
|
|
12565
13011
|
init_project_runtime();
|
|
12566
13012
|
init_reconciliation_service();
|
|
@@ -12571,23 +13017,24 @@ var exports_worktree_commands = {};
|
|
|
12571
13017
|
__export(exports_worktree_commands, {
|
|
12572
13018
|
runWorktreeCommand: () => runWorktreeCommand,
|
|
12573
13019
|
parseSendCommandArgs: () => parseSendCommandArgs,
|
|
13020
|
+
parseListCommandArgs: () => parseListCommandArgs,
|
|
12574
13021
|
parseBranchCommandArgs: () => parseBranchCommandArgs,
|
|
12575
13022
|
parseAddCommandArgs: () => parseAddCommandArgs,
|
|
12576
13023
|
getWorktreeCommandUsage: () => getWorktreeCommandUsage
|
|
12577
13024
|
});
|
|
12578
|
-
import { basename as basename5, resolve as
|
|
13025
|
+
import { basename as basename5, resolve as resolve9 } from "path";
|
|
12579
13026
|
function getWorktreeCommandUsage(command) {
|
|
12580
13027
|
switch (command) {
|
|
12581
13028
|
case "add":
|
|
12582
13029
|
return [
|
|
12583
13030
|
"Usage:",
|
|
12584
|
-
" webmux add [branch] [--existing] [--base <branch>] [--profile <name>] [--agent <claude|codex>] [--prompt <text>] [--env KEY=VALUE] [--detach]",
|
|
13031
|
+
" webmux add [branch] [--existing] [--base <branch>] [--profile <name>] [--agent <claude|codex|both>] [--prompt <text>] [--env KEY=VALUE] [--detach]",
|
|
12585
13032
|
"",
|
|
12586
13033
|
"Options:",
|
|
12587
13034
|
" --existing Use an existing local or remote branch instead of creating a new one",
|
|
12588
13035
|
" --base <branch> Base branch for a new worktree (defaults to config)",
|
|
12589
13036
|
" --profile <name> Worktree profile from .webmux.yaml",
|
|
12590
|
-
" --agent <claude|codex>
|
|
13037
|
+
" --agent <claude|codex|both> Agent to launch (both creates paired worktrees)",
|
|
12591
13038
|
" --prompt <text> Initial agent prompt",
|
|
12592
13039
|
" --env KEY=VALUE Runtime env override (repeatable)",
|
|
12593
13040
|
" -d, --detach Create worktree without switching to it",
|
|
@@ -12595,14 +13042,29 @@ function getWorktreeCommandUsage(command) {
|
|
|
12595
13042
|
].join(`
|
|
12596
13043
|
`);
|
|
12597
13044
|
case "list":
|
|
12598
|
-
return
|
|
12599
|
-
|
|
13045
|
+
return [
|
|
13046
|
+
"Usage:",
|
|
13047
|
+
" webmux list [--all|--archived] [--search <text>]",
|
|
13048
|
+
"",
|
|
13049
|
+
"Options:",
|
|
13050
|
+
" --all Include archived worktrees",
|
|
13051
|
+
" --archived Show only archived worktrees",
|
|
13052
|
+
" --search <text> Filter worktrees by branch/profile/agent",
|
|
13053
|
+
" --help Show this help message"
|
|
13054
|
+
].join(`
|
|
13055
|
+
`);
|
|
12600
13056
|
case "open":
|
|
12601
13057
|
return `Usage:
|
|
12602
13058
|
webmux open <branch>`;
|
|
12603
13059
|
case "close":
|
|
12604
13060
|
return `Usage:
|
|
12605
13061
|
webmux close <branch>`;
|
|
13062
|
+
case "archive":
|
|
13063
|
+
return `Usage:
|
|
13064
|
+
webmux archive <branch>`;
|
|
13065
|
+
case "unarchive":
|
|
13066
|
+
return `Usage:
|
|
13067
|
+
webmux unarchive <branch>`;
|
|
12606
13068
|
case "remove":
|
|
12607
13069
|
return `Usage:
|
|
12608
13070
|
webmux remove <branch>`;
|
|
@@ -12647,7 +13109,7 @@ function readOptionValue(args, index, flag) {
|
|
|
12647
13109
|
};
|
|
12648
13110
|
}
|
|
12649
13111
|
function parseAgent(value) {
|
|
12650
|
-
if (value === "claude" || value === "codex") {
|
|
13112
|
+
if (value === "claude" || value === "codex" || value === "both") {
|
|
12651
13113
|
return value;
|
|
12652
13114
|
}
|
|
12653
13115
|
throw new CommandUsageError(`Unknown agent: ${value}`);
|
|
@@ -12801,19 +13263,53 @@ function parsePruneCommandArgs(args) {
|
|
|
12801
13263
|
}
|
|
12802
13264
|
return true;
|
|
12803
13265
|
}
|
|
13266
|
+
function parseListCommandArgs(args) {
|
|
13267
|
+
let mode = "active";
|
|
13268
|
+
let search = "";
|
|
13269
|
+
for (let index = 0;index < args.length; index++) {
|
|
13270
|
+
const arg = args[index];
|
|
13271
|
+
if (!arg)
|
|
13272
|
+
continue;
|
|
13273
|
+
if (arg === "--help" || arg === "-h") {
|
|
13274
|
+
return null;
|
|
13275
|
+
}
|
|
13276
|
+
if (arg === "--all") {
|
|
13277
|
+
if (mode === "archived") {
|
|
13278
|
+
throw new CommandUsageError("Cannot use --all with --archived");
|
|
13279
|
+
}
|
|
13280
|
+
mode = "all";
|
|
13281
|
+
continue;
|
|
13282
|
+
}
|
|
13283
|
+
if (arg === "--archived") {
|
|
13284
|
+
if (mode === "all") {
|
|
13285
|
+
throw new CommandUsageError("Cannot use --archived with --all");
|
|
13286
|
+
}
|
|
13287
|
+
mode = "archived";
|
|
13288
|
+
continue;
|
|
13289
|
+
}
|
|
13290
|
+
if (arg === "--search" || arg.startsWith("--search=")) {
|
|
13291
|
+
const { value, nextIndex } = readOptionValue(args, index, "--search");
|
|
13292
|
+
search = value;
|
|
13293
|
+
index = nextIndex;
|
|
13294
|
+
continue;
|
|
13295
|
+
}
|
|
13296
|
+
throw new CommandUsageError(`Unknown option: ${arg}`);
|
|
13297
|
+
}
|
|
13298
|
+
return { mode, search };
|
|
13299
|
+
}
|
|
12804
13300
|
function listProjectWorktrees(runtime) {
|
|
12805
|
-
const projectDir =
|
|
12806
|
-
return runtime.git.listWorktrees(projectDir).filter((entry) => !entry.bare &&
|
|
13301
|
+
const projectDir = resolve9(runtime.projectDir);
|
|
13302
|
+
return runtime.git.listWorktrees(projectDir).filter((entry) => !entry.bare && resolve9(entry.path) !== projectDir);
|
|
12807
13303
|
}
|
|
12808
13304
|
async function defaultConfirmPrune(worktreeCount) {
|
|
12809
|
-
const response = await
|
|
13305
|
+
const response = await ot2({
|
|
12810
13306
|
message: `Prune all ${worktreeCount} worktree${worktreeCount === 1 ? "" : "s"}? This action cannot be undone.`,
|
|
12811
13307
|
initialValue: false
|
|
12812
13308
|
});
|
|
12813
|
-
return !
|
|
13309
|
+
return !q(response) && response;
|
|
12814
13310
|
}
|
|
12815
13311
|
function defaultSwitchToTmuxWindow(projectDir, branch) {
|
|
12816
|
-
const sessionName = buildProjectSessionName(
|
|
13312
|
+
const sessionName = buildProjectSessionName(resolve9(projectDir));
|
|
12817
13313
|
const windowName = buildWorktreeWindowName(branch);
|
|
12818
13314
|
const target = `${sessionName}:${windowName}`;
|
|
12819
13315
|
const selectResult = Bun.spawnSync(["tmux", "select-window", "-t", target], {
|
|
@@ -12841,8 +13337,11 @@ function defaultSwitchToTmuxWindow(projectDir, branch) {
|
|
|
12841
13337
|
}
|
|
12842
13338
|
}
|
|
12843
13339
|
}
|
|
12844
|
-
|
|
12845
|
-
|
|
13340
|
+
function matchesListSearch(row, query) {
|
|
13341
|
+
return query.length === 0 || row.searchText.toLowerCase().includes(query.toLowerCase());
|
|
13342
|
+
}
|
|
13343
|
+
async function listWorktrees(runtime, stdout, options) {
|
|
13344
|
+
const projectDir = resolve9(runtime.projectDir);
|
|
12846
13345
|
const entries = listProjectWorktrees(runtime);
|
|
12847
13346
|
if (entries.length === 0) {
|
|
12848
13347
|
stdout("No worktrees found.");
|
|
@@ -12855,20 +13354,59 @@ async function listWorktrees(runtime, stdout) {
|
|
|
12855
13354
|
} catch {
|
|
12856
13355
|
windows = [];
|
|
12857
13356
|
}
|
|
12858
|
-
const openWindows = new Set(windows.filter((
|
|
13357
|
+
const openWindows = new Set(windows.filter((w3) => w3.sessionName === sessionName).map((w3) => w3.windowName));
|
|
13358
|
+
const projectGitDir = runtime.git.resolveWorktreeGitDir(projectDir);
|
|
13359
|
+
const archivedPaths = buildArchivedWorktreePathSet(await readWorktreeArchiveState(projectGitDir));
|
|
12859
13360
|
const rows = await Promise.all(entries.map(async (entry) => {
|
|
12860
13361
|
const branch = entry.branch ?? basename5(entry.path);
|
|
12861
13362
|
const isOpen = openWindows.has(buildWorktreeWindowName(branch));
|
|
12862
13363
|
const gitDir = runtime.git.resolveWorktreeGitDir(entry.path);
|
|
12863
13364
|
const meta = await readWorktreeMeta(gitDir);
|
|
12864
13365
|
const info = meta ? `${meta.profile} / ${meta.agent}` : "";
|
|
12865
|
-
return {
|
|
13366
|
+
return {
|
|
13367
|
+
branch,
|
|
13368
|
+
isOpen,
|
|
13369
|
+
archived: archivedPaths.has(resolve9(entry.path)),
|
|
13370
|
+
info,
|
|
13371
|
+
searchText: [
|
|
13372
|
+
branch,
|
|
13373
|
+
meta?.baseBranch ?? "",
|
|
13374
|
+
meta?.profile ?? "",
|
|
13375
|
+
meta?.agent ?? ""
|
|
13376
|
+
].join(" ")
|
|
13377
|
+
};
|
|
12866
13378
|
}));
|
|
12867
|
-
rows.sort((a, b) => a.branch.localeCompare(b.branch));
|
|
12868
|
-
const
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
13379
|
+
const matchingRows = rows.filter((row) => matchesListSearch(row, options.search.trim())).sort((a, b) => a.branch.localeCompare(b.branch));
|
|
13380
|
+
const visibleRows = matchingRows.filter((row) => {
|
|
13381
|
+
if (options.mode === "all")
|
|
13382
|
+
return true;
|
|
13383
|
+
if (options.mode === "archived")
|
|
13384
|
+
return row.archived;
|
|
13385
|
+
return !row.archived;
|
|
13386
|
+
});
|
|
13387
|
+
if (visibleRows.length === 0) {
|
|
13388
|
+
const hiddenArchivedCount = options.mode === "active" ? matchingRows.filter((row) => row.archived).length : 0;
|
|
13389
|
+
if (hiddenArchivedCount > 0) {
|
|
13390
|
+
stdout(`No active worktrees found. ${hiddenArchivedCount} archived worktree${hiddenArchivedCount === 1 ? "" : "s"} hidden. Use --all or --archived.`);
|
|
13391
|
+
return;
|
|
13392
|
+
}
|
|
13393
|
+
if (options.mode === "archived") {
|
|
13394
|
+
stdout("No archived worktrees found.");
|
|
13395
|
+
return;
|
|
13396
|
+
}
|
|
13397
|
+
stdout(options.search.trim() ? `No worktrees found for "${options.search.trim()}".` : "No worktrees found.");
|
|
13398
|
+
return;
|
|
13399
|
+
}
|
|
13400
|
+
const maxBranch = Math.max(...visibleRows.map((row) => row.branch.length));
|
|
13401
|
+
for (const row of visibleRows) {
|
|
13402
|
+
const status2 = `${row.isOpen ? "open" : "closed"}${row.archived ? " archived" : ""}`;
|
|
13403
|
+
stdout(`${row.branch.padEnd(maxBranch + 2)} ${status2.padEnd(15)} ${row.info}`.trimEnd());
|
|
13404
|
+
}
|
|
13405
|
+
if (options.mode === "active") {
|
|
13406
|
+
const hiddenArchivedCount = matchingRows.filter((row) => row.archived).length;
|
|
13407
|
+
if (hiddenArchivedCount > 0) {
|
|
13408
|
+
stdout(`Hidden ${hiddenArchivedCount} archived worktree${hiddenArchivedCount === 1 ? "" : "s"}. Use --all or --archived.`);
|
|
13409
|
+
}
|
|
12872
13410
|
}
|
|
12873
13411
|
}
|
|
12874
13412
|
async function runWorktreeCommand(context, deps2 = {}) {
|
|
@@ -12894,15 +13432,27 @@ async function runWorktreeCommand(context, deps2 = {}) {
|
|
|
12894
13432
|
if (!parsed.input.branch && parsed.input.prompt && runtime2.config.autoName) {
|
|
12895
13433
|
stdout("Generating branch name...");
|
|
12896
13434
|
}
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
13435
|
+
if (parsed.input.agent === "both") {
|
|
13436
|
+
const result = await runtime2.lifecycleService.createWorktrees(parsed.input);
|
|
13437
|
+
for (const branch2 of result.branches) {
|
|
13438
|
+
stdout(`Created worktree ${branch2}`);
|
|
13439
|
+
}
|
|
13440
|
+
if (!parsed.detach) {
|
|
13441
|
+
switchToTmuxWindow(runtime2.projectDir, result.primaryBranch);
|
|
13442
|
+
}
|
|
13443
|
+
} else {
|
|
13444
|
+
const { agent, ...rest } = parsed.input;
|
|
13445
|
+
const result = await runtime2.lifecycleService.createWorktree({ ...rest, agent });
|
|
13446
|
+
stdout(`Created worktree ${result.branch}`);
|
|
13447
|
+
if (!parsed.detach) {
|
|
13448
|
+
switchToTmuxWindow(runtime2.projectDir, result.branch);
|
|
13449
|
+
}
|
|
12901
13450
|
}
|
|
12902
13451
|
return 0;
|
|
12903
13452
|
}
|
|
12904
13453
|
if (context.command === "list") {
|
|
12905
|
-
|
|
13454
|
+
const parsed = parseListCommandArgs(context.args);
|
|
13455
|
+
if (!parsed) {
|
|
12906
13456
|
stdout(getWorktreeCommandUsage("list"));
|
|
12907
13457
|
return 0;
|
|
12908
13458
|
}
|
|
@@ -12910,7 +13460,7 @@ async function runWorktreeCommand(context, deps2 = {}) {
|
|
|
12910
13460
|
projectDir: context.projectDir,
|
|
12911
13461
|
port: context.port
|
|
12912
13462
|
});
|
|
12913
|
-
await listWorktrees(runtime2, stdout);
|
|
13463
|
+
await listWorktrees(runtime2, stdout, parsed);
|
|
12914
13464
|
return 0;
|
|
12915
13465
|
}
|
|
12916
13466
|
if (context.command === "prune") {
|
|
@@ -12992,6 +13542,14 @@ async function runWorktreeCommand(context, deps2 = {}) {
|
|
|
12992
13542
|
await runtime.lifecycleService.closeWorktree(branch);
|
|
12993
13543
|
stdout(`Closed worktree ${branch}`);
|
|
12994
13544
|
return 0;
|
|
13545
|
+
case "archive":
|
|
13546
|
+
await runtime.lifecycleService.setWorktreeArchived(branch, true);
|
|
13547
|
+
stdout(`Archived worktree ${branch}`);
|
|
13548
|
+
return 0;
|
|
13549
|
+
case "unarchive":
|
|
13550
|
+
await runtime.lifecycleService.setWorktreeArchived(branch, false);
|
|
13551
|
+
stdout(`Restored worktree ${branch}`);
|
|
13552
|
+
return 0;
|
|
12995
13553
|
case "remove":
|
|
12996
13554
|
await runtime.lifecycleService.removeWorktree(branch);
|
|
12997
13555
|
stdout(`Removed worktree ${branch}`);
|
|
@@ -13008,10 +13566,11 @@ async function runWorktreeCommand(context, deps2 = {}) {
|
|
|
13008
13566
|
}
|
|
13009
13567
|
var PHASE_LABELS, CommandUsageError;
|
|
13010
13568
|
var init_worktree_commands = __esm(() => {
|
|
13011
|
-
|
|
13569
|
+
init_dist4();
|
|
13012
13570
|
init_fs();
|
|
13013
13571
|
init_tmux();
|
|
13014
13572
|
init_policies();
|
|
13573
|
+
init_archive_service();
|
|
13015
13574
|
init_runtime();
|
|
13016
13575
|
PHASE_LABELS = {
|
|
13017
13576
|
creating_worktree: "Creating worktree",
|
|
@@ -13025,13 +13584,13 @@ var init_worktree_commands = __esm(() => {
|
|
|
13025
13584
|
});
|
|
13026
13585
|
|
|
13027
13586
|
// bin/src/webmux.ts
|
|
13028
|
-
import { resolve as
|
|
13587
|
+
import { resolve as resolve10, dirname as dirname6, join as join11 } from "path";
|
|
13029
13588
|
import { existsSync as existsSync5 } from "fs";
|
|
13030
13589
|
import { fileURLToPath } from "url";
|
|
13031
13590
|
// package.json
|
|
13032
13591
|
var package_default = {
|
|
13033
13592
|
name: "webmux",
|
|
13034
|
-
version: "0.
|
|
13593
|
+
version: "0.27.0",
|
|
13035
13594
|
description: "Web dashboard for workmux \u2014 browser UI with embedded terminals, PR monitoring, and CI integration",
|
|
13036
13595
|
type: "module",
|
|
13037
13596
|
repository: {
|
|
@@ -13085,7 +13644,7 @@ var package_default = {
|
|
|
13085
13644
|
};
|
|
13086
13645
|
|
|
13087
13646
|
// bin/src/webmux.ts
|
|
13088
|
-
var PKG_ROOT =
|
|
13647
|
+
var PKG_ROOT = resolve10(dirname6(fileURLToPath(import.meta.url)), "..");
|
|
13089
13648
|
function usage2() {
|
|
13090
13649
|
console.log(`
|
|
13091
13650
|
webmux \u2014 Dev dashboard for managing Git worktrees
|
|
@@ -13099,6 +13658,8 @@ Usage:
|
|
|
13099
13658
|
webmux list List worktrees and their status
|
|
13100
13659
|
webmux open Open an existing worktree session
|
|
13101
13660
|
webmux close Close a worktree session without removing it
|
|
13661
|
+
webmux archive Hide a worktree from the default list
|
|
13662
|
+
webmux unarchive Show an archived worktree again
|
|
13102
13663
|
webmux remove Remove a worktree
|
|
13103
13664
|
webmux merge Merge a worktree into the main branch and remove it
|
|
13104
13665
|
webmux send Send a prompt to a running worktree agent
|
|
@@ -13117,7 +13678,7 @@ Environment:
|
|
|
13117
13678
|
`);
|
|
13118
13679
|
}
|
|
13119
13680
|
function isRootCommand(value) {
|
|
13120
|
-
return value === "serve" || value === "init" || value === "service" || value === "update" || value === "add" || value === "list" || value === "open" || value === "close" || value === "remove" || value === "merge" || value === "send" || value === "prune" || value === "completion";
|
|
13681
|
+
return value === "serve" || value === "init" || value === "service" || value === "update" || value === "add" || value === "list" || value === "open" || value === "close" || value === "archive" || value === "unarchive" || value === "remove" || value === "merge" || value === "send" || value === "prune" || value === "completion";
|
|
13121
13682
|
}
|
|
13122
13683
|
function isServeRootOption(value) {
|
|
13123
13684
|
return value === "--port" || value === "--app" || value === "--debug" || value === "--help" || value === "-h" || value === "--version" || value === "-V";
|
|
@@ -13181,7 +13742,7 @@ Run webmux --help for usage.`);
|
|
|
13181
13742
|
};
|
|
13182
13743
|
}
|
|
13183
13744
|
function isWorktreeCommand(command) {
|
|
13184
|
-
return command === "add" || command === "list" || command === "open" || command === "close" || command === "remove" || command === "merge" || command === "send" || command === "prune";
|
|
13745
|
+
return command === "add" || command === "list" || command === "open" || command === "close" || command === "archive" || command === "unarchive" || command === "remove" || command === "merge" || command === "send" || command === "prune";
|
|
13185
13746
|
}
|
|
13186
13747
|
async function loadEnvFile(path) {
|
|
13187
13748
|
if (!existsSync5(path))
|
|
@@ -13298,8 +13859,8 @@ async function main(args = process.argv.slice(2)) {
|
|
|
13298
13859
|
const code = await proc.exited;
|
|
13299
13860
|
process.exit(code);
|
|
13300
13861
|
}
|
|
13301
|
-
await loadEnvFile(
|
|
13302
|
-
await loadEnvFile(
|
|
13862
|
+
await loadEnvFile(resolve10(process.cwd(), ".env.local"));
|
|
13863
|
+
await loadEnvFile(resolve10(process.cwd(), ".env"));
|
|
13303
13864
|
if (isWorktreeCommand(parsed.command)) {
|
|
13304
13865
|
const { runWorktreeCommand: runWorktreeCommand2 } = await Promise.resolve().then(() => (init_worktree_commands(), exports_worktree_commands));
|
|
13305
13866
|
const exitCode = await runWorktreeCommand2({
|
|
@@ -13314,7 +13875,7 @@ async function main(args = process.argv.slice(2)) {
|
|
|
13314
13875
|
usage2();
|
|
13315
13876
|
process.exit(0);
|
|
13316
13877
|
}
|
|
13317
|
-
if (!existsSync5(
|
|
13878
|
+
if (!existsSync5(resolve10(process.cwd(), ".webmux.yaml"))) {
|
|
13318
13879
|
console.error("No .webmux.yaml found in this directory.\nRun `webmux init` to set up your project.");
|
|
13319
13880
|
process.exit(1);
|
|
13320
13881
|
}
|