opencode-swarm 6.56.0 → 6.57.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 +43 -0
- package/dist/cli/index.js +4 -1
- package/dist/config/schema.d.ts +9 -0
- package/dist/hooks/guardrails.d.ts +3 -0
- package/dist/index.js +2049 -11
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -15089,9 +15089,12 @@ var init_schema = __esm(() => {
|
|
|
15089
15089
|
AgentAuthorityRuleSchema = exports_external.object({
|
|
15090
15090
|
readOnly: exports_external.boolean().optional(),
|
|
15091
15091
|
blockedExact: exports_external.array(exports_external.string()).optional(),
|
|
15092
|
+
allowedExact: exports_external.array(exports_external.string()).optional(),
|
|
15092
15093
|
blockedPrefix: exports_external.array(exports_external.string()).optional(),
|
|
15093
15094
|
allowedPrefix: exports_external.array(exports_external.string()).optional(),
|
|
15094
|
-
blockedZones: exports_external.array(exports_external.enum(["production", "test", "config", "generated", "docs", "build"])).optional()
|
|
15095
|
+
blockedZones: exports_external.array(exports_external.enum(["production", "test", "config", "generated", "docs", "build"])).optional(),
|
|
15096
|
+
blockedGlobs: exports_external.array(exports_external.string()).optional(),
|
|
15097
|
+
allowedGlobs: exports_external.array(exports_external.string()).optional()
|
|
15095
15098
|
});
|
|
15096
15099
|
AuthorityConfigSchema = exports_external.object({
|
|
15097
15100
|
enabled: exports_external.boolean().default(true),
|
|
@@ -38784,6 +38787,1685 @@ var init_trigger = __esm(() => {
|
|
|
38784
38787
|
init_queue();
|
|
38785
38788
|
});
|
|
38786
38789
|
|
|
38790
|
+
// node_modules/picomatch/lib/constants.js
|
|
38791
|
+
var require_constants = __commonJS((exports, module2) => {
|
|
38792
|
+
var WIN_SLASH = "\\\\/";
|
|
38793
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
38794
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
38795
|
+
var DOT_LITERAL = "\\.";
|
|
38796
|
+
var PLUS_LITERAL = "\\+";
|
|
38797
|
+
var QMARK_LITERAL = "\\?";
|
|
38798
|
+
var SLASH_LITERAL = "\\/";
|
|
38799
|
+
var ONE_CHAR = "(?=.)";
|
|
38800
|
+
var QMARK = "[^/]";
|
|
38801
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
38802
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
38803
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
38804
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
38805
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
38806
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
38807
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
38808
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
38809
|
+
var STAR = `${QMARK}*?`;
|
|
38810
|
+
var SEP = "/";
|
|
38811
|
+
var POSIX_CHARS = {
|
|
38812
|
+
DOT_LITERAL,
|
|
38813
|
+
PLUS_LITERAL,
|
|
38814
|
+
QMARK_LITERAL,
|
|
38815
|
+
SLASH_LITERAL,
|
|
38816
|
+
ONE_CHAR,
|
|
38817
|
+
QMARK,
|
|
38818
|
+
END_ANCHOR,
|
|
38819
|
+
DOTS_SLASH,
|
|
38820
|
+
NO_DOT,
|
|
38821
|
+
NO_DOTS,
|
|
38822
|
+
NO_DOT_SLASH,
|
|
38823
|
+
NO_DOTS_SLASH,
|
|
38824
|
+
QMARK_NO_DOT,
|
|
38825
|
+
STAR,
|
|
38826
|
+
START_ANCHOR,
|
|
38827
|
+
SEP
|
|
38828
|
+
};
|
|
38829
|
+
var WINDOWS_CHARS = {
|
|
38830
|
+
...POSIX_CHARS,
|
|
38831
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
38832
|
+
QMARK: WIN_NO_SLASH,
|
|
38833
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
38834
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
38835
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
38836
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
38837
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
38838
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
38839
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
38840
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
38841
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
38842
|
+
SEP: "\\"
|
|
38843
|
+
};
|
|
38844
|
+
var POSIX_REGEX_SOURCE = {
|
|
38845
|
+
__proto__: null,
|
|
38846
|
+
alnum: "a-zA-Z0-9",
|
|
38847
|
+
alpha: "a-zA-Z",
|
|
38848
|
+
ascii: "\\x00-\\x7F",
|
|
38849
|
+
blank: " \\t",
|
|
38850
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
38851
|
+
digit: "0-9",
|
|
38852
|
+
graph: "\\x21-\\x7E",
|
|
38853
|
+
lower: "a-z",
|
|
38854
|
+
print: "\\x20-\\x7E ",
|
|
38855
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
38856
|
+
space: " \\t\\r\\n\\v\\f",
|
|
38857
|
+
upper: "A-Z",
|
|
38858
|
+
word: "A-Za-z0-9_",
|
|
38859
|
+
xdigit: "A-Fa-f0-9"
|
|
38860
|
+
};
|
|
38861
|
+
module2.exports = {
|
|
38862
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
38863
|
+
MAX_LENGTH: 1024 * 64,
|
|
38864
|
+
POSIX_REGEX_SOURCE,
|
|
38865
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
38866
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
38867
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
38868
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
38869
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
38870
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
38871
|
+
REPLACEMENTS: {
|
|
38872
|
+
__proto__: null,
|
|
38873
|
+
"***": "*",
|
|
38874
|
+
"**/**": "**",
|
|
38875
|
+
"**/**/**": "**"
|
|
38876
|
+
},
|
|
38877
|
+
CHAR_0: 48,
|
|
38878
|
+
CHAR_9: 57,
|
|
38879
|
+
CHAR_UPPERCASE_A: 65,
|
|
38880
|
+
CHAR_LOWERCASE_A: 97,
|
|
38881
|
+
CHAR_UPPERCASE_Z: 90,
|
|
38882
|
+
CHAR_LOWERCASE_Z: 122,
|
|
38883
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
38884
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
38885
|
+
CHAR_ASTERISK: 42,
|
|
38886
|
+
CHAR_AMPERSAND: 38,
|
|
38887
|
+
CHAR_AT: 64,
|
|
38888
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
38889
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
38890
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
38891
|
+
CHAR_COLON: 58,
|
|
38892
|
+
CHAR_COMMA: 44,
|
|
38893
|
+
CHAR_DOT: 46,
|
|
38894
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
38895
|
+
CHAR_EQUAL: 61,
|
|
38896
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
38897
|
+
CHAR_FORM_FEED: 12,
|
|
38898
|
+
CHAR_FORWARD_SLASH: 47,
|
|
38899
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
38900
|
+
CHAR_HASH: 35,
|
|
38901
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
38902
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
38903
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
38904
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
38905
|
+
CHAR_LINE_FEED: 10,
|
|
38906
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
38907
|
+
CHAR_PERCENT: 37,
|
|
38908
|
+
CHAR_PLUS: 43,
|
|
38909
|
+
CHAR_QUESTION_MARK: 63,
|
|
38910
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
38911
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
38912
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
38913
|
+
CHAR_SEMICOLON: 59,
|
|
38914
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
38915
|
+
CHAR_SPACE: 32,
|
|
38916
|
+
CHAR_TAB: 9,
|
|
38917
|
+
CHAR_UNDERSCORE: 95,
|
|
38918
|
+
CHAR_VERTICAL_LINE: 124,
|
|
38919
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
38920
|
+
extglobChars(chars) {
|
|
38921
|
+
return {
|
|
38922
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
38923
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
38924
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
38925
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
38926
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
38927
|
+
};
|
|
38928
|
+
},
|
|
38929
|
+
globChars(win32) {
|
|
38930
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
38931
|
+
}
|
|
38932
|
+
};
|
|
38933
|
+
});
|
|
38934
|
+
|
|
38935
|
+
// node_modules/picomatch/lib/utils.js
|
|
38936
|
+
var require_utils = __commonJS((exports) => {
|
|
38937
|
+
var {
|
|
38938
|
+
REGEX_BACKSLASH,
|
|
38939
|
+
REGEX_REMOVE_BACKSLASH,
|
|
38940
|
+
REGEX_SPECIAL_CHARS,
|
|
38941
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
38942
|
+
} = require_constants();
|
|
38943
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
38944
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
38945
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
38946
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
38947
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
38948
|
+
exports.isWindows = () => {
|
|
38949
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
38950
|
+
const platform = navigator.platform.toLowerCase();
|
|
38951
|
+
return platform === "win32" || platform === "windows";
|
|
38952
|
+
}
|
|
38953
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
38954
|
+
return process.platform === "win32";
|
|
38955
|
+
}
|
|
38956
|
+
return false;
|
|
38957
|
+
};
|
|
38958
|
+
exports.removeBackslashes = (str) => {
|
|
38959
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
38960
|
+
return match === "\\" ? "" : match;
|
|
38961
|
+
});
|
|
38962
|
+
};
|
|
38963
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
38964
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
38965
|
+
if (idx === -1)
|
|
38966
|
+
return input;
|
|
38967
|
+
if (input[idx - 1] === "\\")
|
|
38968
|
+
return exports.escapeLast(input, char, idx - 1);
|
|
38969
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
38970
|
+
};
|
|
38971
|
+
exports.removePrefix = (input, state = {}) => {
|
|
38972
|
+
let output = input;
|
|
38973
|
+
if (output.startsWith("./")) {
|
|
38974
|
+
output = output.slice(2);
|
|
38975
|
+
state.prefix = "./";
|
|
38976
|
+
}
|
|
38977
|
+
return output;
|
|
38978
|
+
};
|
|
38979
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
38980
|
+
const prepend = options.contains ? "" : "^";
|
|
38981
|
+
const append = options.contains ? "" : "$";
|
|
38982
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
38983
|
+
if (state.negated === true) {
|
|
38984
|
+
output = `(?:^(?!${output}).*$)`;
|
|
38985
|
+
}
|
|
38986
|
+
return output;
|
|
38987
|
+
};
|
|
38988
|
+
exports.basename = (path38, { windows } = {}) => {
|
|
38989
|
+
const segs = path38.split(windows ? /[\\/]/ : "/");
|
|
38990
|
+
const last = segs[segs.length - 1];
|
|
38991
|
+
if (last === "") {
|
|
38992
|
+
return segs[segs.length - 2];
|
|
38993
|
+
}
|
|
38994
|
+
return last;
|
|
38995
|
+
};
|
|
38996
|
+
});
|
|
38997
|
+
|
|
38998
|
+
// node_modules/picomatch/lib/scan.js
|
|
38999
|
+
var require_scan = __commonJS((exports, module2) => {
|
|
39000
|
+
var utils = require_utils();
|
|
39001
|
+
var {
|
|
39002
|
+
CHAR_ASTERISK,
|
|
39003
|
+
CHAR_AT,
|
|
39004
|
+
CHAR_BACKWARD_SLASH,
|
|
39005
|
+
CHAR_COMMA,
|
|
39006
|
+
CHAR_DOT,
|
|
39007
|
+
CHAR_EXCLAMATION_MARK,
|
|
39008
|
+
CHAR_FORWARD_SLASH,
|
|
39009
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
39010
|
+
CHAR_LEFT_PARENTHESES,
|
|
39011
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
39012
|
+
CHAR_PLUS,
|
|
39013
|
+
CHAR_QUESTION_MARK,
|
|
39014
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
39015
|
+
CHAR_RIGHT_PARENTHESES,
|
|
39016
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
39017
|
+
} = require_constants();
|
|
39018
|
+
var isPathSeparator = (code) => {
|
|
39019
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
39020
|
+
};
|
|
39021
|
+
var depth = (token) => {
|
|
39022
|
+
if (token.isPrefix !== true) {
|
|
39023
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
39024
|
+
}
|
|
39025
|
+
};
|
|
39026
|
+
var scan = (input, options) => {
|
|
39027
|
+
const opts = options || {};
|
|
39028
|
+
const length = input.length - 1;
|
|
39029
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
39030
|
+
const slashes = [];
|
|
39031
|
+
const tokens = [];
|
|
39032
|
+
const parts2 = [];
|
|
39033
|
+
let str = input;
|
|
39034
|
+
let index = -1;
|
|
39035
|
+
let start2 = 0;
|
|
39036
|
+
let lastIndex = 0;
|
|
39037
|
+
let isBrace = false;
|
|
39038
|
+
let isBracket = false;
|
|
39039
|
+
let isGlob = false;
|
|
39040
|
+
let isExtglob = false;
|
|
39041
|
+
let isGlobstar = false;
|
|
39042
|
+
let braceEscaped = false;
|
|
39043
|
+
let backslashes = false;
|
|
39044
|
+
let negated = false;
|
|
39045
|
+
let negatedExtglob = false;
|
|
39046
|
+
let finished = false;
|
|
39047
|
+
let braces = 0;
|
|
39048
|
+
let prev;
|
|
39049
|
+
let code;
|
|
39050
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
39051
|
+
const eos = () => index >= length;
|
|
39052
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
39053
|
+
const advance = () => {
|
|
39054
|
+
prev = code;
|
|
39055
|
+
return str.charCodeAt(++index);
|
|
39056
|
+
};
|
|
39057
|
+
while (index < length) {
|
|
39058
|
+
code = advance();
|
|
39059
|
+
let next;
|
|
39060
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
39061
|
+
backslashes = token.backslashes = true;
|
|
39062
|
+
code = advance();
|
|
39063
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
39064
|
+
braceEscaped = true;
|
|
39065
|
+
}
|
|
39066
|
+
continue;
|
|
39067
|
+
}
|
|
39068
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
39069
|
+
braces++;
|
|
39070
|
+
while (eos() !== true && (code = advance())) {
|
|
39071
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
39072
|
+
backslashes = token.backslashes = true;
|
|
39073
|
+
advance();
|
|
39074
|
+
continue;
|
|
39075
|
+
}
|
|
39076
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
39077
|
+
braces++;
|
|
39078
|
+
continue;
|
|
39079
|
+
}
|
|
39080
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
39081
|
+
isBrace = token.isBrace = true;
|
|
39082
|
+
isGlob = token.isGlob = true;
|
|
39083
|
+
finished = true;
|
|
39084
|
+
if (scanToEnd === true) {
|
|
39085
|
+
continue;
|
|
39086
|
+
}
|
|
39087
|
+
break;
|
|
39088
|
+
}
|
|
39089
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
39090
|
+
isBrace = token.isBrace = true;
|
|
39091
|
+
isGlob = token.isGlob = true;
|
|
39092
|
+
finished = true;
|
|
39093
|
+
if (scanToEnd === true) {
|
|
39094
|
+
continue;
|
|
39095
|
+
}
|
|
39096
|
+
break;
|
|
39097
|
+
}
|
|
39098
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
39099
|
+
braces--;
|
|
39100
|
+
if (braces === 0) {
|
|
39101
|
+
braceEscaped = false;
|
|
39102
|
+
isBrace = token.isBrace = true;
|
|
39103
|
+
finished = true;
|
|
39104
|
+
break;
|
|
39105
|
+
}
|
|
39106
|
+
}
|
|
39107
|
+
}
|
|
39108
|
+
if (scanToEnd === true) {
|
|
39109
|
+
continue;
|
|
39110
|
+
}
|
|
39111
|
+
break;
|
|
39112
|
+
}
|
|
39113
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
39114
|
+
slashes.push(index);
|
|
39115
|
+
tokens.push(token);
|
|
39116
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
39117
|
+
if (finished === true)
|
|
39118
|
+
continue;
|
|
39119
|
+
if (prev === CHAR_DOT && index === start2 + 1) {
|
|
39120
|
+
start2 += 2;
|
|
39121
|
+
continue;
|
|
39122
|
+
}
|
|
39123
|
+
lastIndex = index + 1;
|
|
39124
|
+
continue;
|
|
39125
|
+
}
|
|
39126
|
+
if (opts.noext !== true) {
|
|
39127
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
39128
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
39129
|
+
isGlob = token.isGlob = true;
|
|
39130
|
+
isExtglob = token.isExtglob = true;
|
|
39131
|
+
finished = true;
|
|
39132
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start2) {
|
|
39133
|
+
negatedExtglob = true;
|
|
39134
|
+
}
|
|
39135
|
+
if (scanToEnd === true) {
|
|
39136
|
+
while (eos() !== true && (code = advance())) {
|
|
39137
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
39138
|
+
backslashes = token.backslashes = true;
|
|
39139
|
+
code = advance();
|
|
39140
|
+
continue;
|
|
39141
|
+
}
|
|
39142
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
39143
|
+
isGlob = token.isGlob = true;
|
|
39144
|
+
finished = true;
|
|
39145
|
+
break;
|
|
39146
|
+
}
|
|
39147
|
+
}
|
|
39148
|
+
continue;
|
|
39149
|
+
}
|
|
39150
|
+
break;
|
|
39151
|
+
}
|
|
39152
|
+
}
|
|
39153
|
+
if (code === CHAR_ASTERISK) {
|
|
39154
|
+
if (prev === CHAR_ASTERISK)
|
|
39155
|
+
isGlobstar = token.isGlobstar = true;
|
|
39156
|
+
isGlob = token.isGlob = true;
|
|
39157
|
+
finished = true;
|
|
39158
|
+
if (scanToEnd === true) {
|
|
39159
|
+
continue;
|
|
39160
|
+
}
|
|
39161
|
+
break;
|
|
39162
|
+
}
|
|
39163
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
39164
|
+
isGlob = token.isGlob = true;
|
|
39165
|
+
finished = true;
|
|
39166
|
+
if (scanToEnd === true) {
|
|
39167
|
+
continue;
|
|
39168
|
+
}
|
|
39169
|
+
break;
|
|
39170
|
+
}
|
|
39171
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
39172
|
+
while (eos() !== true && (next = advance())) {
|
|
39173
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
39174
|
+
backslashes = token.backslashes = true;
|
|
39175
|
+
advance();
|
|
39176
|
+
continue;
|
|
39177
|
+
}
|
|
39178
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
39179
|
+
isBracket = token.isBracket = true;
|
|
39180
|
+
isGlob = token.isGlob = true;
|
|
39181
|
+
finished = true;
|
|
39182
|
+
break;
|
|
39183
|
+
}
|
|
39184
|
+
}
|
|
39185
|
+
if (scanToEnd === true) {
|
|
39186
|
+
continue;
|
|
39187
|
+
}
|
|
39188
|
+
break;
|
|
39189
|
+
}
|
|
39190
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start2) {
|
|
39191
|
+
negated = token.negated = true;
|
|
39192
|
+
start2++;
|
|
39193
|
+
continue;
|
|
39194
|
+
}
|
|
39195
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
39196
|
+
isGlob = token.isGlob = true;
|
|
39197
|
+
if (scanToEnd === true) {
|
|
39198
|
+
while (eos() !== true && (code = advance())) {
|
|
39199
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
39200
|
+
backslashes = token.backslashes = true;
|
|
39201
|
+
code = advance();
|
|
39202
|
+
continue;
|
|
39203
|
+
}
|
|
39204
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
39205
|
+
finished = true;
|
|
39206
|
+
break;
|
|
39207
|
+
}
|
|
39208
|
+
}
|
|
39209
|
+
continue;
|
|
39210
|
+
}
|
|
39211
|
+
break;
|
|
39212
|
+
}
|
|
39213
|
+
if (isGlob === true) {
|
|
39214
|
+
finished = true;
|
|
39215
|
+
if (scanToEnd === true) {
|
|
39216
|
+
continue;
|
|
39217
|
+
}
|
|
39218
|
+
break;
|
|
39219
|
+
}
|
|
39220
|
+
}
|
|
39221
|
+
if (opts.noext === true) {
|
|
39222
|
+
isExtglob = false;
|
|
39223
|
+
isGlob = false;
|
|
39224
|
+
}
|
|
39225
|
+
let base = str;
|
|
39226
|
+
let prefix = "";
|
|
39227
|
+
let glob = "";
|
|
39228
|
+
if (start2 > 0) {
|
|
39229
|
+
prefix = str.slice(0, start2);
|
|
39230
|
+
str = str.slice(start2);
|
|
39231
|
+
lastIndex -= start2;
|
|
39232
|
+
}
|
|
39233
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
39234
|
+
base = str.slice(0, lastIndex);
|
|
39235
|
+
glob = str.slice(lastIndex);
|
|
39236
|
+
} else if (isGlob === true) {
|
|
39237
|
+
base = "";
|
|
39238
|
+
glob = str;
|
|
39239
|
+
} else {
|
|
39240
|
+
base = str;
|
|
39241
|
+
}
|
|
39242
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
39243
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
39244
|
+
base = base.slice(0, -1);
|
|
39245
|
+
}
|
|
39246
|
+
}
|
|
39247
|
+
if (opts.unescape === true) {
|
|
39248
|
+
if (glob)
|
|
39249
|
+
glob = utils.removeBackslashes(glob);
|
|
39250
|
+
if (base && backslashes === true) {
|
|
39251
|
+
base = utils.removeBackslashes(base);
|
|
39252
|
+
}
|
|
39253
|
+
}
|
|
39254
|
+
const state = {
|
|
39255
|
+
prefix,
|
|
39256
|
+
input,
|
|
39257
|
+
start: start2,
|
|
39258
|
+
base,
|
|
39259
|
+
glob,
|
|
39260
|
+
isBrace,
|
|
39261
|
+
isBracket,
|
|
39262
|
+
isGlob,
|
|
39263
|
+
isExtglob,
|
|
39264
|
+
isGlobstar,
|
|
39265
|
+
negated,
|
|
39266
|
+
negatedExtglob
|
|
39267
|
+
};
|
|
39268
|
+
if (opts.tokens === true) {
|
|
39269
|
+
state.maxDepth = 0;
|
|
39270
|
+
if (!isPathSeparator(code)) {
|
|
39271
|
+
tokens.push(token);
|
|
39272
|
+
}
|
|
39273
|
+
state.tokens = tokens;
|
|
39274
|
+
}
|
|
39275
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
39276
|
+
let prevIndex;
|
|
39277
|
+
for (let idx = 0;idx < slashes.length; idx++) {
|
|
39278
|
+
const n = prevIndex ? prevIndex + 1 : start2;
|
|
39279
|
+
const i2 = slashes[idx];
|
|
39280
|
+
const value = input.slice(n, i2);
|
|
39281
|
+
if (opts.tokens) {
|
|
39282
|
+
if (idx === 0 && start2 !== 0) {
|
|
39283
|
+
tokens[idx].isPrefix = true;
|
|
39284
|
+
tokens[idx].value = prefix;
|
|
39285
|
+
} else {
|
|
39286
|
+
tokens[idx].value = value;
|
|
39287
|
+
}
|
|
39288
|
+
depth(tokens[idx]);
|
|
39289
|
+
state.maxDepth += tokens[idx].depth;
|
|
39290
|
+
}
|
|
39291
|
+
if (idx !== 0 || value !== "") {
|
|
39292
|
+
parts2.push(value);
|
|
39293
|
+
}
|
|
39294
|
+
prevIndex = i2;
|
|
39295
|
+
}
|
|
39296
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
39297
|
+
const value = input.slice(prevIndex + 1);
|
|
39298
|
+
parts2.push(value);
|
|
39299
|
+
if (opts.tokens) {
|
|
39300
|
+
tokens[tokens.length - 1].value = value;
|
|
39301
|
+
depth(tokens[tokens.length - 1]);
|
|
39302
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
39303
|
+
}
|
|
39304
|
+
}
|
|
39305
|
+
state.slashes = slashes;
|
|
39306
|
+
state.parts = parts2;
|
|
39307
|
+
}
|
|
39308
|
+
return state;
|
|
39309
|
+
};
|
|
39310
|
+
module2.exports = scan;
|
|
39311
|
+
});
|
|
39312
|
+
|
|
39313
|
+
// node_modules/picomatch/lib/parse.js
|
|
39314
|
+
var require_parse = __commonJS((exports, module2) => {
|
|
39315
|
+
var constants2 = require_constants();
|
|
39316
|
+
var utils = require_utils();
|
|
39317
|
+
var {
|
|
39318
|
+
MAX_LENGTH,
|
|
39319
|
+
POSIX_REGEX_SOURCE,
|
|
39320
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
39321
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
39322
|
+
REPLACEMENTS
|
|
39323
|
+
} = constants2;
|
|
39324
|
+
var expandRange = (args2, options) => {
|
|
39325
|
+
if (typeof options.expandRange === "function") {
|
|
39326
|
+
return options.expandRange(...args2, options);
|
|
39327
|
+
}
|
|
39328
|
+
args2.sort();
|
|
39329
|
+
const value = `[${args2.join("-")}]`;
|
|
39330
|
+
try {
|
|
39331
|
+
new RegExp(value);
|
|
39332
|
+
} catch (ex) {
|
|
39333
|
+
return args2.map((v) => utils.escapeRegex(v)).join("..");
|
|
39334
|
+
}
|
|
39335
|
+
return value;
|
|
39336
|
+
};
|
|
39337
|
+
var syntaxError = (type, char) => {
|
|
39338
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
39339
|
+
};
|
|
39340
|
+
var splitTopLevel = (input) => {
|
|
39341
|
+
const parts2 = [];
|
|
39342
|
+
let bracket = 0;
|
|
39343
|
+
let paren = 0;
|
|
39344
|
+
let quote = 0;
|
|
39345
|
+
let value = "";
|
|
39346
|
+
let escaped = false;
|
|
39347
|
+
for (const ch of input) {
|
|
39348
|
+
if (escaped === true) {
|
|
39349
|
+
value += ch;
|
|
39350
|
+
escaped = false;
|
|
39351
|
+
continue;
|
|
39352
|
+
}
|
|
39353
|
+
if (ch === "\\") {
|
|
39354
|
+
value += ch;
|
|
39355
|
+
escaped = true;
|
|
39356
|
+
continue;
|
|
39357
|
+
}
|
|
39358
|
+
if (ch === '"') {
|
|
39359
|
+
quote = quote === 1 ? 0 : 1;
|
|
39360
|
+
value += ch;
|
|
39361
|
+
continue;
|
|
39362
|
+
}
|
|
39363
|
+
if (quote === 0) {
|
|
39364
|
+
if (ch === "[") {
|
|
39365
|
+
bracket++;
|
|
39366
|
+
} else if (ch === "]" && bracket > 0) {
|
|
39367
|
+
bracket--;
|
|
39368
|
+
} else if (bracket === 0) {
|
|
39369
|
+
if (ch === "(") {
|
|
39370
|
+
paren++;
|
|
39371
|
+
} else if (ch === ")" && paren > 0) {
|
|
39372
|
+
paren--;
|
|
39373
|
+
} else if (ch === "|" && paren === 0) {
|
|
39374
|
+
parts2.push(value);
|
|
39375
|
+
value = "";
|
|
39376
|
+
continue;
|
|
39377
|
+
}
|
|
39378
|
+
}
|
|
39379
|
+
}
|
|
39380
|
+
value += ch;
|
|
39381
|
+
}
|
|
39382
|
+
parts2.push(value);
|
|
39383
|
+
return parts2;
|
|
39384
|
+
};
|
|
39385
|
+
var isPlainBranch = (branch) => {
|
|
39386
|
+
let escaped = false;
|
|
39387
|
+
for (const ch of branch) {
|
|
39388
|
+
if (escaped === true) {
|
|
39389
|
+
escaped = false;
|
|
39390
|
+
continue;
|
|
39391
|
+
}
|
|
39392
|
+
if (ch === "\\") {
|
|
39393
|
+
escaped = true;
|
|
39394
|
+
continue;
|
|
39395
|
+
}
|
|
39396
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
39397
|
+
return false;
|
|
39398
|
+
}
|
|
39399
|
+
}
|
|
39400
|
+
return true;
|
|
39401
|
+
};
|
|
39402
|
+
var normalizeSimpleBranch = (branch) => {
|
|
39403
|
+
let value = branch.trim();
|
|
39404
|
+
let changed = true;
|
|
39405
|
+
while (changed === true) {
|
|
39406
|
+
changed = false;
|
|
39407
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
39408
|
+
value = value.slice(2, -1);
|
|
39409
|
+
changed = true;
|
|
39410
|
+
}
|
|
39411
|
+
}
|
|
39412
|
+
if (!isPlainBranch(value)) {
|
|
39413
|
+
return;
|
|
39414
|
+
}
|
|
39415
|
+
return value.replace(/\\(.)/g, "$1");
|
|
39416
|
+
};
|
|
39417
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
39418
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
39419
|
+
for (let i2 = 0;i2 < values.length; i2++) {
|
|
39420
|
+
for (let j = i2 + 1;j < values.length; j++) {
|
|
39421
|
+
const a = values[i2];
|
|
39422
|
+
const b = values[j];
|
|
39423
|
+
const char = a[0];
|
|
39424
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
39425
|
+
continue;
|
|
39426
|
+
}
|
|
39427
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
39428
|
+
return true;
|
|
39429
|
+
}
|
|
39430
|
+
}
|
|
39431
|
+
}
|
|
39432
|
+
return false;
|
|
39433
|
+
};
|
|
39434
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
39435
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
39436
|
+
return;
|
|
39437
|
+
}
|
|
39438
|
+
let bracket = 0;
|
|
39439
|
+
let paren = 0;
|
|
39440
|
+
let quote = 0;
|
|
39441
|
+
let escaped = false;
|
|
39442
|
+
for (let i2 = 1;i2 < pattern.length; i2++) {
|
|
39443
|
+
const ch = pattern[i2];
|
|
39444
|
+
if (escaped === true) {
|
|
39445
|
+
escaped = false;
|
|
39446
|
+
continue;
|
|
39447
|
+
}
|
|
39448
|
+
if (ch === "\\") {
|
|
39449
|
+
escaped = true;
|
|
39450
|
+
continue;
|
|
39451
|
+
}
|
|
39452
|
+
if (ch === '"') {
|
|
39453
|
+
quote = quote === 1 ? 0 : 1;
|
|
39454
|
+
continue;
|
|
39455
|
+
}
|
|
39456
|
+
if (quote === 1) {
|
|
39457
|
+
continue;
|
|
39458
|
+
}
|
|
39459
|
+
if (ch === "[") {
|
|
39460
|
+
bracket++;
|
|
39461
|
+
continue;
|
|
39462
|
+
}
|
|
39463
|
+
if (ch === "]" && bracket > 0) {
|
|
39464
|
+
bracket--;
|
|
39465
|
+
continue;
|
|
39466
|
+
}
|
|
39467
|
+
if (bracket > 0) {
|
|
39468
|
+
continue;
|
|
39469
|
+
}
|
|
39470
|
+
if (ch === "(") {
|
|
39471
|
+
paren++;
|
|
39472
|
+
continue;
|
|
39473
|
+
}
|
|
39474
|
+
if (ch === ")") {
|
|
39475
|
+
paren--;
|
|
39476
|
+
if (paren === 0) {
|
|
39477
|
+
if (requireEnd === true && i2 !== pattern.length - 1) {
|
|
39478
|
+
return;
|
|
39479
|
+
}
|
|
39480
|
+
return {
|
|
39481
|
+
type: pattern[0],
|
|
39482
|
+
body: pattern.slice(2, i2),
|
|
39483
|
+
end: i2
|
|
39484
|
+
};
|
|
39485
|
+
}
|
|
39486
|
+
}
|
|
39487
|
+
}
|
|
39488
|
+
};
|
|
39489
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
39490
|
+
let index = 0;
|
|
39491
|
+
const chars = [];
|
|
39492
|
+
while (index < pattern.length) {
|
|
39493
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
39494
|
+
if (!match || match.type !== "*") {
|
|
39495
|
+
return;
|
|
39496
|
+
}
|
|
39497
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
39498
|
+
if (branches.length !== 1) {
|
|
39499
|
+
return;
|
|
39500
|
+
}
|
|
39501
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
39502
|
+
if (!branch || branch.length !== 1) {
|
|
39503
|
+
return;
|
|
39504
|
+
}
|
|
39505
|
+
chars.push(branch);
|
|
39506
|
+
index += match.end + 1;
|
|
39507
|
+
}
|
|
39508
|
+
if (chars.length < 1) {
|
|
39509
|
+
return;
|
|
39510
|
+
}
|
|
39511
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
39512
|
+
return `${source}*`;
|
|
39513
|
+
};
|
|
39514
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
39515
|
+
let depth = 0;
|
|
39516
|
+
let value = pattern.trim();
|
|
39517
|
+
let match = parseRepeatedExtglob(value);
|
|
39518
|
+
while (match) {
|
|
39519
|
+
depth++;
|
|
39520
|
+
value = match.body.trim();
|
|
39521
|
+
match = parseRepeatedExtglob(value);
|
|
39522
|
+
}
|
|
39523
|
+
return depth;
|
|
39524
|
+
};
|
|
39525
|
+
var analyzeRepeatedExtglob = (body2, options) => {
|
|
39526
|
+
if (options.maxExtglobRecursion === false) {
|
|
39527
|
+
return { risky: false };
|
|
39528
|
+
}
|
|
39529
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants2.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
39530
|
+
const branches = splitTopLevel(body2).map((branch) => branch.trim());
|
|
39531
|
+
if (branches.length > 1) {
|
|
39532
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
39533
|
+
return { risky: true };
|
|
39534
|
+
}
|
|
39535
|
+
}
|
|
39536
|
+
for (const branch of branches) {
|
|
39537
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
39538
|
+
if (safeOutput) {
|
|
39539
|
+
return { risky: true, safeOutput };
|
|
39540
|
+
}
|
|
39541
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
39542
|
+
return { risky: true };
|
|
39543
|
+
}
|
|
39544
|
+
}
|
|
39545
|
+
return { risky: false };
|
|
39546
|
+
};
|
|
39547
|
+
var parse9 = (input, options) => {
|
|
39548
|
+
if (typeof input !== "string") {
|
|
39549
|
+
throw new TypeError("Expected a string");
|
|
39550
|
+
}
|
|
39551
|
+
input = REPLACEMENTS[input] || input;
|
|
39552
|
+
const opts = { ...options };
|
|
39553
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
39554
|
+
let len = input.length;
|
|
39555
|
+
if (len > max) {
|
|
39556
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
39557
|
+
}
|
|
39558
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
39559
|
+
const tokens = [bos];
|
|
39560
|
+
const capture = opts.capture ? "" : "?:";
|
|
39561
|
+
const PLATFORM_CHARS = constants2.globChars(opts.windows);
|
|
39562
|
+
const EXTGLOB_CHARS = constants2.extglobChars(PLATFORM_CHARS);
|
|
39563
|
+
const {
|
|
39564
|
+
DOT_LITERAL,
|
|
39565
|
+
PLUS_LITERAL,
|
|
39566
|
+
SLASH_LITERAL,
|
|
39567
|
+
ONE_CHAR,
|
|
39568
|
+
DOTS_SLASH,
|
|
39569
|
+
NO_DOT,
|
|
39570
|
+
NO_DOT_SLASH,
|
|
39571
|
+
NO_DOTS_SLASH,
|
|
39572
|
+
QMARK,
|
|
39573
|
+
QMARK_NO_DOT,
|
|
39574
|
+
STAR,
|
|
39575
|
+
START_ANCHOR
|
|
39576
|
+
} = PLATFORM_CHARS;
|
|
39577
|
+
const globstar = (opts2) => {
|
|
39578
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
39579
|
+
};
|
|
39580
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
39581
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
39582
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
39583
|
+
if (opts.capture) {
|
|
39584
|
+
star = `(${star})`;
|
|
39585
|
+
}
|
|
39586
|
+
if (typeof opts.noext === "boolean") {
|
|
39587
|
+
opts.noextglob = opts.noext;
|
|
39588
|
+
}
|
|
39589
|
+
const state = {
|
|
39590
|
+
input,
|
|
39591
|
+
index: -1,
|
|
39592
|
+
start: 0,
|
|
39593
|
+
dot: opts.dot === true,
|
|
39594
|
+
consumed: "",
|
|
39595
|
+
output: "",
|
|
39596
|
+
prefix: "",
|
|
39597
|
+
backtrack: false,
|
|
39598
|
+
negated: false,
|
|
39599
|
+
brackets: 0,
|
|
39600
|
+
braces: 0,
|
|
39601
|
+
parens: 0,
|
|
39602
|
+
quotes: 0,
|
|
39603
|
+
globstar: false,
|
|
39604
|
+
tokens
|
|
39605
|
+
};
|
|
39606
|
+
input = utils.removePrefix(input, state);
|
|
39607
|
+
len = input.length;
|
|
39608
|
+
const extglobs = [];
|
|
39609
|
+
const braces = [];
|
|
39610
|
+
const stack = [];
|
|
39611
|
+
let prev = bos;
|
|
39612
|
+
let value;
|
|
39613
|
+
const eos = () => state.index === len - 1;
|
|
39614
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
39615
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
39616
|
+
const remaining = () => input.slice(state.index + 1);
|
|
39617
|
+
const consume = (value2 = "", num = 0) => {
|
|
39618
|
+
state.consumed += value2;
|
|
39619
|
+
state.index += num;
|
|
39620
|
+
};
|
|
39621
|
+
const append = (token) => {
|
|
39622
|
+
state.output += token.output != null ? token.output : token.value;
|
|
39623
|
+
consume(token.value);
|
|
39624
|
+
};
|
|
39625
|
+
const negate = () => {
|
|
39626
|
+
let count = 1;
|
|
39627
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
39628
|
+
advance();
|
|
39629
|
+
state.start++;
|
|
39630
|
+
count++;
|
|
39631
|
+
}
|
|
39632
|
+
if (count % 2 === 0) {
|
|
39633
|
+
return false;
|
|
39634
|
+
}
|
|
39635
|
+
state.negated = true;
|
|
39636
|
+
state.start++;
|
|
39637
|
+
return true;
|
|
39638
|
+
};
|
|
39639
|
+
const increment = (type) => {
|
|
39640
|
+
state[type]++;
|
|
39641
|
+
stack.push(type);
|
|
39642
|
+
};
|
|
39643
|
+
const decrement = (type) => {
|
|
39644
|
+
state[type]--;
|
|
39645
|
+
stack.pop();
|
|
39646
|
+
};
|
|
39647
|
+
const push = (tok) => {
|
|
39648
|
+
if (prev.type === "globstar") {
|
|
39649
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
39650
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
39651
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
39652
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
39653
|
+
prev.type = "star";
|
|
39654
|
+
prev.value = "*";
|
|
39655
|
+
prev.output = star;
|
|
39656
|
+
state.output += prev.output;
|
|
39657
|
+
}
|
|
39658
|
+
}
|
|
39659
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
39660
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
39661
|
+
}
|
|
39662
|
+
if (tok.value || tok.output)
|
|
39663
|
+
append(tok);
|
|
39664
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
39665
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
39666
|
+
prev.value += tok.value;
|
|
39667
|
+
return;
|
|
39668
|
+
}
|
|
39669
|
+
tok.prev = prev;
|
|
39670
|
+
tokens.push(tok);
|
|
39671
|
+
prev = tok;
|
|
39672
|
+
};
|
|
39673
|
+
const extglobOpen = (type, value2) => {
|
|
39674
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
39675
|
+
token.prev = prev;
|
|
39676
|
+
token.parens = state.parens;
|
|
39677
|
+
token.output = state.output;
|
|
39678
|
+
token.startIndex = state.index;
|
|
39679
|
+
token.tokensIndex = tokens.length;
|
|
39680
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
39681
|
+
increment("parens");
|
|
39682
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
39683
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
39684
|
+
extglobs.push(token);
|
|
39685
|
+
};
|
|
39686
|
+
const extglobClose = (token) => {
|
|
39687
|
+
const literal3 = input.slice(token.startIndex, state.index + 1);
|
|
39688
|
+
const body2 = input.slice(token.startIndex + 2, state.index);
|
|
39689
|
+
const analysis = analyzeRepeatedExtglob(body2, opts);
|
|
39690
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
39691
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
|
|
39692
|
+
const open = tokens[token.tokensIndex];
|
|
39693
|
+
open.type = "text";
|
|
39694
|
+
open.value = literal3;
|
|
39695
|
+
open.output = safeOutput || utils.escapeRegex(literal3);
|
|
39696
|
+
for (let i2 = token.tokensIndex + 1;i2 < tokens.length; i2++) {
|
|
39697
|
+
tokens[i2].value = "";
|
|
39698
|
+
tokens[i2].output = "";
|
|
39699
|
+
delete tokens[i2].suffix;
|
|
39700
|
+
}
|
|
39701
|
+
state.output = token.output + open.output;
|
|
39702
|
+
state.backtrack = true;
|
|
39703
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
39704
|
+
decrement("parens");
|
|
39705
|
+
return;
|
|
39706
|
+
}
|
|
39707
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
39708
|
+
let rest;
|
|
39709
|
+
if (token.type === "negate") {
|
|
39710
|
+
let extglobStar = star;
|
|
39711
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
39712
|
+
extglobStar = globstar(opts);
|
|
39713
|
+
}
|
|
39714
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
39715
|
+
output = token.close = `)$))${extglobStar}`;
|
|
39716
|
+
}
|
|
39717
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
39718
|
+
const expression = parse9(rest, { ...options, fastpaths: false }).output;
|
|
39719
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
39720
|
+
}
|
|
39721
|
+
if (token.prev.type === "bos") {
|
|
39722
|
+
state.negatedExtglob = true;
|
|
39723
|
+
}
|
|
39724
|
+
}
|
|
39725
|
+
push({ type: "paren", extglob: true, value, output });
|
|
39726
|
+
decrement("parens");
|
|
39727
|
+
};
|
|
39728
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
39729
|
+
let backslashes = false;
|
|
39730
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc3, chars, first, rest, index) => {
|
|
39731
|
+
if (first === "\\") {
|
|
39732
|
+
backslashes = true;
|
|
39733
|
+
return m;
|
|
39734
|
+
}
|
|
39735
|
+
if (first === "?") {
|
|
39736
|
+
if (esc3) {
|
|
39737
|
+
return esc3 + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
39738
|
+
}
|
|
39739
|
+
if (index === 0) {
|
|
39740
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
39741
|
+
}
|
|
39742
|
+
return QMARK.repeat(chars.length);
|
|
39743
|
+
}
|
|
39744
|
+
if (first === ".") {
|
|
39745
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
39746
|
+
}
|
|
39747
|
+
if (first === "*") {
|
|
39748
|
+
if (esc3) {
|
|
39749
|
+
return esc3 + first + (rest ? star : "");
|
|
39750
|
+
}
|
|
39751
|
+
return star;
|
|
39752
|
+
}
|
|
39753
|
+
return esc3 ? m : `\\${m}`;
|
|
39754
|
+
});
|
|
39755
|
+
if (backslashes === true) {
|
|
39756
|
+
if (opts.unescape === true) {
|
|
39757
|
+
output = output.replace(/\\/g, "");
|
|
39758
|
+
} else {
|
|
39759
|
+
output = output.replace(/\\+/g, (m) => {
|
|
39760
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
39761
|
+
});
|
|
39762
|
+
}
|
|
39763
|
+
}
|
|
39764
|
+
if (output === input && opts.contains === true) {
|
|
39765
|
+
state.output = input;
|
|
39766
|
+
return state;
|
|
39767
|
+
}
|
|
39768
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
39769
|
+
return state;
|
|
39770
|
+
}
|
|
39771
|
+
while (!eos()) {
|
|
39772
|
+
value = advance();
|
|
39773
|
+
if (value === "\x00") {
|
|
39774
|
+
continue;
|
|
39775
|
+
}
|
|
39776
|
+
if (value === "\\") {
|
|
39777
|
+
const next = peek();
|
|
39778
|
+
if (next === "/" && opts.bash !== true) {
|
|
39779
|
+
continue;
|
|
39780
|
+
}
|
|
39781
|
+
if (next === "." || next === ";") {
|
|
39782
|
+
continue;
|
|
39783
|
+
}
|
|
39784
|
+
if (!next) {
|
|
39785
|
+
value += "\\";
|
|
39786
|
+
push({ type: "text", value });
|
|
39787
|
+
continue;
|
|
39788
|
+
}
|
|
39789
|
+
const match = /^\\+/.exec(remaining());
|
|
39790
|
+
let slashes = 0;
|
|
39791
|
+
if (match && match[0].length > 2) {
|
|
39792
|
+
slashes = match[0].length;
|
|
39793
|
+
state.index += slashes;
|
|
39794
|
+
if (slashes % 2 !== 0) {
|
|
39795
|
+
value += "\\";
|
|
39796
|
+
}
|
|
39797
|
+
}
|
|
39798
|
+
if (opts.unescape === true) {
|
|
39799
|
+
value = advance();
|
|
39800
|
+
} else {
|
|
39801
|
+
value += advance();
|
|
39802
|
+
}
|
|
39803
|
+
if (state.brackets === 0) {
|
|
39804
|
+
push({ type: "text", value });
|
|
39805
|
+
continue;
|
|
39806
|
+
}
|
|
39807
|
+
}
|
|
39808
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
39809
|
+
if (opts.posix !== false && value === ":") {
|
|
39810
|
+
const inner = prev.value.slice(1);
|
|
39811
|
+
if (inner.includes("[")) {
|
|
39812
|
+
prev.posix = true;
|
|
39813
|
+
if (inner.includes(":")) {
|
|
39814
|
+
const idx = prev.value.lastIndexOf("[");
|
|
39815
|
+
const pre = prev.value.slice(0, idx);
|
|
39816
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
39817
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
39818
|
+
if (posix) {
|
|
39819
|
+
prev.value = pre + posix;
|
|
39820
|
+
state.backtrack = true;
|
|
39821
|
+
advance();
|
|
39822
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
39823
|
+
bos.output = ONE_CHAR;
|
|
39824
|
+
}
|
|
39825
|
+
continue;
|
|
39826
|
+
}
|
|
39827
|
+
}
|
|
39828
|
+
}
|
|
39829
|
+
}
|
|
39830
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
39831
|
+
value = `\\${value}`;
|
|
39832
|
+
}
|
|
39833
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
39834
|
+
value = `\\${value}`;
|
|
39835
|
+
}
|
|
39836
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
39837
|
+
value = "^";
|
|
39838
|
+
}
|
|
39839
|
+
prev.value += value;
|
|
39840
|
+
append({ value });
|
|
39841
|
+
continue;
|
|
39842
|
+
}
|
|
39843
|
+
if (state.quotes === 1 && value !== '"') {
|
|
39844
|
+
value = utils.escapeRegex(value);
|
|
39845
|
+
prev.value += value;
|
|
39846
|
+
append({ value });
|
|
39847
|
+
continue;
|
|
39848
|
+
}
|
|
39849
|
+
if (value === '"') {
|
|
39850
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
39851
|
+
if (opts.keepQuotes === true) {
|
|
39852
|
+
push({ type: "text", value });
|
|
39853
|
+
}
|
|
39854
|
+
continue;
|
|
39855
|
+
}
|
|
39856
|
+
if (value === "(") {
|
|
39857
|
+
increment("parens");
|
|
39858
|
+
push({ type: "paren", value });
|
|
39859
|
+
continue;
|
|
39860
|
+
}
|
|
39861
|
+
if (value === ")") {
|
|
39862
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
39863
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
39864
|
+
}
|
|
39865
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
39866
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
39867
|
+
extglobClose(extglobs.pop());
|
|
39868
|
+
continue;
|
|
39869
|
+
}
|
|
39870
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
39871
|
+
decrement("parens");
|
|
39872
|
+
continue;
|
|
39873
|
+
}
|
|
39874
|
+
if (value === "[") {
|
|
39875
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
39876
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
39877
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
39878
|
+
}
|
|
39879
|
+
value = `\\${value}`;
|
|
39880
|
+
} else {
|
|
39881
|
+
increment("brackets");
|
|
39882
|
+
}
|
|
39883
|
+
push({ type: "bracket", value });
|
|
39884
|
+
continue;
|
|
39885
|
+
}
|
|
39886
|
+
if (value === "]") {
|
|
39887
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
39888
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
39889
|
+
continue;
|
|
39890
|
+
}
|
|
39891
|
+
if (state.brackets === 0) {
|
|
39892
|
+
if (opts.strictBrackets === true) {
|
|
39893
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
39894
|
+
}
|
|
39895
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
39896
|
+
continue;
|
|
39897
|
+
}
|
|
39898
|
+
decrement("brackets");
|
|
39899
|
+
const prevValue = prev.value.slice(1);
|
|
39900
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
39901
|
+
value = `/${value}`;
|
|
39902
|
+
}
|
|
39903
|
+
prev.value += value;
|
|
39904
|
+
append({ value });
|
|
39905
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
39906
|
+
continue;
|
|
39907
|
+
}
|
|
39908
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
39909
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
39910
|
+
if (opts.literalBrackets === true) {
|
|
39911
|
+
state.output += escaped;
|
|
39912
|
+
prev.value = escaped;
|
|
39913
|
+
continue;
|
|
39914
|
+
}
|
|
39915
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
39916
|
+
state.output += prev.value;
|
|
39917
|
+
continue;
|
|
39918
|
+
}
|
|
39919
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
39920
|
+
increment("braces");
|
|
39921
|
+
const open = {
|
|
39922
|
+
type: "brace",
|
|
39923
|
+
value,
|
|
39924
|
+
output: "(",
|
|
39925
|
+
outputIndex: state.output.length,
|
|
39926
|
+
tokensIndex: state.tokens.length
|
|
39927
|
+
};
|
|
39928
|
+
braces.push(open);
|
|
39929
|
+
push(open);
|
|
39930
|
+
continue;
|
|
39931
|
+
}
|
|
39932
|
+
if (value === "}") {
|
|
39933
|
+
const brace = braces[braces.length - 1];
|
|
39934
|
+
if (opts.nobrace === true || !brace) {
|
|
39935
|
+
push({ type: "text", value, output: value });
|
|
39936
|
+
continue;
|
|
39937
|
+
}
|
|
39938
|
+
let output = ")";
|
|
39939
|
+
if (brace.dots === true) {
|
|
39940
|
+
const arr = tokens.slice();
|
|
39941
|
+
const range = [];
|
|
39942
|
+
for (let i2 = arr.length - 1;i2 >= 0; i2--) {
|
|
39943
|
+
tokens.pop();
|
|
39944
|
+
if (arr[i2].type === "brace") {
|
|
39945
|
+
break;
|
|
39946
|
+
}
|
|
39947
|
+
if (arr[i2].type !== "dots") {
|
|
39948
|
+
range.unshift(arr[i2].value);
|
|
39949
|
+
}
|
|
39950
|
+
}
|
|
39951
|
+
output = expandRange(range, opts);
|
|
39952
|
+
state.backtrack = true;
|
|
39953
|
+
}
|
|
39954
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
39955
|
+
const out2 = state.output.slice(0, brace.outputIndex);
|
|
39956
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
39957
|
+
brace.value = brace.output = "\\{";
|
|
39958
|
+
value = output = "\\}";
|
|
39959
|
+
state.output = out2;
|
|
39960
|
+
for (const t of toks) {
|
|
39961
|
+
state.output += t.output || t.value;
|
|
39962
|
+
}
|
|
39963
|
+
}
|
|
39964
|
+
push({ type: "brace", value, output });
|
|
39965
|
+
decrement("braces");
|
|
39966
|
+
braces.pop();
|
|
39967
|
+
continue;
|
|
39968
|
+
}
|
|
39969
|
+
if (value === "|") {
|
|
39970
|
+
if (extglobs.length > 0) {
|
|
39971
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
39972
|
+
}
|
|
39973
|
+
push({ type: "text", value });
|
|
39974
|
+
continue;
|
|
39975
|
+
}
|
|
39976
|
+
if (value === ",") {
|
|
39977
|
+
let output = value;
|
|
39978
|
+
const brace = braces[braces.length - 1];
|
|
39979
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
39980
|
+
brace.comma = true;
|
|
39981
|
+
output = "|";
|
|
39982
|
+
}
|
|
39983
|
+
push({ type: "comma", value, output });
|
|
39984
|
+
continue;
|
|
39985
|
+
}
|
|
39986
|
+
if (value === "/") {
|
|
39987
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
39988
|
+
state.start = state.index + 1;
|
|
39989
|
+
state.consumed = "";
|
|
39990
|
+
state.output = "";
|
|
39991
|
+
tokens.pop();
|
|
39992
|
+
prev = bos;
|
|
39993
|
+
continue;
|
|
39994
|
+
}
|
|
39995
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
39996
|
+
continue;
|
|
39997
|
+
}
|
|
39998
|
+
if (value === ".") {
|
|
39999
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
40000
|
+
if (prev.value === ".")
|
|
40001
|
+
prev.output = DOT_LITERAL;
|
|
40002
|
+
const brace = braces[braces.length - 1];
|
|
40003
|
+
prev.type = "dots";
|
|
40004
|
+
prev.output += value;
|
|
40005
|
+
prev.value += value;
|
|
40006
|
+
brace.dots = true;
|
|
40007
|
+
continue;
|
|
40008
|
+
}
|
|
40009
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
40010
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
40011
|
+
continue;
|
|
40012
|
+
}
|
|
40013
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
40014
|
+
continue;
|
|
40015
|
+
}
|
|
40016
|
+
if (value === "?") {
|
|
40017
|
+
const isGroup = prev && prev.value === "(";
|
|
40018
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
40019
|
+
extglobOpen("qmark", value);
|
|
40020
|
+
continue;
|
|
40021
|
+
}
|
|
40022
|
+
if (prev && prev.type === "paren") {
|
|
40023
|
+
const next = peek();
|
|
40024
|
+
let output = value;
|
|
40025
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
40026
|
+
output = `\\${value}`;
|
|
40027
|
+
}
|
|
40028
|
+
push({ type: "text", value, output });
|
|
40029
|
+
continue;
|
|
40030
|
+
}
|
|
40031
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
40032
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
40033
|
+
continue;
|
|
40034
|
+
}
|
|
40035
|
+
push({ type: "qmark", value, output: QMARK });
|
|
40036
|
+
continue;
|
|
40037
|
+
}
|
|
40038
|
+
if (value === "!") {
|
|
40039
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
40040
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
40041
|
+
extglobOpen("negate", value);
|
|
40042
|
+
continue;
|
|
40043
|
+
}
|
|
40044
|
+
}
|
|
40045
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
40046
|
+
negate();
|
|
40047
|
+
continue;
|
|
40048
|
+
}
|
|
40049
|
+
}
|
|
40050
|
+
if (value === "+") {
|
|
40051
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
40052
|
+
extglobOpen("plus", value);
|
|
40053
|
+
continue;
|
|
40054
|
+
}
|
|
40055
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
40056
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
40057
|
+
continue;
|
|
40058
|
+
}
|
|
40059
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
40060
|
+
push({ type: "plus", value });
|
|
40061
|
+
continue;
|
|
40062
|
+
}
|
|
40063
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
40064
|
+
continue;
|
|
40065
|
+
}
|
|
40066
|
+
if (value === "@") {
|
|
40067
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
40068
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
40069
|
+
continue;
|
|
40070
|
+
}
|
|
40071
|
+
push({ type: "text", value });
|
|
40072
|
+
continue;
|
|
40073
|
+
}
|
|
40074
|
+
if (value !== "*") {
|
|
40075
|
+
if (value === "$" || value === "^") {
|
|
40076
|
+
value = `\\${value}`;
|
|
40077
|
+
}
|
|
40078
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
40079
|
+
if (match) {
|
|
40080
|
+
value += match[0];
|
|
40081
|
+
state.index += match[0].length;
|
|
40082
|
+
}
|
|
40083
|
+
push({ type: "text", value });
|
|
40084
|
+
continue;
|
|
40085
|
+
}
|
|
40086
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
40087
|
+
prev.type = "star";
|
|
40088
|
+
prev.star = true;
|
|
40089
|
+
prev.value += value;
|
|
40090
|
+
prev.output = star;
|
|
40091
|
+
state.backtrack = true;
|
|
40092
|
+
state.globstar = true;
|
|
40093
|
+
consume(value);
|
|
40094
|
+
continue;
|
|
40095
|
+
}
|
|
40096
|
+
let rest = remaining();
|
|
40097
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
40098
|
+
extglobOpen("star", value);
|
|
40099
|
+
continue;
|
|
40100
|
+
}
|
|
40101
|
+
if (prev.type === "star") {
|
|
40102
|
+
if (opts.noglobstar === true) {
|
|
40103
|
+
consume(value);
|
|
40104
|
+
continue;
|
|
40105
|
+
}
|
|
40106
|
+
const prior = prev.prev;
|
|
40107
|
+
const before = prior.prev;
|
|
40108
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
40109
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
40110
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
40111
|
+
push({ type: "star", value, output: "" });
|
|
40112
|
+
continue;
|
|
40113
|
+
}
|
|
40114
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
40115
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
40116
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
40117
|
+
push({ type: "star", value, output: "" });
|
|
40118
|
+
continue;
|
|
40119
|
+
}
|
|
40120
|
+
while (rest.slice(0, 3) === "/**") {
|
|
40121
|
+
const after = input[state.index + 4];
|
|
40122
|
+
if (after && after !== "/") {
|
|
40123
|
+
break;
|
|
40124
|
+
}
|
|
40125
|
+
rest = rest.slice(3);
|
|
40126
|
+
consume("/**", 3);
|
|
40127
|
+
}
|
|
40128
|
+
if (prior.type === "bos" && eos()) {
|
|
40129
|
+
prev.type = "globstar";
|
|
40130
|
+
prev.value += value;
|
|
40131
|
+
prev.output = globstar(opts);
|
|
40132
|
+
state.output = prev.output;
|
|
40133
|
+
state.globstar = true;
|
|
40134
|
+
consume(value);
|
|
40135
|
+
continue;
|
|
40136
|
+
}
|
|
40137
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
40138
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
40139
|
+
prior.output = `(?:${prior.output}`;
|
|
40140
|
+
prev.type = "globstar";
|
|
40141
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
40142
|
+
prev.value += value;
|
|
40143
|
+
state.globstar = true;
|
|
40144
|
+
state.output += prior.output + prev.output;
|
|
40145
|
+
consume(value);
|
|
40146
|
+
continue;
|
|
40147
|
+
}
|
|
40148
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
40149
|
+
const end = rest[1] !== undefined ? "|$" : "";
|
|
40150
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
40151
|
+
prior.output = `(?:${prior.output}`;
|
|
40152
|
+
prev.type = "globstar";
|
|
40153
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
40154
|
+
prev.value += value;
|
|
40155
|
+
state.output += prior.output + prev.output;
|
|
40156
|
+
state.globstar = true;
|
|
40157
|
+
consume(value + advance());
|
|
40158
|
+
push({ type: "slash", value: "/", output: "" });
|
|
40159
|
+
continue;
|
|
40160
|
+
}
|
|
40161
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
40162
|
+
prev.type = "globstar";
|
|
40163
|
+
prev.value += value;
|
|
40164
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
40165
|
+
state.output = prev.output;
|
|
40166
|
+
state.globstar = true;
|
|
40167
|
+
consume(value + advance());
|
|
40168
|
+
push({ type: "slash", value: "/", output: "" });
|
|
40169
|
+
continue;
|
|
40170
|
+
}
|
|
40171
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
40172
|
+
prev.type = "globstar";
|
|
40173
|
+
prev.output = globstar(opts);
|
|
40174
|
+
prev.value += value;
|
|
40175
|
+
state.output += prev.output;
|
|
40176
|
+
state.globstar = true;
|
|
40177
|
+
consume(value);
|
|
40178
|
+
continue;
|
|
40179
|
+
}
|
|
40180
|
+
const token = { type: "star", value, output: star };
|
|
40181
|
+
if (opts.bash === true) {
|
|
40182
|
+
token.output = ".*?";
|
|
40183
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
40184
|
+
token.output = nodot + token.output;
|
|
40185
|
+
}
|
|
40186
|
+
push(token);
|
|
40187
|
+
continue;
|
|
40188
|
+
}
|
|
40189
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
40190
|
+
token.output = value;
|
|
40191
|
+
push(token);
|
|
40192
|
+
continue;
|
|
40193
|
+
}
|
|
40194
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
40195
|
+
if (prev.type === "dot") {
|
|
40196
|
+
state.output += NO_DOT_SLASH;
|
|
40197
|
+
prev.output += NO_DOT_SLASH;
|
|
40198
|
+
} else if (opts.dot === true) {
|
|
40199
|
+
state.output += NO_DOTS_SLASH;
|
|
40200
|
+
prev.output += NO_DOTS_SLASH;
|
|
40201
|
+
} else {
|
|
40202
|
+
state.output += nodot;
|
|
40203
|
+
prev.output += nodot;
|
|
40204
|
+
}
|
|
40205
|
+
if (peek() !== "*") {
|
|
40206
|
+
state.output += ONE_CHAR;
|
|
40207
|
+
prev.output += ONE_CHAR;
|
|
40208
|
+
}
|
|
40209
|
+
}
|
|
40210
|
+
push(token);
|
|
40211
|
+
}
|
|
40212
|
+
while (state.brackets > 0) {
|
|
40213
|
+
if (opts.strictBrackets === true)
|
|
40214
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
40215
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
40216
|
+
decrement("brackets");
|
|
40217
|
+
}
|
|
40218
|
+
while (state.parens > 0) {
|
|
40219
|
+
if (opts.strictBrackets === true)
|
|
40220
|
+
throw new SyntaxError(syntaxError("closing", ")"));
|
|
40221
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
40222
|
+
decrement("parens");
|
|
40223
|
+
}
|
|
40224
|
+
while (state.braces > 0) {
|
|
40225
|
+
if (opts.strictBrackets === true)
|
|
40226
|
+
throw new SyntaxError(syntaxError("closing", "}"));
|
|
40227
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
40228
|
+
decrement("braces");
|
|
40229
|
+
}
|
|
40230
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
40231
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
40232
|
+
}
|
|
40233
|
+
if (state.backtrack === true) {
|
|
40234
|
+
state.output = "";
|
|
40235
|
+
for (const token of state.tokens) {
|
|
40236
|
+
state.output += token.output != null ? token.output : token.value;
|
|
40237
|
+
if (token.suffix) {
|
|
40238
|
+
state.output += token.suffix;
|
|
40239
|
+
}
|
|
40240
|
+
}
|
|
40241
|
+
}
|
|
40242
|
+
return state;
|
|
40243
|
+
};
|
|
40244
|
+
parse9.fastpaths = (input, options) => {
|
|
40245
|
+
const opts = { ...options };
|
|
40246
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
40247
|
+
const len = input.length;
|
|
40248
|
+
if (len > max) {
|
|
40249
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
40250
|
+
}
|
|
40251
|
+
input = REPLACEMENTS[input] || input;
|
|
40252
|
+
const {
|
|
40253
|
+
DOT_LITERAL,
|
|
40254
|
+
SLASH_LITERAL,
|
|
40255
|
+
ONE_CHAR,
|
|
40256
|
+
DOTS_SLASH,
|
|
40257
|
+
NO_DOT,
|
|
40258
|
+
NO_DOTS,
|
|
40259
|
+
NO_DOTS_SLASH,
|
|
40260
|
+
STAR,
|
|
40261
|
+
START_ANCHOR
|
|
40262
|
+
} = constants2.globChars(opts.windows);
|
|
40263
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
40264
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
40265
|
+
const capture = opts.capture ? "" : "?:";
|
|
40266
|
+
const state = { negated: false, prefix: "" };
|
|
40267
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
40268
|
+
if (opts.capture) {
|
|
40269
|
+
star = `(${star})`;
|
|
40270
|
+
}
|
|
40271
|
+
const globstar = (opts2) => {
|
|
40272
|
+
if (opts2.noglobstar === true)
|
|
40273
|
+
return star;
|
|
40274
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
40275
|
+
};
|
|
40276
|
+
const create = (str) => {
|
|
40277
|
+
switch (str) {
|
|
40278
|
+
case "*":
|
|
40279
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
40280
|
+
case ".*":
|
|
40281
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
40282
|
+
case "*.*":
|
|
40283
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
40284
|
+
case "*/*":
|
|
40285
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
40286
|
+
case "**":
|
|
40287
|
+
return nodot + globstar(opts);
|
|
40288
|
+
case "**/*":
|
|
40289
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
40290
|
+
case "**/*.*":
|
|
40291
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
40292
|
+
case "**/.*":
|
|
40293
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
40294
|
+
default: {
|
|
40295
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
40296
|
+
if (!match)
|
|
40297
|
+
return;
|
|
40298
|
+
const source2 = create(match[1]);
|
|
40299
|
+
if (!source2)
|
|
40300
|
+
return;
|
|
40301
|
+
return source2 + DOT_LITERAL + match[2];
|
|
40302
|
+
}
|
|
40303
|
+
}
|
|
40304
|
+
};
|
|
40305
|
+
const output = utils.removePrefix(input, state);
|
|
40306
|
+
let source = create(output);
|
|
40307
|
+
if (source && opts.strictSlashes !== true) {
|
|
40308
|
+
source += `${SLASH_LITERAL}?`;
|
|
40309
|
+
}
|
|
40310
|
+
return source;
|
|
40311
|
+
};
|
|
40312
|
+
module2.exports = parse9;
|
|
40313
|
+
});
|
|
40314
|
+
|
|
40315
|
+
// node_modules/picomatch/lib/picomatch.js
|
|
40316
|
+
var require_picomatch = __commonJS((exports, module2) => {
|
|
40317
|
+
var scan = require_scan();
|
|
40318
|
+
var parse9 = require_parse();
|
|
40319
|
+
var utils = require_utils();
|
|
40320
|
+
var constants2 = require_constants();
|
|
40321
|
+
var isObject3 = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
40322
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
40323
|
+
if (Array.isArray(glob)) {
|
|
40324
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
40325
|
+
const arrayMatcher = (str) => {
|
|
40326
|
+
for (const isMatch of fns) {
|
|
40327
|
+
const state2 = isMatch(str);
|
|
40328
|
+
if (state2)
|
|
40329
|
+
return state2;
|
|
40330
|
+
}
|
|
40331
|
+
return false;
|
|
40332
|
+
};
|
|
40333
|
+
return arrayMatcher;
|
|
40334
|
+
}
|
|
40335
|
+
const isState = isObject3(glob) && glob.tokens && glob.input;
|
|
40336
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
40337
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
40338
|
+
}
|
|
40339
|
+
const opts = options || {};
|
|
40340
|
+
const posix = opts.windows;
|
|
40341
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
40342
|
+
const state = regex.state;
|
|
40343
|
+
delete regex.state;
|
|
40344
|
+
let isIgnored = () => false;
|
|
40345
|
+
if (opts.ignore) {
|
|
40346
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
40347
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
40348
|
+
}
|
|
40349
|
+
const matcher = (input, returnObject = false) => {
|
|
40350
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
40351
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
40352
|
+
if (typeof opts.onResult === "function") {
|
|
40353
|
+
opts.onResult(result);
|
|
40354
|
+
}
|
|
40355
|
+
if (isMatch === false) {
|
|
40356
|
+
result.isMatch = false;
|
|
40357
|
+
return returnObject ? result : false;
|
|
40358
|
+
}
|
|
40359
|
+
if (isIgnored(input)) {
|
|
40360
|
+
if (typeof opts.onIgnore === "function") {
|
|
40361
|
+
opts.onIgnore(result);
|
|
40362
|
+
}
|
|
40363
|
+
result.isMatch = false;
|
|
40364
|
+
return returnObject ? result : false;
|
|
40365
|
+
}
|
|
40366
|
+
if (typeof opts.onMatch === "function") {
|
|
40367
|
+
opts.onMatch(result);
|
|
40368
|
+
}
|
|
40369
|
+
return returnObject ? result : true;
|
|
40370
|
+
};
|
|
40371
|
+
if (returnState) {
|
|
40372
|
+
matcher.state = state;
|
|
40373
|
+
}
|
|
40374
|
+
return matcher;
|
|
40375
|
+
};
|
|
40376
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
40377
|
+
if (typeof input !== "string") {
|
|
40378
|
+
throw new TypeError("Expected input to be a string");
|
|
40379
|
+
}
|
|
40380
|
+
if (input === "") {
|
|
40381
|
+
return { isMatch: false, output: "" };
|
|
40382
|
+
}
|
|
40383
|
+
const opts = options || {};
|
|
40384
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
40385
|
+
let match = input === glob;
|
|
40386
|
+
let output = match && format ? format(input) : input;
|
|
40387
|
+
if (match === false) {
|
|
40388
|
+
output = format ? format(input) : input;
|
|
40389
|
+
match = output === glob;
|
|
40390
|
+
}
|
|
40391
|
+
if (match === false || opts.capture === true) {
|
|
40392
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
40393
|
+
match = picomatch.matchBase(input, regex, options, posix);
|
|
40394
|
+
} else {
|
|
40395
|
+
match = regex.exec(output);
|
|
40396
|
+
}
|
|
40397
|
+
}
|
|
40398
|
+
return { isMatch: Boolean(match), match, output };
|
|
40399
|
+
};
|
|
40400
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
40401
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
40402
|
+
return regex.test(utils.basename(input));
|
|
40403
|
+
};
|
|
40404
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
40405
|
+
picomatch.parse = (pattern, options) => {
|
|
40406
|
+
if (Array.isArray(pattern))
|
|
40407
|
+
return pattern.map((p) => picomatch.parse(p, options));
|
|
40408
|
+
return parse9(pattern, { ...options, fastpaths: false });
|
|
40409
|
+
};
|
|
40410
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
40411
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
40412
|
+
if (returnOutput === true) {
|
|
40413
|
+
return state.output;
|
|
40414
|
+
}
|
|
40415
|
+
const opts = options || {};
|
|
40416
|
+
const prepend = opts.contains ? "" : "^";
|
|
40417
|
+
const append = opts.contains ? "" : "$";
|
|
40418
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
40419
|
+
if (state && state.negated === true) {
|
|
40420
|
+
source = `^(?!${source}).*$`;
|
|
40421
|
+
}
|
|
40422
|
+
const regex = picomatch.toRegex(source, options);
|
|
40423
|
+
if (returnState === true) {
|
|
40424
|
+
regex.state = state;
|
|
40425
|
+
}
|
|
40426
|
+
return regex;
|
|
40427
|
+
};
|
|
40428
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
40429
|
+
if (!input || typeof input !== "string") {
|
|
40430
|
+
throw new TypeError("Expected a non-empty string");
|
|
40431
|
+
}
|
|
40432
|
+
let parsed = { negated: false, fastpaths: true };
|
|
40433
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
40434
|
+
parsed.output = parse9.fastpaths(input, options);
|
|
40435
|
+
}
|
|
40436
|
+
if (!parsed.output) {
|
|
40437
|
+
parsed = parse9(input, options);
|
|
40438
|
+
}
|
|
40439
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
40440
|
+
};
|
|
40441
|
+
picomatch.toRegex = (source, options) => {
|
|
40442
|
+
try {
|
|
40443
|
+
const opts = options || {};
|
|
40444
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
40445
|
+
} catch (err2) {
|
|
40446
|
+
if (options && options.debug === true)
|
|
40447
|
+
throw err2;
|
|
40448
|
+
return /$^/;
|
|
40449
|
+
}
|
|
40450
|
+
};
|
|
40451
|
+
picomatch.constants = constants2;
|
|
40452
|
+
module2.exports = picomatch;
|
|
40453
|
+
});
|
|
40454
|
+
|
|
40455
|
+
// node_modules/picomatch/index.js
|
|
40456
|
+
var require_picomatch2 = __commonJS((exports, module2) => {
|
|
40457
|
+
var pico = require_picomatch();
|
|
40458
|
+
var utils = require_utils();
|
|
40459
|
+
function picomatch(glob, options, returnState = false) {
|
|
40460
|
+
if (options && (options.windows === null || options.windows === undefined)) {
|
|
40461
|
+
options = { ...options, windows: utils.isWindows() };
|
|
40462
|
+
}
|
|
40463
|
+
return pico(glob, options, returnState);
|
|
40464
|
+
}
|
|
40465
|
+
Object.assign(picomatch, pico);
|
|
40466
|
+
module2.exports = picomatch;
|
|
40467
|
+
});
|
|
40468
|
+
|
|
38787
40469
|
// src/gate-evidence.ts
|
|
38788
40470
|
var exports_gate_evidence = {};
|
|
38789
40471
|
__export(exports_gate_evidence, {
|
|
@@ -54811,7 +56493,283 @@ init_state();
|
|
|
54811
56493
|
init_telemetry();
|
|
54812
56494
|
|
|
54813
56495
|
// src/hooks/guardrails.ts
|
|
56496
|
+
import * as fsSync from "fs";
|
|
56497
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
54814
56498
|
import * as path38 from "path";
|
|
56499
|
+
|
|
56500
|
+
// node_modules/quick-lru/index.js
|
|
56501
|
+
class QuickLRU extends Map {
|
|
56502
|
+
#size = 0;
|
|
56503
|
+
#cache = new Map;
|
|
56504
|
+
#oldCache = new Map;
|
|
56505
|
+
#maxSize;
|
|
56506
|
+
#maxAge;
|
|
56507
|
+
#onEviction;
|
|
56508
|
+
constructor(options = {}) {
|
|
56509
|
+
super();
|
|
56510
|
+
if (!(options.maxSize && options.maxSize > 0)) {
|
|
56511
|
+
throw new TypeError("`maxSize` must be a number greater than 0");
|
|
56512
|
+
}
|
|
56513
|
+
if (typeof options.maxAge === "number" && options.maxAge === 0) {
|
|
56514
|
+
throw new TypeError("`maxAge` must be a number greater than 0");
|
|
56515
|
+
}
|
|
56516
|
+
this.#maxSize = options.maxSize;
|
|
56517
|
+
this.#maxAge = options.maxAge || Number.POSITIVE_INFINITY;
|
|
56518
|
+
this.#onEviction = options.onEviction;
|
|
56519
|
+
}
|
|
56520
|
+
get __oldCache() {
|
|
56521
|
+
return this.#oldCache;
|
|
56522
|
+
}
|
|
56523
|
+
#emitEvictions(cache) {
|
|
56524
|
+
if (typeof this.#onEviction !== "function") {
|
|
56525
|
+
return;
|
|
56526
|
+
}
|
|
56527
|
+
for (const [key, item] of cache) {
|
|
56528
|
+
this.#onEviction(key, item.value);
|
|
56529
|
+
}
|
|
56530
|
+
}
|
|
56531
|
+
#deleteIfExpired(key, item) {
|
|
56532
|
+
if (typeof item.expiry === "number" && item.expiry <= Date.now()) {
|
|
56533
|
+
if (typeof this.#onEviction === "function") {
|
|
56534
|
+
this.#onEviction(key, item.value);
|
|
56535
|
+
}
|
|
56536
|
+
return this.delete(key);
|
|
56537
|
+
}
|
|
56538
|
+
return false;
|
|
56539
|
+
}
|
|
56540
|
+
#getOrDeleteIfExpired(key, item) {
|
|
56541
|
+
const deleted = this.#deleteIfExpired(key, item);
|
|
56542
|
+
if (deleted === false) {
|
|
56543
|
+
return item.value;
|
|
56544
|
+
}
|
|
56545
|
+
}
|
|
56546
|
+
#getItemValue(key, item) {
|
|
56547
|
+
return item.expiry ? this.#getOrDeleteIfExpired(key, item) : item.value;
|
|
56548
|
+
}
|
|
56549
|
+
#peek(key, cache) {
|
|
56550
|
+
const item = cache.get(key);
|
|
56551
|
+
return this.#getItemValue(key, item);
|
|
56552
|
+
}
|
|
56553
|
+
#set(key, value) {
|
|
56554
|
+
this.#cache.set(key, value);
|
|
56555
|
+
this.#size++;
|
|
56556
|
+
if (this.#size >= this.#maxSize) {
|
|
56557
|
+
this.#size = 0;
|
|
56558
|
+
this.#emitEvictions(this.#oldCache);
|
|
56559
|
+
this.#oldCache = this.#cache;
|
|
56560
|
+
this.#cache = new Map;
|
|
56561
|
+
}
|
|
56562
|
+
}
|
|
56563
|
+
#moveToRecent(key, item) {
|
|
56564
|
+
this.#oldCache.delete(key);
|
|
56565
|
+
this.#set(key, item);
|
|
56566
|
+
}
|
|
56567
|
+
*#entriesAscending() {
|
|
56568
|
+
for (const item of this.#oldCache) {
|
|
56569
|
+
const [key, value] = item;
|
|
56570
|
+
if (!this.#cache.has(key)) {
|
|
56571
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
56572
|
+
if (deleted === false) {
|
|
56573
|
+
yield item;
|
|
56574
|
+
}
|
|
56575
|
+
}
|
|
56576
|
+
}
|
|
56577
|
+
for (const item of this.#cache) {
|
|
56578
|
+
const [key, value] = item;
|
|
56579
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
56580
|
+
if (deleted === false) {
|
|
56581
|
+
yield item;
|
|
56582
|
+
}
|
|
56583
|
+
}
|
|
56584
|
+
}
|
|
56585
|
+
get(key) {
|
|
56586
|
+
if (this.#cache.has(key)) {
|
|
56587
|
+
const item = this.#cache.get(key);
|
|
56588
|
+
return this.#getItemValue(key, item);
|
|
56589
|
+
}
|
|
56590
|
+
if (this.#oldCache.has(key)) {
|
|
56591
|
+
const item = this.#oldCache.get(key);
|
|
56592
|
+
if (this.#deleteIfExpired(key, item) === false) {
|
|
56593
|
+
this.#moveToRecent(key, item);
|
|
56594
|
+
return item.value;
|
|
56595
|
+
}
|
|
56596
|
+
}
|
|
56597
|
+
}
|
|
56598
|
+
set(key, value, { maxAge = this.#maxAge } = {}) {
|
|
56599
|
+
const expiry = typeof maxAge === "number" && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : undefined;
|
|
56600
|
+
if (this.#cache.has(key)) {
|
|
56601
|
+
this.#cache.set(key, {
|
|
56602
|
+
value,
|
|
56603
|
+
expiry
|
|
56604
|
+
});
|
|
56605
|
+
} else {
|
|
56606
|
+
this.#set(key, { value, expiry });
|
|
56607
|
+
}
|
|
56608
|
+
return this;
|
|
56609
|
+
}
|
|
56610
|
+
has(key) {
|
|
56611
|
+
if (this.#cache.has(key)) {
|
|
56612
|
+
return !this.#deleteIfExpired(key, this.#cache.get(key));
|
|
56613
|
+
}
|
|
56614
|
+
if (this.#oldCache.has(key)) {
|
|
56615
|
+
return !this.#deleteIfExpired(key, this.#oldCache.get(key));
|
|
56616
|
+
}
|
|
56617
|
+
return false;
|
|
56618
|
+
}
|
|
56619
|
+
peek(key) {
|
|
56620
|
+
if (this.#cache.has(key)) {
|
|
56621
|
+
return this.#peek(key, this.#cache);
|
|
56622
|
+
}
|
|
56623
|
+
if (this.#oldCache.has(key)) {
|
|
56624
|
+
return this.#peek(key, this.#oldCache);
|
|
56625
|
+
}
|
|
56626
|
+
}
|
|
56627
|
+
expiresIn(key) {
|
|
56628
|
+
const item = this.#cache.get(key) ?? this.#oldCache.get(key);
|
|
56629
|
+
if (item) {
|
|
56630
|
+
return item.expiry ? item.expiry - Date.now() : Number.POSITIVE_INFINITY;
|
|
56631
|
+
}
|
|
56632
|
+
}
|
|
56633
|
+
delete(key) {
|
|
56634
|
+
const deleted = this.#cache.delete(key);
|
|
56635
|
+
if (deleted) {
|
|
56636
|
+
this.#size--;
|
|
56637
|
+
}
|
|
56638
|
+
return this.#oldCache.delete(key) || deleted;
|
|
56639
|
+
}
|
|
56640
|
+
clear() {
|
|
56641
|
+
this.#cache.clear();
|
|
56642
|
+
this.#oldCache.clear();
|
|
56643
|
+
this.#size = 0;
|
|
56644
|
+
}
|
|
56645
|
+
resize(newSize) {
|
|
56646
|
+
if (!(newSize && newSize > 0)) {
|
|
56647
|
+
throw new TypeError("`maxSize` must be a number greater than 0");
|
|
56648
|
+
}
|
|
56649
|
+
const items = [...this.#entriesAscending()];
|
|
56650
|
+
const removeCount = items.length - newSize;
|
|
56651
|
+
if (removeCount < 0) {
|
|
56652
|
+
this.#cache = new Map(items);
|
|
56653
|
+
this.#oldCache = new Map;
|
|
56654
|
+
this.#size = items.length;
|
|
56655
|
+
} else {
|
|
56656
|
+
if (removeCount > 0) {
|
|
56657
|
+
this.#emitEvictions(items.slice(0, removeCount));
|
|
56658
|
+
}
|
|
56659
|
+
this.#oldCache = new Map(items.slice(removeCount));
|
|
56660
|
+
this.#cache = new Map;
|
|
56661
|
+
this.#size = 0;
|
|
56662
|
+
}
|
|
56663
|
+
this.#maxSize = newSize;
|
|
56664
|
+
}
|
|
56665
|
+
evict(count = 1) {
|
|
56666
|
+
const requested = Number(count);
|
|
56667
|
+
if (!requested || requested <= 0) {
|
|
56668
|
+
return;
|
|
56669
|
+
}
|
|
56670
|
+
const items = [...this.#entriesAscending()];
|
|
56671
|
+
const evictCount = Math.trunc(Math.min(requested, Math.max(items.length - 1, 0)));
|
|
56672
|
+
if (evictCount <= 0) {
|
|
56673
|
+
return;
|
|
56674
|
+
}
|
|
56675
|
+
this.#emitEvictions(items.slice(0, evictCount));
|
|
56676
|
+
this.#oldCache = new Map(items.slice(evictCount));
|
|
56677
|
+
this.#cache = new Map;
|
|
56678
|
+
this.#size = 0;
|
|
56679
|
+
}
|
|
56680
|
+
*keys() {
|
|
56681
|
+
for (const [key] of this) {
|
|
56682
|
+
yield key;
|
|
56683
|
+
}
|
|
56684
|
+
}
|
|
56685
|
+
*values() {
|
|
56686
|
+
for (const [, value] of this) {
|
|
56687
|
+
yield value;
|
|
56688
|
+
}
|
|
56689
|
+
}
|
|
56690
|
+
*[Symbol.iterator]() {
|
|
56691
|
+
for (const item of this.#cache) {
|
|
56692
|
+
const [key, value] = item;
|
|
56693
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
56694
|
+
if (deleted === false) {
|
|
56695
|
+
yield [key, value.value];
|
|
56696
|
+
}
|
|
56697
|
+
}
|
|
56698
|
+
for (const item of this.#oldCache) {
|
|
56699
|
+
const [key, value] = item;
|
|
56700
|
+
if (!this.#cache.has(key)) {
|
|
56701
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
56702
|
+
if (deleted === false) {
|
|
56703
|
+
yield [key, value.value];
|
|
56704
|
+
}
|
|
56705
|
+
}
|
|
56706
|
+
}
|
|
56707
|
+
}
|
|
56708
|
+
*entriesDescending() {
|
|
56709
|
+
let items = [...this.#cache];
|
|
56710
|
+
for (let i2 = items.length - 1;i2 >= 0; --i2) {
|
|
56711
|
+
const item = items[i2];
|
|
56712
|
+
const [key, value] = item;
|
|
56713
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
56714
|
+
if (deleted === false) {
|
|
56715
|
+
yield [key, value.value];
|
|
56716
|
+
}
|
|
56717
|
+
}
|
|
56718
|
+
items = [...this.#oldCache];
|
|
56719
|
+
for (let i2 = items.length - 1;i2 >= 0; --i2) {
|
|
56720
|
+
const item = items[i2];
|
|
56721
|
+
const [key, value] = item;
|
|
56722
|
+
if (!this.#cache.has(key)) {
|
|
56723
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
56724
|
+
if (deleted === false) {
|
|
56725
|
+
yield [key, value.value];
|
|
56726
|
+
}
|
|
56727
|
+
}
|
|
56728
|
+
}
|
|
56729
|
+
}
|
|
56730
|
+
*entriesAscending() {
|
|
56731
|
+
for (const [key, value] of this.#entriesAscending()) {
|
|
56732
|
+
yield [key, value.value];
|
|
56733
|
+
}
|
|
56734
|
+
}
|
|
56735
|
+
get size() {
|
|
56736
|
+
if (!this.#size) {
|
|
56737
|
+
return this.#oldCache.size;
|
|
56738
|
+
}
|
|
56739
|
+
let oldCacheSize = 0;
|
|
56740
|
+
for (const key of this.#oldCache.keys()) {
|
|
56741
|
+
if (!this.#cache.has(key)) {
|
|
56742
|
+
oldCacheSize++;
|
|
56743
|
+
}
|
|
56744
|
+
}
|
|
56745
|
+
return Math.min(this.#size + oldCacheSize, this.#maxSize);
|
|
56746
|
+
}
|
|
56747
|
+
get maxSize() {
|
|
56748
|
+
return this.#maxSize;
|
|
56749
|
+
}
|
|
56750
|
+
get maxAge() {
|
|
56751
|
+
return this.#maxAge;
|
|
56752
|
+
}
|
|
56753
|
+
entries() {
|
|
56754
|
+
return this.entriesAscending();
|
|
56755
|
+
}
|
|
56756
|
+
forEach(callbackFunction, thisArgument = this) {
|
|
56757
|
+
for (const [key, value] of this.entriesAscending()) {
|
|
56758
|
+
callbackFunction.call(thisArgument, value, key, this);
|
|
56759
|
+
}
|
|
56760
|
+
}
|
|
56761
|
+
get [Symbol.toStringTag]() {
|
|
56762
|
+
return "QuickLRU";
|
|
56763
|
+
}
|
|
56764
|
+
toString() {
|
|
56765
|
+
return `QuickLRU(${this.size}/${this.maxSize})`;
|
|
56766
|
+
}
|
|
56767
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
56768
|
+
return this.toString();
|
|
56769
|
+
}
|
|
56770
|
+
}
|
|
56771
|
+
|
|
56772
|
+
// src/hooks/guardrails.ts
|
|
54815
56773
|
init_constants();
|
|
54816
56774
|
init_schema();
|
|
54817
56775
|
|
|
@@ -56007,6 +57965,41 @@ function hashArgs(args2) {
|
|
|
56007
57965
|
return 0;
|
|
56008
57966
|
}
|
|
56009
57967
|
}
|
|
57968
|
+
var pathNormalizationCache = new QuickLRU({
|
|
57969
|
+
maxSize: 500
|
|
57970
|
+
});
|
|
57971
|
+
var globMatcherCache = new QuickLRU({
|
|
57972
|
+
maxSize: 200
|
|
57973
|
+
});
|
|
57974
|
+
function normalizePathWithCache(filePath, cwd) {
|
|
57975
|
+
const cacheKey = `${cwd}:${filePath}`;
|
|
57976
|
+
const cached3 = pathNormalizationCache.get(cacheKey);
|
|
57977
|
+
if (cached3 !== undefined) {
|
|
57978
|
+
return cached3;
|
|
57979
|
+
}
|
|
57980
|
+
try {
|
|
57981
|
+
const absolutePath = path38.isAbsolute(filePath) ? filePath : path38.resolve(cwd, filePath);
|
|
57982
|
+
const normalized = fsSync.realpathSync(absolutePath);
|
|
57983
|
+
pathNormalizationCache.set(cacheKey, normalized);
|
|
57984
|
+
return normalized;
|
|
57985
|
+
} catch {
|
|
57986
|
+
const fallback = path38.isAbsolute(filePath) ? filePath : path38.resolve(cwd, filePath);
|
|
57987
|
+
pathNormalizationCache.set(cacheKey, fallback);
|
|
57988
|
+
return fallback;
|
|
57989
|
+
}
|
|
57990
|
+
}
|
|
57991
|
+
function getGlobMatcher(pattern) {
|
|
57992
|
+
const cached3 = globMatcherCache.get(pattern);
|
|
57993
|
+
if (cached3 !== undefined) {
|
|
57994
|
+
return cached3;
|
|
57995
|
+
}
|
|
57996
|
+
const matcher = import_picomatch.default(pattern, {
|
|
57997
|
+
dot: true,
|
|
57998
|
+
nocase: process.platform === "win32"
|
|
57999
|
+
});
|
|
58000
|
+
globMatcherCache.set(pattern, matcher);
|
|
58001
|
+
return matcher;
|
|
58002
|
+
}
|
|
56010
58003
|
var DEFAULT_AGENT_AUTHORITY_RULES = {
|
|
56011
58004
|
architect: {
|
|
56012
58005
|
blockedExact: [".swarm/plan.md", ".swarm/plan.json"],
|
|
@@ -56065,10 +58058,14 @@ function buildEffectiveRules(authorityConfig) {
|
|
|
56065
58058
|
merged[normalizedRuleKey] = {
|
|
56066
58059
|
...existing,
|
|
56067
58060
|
...userRule,
|
|
58061
|
+
readOnly: userRule.readOnly ?? existing.readOnly,
|
|
56068
58062
|
blockedExact: userRule.blockedExact ?? existing.blockedExact,
|
|
58063
|
+
allowedExact: userRule.allowedExact ?? existing.allowedExact,
|
|
56069
58064
|
blockedPrefix: userRule.blockedPrefix ?? existing.blockedPrefix,
|
|
56070
58065
|
allowedPrefix: userRule.allowedPrefix ?? existing.allowedPrefix,
|
|
56071
|
-
blockedZones: userRule.blockedZones ?? existing.blockedZones
|
|
58066
|
+
blockedZones: userRule.blockedZones ?? existing.blockedZones,
|
|
58067
|
+
blockedGlobs: userRule.blockedGlobs ?? existing.blockedGlobs,
|
|
58068
|
+
allowedGlobs: userRule.allowedGlobs ?? existing.allowedGlobs
|
|
56072
58069
|
};
|
|
56073
58070
|
}
|
|
56074
58071
|
return merged;
|
|
@@ -56077,8 +58074,15 @@ function checkFileAuthorityWithRules(agentName, filePath, cwd, effectiveRules) {
|
|
|
56077
58074
|
const normalizedAgent = agentName.toLowerCase();
|
|
56078
58075
|
const strippedAgent = stripKnownSwarmPrefix(agentName).toLowerCase();
|
|
56079
58076
|
const dir = cwd || process.cwd();
|
|
56080
|
-
|
|
56081
|
-
|
|
58077
|
+
let normalizedPath;
|
|
58078
|
+
try {
|
|
58079
|
+
const normalizedWithSymlinks = normalizePathWithCache(filePath, cwd);
|
|
58080
|
+
const resolved = path38.resolve(dir, normalizedWithSymlinks);
|
|
58081
|
+
normalizedPath = path38.relative(dir, resolved).replace(/\\/g, "/");
|
|
58082
|
+
} catch {
|
|
58083
|
+
const resolved = path38.resolve(dir, filePath);
|
|
58084
|
+
normalizedPath = path38.relative(dir, resolved).replace(/\\/g, "/");
|
|
58085
|
+
}
|
|
56082
58086
|
const rules = effectiveRules[normalizedAgent] ?? effectiveRules[strippedAgent];
|
|
56083
58087
|
if (!rules) {
|
|
56084
58088
|
return { allowed: false, reason: `Unknown agent: ${agentName}` };
|
|
@@ -56092,28 +58096,62 @@ function checkFileAuthorityWithRules(agentName, filePath, cwd, effectiveRules) {
|
|
|
56092
58096
|
if (rules.blockedExact) {
|
|
56093
58097
|
for (const blocked of rules.blockedExact) {
|
|
56094
58098
|
if (normalizedPath === blocked) {
|
|
56095
|
-
return {
|
|
58099
|
+
return {
|
|
58100
|
+
allowed: false,
|
|
58101
|
+
reason: `Path blocked (exact): ${normalizedPath}`
|
|
58102
|
+
};
|
|
56096
58103
|
}
|
|
56097
58104
|
}
|
|
56098
58105
|
}
|
|
56099
|
-
if (rules.
|
|
56100
|
-
for (const
|
|
56101
|
-
|
|
58106
|
+
if (rules.blockedGlobs && rules.blockedGlobs.length > 0) {
|
|
58107
|
+
for (const glob of rules.blockedGlobs) {
|
|
58108
|
+
const matcher = getGlobMatcher(glob);
|
|
58109
|
+
if (matcher(normalizedPath)) {
|
|
56102
58110
|
return {
|
|
56103
58111
|
allowed: false,
|
|
56104
|
-
reason: `Path blocked
|
|
58112
|
+
reason: `Path blocked (glob ${glob}): ${normalizedPath}`
|
|
56105
58113
|
};
|
|
56106
58114
|
}
|
|
56107
58115
|
}
|
|
56108
58116
|
}
|
|
56109
|
-
if (rules.
|
|
56110
|
-
const
|
|
58117
|
+
if (rules.allowedExact && rules.allowedExact.length > 0) {
|
|
58118
|
+
const isExplicitlyAllowed = rules.allowedExact.some((allowed) => normalizedPath === allowed);
|
|
58119
|
+
if (isExplicitlyAllowed) {
|
|
58120
|
+
return { allowed: true };
|
|
58121
|
+
}
|
|
58122
|
+
}
|
|
58123
|
+
if (rules.allowedGlobs && rules.allowedGlobs.length > 0) {
|
|
58124
|
+
const isGlobAllowed = rules.allowedGlobs.some((glob) => {
|
|
58125
|
+
const matcher = getGlobMatcher(glob);
|
|
58126
|
+
return matcher(normalizedPath);
|
|
58127
|
+
});
|
|
58128
|
+
if (isGlobAllowed) {
|
|
58129
|
+
return { allowed: true };
|
|
58130
|
+
}
|
|
58131
|
+
}
|
|
58132
|
+
if (rules.allowedPrefix != null && rules.allowedPrefix.length > 0) {
|
|
58133
|
+
const isAllowed = rules.allowedPrefix.some((prefix) => normalizedPath.startsWith(prefix));
|
|
56111
58134
|
if (!isAllowed) {
|
|
56112
58135
|
return {
|
|
56113
58136
|
allowed: false,
|
|
56114
58137
|
reason: `Path ${normalizedPath} not in allowed list for ${normalizedAgent}`
|
|
56115
58138
|
};
|
|
56116
58139
|
}
|
|
58140
|
+
} else if (rules.allowedPrefix != null && rules.allowedPrefix.length === 0) {
|
|
58141
|
+
return {
|
|
58142
|
+
allowed: false,
|
|
58143
|
+
reason: `Path ${normalizedPath} not in allowed list for ${normalizedAgent}`
|
|
58144
|
+
};
|
|
58145
|
+
}
|
|
58146
|
+
if (rules.blockedPrefix && rules.blockedPrefix.length > 0) {
|
|
58147
|
+
for (const prefix of rules.blockedPrefix) {
|
|
58148
|
+
if (normalizedPath.startsWith(prefix)) {
|
|
58149
|
+
return {
|
|
58150
|
+
allowed: false,
|
|
58151
|
+
reason: `Path blocked: ${normalizedPath} is under ${prefix}`
|
|
58152
|
+
};
|
|
58153
|
+
}
|
|
58154
|
+
}
|
|
56117
58155
|
}
|
|
56118
58156
|
if (rules.blockedZones && rules.blockedZones.length > 0) {
|
|
56119
58157
|
const { zone } = classifyFile(normalizedPath);
|