oh-my-opencode 2.1.4 → 2.1.5
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.ja.md +33 -18
- package/README.ko.md +42 -27
- package/README.md +59 -23
- package/dist/index.js +222 -217
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -205,19 +205,19 @@ var require_utils = __commonJS((exports) => {
|
|
|
205
205
|
return exports.escapeLast(input, char, idx - 1);
|
|
206
206
|
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
207
207
|
};
|
|
208
|
-
exports.removePrefix = (input,
|
|
208
|
+
exports.removePrefix = (input, state2 = {}) => {
|
|
209
209
|
let output = input;
|
|
210
210
|
if (output.startsWith("./")) {
|
|
211
211
|
output = output.slice(2);
|
|
212
|
-
|
|
212
|
+
state2.prefix = "./";
|
|
213
213
|
}
|
|
214
214
|
return output;
|
|
215
215
|
};
|
|
216
|
-
exports.wrapOutput = (input,
|
|
216
|
+
exports.wrapOutput = (input, state2 = {}, options = {}) => {
|
|
217
217
|
const prepend = options.contains ? "" : "^";
|
|
218
218
|
const append = options.contains ? "" : "$";
|
|
219
219
|
let output = `${prepend}(?:${input})${append}`;
|
|
220
|
-
if (
|
|
220
|
+
if (state2.negated === true) {
|
|
221
221
|
output = `(?:^(?!${output}).*$)`;
|
|
222
222
|
}
|
|
223
223
|
return output;
|
|
@@ -488,7 +488,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
488
488
|
base = utils.removeBackslashes(base);
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
-
const
|
|
491
|
+
const state2 = {
|
|
492
492
|
prefix,
|
|
493
493
|
input,
|
|
494
494
|
start,
|
|
@@ -503,11 +503,11 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
503
503
|
negatedExtglob
|
|
504
504
|
};
|
|
505
505
|
if (opts.tokens === true) {
|
|
506
|
-
|
|
506
|
+
state2.maxDepth = 0;
|
|
507
507
|
if (!isPathSeparator(code)) {
|
|
508
508
|
tokens.push(token);
|
|
509
509
|
}
|
|
510
|
-
|
|
510
|
+
state2.tokens = tokens;
|
|
511
511
|
}
|
|
512
512
|
if (opts.parts === true || opts.tokens === true) {
|
|
513
513
|
let prevIndex;
|
|
@@ -523,7 +523,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
523
523
|
tokens[idx].value = value;
|
|
524
524
|
}
|
|
525
525
|
depth(tokens[idx]);
|
|
526
|
-
|
|
526
|
+
state2.maxDepth += tokens[idx].depth;
|
|
527
527
|
}
|
|
528
528
|
if (idx !== 0 || value !== "") {
|
|
529
529
|
parts.push(value);
|
|
@@ -536,13 +536,13 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
536
536
|
if (opts.tokens) {
|
|
537
537
|
tokens[tokens.length - 1].value = value;
|
|
538
538
|
depth(tokens[tokens.length - 1]);
|
|
539
|
-
|
|
539
|
+
state2.maxDepth += tokens[tokens.length - 1].depth;
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
-
|
|
543
|
-
|
|
542
|
+
state2.slashes = slashes;
|
|
543
|
+
state2.parts = parts;
|
|
544
544
|
}
|
|
545
|
-
return
|
|
545
|
+
return state2;
|
|
546
546
|
};
|
|
547
547
|
module.exports = scan;
|
|
548
548
|
});
|
|
@@ -616,7 +616,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
616
616
|
if (typeof opts.noext === "boolean") {
|
|
617
617
|
opts.noextglob = opts.noext;
|
|
618
618
|
}
|
|
619
|
-
const
|
|
619
|
+
const state2 = {
|
|
620
620
|
input,
|
|
621
621
|
index: -1,
|
|
622
622
|
start: 0,
|
|
@@ -633,57 +633,57 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
633
633
|
globstar: false,
|
|
634
634
|
tokens
|
|
635
635
|
};
|
|
636
|
-
input = utils.removePrefix(input,
|
|
636
|
+
input = utils.removePrefix(input, state2);
|
|
637
637
|
len = input.length;
|
|
638
638
|
const extglobs = [];
|
|
639
639
|
const braces = [];
|
|
640
640
|
const stack = [];
|
|
641
641
|
let prev = bos;
|
|
642
642
|
let value;
|
|
643
|
-
const eos = () =>
|
|
644
|
-
const peek =
|
|
645
|
-
const advance =
|
|
646
|
-
const remaining = () => input.slice(
|
|
643
|
+
const eos = () => state2.index === len - 1;
|
|
644
|
+
const peek = state2.peek = (n = 1) => input[state2.index + n];
|
|
645
|
+
const advance = state2.advance = () => input[++state2.index] || "";
|
|
646
|
+
const remaining = () => input.slice(state2.index + 1);
|
|
647
647
|
const consume = (value2 = "", num = 0) => {
|
|
648
|
-
|
|
649
|
-
|
|
648
|
+
state2.consumed += value2;
|
|
649
|
+
state2.index += num;
|
|
650
650
|
};
|
|
651
651
|
const append = (token) => {
|
|
652
|
-
|
|
652
|
+
state2.output += token.output != null ? token.output : token.value;
|
|
653
653
|
consume(token.value);
|
|
654
654
|
};
|
|
655
655
|
const negate = () => {
|
|
656
656
|
let count = 1;
|
|
657
657
|
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
658
658
|
advance();
|
|
659
|
-
|
|
659
|
+
state2.start++;
|
|
660
660
|
count++;
|
|
661
661
|
}
|
|
662
662
|
if (count % 2 === 0) {
|
|
663
663
|
return false;
|
|
664
664
|
}
|
|
665
|
-
|
|
666
|
-
|
|
665
|
+
state2.negated = true;
|
|
666
|
+
state2.start++;
|
|
667
667
|
return true;
|
|
668
668
|
};
|
|
669
669
|
const increment = (type) => {
|
|
670
|
-
|
|
670
|
+
state2[type]++;
|
|
671
671
|
stack.push(type);
|
|
672
672
|
};
|
|
673
673
|
const decrement = (type) => {
|
|
674
|
-
|
|
674
|
+
state2[type]--;
|
|
675
675
|
stack.pop();
|
|
676
676
|
};
|
|
677
677
|
const push = (tok) => {
|
|
678
678
|
if (prev.type === "globstar") {
|
|
679
|
-
const isBrace =
|
|
679
|
+
const isBrace = state2.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
680
680
|
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
681
681
|
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
682
|
-
|
|
682
|
+
state2.output = state2.output.slice(0, -prev.output.length);
|
|
683
683
|
prev.type = "star";
|
|
684
684
|
prev.value = "*";
|
|
685
685
|
prev.output = star;
|
|
686
|
-
|
|
686
|
+
state2.output += prev.output;
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
689
|
if (extglobs.length && tok.type !== "paren") {
|
|
@@ -703,11 +703,11 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
703
703
|
const extglobOpen = (type, value2) => {
|
|
704
704
|
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
705
705
|
token.prev = prev;
|
|
706
|
-
token.parens =
|
|
707
|
-
token.output =
|
|
706
|
+
token.parens = state2.parens;
|
|
707
|
+
token.output = state2.output;
|
|
708
708
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
709
709
|
increment("parens");
|
|
710
|
-
push({ type, value: value2, output:
|
|
710
|
+
push({ type, value: value2, output: state2.output ? "" : ONE_CHAR });
|
|
711
711
|
push({ type: "paren", extglob: true, value: advance(), output });
|
|
712
712
|
extglobs.push(token);
|
|
713
713
|
};
|
|
@@ -727,7 +727,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
727
727
|
output = token.close = `)${expression})${extglobStar})`;
|
|
728
728
|
}
|
|
729
729
|
if (token.prev.type === "bos") {
|
|
730
|
-
|
|
730
|
+
state2.negatedExtglob = true;
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
push({ type: "paren", extglob: true, value, output });
|
|
@@ -770,11 +770,11 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
772
|
if (output === input && opts.contains === true) {
|
|
773
|
-
|
|
774
|
-
return
|
|
773
|
+
state2.output = input;
|
|
774
|
+
return state2;
|
|
775
775
|
}
|
|
776
|
-
|
|
777
|
-
return
|
|
776
|
+
state2.output = utils.wrapOutput(output, state2, options);
|
|
777
|
+
return state2;
|
|
778
778
|
}
|
|
779
779
|
while (!eos()) {
|
|
780
780
|
value = advance();
|
|
@@ -798,7 +798,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
798
798
|
let slashes = 0;
|
|
799
799
|
if (match && match[0].length > 2) {
|
|
800
800
|
slashes = match[0].length;
|
|
801
|
-
|
|
801
|
+
state2.index += slashes;
|
|
802
802
|
if (slashes % 2 !== 0) {
|
|
803
803
|
value += "\\";
|
|
804
804
|
}
|
|
@@ -808,12 +808,12 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
808
808
|
} else {
|
|
809
809
|
value += advance();
|
|
810
810
|
}
|
|
811
|
-
if (
|
|
811
|
+
if (state2.brackets === 0) {
|
|
812
812
|
push({ type: "text", value });
|
|
813
813
|
continue;
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
|
-
if (
|
|
816
|
+
if (state2.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
817
817
|
if (opts.posix !== false && value === ":") {
|
|
818
818
|
const inner = prev.value.slice(1);
|
|
819
819
|
if (inner.includes("[")) {
|
|
@@ -825,7 +825,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
825
825
|
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
826
826
|
if (posix) {
|
|
827
827
|
prev.value = pre + posix;
|
|
828
|
-
|
|
828
|
+
state2.backtrack = true;
|
|
829
829
|
advance();
|
|
830
830
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
831
831
|
bos.output = ONE_CHAR;
|
|
@@ -848,14 +848,14 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
848
848
|
append({ value });
|
|
849
849
|
continue;
|
|
850
850
|
}
|
|
851
|
-
if (
|
|
851
|
+
if (state2.quotes === 1 && value !== '"') {
|
|
852
852
|
value = utils.escapeRegex(value);
|
|
853
853
|
prev.value += value;
|
|
854
854
|
append({ value });
|
|
855
855
|
continue;
|
|
856
856
|
}
|
|
857
857
|
if (value === '"') {
|
|
858
|
-
|
|
858
|
+
state2.quotes = state2.quotes === 1 ? 0 : 1;
|
|
859
859
|
if (opts.keepQuotes === true) {
|
|
860
860
|
push({ type: "text", value });
|
|
861
861
|
}
|
|
@@ -867,15 +867,15 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
867
867
|
continue;
|
|
868
868
|
}
|
|
869
869
|
if (value === ")") {
|
|
870
|
-
if (
|
|
870
|
+
if (state2.parens === 0 && opts.strictBrackets === true) {
|
|
871
871
|
throw new SyntaxError(syntaxError("opening", "("));
|
|
872
872
|
}
|
|
873
873
|
const extglob = extglobs[extglobs.length - 1];
|
|
874
|
-
if (extglob &&
|
|
874
|
+
if (extglob && state2.parens === extglob.parens + 1) {
|
|
875
875
|
extglobClose(extglobs.pop());
|
|
876
876
|
continue;
|
|
877
877
|
}
|
|
878
|
-
push({ type: "paren", value, output:
|
|
878
|
+
push({ type: "paren", value, output: state2.parens ? ")" : "\\)" });
|
|
879
879
|
decrement("parens");
|
|
880
880
|
continue;
|
|
881
881
|
}
|
|
@@ -896,7 +896,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
896
896
|
push({ type: "text", value, output: `\\${value}` });
|
|
897
897
|
continue;
|
|
898
898
|
}
|
|
899
|
-
if (
|
|
899
|
+
if (state2.brackets === 0) {
|
|
900
900
|
if (opts.strictBrackets === true) {
|
|
901
901
|
throw new SyntaxError(syntaxError("opening", "["));
|
|
902
902
|
}
|
|
@@ -914,14 +914,14 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
914
914
|
continue;
|
|
915
915
|
}
|
|
916
916
|
const escaped = utils.escapeRegex(prev.value);
|
|
917
|
-
|
|
917
|
+
state2.output = state2.output.slice(0, -prev.value.length);
|
|
918
918
|
if (opts.literalBrackets === true) {
|
|
919
|
-
|
|
919
|
+
state2.output += escaped;
|
|
920
920
|
prev.value = escaped;
|
|
921
921
|
continue;
|
|
922
922
|
}
|
|
923
923
|
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
924
|
-
|
|
924
|
+
state2.output += prev.value;
|
|
925
925
|
continue;
|
|
926
926
|
}
|
|
927
927
|
if (value === "{" && opts.nobrace !== true) {
|
|
@@ -930,8 +930,8 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
930
930
|
type: "brace",
|
|
931
931
|
value,
|
|
932
932
|
output: "(",
|
|
933
|
-
outputIndex:
|
|
934
|
-
tokensIndex:
|
|
933
|
+
outputIndex: state2.output.length,
|
|
934
|
+
tokensIndex: state2.tokens.length
|
|
935
935
|
};
|
|
936
936
|
braces.push(open);
|
|
937
937
|
push(open);
|
|
@@ -957,16 +957,16 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
output = expandRange(range, opts);
|
|
960
|
-
|
|
960
|
+
state2.backtrack = true;
|
|
961
961
|
}
|
|
962
962
|
if (brace.comma !== true && brace.dots !== true) {
|
|
963
|
-
const out =
|
|
964
|
-
const toks =
|
|
963
|
+
const out = state2.output.slice(0, brace.outputIndex);
|
|
964
|
+
const toks = state2.tokens.slice(brace.tokensIndex);
|
|
965
965
|
brace.value = brace.output = "\\{";
|
|
966
966
|
value = output = "\\}";
|
|
967
|
-
|
|
967
|
+
state2.output = out;
|
|
968
968
|
for (const t of toks) {
|
|
969
|
-
|
|
969
|
+
state2.output += t.output || t.value;
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
972
|
push({ type: "brace", value, output });
|
|
@@ -992,10 +992,10 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
992
992
|
continue;
|
|
993
993
|
}
|
|
994
994
|
if (value === "/") {
|
|
995
|
-
if (prev.type === "dot" &&
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
995
|
+
if (prev.type === "dot" && state2.index === state2.start + 1) {
|
|
996
|
+
state2.start = state2.index + 1;
|
|
997
|
+
state2.consumed = "";
|
|
998
|
+
state2.output = "";
|
|
999
999
|
tokens.pop();
|
|
1000
1000
|
prev = bos;
|
|
1001
1001
|
continue;
|
|
@@ -1004,7 +1004,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1004
1004
|
continue;
|
|
1005
1005
|
}
|
|
1006
1006
|
if (value === ".") {
|
|
1007
|
-
if (
|
|
1007
|
+
if (state2.braces > 0 && prev.type === "dot") {
|
|
1008
1008
|
if (prev.value === ".")
|
|
1009
1009
|
prev.output = DOT_LITERAL;
|
|
1010
1010
|
const brace = braces[braces.length - 1];
|
|
@@ -1014,7 +1014,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1014
1014
|
brace.dots = true;
|
|
1015
1015
|
continue;
|
|
1016
1016
|
}
|
|
1017
|
-
if (
|
|
1017
|
+
if (state2.braces + state2.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1018
1018
|
push({ type: "text", value, output: DOT_LITERAL });
|
|
1019
1019
|
continue;
|
|
1020
1020
|
}
|
|
@@ -1050,7 +1050,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1050
1050
|
continue;
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
|
-
if (opts.nonegate !== true &&
|
|
1053
|
+
if (opts.nonegate !== true && state2.index === 0) {
|
|
1054
1054
|
negate();
|
|
1055
1055
|
continue;
|
|
1056
1056
|
}
|
|
@@ -1064,7 +1064,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1064
1064
|
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1065
1065
|
continue;
|
|
1066
1066
|
}
|
|
1067
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") ||
|
|
1067
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state2.parens > 0) {
|
|
1068
1068
|
push({ type: "plus", value });
|
|
1069
1069
|
continue;
|
|
1070
1070
|
}
|
|
@@ -1086,7 +1086,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1086
1086
|
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1087
1087
|
if (match) {
|
|
1088
1088
|
value += match[0];
|
|
1089
|
-
|
|
1089
|
+
state2.index += match[0].length;
|
|
1090
1090
|
}
|
|
1091
1091
|
push({ type: "text", value });
|
|
1092
1092
|
continue;
|
|
@@ -1096,8 +1096,8 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1096
1096
|
prev.star = true;
|
|
1097
1097
|
prev.value += value;
|
|
1098
1098
|
prev.output = star;
|
|
1099
|
-
|
|
1100
|
-
|
|
1099
|
+
state2.backtrack = true;
|
|
1100
|
+
state2.globstar = true;
|
|
1101
1101
|
consume(value);
|
|
1102
1102
|
continue;
|
|
1103
1103
|
}
|
|
@@ -1119,14 +1119,14 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1119
1119
|
push({ type: "star", value, output: "" });
|
|
1120
1120
|
continue;
|
|
1121
1121
|
}
|
|
1122
|
-
const isBrace =
|
|
1122
|
+
const isBrace = state2.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1123
1123
|
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1124
1124
|
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1125
1125
|
push({ type: "star", value, output: "" });
|
|
1126
1126
|
continue;
|
|
1127
1127
|
}
|
|
1128
1128
|
while (rest.slice(0, 3) === "/**") {
|
|
1129
|
-
const after = input[
|
|
1129
|
+
const after = input[state2.index + 4];
|
|
1130
1130
|
if (after && after !== "/") {
|
|
1131
1131
|
break;
|
|
1132
1132
|
}
|
|
@@ -1137,31 +1137,31 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1137
1137
|
prev.type = "globstar";
|
|
1138
1138
|
prev.value += value;
|
|
1139
1139
|
prev.output = globstar(opts);
|
|
1140
|
-
|
|
1141
|
-
|
|
1140
|
+
state2.output = prev.output;
|
|
1141
|
+
state2.globstar = true;
|
|
1142
1142
|
consume(value);
|
|
1143
1143
|
continue;
|
|
1144
1144
|
}
|
|
1145
1145
|
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1146
|
-
|
|
1146
|
+
state2.output = state2.output.slice(0, -(prior.output + prev.output).length);
|
|
1147
1147
|
prior.output = `(?:${prior.output}`;
|
|
1148
1148
|
prev.type = "globstar";
|
|
1149
1149
|
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1150
1150
|
prev.value += value;
|
|
1151
|
-
|
|
1152
|
-
|
|
1151
|
+
state2.globstar = true;
|
|
1152
|
+
state2.output += prior.output + prev.output;
|
|
1153
1153
|
consume(value);
|
|
1154
1154
|
continue;
|
|
1155
1155
|
}
|
|
1156
1156
|
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1157
1157
|
const end = rest[1] !== undefined ? "|$" : "";
|
|
1158
|
-
|
|
1158
|
+
state2.output = state2.output.slice(0, -(prior.output + prev.output).length);
|
|
1159
1159
|
prior.output = `(?:${prior.output}`;
|
|
1160
1160
|
prev.type = "globstar";
|
|
1161
1161
|
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1162
1162
|
prev.value += value;
|
|
1163
|
-
|
|
1164
|
-
|
|
1163
|
+
state2.output += prior.output + prev.output;
|
|
1164
|
+
state2.globstar = true;
|
|
1165
1165
|
consume(value + advance());
|
|
1166
1166
|
push({ type: "slash", value: "/", output: "" });
|
|
1167
1167
|
continue;
|
|
@@ -1170,18 +1170,18 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1170
1170
|
prev.type = "globstar";
|
|
1171
1171
|
prev.value += value;
|
|
1172
1172
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1173
|
-
|
|
1174
|
-
|
|
1173
|
+
state2.output = prev.output;
|
|
1174
|
+
state2.globstar = true;
|
|
1175
1175
|
consume(value + advance());
|
|
1176
1176
|
push({ type: "slash", value: "/", output: "" });
|
|
1177
1177
|
continue;
|
|
1178
1178
|
}
|
|
1179
|
-
|
|
1179
|
+
state2.output = state2.output.slice(0, -prev.output.length);
|
|
1180
1180
|
prev.type = "globstar";
|
|
1181
1181
|
prev.output = globstar(opts);
|
|
1182
1182
|
prev.value += value;
|
|
1183
|
-
|
|
1184
|
-
|
|
1183
|
+
state2.output += prev.output;
|
|
1184
|
+
state2.globstar = true;
|
|
1185
1185
|
consume(value);
|
|
1186
1186
|
continue;
|
|
1187
1187
|
}
|
|
@@ -1199,55 +1199,55 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1199
1199
|
push(token);
|
|
1200
1200
|
continue;
|
|
1201
1201
|
}
|
|
1202
|
-
if (
|
|
1202
|
+
if (state2.index === state2.start || prev.type === "slash" || prev.type === "dot") {
|
|
1203
1203
|
if (prev.type === "dot") {
|
|
1204
|
-
|
|
1204
|
+
state2.output += NO_DOT_SLASH;
|
|
1205
1205
|
prev.output += NO_DOT_SLASH;
|
|
1206
1206
|
} else if (opts.dot === true) {
|
|
1207
|
-
|
|
1207
|
+
state2.output += NO_DOTS_SLASH;
|
|
1208
1208
|
prev.output += NO_DOTS_SLASH;
|
|
1209
1209
|
} else {
|
|
1210
|
-
|
|
1210
|
+
state2.output += nodot;
|
|
1211
1211
|
prev.output += nodot;
|
|
1212
1212
|
}
|
|
1213
1213
|
if (peek() !== "*") {
|
|
1214
|
-
|
|
1214
|
+
state2.output += ONE_CHAR;
|
|
1215
1215
|
prev.output += ONE_CHAR;
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
1218
1218
|
push(token);
|
|
1219
1219
|
}
|
|
1220
|
-
while (
|
|
1220
|
+
while (state2.brackets > 0) {
|
|
1221
1221
|
if (opts.strictBrackets === true)
|
|
1222
1222
|
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1223
|
-
|
|
1223
|
+
state2.output = utils.escapeLast(state2.output, "[");
|
|
1224
1224
|
decrement("brackets");
|
|
1225
1225
|
}
|
|
1226
|
-
while (
|
|
1226
|
+
while (state2.parens > 0) {
|
|
1227
1227
|
if (opts.strictBrackets === true)
|
|
1228
1228
|
throw new SyntaxError(syntaxError("closing", ")"));
|
|
1229
|
-
|
|
1229
|
+
state2.output = utils.escapeLast(state2.output, "(");
|
|
1230
1230
|
decrement("parens");
|
|
1231
1231
|
}
|
|
1232
|
-
while (
|
|
1232
|
+
while (state2.braces > 0) {
|
|
1233
1233
|
if (opts.strictBrackets === true)
|
|
1234
1234
|
throw new SyntaxError(syntaxError("closing", "}"));
|
|
1235
|
-
|
|
1235
|
+
state2.output = utils.escapeLast(state2.output, "{");
|
|
1236
1236
|
decrement("braces");
|
|
1237
1237
|
}
|
|
1238
1238
|
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1239
1239
|
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1240
1240
|
}
|
|
1241
|
-
if (
|
|
1242
|
-
|
|
1243
|
-
for (const token of
|
|
1244
|
-
|
|
1241
|
+
if (state2.backtrack === true) {
|
|
1242
|
+
state2.output = "";
|
|
1243
|
+
for (const token of state2.tokens) {
|
|
1244
|
+
state2.output += token.output != null ? token.output : token.value;
|
|
1245
1245
|
if (token.suffix) {
|
|
1246
|
-
|
|
1246
|
+
state2.output += token.suffix;
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
1249
|
}
|
|
1250
|
-
return
|
|
1250
|
+
return state2;
|
|
1251
1251
|
};
|
|
1252
1252
|
parse.fastpaths = (input, options) => {
|
|
1253
1253
|
const opts = { ...options };
|
|
@@ -1271,7 +1271,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1271
1271
|
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1272
1272
|
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1273
1273
|
const capture = opts.capture ? "" : "?:";
|
|
1274
|
-
const
|
|
1274
|
+
const state2 = { negated: false, prefix: "" };
|
|
1275
1275
|
let star = opts.bash === true ? ".*?" : STAR;
|
|
1276
1276
|
if (opts.capture) {
|
|
1277
1277
|
star = `(${star})`;
|
|
@@ -1310,7 +1310,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
1310
1310
|
}
|
|
1311
1311
|
}
|
|
1312
1312
|
};
|
|
1313
|
-
const output = utils.removePrefix(input,
|
|
1313
|
+
const output = utils.removePrefix(input, state2);
|
|
1314
1314
|
let source = create(output);
|
|
1315
1315
|
if (source && opts.strictSlashes !== true) {
|
|
1316
1316
|
source += `${SLASH_LITERAL}?`;
|
|
@@ -1332,9 +1332,9 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
1332
1332
|
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1333
1333
|
const arrayMatcher = (str) => {
|
|
1334
1334
|
for (const isMatch of fns) {
|
|
1335
|
-
const
|
|
1336
|
-
if (
|
|
1337
|
-
return
|
|
1335
|
+
const state3 = isMatch(str);
|
|
1336
|
+
if (state3)
|
|
1337
|
+
return state3;
|
|
1338
1338
|
}
|
|
1339
1339
|
return false;
|
|
1340
1340
|
};
|
|
@@ -1347,7 +1347,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
1347
1347
|
const opts = options || {};
|
|
1348
1348
|
const posix = opts.windows;
|
|
1349
1349
|
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1350
|
-
const
|
|
1350
|
+
const state2 = regex.state;
|
|
1351
1351
|
delete regex.state;
|
|
1352
1352
|
let isIgnored = () => false;
|
|
1353
1353
|
if (opts.ignore) {
|
|
@@ -1356,7 +1356,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
const matcher = (input, returnObject = false) => {
|
|
1358
1358
|
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
1359
|
-
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1359
|
+
const result = { glob, state: state2, regex, posix, input, output, match, isMatch };
|
|
1360
1360
|
if (typeof opts.onResult === "function") {
|
|
1361
1361
|
opts.onResult(result);
|
|
1362
1362
|
}
|
|
@@ -1377,7 +1377,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
1377
1377
|
return returnObject ? result : true;
|
|
1378
1378
|
};
|
|
1379
1379
|
if (returnState) {
|
|
1380
|
-
matcher.state =
|
|
1380
|
+
matcher.state = state2;
|
|
1381
1381
|
}
|
|
1382
1382
|
return matcher;
|
|
1383
1383
|
};
|
|
@@ -1416,20 +1416,20 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
1416
1416
|
return parse(pattern, { ...options, fastpaths: false });
|
|
1417
1417
|
};
|
|
1418
1418
|
picomatch.scan = (input, options) => scan(input, options);
|
|
1419
|
-
picomatch.compileRe = (
|
|
1419
|
+
picomatch.compileRe = (state2, options, returnOutput = false, returnState = false) => {
|
|
1420
1420
|
if (returnOutput === true) {
|
|
1421
|
-
return
|
|
1421
|
+
return state2.output;
|
|
1422
1422
|
}
|
|
1423
1423
|
const opts = options || {};
|
|
1424
1424
|
const prepend = opts.contains ? "" : "^";
|
|
1425
1425
|
const append = opts.contains ? "" : "$";
|
|
1426
|
-
let source = `${prepend}(?:${
|
|
1427
|
-
if (
|
|
1426
|
+
let source = `${prepend}(?:${state2.output})${append}`;
|
|
1427
|
+
if (state2 && state2.negated === true) {
|
|
1428
1428
|
source = `^(?!${source}).*$`;
|
|
1429
1429
|
}
|
|
1430
1430
|
const regex = picomatch.toRegex(source, options);
|
|
1431
1431
|
if (returnState === true) {
|
|
1432
|
-
regex.state =
|
|
1432
|
+
regex.state = state2;
|
|
1433
1433
|
}
|
|
1434
1434
|
return regex;
|
|
1435
1435
|
};
|
|
@@ -3534,6 +3534,28 @@ ${CONTEXT_REMINDER}
|
|
|
3534
3534
|
}
|
|
3535
3535
|
// src/hooks/session-notification.ts
|
|
3536
3536
|
import { platform } from "os";
|
|
3537
|
+
// src/features/claude-code-session-state/state.ts
|
|
3538
|
+
var sessionErrorState = new Map;
|
|
3539
|
+
var sessionInterruptState = new Map;
|
|
3540
|
+
var subagentSessions = new Set;
|
|
3541
|
+
var sessionFirstMessageProcessed = new Set;
|
|
3542
|
+
var currentSessionID;
|
|
3543
|
+
var currentSessionTitle;
|
|
3544
|
+
var mainSessionID;
|
|
3545
|
+
function setCurrentSession(id, title) {
|
|
3546
|
+
currentSessionID = id;
|
|
3547
|
+
currentSessionTitle = title;
|
|
3548
|
+
}
|
|
3549
|
+
function setMainSession(id) {
|
|
3550
|
+
mainSessionID = id;
|
|
3551
|
+
}
|
|
3552
|
+
function getCurrentSessionTitle() {
|
|
3553
|
+
return currentSessionTitle;
|
|
3554
|
+
}
|
|
3555
|
+
function getMainSessionID() {
|
|
3556
|
+
return mainSessionID;
|
|
3557
|
+
}
|
|
3558
|
+
// src/hooks/session-notification.ts
|
|
3537
3559
|
function detectPlatform() {
|
|
3538
3560
|
const p = platform();
|
|
3539
3561
|
if (p === "darwin" || p === "linux" || p === "win32")
|
|
@@ -3700,6 +3722,8 @@ function createSessionNotification(ctx, config = {}) {
|
|
|
3700
3722
|
const sessionID = props?.sessionID;
|
|
3701
3723
|
if (!sessionID)
|
|
3702
3724
|
return;
|
|
3725
|
+
if (subagentSessions.has(sessionID))
|
|
3726
|
+
return;
|
|
3703
3727
|
if (notifiedSessions.has(sessionID))
|
|
3704
3728
|
return;
|
|
3705
3729
|
if (pendingTimers.has(sessionID))
|
|
@@ -5260,28 +5284,28 @@ function truncateToolResult(partPath) {
|
|
|
5260
5284
|
|
|
5261
5285
|
// src/hooks/anthropic-auto-compact/executor.ts
|
|
5262
5286
|
function getOrCreateRetryState(autoCompactState, sessionID) {
|
|
5263
|
-
let
|
|
5264
|
-
if (!
|
|
5265
|
-
|
|
5266
|
-
autoCompactState.retryStateBySession.set(sessionID,
|
|
5287
|
+
let state2 = autoCompactState.retryStateBySession.get(sessionID);
|
|
5288
|
+
if (!state2) {
|
|
5289
|
+
state2 = { attempt: 0, lastAttemptTime: 0 };
|
|
5290
|
+
autoCompactState.retryStateBySession.set(sessionID, state2);
|
|
5267
5291
|
}
|
|
5268
|
-
return
|
|
5292
|
+
return state2;
|
|
5269
5293
|
}
|
|
5270
5294
|
function getOrCreateFallbackState(autoCompactState, sessionID) {
|
|
5271
|
-
let
|
|
5272
|
-
if (!
|
|
5273
|
-
|
|
5274
|
-
autoCompactState.fallbackStateBySession.set(sessionID,
|
|
5295
|
+
let state2 = autoCompactState.fallbackStateBySession.get(sessionID);
|
|
5296
|
+
if (!state2) {
|
|
5297
|
+
state2 = { revertAttempt: 0 };
|
|
5298
|
+
autoCompactState.fallbackStateBySession.set(sessionID, state2);
|
|
5275
5299
|
}
|
|
5276
|
-
return
|
|
5300
|
+
return state2;
|
|
5277
5301
|
}
|
|
5278
5302
|
function getOrCreateTruncateState(autoCompactState, sessionID) {
|
|
5279
|
-
let
|
|
5280
|
-
if (!
|
|
5281
|
-
|
|
5282
|
-
autoCompactState.truncateStateBySession.set(sessionID,
|
|
5303
|
+
let state2 = autoCompactState.truncateStateBySession.get(sessionID);
|
|
5304
|
+
if (!state2) {
|
|
5305
|
+
state2 = { truncateAttempt: 0 };
|
|
5306
|
+
autoCompactState.truncateStateBySession.set(sessionID, state2);
|
|
5283
5307
|
}
|
|
5284
|
-
return
|
|
5308
|
+
return state2;
|
|
5285
5309
|
}
|
|
5286
5310
|
async function getLastMessagePair(sessionID, client, directory) {
|
|
5287
5311
|
try {
|
|
@@ -5811,25 +5835,25 @@ function createThinkModeHook() {
|
|
|
5811
5835
|
return {
|
|
5812
5836
|
"chat.params": async (output, sessionID) => {
|
|
5813
5837
|
const promptText = extractPromptText(output.parts);
|
|
5814
|
-
const
|
|
5838
|
+
const state2 = {
|
|
5815
5839
|
requested: false,
|
|
5816
5840
|
modelSwitched: false,
|
|
5817
5841
|
thinkingConfigInjected: false
|
|
5818
5842
|
};
|
|
5819
5843
|
if (!detectThinkKeyword(promptText)) {
|
|
5820
|
-
thinkModeState.set(sessionID,
|
|
5844
|
+
thinkModeState.set(sessionID, state2);
|
|
5821
5845
|
return;
|
|
5822
5846
|
}
|
|
5823
|
-
|
|
5847
|
+
state2.requested = true;
|
|
5824
5848
|
const currentModel = output.message.model;
|
|
5825
5849
|
if (!currentModel) {
|
|
5826
|
-
thinkModeState.set(sessionID,
|
|
5850
|
+
thinkModeState.set(sessionID, state2);
|
|
5827
5851
|
return;
|
|
5828
5852
|
}
|
|
5829
|
-
|
|
5830
|
-
|
|
5853
|
+
state2.providerID = currentModel.providerID;
|
|
5854
|
+
state2.modelID = currentModel.modelID;
|
|
5831
5855
|
if (isAlreadyHighVariant(currentModel.modelID)) {
|
|
5832
|
-
thinkModeState.set(sessionID,
|
|
5856
|
+
thinkModeState.set(sessionID, state2);
|
|
5833
5857
|
return;
|
|
5834
5858
|
}
|
|
5835
5859
|
const highVariant = getHighVariant(currentModel.modelID);
|
|
@@ -5839,7 +5863,7 @@ function createThinkModeHook() {
|
|
|
5839
5863
|
providerID: currentModel.providerID,
|
|
5840
5864
|
modelID: highVariant
|
|
5841
5865
|
};
|
|
5842
|
-
|
|
5866
|
+
state2.modelSwitched = true;
|
|
5843
5867
|
log("Think mode: model switched to high variant", {
|
|
5844
5868
|
sessionID,
|
|
5845
5869
|
from: currentModel.modelID,
|
|
@@ -5848,14 +5872,14 @@ function createThinkModeHook() {
|
|
|
5848
5872
|
}
|
|
5849
5873
|
if (thinkingConfig) {
|
|
5850
5874
|
Object.assign(output.message, thinkingConfig);
|
|
5851
|
-
|
|
5875
|
+
state2.thinkingConfigInjected = true;
|
|
5852
5876
|
log("Think mode: thinking config injected", {
|
|
5853
5877
|
sessionID,
|
|
5854
5878
|
provider: currentModel.providerID,
|
|
5855
5879
|
config: thinkingConfig
|
|
5856
5880
|
});
|
|
5857
5881
|
}
|
|
5858
|
-
thinkModeState.set(sessionID,
|
|
5882
|
+
thinkModeState.set(sessionID, state2);
|
|
5859
5883
|
},
|
|
5860
5884
|
event: async ({ event }) => {
|
|
5861
5885
|
if (event.type === "session.deleted") {
|
|
@@ -6551,13 +6575,13 @@ setInterval(() => {
|
|
|
6551
6575
|
}, CACHE_TTL);
|
|
6552
6576
|
|
|
6553
6577
|
// src/hooks/claude-code-hooks/index.ts
|
|
6554
|
-
var
|
|
6555
|
-
var
|
|
6556
|
-
var
|
|
6578
|
+
var sessionFirstMessageProcessed2 = new Set;
|
|
6579
|
+
var sessionErrorState2 = new Map;
|
|
6580
|
+
var sessionInterruptState2 = new Map;
|
|
6557
6581
|
function createClaudeCodeHooksHook(ctx, config = {}) {
|
|
6558
6582
|
return {
|
|
6559
6583
|
"chat.message": async (input, output) => {
|
|
6560
|
-
const interruptState =
|
|
6584
|
+
const interruptState = sessionInterruptState2.get(input.sessionID);
|
|
6561
6585
|
if (interruptState?.interrupted) {
|
|
6562
6586
|
log("chat.message hook skipped - session interrupted", { sessionID: input.sessionID });
|
|
6563
6587
|
return;
|
|
@@ -6572,7 +6596,7 @@ function createClaudeCodeHooksHook(ctx, config = {}) {
|
|
|
6572
6596
|
type: p.type,
|
|
6573
6597
|
text: p.text
|
|
6574
6598
|
}));
|
|
6575
|
-
const interruptStateBeforeHooks =
|
|
6599
|
+
const interruptStateBeforeHooks = sessionInterruptState2.get(input.sessionID);
|
|
6576
6600
|
if (interruptStateBeforeHooks?.interrupted) {
|
|
6577
6601
|
log("chat.message hooks skipped - interrupted during preparation", { sessionID: input.sessionID });
|
|
6578
6602
|
return;
|
|
@@ -6584,8 +6608,8 @@ function createClaudeCodeHooksHook(ctx, config = {}) {
|
|
|
6584
6608
|
});
|
|
6585
6609
|
parentSessionId = sessionInfo.data?.parentID;
|
|
6586
6610
|
} catch {}
|
|
6587
|
-
const isFirstMessage = !
|
|
6588
|
-
|
|
6611
|
+
const isFirstMessage = !sessionFirstMessageProcessed2.has(input.sessionID);
|
|
6612
|
+
sessionFirstMessageProcessed2.add(input.sessionID);
|
|
6589
6613
|
if (isFirstMessage) {
|
|
6590
6614
|
log("Skipping UserPromptSubmit hooks on first message for title generation", { sessionID: input.sessionID });
|
|
6591
6615
|
return;
|
|
@@ -6602,7 +6626,7 @@ function createClaudeCodeHooksHook(ctx, config = {}) {
|
|
|
6602
6626
|
if (result.block) {
|
|
6603
6627
|
throw new Error(result.reason ?? "Hook blocked the prompt");
|
|
6604
6628
|
}
|
|
6605
|
-
const interruptStateAfterHooks =
|
|
6629
|
+
const interruptStateAfterHooks = sessionInterruptState2.get(input.sessionID);
|
|
6606
6630
|
if (interruptStateAfterHooks?.interrupted) {
|
|
6607
6631
|
log("chat.message injection skipped - interrupted during hooks", { sessionID: input.sessionID });
|
|
6608
6632
|
return;
|
|
@@ -6722,7 +6746,7 @@ ${result.message}`;
|
|
|
6722
6746
|
const props = event.properties;
|
|
6723
6747
|
const sessionID = props?.sessionID;
|
|
6724
6748
|
if (sessionID) {
|
|
6725
|
-
|
|
6749
|
+
sessionErrorState2.set(sessionID, {
|
|
6726
6750
|
hasError: true,
|
|
6727
6751
|
errorMessage: String(props?.error ?? "Unknown error")
|
|
6728
6752
|
});
|
|
@@ -6733,9 +6757,9 @@ ${result.message}`;
|
|
|
6733
6757
|
const props = event.properties;
|
|
6734
6758
|
const sessionInfo = props?.info;
|
|
6735
6759
|
if (sessionInfo?.id) {
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6760
|
+
sessionErrorState2.delete(sessionInfo.id);
|
|
6761
|
+
sessionInterruptState2.delete(sessionInfo.id);
|
|
6762
|
+
sessionFirstMessageProcessed2.delete(sessionInfo.id);
|
|
6739
6763
|
}
|
|
6740
6764
|
return;
|
|
6741
6765
|
}
|
|
@@ -6746,9 +6770,9 @@ ${result.message}`;
|
|
|
6746
6770
|
return;
|
|
6747
6771
|
const claudeConfig = await loadClaudeHooksConfig();
|
|
6748
6772
|
const extendedConfig = await loadPluginExtendedConfig();
|
|
6749
|
-
const errorStateBefore =
|
|
6773
|
+
const errorStateBefore = sessionErrorState2.get(sessionID);
|
|
6750
6774
|
const endedWithErrorBefore = errorStateBefore?.hasError === true;
|
|
6751
|
-
const interruptStateBefore =
|
|
6775
|
+
const interruptStateBefore = sessionInterruptState2.get(sessionID);
|
|
6752
6776
|
const interruptedBefore = interruptStateBefore?.interrupted === true;
|
|
6753
6777
|
let parentSessionId;
|
|
6754
6778
|
try {
|
|
@@ -6764,9 +6788,9 @@ ${result.message}`;
|
|
|
6764
6788
|
cwd: ctx.directory
|
|
6765
6789
|
};
|
|
6766
6790
|
const stopResult = await executeStopHooks(stopCtx, claudeConfig, extendedConfig);
|
|
6767
|
-
const errorStateAfter =
|
|
6791
|
+
const errorStateAfter = sessionErrorState2.get(sessionID);
|
|
6768
6792
|
const endedWithErrorAfter = errorStateAfter?.hasError === true;
|
|
6769
|
-
const interruptStateAfter =
|
|
6793
|
+
const interruptStateAfter = sessionInterruptState2.get(sessionID);
|
|
6770
6794
|
const interruptedAfter = interruptStateAfter?.interrupted === true;
|
|
6771
6795
|
const shouldBypass = endedWithErrorBefore || endedWithErrorAfter || interruptedBefore || interruptedAfter;
|
|
6772
6796
|
if (shouldBypass && stopResult.block) {
|
|
@@ -6784,8 +6808,8 @@ ${result.message}`;
|
|
|
6784
6808
|
log("Stop hook returned block", { sessionID, reason: stopResult.reason });
|
|
6785
6809
|
}
|
|
6786
6810
|
}
|
|
6787
|
-
|
|
6788
|
-
|
|
6811
|
+
sessionErrorState2.delete(sessionID);
|
|
6812
|
+
sessionInterruptState2.delete(sessionID);
|
|
6789
6813
|
}
|
|
6790
6814
|
}
|
|
6791
6815
|
};
|
|
@@ -7601,12 +7625,12 @@ function loadAgentUsageState(sessionID) {
|
|
|
7601
7625
|
return null;
|
|
7602
7626
|
}
|
|
7603
7627
|
}
|
|
7604
|
-
function saveAgentUsageState(
|
|
7628
|
+
function saveAgentUsageState(state2) {
|
|
7605
7629
|
if (!existsSync21(AGENT_USAGE_REMINDER_STORAGE)) {
|
|
7606
7630
|
mkdirSync8(AGENT_USAGE_REMINDER_STORAGE, { recursive: true });
|
|
7607
7631
|
}
|
|
7608
|
-
const filePath = getStoragePath4(
|
|
7609
|
-
writeFileSync9(filePath, JSON.stringify(
|
|
7632
|
+
const filePath = getStoragePath4(state2.sessionID);
|
|
7633
|
+
writeFileSync9(filePath, JSON.stringify(state2, null, 2));
|
|
7610
7634
|
}
|
|
7611
7635
|
function clearAgentUsageState(sessionID) {
|
|
7612
7636
|
const filePath = getStoragePath4(sessionID);
|
|
@@ -7621,21 +7645,21 @@ function createAgentUsageReminderHook(_ctx) {
|
|
|
7621
7645
|
function getOrCreateState(sessionID) {
|
|
7622
7646
|
if (!sessionStates.has(sessionID)) {
|
|
7623
7647
|
const persisted = loadAgentUsageState(sessionID);
|
|
7624
|
-
const
|
|
7648
|
+
const state2 = persisted ?? {
|
|
7625
7649
|
sessionID,
|
|
7626
7650
|
agentUsed: false,
|
|
7627
7651
|
reminderCount: 0,
|
|
7628
7652
|
updatedAt: Date.now()
|
|
7629
7653
|
};
|
|
7630
|
-
sessionStates.set(sessionID,
|
|
7654
|
+
sessionStates.set(sessionID, state2);
|
|
7631
7655
|
}
|
|
7632
7656
|
return sessionStates.get(sessionID);
|
|
7633
7657
|
}
|
|
7634
7658
|
function markAgentUsed(sessionID) {
|
|
7635
|
-
const
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
saveAgentUsageState(
|
|
7659
|
+
const state2 = getOrCreateState(sessionID);
|
|
7660
|
+
state2.agentUsed = true;
|
|
7661
|
+
state2.updatedAt = Date.now();
|
|
7662
|
+
saveAgentUsageState(state2);
|
|
7639
7663
|
}
|
|
7640
7664
|
function resetState(sessionID) {
|
|
7641
7665
|
sessionStates.delete(sessionID);
|
|
@@ -7651,14 +7675,14 @@ function createAgentUsageReminderHook(_ctx) {
|
|
|
7651
7675
|
if (!TARGET_TOOLS.has(toolLower)) {
|
|
7652
7676
|
return;
|
|
7653
7677
|
}
|
|
7654
|
-
const
|
|
7655
|
-
if (
|
|
7678
|
+
const state2 = getOrCreateState(sessionID);
|
|
7679
|
+
if (state2.agentUsed) {
|
|
7656
7680
|
return;
|
|
7657
7681
|
}
|
|
7658
7682
|
output.output += REMINDER_MESSAGE;
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
saveAgentUsageState(
|
|
7683
|
+
state2.reminderCount++;
|
|
7684
|
+
state2.updatedAt = Date.now();
|
|
7685
|
+
saveAgentUsageState(state2);
|
|
7662
7686
|
};
|
|
7663
7687
|
const eventHandler = async ({ event }) => {
|
|
7664
7688
|
const props = event.properties;
|
|
@@ -7873,15 +7897,15 @@ function loadInteractiveBashSessionState(sessionID) {
|
|
|
7873
7897
|
return null;
|
|
7874
7898
|
}
|
|
7875
7899
|
}
|
|
7876
|
-
function saveInteractiveBashSessionState(
|
|
7900
|
+
function saveInteractiveBashSessionState(state2) {
|
|
7877
7901
|
if (!existsSync22(INTERACTIVE_BASH_SESSION_STORAGE)) {
|
|
7878
7902
|
mkdirSync9(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
|
|
7879
7903
|
}
|
|
7880
|
-
const filePath = getStoragePath5(
|
|
7904
|
+
const filePath = getStoragePath5(state2.sessionID);
|
|
7881
7905
|
const serialized = {
|
|
7882
|
-
sessionID:
|
|
7883
|
-
tmuxSessions: Array.from(
|
|
7884
|
-
updatedAt:
|
|
7906
|
+
sessionID: state2.sessionID,
|
|
7907
|
+
tmuxSessions: Array.from(state2.tmuxSessions),
|
|
7908
|
+
updatedAt: state2.updatedAt
|
|
7885
7909
|
};
|
|
7886
7910
|
writeFileSync10(filePath, JSON.stringify(serialized, null, 2));
|
|
7887
7911
|
}
|
|
@@ -7979,20 +8003,20 @@ function createInteractiveBashSessionHook(_ctx) {
|
|
|
7979
8003
|
function getOrCreateState(sessionID) {
|
|
7980
8004
|
if (!sessionStates.has(sessionID)) {
|
|
7981
8005
|
const persisted = loadInteractiveBashSessionState(sessionID);
|
|
7982
|
-
const
|
|
8006
|
+
const state2 = persisted ?? {
|
|
7983
8007
|
sessionID,
|
|
7984
8008
|
tmuxSessions: new Set,
|
|
7985
8009
|
updatedAt: Date.now()
|
|
7986
8010
|
};
|
|
7987
|
-
sessionStates.set(sessionID,
|
|
8011
|
+
sessionStates.set(sessionID, state2);
|
|
7988
8012
|
}
|
|
7989
8013
|
return sessionStates.get(sessionID);
|
|
7990
8014
|
}
|
|
7991
8015
|
function isOmoSession(sessionName) {
|
|
7992
8016
|
return sessionName !== null && sessionName.startsWith(OMO_SESSION_PREFIX);
|
|
7993
8017
|
}
|
|
7994
|
-
async function killAllTrackedSessions(
|
|
7995
|
-
for (const sessionName of
|
|
8018
|
+
async function killAllTrackedSessions(state2) {
|
|
8019
|
+
for (const sessionName of state2.tmuxSessions) {
|
|
7996
8020
|
try {
|
|
7997
8021
|
const proc = Bun.spawn(["tmux", "kill-session", "-t", sessionName], {
|
|
7998
8022
|
stdout: "ignore",
|
|
@@ -8014,7 +8038,7 @@ function createInteractiveBashSessionHook(_ctx) {
|
|
|
8014
8038
|
const tmuxCommand = args.tmux_command;
|
|
8015
8039
|
const tokens = tokenizeCommand(tmuxCommand);
|
|
8016
8040
|
const subCommand = findSubcommand(tokens);
|
|
8017
|
-
const
|
|
8041
|
+
const state2 = getOrCreateState(sessionID);
|
|
8018
8042
|
let stateChanged = false;
|
|
8019
8043
|
const toolOutput = output?.output ?? "";
|
|
8020
8044
|
if (toolOutput.startsWith("Error:")) {
|
|
@@ -8025,22 +8049,22 @@ function createInteractiveBashSessionHook(_ctx) {
|
|
|
8025
8049
|
const isKillServer = subCommand === "kill-server";
|
|
8026
8050
|
const sessionName = extractSessionNameFromTokens(tokens, subCommand);
|
|
8027
8051
|
if (isNewSession && isOmoSession(sessionName)) {
|
|
8028
|
-
|
|
8052
|
+
state2.tmuxSessions.add(sessionName);
|
|
8029
8053
|
stateChanged = true;
|
|
8030
8054
|
} else if (isKillSession && isOmoSession(sessionName)) {
|
|
8031
|
-
|
|
8055
|
+
state2.tmuxSessions.delete(sessionName);
|
|
8032
8056
|
stateChanged = true;
|
|
8033
8057
|
} else if (isKillServer) {
|
|
8034
|
-
|
|
8058
|
+
state2.tmuxSessions.clear();
|
|
8035
8059
|
stateChanged = true;
|
|
8036
8060
|
}
|
|
8037
8061
|
if (stateChanged) {
|
|
8038
|
-
|
|
8039
|
-
saveInteractiveBashSessionState(
|
|
8062
|
+
state2.updatedAt = Date.now();
|
|
8063
|
+
saveInteractiveBashSessionState(state2);
|
|
8040
8064
|
}
|
|
8041
8065
|
const isSessionOperation = isNewSession || isKillSession || isKillServer;
|
|
8042
8066
|
if (isSessionOperation) {
|
|
8043
|
-
const reminder = buildSessionReminderMessage(Array.from(
|
|
8067
|
+
const reminder = buildSessionReminderMessage(Array.from(state2.tmuxSessions));
|
|
8044
8068
|
if (reminder) {
|
|
8045
8069
|
output.output += reminder;
|
|
8046
8070
|
}
|
|
@@ -8052,8 +8076,8 @@ function createInteractiveBashSessionHook(_ctx) {
|
|
|
8052
8076
|
const sessionInfo = props?.info;
|
|
8053
8077
|
const sessionID = sessionInfo?.id;
|
|
8054
8078
|
if (sessionID) {
|
|
8055
|
-
const
|
|
8056
|
-
await killAllTrackedSessions(
|
|
8079
|
+
const state2 = getOrCreateState(sessionID);
|
|
8080
|
+
await killAllTrackedSessions(state2);
|
|
8057
8081
|
sessionStates.delete(sessionID);
|
|
8058
8082
|
clearInteractiveBashSessionState(sessionID);
|
|
8059
8083
|
}
|
|
@@ -8249,8 +8273,8 @@ async function generatePKCEPair() {
|
|
|
8249
8273
|
method: pkce.method
|
|
8250
8274
|
};
|
|
8251
8275
|
}
|
|
8252
|
-
function encodeState(
|
|
8253
|
-
const json = JSON.stringify(
|
|
8276
|
+
function encodeState(state2) {
|
|
8277
|
+
const json = JSON.stringify(state2);
|
|
8254
8278
|
return Buffer.from(json, "utf8").toString("base64url");
|
|
8255
8279
|
}
|
|
8256
8280
|
function decodeState(encoded) {
|
|
@@ -8268,7 +8292,7 @@ function decodeState(encoded) {
|
|
|
8268
8292
|
}
|
|
8269
8293
|
async function buildAuthURL(projectId, clientId = ANTIGRAVITY_CLIENT_ID, port = ANTIGRAVITY_CALLBACK_PORT) {
|
|
8270
8294
|
const pkce = await generatePKCEPair();
|
|
8271
|
-
const
|
|
8295
|
+
const state2 = {
|
|
8272
8296
|
verifier: pkce.verifier,
|
|
8273
8297
|
projectId
|
|
8274
8298
|
};
|
|
@@ -8278,7 +8302,7 @@ async function buildAuthURL(projectId, clientId = ANTIGRAVITY_CLIENT_ID, port =
|
|
|
8278
8302
|
url.searchParams.set("redirect_uri", redirectUri);
|
|
8279
8303
|
url.searchParams.set("response_type", "code");
|
|
8280
8304
|
url.searchParams.set("scope", ANTIGRAVITY_SCOPES.join(" "));
|
|
8281
|
-
url.searchParams.set("state", encodeState(
|
|
8305
|
+
url.searchParams.set("state", encodeState(state2));
|
|
8282
8306
|
url.searchParams.set("code_challenge", pkce.challenge);
|
|
8283
8307
|
url.searchParams.set("code_challenge_method", "S256");
|
|
8284
8308
|
url.searchParams.set("access_type", "offline");
|
|
@@ -8354,7 +8378,7 @@ function startCallbackServer(timeoutMs = 5 * 60 * 1000) {
|
|
|
8354
8378
|
const url = new URL(request.url);
|
|
8355
8379
|
if (url.pathname === "/oauth-callback") {
|
|
8356
8380
|
const code = url.searchParams.get("code") || "";
|
|
8357
|
-
const
|
|
8381
|
+
const state2 = url.searchParams.get("state") || "";
|
|
8358
8382
|
const error = url.searchParams.get("error") || undefined;
|
|
8359
8383
|
let responseBody;
|
|
8360
8384
|
if (code && !error) {
|
|
@@ -8365,7 +8389,7 @@ function startCallbackServer(timeoutMs = 5 * 60 * 1000) {
|
|
|
8365
8389
|
setTimeout(() => {
|
|
8366
8390
|
cleanup();
|
|
8367
8391
|
if (resolveCallback) {
|
|
8368
|
-
resolveCallback({ code, state, error });
|
|
8392
|
+
resolveCallback({ code, state: state2, error });
|
|
8369
8393
|
}
|
|
8370
8394
|
}, 100);
|
|
8371
8395
|
return new Response(responseBody, {
|
|
@@ -9781,8 +9805,8 @@ async function createGoogleAntigravityAuthPlugin({
|
|
|
9781
9805
|
}
|
|
9782
9806
|
return { type: "failed" };
|
|
9783
9807
|
}
|
|
9784
|
-
const
|
|
9785
|
-
if (
|
|
9808
|
+
const state2 = decodeState(result.state);
|
|
9809
|
+
if (state2.verifier !== verifier) {
|
|
9786
9810
|
if (process.env.ANTIGRAVITY_DEBUG === "1") {
|
|
9787
9811
|
console.error("[antigravity-plugin] PKCE verifier mismatch");
|
|
9788
9812
|
}
|
|
@@ -10152,27 +10176,6 @@ async function loadMcpConfigs() {
|
|
|
10152
10176
|
}
|
|
10153
10177
|
return { servers, loadedServers };
|
|
10154
10178
|
}
|
|
10155
|
-
// src/features/claude-code-session-state/state.ts
|
|
10156
|
-
var sessionErrorState2 = new Map;
|
|
10157
|
-
var sessionInterruptState2 = new Map;
|
|
10158
|
-
var subagentSessions = new Set;
|
|
10159
|
-
var sessionFirstMessageProcessed2 = new Set;
|
|
10160
|
-
var currentSessionID;
|
|
10161
|
-
var currentSessionTitle;
|
|
10162
|
-
var mainSessionID;
|
|
10163
|
-
function setCurrentSession(id, title) {
|
|
10164
|
-
currentSessionID = id;
|
|
10165
|
-
currentSessionTitle = title;
|
|
10166
|
-
}
|
|
10167
|
-
function setMainSession(id) {
|
|
10168
|
-
mainSessionID = id;
|
|
10169
|
-
}
|
|
10170
|
-
function getCurrentSessionTitle() {
|
|
10171
|
-
return currentSessionTitle;
|
|
10172
|
-
}
|
|
10173
|
-
function getMainSessionID() {
|
|
10174
|
-
return mainSessionID;
|
|
10175
|
-
}
|
|
10176
10179
|
// src/features/terminal/title.ts
|
|
10177
10180
|
var STATUS_ICONS = {
|
|
10178
10181
|
ready: "",
|
|
@@ -26200,6 +26203,7 @@ class BackgroundManager {
|
|
|
26200
26203
|
throw new Error(`Failed to create background session: ${createResult.error}`);
|
|
26201
26204
|
}
|
|
26202
26205
|
const sessionID = createResult.data.id;
|
|
26206
|
+
subagentSessions.add(sessionID);
|
|
26203
26207
|
const task = {
|
|
26204
26208
|
id: `bg_${crypto.randomUUID().slice(0, 8)}`,
|
|
26205
26209
|
sessionID,
|
|
@@ -26338,6 +26342,7 @@ class BackgroundManager {
|
|
|
26338
26342
|
}
|
|
26339
26343
|
this.tasks.delete(task.id);
|
|
26340
26344
|
this.clearNotificationsForTask(task.id);
|
|
26345
|
+
subagentSessions.delete(sessionID);
|
|
26341
26346
|
}
|
|
26342
26347
|
}
|
|
26343
26348
|
markForNotification(task) {
|