@ev-ai/agent-hook 1.3.11 → 1.4.1
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/COLLECTED-DATA.md +8 -8
- package/README.md +1 -1
- package/dist/cli.mjs +50 -46
- package/dist/hook.mjs +46 -42
- package/dist/launcher-update.mjs +1 -1
- package/dist/launcher.mjs +1 -1
- package/dist/managed-hooks-snippet.cjs +3700 -229
- package/dist/managed-hooks-snippet.d.ts +13 -2
- package/dist/managed-hooks-snippet.mjs +3664 -195
- package/dist/plugin-hooks.mjs +4715 -9
- package/package.json +1 -1
package/dist/plugin-hooks.mjs
CHANGED
|
@@ -1,6 +1,4144 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module';
|
|
2
2
|
const require = __createRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
28
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
33
|
+
mod
|
|
34
|
+
));
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/braces/lib/utils.js
|
|
37
|
+
var require_utils = __commonJS({
|
|
38
|
+
"../../node_modules/braces/lib/utils.js"(exports) {
|
|
39
|
+
"use strict";
|
|
40
|
+
exports.isInteger = (num) => {
|
|
41
|
+
if (typeof num === "number") {
|
|
42
|
+
return Number.isInteger(num);
|
|
43
|
+
}
|
|
44
|
+
if (typeof num === "string" && num.trim() !== "") {
|
|
45
|
+
return Number.isInteger(Number(num));
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
};
|
|
49
|
+
exports.find = (node, type) => node.nodes.find((node2) => node2.type === type);
|
|
50
|
+
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
|
51
|
+
if (limit === false) return false;
|
|
52
|
+
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
|
53
|
+
return (Number(max) - Number(min)) / Number(step) >= limit;
|
|
54
|
+
};
|
|
55
|
+
exports.escapeNode = (block, n = 0, type) => {
|
|
56
|
+
const node = block.nodes[n];
|
|
57
|
+
if (!node) return;
|
|
58
|
+
if (type && node.type === type || node.type === "open" || node.type === "close") {
|
|
59
|
+
if (node.escaped !== true) {
|
|
60
|
+
node.value = "\\" + node.value;
|
|
61
|
+
node.escaped = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.encloseBrace = (node) => {
|
|
66
|
+
if (node.type !== "brace") return false;
|
|
67
|
+
if (node.commas >> 0 + node.ranges >> 0 === 0) {
|
|
68
|
+
node.invalid = true;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
};
|
|
73
|
+
exports.isInvalidBrace = (block) => {
|
|
74
|
+
if (block.type !== "brace") return false;
|
|
75
|
+
if (block.invalid === true || block.dollar) return true;
|
|
76
|
+
if (block.commas >> 0 + block.ranges >> 0 === 0) {
|
|
77
|
+
block.invalid = true;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (block.open !== true || block.close !== true) {
|
|
81
|
+
block.invalid = true;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
86
|
+
exports.isOpenOrClose = (node) => {
|
|
87
|
+
if (node.type === "open" || node.type === "close") {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
return node.open === true || node.close === true;
|
|
91
|
+
};
|
|
92
|
+
exports.reduce = (nodes) => nodes.reduce((acc, node) => {
|
|
93
|
+
if (node.type === "text") acc.push(node.value);
|
|
94
|
+
if (node.type === "range") node.type = "text";
|
|
95
|
+
return acc;
|
|
96
|
+
}, []);
|
|
97
|
+
exports.flatten = (...args) => {
|
|
98
|
+
const result = [];
|
|
99
|
+
const flat = (arr) => {
|
|
100
|
+
for (let i = 0; i < arr.length; i++) {
|
|
101
|
+
const ele = arr[i];
|
|
102
|
+
if (Array.isArray(ele)) {
|
|
103
|
+
flat(ele);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (ele !== void 0) {
|
|
107
|
+
result.push(ele);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
};
|
|
112
|
+
flat(args);
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// ../../node_modules/braces/lib/stringify.js
|
|
119
|
+
var require_stringify = __commonJS({
|
|
120
|
+
"../../node_modules/braces/lib/stringify.js"(exports, module) {
|
|
121
|
+
"use strict";
|
|
122
|
+
var utils = require_utils();
|
|
123
|
+
module.exports = (ast, options = {}) => {
|
|
124
|
+
const stringify = (node, parent = {}) => {
|
|
125
|
+
const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
|
126
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
127
|
+
let output = "";
|
|
128
|
+
if (node.value) {
|
|
129
|
+
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
|
|
130
|
+
return "\\" + node.value;
|
|
131
|
+
}
|
|
132
|
+
return node.value;
|
|
133
|
+
}
|
|
134
|
+
if (node.value) {
|
|
135
|
+
return node.value;
|
|
136
|
+
}
|
|
137
|
+
if (node.nodes) {
|
|
138
|
+
for (const child of node.nodes) {
|
|
139
|
+
output += stringify(child);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return output;
|
|
143
|
+
};
|
|
144
|
+
return stringify(ast);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// ../../node_modules/is-number/index.js
|
|
150
|
+
var require_is_number = __commonJS({
|
|
151
|
+
"../../node_modules/is-number/index.js"(exports, module) {
|
|
152
|
+
"use strict";
|
|
153
|
+
module.exports = function(num) {
|
|
154
|
+
if (typeof num === "number") {
|
|
155
|
+
return num - num === 0;
|
|
156
|
+
}
|
|
157
|
+
if (typeof num === "string" && num.trim() !== "") {
|
|
158
|
+
return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// ../../node_modules/to-regex-range/index.js
|
|
166
|
+
var require_to_regex_range = __commonJS({
|
|
167
|
+
"../../node_modules/to-regex-range/index.js"(exports, module) {
|
|
168
|
+
"use strict";
|
|
169
|
+
var isNumber = require_is_number();
|
|
170
|
+
var toRegexRange = (min, max, options) => {
|
|
171
|
+
if (isNumber(min) === false) {
|
|
172
|
+
throw new TypeError("toRegexRange: expected the first argument to be a number");
|
|
173
|
+
}
|
|
174
|
+
if (max === void 0 || min === max) {
|
|
175
|
+
return String(min);
|
|
176
|
+
}
|
|
177
|
+
if (isNumber(max) === false) {
|
|
178
|
+
throw new TypeError("toRegexRange: expected the second argument to be a number.");
|
|
179
|
+
}
|
|
180
|
+
let opts = { relaxZeros: true, ...options };
|
|
181
|
+
if (typeof opts.strictZeros === "boolean") {
|
|
182
|
+
opts.relaxZeros = opts.strictZeros === false;
|
|
183
|
+
}
|
|
184
|
+
let relax = String(opts.relaxZeros);
|
|
185
|
+
let shorthand = String(opts.shorthand);
|
|
186
|
+
let capture = String(opts.capture);
|
|
187
|
+
let wrap = String(opts.wrap);
|
|
188
|
+
let cacheKey = min + ":" + max + "=" + relax + shorthand + capture + wrap;
|
|
189
|
+
if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
|
|
190
|
+
return toRegexRange.cache[cacheKey].result;
|
|
191
|
+
}
|
|
192
|
+
let a = Math.min(min, max);
|
|
193
|
+
let b = Math.max(min, max);
|
|
194
|
+
if (Math.abs(a - b) === 1) {
|
|
195
|
+
let result = min + "|" + max;
|
|
196
|
+
if (opts.capture) {
|
|
197
|
+
return `(${result})`;
|
|
198
|
+
}
|
|
199
|
+
if (opts.wrap === false) {
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
return `(?:${result})`;
|
|
203
|
+
}
|
|
204
|
+
let isPadded = hasPadding(min) || hasPadding(max);
|
|
205
|
+
let state = { min, max, a, b };
|
|
206
|
+
let positives = [];
|
|
207
|
+
let negatives = [];
|
|
208
|
+
if (isPadded) {
|
|
209
|
+
state.isPadded = isPadded;
|
|
210
|
+
state.maxLen = String(state.max).length;
|
|
211
|
+
}
|
|
212
|
+
if (a < 0) {
|
|
213
|
+
let newMin = b < 0 ? Math.abs(b) : 1;
|
|
214
|
+
negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
|
|
215
|
+
a = state.a = 0;
|
|
216
|
+
}
|
|
217
|
+
if (b >= 0) {
|
|
218
|
+
positives = splitToPatterns(a, b, state, opts);
|
|
219
|
+
}
|
|
220
|
+
state.negatives = negatives;
|
|
221
|
+
state.positives = positives;
|
|
222
|
+
state.result = collatePatterns(negatives, positives, opts);
|
|
223
|
+
if (opts.capture === true) {
|
|
224
|
+
state.result = `(${state.result})`;
|
|
225
|
+
} else if (opts.wrap !== false && positives.length + negatives.length > 1) {
|
|
226
|
+
state.result = `(?:${state.result})`;
|
|
227
|
+
}
|
|
228
|
+
toRegexRange.cache[cacheKey] = state;
|
|
229
|
+
return state.result;
|
|
230
|
+
};
|
|
231
|
+
function collatePatterns(neg, pos, options) {
|
|
232
|
+
let onlyNegative = filterPatterns(neg, pos, "-", false, options) || [];
|
|
233
|
+
let onlyPositive = filterPatterns(pos, neg, "", false, options) || [];
|
|
234
|
+
let intersected = filterPatterns(neg, pos, "-?", true, options) || [];
|
|
235
|
+
let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
|
|
236
|
+
return subpatterns.join("|");
|
|
237
|
+
}
|
|
238
|
+
function splitToRanges(min, max) {
|
|
239
|
+
let nines = 1;
|
|
240
|
+
let zeros = 1;
|
|
241
|
+
let stop = countNines(min, nines);
|
|
242
|
+
let stops = /* @__PURE__ */ new Set([max]);
|
|
243
|
+
while (min <= stop && stop <= max) {
|
|
244
|
+
stops.add(stop);
|
|
245
|
+
nines += 1;
|
|
246
|
+
stop = countNines(min, nines);
|
|
247
|
+
}
|
|
248
|
+
stop = countZeros(max + 1, zeros) - 1;
|
|
249
|
+
while (min < stop && stop <= max) {
|
|
250
|
+
stops.add(stop);
|
|
251
|
+
zeros += 1;
|
|
252
|
+
stop = countZeros(max + 1, zeros) - 1;
|
|
253
|
+
}
|
|
254
|
+
stops = [...stops];
|
|
255
|
+
stops.sort(compare);
|
|
256
|
+
return stops;
|
|
257
|
+
}
|
|
258
|
+
function rangeToPattern(start, stop, options) {
|
|
259
|
+
if (start === stop) {
|
|
260
|
+
return { pattern: start, count: [], digits: 0 };
|
|
261
|
+
}
|
|
262
|
+
let zipped = zip(start, stop);
|
|
263
|
+
let digits = zipped.length;
|
|
264
|
+
let pattern = "";
|
|
265
|
+
let count = 0;
|
|
266
|
+
for (let i = 0; i < digits; i++) {
|
|
267
|
+
let [startDigit, stopDigit] = zipped[i];
|
|
268
|
+
if (startDigit === stopDigit) {
|
|
269
|
+
pattern += startDigit;
|
|
270
|
+
} else if (startDigit !== "0" || stopDigit !== "9") {
|
|
271
|
+
pattern += toCharacterClass(startDigit, stopDigit, options);
|
|
272
|
+
} else {
|
|
273
|
+
count++;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (count) {
|
|
277
|
+
pattern += options.shorthand === true ? "\\d" : "[0-9]";
|
|
278
|
+
}
|
|
279
|
+
return { pattern, count: [count], digits };
|
|
280
|
+
}
|
|
281
|
+
function splitToPatterns(min, max, tok, options) {
|
|
282
|
+
let ranges = splitToRanges(min, max);
|
|
283
|
+
let tokens = [];
|
|
284
|
+
let start = min;
|
|
285
|
+
let prev;
|
|
286
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
287
|
+
let max2 = ranges[i];
|
|
288
|
+
let obj = rangeToPattern(String(start), String(max2), options);
|
|
289
|
+
let zeros = "";
|
|
290
|
+
if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
|
|
291
|
+
if (prev.count.length > 1) {
|
|
292
|
+
prev.count.pop();
|
|
293
|
+
}
|
|
294
|
+
prev.count.push(obj.count[0]);
|
|
295
|
+
prev.string = prev.pattern + toQuantifier(prev.count);
|
|
296
|
+
start = max2 + 1;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (tok.isPadded) {
|
|
300
|
+
zeros = padZeros(max2, tok, options);
|
|
301
|
+
}
|
|
302
|
+
obj.string = zeros + obj.pattern + toQuantifier(obj.count);
|
|
303
|
+
tokens.push(obj);
|
|
304
|
+
start = max2 + 1;
|
|
305
|
+
prev = obj;
|
|
306
|
+
}
|
|
307
|
+
return tokens;
|
|
308
|
+
}
|
|
309
|
+
function filterPatterns(arr, comparison, prefix, intersection, options) {
|
|
310
|
+
let result = [];
|
|
311
|
+
for (let ele of arr) {
|
|
312
|
+
let { string } = ele;
|
|
313
|
+
if (!intersection && !contains(comparison, "string", string)) {
|
|
314
|
+
result.push(prefix + string);
|
|
315
|
+
}
|
|
316
|
+
if (intersection && contains(comparison, "string", string)) {
|
|
317
|
+
result.push(prefix + string);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
function zip(a, b) {
|
|
323
|
+
let arr = [];
|
|
324
|
+
for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
|
|
325
|
+
return arr;
|
|
326
|
+
}
|
|
327
|
+
function compare(a, b) {
|
|
328
|
+
return a > b ? 1 : b > a ? -1 : 0;
|
|
329
|
+
}
|
|
330
|
+
function contains(arr, key, val) {
|
|
331
|
+
return arr.some((ele) => ele[key] === val);
|
|
332
|
+
}
|
|
333
|
+
function countNines(min, len) {
|
|
334
|
+
return Number(String(min).slice(0, -len) + "9".repeat(len));
|
|
335
|
+
}
|
|
336
|
+
function countZeros(integer, zeros) {
|
|
337
|
+
return integer - integer % Math.pow(10, zeros);
|
|
338
|
+
}
|
|
339
|
+
function toQuantifier(digits) {
|
|
340
|
+
let [start = 0, stop = ""] = digits;
|
|
341
|
+
if (stop || start > 1) {
|
|
342
|
+
return `{${start + (stop ? "," + stop : "")}}`;
|
|
343
|
+
}
|
|
344
|
+
return "";
|
|
345
|
+
}
|
|
346
|
+
function toCharacterClass(a, b, options) {
|
|
347
|
+
return `[${a}${b - a === 1 ? "" : "-"}${b}]`;
|
|
348
|
+
}
|
|
349
|
+
function hasPadding(str) {
|
|
350
|
+
return /^-?(0+)\d/.test(str);
|
|
351
|
+
}
|
|
352
|
+
function padZeros(value, tok, options) {
|
|
353
|
+
if (!tok.isPadded) {
|
|
354
|
+
return value;
|
|
355
|
+
}
|
|
356
|
+
let diff = Math.abs(tok.maxLen - String(value).length);
|
|
357
|
+
let relax = options.relaxZeros !== false;
|
|
358
|
+
switch (diff) {
|
|
359
|
+
case 0:
|
|
360
|
+
return "";
|
|
361
|
+
case 1:
|
|
362
|
+
return relax ? "0?" : "0";
|
|
363
|
+
case 2:
|
|
364
|
+
return relax ? "0{0,2}" : "00";
|
|
365
|
+
default: {
|
|
366
|
+
return relax ? `0{0,${diff}}` : `0{${diff}}`;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
toRegexRange.cache = {};
|
|
371
|
+
toRegexRange.clearCache = () => toRegexRange.cache = {};
|
|
372
|
+
module.exports = toRegexRange;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// ../../node_modules/fill-range/index.js
|
|
377
|
+
var require_fill_range = __commonJS({
|
|
378
|
+
"../../node_modules/fill-range/index.js"(exports, module) {
|
|
379
|
+
"use strict";
|
|
380
|
+
var util = __require("util");
|
|
381
|
+
var toRegexRange = require_to_regex_range();
|
|
382
|
+
var isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
383
|
+
var transform = (toNumber) => {
|
|
384
|
+
return (value) => toNumber === true ? Number(value) : String(value);
|
|
385
|
+
};
|
|
386
|
+
var isValidValue = (value) => {
|
|
387
|
+
return typeof value === "number" || typeof value === "string" && value !== "";
|
|
388
|
+
};
|
|
389
|
+
var isNumber = (num) => Number.isInteger(+num);
|
|
390
|
+
var zeros = (input) => {
|
|
391
|
+
let value = `${input}`;
|
|
392
|
+
let index = -1;
|
|
393
|
+
if (value[0] === "-") value = value.slice(1);
|
|
394
|
+
if (value === "0") return false;
|
|
395
|
+
while (value[++index] === "0") ;
|
|
396
|
+
return index > 0;
|
|
397
|
+
};
|
|
398
|
+
var stringify = (start, end, options) => {
|
|
399
|
+
if (typeof start === "string" || typeof end === "string") {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
return options.stringify === true;
|
|
403
|
+
};
|
|
404
|
+
var pad = (input, maxLength, toNumber) => {
|
|
405
|
+
if (maxLength > 0) {
|
|
406
|
+
let dash = input[0] === "-" ? "-" : "";
|
|
407
|
+
if (dash) input = input.slice(1);
|
|
408
|
+
input = dash + input.padStart(dash ? maxLength - 1 : maxLength, "0");
|
|
409
|
+
}
|
|
410
|
+
if (toNumber === false) {
|
|
411
|
+
return String(input);
|
|
412
|
+
}
|
|
413
|
+
return input;
|
|
414
|
+
};
|
|
415
|
+
var toMaxLen = (input, maxLength) => {
|
|
416
|
+
let negative = input[0] === "-" ? "-" : "";
|
|
417
|
+
if (negative) {
|
|
418
|
+
input = input.slice(1);
|
|
419
|
+
maxLength--;
|
|
420
|
+
}
|
|
421
|
+
while (input.length < maxLength) input = "0" + input;
|
|
422
|
+
return negative ? "-" + input : input;
|
|
423
|
+
};
|
|
424
|
+
var toSequence = (parts, options, maxLen) => {
|
|
425
|
+
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
426
|
+
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
427
|
+
let prefix = options.capture ? "" : "?:";
|
|
428
|
+
let positives = "";
|
|
429
|
+
let negatives = "";
|
|
430
|
+
let result;
|
|
431
|
+
if (parts.positives.length) {
|
|
432
|
+
positives = parts.positives.map((v) => toMaxLen(String(v), maxLen)).join("|");
|
|
433
|
+
}
|
|
434
|
+
if (parts.negatives.length) {
|
|
435
|
+
negatives = `-(${prefix}${parts.negatives.map((v) => toMaxLen(String(v), maxLen)).join("|")})`;
|
|
436
|
+
}
|
|
437
|
+
if (positives && negatives) {
|
|
438
|
+
result = `${positives}|${negatives}`;
|
|
439
|
+
} else {
|
|
440
|
+
result = positives || negatives;
|
|
441
|
+
}
|
|
442
|
+
if (options.wrap) {
|
|
443
|
+
return `(${prefix}${result})`;
|
|
444
|
+
}
|
|
445
|
+
return result;
|
|
446
|
+
};
|
|
447
|
+
var toRange = (a, b, isNumbers, options) => {
|
|
448
|
+
if (isNumbers) {
|
|
449
|
+
return toRegexRange(a, b, { wrap: false, ...options });
|
|
450
|
+
}
|
|
451
|
+
let start = String.fromCharCode(a);
|
|
452
|
+
if (a === b) return start;
|
|
453
|
+
let stop = String.fromCharCode(b);
|
|
454
|
+
return `[${start}-${stop}]`;
|
|
455
|
+
};
|
|
456
|
+
var toRegex = (start, end, options) => {
|
|
457
|
+
if (Array.isArray(start)) {
|
|
458
|
+
let wrap = options.wrap === true;
|
|
459
|
+
let prefix = options.capture ? "" : "?:";
|
|
460
|
+
return wrap ? `(${prefix}${start.join("|")})` : start.join("|");
|
|
461
|
+
}
|
|
462
|
+
return toRegexRange(start, end, options);
|
|
463
|
+
};
|
|
464
|
+
var rangeError = (...args) => {
|
|
465
|
+
return new RangeError("Invalid range arguments: " + util.inspect(...args));
|
|
466
|
+
};
|
|
467
|
+
var invalidRange = (start, end, options) => {
|
|
468
|
+
if (options.strictRanges === true) throw rangeError([start, end]);
|
|
469
|
+
return [];
|
|
470
|
+
};
|
|
471
|
+
var invalidStep = (step, options) => {
|
|
472
|
+
if (options.strictRanges === true) {
|
|
473
|
+
throw new TypeError(`Expected step "${step}" to be a number`);
|
|
474
|
+
}
|
|
475
|
+
return [];
|
|
476
|
+
};
|
|
477
|
+
var fillNumbers = (start, end, step = 1, options = {}) => {
|
|
478
|
+
let a = Number(start);
|
|
479
|
+
let b = Number(end);
|
|
480
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
481
|
+
if (options.strictRanges === true) throw rangeError([start, end]);
|
|
482
|
+
return [];
|
|
483
|
+
}
|
|
484
|
+
if (a === 0) a = 0;
|
|
485
|
+
if (b === 0) b = 0;
|
|
486
|
+
let descending = a > b;
|
|
487
|
+
let startString = String(start);
|
|
488
|
+
let endString = String(end);
|
|
489
|
+
let stepString = String(step);
|
|
490
|
+
step = Math.max(Math.abs(step), 1);
|
|
491
|
+
let padded = zeros(startString) || zeros(endString) || zeros(stepString);
|
|
492
|
+
let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
|
|
493
|
+
let toNumber = padded === false && stringify(start, end, options) === false;
|
|
494
|
+
let format = options.transform || transform(toNumber);
|
|
495
|
+
if (options.toRegex && step === 1) {
|
|
496
|
+
return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
|
|
497
|
+
}
|
|
498
|
+
let parts = { negatives: [], positives: [] };
|
|
499
|
+
let push = (num) => parts[num < 0 ? "negatives" : "positives"].push(Math.abs(num));
|
|
500
|
+
let range = [];
|
|
501
|
+
let index = 0;
|
|
502
|
+
while (descending ? a >= b : a <= b) {
|
|
503
|
+
if (options.toRegex === true && step > 1) {
|
|
504
|
+
push(a);
|
|
505
|
+
} else {
|
|
506
|
+
range.push(pad(format(a, index), maxLen, toNumber));
|
|
507
|
+
}
|
|
508
|
+
a = descending ? a - step : a + step;
|
|
509
|
+
index++;
|
|
510
|
+
}
|
|
511
|
+
if (options.toRegex === true) {
|
|
512
|
+
return step > 1 ? toSequence(parts, options, maxLen) : toRegex(range, null, { wrap: false, ...options });
|
|
513
|
+
}
|
|
514
|
+
return range;
|
|
515
|
+
};
|
|
516
|
+
var fillLetters = (start, end, step = 1, options = {}) => {
|
|
517
|
+
if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) {
|
|
518
|
+
return invalidRange(start, end, options);
|
|
519
|
+
}
|
|
520
|
+
let format = options.transform || ((val) => String.fromCharCode(val));
|
|
521
|
+
let a = `${start}`.charCodeAt(0);
|
|
522
|
+
let b = `${end}`.charCodeAt(0);
|
|
523
|
+
let descending = a > b;
|
|
524
|
+
let min = Math.min(a, b);
|
|
525
|
+
let max = Math.max(a, b);
|
|
526
|
+
if (options.toRegex && step === 1) {
|
|
527
|
+
return toRange(min, max, false, options);
|
|
528
|
+
}
|
|
529
|
+
let range = [];
|
|
530
|
+
let index = 0;
|
|
531
|
+
while (descending ? a >= b : a <= b) {
|
|
532
|
+
range.push(format(a, index));
|
|
533
|
+
a = descending ? a - step : a + step;
|
|
534
|
+
index++;
|
|
535
|
+
}
|
|
536
|
+
if (options.toRegex === true) {
|
|
537
|
+
return toRegex(range, null, { wrap: false, options });
|
|
538
|
+
}
|
|
539
|
+
return range;
|
|
540
|
+
};
|
|
541
|
+
var fill = (start, end, step, options = {}) => {
|
|
542
|
+
if (end == null && isValidValue(start)) {
|
|
543
|
+
return [start];
|
|
544
|
+
}
|
|
545
|
+
if (!isValidValue(start) || !isValidValue(end)) {
|
|
546
|
+
return invalidRange(start, end, options);
|
|
547
|
+
}
|
|
548
|
+
if (typeof step === "function") {
|
|
549
|
+
return fill(start, end, 1, { transform: step });
|
|
550
|
+
}
|
|
551
|
+
if (isObject(step)) {
|
|
552
|
+
return fill(start, end, 0, step);
|
|
553
|
+
}
|
|
554
|
+
let opts = { ...options };
|
|
555
|
+
if (opts.capture === true) opts.wrap = true;
|
|
556
|
+
step = step || opts.step || 1;
|
|
557
|
+
if (!isNumber(step)) {
|
|
558
|
+
if (step != null && !isObject(step)) return invalidStep(step, opts);
|
|
559
|
+
return fill(start, end, 1, step);
|
|
560
|
+
}
|
|
561
|
+
if (isNumber(start) && isNumber(end)) {
|
|
562
|
+
return fillNumbers(start, end, step, opts);
|
|
563
|
+
}
|
|
564
|
+
return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
|
|
565
|
+
};
|
|
566
|
+
module.exports = fill;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
// ../../node_modules/braces/lib/compile.js
|
|
571
|
+
var require_compile = __commonJS({
|
|
572
|
+
"../../node_modules/braces/lib/compile.js"(exports, module) {
|
|
573
|
+
"use strict";
|
|
574
|
+
var fill = require_fill_range();
|
|
575
|
+
var utils = require_utils();
|
|
576
|
+
var compile = (ast, options = {}) => {
|
|
577
|
+
const walk = (node, parent = {}) => {
|
|
578
|
+
const invalidBlock = utils.isInvalidBrace(parent);
|
|
579
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
580
|
+
const invalid = invalidBlock === true || invalidNode === true;
|
|
581
|
+
const prefix = options.escapeInvalid === true ? "\\" : "";
|
|
582
|
+
let output = "";
|
|
583
|
+
if (node.isOpen === true) {
|
|
584
|
+
return prefix + node.value;
|
|
585
|
+
}
|
|
586
|
+
if (node.isClose === true) {
|
|
587
|
+
console.log("node.isClose", prefix, node.value);
|
|
588
|
+
return prefix + node.value;
|
|
589
|
+
}
|
|
590
|
+
if (node.type === "open") {
|
|
591
|
+
return invalid ? prefix + node.value : "(";
|
|
592
|
+
}
|
|
593
|
+
if (node.type === "close") {
|
|
594
|
+
return invalid ? prefix + node.value : ")";
|
|
595
|
+
}
|
|
596
|
+
if (node.type === "comma") {
|
|
597
|
+
return node.prev.type === "comma" ? "" : invalid ? node.value : "|";
|
|
598
|
+
}
|
|
599
|
+
if (node.value) {
|
|
600
|
+
return node.value;
|
|
601
|
+
}
|
|
602
|
+
if (node.nodes && node.ranges > 0) {
|
|
603
|
+
const args = utils.reduce(node.nodes);
|
|
604
|
+
const range = fill(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
|
605
|
+
if (range.length !== 0) {
|
|
606
|
+
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (node.nodes) {
|
|
610
|
+
for (const child of node.nodes) {
|
|
611
|
+
output += walk(child, node);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return output;
|
|
615
|
+
};
|
|
616
|
+
return walk(ast);
|
|
617
|
+
};
|
|
618
|
+
module.exports = compile;
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
// ../../node_modules/braces/lib/expand.js
|
|
623
|
+
var require_expand = __commonJS({
|
|
624
|
+
"../../node_modules/braces/lib/expand.js"(exports, module) {
|
|
625
|
+
"use strict";
|
|
626
|
+
var fill = require_fill_range();
|
|
627
|
+
var stringify = require_stringify();
|
|
628
|
+
var utils = require_utils();
|
|
629
|
+
var append = (queue = "", stash = "", enclose = false) => {
|
|
630
|
+
const result = [];
|
|
631
|
+
queue = [].concat(queue);
|
|
632
|
+
stash = [].concat(stash);
|
|
633
|
+
if (!stash.length) return queue;
|
|
634
|
+
if (!queue.length) {
|
|
635
|
+
return enclose ? utils.flatten(stash).map((ele) => `{${ele}}`) : stash;
|
|
636
|
+
}
|
|
637
|
+
for (const item of queue) {
|
|
638
|
+
if (Array.isArray(item)) {
|
|
639
|
+
for (const value of item) {
|
|
640
|
+
result.push(append(value, stash, enclose));
|
|
641
|
+
}
|
|
642
|
+
} else {
|
|
643
|
+
for (let ele of stash) {
|
|
644
|
+
if (enclose === true && typeof ele === "string") ele = `{${ele}}`;
|
|
645
|
+
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return utils.flatten(result);
|
|
650
|
+
};
|
|
651
|
+
var expand = (ast, options = {}) => {
|
|
652
|
+
const rangeLimit = options.rangeLimit === void 0 ? 1e3 : options.rangeLimit;
|
|
653
|
+
const walk = (node, parent = {}) => {
|
|
654
|
+
node.queue = [];
|
|
655
|
+
let p = parent;
|
|
656
|
+
let q = parent.queue;
|
|
657
|
+
while (p.type !== "brace" && p.type !== "root" && p.parent) {
|
|
658
|
+
p = p.parent;
|
|
659
|
+
q = p.queue;
|
|
660
|
+
}
|
|
661
|
+
if (node.invalid || node.dollar) {
|
|
662
|
+
q.push(append(q.pop(), stringify(node, options)));
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if (node.type === "brace" && node.invalid !== true && node.nodes.length === 2) {
|
|
666
|
+
q.push(append(q.pop(), ["{}"]));
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (node.nodes && node.ranges > 0) {
|
|
670
|
+
const args = utils.reduce(node.nodes);
|
|
671
|
+
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
|
|
672
|
+
throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");
|
|
673
|
+
}
|
|
674
|
+
let range = fill(...args, options);
|
|
675
|
+
if (range.length === 0) {
|
|
676
|
+
range = stringify(node, options);
|
|
677
|
+
}
|
|
678
|
+
q.push(append(q.pop(), range));
|
|
679
|
+
node.nodes = [];
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const enclose = utils.encloseBrace(node);
|
|
683
|
+
let queue = node.queue;
|
|
684
|
+
let block = node;
|
|
685
|
+
while (block.type !== "brace" && block.type !== "root" && block.parent) {
|
|
686
|
+
block = block.parent;
|
|
687
|
+
queue = block.queue;
|
|
688
|
+
}
|
|
689
|
+
for (let i = 0; i < node.nodes.length; i++) {
|
|
690
|
+
const child = node.nodes[i];
|
|
691
|
+
if (child.type === "comma" && node.type === "brace") {
|
|
692
|
+
if (i === 1) queue.push("");
|
|
693
|
+
queue.push("");
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
if (child.type === "close") {
|
|
697
|
+
q.push(append(q.pop(), queue, enclose));
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (child.value && child.type !== "open") {
|
|
701
|
+
queue.push(append(queue.pop(), child.value));
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
if (child.nodes) {
|
|
705
|
+
walk(child, node);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return queue;
|
|
709
|
+
};
|
|
710
|
+
return utils.flatten(walk(ast));
|
|
711
|
+
};
|
|
712
|
+
module.exports = expand;
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
// ../../node_modules/braces/lib/constants.js
|
|
717
|
+
var require_constants = __commonJS({
|
|
718
|
+
"../../node_modules/braces/lib/constants.js"(exports, module) {
|
|
719
|
+
"use strict";
|
|
720
|
+
module.exports = {
|
|
721
|
+
MAX_LENGTH: 1e4,
|
|
722
|
+
// Digits
|
|
723
|
+
CHAR_0: "0",
|
|
724
|
+
/* 0 */
|
|
725
|
+
CHAR_9: "9",
|
|
726
|
+
/* 9 */
|
|
727
|
+
// Alphabet chars.
|
|
728
|
+
CHAR_UPPERCASE_A: "A",
|
|
729
|
+
/* A */
|
|
730
|
+
CHAR_LOWERCASE_A: "a",
|
|
731
|
+
/* a */
|
|
732
|
+
CHAR_UPPERCASE_Z: "Z",
|
|
733
|
+
/* Z */
|
|
734
|
+
CHAR_LOWERCASE_Z: "z",
|
|
735
|
+
/* z */
|
|
736
|
+
CHAR_LEFT_PARENTHESES: "(",
|
|
737
|
+
/* ( */
|
|
738
|
+
CHAR_RIGHT_PARENTHESES: ")",
|
|
739
|
+
/* ) */
|
|
740
|
+
CHAR_ASTERISK: "*",
|
|
741
|
+
/* * */
|
|
742
|
+
// Non-alphabetic chars.
|
|
743
|
+
CHAR_AMPERSAND: "&",
|
|
744
|
+
/* & */
|
|
745
|
+
CHAR_AT: "@",
|
|
746
|
+
/* @ */
|
|
747
|
+
CHAR_BACKSLASH: "\\",
|
|
748
|
+
/* \ */
|
|
749
|
+
CHAR_BACKTICK: "`",
|
|
750
|
+
/* ` */
|
|
751
|
+
CHAR_CARRIAGE_RETURN: "\r",
|
|
752
|
+
/* \r */
|
|
753
|
+
CHAR_CIRCUMFLEX_ACCENT: "^",
|
|
754
|
+
/* ^ */
|
|
755
|
+
CHAR_COLON: ":",
|
|
756
|
+
/* : */
|
|
757
|
+
CHAR_COMMA: ",",
|
|
758
|
+
/* , */
|
|
759
|
+
CHAR_DOLLAR: "$",
|
|
760
|
+
/* . */
|
|
761
|
+
CHAR_DOT: ".",
|
|
762
|
+
/* . */
|
|
763
|
+
CHAR_DOUBLE_QUOTE: '"',
|
|
764
|
+
/* " */
|
|
765
|
+
CHAR_EQUAL: "=",
|
|
766
|
+
/* = */
|
|
767
|
+
CHAR_EXCLAMATION_MARK: "!",
|
|
768
|
+
/* ! */
|
|
769
|
+
CHAR_FORM_FEED: "\f",
|
|
770
|
+
/* \f */
|
|
771
|
+
CHAR_FORWARD_SLASH: "/",
|
|
772
|
+
/* / */
|
|
773
|
+
CHAR_HASH: "#",
|
|
774
|
+
/* # */
|
|
775
|
+
CHAR_HYPHEN_MINUS: "-",
|
|
776
|
+
/* - */
|
|
777
|
+
CHAR_LEFT_ANGLE_BRACKET: "<",
|
|
778
|
+
/* < */
|
|
779
|
+
CHAR_LEFT_CURLY_BRACE: "{",
|
|
780
|
+
/* { */
|
|
781
|
+
CHAR_LEFT_SQUARE_BRACKET: "[",
|
|
782
|
+
/* [ */
|
|
783
|
+
CHAR_LINE_FEED: "\n",
|
|
784
|
+
/* \n */
|
|
785
|
+
CHAR_NO_BREAK_SPACE: "\xA0",
|
|
786
|
+
/* \u00A0 */
|
|
787
|
+
CHAR_PERCENT: "%",
|
|
788
|
+
/* % */
|
|
789
|
+
CHAR_PLUS: "+",
|
|
790
|
+
/* + */
|
|
791
|
+
CHAR_QUESTION_MARK: "?",
|
|
792
|
+
/* ? */
|
|
793
|
+
CHAR_RIGHT_ANGLE_BRACKET: ">",
|
|
794
|
+
/* > */
|
|
795
|
+
CHAR_RIGHT_CURLY_BRACE: "}",
|
|
796
|
+
/* } */
|
|
797
|
+
CHAR_RIGHT_SQUARE_BRACKET: "]",
|
|
798
|
+
/* ] */
|
|
799
|
+
CHAR_SEMICOLON: ";",
|
|
800
|
+
/* ; */
|
|
801
|
+
CHAR_SINGLE_QUOTE: "'",
|
|
802
|
+
/* ' */
|
|
803
|
+
CHAR_SPACE: " ",
|
|
804
|
+
/* */
|
|
805
|
+
CHAR_TAB: " ",
|
|
806
|
+
/* \t */
|
|
807
|
+
CHAR_UNDERSCORE: "_",
|
|
808
|
+
/* _ */
|
|
809
|
+
CHAR_VERTICAL_LINE: "|",
|
|
810
|
+
/* | */
|
|
811
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: "\uFEFF"
|
|
812
|
+
/* \uFEFF */
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
// ../../node_modules/braces/lib/parse.js
|
|
818
|
+
var require_parse = __commonJS({
|
|
819
|
+
"../../node_modules/braces/lib/parse.js"(exports, module) {
|
|
820
|
+
"use strict";
|
|
821
|
+
var stringify = require_stringify();
|
|
822
|
+
var {
|
|
823
|
+
MAX_LENGTH,
|
|
824
|
+
CHAR_BACKSLASH,
|
|
825
|
+
/* \ */
|
|
826
|
+
CHAR_BACKTICK,
|
|
827
|
+
/* ` */
|
|
828
|
+
CHAR_COMMA,
|
|
829
|
+
/* , */
|
|
830
|
+
CHAR_DOT,
|
|
831
|
+
/* . */
|
|
832
|
+
CHAR_LEFT_PARENTHESES,
|
|
833
|
+
/* ( */
|
|
834
|
+
CHAR_RIGHT_PARENTHESES,
|
|
835
|
+
/* ) */
|
|
836
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
837
|
+
/* { */
|
|
838
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
839
|
+
/* } */
|
|
840
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
841
|
+
/* [ */
|
|
842
|
+
CHAR_RIGHT_SQUARE_BRACKET,
|
|
843
|
+
/* ] */
|
|
844
|
+
CHAR_DOUBLE_QUOTE,
|
|
845
|
+
/* " */
|
|
846
|
+
CHAR_SINGLE_QUOTE,
|
|
847
|
+
/* ' */
|
|
848
|
+
CHAR_NO_BREAK_SPACE,
|
|
849
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
|
850
|
+
} = require_constants();
|
|
851
|
+
var parse = (input, options = {}) => {
|
|
852
|
+
if (typeof input !== "string") {
|
|
853
|
+
throw new TypeError("Expected a string");
|
|
854
|
+
}
|
|
855
|
+
const opts = options || {};
|
|
856
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
857
|
+
if (input.length > max) {
|
|
858
|
+
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
|
859
|
+
}
|
|
860
|
+
const ast = { type: "root", input, nodes: [] };
|
|
861
|
+
const stack = [ast];
|
|
862
|
+
let block = ast;
|
|
863
|
+
let prev = ast;
|
|
864
|
+
let brackets = 0;
|
|
865
|
+
const length = input.length;
|
|
866
|
+
let index = 0;
|
|
867
|
+
let depth = 0;
|
|
868
|
+
let value;
|
|
869
|
+
const advance = () => input[index++];
|
|
870
|
+
const push = (node) => {
|
|
871
|
+
if (node.type === "text" && prev.type === "dot") {
|
|
872
|
+
prev.type = "text";
|
|
873
|
+
}
|
|
874
|
+
if (prev && prev.type === "text" && node.type === "text") {
|
|
875
|
+
prev.value += node.value;
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
block.nodes.push(node);
|
|
879
|
+
node.parent = block;
|
|
880
|
+
node.prev = prev;
|
|
881
|
+
prev = node;
|
|
882
|
+
return node;
|
|
883
|
+
};
|
|
884
|
+
push({ type: "bos" });
|
|
885
|
+
while (index < length) {
|
|
886
|
+
block = stack[stack.length - 1];
|
|
887
|
+
value = advance();
|
|
888
|
+
if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
|
|
889
|
+
continue;
|
|
890
|
+
}
|
|
891
|
+
if (value === CHAR_BACKSLASH) {
|
|
892
|
+
push({ type: "text", value: (options.keepEscaping ? value : "") + advance() });
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
if (value === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
896
|
+
push({ type: "text", value: "\\" + value });
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
|
900
|
+
brackets++;
|
|
901
|
+
let next;
|
|
902
|
+
while (index < length && (next = advance())) {
|
|
903
|
+
value += next;
|
|
904
|
+
if (next === CHAR_LEFT_SQUARE_BRACKET) {
|
|
905
|
+
brackets++;
|
|
906
|
+
continue;
|
|
907
|
+
}
|
|
908
|
+
if (next === CHAR_BACKSLASH) {
|
|
909
|
+
value += advance();
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
912
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
913
|
+
brackets--;
|
|
914
|
+
if (brackets === 0) {
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
push({ type: "text", value });
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
if (value === CHAR_LEFT_PARENTHESES) {
|
|
923
|
+
block = push({ type: "paren", nodes: [] });
|
|
924
|
+
stack.push(block);
|
|
925
|
+
push({ type: "text", value });
|
|
926
|
+
continue;
|
|
927
|
+
}
|
|
928
|
+
if (value === CHAR_RIGHT_PARENTHESES) {
|
|
929
|
+
if (block.type !== "paren") {
|
|
930
|
+
push({ type: "text", value });
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
block = stack.pop();
|
|
934
|
+
push({ type: "text", value });
|
|
935
|
+
block = stack[stack.length - 1];
|
|
936
|
+
continue;
|
|
937
|
+
}
|
|
938
|
+
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
|
939
|
+
const open = value;
|
|
940
|
+
let next;
|
|
941
|
+
if (options.keepQuotes !== true) {
|
|
942
|
+
value = "";
|
|
943
|
+
}
|
|
944
|
+
while (index < length && (next = advance())) {
|
|
945
|
+
if (next === CHAR_BACKSLASH) {
|
|
946
|
+
value += next + advance();
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
if (next === open) {
|
|
950
|
+
if (options.keepQuotes === true) value += next;
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
value += next;
|
|
954
|
+
}
|
|
955
|
+
push({ type: "text", value });
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
if (value === CHAR_LEFT_CURLY_BRACE) {
|
|
959
|
+
depth++;
|
|
960
|
+
const dollar = prev.value && prev.value.slice(-1) === "$" || block.dollar === true;
|
|
961
|
+
const brace = {
|
|
962
|
+
type: "brace",
|
|
963
|
+
open: true,
|
|
964
|
+
close: false,
|
|
965
|
+
dollar,
|
|
966
|
+
depth,
|
|
967
|
+
commas: 0,
|
|
968
|
+
ranges: 0,
|
|
969
|
+
nodes: []
|
|
970
|
+
};
|
|
971
|
+
block = push(brace);
|
|
972
|
+
stack.push(block);
|
|
973
|
+
push({ type: "open", value });
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
976
|
+
if (value === CHAR_RIGHT_CURLY_BRACE) {
|
|
977
|
+
if (block.type !== "brace") {
|
|
978
|
+
push({ type: "text", value });
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
981
|
+
const type = "close";
|
|
982
|
+
block = stack.pop();
|
|
983
|
+
block.close = true;
|
|
984
|
+
push({ type, value });
|
|
985
|
+
depth--;
|
|
986
|
+
block = stack[stack.length - 1];
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
989
|
+
if (value === CHAR_COMMA && depth > 0) {
|
|
990
|
+
if (block.ranges > 0) {
|
|
991
|
+
block.ranges = 0;
|
|
992
|
+
const open = block.nodes.shift();
|
|
993
|
+
block.nodes = [open, { type: "text", value: stringify(block) }];
|
|
994
|
+
}
|
|
995
|
+
push({ type: "comma", value });
|
|
996
|
+
block.commas++;
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
|
1000
|
+
const siblings = block.nodes;
|
|
1001
|
+
if (depth === 0 || siblings.length === 0) {
|
|
1002
|
+
push({ type: "text", value });
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
if (prev.type === "dot") {
|
|
1006
|
+
block.range = [];
|
|
1007
|
+
prev.value += value;
|
|
1008
|
+
prev.type = "range";
|
|
1009
|
+
if (block.nodes.length !== 3 && block.nodes.length !== 5) {
|
|
1010
|
+
block.invalid = true;
|
|
1011
|
+
block.ranges = 0;
|
|
1012
|
+
prev.type = "text";
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
block.ranges++;
|
|
1016
|
+
block.args = [];
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
if (prev.type === "range") {
|
|
1020
|
+
siblings.pop();
|
|
1021
|
+
const before = siblings[siblings.length - 1];
|
|
1022
|
+
before.value += prev.value + value;
|
|
1023
|
+
prev = before;
|
|
1024
|
+
block.ranges--;
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
1027
|
+
push({ type: "dot", value });
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
push({ type: "text", value });
|
|
1031
|
+
}
|
|
1032
|
+
do {
|
|
1033
|
+
block = stack.pop();
|
|
1034
|
+
if (block.type !== "root") {
|
|
1035
|
+
block.nodes.forEach((node) => {
|
|
1036
|
+
if (!node.nodes) {
|
|
1037
|
+
if (node.type === "open") node.isOpen = true;
|
|
1038
|
+
if (node.type === "close") node.isClose = true;
|
|
1039
|
+
if (!node.nodes) node.type = "text";
|
|
1040
|
+
node.invalid = true;
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
const parent = stack[stack.length - 1];
|
|
1044
|
+
const index2 = parent.nodes.indexOf(block);
|
|
1045
|
+
parent.nodes.splice(index2, 1, ...block.nodes);
|
|
1046
|
+
}
|
|
1047
|
+
} while (stack.length > 0);
|
|
1048
|
+
push({ type: "eos" });
|
|
1049
|
+
return ast;
|
|
1050
|
+
};
|
|
1051
|
+
module.exports = parse;
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1055
|
+
// ../../node_modules/braces/index.js
|
|
1056
|
+
var require_braces = __commonJS({
|
|
1057
|
+
"../../node_modules/braces/index.js"(exports, module) {
|
|
1058
|
+
"use strict";
|
|
1059
|
+
var stringify = require_stringify();
|
|
1060
|
+
var compile = require_compile();
|
|
1061
|
+
var expand = require_expand();
|
|
1062
|
+
var parse = require_parse();
|
|
1063
|
+
var braces = (input, options = {}) => {
|
|
1064
|
+
let output = [];
|
|
1065
|
+
if (Array.isArray(input)) {
|
|
1066
|
+
for (const pattern of input) {
|
|
1067
|
+
const result = braces.create(pattern, options);
|
|
1068
|
+
if (Array.isArray(result)) {
|
|
1069
|
+
output.push(...result);
|
|
1070
|
+
} else {
|
|
1071
|
+
output.push(result);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
} else {
|
|
1075
|
+
output = [].concat(braces.create(input, options));
|
|
1076
|
+
}
|
|
1077
|
+
if (options && options.expand === true && options.nodupes === true) {
|
|
1078
|
+
output = [...new Set(output)];
|
|
1079
|
+
}
|
|
1080
|
+
return output;
|
|
1081
|
+
};
|
|
1082
|
+
braces.parse = (input, options = {}) => parse(input, options);
|
|
1083
|
+
braces.stringify = (input, options = {}) => {
|
|
1084
|
+
if (typeof input === "string") {
|
|
1085
|
+
return stringify(braces.parse(input, options), options);
|
|
1086
|
+
}
|
|
1087
|
+
return stringify(input, options);
|
|
1088
|
+
};
|
|
1089
|
+
braces.compile = (input, options = {}) => {
|
|
1090
|
+
if (typeof input === "string") {
|
|
1091
|
+
input = braces.parse(input, options);
|
|
1092
|
+
}
|
|
1093
|
+
return compile(input, options);
|
|
1094
|
+
};
|
|
1095
|
+
braces.expand = (input, options = {}) => {
|
|
1096
|
+
if (typeof input === "string") {
|
|
1097
|
+
input = braces.parse(input, options);
|
|
1098
|
+
}
|
|
1099
|
+
let result = expand(input, options);
|
|
1100
|
+
if (options.noempty === true) {
|
|
1101
|
+
result = result.filter(Boolean);
|
|
1102
|
+
}
|
|
1103
|
+
if (options.nodupes === true) {
|
|
1104
|
+
result = [...new Set(result)];
|
|
1105
|
+
}
|
|
1106
|
+
return result;
|
|
1107
|
+
};
|
|
1108
|
+
braces.create = (input, options = {}) => {
|
|
1109
|
+
if (input === "" || input.length < 3) {
|
|
1110
|
+
return [input];
|
|
1111
|
+
}
|
|
1112
|
+
return options.expand !== true ? braces.compile(input, options) : braces.expand(input, options);
|
|
1113
|
+
};
|
|
1114
|
+
module.exports = braces;
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
// ../../node_modules/micromatch/node_modules/picomatch/lib/constants.js
|
|
1119
|
+
var require_constants2 = __commonJS({
|
|
1120
|
+
"../../node_modules/micromatch/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
1121
|
+
"use strict";
|
|
1122
|
+
var path = __require("path");
|
|
1123
|
+
var WIN_SLASH = "\\\\/";
|
|
1124
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
1125
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
1126
|
+
var DOT_LITERAL = "\\.";
|
|
1127
|
+
var PLUS_LITERAL = "\\+";
|
|
1128
|
+
var QMARK_LITERAL = "\\?";
|
|
1129
|
+
var SLASH_LITERAL = "\\/";
|
|
1130
|
+
var ONE_CHAR = "(?=.)";
|
|
1131
|
+
var QMARK = "[^/]";
|
|
1132
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
1133
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
1134
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
1135
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
1136
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
1137
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
1138
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
1139
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
1140
|
+
var STAR = `${QMARK}*?`;
|
|
1141
|
+
var POSIX_CHARS = {
|
|
1142
|
+
DOT_LITERAL,
|
|
1143
|
+
PLUS_LITERAL,
|
|
1144
|
+
QMARK_LITERAL,
|
|
1145
|
+
SLASH_LITERAL,
|
|
1146
|
+
ONE_CHAR,
|
|
1147
|
+
QMARK,
|
|
1148
|
+
END_ANCHOR,
|
|
1149
|
+
DOTS_SLASH,
|
|
1150
|
+
NO_DOT,
|
|
1151
|
+
NO_DOTS,
|
|
1152
|
+
NO_DOT_SLASH,
|
|
1153
|
+
NO_DOTS_SLASH,
|
|
1154
|
+
QMARK_NO_DOT,
|
|
1155
|
+
STAR,
|
|
1156
|
+
START_ANCHOR
|
|
1157
|
+
};
|
|
1158
|
+
var WINDOWS_CHARS = {
|
|
1159
|
+
...POSIX_CHARS,
|
|
1160
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
1161
|
+
QMARK: WIN_NO_SLASH,
|
|
1162
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
1163
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
1164
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
1165
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
1166
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
1167
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
1168
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
1169
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
1170
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
1171
|
+
};
|
|
1172
|
+
var POSIX_REGEX_SOURCE = {
|
|
1173
|
+
__proto__: null,
|
|
1174
|
+
alnum: "a-zA-Z0-9",
|
|
1175
|
+
alpha: "a-zA-Z",
|
|
1176
|
+
ascii: "\\x00-\\x7F",
|
|
1177
|
+
blank: " \\t",
|
|
1178
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
1179
|
+
digit: "0-9",
|
|
1180
|
+
graph: "\\x21-\\x7E",
|
|
1181
|
+
lower: "a-z",
|
|
1182
|
+
print: "\\x20-\\x7E ",
|
|
1183
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
1184
|
+
space: " \\t\\r\\n\\v\\f",
|
|
1185
|
+
upper: "A-Z",
|
|
1186
|
+
word: "A-Za-z0-9_",
|
|
1187
|
+
xdigit: "A-Fa-f0-9"
|
|
1188
|
+
};
|
|
1189
|
+
module.exports = {
|
|
1190
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
1191
|
+
MAX_LENGTH: 1024 * 64,
|
|
1192
|
+
POSIX_REGEX_SOURCE,
|
|
1193
|
+
// regular expressions
|
|
1194
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
1195
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
1196
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
1197
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
1198
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
1199
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
1200
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
1201
|
+
REPLACEMENTS: {
|
|
1202
|
+
__proto__: null,
|
|
1203
|
+
"***": "*",
|
|
1204
|
+
"**/**": "**",
|
|
1205
|
+
"**/**/**": "**"
|
|
1206
|
+
},
|
|
1207
|
+
// Digits
|
|
1208
|
+
CHAR_0: 48,
|
|
1209
|
+
/* 0 */
|
|
1210
|
+
CHAR_9: 57,
|
|
1211
|
+
/* 9 */
|
|
1212
|
+
// Alphabet chars.
|
|
1213
|
+
CHAR_UPPERCASE_A: 65,
|
|
1214
|
+
/* A */
|
|
1215
|
+
CHAR_LOWERCASE_A: 97,
|
|
1216
|
+
/* a */
|
|
1217
|
+
CHAR_UPPERCASE_Z: 90,
|
|
1218
|
+
/* Z */
|
|
1219
|
+
CHAR_LOWERCASE_Z: 122,
|
|
1220
|
+
/* z */
|
|
1221
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
1222
|
+
/* ( */
|
|
1223
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
1224
|
+
/* ) */
|
|
1225
|
+
CHAR_ASTERISK: 42,
|
|
1226
|
+
/* * */
|
|
1227
|
+
// Non-alphabetic chars.
|
|
1228
|
+
CHAR_AMPERSAND: 38,
|
|
1229
|
+
/* & */
|
|
1230
|
+
CHAR_AT: 64,
|
|
1231
|
+
/* @ */
|
|
1232
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
1233
|
+
/* \ */
|
|
1234
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
1235
|
+
/* \r */
|
|
1236
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
1237
|
+
/* ^ */
|
|
1238
|
+
CHAR_COLON: 58,
|
|
1239
|
+
/* : */
|
|
1240
|
+
CHAR_COMMA: 44,
|
|
1241
|
+
/* , */
|
|
1242
|
+
CHAR_DOT: 46,
|
|
1243
|
+
/* . */
|
|
1244
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
1245
|
+
/* " */
|
|
1246
|
+
CHAR_EQUAL: 61,
|
|
1247
|
+
/* = */
|
|
1248
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
1249
|
+
/* ! */
|
|
1250
|
+
CHAR_FORM_FEED: 12,
|
|
1251
|
+
/* \f */
|
|
1252
|
+
CHAR_FORWARD_SLASH: 47,
|
|
1253
|
+
/* / */
|
|
1254
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
1255
|
+
/* ` */
|
|
1256
|
+
CHAR_HASH: 35,
|
|
1257
|
+
/* # */
|
|
1258
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
1259
|
+
/* - */
|
|
1260
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
1261
|
+
/* < */
|
|
1262
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
1263
|
+
/* { */
|
|
1264
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
1265
|
+
/* [ */
|
|
1266
|
+
CHAR_LINE_FEED: 10,
|
|
1267
|
+
/* \n */
|
|
1268
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
1269
|
+
/* \u00A0 */
|
|
1270
|
+
CHAR_PERCENT: 37,
|
|
1271
|
+
/* % */
|
|
1272
|
+
CHAR_PLUS: 43,
|
|
1273
|
+
/* + */
|
|
1274
|
+
CHAR_QUESTION_MARK: 63,
|
|
1275
|
+
/* ? */
|
|
1276
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
1277
|
+
/* > */
|
|
1278
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
1279
|
+
/* } */
|
|
1280
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
1281
|
+
/* ] */
|
|
1282
|
+
CHAR_SEMICOLON: 59,
|
|
1283
|
+
/* ; */
|
|
1284
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
1285
|
+
/* ' */
|
|
1286
|
+
CHAR_SPACE: 32,
|
|
1287
|
+
/* */
|
|
1288
|
+
CHAR_TAB: 9,
|
|
1289
|
+
/* \t */
|
|
1290
|
+
CHAR_UNDERSCORE: 95,
|
|
1291
|
+
/* _ */
|
|
1292
|
+
CHAR_VERTICAL_LINE: 124,
|
|
1293
|
+
/* | */
|
|
1294
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
1295
|
+
/* \uFEFF */
|
|
1296
|
+
SEP: path.sep,
|
|
1297
|
+
/**
|
|
1298
|
+
* Create EXTGLOB_CHARS
|
|
1299
|
+
*/
|
|
1300
|
+
extglobChars(chars) {
|
|
1301
|
+
return {
|
|
1302
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
1303
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
1304
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
1305
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
1306
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
1307
|
+
};
|
|
1308
|
+
},
|
|
1309
|
+
/**
|
|
1310
|
+
* Create GLOB_CHARS
|
|
1311
|
+
*/
|
|
1312
|
+
globChars(win32) {
|
|
1313
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
|
|
1319
|
+
// ../../node_modules/micromatch/node_modules/picomatch/lib/utils.js
|
|
1320
|
+
var require_utils2 = __commonJS({
|
|
1321
|
+
"../../node_modules/micromatch/node_modules/picomatch/lib/utils.js"(exports) {
|
|
1322
|
+
"use strict";
|
|
1323
|
+
var path = __require("path");
|
|
1324
|
+
var win32 = process.platform === "win32";
|
|
1325
|
+
var {
|
|
1326
|
+
REGEX_BACKSLASH,
|
|
1327
|
+
REGEX_REMOVE_BACKSLASH,
|
|
1328
|
+
REGEX_SPECIAL_CHARS,
|
|
1329
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
1330
|
+
} = require_constants2();
|
|
1331
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1332
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
1333
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
1334
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
1335
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
1336
|
+
exports.removeBackslashes = (str) => {
|
|
1337
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
1338
|
+
return match === "\\" ? "" : match;
|
|
1339
|
+
});
|
|
1340
|
+
};
|
|
1341
|
+
exports.supportsLookbehinds = () => {
|
|
1342
|
+
const segs = process.version.slice(1).split(".").map(Number);
|
|
1343
|
+
if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
|
|
1344
|
+
return true;
|
|
1345
|
+
}
|
|
1346
|
+
return false;
|
|
1347
|
+
};
|
|
1348
|
+
exports.isWindows = (options) => {
|
|
1349
|
+
if (options && typeof options.windows === "boolean") {
|
|
1350
|
+
return options.windows;
|
|
1351
|
+
}
|
|
1352
|
+
return win32 === true || path.sep === "\\";
|
|
1353
|
+
};
|
|
1354
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
1355
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
1356
|
+
if (idx === -1) return input;
|
|
1357
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
1358
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
1359
|
+
};
|
|
1360
|
+
exports.removePrefix = (input, state = {}) => {
|
|
1361
|
+
let output = input;
|
|
1362
|
+
if (output.startsWith("./")) {
|
|
1363
|
+
output = output.slice(2);
|
|
1364
|
+
state.prefix = "./";
|
|
1365
|
+
}
|
|
1366
|
+
return output;
|
|
1367
|
+
};
|
|
1368
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
1369
|
+
const prepend = options.contains ? "" : "^";
|
|
1370
|
+
const append = options.contains ? "" : "$";
|
|
1371
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
1372
|
+
if (state.negated === true) {
|
|
1373
|
+
output = `(?:^(?!${output}).*$)`;
|
|
1374
|
+
}
|
|
1375
|
+
return output;
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
// ../../node_modules/micromatch/node_modules/picomatch/lib/scan.js
|
|
1381
|
+
var require_scan = __commonJS({
|
|
1382
|
+
"../../node_modules/micromatch/node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
1383
|
+
"use strict";
|
|
1384
|
+
var utils = require_utils2();
|
|
1385
|
+
var {
|
|
1386
|
+
CHAR_ASTERISK,
|
|
1387
|
+
/* * */
|
|
1388
|
+
CHAR_AT,
|
|
1389
|
+
/* @ */
|
|
1390
|
+
CHAR_BACKWARD_SLASH,
|
|
1391
|
+
/* \ */
|
|
1392
|
+
CHAR_COMMA,
|
|
1393
|
+
/* , */
|
|
1394
|
+
CHAR_DOT,
|
|
1395
|
+
/* . */
|
|
1396
|
+
CHAR_EXCLAMATION_MARK,
|
|
1397
|
+
/* ! */
|
|
1398
|
+
CHAR_FORWARD_SLASH,
|
|
1399
|
+
/* / */
|
|
1400
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
1401
|
+
/* { */
|
|
1402
|
+
CHAR_LEFT_PARENTHESES,
|
|
1403
|
+
/* ( */
|
|
1404
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
1405
|
+
/* [ */
|
|
1406
|
+
CHAR_PLUS,
|
|
1407
|
+
/* + */
|
|
1408
|
+
CHAR_QUESTION_MARK,
|
|
1409
|
+
/* ? */
|
|
1410
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
1411
|
+
/* } */
|
|
1412
|
+
CHAR_RIGHT_PARENTHESES,
|
|
1413
|
+
/* ) */
|
|
1414
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
1415
|
+
/* ] */
|
|
1416
|
+
} = require_constants2();
|
|
1417
|
+
var isPathSeparator = (code) => {
|
|
1418
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1419
|
+
};
|
|
1420
|
+
var depth = (token) => {
|
|
1421
|
+
if (token.isPrefix !== true) {
|
|
1422
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
var scan = (input, options) => {
|
|
1426
|
+
const opts = options || {};
|
|
1427
|
+
const length = input.length - 1;
|
|
1428
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
1429
|
+
const slashes = [];
|
|
1430
|
+
const tokens = [];
|
|
1431
|
+
const parts = [];
|
|
1432
|
+
let str = input;
|
|
1433
|
+
let index = -1;
|
|
1434
|
+
let start = 0;
|
|
1435
|
+
let lastIndex = 0;
|
|
1436
|
+
let isBrace = false;
|
|
1437
|
+
let isBracket = false;
|
|
1438
|
+
let isGlob = false;
|
|
1439
|
+
let isExtglob = false;
|
|
1440
|
+
let isGlobstar = false;
|
|
1441
|
+
let braceEscaped = false;
|
|
1442
|
+
let backslashes = false;
|
|
1443
|
+
let negated = false;
|
|
1444
|
+
let negatedExtglob = false;
|
|
1445
|
+
let finished = false;
|
|
1446
|
+
let braces = 0;
|
|
1447
|
+
let prev;
|
|
1448
|
+
let code;
|
|
1449
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
1450
|
+
const eos = () => index >= length;
|
|
1451
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
1452
|
+
const advance = () => {
|
|
1453
|
+
prev = code;
|
|
1454
|
+
return str.charCodeAt(++index);
|
|
1455
|
+
};
|
|
1456
|
+
while (index < length) {
|
|
1457
|
+
code = advance();
|
|
1458
|
+
let next;
|
|
1459
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1460
|
+
backslashes = token.backslashes = true;
|
|
1461
|
+
code = advance();
|
|
1462
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1463
|
+
braceEscaped = true;
|
|
1464
|
+
}
|
|
1465
|
+
continue;
|
|
1466
|
+
}
|
|
1467
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1468
|
+
braces++;
|
|
1469
|
+
while (eos() !== true && (code = advance())) {
|
|
1470
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1471
|
+
backslashes = token.backslashes = true;
|
|
1472
|
+
advance();
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1475
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1476
|
+
braces++;
|
|
1477
|
+
continue;
|
|
1478
|
+
}
|
|
1479
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1480
|
+
isBrace = token.isBrace = true;
|
|
1481
|
+
isGlob = token.isGlob = true;
|
|
1482
|
+
finished = true;
|
|
1483
|
+
if (scanToEnd === true) {
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
break;
|
|
1487
|
+
}
|
|
1488
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
1489
|
+
isBrace = token.isBrace = true;
|
|
1490
|
+
isGlob = token.isGlob = true;
|
|
1491
|
+
finished = true;
|
|
1492
|
+
if (scanToEnd === true) {
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
break;
|
|
1496
|
+
}
|
|
1497
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1498
|
+
braces--;
|
|
1499
|
+
if (braces === 0) {
|
|
1500
|
+
braceEscaped = false;
|
|
1501
|
+
isBrace = token.isBrace = true;
|
|
1502
|
+
finished = true;
|
|
1503
|
+
break;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
if (scanToEnd === true) {
|
|
1508
|
+
continue;
|
|
1509
|
+
}
|
|
1510
|
+
break;
|
|
1511
|
+
}
|
|
1512
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
1513
|
+
slashes.push(index);
|
|
1514
|
+
tokens.push(token);
|
|
1515
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
1516
|
+
if (finished === true) continue;
|
|
1517
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
1518
|
+
start += 2;
|
|
1519
|
+
continue;
|
|
1520
|
+
}
|
|
1521
|
+
lastIndex = index + 1;
|
|
1522
|
+
continue;
|
|
1523
|
+
}
|
|
1524
|
+
if (opts.noext !== true) {
|
|
1525
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
1526
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1527
|
+
isGlob = token.isGlob = true;
|
|
1528
|
+
isExtglob = token.isExtglob = true;
|
|
1529
|
+
finished = true;
|
|
1530
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1531
|
+
negatedExtglob = true;
|
|
1532
|
+
}
|
|
1533
|
+
if (scanToEnd === true) {
|
|
1534
|
+
while (eos() !== true && (code = advance())) {
|
|
1535
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1536
|
+
backslashes = token.backslashes = true;
|
|
1537
|
+
code = advance();
|
|
1538
|
+
continue;
|
|
1539
|
+
}
|
|
1540
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1541
|
+
isGlob = token.isGlob = true;
|
|
1542
|
+
finished = true;
|
|
1543
|
+
break;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
continue;
|
|
1547
|
+
}
|
|
1548
|
+
break;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
if (code === CHAR_ASTERISK) {
|
|
1552
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1553
|
+
isGlob = token.isGlob = true;
|
|
1554
|
+
finished = true;
|
|
1555
|
+
if (scanToEnd === true) {
|
|
1556
|
+
continue;
|
|
1557
|
+
}
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
1561
|
+
isGlob = token.isGlob = true;
|
|
1562
|
+
finished = true;
|
|
1563
|
+
if (scanToEnd === true) {
|
|
1564
|
+
continue;
|
|
1565
|
+
}
|
|
1566
|
+
break;
|
|
1567
|
+
}
|
|
1568
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1569
|
+
while (eos() !== true && (next = advance())) {
|
|
1570
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
1571
|
+
backslashes = token.backslashes = true;
|
|
1572
|
+
advance();
|
|
1573
|
+
continue;
|
|
1574
|
+
}
|
|
1575
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1576
|
+
isBracket = token.isBracket = true;
|
|
1577
|
+
isGlob = token.isGlob = true;
|
|
1578
|
+
finished = true;
|
|
1579
|
+
break;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
if (scanToEnd === true) {
|
|
1583
|
+
continue;
|
|
1584
|
+
}
|
|
1585
|
+
break;
|
|
1586
|
+
}
|
|
1587
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1588
|
+
negated = token.negated = true;
|
|
1589
|
+
start++;
|
|
1590
|
+
continue;
|
|
1591
|
+
}
|
|
1592
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
1593
|
+
isGlob = token.isGlob = true;
|
|
1594
|
+
if (scanToEnd === true) {
|
|
1595
|
+
while (eos() !== true && (code = advance())) {
|
|
1596
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1597
|
+
backslashes = token.backslashes = true;
|
|
1598
|
+
code = advance();
|
|
1599
|
+
continue;
|
|
1600
|
+
}
|
|
1601
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1602
|
+
finished = true;
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
continue;
|
|
1607
|
+
}
|
|
1608
|
+
break;
|
|
1609
|
+
}
|
|
1610
|
+
if (isGlob === true) {
|
|
1611
|
+
finished = true;
|
|
1612
|
+
if (scanToEnd === true) {
|
|
1613
|
+
continue;
|
|
1614
|
+
}
|
|
1615
|
+
break;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
if (opts.noext === true) {
|
|
1619
|
+
isExtglob = false;
|
|
1620
|
+
isGlob = false;
|
|
1621
|
+
}
|
|
1622
|
+
let base = str;
|
|
1623
|
+
let prefix = "";
|
|
1624
|
+
let glob = "";
|
|
1625
|
+
if (start > 0) {
|
|
1626
|
+
prefix = str.slice(0, start);
|
|
1627
|
+
str = str.slice(start);
|
|
1628
|
+
lastIndex -= start;
|
|
1629
|
+
}
|
|
1630
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
1631
|
+
base = str.slice(0, lastIndex);
|
|
1632
|
+
glob = str.slice(lastIndex);
|
|
1633
|
+
} else if (isGlob === true) {
|
|
1634
|
+
base = "";
|
|
1635
|
+
glob = str;
|
|
1636
|
+
} else {
|
|
1637
|
+
base = str;
|
|
1638
|
+
}
|
|
1639
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
1640
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
1641
|
+
base = base.slice(0, -1);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
if (opts.unescape === true) {
|
|
1645
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
1646
|
+
if (base && backslashes === true) {
|
|
1647
|
+
base = utils.removeBackslashes(base);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
const state = {
|
|
1651
|
+
prefix,
|
|
1652
|
+
input,
|
|
1653
|
+
start,
|
|
1654
|
+
base,
|
|
1655
|
+
glob,
|
|
1656
|
+
isBrace,
|
|
1657
|
+
isBracket,
|
|
1658
|
+
isGlob,
|
|
1659
|
+
isExtglob,
|
|
1660
|
+
isGlobstar,
|
|
1661
|
+
negated,
|
|
1662
|
+
negatedExtglob
|
|
1663
|
+
};
|
|
1664
|
+
if (opts.tokens === true) {
|
|
1665
|
+
state.maxDepth = 0;
|
|
1666
|
+
if (!isPathSeparator(code)) {
|
|
1667
|
+
tokens.push(token);
|
|
1668
|
+
}
|
|
1669
|
+
state.tokens = tokens;
|
|
1670
|
+
}
|
|
1671
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
1672
|
+
let prevIndex;
|
|
1673
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1674
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
1675
|
+
const i = slashes[idx];
|
|
1676
|
+
const value = input.slice(n, i);
|
|
1677
|
+
if (opts.tokens) {
|
|
1678
|
+
if (idx === 0 && start !== 0) {
|
|
1679
|
+
tokens[idx].isPrefix = true;
|
|
1680
|
+
tokens[idx].value = prefix;
|
|
1681
|
+
} else {
|
|
1682
|
+
tokens[idx].value = value;
|
|
1683
|
+
}
|
|
1684
|
+
depth(tokens[idx]);
|
|
1685
|
+
state.maxDepth += tokens[idx].depth;
|
|
1686
|
+
}
|
|
1687
|
+
if (idx !== 0 || value !== "") {
|
|
1688
|
+
parts.push(value);
|
|
1689
|
+
}
|
|
1690
|
+
prevIndex = i;
|
|
1691
|
+
}
|
|
1692
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1693
|
+
const value = input.slice(prevIndex + 1);
|
|
1694
|
+
parts.push(value);
|
|
1695
|
+
if (opts.tokens) {
|
|
1696
|
+
tokens[tokens.length - 1].value = value;
|
|
1697
|
+
depth(tokens[tokens.length - 1]);
|
|
1698
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
state.slashes = slashes;
|
|
1702
|
+
state.parts = parts;
|
|
1703
|
+
}
|
|
1704
|
+
return state;
|
|
1705
|
+
};
|
|
1706
|
+
module.exports = scan;
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1710
|
+
// ../../node_modules/micromatch/node_modules/picomatch/lib/parse.js
|
|
1711
|
+
var require_parse2 = __commonJS({
|
|
1712
|
+
"../../node_modules/micromatch/node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
1713
|
+
"use strict";
|
|
1714
|
+
var constants2 = require_constants2();
|
|
1715
|
+
var utils = require_utils2();
|
|
1716
|
+
var {
|
|
1717
|
+
MAX_LENGTH,
|
|
1718
|
+
POSIX_REGEX_SOURCE,
|
|
1719
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
1720
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
1721
|
+
REPLACEMENTS
|
|
1722
|
+
} = constants2;
|
|
1723
|
+
var expandRange = (args, options) => {
|
|
1724
|
+
if (typeof options.expandRange === "function") {
|
|
1725
|
+
return options.expandRange(...args, options);
|
|
1726
|
+
}
|
|
1727
|
+
args.sort();
|
|
1728
|
+
const value = `[${args.join("-")}]`;
|
|
1729
|
+
try {
|
|
1730
|
+
new RegExp(value);
|
|
1731
|
+
} catch (ex) {
|
|
1732
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
1733
|
+
}
|
|
1734
|
+
return value;
|
|
1735
|
+
};
|
|
1736
|
+
var syntaxError = (type, char) => {
|
|
1737
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1738
|
+
};
|
|
1739
|
+
var splitTopLevel = (input) => {
|
|
1740
|
+
const parts = [];
|
|
1741
|
+
let bracket = 0;
|
|
1742
|
+
let paren = 0;
|
|
1743
|
+
let quote = 0;
|
|
1744
|
+
let value = "";
|
|
1745
|
+
let escaped = false;
|
|
1746
|
+
for (const ch of input) {
|
|
1747
|
+
if (escaped === true) {
|
|
1748
|
+
value += ch;
|
|
1749
|
+
escaped = false;
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
if (ch === "\\") {
|
|
1753
|
+
value += ch;
|
|
1754
|
+
escaped = true;
|
|
1755
|
+
continue;
|
|
1756
|
+
}
|
|
1757
|
+
if (ch === '"') {
|
|
1758
|
+
quote = quote === 1 ? 0 : 1;
|
|
1759
|
+
value += ch;
|
|
1760
|
+
continue;
|
|
1761
|
+
}
|
|
1762
|
+
if (quote === 0) {
|
|
1763
|
+
if (ch === "[") {
|
|
1764
|
+
bracket++;
|
|
1765
|
+
} else if (ch === "]" && bracket > 0) {
|
|
1766
|
+
bracket--;
|
|
1767
|
+
} else if (bracket === 0) {
|
|
1768
|
+
if (ch === "(") {
|
|
1769
|
+
paren++;
|
|
1770
|
+
} else if (ch === ")" && paren > 0) {
|
|
1771
|
+
paren--;
|
|
1772
|
+
} else if (ch === "|" && paren === 0) {
|
|
1773
|
+
parts.push(value);
|
|
1774
|
+
value = "";
|
|
1775
|
+
continue;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
value += ch;
|
|
1780
|
+
}
|
|
1781
|
+
parts.push(value);
|
|
1782
|
+
return parts;
|
|
1783
|
+
};
|
|
1784
|
+
var isPlainBranch = (branch) => {
|
|
1785
|
+
let escaped = false;
|
|
1786
|
+
for (const ch of branch) {
|
|
1787
|
+
if (escaped === true) {
|
|
1788
|
+
escaped = false;
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
if (ch === "\\") {
|
|
1792
|
+
escaped = true;
|
|
1793
|
+
continue;
|
|
1794
|
+
}
|
|
1795
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
1796
|
+
return false;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
return true;
|
|
1800
|
+
};
|
|
1801
|
+
var normalizeSimpleBranch = (branch) => {
|
|
1802
|
+
let value = branch.trim();
|
|
1803
|
+
let changed = true;
|
|
1804
|
+
while (changed === true) {
|
|
1805
|
+
changed = false;
|
|
1806
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
1807
|
+
value = value.slice(2, -1);
|
|
1808
|
+
changed = true;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
if (!isPlainBranch(value)) {
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
return value.replace(/\\(.)/g, "$1");
|
|
1815
|
+
};
|
|
1816
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
1817
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
1818
|
+
for (let i = 0; i < values.length; i++) {
|
|
1819
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
1820
|
+
const a = values[i];
|
|
1821
|
+
const b = values[j];
|
|
1822
|
+
const char = a[0];
|
|
1823
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
1827
|
+
return true;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
return false;
|
|
1832
|
+
};
|
|
1833
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
1834
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
1835
|
+
return;
|
|
1836
|
+
}
|
|
1837
|
+
let bracket = 0;
|
|
1838
|
+
let paren = 0;
|
|
1839
|
+
let quote = 0;
|
|
1840
|
+
let escaped = false;
|
|
1841
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
1842
|
+
const ch = pattern[i];
|
|
1843
|
+
if (escaped === true) {
|
|
1844
|
+
escaped = false;
|
|
1845
|
+
continue;
|
|
1846
|
+
}
|
|
1847
|
+
if (ch === "\\") {
|
|
1848
|
+
escaped = true;
|
|
1849
|
+
continue;
|
|
1850
|
+
}
|
|
1851
|
+
if (ch === '"') {
|
|
1852
|
+
quote = quote === 1 ? 0 : 1;
|
|
1853
|
+
continue;
|
|
1854
|
+
}
|
|
1855
|
+
if (quote === 1) {
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
if (ch === "[") {
|
|
1859
|
+
bracket++;
|
|
1860
|
+
continue;
|
|
1861
|
+
}
|
|
1862
|
+
if (ch === "]" && bracket > 0) {
|
|
1863
|
+
bracket--;
|
|
1864
|
+
continue;
|
|
1865
|
+
}
|
|
1866
|
+
if (bracket > 0) {
|
|
1867
|
+
continue;
|
|
1868
|
+
}
|
|
1869
|
+
if (ch === "(") {
|
|
1870
|
+
paren++;
|
|
1871
|
+
continue;
|
|
1872
|
+
}
|
|
1873
|
+
if (ch === ")") {
|
|
1874
|
+
paren--;
|
|
1875
|
+
if (paren === 0) {
|
|
1876
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
return {
|
|
1880
|
+
type: pattern[0],
|
|
1881
|
+
body: pattern.slice(2, i),
|
|
1882
|
+
end: i
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
1889
|
+
let index = 0;
|
|
1890
|
+
const chars = [];
|
|
1891
|
+
while (index < pattern.length) {
|
|
1892
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
1893
|
+
if (!match || match.type !== "*") {
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
1897
|
+
if (branches.length !== 1) {
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
1901
|
+
if (!branch || branch.length !== 1) {
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
chars.push(branch);
|
|
1905
|
+
index += match.end + 1;
|
|
1906
|
+
}
|
|
1907
|
+
if (chars.length < 1) {
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
1911
|
+
return `${source}*`;
|
|
1912
|
+
};
|
|
1913
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
1914
|
+
let depth = 0;
|
|
1915
|
+
let value = pattern.trim();
|
|
1916
|
+
let match = parseRepeatedExtglob(value);
|
|
1917
|
+
while (match) {
|
|
1918
|
+
depth++;
|
|
1919
|
+
value = match.body.trim();
|
|
1920
|
+
match = parseRepeatedExtglob(value);
|
|
1921
|
+
}
|
|
1922
|
+
return depth;
|
|
1923
|
+
};
|
|
1924
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
1925
|
+
if (options.maxExtglobRecursion === false) {
|
|
1926
|
+
return { risky: false };
|
|
1927
|
+
}
|
|
1928
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants2.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
1929
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
1930
|
+
if (branches.length > 1) {
|
|
1931
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
1932
|
+
return { risky: true };
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
for (const branch of branches) {
|
|
1936
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
1937
|
+
if (safeOutput) {
|
|
1938
|
+
return { risky: true, safeOutput };
|
|
1939
|
+
}
|
|
1940
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
1941
|
+
return { risky: true };
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
return { risky: false };
|
|
1945
|
+
};
|
|
1946
|
+
var parse = (input, options) => {
|
|
1947
|
+
if (typeof input !== "string") {
|
|
1948
|
+
throw new TypeError("Expected a string");
|
|
1949
|
+
}
|
|
1950
|
+
input = REPLACEMENTS[input] || input;
|
|
1951
|
+
const opts = { ...options };
|
|
1952
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1953
|
+
let len = input.length;
|
|
1954
|
+
if (len > max) {
|
|
1955
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1956
|
+
}
|
|
1957
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
1958
|
+
const tokens = [bos];
|
|
1959
|
+
const capture = opts.capture ? "" : "?:";
|
|
1960
|
+
const win32 = utils.isWindows(options);
|
|
1961
|
+
const PLATFORM_CHARS = constants2.globChars(win32);
|
|
1962
|
+
const EXTGLOB_CHARS = constants2.extglobChars(PLATFORM_CHARS);
|
|
1963
|
+
const {
|
|
1964
|
+
DOT_LITERAL,
|
|
1965
|
+
PLUS_LITERAL,
|
|
1966
|
+
SLASH_LITERAL,
|
|
1967
|
+
ONE_CHAR,
|
|
1968
|
+
DOTS_SLASH,
|
|
1969
|
+
NO_DOT,
|
|
1970
|
+
NO_DOT_SLASH,
|
|
1971
|
+
NO_DOTS_SLASH,
|
|
1972
|
+
QMARK,
|
|
1973
|
+
QMARK_NO_DOT,
|
|
1974
|
+
STAR,
|
|
1975
|
+
START_ANCHOR
|
|
1976
|
+
} = PLATFORM_CHARS;
|
|
1977
|
+
const globstar = (opts2) => {
|
|
1978
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1979
|
+
};
|
|
1980
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
1981
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
1982
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
1983
|
+
if (opts.capture) {
|
|
1984
|
+
star = `(${star})`;
|
|
1985
|
+
}
|
|
1986
|
+
if (typeof opts.noext === "boolean") {
|
|
1987
|
+
opts.noextglob = opts.noext;
|
|
1988
|
+
}
|
|
1989
|
+
const state = {
|
|
1990
|
+
input,
|
|
1991
|
+
index: -1,
|
|
1992
|
+
start: 0,
|
|
1993
|
+
dot: opts.dot === true,
|
|
1994
|
+
consumed: "",
|
|
1995
|
+
output: "",
|
|
1996
|
+
prefix: "",
|
|
1997
|
+
backtrack: false,
|
|
1998
|
+
negated: false,
|
|
1999
|
+
brackets: 0,
|
|
2000
|
+
braces: 0,
|
|
2001
|
+
parens: 0,
|
|
2002
|
+
quotes: 0,
|
|
2003
|
+
globstar: false,
|
|
2004
|
+
tokens
|
|
2005
|
+
};
|
|
2006
|
+
input = utils.removePrefix(input, state);
|
|
2007
|
+
len = input.length;
|
|
2008
|
+
const extglobs = [];
|
|
2009
|
+
const braces = [];
|
|
2010
|
+
const stack = [];
|
|
2011
|
+
let prev = bos;
|
|
2012
|
+
let value;
|
|
2013
|
+
const eos = () => state.index === len - 1;
|
|
2014
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
2015
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
2016
|
+
const remaining = () => input.slice(state.index + 1);
|
|
2017
|
+
const consume = (value2 = "", num = 0) => {
|
|
2018
|
+
state.consumed += value2;
|
|
2019
|
+
state.index += num;
|
|
2020
|
+
};
|
|
2021
|
+
const append = (token) => {
|
|
2022
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2023
|
+
consume(token.value);
|
|
2024
|
+
};
|
|
2025
|
+
const negate = () => {
|
|
2026
|
+
let count = 1;
|
|
2027
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
2028
|
+
advance();
|
|
2029
|
+
state.start++;
|
|
2030
|
+
count++;
|
|
2031
|
+
}
|
|
2032
|
+
if (count % 2 === 0) {
|
|
2033
|
+
return false;
|
|
2034
|
+
}
|
|
2035
|
+
state.negated = true;
|
|
2036
|
+
state.start++;
|
|
2037
|
+
return true;
|
|
2038
|
+
};
|
|
2039
|
+
const increment = (type) => {
|
|
2040
|
+
state[type]++;
|
|
2041
|
+
stack.push(type);
|
|
2042
|
+
};
|
|
2043
|
+
const decrement = (type) => {
|
|
2044
|
+
state[type]--;
|
|
2045
|
+
stack.pop();
|
|
2046
|
+
};
|
|
2047
|
+
const push = (tok) => {
|
|
2048
|
+
if (prev.type === "globstar") {
|
|
2049
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
2050
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
2051
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
2052
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
2053
|
+
prev.type = "star";
|
|
2054
|
+
prev.value = "*";
|
|
2055
|
+
prev.output = star;
|
|
2056
|
+
state.output += prev.output;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
2060
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
2061
|
+
}
|
|
2062
|
+
if (tok.value || tok.output) append(tok);
|
|
2063
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
2064
|
+
prev.value += tok.value;
|
|
2065
|
+
prev.output = (prev.output || "") + tok.value;
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2068
|
+
tok.prev = prev;
|
|
2069
|
+
tokens.push(tok);
|
|
2070
|
+
prev = tok;
|
|
2071
|
+
};
|
|
2072
|
+
const extglobOpen = (type, value2) => {
|
|
2073
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
2074
|
+
token.prev = prev;
|
|
2075
|
+
token.parens = state.parens;
|
|
2076
|
+
token.output = state.output;
|
|
2077
|
+
token.startIndex = state.index;
|
|
2078
|
+
token.tokensIndex = tokens.length;
|
|
2079
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
2080
|
+
increment("parens");
|
|
2081
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
2082
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
2083
|
+
extglobs.push(token);
|
|
2084
|
+
};
|
|
2085
|
+
const extglobClose = (token) => {
|
|
2086
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
2087
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
2088
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
2089
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
2090
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
2091
|
+
const open = tokens[token.tokensIndex];
|
|
2092
|
+
open.type = "text";
|
|
2093
|
+
open.value = literal;
|
|
2094
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
2095
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
2096
|
+
tokens[i].value = "";
|
|
2097
|
+
tokens[i].output = "";
|
|
2098
|
+
delete tokens[i].suffix;
|
|
2099
|
+
}
|
|
2100
|
+
state.output = token.output + open.output;
|
|
2101
|
+
state.backtrack = true;
|
|
2102
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
2103
|
+
decrement("parens");
|
|
2104
|
+
return;
|
|
2105
|
+
}
|
|
2106
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
2107
|
+
let rest;
|
|
2108
|
+
if (token.type === "negate") {
|
|
2109
|
+
let extglobStar = star;
|
|
2110
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
2111
|
+
extglobStar = globstar(opts);
|
|
2112
|
+
}
|
|
2113
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
2114
|
+
output = token.close = `)$))${extglobStar}`;
|
|
2115
|
+
}
|
|
2116
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
2117
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
2118
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
2119
|
+
}
|
|
2120
|
+
if (token.prev.type === "bos") {
|
|
2121
|
+
state.negatedExtglob = true;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
push({ type: "paren", extglob: true, value, output });
|
|
2125
|
+
decrement("parens");
|
|
2126
|
+
};
|
|
2127
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
2128
|
+
let backslashes = false;
|
|
2129
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
2130
|
+
if (first === "\\") {
|
|
2131
|
+
backslashes = true;
|
|
2132
|
+
return m;
|
|
2133
|
+
}
|
|
2134
|
+
if (first === "?") {
|
|
2135
|
+
if (esc) {
|
|
2136
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
2137
|
+
}
|
|
2138
|
+
if (index === 0) {
|
|
2139
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
2140
|
+
}
|
|
2141
|
+
return QMARK.repeat(chars.length);
|
|
2142
|
+
}
|
|
2143
|
+
if (first === ".") {
|
|
2144
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
2145
|
+
}
|
|
2146
|
+
if (first === "*") {
|
|
2147
|
+
if (esc) {
|
|
2148
|
+
return esc + first + (rest ? star : "");
|
|
2149
|
+
}
|
|
2150
|
+
return star;
|
|
2151
|
+
}
|
|
2152
|
+
return esc ? m : `\\${m}`;
|
|
2153
|
+
});
|
|
2154
|
+
if (backslashes === true) {
|
|
2155
|
+
if (opts.unescape === true) {
|
|
2156
|
+
output = output.replace(/\\/g, "");
|
|
2157
|
+
} else {
|
|
2158
|
+
output = output.replace(/\\+/g, (m) => {
|
|
2159
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
if (output === input && opts.contains === true) {
|
|
2164
|
+
state.output = input;
|
|
2165
|
+
return state;
|
|
2166
|
+
}
|
|
2167
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
2168
|
+
return state;
|
|
2169
|
+
}
|
|
2170
|
+
while (!eos()) {
|
|
2171
|
+
value = advance();
|
|
2172
|
+
if (value === "\0") {
|
|
2173
|
+
continue;
|
|
2174
|
+
}
|
|
2175
|
+
if (value === "\\") {
|
|
2176
|
+
const next = peek();
|
|
2177
|
+
if (next === "/" && opts.bash !== true) {
|
|
2178
|
+
continue;
|
|
2179
|
+
}
|
|
2180
|
+
if (next === "." || next === ";") {
|
|
2181
|
+
continue;
|
|
2182
|
+
}
|
|
2183
|
+
if (!next) {
|
|
2184
|
+
value += "\\";
|
|
2185
|
+
push({ type: "text", value });
|
|
2186
|
+
continue;
|
|
2187
|
+
}
|
|
2188
|
+
const match = /^\\+/.exec(remaining());
|
|
2189
|
+
let slashes = 0;
|
|
2190
|
+
if (match && match[0].length > 2) {
|
|
2191
|
+
slashes = match[0].length;
|
|
2192
|
+
state.index += slashes;
|
|
2193
|
+
if (slashes % 2 !== 0) {
|
|
2194
|
+
value += "\\";
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
if (opts.unescape === true) {
|
|
2198
|
+
value = advance();
|
|
2199
|
+
} else {
|
|
2200
|
+
value += advance();
|
|
2201
|
+
}
|
|
2202
|
+
if (state.brackets === 0) {
|
|
2203
|
+
push({ type: "text", value });
|
|
2204
|
+
continue;
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
2208
|
+
if (opts.posix !== false && value === ":") {
|
|
2209
|
+
const inner = prev.value.slice(1);
|
|
2210
|
+
if (inner.includes("[")) {
|
|
2211
|
+
prev.posix = true;
|
|
2212
|
+
if (inner.includes(":")) {
|
|
2213
|
+
const idx = prev.value.lastIndexOf("[");
|
|
2214
|
+
const pre = prev.value.slice(0, idx);
|
|
2215
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
2216
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
2217
|
+
if (posix) {
|
|
2218
|
+
prev.value = pre + posix;
|
|
2219
|
+
state.backtrack = true;
|
|
2220
|
+
advance();
|
|
2221
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
2222
|
+
bos.output = ONE_CHAR;
|
|
2223
|
+
}
|
|
2224
|
+
continue;
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
2230
|
+
value = `\\${value}`;
|
|
2231
|
+
}
|
|
2232
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
2233
|
+
value = `\\${value}`;
|
|
2234
|
+
}
|
|
2235
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
2236
|
+
value = "^";
|
|
2237
|
+
}
|
|
2238
|
+
prev.value += value;
|
|
2239
|
+
append({ value });
|
|
2240
|
+
continue;
|
|
2241
|
+
}
|
|
2242
|
+
if (state.quotes === 1 && value !== '"') {
|
|
2243
|
+
value = utils.escapeRegex(value);
|
|
2244
|
+
prev.value += value;
|
|
2245
|
+
append({ value });
|
|
2246
|
+
continue;
|
|
2247
|
+
}
|
|
2248
|
+
if (value === '"') {
|
|
2249
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
2250
|
+
if (opts.keepQuotes === true) {
|
|
2251
|
+
push({ type: "text", value });
|
|
2252
|
+
}
|
|
2253
|
+
continue;
|
|
2254
|
+
}
|
|
2255
|
+
if (value === "(") {
|
|
2256
|
+
increment("parens");
|
|
2257
|
+
push({ type: "paren", value });
|
|
2258
|
+
continue;
|
|
2259
|
+
}
|
|
2260
|
+
if (value === ")") {
|
|
2261
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
2262
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
2263
|
+
}
|
|
2264
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
2265
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
2266
|
+
extglobClose(extglobs.pop());
|
|
2267
|
+
continue;
|
|
2268
|
+
}
|
|
2269
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
2270
|
+
decrement("parens");
|
|
2271
|
+
continue;
|
|
2272
|
+
}
|
|
2273
|
+
if (value === "[") {
|
|
2274
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
2275
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
2276
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
2277
|
+
}
|
|
2278
|
+
value = `\\${value}`;
|
|
2279
|
+
} else {
|
|
2280
|
+
increment("brackets");
|
|
2281
|
+
}
|
|
2282
|
+
push({ type: "bracket", value });
|
|
2283
|
+
continue;
|
|
2284
|
+
}
|
|
2285
|
+
if (value === "]") {
|
|
2286
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
2287
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
2288
|
+
continue;
|
|
2289
|
+
}
|
|
2290
|
+
if (state.brackets === 0) {
|
|
2291
|
+
if (opts.strictBrackets === true) {
|
|
2292
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
2293
|
+
}
|
|
2294
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
2295
|
+
continue;
|
|
2296
|
+
}
|
|
2297
|
+
decrement("brackets");
|
|
2298
|
+
const prevValue = prev.value.slice(1);
|
|
2299
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
2300
|
+
value = `/${value}`;
|
|
2301
|
+
}
|
|
2302
|
+
prev.value += value;
|
|
2303
|
+
append({ value });
|
|
2304
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
2305
|
+
continue;
|
|
2306
|
+
}
|
|
2307
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
2308
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
2309
|
+
if (opts.literalBrackets === true) {
|
|
2310
|
+
state.output += escaped;
|
|
2311
|
+
prev.value = escaped;
|
|
2312
|
+
continue;
|
|
2313
|
+
}
|
|
2314
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
2315
|
+
state.output += prev.value;
|
|
2316
|
+
continue;
|
|
2317
|
+
}
|
|
2318
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
2319
|
+
increment("braces");
|
|
2320
|
+
const open = {
|
|
2321
|
+
type: "brace",
|
|
2322
|
+
value,
|
|
2323
|
+
output: "(",
|
|
2324
|
+
outputIndex: state.output.length,
|
|
2325
|
+
tokensIndex: state.tokens.length
|
|
2326
|
+
};
|
|
2327
|
+
braces.push(open);
|
|
2328
|
+
push(open);
|
|
2329
|
+
continue;
|
|
2330
|
+
}
|
|
2331
|
+
if (value === "}") {
|
|
2332
|
+
const brace = braces[braces.length - 1];
|
|
2333
|
+
if (opts.nobrace === true || !brace) {
|
|
2334
|
+
push({ type: "text", value, output: value });
|
|
2335
|
+
continue;
|
|
2336
|
+
}
|
|
2337
|
+
let output = ")";
|
|
2338
|
+
if (brace.dots === true) {
|
|
2339
|
+
const arr = tokens.slice();
|
|
2340
|
+
const range = [];
|
|
2341
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
2342
|
+
tokens.pop();
|
|
2343
|
+
if (arr[i].type === "brace") {
|
|
2344
|
+
break;
|
|
2345
|
+
}
|
|
2346
|
+
if (arr[i].type !== "dots") {
|
|
2347
|
+
range.unshift(arr[i].value);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
output = expandRange(range, opts);
|
|
2351
|
+
state.backtrack = true;
|
|
2352
|
+
}
|
|
2353
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
2354
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
2355
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
2356
|
+
brace.value = brace.output = "\\{";
|
|
2357
|
+
value = output = "\\}";
|
|
2358
|
+
state.output = out;
|
|
2359
|
+
for (const t of toks) {
|
|
2360
|
+
state.output += t.output || t.value;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
push({ type: "brace", value, output });
|
|
2364
|
+
decrement("braces");
|
|
2365
|
+
braces.pop();
|
|
2366
|
+
continue;
|
|
2367
|
+
}
|
|
2368
|
+
if (value === "|") {
|
|
2369
|
+
if (extglobs.length > 0) {
|
|
2370
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
2371
|
+
}
|
|
2372
|
+
push({ type: "text", value });
|
|
2373
|
+
continue;
|
|
2374
|
+
}
|
|
2375
|
+
if (value === ",") {
|
|
2376
|
+
let output = value;
|
|
2377
|
+
const brace = braces[braces.length - 1];
|
|
2378
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
2379
|
+
brace.comma = true;
|
|
2380
|
+
output = "|";
|
|
2381
|
+
}
|
|
2382
|
+
push({ type: "comma", value, output });
|
|
2383
|
+
continue;
|
|
2384
|
+
}
|
|
2385
|
+
if (value === "/") {
|
|
2386
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
2387
|
+
state.start = state.index + 1;
|
|
2388
|
+
state.consumed = "";
|
|
2389
|
+
state.output = "";
|
|
2390
|
+
tokens.pop();
|
|
2391
|
+
prev = bos;
|
|
2392
|
+
continue;
|
|
2393
|
+
}
|
|
2394
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
2395
|
+
continue;
|
|
2396
|
+
}
|
|
2397
|
+
if (value === ".") {
|
|
2398
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
2399
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
2400
|
+
const brace = braces[braces.length - 1];
|
|
2401
|
+
prev.type = "dots";
|
|
2402
|
+
prev.output += value;
|
|
2403
|
+
prev.value += value;
|
|
2404
|
+
brace.dots = true;
|
|
2405
|
+
continue;
|
|
2406
|
+
}
|
|
2407
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
2408
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
2409
|
+
continue;
|
|
2410
|
+
}
|
|
2411
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
2412
|
+
continue;
|
|
2413
|
+
}
|
|
2414
|
+
if (value === "?") {
|
|
2415
|
+
const isGroup = prev && prev.value === "(";
|
|
2416
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
2417
|
+
extglobOpen("qmark", value);
|
|
2418
|
+
continue;
|
|
2419
|
+
}
|
|
2420
|
+
if (prev && prev.type === "paren") {
|
|
2421
|
+
const next = peek();
|
|
2422
|
+
let output = value;
|
|
2423
|
+
if (next === "<" && !utils.supportsLookbehinds()) {
|
|
2424
|
+
throw new Error("Node.js v10 or higher is required for regex lookbehinds");
|
|
2425
|
+
}
|
|
2426
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
2427
|
+
output = `\\${value}`;
|
|
2428
|
+
}
|
|
2429
|
+
push({ type: "text", value, output });
|
|
2430
|
+
continue;
|
|
2431
|
+
}
|
|
2432
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
2433
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
2434
|
+
continue;
|
|
2435
|
+
}
|
|
2436
|
+
push({ type: "qmark", value, output: QMARK });
|
|
2437
|
+
continue;
|
|
2438
|
+
}
|
|
2439
|
+
if (value === "!") {
|
|
2440
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
2441
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
2442
|
+
extglobOpen("negate", value);
|
|
2443
|
+
continue;
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
2447
|
+
negate();
|
|
2448
|
+
continue;
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
if (value === "+") {
|
|
2452
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
2453
|
+
extglobOpen("plus", value);
|
|
2454
|
+
continue;
|
|
2455
|
+
}
|
|
2456
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
2457
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
2458
|
+
continue;
|
|
2459
|
+
}
|
|
2460
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
2461
|
+
push({ type: "plus", value });
|
|
2462
|
+
continue;
|
|
2463
|
+
}
|
|
2464
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
2465
|
+
continue;
|
|
2466
|
+
}
|
|
2467
|
+
if (value === "@") {
|
|
2468
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
2469
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
2470
|
+
continue;
|
|
2471
|
+
}
|
|
2472
|
+
push({ type: "text", value });
|
|
2473
|
+
continue;
|
|
2474
|
+
}
|
|
2475
|
+
if (value !== "*") {
|
|
2476
|
+
if (value === "$" || value === "^") {
|
|
2477
|
+
value = `\\${value}`;
|
|
2478
|
+
}
|
|
2479
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
2480
|
+
if (match) {
|
|
2481
|
+
value += match[0];
|
|
2482
|
+
state.index += match[0].length;
|
|
2483
|
+
}
|
|
2484
|
+
push({ type: "text", value });
|
|
2485
|
+
continue;
|
|
2486
|
+
}
|
|
2487
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
2488
|
+
prev.type = "star";
|
|
2489
|
+
prev.star = true;
|
|
2490
|
+
prev.value += value;
|
|
2491
|
+
prev.output = star;
|
|
2492
|
+
state.backtrack = true;
|
|
2493
|
+
state.globstar = true;
|
|
2494
|
+
consume(value);
|
|
2495
|
+
continue;
|
|
2496
|
+
}
|
|
2497
|
+
let rest = remaining();
|
|
2498
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
2499
|
+
extglobOpen("star", value);
|
|
2500
|
+
continue;
|
|
2501
|
+
}
|
|
2502
|
+
if (prev.type === "star") {
|
|
2503
|
+
if (opts.noglobstar === true) {
|
|
2504
|
+
consume(value);
|
|
2505
|
+
continue;
|
|
2506
|
+
}
|
|
2507
|
+
const prior = prev.prev;
|
|
2508
|
+
const before = prior.prev;
|
|
2509
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
2510
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
2511
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
2512
|
+
push({ type: "star", value, output: "" });
|
|
2513
|
+
continue;
|
|
2514
|
+
}
|
|
2515
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
2516
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
2517
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
2518
|
+
push({ type: "star", value, output: "" });
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
while (rest.slice(0, 3) === "/**") {
|
|
2522
|
+
const after = input[state.index + 4];
|
|
2523
|
+
if (after && after !== "/") {
|
|
2524
|
+
break;
|
|
2525
|
+
}
|
|
2526
|
+
rest = rest.slice(3);
|
|
2527
|
+
consume("/**", 3);
|
|
2528
|
+
}
|
|
2529
|
+
if (prior.type === "bos" && eos()) {
|
|
2530
|
+
prev.type = "globstar";
|
|
2531
|
+
prev.value += value;
|
|
2532
|
+
prev.output = globstar(opts);
|
|
2533
|
+
state.output = prev.output;
|
|
2534
|
+
state.globstar = true;
|
|
2535
|
+
consume(value);
|
|
2536
|
+
continue;
|
|
2537
|
+
}
|
|
2538
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
2539
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2540
|
+
prior.output = `(?:${prior.output}`;
|
|
2541
|
+
prev.type = "globstar";
|
|
2542
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
2543
|
+
prev.value += value;
|
|
2544
|
+
state.globstar = true;
|
|
2545
|
+
state.output += prior.output + prev.output;
|
|
2546
|
+
consume(value);
|
|
2547
|
+
continue;
|
|
2548
|
+
}
|
|
2549
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
2550
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
2551
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2552
|
+
prior.output = `(?:${prior.output}`;
|
|
2553
|
+
prev.type = "globstar";
|
|
2554
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
2555
|
+
prev.value += value;
|
|
2556
|
+
state.output += prior.output + prev.output;
|
|
2557
|
+
state.globstar = true;
|
|
2558
|
+
consume(value + advance());
|
|
2559
|
+
push({ type: "slash", value: "/", output: "" });
|
|
2560
|
+
continue;
|
|
2561
|
+
}
|
|
2562
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
2563
|
+
prev.type = "globstar";
|
|
2564
|
+
prev.value += value;
|
|
2565
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
2566
|
+
state.output = prev.output;
|
|
2567
|
+
state.globstar = true;
|
|
2568
|
+
consume(value + advance());
|
|
2569
|
+
push({ type: "slash", value: "/", output: "" });
|
|
2570
|
+
continue;
|
|
2571
|
+
}
|
|
2572
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
2573
|
+
prev.type = "globstar";
|
|
2574
|
+
prev.output = globstar(opts);
|
|
2575
|
+
prev.value += value;
|
|
2576
|
+
state.output += prev.output;
|
|
2577
|
+
state.globstar = true;
|
|
2578
|
+
consume(value);
|
|
2579
|
+
continue;
|
|
2580
|
+
}
|
|
2581
|
+
const token = { type: "star", value, output: star };
|
|
2582
|
+
if (opts.bash === true) {
|
|
2583
|
+
token.output = ".*?";
|
|
2584
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
2585
|
+
token.output = nodot + token.output;
|
|
2586
|
+
}
|
|
2587
|
+
push(token);
|
|
2588
|
+
continue;
|
|
2589
|
+
}
|
|
2590
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
2591
|
+
token.output = value;
|
|
2592
|
+
push(token);
|
|
2593
|
+
continue;
|
|
2594
|
+
}
|
|
2595
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
2596
|
+
if (prev.type === "dot") {
|
|
2597
|
+
state.output += NO_DOT_SLASH;
|
|
2598
|
+
prev.output += NO_DOT_SLASH;
|
|
2599
|
+
} else if (opts.dot === true) {
|
|
2600
|
+
state.output += NO_DOTS_SLASH;
|
|
2601
|
+
prev.output += NO_DOTS_SLASH;
|
|
2602
|
+
} else {
|
|
2603
|
+
state.output += nodot;
|
|
2604
|
+
prev.output += nodot;
|
|
2605
|
+
}
|
|
2606
|
+
if (peek() !== "*") {
|
|
2607
|
+
state.output += ONE_CHAR;
|
|
2608
|
+
prev.output += ONE_CHAR;
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
push(token);
|
|
2612
|
+
}
|
|
2613
|
+
while (state.brackets > 0) {
|
|
2614
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
2615
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
2616
|
+
decrement("brackets");
|
|
2617
|
+
}
|
|
2618
|
+
while (state.parens > 0) {
|
|
2619
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
2620
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
2621
|
+
decrement("parens");
|
|
2622
|
+
}
|
|
2623
|
+
while (state.braces > 0) {
|
|
2624
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
2625
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
2626
|
+
decrement("braces");
|
|
2627
|
+
}
|
|
2628
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
2629
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
2630
|
+
}
|
|
2631
|
+
if (state.backtrack === true) {
|
|
2632
|
+
state.output = "";
|
|
2633
|
+
for (const token of state.tokens) {
|
|
2634
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2635
|
+
if (token.suffix) {
|
|
2636
|
+
state.output += token.suffix;
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
return state;
|
|
2641
|
+
};
|
|
2642
|
+
parse.fastpaths = (input, options) => {
|
|
2643
|
+
const opts = { ...options };
|
|
2644
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2645
|
+
const len = input.length;
|
|
2646
|
+
if (len > max) {
|
|
2647
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2648
|
+
}
|
|
2649
|
+
input = REPLACEMENTS[input] || input;
|
|
2650
|
+
const win32 = utils.isWindows(options);
|
|
2651
|
+
const {
|
|
2652
|
+
DOT_LITERAL,
|
|
2653
|
+
SLASH_LITERAL,
|
|
2654
|
+
ONE_CHAR,
|
|
2655
|
+
DOTS_SLASH,
|
|
2656
|
+
NO_DOT,
|
|
2657
|
+
NO_DOTS,
|
|
2658
|
+
NO_DOTS_SLASH,
|
|
2659
|
+
STAR,
|
|
2660
|
+
START_ANCHOR
|
|
2661
|
+
} = constants2.globChars(win32);
|
|
2662
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
2663
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
2664
|
+
const capture = opts.capture ? "" : "?:";
|
|
2665
|
+
const state = { negated: false, prefix: "" };
|
|
2666
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
2667
|
+
if (opts.capture) {
|
|
2668
|
+
star = `(${star})`;
|
|
2669
|
+
}
|
|
2670
|
+
const globstar = (opts2) => {
|
|
2671
|
+
if (opts2.noglobstar === true) return star;
|
|
2672
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
2673
|
+
};
|
|
2674
|
+
const create = (str) => {
|
|
2675
|
+
switch (str) {
|
|
2676
|
+
case "*":
|
|
2677
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
2678
|
+
case ".*":
|
|
2679
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2680
|
+
case "*.*":
|
|
2681
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2682
|
+
case "*/*":
|
|
2683
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
2684
|
+
case "**":
|
|
2685
|
+
return nodot + globstar(opts);
|
|
2686
|
+
case "**/*":
|
|
2687
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
2688
|
+
case "**/*.*":
|
|
2689
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2690
|
+
case "**/.*":
|
|
2691
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2692
|
+
default: {
|
|
2693
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
2694
|
+
if (!match) return;
|
|
2695
|
+
const source2 = create(match[1]);
|
|
2696
|
+
if (!source2) return;
|
|
2697
|
+
return source2 + DOT_LITERAL + match[2];
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2701
|
+
const output = utils.removePrefix(input, state);
|
|
2702
|
+
let source = create(output);
|
|
2703
|
+
if (source && opts.strictSlashes !== true) {
|
|
2704
|
+
source += `${SLASH_LITERAL}?`;
|
|
2705
|
+
}
|
|
2706
|
+
return source;
|
|
2707
|
+
};
|
|
2708
|
+
module.exports = parse;
|
|
2709
|
+
}
|
|
2710
|
+
});
|
|
2711
|
+
|
|
2712
|
+
// ../../node_modules/micromatch/node_modules/picomatch/lib/picomatch.js
|
|
2713
|
+
var require_picomatch = __commonJS({
|
|
2714
|
+
"../../node_modules/micromatch/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
2715
|
+
"use strict";
|
|
2716
|
+
var path = __require("path");
|
|
2717
|
+
var scan = require_scan();
|
|
2718
|
+
var parse = require_parse2();
|
|
2719
|
+
var utils = require_utils2();
|
|
2720
|
+
var constants2 = require_constants2();
|
|
2721
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
2722
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
2723
|
+
if (Array.isArray(glob)) {
|
|
2724
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
2725
|
+
const arrayMatcher = (str) => {
|
|
2726
|
+
for (const isMatch of fns) {
|
|
2727
|
+
const state2 = isMatch(str);
|
|
2728
|
+
if (state2) return state2;
|
|
2729
|
+
}
|
|
2730
|
+
return false;
|
|
2731
|
+
};
|
|
2732
|
+
return arrayMatcher;
|
|
2733
|
+
}
|
|
2734
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
2735
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
2736
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
2737
|
+
}
|
|
2738
|
+
const opts = options || {};
|
|
2739
|
+
const posix = utils.isWindows(options);
|
|
2740
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
2741
|
+
const state = regex.state;
|
|
2742
|
+
delete regex.state;
|
|
2743
|
+
let isIgnored = () => false;
|
|
2744
|
+
if (opts.ignore) {
|
|
2745
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
2746
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
2747
|
+
}
|
|
2748
|
+
const matcher = (input, returnObject = false) => {
|
|
2749
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
2750
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
2751
|
+
if (typeof opts.onResult === "function") {
|
|
2752
|
+
opts.onResult(result);
|
|
2753
|
+
}
|
|
2754
|
+
if (isMatch === false) {
|
|
2755
|
+
result.isMatch = false;
|
|
2756
|
+
return returnObject ? result : false;
|
|
2757
|
+
}
|
|
2758
|
+
if (isIgnored(input)) {
|
|
2759
|
+
if (typeof opts.onIgnore === "function") {
|
|
2760
|
+
opts.onIgnore(result);
|
|
2761
|
+
}
|
|
2762
|
+
result.isMatch = false;
|
|
2763
|
+
return returnObject ? result : false;
|
|
2764
|
+
}
|
|
2765
|
+
if (typeof opts.onMatch === "function") {
|
|
2766
|
+
opts.onMatch(result);
|
|
2767
|
+
}
|
|
2768
|
+
return returnObject ? result : true;
|
|
2769
|
+
};
|
|
2770
|
+
if (returnState) {
|
|
2771
|
+
matcher.state = state;
|
|
2772
|
+
}
|
|
2773
|
+
return matcher;
|
|
2774
|
+
};
|
|
2775
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
2776
|
+
if (typeof input !== "string") {
|
|
2777
|
+
throw new TypeError("Expected input to be a string");
|
|
2778
|
+
}
|
|
2779
|
+
if (input === "") {
|
|
2780
|
+
return { isMatch: false, output: "" };
|
|
2781
|
+
}
|
|
2782
|
+
const opts = options || {};
|
|
2783
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
2784
|
+
let match = input === glob;
|
|
2785
|
+
let output = match && format ? format(input) : input;
|
|
2786
|
+
if (match === false) {
|
|
2787
|
+
output = format ? format(input) : input;
|
|
2788
|
+
match = output === glob;
|
|
2789
|
+
}
|
|
2790
|
+
if (match === false || opts.capture === true) {
|
|
2791
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
2792
|
+
match = picomatch.matchBase(input, regex, options, posix);
|
|
2793
|
+
} else {
|
|
2794
|
+
match = regex.exec(output);
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
return { isMatch: Boolean(match), match, output };
|
|
2798
|
+
};
|
|
2799
|
+
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
2800
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
2801
|
+
return regex.test(path.basename(input));
|
|
2802
|
+
};
|
|
2803
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
2804
|
+
picomatch.parse = (pattern, options) => {
|
|
2805
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
2806
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
2807
|
+
};
|
|
2808
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
2809
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
2810
|
+
if (returnOutput === true) {
|
|
2811
|
+
return state.output;
|
|
2812
|
+
}
|
|
2813
|
+
const opts = options || {};
|
|
2814
|
+
const prepend = opts.contains ? "" : "^";
|
|
2815
|
+
const append = opts.contains ? "" : "$";
|
|
2816
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
2817
|
+
if (state && state.negated === true) {
|
|
2818
|
+
source = `^(?!${source}).*$`;
|
|
2819
|
+
}
|
|
2820
|
+
const regex = picomatch.toRegex(source, options);
|
|
2821
|
+
if (returnState === true) {
|
|
2822
|
+
regex.state = state;
|
|
2823
|
+
}
|
|
2824
|
+
return regex;
|
|
2825
|
+
};
|
|
2826
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
2827
|
+
if (!input || typeof input !== "string") {
|
|
2828
|
+
throw new TypeError("Expected a non-empty string");
|
|
2829
|
+
}
|
|
2830
|
+
let parsed = { negated: false, fastpaths: true };
|
|
2831
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
2832
|
+
parsed.output = parse.fastpaths(input, options);
|
|
2833
|
+
}
|
|
2834
|
+
if (!parsed.output) {
|
|
2835
|
+
parsed = parse(input, options);
|
|
2836
|
+
}
|
|
2837
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
2838
|
+
};
|
|
2839
|
+
picomatch.toRegex = (source, options) => {
|
|
2840
|
+
try {
|
|
2841
|
+
const opts = options || {};
|
|
2842
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
2843
|
+
} catch (err) {
|
|
2844
|
+
if (options && options.debug === true) throw err;
|
|
2845
|
+
return /$^/;
|
|
2846
|
+
}
|
|
2847
|
+
};
|
|
2848
|
+
picomatch.constants = constants2;
|
|
2849
|
+
module.exports = picomatch;
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
|
|
2853
|
+
// ../../node_modules/micromatch/node_modules/picomatch/index.js
|
|
2854
|
+
var require_picomatch2 = __commonJS({
|
|
2855
|
+
"../../node_modules/micromatch/node_modules/picomatch/index.js"(exports, module) {
|
|
2856
|
+
"use strict";
|
|
2857
|
+
module.exports = require_picomatch();
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2860
|
+
|
|
2861
|
+
// ../../node_modules/micromatch/index.js
|
|
2862
|
+
var require_micromatch = __commonJS({
|
|
2863
|
+
"../../node_modules/micromatch/index.js"(exports, module) {
|
|
2864
|
+
"use strict";
|
|
2865
|
+
var util = __require("util");
|
|
2866
|
+
var braces = require_braces();
|
|
2867
|
+
var picomatch = require_picomatch2();
|
|
2868
|
+
var utils = require_utils2();
|
|
2869
|
+
var isEmptyString = (v) => v === "" || v === "./";
|
|
2870
|
+
var hasBraces = (v) => {
|
|
2871
|
+
const index = v.indexOf("{");
|
|
2872
|
+
return index > -1 && v.indexOf("}", index) > -1;
|
|
2873
|
+
};
|
|
2874
|
+
var micromatch2 = (list, patterns, options) => {
|
|
2875
|
+
patterns = [].concat(patterns);
|
|
2876
|
+
list = [].concat(list);
|
|
2877
|
+
let omit = /* @__PURE__ */ new Set();
|
|
2878
|
+
let keep = /* @__PURE__ */ new Set();
|
|
2879
|
+
let items = /* @__PURE__ */ new Set();
|
|
2880
|
+
let negatives = 0;
|
|
2881
|
+
let onResult = (state) => {
|
|
2882
|
+
items.add(state.output);
|
|
2883
|
+
if (options && options.onResult) {
|
|
2884
|
+
options.onResult(state);
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
2888
|
+
let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
|
|
2889
|
+
let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
|
|
2890
|
+
if (negated) negatives++;
|
|
2891
|
+
for (let item of list) {
|
|
2892
|
+
let matched = isMatch(item, true);
|
|
2893
|
+
let match = negated ? !matched.isMatch : matched.isMatch;
|
|
2894
|
+
if (!match) continue;
|
|
2895
|
+
if (negated) {
|
|
2896
|
+
omit.add(matched.output);
|
|
2897
|
+
} else {
|
|
2898
|
+
omit.delete(matched.output);
|
|
2899
|
+
keep.add(matched.output);
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
let result = negatives === patterns.length ? [...items] : [...keep];
|
|
2904
|
+
let matches = result.filter((item) => !omit.has(item));
|
|
2905
|
+
if (options && matches.length === 0) {
|
|
2906
|
+
if (options.failglob === true) {
|
|
2907
|
+
throw new Error(`No matches found for "${patterns.join(", ")}"`);
|
|
2908
|
+
}
|
|
2909
|
+
if (options.nonull === true || options.nullglob === true) {
|
|
2910
|
+
return options.unescape ? patterns.map((p) => p.replace(/\\/g, "")) : patterns;
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
return matches;
|
|
2914
|
+
};
|
|
2915
|
+
micromatch2.match = micromatch2;
|
|
2916
|
+
micromatch2.matcher = (pattern, options) => picomatch(pattern, options);
|
|
2917
|
+
micromatch2.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
2918
|
+
micromatch2.any = micromatch2.isMatch;
|
|
2919
|
+
micromatch2.not = (list, patterns, options = {}) => {
|
|
2920
|
+
patterns = [].concat(patterns).map(String);
|
|
2921
|
+
let result = /* @__PURE__ */ new Set();
|
|
2922
|
+
let items = [];
|
|
2923
|
+
let onResult = (state) => {
|
|
2924
|
+
if (options.onResult) options.onResult(state);
|
|
2925
|
+
items.push(state.output);
|
|
2926
|
+
};
|
|
2927
|
+
let matches = new Set(micromatch2(list, patterns, { ...options, onResult }));
|
|
2928
|
+
for (let item of items) {
|
|
2929
|
+
if (!matches.has(item)) {
|
|
2930
|
+
result.add(item);
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
return [...result];
|
|
2934
|
+
};
|
|
2935
|
+
micromatch2.contains = (str, pattern, options) => {
|
|
2936
|
+
if (typeof str !== "string") {
|
|
2937
|
+
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
|
|
2938
|
+
}
|
|
2939
|
+
if (Array.isArray(pattern)) {
|
|
2940
|
+
return pattern.some((p) => micromatch2.contains(str, p, options));
|
|
2941
|
+
}
|
|
2942
|
+
if (typeof pattern === "string") {
|
|
2943
|
+
if (isEmptyString(str) || isEmptyString(pattern)) {
|
|
2944
|
+
return false;
|
|
2945
|
+
}
|
|
2946
|
+
if (str.includes(pattern) || str.startsWith("./") && str.slice(2).includes(pattern)) {
|
|
2947
|
+
return true;
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
return micromatch2.isMatch(str, pattern, { ...options, contains: true });
|
|
2951
|
+
};
|
|
2952
|
+
micromatch2.matchKeys = (obj, patterns, options) => {
|
|
2953
|
+
if (!utils.isObject(obj)) {
|
|
2954
|
+
throw new TypeError("Expected the first argument to be an object");
|
|
2955
|
+
}
|
|
2956
|
+
let keys = micromatch2(Object.keys(obj), patterns, options);
|
|
2957
|
+
let res = {};
|
|
2958
|
+
for (let key of keys) res[key] = obj[key];
|
|
2959
|
+
return res;
|
|
2960
|
+
};
|
|
2961
|
+
micromatch2.some = (list, patterns, options) => {
|
|
2962
|
+
let items = [].concat(list);
|
|
2963
|
+
for (let pattern of [].concat(patterns)) {
|
|
2964
|
+
let isMatch = picomatch(String(pattern), options);
|
|
2965
|
+
if (items.some((item) => isMatch(item))) {
|
|
2966
|
+
return true;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
return false;
|
|
2970
|
+
};
|
|
2971
|
+
micromatch2.every = (list, patterns, options) => {
|
|
2972
|
+
let items = [].concat(list);
|
|
2973
|
+
for (let pattern of [].concat(patterns)) {
|
|
2974
|
+
let isMatch = picomatch(String(pattern), options);
|
|
2975
|
+
if (!items.every((item) => isMatch(item))) {
|
|
2976
|
+
return false;
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
return true;
|
|
2980
|
+
};
|
|
2981
|
+
micromatch2.all = (str, patterns, options) => {
|
|
2982
|
+
if (typeof str !== "string") {
|
|
2983
|
+
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
|
|
2984
|
+
}
|
|
2985
|
+
return [].concat(patterns).every((p) => picomatch(p, options)(str));
|
|
2986
|
+
};
|
|
2987
|
+
micromatch2.capture = (glob, input, options) => {
|
|
2988
|
+
let posix = utils.isWindows(options);
|
|
2989
|
+
let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
|
|
2990
|
+
let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
|
|
2991
|
+
if (match) {
|
|
2992
|
+
return match.slice(1).map((v) => v === void 0 ? "" : v);
|
|
2993
|
+
}
|
|
2994
|
+
};
|
|
2995
|
+
micromatch2.makeRe = (...args) => picomatch.makeRe(...args);
|
|
2996
|
+
micromatch2.scan = (...args) => picomatch.scan(...args);
|
|
2997
|
+
micromatch2.parse = (patterns, options) => {
|
|
2998
|
+
let res = [];
|
|
2999
|
+
for (let pattern of [].concat(patterns || [])) {
|
|
3000
|
+
for (let str of braces(String(pattern), options)) {
|
|
3001
|
+
res.push(picomatch.parse(str, options));
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
return res;
|
|
3005
|
+
};
|
|
3006
|
+
micromatch2.braces = (pattern, options) => {
|
|
3007
|
+
if (typeof pattern !== "string") throw new TypeError("Expected a string");
|
|
3008
|
+
if (options && options.nobrace === true || !hasBraces(pattern)) {
|
|
3009
|
+
return [pattern];
|
|
3010
|
+
}
|
|
3011
|
+
return braces(pattern, options);
|
|
3012
|
+
};
|
|
3013
|
+
micromatch2.braceExpand = (pattern, options) => {
|
|
3014
|
+
if (typeof pattern !== "string") throw new TypeError("Expected a string");
|
|
3015
|
+
return micromatch2.braces(pattern, { ...options, expand: true });
|
|
3016
|
+
};
|
|
3017
|
+
micromatch2.hasBraces = hasBraces;
|
|
3018
|
+
module.exports = micromatch2;
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
3021
|
+
|
|
3022
|
+
// ../composition-identity/dist/mcp-launch-identity.js
|
|
3023
|
+
var require_mcp_launch_identity = __commonJS({
|
|
3024
|
+
"../composition-identity/dist/mcp-launch-identity.js"(exports) {
|
|
3025
|
+
"use strict";
|
|
3026
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3027
|
+
exports.MCP_MISSING_LAUNCH_SERIALIZED = exports.MCP_LAUNCH_IDENTITY_ALGORITHM = void 0;
|
|
3028
|
+
exports.foldMcpName = foldMcpName;
|
|
3029
|
+
exports.buildMcpFamilyCanonicalKey = buildMcpFamilyCanonicalKey;
|
|
3030
|
+
exports.launchContainsCredentials = launchContainsCredentials2;
|
|
3031
|
+
exports.serializeMcpLaunchIdentity = serializeMcpLaunchIdentity;
|
|
3032
|
+
exports.hashMcpLaunchIdentity = hashMcpLaunchIdentity;
|
|
3033
|
+
exports.projectMcpMissingLaunchIdentity = projectMcpMissingLaunchIdentity;
|
|
3034
|
+
exports.projectMcpLaunchIdentity = projectMcpLaunchIdentity;
|
|
3035
|
+
exports.maskMcpLaunchForDisplay = maskMcpLaunchForDisplay;
|
|
3036
|
+
exports.normalizeMcpToolNames = normalizeMcpToolNames;
|
|
3037
|
+
var node_crypto_1 = __require("node:crypto");
|
|
3038
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM = "mcp-launch-v1";
|
|
3039
|
+
exports.MCP_MISSING_LAUNCH_SERIALIZED = `${exports.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;
|
|
3040
|
+
function foldCase(value) {
|
|
3041
|
+
return value.toLocaleLowerCase("en-US");
|
|
3042
|
+
}
|
|
3043
|
+
function foldMcpName(nativeName) {
|
|
3044
|
+
return foldCase(nativeName);
|
|
3045
|
+
}
|
|
3046
|
+
function buildMcpFamilyCanonicalKey(nativeName) {
|
|
3047
|
+
return `interface:${foldMcpName(nativeName)}`;
|
|
3048
|
+
}
|
|
3049
|
+
var CREDENTIAL_QUERY_KEYS = /* @__PURE__ */ new Set([
|
|
3050
|
+
"access_token",
|
|
3051
|
+
"api_key",
|
|
3052
|
+
"apikey",
|
|
3053
|
+
"auth",
|
|
3054
|
+
"authorization",
|
|
3055
|
+
"key",
|
|
3056
|
+
"password",
|
|
3057
|
+
"secret",
|
|
3058
|
+
"token"
|
|
3059
|
+
]);
|
|
3060
|
+
var LITERAL_TOKEN_ARGUMENT = /^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;
|
|
3061
|
+
function lengthPrefixed(value) {
|
|
3062
|
+
return `${Buffer.byteLength(value, "utf8")}:${value}`;
|
|
3063
|
+
}
|
|
3064
|
+
function launchContainsCredentials2(input) {
|
|
3065
|
+
if (input.kind === "url") {
|
|
3066
|
+
return urlContainsCredentials(input.url);
|
|
3067
|
+
}
|
|
3068
|
+
if (input.kind === "command") {
|
|
3069
|
+
return input.arguments.some((argument) => LITERAL_TOKEN_ARGUMENT.test(argument));
|
|
3070
|
+
}
|
|
3071
|
+
return false;
|
|
3072
|
+
}
|
|
3073
|
+
function urlContainsCredentials(rawUrl) {
|
|
3074
|
+
try {
|
|
3075
|
+
const parsed = new URL(rawUrl);
|
|
3076
|
+
if (parsed.username.length > 0 || parsed.password.length > 0) {
|
|
3077
|
+
return true;
|
|
3078
|
+
}
|
|
3079
|
+
for (const key of parsed.searchParams.keys()) {
|
|
3080
|
+
if (CREDENTIAL_QUERY_KEYS.has(foldCase(key))) {
|
|
3081
|
+
return true;
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
return false;
|
|
3085
|
+
} catch {
|
|
3086
|
+
const schemeSplit = rawUrl.split("://", 2);
|
|
3087
|
+
const afterScheme = schemeSplit.length === 2 ? schemeSplit[1] : rawUrl;
|
|
3088
|
+
const atIndex = afterScheme.indexOf("@");
|
|
3089
|
+
const slashIndex = afterScheme.indexOf("/");
|
|
3090
|
+
if (atIndex > 0 && (slashIndex === -1 || atIndex < slashIndex)) {
|
|
3091
|
+
return true;
|
|
3092
|
+
}
|
|
3093
|
+
const query = rawUrl.split("?", 2)[1];
|
|
3094
|
+
if (query === void 0) {
|
|
3095
|
+
return false;
|
|
3096
|
+
}
|
|
3097
|
+
return query.split("&").some((pair) => {
|
|
3098
|
+
const key = foldCase(pair.split("=", 1)[0] ?? "");
|
|
3099
|
+
return CREDENTIAL_QUERY_KEYS.has(key);
|
|
3100
|
+
});
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
function serializeMcpLaunchIdentity(input) {
|
|
3104
|
+
if (input.kind === "url") {
|
|
3105
|
+
return [
|
|
3106
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM,
|
|
3107
|
+
"url",
|
|
3108
|
+
lengthPrefixed(foldCase(input.url))
|
|
3109
|
+
].join("|");
|
|
3110
|
+
}
|
|
3111
|
+
if (input.kind === "command") {
|
|
3112
|
+
const foldedArguments = [...input.arguments].map((argument) => foldCase(argument)).sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
3113
|
+
return [
|
|
3114
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM,
|
|
3115
|
+
"command",
|
|
3116
|
+
lengthPrefixed(foldCase(input.command)),
|
|
3117
|
+
String(foldedArguments.length),
|
|
3118
|
+
...foldedArguments.map(lengthPrefixed)
|
|
3119
|
+
].join("|");
|
|
3120
|
+
}
|
|
3121
|
+
return [
|
|
3122
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM,
|
|
3123
|
+
"unknown",
|
|
3124
|
+
lengthPrefixed(input.installationRootExternalKey),
|
|
3125
|
+
lengthPrefixed(input.sourcePath),
|
|
3126
|
+
lengthPrefixed(input.nativeKey)
|
|
3127
|
+
].join("|");
|
|
3128
|
+
}
|
|
3129
|
+
function hashMcpLaunchIdentity(serialized) {
|
|
3130
|
+
return (0, node_crypto_1.createHash)("sha256").update(serialized).digest("hex");
|
|
3131
|
+
}
|
|
3132
|
+
var MCP_MISSING_LAUNCH_CONTENT_HASH = hashMcpLaunchIdentity(exports.MCP_MISSING_LAUNCH_SERIALIZED);
|
|
3133
|
+
function projectMcpMissingLaunchIdentity() {
|
|
3134
|
+
return {
|
|
3135
|
+
kind: "unknown",
|
|
3136
|
+
arguments: [],
|
|
3137
|
+
serialized: exports.MCP_MISSING_LAUNCH_SERIALIZED,
|
|
3138
|
+
contentHash: MCP_MISSING_LAUNCH_CONTENT_HASH
|
|
3139
|
+
};
|
|
3140
|
+
}
|
|
3141
|
+
function projectMcpLaunchIdentity(input) {
|
|
3142
|
+
const serialized = serializeMcpLaunchIdentity(input);
|
|
3143
|
+
if (input.kind === "url") {
|
|
3144
|
+
return {
|
|
3145
|
+
kind: "url",
|
|
3146
|
+
url: foldCase(input.url),
|
|
3147
|
+
arguments: [],
|
|
3148
|
+
serialized,
|
|
3149
|
+
contentHash: hashMcpLaunchIdentity(serialized)
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
if (input.kind === "command") {
|
|
3153
|
+
return {
|
|
3154
|
+
kind: "command",
|
|
3155
|
+
command: foldCase(input.command),
|
|
3156
|
+
arguments: [...input.arguments].map((argument) => foldCase(argument)).sort((left, right) => left < right ? -1 : left > right ? 1 : 0),
|
|
3157
|
+
serialized,
|
|
3158
|
+
contentHash: hashMcpLaunchIdentity(serialized)
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
return {
|
|
3162
|
+
kind: "unknown",
|
|
3163
|
+
arguments: [],
|
|
3164
|
+
serialized,
|
|
3165
|
+
contentHash: hashMcpLaunchIdentity(serialized)
|
|
3166
|
+
};
|
|
3167
|
+
}
|
|
3168
|
+
var CREDENTIAL_DISPLAY = /^(https?:\/\/)([^/?#]*@)/i;
|
|
3169
|
+
function maskMcpLaunchForDisplay(value) {
|
|
3170
|
+
return value.replace(CREDENTIAL_DISPLAY, "$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi, "$1***");
|
|
3171
|
+
}
|
|
3172
|
+
function normalizeMcpToolNames(names) {
|
|
3173
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3174
|
+
const unique = [];
|
|
3175
|
+
for (const name of names) {
|
|
3176
|
+
if (name.length === 0 || seen.has(name)) {
|
|
3177
|
+
continue;
|
|
3178
|
+
}
|
|
3179
|
+
seen.add(name);
|
|
3180
|
+
unique.push(name);
|
|
3181
|
+
}
|
|
3182
|
+
unique.sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
3183
|
+
return unique;
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
});
|
|
3187
|
+
|
|
3188
|
+
// ../composition-identity/dist/npx-package.js
|
|
3189
|
+
var require_npx_package = __commonJS({
|
|
3190
|
+
"../composition-identity/dist/npx-package.js"(exports) {
|
|
3191
|
+
"use strict";
|
|
3192
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3193
|
+
exports.LOCAL_BIN_PACKAGE_VERSION_SOURCE = exports.PACKAGE_FIELD_MAX = void 0;
|
|
3194
|
+
exports.npxExecBin = npxExecBin2;
|
|
3195
|
+
exports.isExactNpmVersion = isExactNpmVersion3;
|
|
3196
|
+
exports.isNodeModulesBinCommand = isNodeModulesBinCommand2;
|
|
3197
|
+
exports.packageNameFromSpec = packageNameFromSpec4;
|
|
3198
|
+
exports.pinnedPackageVersionFromSpec = pinnedPackageVersionFromSpec2;
|
|
3199
|
+
exports.pinnedPackageVersionFromNpx = pinnedPackageVersionFromNpx;
|
|
3200
|
+
exports.npxPackageSpecs = npxPackageSpecs2;
|
|
3201
|
+
exports.PACKAGE_FIELD_MAX = 128;
|
|
3202
|
+
var PACKAGE_NAME_RE = /^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/;
|
|
3203
|
+
var PACKAGE_FLAGS = /* @__PURE__ */ new Set(["-p", "--package"]);
|
|
3204
|
+
var CALL_FLAGS = /* @__PURE__ */ new Set(["-c", "--call"]);
|
|
3205
|
+
var VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
3206
|
+
"--registry",
|
|
3207
|
+
"--userconfig",
|
|
3208
|
+
"--globalconfig",
|
|
3209
|
+
"--prefix",
|
|
3210
|
+
"--cache",
|
|
3211
|
+
"--node-options",
|
|
3212
|
+
"--workspace",
|
|
3213
|
+
"-w",
|
|
3214
|
+
"--loglevel"
|
|
3215
|
+
]);
|
|
3216
|
+
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
3217
|
+
"-y",
|
|
3218
|
+
"--yes",
|
|
3219
|
+
"-n",
|
|
3220
|
+
"--no",
|
|
3221
|
+
"-q",
|
|
3222
|
+
"-s",
|
|
3223
|
+
"--quiet",
|
|
3224
|
+
"--silent",
|
|
3225
|
+
"--offline",
|
|
3226
|
+
"--prefer-offline",
|
|
3227
|
+
"--prefer-online",
|
|
3228
|
+
"--ignore-existing",
|
|
3229
|
+
"--ignore-scripts",
|
|
3230
|
+
"--legacy-peer-deps",
|
|
3231
|
+
"--foreground-scripts"
|
|
3232
|
+
]);
|
|
3233
|
+
var NEGATED_FLAG_RE = /^--no-/;
|
|
3234
|
+
function booleanFlag(flag) {
|
|
3235
|
+
return BOOLEAN_FLAGS.has(flag) || NEGATED_FLAG_RE.test(flag);
|
|
3236
|
+
}
|
|
3237
|
+
function npxExecBin2(command) {
|
|
3238
|
+
const base = command.replace(/\\/g, "/").split("/").pop() ?? "";
|
|
3239
|
+
const bare = base.replace(/\.(cmd|exe|bat|ps1)$/i, "").toLowerCase();
|
|
3240
|
+
if (bare === "npx") {
|
|
3241
|
+
return "npx";
|
|
3242
|
+
}
|
|
3243
|
+
return bare === "npm" ? "npm" : null;
|
|
3244
|
+
}
|
|
3245
|
+
var STRICT_SEMVER_RE = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
3246
|
+
function isExactNpmVersion3(version) {
|
|
3247
|
+
return version.length <= exports.PACKAGE_FIELD_MAX && STRICT_SEMVER_RE.test(version);
|
|
3248
|
+
}
|
|
3249
|
+
exports.LOCAL_BIN_PACKAGE_VERSION_SOURCE = "node_modules_local";
|
|
3250
|
+
var NODE_MODULES_BIN_RE = /(?:^|\/)node_modules\/\.bin\/[^/]+$/;
|
|
3251
|
+
function isNodeModulesBinCommand2(command) {
|
|
3252
|
+
return NODE_MODULES_BIN_RE.test(command.replaceAll("\\", "/"));
|
|
3253
|
+
}
|
|
3254
|
+
function packageNameFromSpec4(spec) {
|
|
3255
|
+
if (spec.length === 0 || spec.length > exports.PACKAGE_FIELD_MAX) {
|
|
3256
|
+
return null;
|
|
3257
|
+
}
|
|
3258
|
+
const at = spec.lastIndexOf("@");
|
|
3259
|
+
const name = at > 0 ? spec.slice(0, at) : spec;
|
|
3260
|
+
return PACKAGE_NAME_RE.test(name) ? name : null;
|
|
3261
|
+
}
|
|
3262
|
+
function pinnedPackageVersionFromSpec2(spec) {
|
|
3263
|
+
const name = packageNameFromSpec4(spec);
|
|
3264
|
+
if (name === null || !spec.startsWith(`${name}@`)) {
|
|
3265
|
+
return void 0;
|
|
3266
|
+
}
|
|
3267
|
+
const selector = spec.slice(name.length + 1);
|
|
3268
|
+
return isExactNpmVersion3(selector) ? selector : void 0;
|
|
3269
|
+
}
|
|
3270
|
+
function pinnedPackageVersionFromNpx(command, args) {
|
|
3271
|
+
for (const spec of npxPackageSpecs2(command, args)) {
|
|
3272
|
+
const pinned = pinnedPackageVersionFromSpec2(spec);
|
|
3273
|
+
if (pinned !== void 0) {
|
|
3274
|
+
return pinned;
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
return void 0;
|
|
3278
|
+
}
|
|
3279
|
+
function npxPackageSpecs2(command, args) {
|
|
3280
|
+
const bin = npxExecBin2(command);
|
|
3281
|
+
if (bin === null) {
|
|
3282
|
+
return [];
|
|
3283
|
+
}
|
|
3284
|
+
let rest = [...args];
|
|
3285
|
+
if (bin === "npm") {
|
|
3286
|
+
const sub = rest[0]?.toLowerCase();
|
|
3287
|
+
if (sub !== "exec" && sub !== "x") {
|
|
3288
|
+
return [];
|
|
3289
|
+
}
|
|
3290
|
+
rest = rest.slice(1);
|
|
3291
|
+
}
|
|
3292
|
+
const explicit = [];
|
|
3293
|
+
let firstPositional = null;
|
|
3294
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
3295
|
+
const token = rest[i] ?? "";
|
|
3296
|
+
if (token === "--") {
|
|
3297
|
+
firstPositional = rest[i + 1] ?? null;
|
|
3298
|
+
break;
|
|
3299
|
+
}
|
|
3300
|
+
if (!token.startsWith("-")) {
|
|
3301
|
+
firstPositional = token;
|
|
3302
|
+
break;
|
|
3303
|
+
}
|
|
3304
|
+
const eq = token.indexOf("=");
|
|
3305
|
+
const flag = eq === -1 ? token : token.slice(0, eq);
|
|
3306
|
+
if (CALL_FLAGS.has(flag)) {
|
|
3307
|
+
return [];
|
|
3308
|
+
}
|
|
3309
|
+
if (PACKAGE_FLAGS.has(flag)) {
|
|
3310
|
+
const value = eq === -1 ? rest[i + 1] : token.slice(eq + 1);
|
|
3311
|
+
if (value !== void 0 && value.length > 0) {
|
|
3312
|
+
explicit.push(value);
|
|
3313
|
+
}
|
|
3314
|
+
if (eq === -1) {
|
|
3315
|
+
i += 1;
|
|
3316
|
+
}
|
|
3317
|
+
continue;
|
|
3318
|
+
}
|
|
3319
|
+
if (eq !== -1 || booleanFlag(flag)) {
|
|
3320
|
+
continue;
|
|
3321
|
+
}
|
|
3322
|
+
if (VALUE_FLAGS.has(flag)) {
|
|
3323
|
+
i += 1;
|
|
3324
|
+
continue;
|
|
3325
|
+
}
|
|
3326
|
+
return [];
|
|
3327
|
+
}
|
|
3328
|
+
if (explicit.length > 0) {
|
|
3329
|
+
return explicit.every((spec) => packageNameFromSpec4(spec) !== null) ? explicit : [];
|
|
3330
|
+
}
|
|
3331
|
+
if (firstPositional === null || packageNameFromSpec4(firstPositional) === null) {
|
|
3332
|
+
return [];
|
|
3333
|
+
}
|
|
3334
|
+
return [firstPositional];
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
});
|
|
3338
|
+
|
|
3339
|
+
// ../composition-identity/dist/mcp-package-identity.js
|
|
3340
|
+
var require_mcp_package_identity = __commonJS({
|
|
3341
|
+
"../composition-identity/dist/mcp-package-identity.js"(exports) {
|
|
3342
|
+
"use strict";
|
|
3343
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3344
|
+
exports.McpPackageEcosystem = void 0;
|
|
3345
|
+
exports.resolveMcpPackageIdentity = resolveMcpPackageIdentity;
|
|
3346
|
+
exports.resolveLocalBinPackageIdentity = resolveLocalBinPackageIdentity;
|
|
3347
|
+
var mcp_launch_identity_js_1 = require_mcp_launch_identity();
|
|
3348
|
+
var npx_package_js_1 = require_npx_package();
|
|
3349
|
+
exports.McpPackageEcosystem = {
|
|
3350
|
+
NPM: "npm",
|
|
3351
|
+
PYPI: "pypi"
|
|
3352
|
+
};
|
|
3353
|
+
var PYPI_NAME_RE = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
3354
|
+
var PYPI_EXACT_VERSION_RE = /^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;
|
|
3355
|
+
function pythonRunnerBin(command) {
|
|
3356
|
+
const base = command.replaceAll("\\", "/").split("/").pop() ?? "";
|
|
3357
|
+
const bare = base.replace(/\.(cmd|exe|bat|ps1)$/i, "").toLowerCase();
|
|
3358
|
+
if (bare === "uvx" || bare === "uv" || bare === "pipx") {
|
|
3359
|
+
return bare;
|
|
3360
|
+
}
|
|
3361
|
+
return null;
|
|
3362
|
+
}
|
|
3363
|
+
var PYTHON_SPEC_FLAGS = /* @__PURE__ */ new Set(["--from", "--spec"]);
|
|
3364
|
+
var PYTHON_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
3365
|
+
"--python",
|
|
3366
|
+
"-p",
|
|
3367
|
+
"--with",
|
|
3368
|
+
"--with-editable",
|
|
3369
|
+
"--with-requirements",
|
|
3370
|
+
"--index",
|
|
3371
|
+
"--index-url",
|
|
3372
|
+
"--default-index",
|
|
3373
|
+
"--extra-index-url",
|
|
3374
|
+
"--find-links",
|
|
3375
|
+
"-f",
|
|
3376
|
+
"--constraint",
|
|
3377
|
+
"-c",
|
|
3378
|
+
"--override",
|
|
3379
|
+
"--refresh-package",
|
|
3380
|
+
"--cache-dir",
|
|
3381
|
+
"--directory",
|
|
3382
|
+
"--project",
|
|
3383
|
+
"--config-file",
|
|
3384
|
+
"--color",
|
|
3385
|
+
"--exclude-newer",
|
|
3386
|
+
"--pip-args",
|
|
3387
|
+
"--verbose-pip"
|
|
3388
|
+
]);
|
|
3389
|
+
var PYTHON_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
3390
|
+
"-q",
|
|
3391
|
+
"--quiet",
|
|
3392
|
+
"-v",
|
|
3393
|
+
"--verbose",
|
|
3394
|
+
"-n",
|
|
3395
|
+
"--native-tls",
|
|
3396
|
+
"--offline",
|
|
3397
|
+
"--isolated",
|
|
3398
|
+
"--preview",
|
|
3399
|
+
"--refresh",
|
|
3400
|
+
"--reinstall",
|
|
3401
|
+
"--upgrade",
|
|
3402
|
+
"-U",
|
|
3403
|
+
"--force",
|
|
3404
|
+
"--system",
|
|
3405
|
+
"--system-site-packages",
|
|
3406
|
+
"--path",
|
|
3407
|
+
"--managed-python",
|
|
3408
|
+
"--progress"
|
|
3409
|
+
]);
|
|
3410
|
+
var NEGATED_FLAG_RE = /^--no-/;
|
|
3411
|
+
function pythonRunnerSpec(command, args) {
|
|
3412
|
+
const bin = pythonRunnerBin(command);
|
|
3413
|
+
if (bin === null) {
|
|
3414
|
+
return null;
|
|
3415
|
+
}
|
|
3416
|
+
let rest = [...args];
|
|
3417
|
+
if (bin === "uv") {
|
|
3418
|
+
if (rest[0]?.toLowerCase() !== "tool" || rest[1]?.toLowerCase() !== "run") {
|
|
3419
|
+
return null;
|
|
3420
|
+
}
|
|
3421
|
+
rest = rest.slice(2);
|
|
3422
|
+
} else if (bin === "pipx") {
|
|
3423
|
+
if (rest[0]?.toLowerCase() !== "run") {
|
|
3424
|
+
return null;
|
|
3425
|
+
}
|
|
3426
|
+
rest = rest.slice(1);
|
|
3427
|
+
}
|
|
3428
|
+
let explicit = null;
|
|
3429
|
+
let firstPositional = null;
|
|
3430
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
3431
|
+
const token = rest[i] ?? "";
|
|
3432
|
+
if (token === "--") {
|
|
3433
|
+
firstPositional = rest[i + 1] ?? null;
|
|
3434
|
+
break;
|
|
3435
|
+
}
|
|
3436
|
+
if (!token.startsWith("-")) {
|
|
3437
|
+
firstPositional = token;
|
|
3438
|
+
break;
|
|
3439
|
+
}
|
|
3440
|
+
const eq = token.indexOf("=");
|
|
3441
|
+
const flag = eq === -1 ? token : token.slice(0, eq);
|
|
3442
|
+
if (PYTHON_SPEC_FLAGS.has(flag)) {
|
|
3443
|
+
const value = eq === -1 ? rest[i + 1] : token.slice(eq + 1);
|
|
3444
|
+
if (value !== void 0 && value.length > 0) {
|
|
3445
|
+
explicit = value;
|
|
3446
|
+
}
|
|
3447
|
+
if (eq === -1) {
|
|
3448
|
+
i += 1;
|
|
3449
|
+
}
|
|
3450
|
+
continue;
|
|
3451
|
+
}
|
|
3452
|
+
if (eq !== -1 || PYTHON_BOOLEAN_FLAGS.has(flag) || NEGATED_FLAG_RE.test(flag)) {
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
if (PYTHON_VALUE_FLAGS.has(flag)) {
|
|
3456
|
+
i += 1;
|
|
3457
|
+
continue;
|
|
3458
|
+
}
|
|
3459
|
+
return null;
|
|
3460
|
+
}
|
|
3461
|
+
return explicit ?? firstPositional;
|
|
3462
|
+
}
|
|
3463
|
+
function pypiIdentityFromSpec(spec) {
|
|
3464
|
+
if (spec.length === 0 || spec.length > npx_package_js_1.PACKAGE_FIELD_MAX) {
|
|
3465
|
+
return null;
|
|
3466
|
+
}
|
|
3467
|
+
const separator = spec.includes("==") ? "==" : spec.includes("@") ? "@" : null;
|
|
3468
|
+
if (separator === null) {
|
|
3469
|
+
return null;
|
|
3470
|
+
}
|
|
3471
|
+
const at = spec.indexOf(separator);
|
|
3472
|
+
const name = spec.slice(0, at);
|
|
3473
|
+
const version = spec.slice(at + separator.length);
|
|
3474
|
+
if (!PYPI_NAME_RE.test(name) || !PYPI_EXACT_VERSION_RE.test(version)) {
|
|
3475
|
+
return null;
|
|
3476
|
+
}
|
|
3477
|
+
return { ecosystem: exports.McpPackageEcosystem.PYPI, packageName: name, version };
|
|
3478
|
+
}
|
|
3479
|
+
function npmIdentityFromSpec(spec) {
|
|
3480
|
+
const packageName = (0, npx_package_js_1.packageNameFromSpec)(spec);
|
|
3481
|
+
if (packageName === null || !spec.startsWith(`${packageName}@`)) {
|
|
3482
|
+
return null;
|
|
3483
|
+
}
|
|
3484
|
+
const version = spec.slice(packageName.length + 1);
|
|
3485
|
+
if (!(0, npx_package_js_1.isExactNpmVersion)(version)) {
|
|
3486
|
+
return null;
|
|
3487
|
+
}
|
|
3488
|
+
return { ecosystem: exports.McpPackageEcosystem.NPM, packageName, version };
|
|
3489
|
+
}
|
|
3490
|
+
function resolveMcpPackageIdentity(launch) {
|
|
3491
|
+
if (launch?.kind !== "command") {
|
|
3492
|
+
return void 0;
|
|
3493
|
+
}
|
|
3494
|
+
if ((0, mcp_launch_identity_js_1.launchContainsCredentials)(launch)) {
|
|
3495
|
+
return void 0;
|
|
3496
|
+
}
|
|
3497
|
+
for (const spec of (0, npx_package_js_1.npxPackageSpecs)(launch.command, launch.arguments)) {
|
|
3498
|
+
const identity = npmIdentityFromSpec(spec);
|
|
3499
|
+
if (identity !== null) {
|
|
3500
|
+
return identity;
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
const pythonSpec = pythonRunnerSpec(launch.command, launch.arguments);
|
|
3504
|
+
if (pythonSpec !== null) {
|
|
3505
|
+
return pypiIdentityFromSpec(pythonSpec) ?? void 0;
|
|
3506
|
+
}
|
|
3507
|
+
return void 0;
|
|
3508
|
+
}
|
|
3509
|
+
function resolveLocalBinPackageIdentity(launch, hook) {
|
|
3510
|
+
if (launch?.kind !== "command" || (0, mcp_launch_identity_js_1.launchContainsCredentials)(launch)) {
|
|
3511
|
+
return void 0;
|
|
3512
|
+
}
|
|
3513
|
+
if (!(0, npx_package_js_1.isNodeModulesBinCommand)(launch.command) || hook.packageVersionSource !== npx_package_js_1.LOCAL_BIN_PACKAGE_VERSION_SOURCE) {
|
|
3514
|
+
return void 0;
|
|
3515
|
+
}
|
|
3516
|
+
const { packageName, packageVersion } = hook;
|
|
3517
|
+
if (packageName === void 0 || packageVersion === void 0 || (0, npx_package_js_1.packageNameFromSpec)(packageName) !== packageName || !(0, npx_package_js_1.isExactNpmVersion)(packageVersion)) {
|
|
3518
|
+
return void 0;
|
|
3519
|
+
}
|
|
3520
|
+
return { ecosystem: exports.McpPackageEcosystem.NPM, packageName, version: packageVersion };
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
});
|
|
3524
|
+
|
|
3525
|
+
// ../composition-identity/dist/mcp-provenance.js
|
|
3526
|
+
var require_mcp_provenance = __commonJS({
|
|
3527
|
+
"../composition-identity/dist/mcp-provenance.js"(exports) {
|
|
3528
|
+
"use strict";
|
|
3529
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3530
|
+
exports.EMPTY_NPM_PUBLISHER = void 0;
|
|
3531
|
+
exports.isNpmRegistryPublisher = isNpmRegistryPublisher;
|
|
3532
|
+
exports.displayPublisherName = displayPublisherName;
|
|
3533
|
+
exports.classifyMcpProvenance = classifyMcpProvenance;
|
|
3534
|
+
var mcp_launch_identity_js_1 = require_mcp_launch_identity();
|
|
3535
|
+
var npx_package_js_1 = require_npx_package();
|
|
3536
|
+
exports.EMPTY_NPM_PUBLISHER = "npm:";
|
|
3537
|
+
var NPM_ACCOUNT_PREFIX = "npm:";
|
|
3538
|
+
var NPM_USERNAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
3539
|
+
function isNpmRegistryPublisher(name) {
|
|
3540
|
+
return name.startsWith(NPM_ACCOUNT_PREFIX) && name !== exports.EMPTY_NPM_PUBLISHER && NPM_USERNAME_RE.test(name.slice(NPM_ACCOUNT_PREFIX.length));
|
|
3541
|
+
}
|
|
3542
|
+
function displayPublisherName(name) {
|
|
3543
|
+
if (name == null || name === "" || name === exports.EMPTY_NPM_PUBLISHER) {
|
|
3544
|
+
return void 0;
|
|
3545
|
+
}
|
|
3546
|
+
return name;
|
|
3547
|
+
}
|
|
3548
|
+
function privateIpv4(hostname) {
|
|
3549
|
+
const parts = hostname.split(".").map(Number);
|
|
3550
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {
|
|
3551
|
+
return false;
|
|
3552
|
+
}
|
|
3553
|
+
return parts[0] === 0 || parts[0] === 10 || parts[0] === 127 || parts[0] === 169 && parts[1] === 254 || parts[0] === 172 && (parts[1] ?? 0) >= 16 && (parts[1] ?? 0) <= 31 || parts[0] === 192 && parts[1] === 168;
|
|
3554
|
+
}
|
|
3555
|
+
function ipv4MappedAddress(host) {
|
|
3556
|
+
const dotted = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(host);
|
|
3557
|
+
if (dotted?.[1]) {
|
|
3558
|
+
return dotted[1];
|
|
3559
|
+
}
|
|
3560
|
+
const hex = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(host);
|
|
3561
|
+
if (!hex) {
|
|
3562
|
+
return void 0;
|
|
3563
|
+
}
|
|
3564
|
+
const high = Number.parseInt(hex[1], 16);
|
|
3565
|
+
const low = Number.parseInt(hex[2], 16);
|
|
3566
|
+
return `${high >> 8 & 255}.${high & 255}.${low >> 8 & 255}.${low & 255}`;
|
|
3567
|
+
}
|
|
3568
|
+
function normalizedHost(hostname) {
|
|
3569
|
+
return hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
3570
|
+
}
|
|
3571
|
+
function privateHostname(hostname) {
|
|
3572
|
+
const host = normalizedHost(hostname);
|
|
3573
|
+
const mappedIpv4 = ipv4MappedAddress(host);
|
|
3574
|
+
return host === "localhost" || host.endsWith(".localhost") || host === "::1" || host.endsWith(".local") || // A single-label host resolves only through a local suffix search; it is
|
|
3575
|
+
// never a public internet endpoint.
|
|
3576
|
+
!host.includes(".") && !host.includes(":") || privateIpv4(host) || mappedIpv4 !== void 0 && privateIpv4(mappedIpv4) || /^(?:fc|fd)[0-9a-f]{2}:/i.test(host) || /^fe[89ab][0-9a-f]:/i.test(host);
|
|
3577
|
+
}
|
|
3578
|
+
function publisherHost(hostname) {
|
|
3579
|
+
const host = normalizedHost(hostname);
|
|
3580
|
+
if (host.includes(":") || /^[0-9.]+$/.test(host)) {
|
|
3581
|
+
return null;
|
|
3582
|
+
}
|
|
3583
|
+
return host.split(".").filter(Boolean).length < 2 ? null : host;
|
|
3584
|
+
}
|
|
3585
|
+
function publicOrigin(url) {
|
|
3586
|
+
const host = normalizedHost(url.hostname);
|
|
3587
|
+
const hostname = host.includes(":") ? `[${host}]` : host;
|
|
3588
|
+
const port = url.port ? `:${url.port}` : "";
|
|
3589
|
+
return `${url.protocol}//${hostname}${port}`;
|
|
3590
|
+
}
|
|
3591
|
+
function classifyUrl(rawUrl) {
|
|
3592
|
+
const launch = { kind: "url", url: rawUrl };
|
|
3593
|
+
if ((0, mcp_launch_identity_js_1.launchContainsCredentials)(launch)) {
|
|
3594
|
+
return { origin: "UNKNOWN" };
|
|
3595
|
+
}
|
|
3596
|
+
try {
|
|
3597
|
+
const url = new URL(rawUrl);
|
|
3598
|
+
if (!["http:", "https:"].includes(url.protocol) || privateHostname(url.hostname)) {
|
|
3599
|
+
return { origin: "UNKNOWN" };
|
|
3600
|
+
}
|
|
3601
|
+
const publisherName = publisherHost(url.hostname);
|
|
3602
|
+
return {
|
|
3603
|
+
origin: "THIRD_PARTY",
|
|
3604
|
+
...publisherName === null ? {} : { publisherName },
|
|
3605
|
+
packageSourceUrl: publicOrigin(url)
|
|
3606
|
+
};
|
|
3607
|
+
} catch {
|
|
3608
|
+
return { origin: "UNKNOWN" };
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
var MCP_REMOTE_PACKAGE = "mcp-remote";
|
|
3612
|
+
function remoteUrlChild(packageName, args) {
|
|
3613
|
+
if (packageName !== MCP_REMOTE_PACKAGE) {
|
|
3614
|
+
return void 0;
|
|
3615
|
+
}
|
|
3616
|
+
return args.find((arg) => /^https?:\/\//i.test(arg));
|
|
3617
|
+
}
|
|
3618
|
+
function thirdPartyPackage(packageName, publisherName) {
|
|
3619
|
+
return {
|
|
3620
|
+
origin: "THIRD_PARTY",
|
|
3621
|
+
...publisherName ? { publisherName } : {},
|
|
3622
|
+
packageName,
|
|
3623
|
+
packageKey: packageName
|
|
3624
|
+
};
|
|
3625
|
+
}
|
|
3626
|
+
function classifyRegistryPackage(packageName, args, publisherName) {
|
|
3627
|
+
const childUrl = remoteUrlChild(packageName, args);
|
|
3628
|
+
if (childUrl !== void 0) {
|
|
3629
|
+
return classifyUrl(childUrl);
|
|
3630
|
+
}
|
|
3631
|
+
if (packageName === MCP_REMOTE_PACKAGE) {
|
|
3632
|
+
return { origin: "UNKNOWN" };
|
|
3633
|
+
}
|
|
3634
|
+
return thirdPartyPackage(packageName, publisherName);
|
|
3635
|
+
}
|
|
3636
|
+
function isRepoRelativeCommand(command) {
|
|
3637
|
+
const normalized = command.replaceAll("\\", "/");
|
|
3638
|
+
if (normalized.startsWith("~/") || normalized.startsWith("/") || /^[A-Za-z]:\//.test(normalized)) {
|
|
3639
|
+
return false;
|
|
3640
|
+
}
|
|
3641
|
+
return normalized.startsWith("./") || normalized.startsWith("../") || normalized === "scripts" || normalized.startsWith("scripts/");
|
|
3642
|
+
}
|
|
3643
|
+
function classifyMcpProvenance(input) {
|
|
3644
|
+
const launch = input.launch;
|
|
3645
|
+
if (launch === void 0 || launch.kind === "unknown") {
|
|
3646
|
+
return { origin: "UNKNOWN" };
|
|
3647
|
+
}
|
|
3648
|
+
if ((0, mcp_launch_identity_js_1.launchContainsCredentials)(launch)) {
|
|
3649
|
+
return { origin: "UNKNOWN" };
|
|
3650
|
+
}
|
|
3651
|
+
if (launch.kind === "url") {
|
|
3652
|
+
return classifyUrl(launch.url);
|
|
3653
|
+
}
|
|
3654
|
+
const specs = (0, npx_package_js_1.npxPackageSpecs)(launch.command, launch.arguments);
|
|
3655
|
+
const spec = specs[0];
|
|
3656
|
+
if (spec !== void 0) {
|
|
3657
|
+
const parsedPackageName = (0, npx_package_js_1.packageNameFromSpec)(spec);
|
|
3658
|
+
if (parsedPackageName === null) {
|
|
3659
|
+
return { origin: "UNKNOWN" };
|
|
3660
|
+
}
|
|
3661
|
+
const classified = classifyRegistryPackage(parsedPackageName, launch.arguments, input.publisherName);
|
|
3662
|
+
const hookPackageName = typeof input.packageName === "string" ? (0, npx_package_js_1.packageNameFromSpec)(input.packageName) : null;
|
|
3663
|
+
if (hookPackageName !== null && hookPackageName === parsedPackageName && classified.packageName !== void 0) {
|
|
3664
|
+
return {
|
|
3665
|
+
...classified,
|
|
3666
|
+
packageName: hookPackageName,
|
|
3667
|
+
packageKey: hookPackageName
|
|
3668
|
+
};
|
|
3669
|
+
}
|
|
3670
|
+
return classified;
|
|
3671
|
+
}
|
|
3672
|
+
if ((0, npx_package_js_1.isNodeModulesBinCommand)(launch.command)) {
|
|
3673
|
+
const hookPackageName = typeof input.packageName === "string" ? (0, npx_package_js_1.packageNameFromSpec)(input.packageName) : null;
|
|
3674
|
+
return hookPackageName === null || hookPackageName !== input.packageName ? { origin: "UNKNOWN" } : classifyRegistryPackage(hookPackageName, launch.arguments, input.publisherName);
|
|
3675
|
+
}
|
|
3676
|
+
if (isRepoRelativeCommand(launch.command)) {
|
|
3677
|
+
return { origin: "INTERNAL" };
|
|
3678
|
+
}
|
|
3679
|
+
return { origin: "UNKNOWN" };
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
});
|
|
3683
|
+
|
|
3684
|
+
// ../composition-identity/dist/mcp-server-name.js
|
|
3685
|
+
var require_mcp_server_name = __commonJS({
|
|
3686
|
+
"../composition-identity/dist/mcp-server-name.js"(exports) {
|
|
3687
|
+
"use strict";
|
|
3688
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3689
|
+
exports.mcpServerToolSegmentForms = mcpServerToolSegmentForms;
|
|
3690
|
+
exports.mcpServerNameMatchesToolSegment = mcpServerNameMatchesToolSegment;
|
|
3691
|
+
function mcpServerToolSegmentForms(name) {
|
|
3692
|
+
return [
|
|
3693
|
+
.../* @__PURE__ */ new Set([
|
|
3694
|
+
name,
|
|
3695
|
+
name.replaceAll(/[^A-Za-z0-9_-]/g, "_"),
|
|
3696
|
+
name.replaceAll(/[^A-Za-z0-9_-]+/g, "_")
|
|
3697
|
+
])
|
|
3698
|
+
];
|
|
3699
|
+
}
|
|
3700
|
+
function mcpServerNameMatchesToolSegment(name, segment) {
|
|
3701
|
+
const lower = segment.toLowerCase();
|
|
3702
|
+
return mcpServerToolSegmentForms(name).some((form) => form.toLowerCase() === lower);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
});
|
|
3706
|
+
|
|
3707
|
+
// ../composition-identity/dist/catalog-text.js
|
|
3708
|
+
var require_catalog_text = __commonJS({
|
|
3709
|
+
"../composition-identity/dist/catalog-text.js"(exports) {
|
|
3710
|
+
"use strict";
|
|
3711
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3712
|
+
exports.parseFrontmatterField = exports.parseFrontmatterDescription = exports.usableCatalogText = void 0;
|
|
3713
|
+
var YAML_BLOCK_SCALAR_TOKEN = /^(?:>|\|)[-+]?$/;
|
|
3714
|
+
var YAML_BLOCK_HEADER = /^(?:>|\|)[-+]?(?:\s+(.*))?$/;
|
|
3715
|
+
var usableCatalogText = (value) => {
|
|
3716
|
+
const trimmed = value?.trim() ?? "";
|
|
3717
|
+
if (trimmed.length === 0 || YAML_BLOCK_SCALAR_TOKEN.test(trimmed)) {
|
|
3718
|
+
return void 0;
|
|
3719
|
+
}
|
|
3720
|
+
return trimmed;
|
|
3721
|
+
};
|
|
3722
|
+
exports.usableCatalogText = usableCatalogText;
|
|
3723
|
+
var parseFrontmatterDescription = (content) => (0, exports.parseFrontmatterField)(content, "description");
|
|
3724
|
+
exports.parseFrontmatterDescription = parseFrontmatterDescription;
|
|
3725
|
+
var parseFrontmatterField = (content, field) => {
|
|
3726
|
+
const match = /^---\s*\n([\s\S]*?)\n---/.exec(content);
|
|
3727
|
+
if (!match) {
|
|
3728
|
+
return void 0;
|
|
3729
|
+
}
|
|
3730
|
+
return parseYamlFrontmatterScalar(match[1], field);
|
|
3731
|
+
};
|
|
3732
|
+
exports.parseFrontmatterField = parseFrontmatterField;
|
|
3733
|
+
var stripYamlQuotes = (value) => value.replace(/^["']|["']$/g, "");
|
|
3734
|
+
function parseYamlFrontmatterScalar(block, field) {
|
|
3735
|
+
const lines = block.split("\n");
|
|
3736
|
+
const prefix = `${field}:`;
|
|
3737
|
+
const start = lines.findIndex((line) => line === prefix || line.startsWith(`${prefix} `) || line.startsWith(`${prefix} `));
|
|
3738
|
+
if (start < 0) {
|
|
3739
|
+
return void 0;
|
|
3740
|
+
}
|
|
3741
|
+
const remainder = (lines[start] ?? "").slice(prefix.length).trim();
|
|
3742
|
+
const header = YAML_BLOCK_HEADER.exec(remainder);
|
|
3743
|
+
if (!header) {
|
|
3744
|
+
const inline = stripYamlQuotes(remainder).trim();
|
|
3745
|
+
return (0, exports.usableCatalogText)(inline);
|
|
3746
|
+
}
|
|
3747
|
+
const indented = [];
|
|
3748
|
+
for (let index = start + 1; index < lines.length; index += 1) {
|
|
3749
|
+
const line = lines[index] ?? "";
|
|
3750
|
+
if (line.trim() === "") {
|
|
3751
|
+
indented.push("");
|
|
3752
|
+
continue;
|
|
3753
|
+
}
|
|
3754
|
+
if (line.length === line.trimStart().length) {
|
|
3755
|
+
break;
|
|
3756
|
+
}
|
|
3757
|
+
indented.push(line);
|
|
3758
|
+
}
|
|
3759
|
+
const blockIndent = indented.reduce((min, line) => line.trim() === "" ? min : Math.min(min, line.length - line.trimStart().length), Number.POSITIVE_INFINITY);
|
|
3760
|
+
const body = [];
|
|
3761
|
+
const sameLine = header[1]?.trim();
|
|
3762
|
+
if (sameLine) {
|
|
3763
|
+
body.push(sameLine);
|
|
3764
|
+
}
|
|
3765
|
+
for (const line of indented) {
|
|
3766
|
+
body.push(line.trim() === "" ? "" : line.slice(blockIndent));
|
|
3767
|
+
}
|
|
3768
|
+
while (body.length > 0 && body[body.length - 1] === "") {
|
|
3769
|
+
body.pop();
|
|
3770
|
+
}
|
|
3771
|
+
const folded = remainder.startsWith(">");
|
|
3772
|
+
const text = folded ? body.join("\n").split(/\n{2,}/).map((paragraph) => paragraph.split("\n").map((line) => line.trim()).filter(Boolean).join(" ")).filter((paragraph) => paragraph.length > 0).join("\n\n") : body.join("\n").trimEnd();
|
|
3773
|
+
return (0, exports.usableCatalogText)(text);
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
});
|
|
3777
|
+
|
|
3778
|
+
// ../composition-identity/dist/skill-source-redaction.js
|
|
3779
|
+
var require_skill_source_redaction = __commonJS({
|
|
3780
|
+
"../composition-identity/dist/skill-source-redaction.js"(exports) {
|
|
3781
|
+
"use strict";
|
|
3782
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3783
|
+
exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = void 0;
|
|
3784
|
+
exports.fitSnapshotInspectionTextBudget = fitSnapshotInspectionTextBudget;
|
|
3785
|
+
exports.capComponentTextBytes = capComponentTextBytes;
|
|
3786
|
+
exports.prepareComponentInspectionText = prepareComponentInspectionText;
|
|
3787
|
+
exports.redactComponentSource = redactComponentSource;
|
|
3788
|
+
exports.componentSourceContainsRedactableSecret = componentSourceContainsRedactableSecret;
|
|
3789
|
+
exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = "[REDACTED]";
|
|
3790
|
+
exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = 256 * 1024;
|
|
3791
|
+
exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = 3 * 1024 * 1024;
|
|
3792
|
+
function fitSnapshotInspectionTextBudget(definitions) {
|
|
3793
|
+
let usedBytes = 0;
|
|
3794
|
+
return definitions.map((definition) => {
|
|
3795
|
+
const flat = definition;
|
|
3796
|
+
const inspectionText = flat.skill?.inspectionText;
|
|
3797
|
+
if (inspectionText === void 0)
|
|
3798
|
+
return definition;
|
|
3799
|
+
const byteLength = Buffer.byteLength(inspectionText, "utf8");
|
|
3800
|
+
if (usedBytes + byteLength <= exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES) {
|
|
3801
|
+
usedBytes += byteLength;
|
|
3802
|
+
return definition;
|
|
3803
|
+
}
|
|
3804
|
+
return {
|
|
3805
|
+
...definition,
|
|
3806
|
+
skill: {
|
|
3807
|
+
...flat.skill,
|
|
3808
|
+
inspectionText: void 0
|
|
3809
|
+
}
|
|
3810
|
+
};
|
|
3811
|
+
});
|
|
3812
|
+
}
|
|
3813
|
+
function capComponentTextBytes(text, maxBytes) {
|
|
3814
|
+
if (text == null || text.length === 0) {
|
|
3815
|
+
return void 0;
|
|
3816
|
+
}
|
|
3817
|
+
const buf = Buffer.from(text, "utf8");
|
|
3818
|
+
if (buf.byteLength <= maxBytes) {
|
|
3819
|
+
return text;
|
|
3820
|
+
}
|
|
3821
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
3822
|
+
for (let end = maxBytes; end > 0; end -= 1) {
|
|
3823
|
+
try {
|
|
3824
|
+
return decoder.decode(buf.subarray(0, end));
|
|
3825
|
+
} catch {
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
return void 0;
|
|
3829
|
+
}
|
|
3830
|
+
function prepareComponentInspectionText(text) {
|
|
3831
|
+
if (text == null || text.length === 0) {
|
|
3832
|
+
return void 0;
|
|
3833
|
+
}
|
|
3834
|
+
return capComponentTextBytes(redactComponentSource(text), exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES);
|
|
3835
|
+
}
|
|
3836
|
+
var TOKEN_LITERAL_RES = [
|
|
3837
|
+
// OpenAI-style and generic `sk-` / `sk-proj-` keys.
|
|
3838
|
+
/\bsk-(?:proj-)?[A-Za-z0-9_-]{16,}/g,
|
|
3839
|
+
// GitHub personal access, OAuth, user, server, and refresh tokens.
|
|
3840
|
+
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,
|
|
3841
|
+
/\bgithub_pat_[A-Za-z0-9_]{20,}/g,
|
|
3842
|
+
// Slack bot / user / app / refresh tokens.
|
|
3843
|
+
/\bxox[baprs]-[A-Za-z0-9-]{10,}/g,
|
|
3844
|
+
// AWS access key ids.
|
|
3845
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
3846
|
+
// Google API keys.
|
|
3847
|
+
/\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
3848
|
+
// JWTs (three base64url segments).
|
|
3849
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
3850
|
+
];
|
|
3851
|
+
var BEARER_RE = /\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi;
|
|
3852
|
+
var URL_USERINFO_RE = /\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi;
|
|
3853
|
+
var URL_CREDENTIAL_PARAM_RE = /([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi;
|
|
3854
|
+
var PRIVATE_KEY_BEGIN_RE = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/;
|
|
3855
|
+
var PRIVATE_KEY_END_RE = /-----END [A-Z0-9 ]*PRIVATE KEY-----/;
|
|
3856
|
+
function redactLine(line) {
|
|
3857
|
+
let redacted = line.replace(URL_USERINFO_RE, (_match, scheme) => `${scheme}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);
|
|
3858
|
+
redacted = redacted.replace(URL_CREDENTIAL_PARAM_RE, (_match, prefix) => `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
|
|
3859
|
+
redacted = redacted.replace(BEARER_RE, (_match, prefix) => `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
|
|
3860
|
+
for (const pattern of TOKEN_LITERAL_RES) {
|
|
3861
|
+
redacted = redacted.replace(pattern, exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);
|
|
3862
|
+
}
|
|
3863
|
+
return redacted;
|
|
3864
|
+
}
|
|
3865
|
+
function redactComponentSource(text) {
|
|
3866
|
+
if (text.length === 0) {
|
|
3867
|
+
return text;
|
|
3868
|
+
}
|
|
3869
|
+
const lines = text.split("\n");
|
|
3870
|
+
let insidePrivateKey = false;
|
|
3871
|
+
const redacted = lines.map((line) => {
|
|
3872
|
+
if (insidePrivateKey) {
|
|
3873
|
+
if (PRIVATE_KEY_END_RE.test(line)) {
|
|
3874
|
+
insidePrivateKey = false;
|
|
3875
|
+
return line;
|
|
3876
|
+
}
|
|
3877
|
+
return line.trim().length === 0 ? line : exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER;
|
|
3878
|
+
}
|
|
3879
|
+
if (PRIVATE_KEY_BEGIN_RE.test(line) && !PRIVATE_KEY_END_RE.test(line)) {
|
|
3880
|
+
insidePrivateKey = true;
|
|
3881
|
+
return line;
|
|
3882
|
+
}
|
|
3883
|
+
return redactLine(line);
|
|
3884
|
+
});
|
|
3885
|
+
return redacted.join("\n");
|
|
3886
|
+
}
|
|
3887
|
+
function componentSourceContainsRedactableSecret(text) {
|
|
3888
|
+
return redactComponentSource(text) !== text;
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
});
|
|
3892
|
+
|
|
3893
|
+
// ../composition-identity/dist/index.js
|
|
3894
|
+
var require_dist = __commonJS({
|
|
3895
|
+
"../composition-identity/dist/index.js"(exports) {
|
|
3896
|
+
"use strict";
|
|
3897
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3898
|
+
exports.redactComponentSource = exports.prepareComponentInspectionText = exports.fitSnapshotInspectionTextBudget = exports.componentSourceContainsRedactableSecret = exports.capComponentTextBytes = exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = exports.usableCatalogText = exports.parseFrontmatterField = exports.parseFrontmatterDescription = exports.mcpServerToolSegmentForms = exports.mcpServerNameMatchesToolSegment = exports.isNpmRegistryPublisher = exports.EMPTY_NPM_PUBLISHER = exports.displayPublisherName = exports.classifyMcpProvenance = exports.resolveMcpPackageIdentity = exports.resolveLocalBinPackageIdentity = exports.McpPackageEcosystem = exports.pinnedPackageVersionFromSpec = exports.pinnedPackageVersionFromNpx = exports.packageNameFromSpec = exports.npxPackageSpecs = exports.npxExecBin = exports.isNodeModulesBinCommand = exports.isExactNpmVersion = exports.LOCAL_BIN_PACKAGE_VERSION_SOURCE = exports.PACKAGE_FIELD_MAX = exports.serializeMcpLaunchIdentity = exports.projectMcpMissingLaunchIdentity = exports.projectMcpLaunchIdentity = exports.normalizeMcpToolNames = exports.MCP_MISSING_LAUNCH_SERIALIZED = exports.MCP_LAUNCH_IDENTITY_ALGORITHM = exports.maskMcpLaunchForDisplay = exports.launchContainsCredentials = exports.hashMcpLaunchIdentity = exports.foldMcpName = exports.buildMcpFamilyCanonicalKey = exports.ComponentKind = void 0;
|
|
3899
|
+
exports.userConfigRootFromPath = userConfigRootFromPath;
|
|
3900
|
+
exports.installationRootExternalKey = installationRootExternalKey;
|
|
3901
|
+
exports.normalizeRepositoryRelativePath = normalizeRepositoryRelativePath;
|
|
3902
|
+
exports.nativeKeyForSkillPath = nativeKeyForSkillPath;
|
|
3903
|
+
exports.nativeKeyForRulePath = nativeKeyForRulePath;
|
|
3904
|
+
exports.nativeKeyForCommandPath = nativeKeyForCommandPath;
|
|
3905
|
+
exports.serializeComponentIdentity = serializeComponentIdentity;
|
|
3906
|
+
exports.buildComponentReference = buildComponentReference;
|
|
3907
|
+
exports.validateComponentReference = validateComponentReference;
|
|
3908
|
+
var node_crypto_1 = __require("node:crypto");
|
|
3909
|
+
var node_path_1 = __require("node:path");
|
|
3910
|
+
var REFERENCE_PREFIX = "cmp1_";
|
|
3911
|
+
var REFERENCE_PATTERN = /^cmp1_[A-Za-z0-9_-]{43}$/;
|
|
3912
|
+
var SKILLS_DIR_MARKERS = ["/skills/", "/skills-cursor/"];
|
|
3913
|
+
var RULE_PATH_RE = /(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i;
|
|
3914
|
+
var COMMAND_PATH_RE = /(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i;
|
|
3915
|
+
var COPILOT_INSTRUCTION_PATH_RE = /(?:^|\/)\.(?:github|copilot)\/instructions\/(.+)$/i;
|
|
3916
|
+
var COPILOT_PROMPT_PATH_RE = /(?:^|\/)\.github\/prompts\/(.+)$/i;
|
|
3917
|
+
var USER_CONFIG_ROOTS = [".cursor", ".claude", ".codex", ".copilot"];
|
|
3918
|
+
var USER_CONFIG_ROOT_ALIASES = {
|
|
3919
|
+
".claude.json": ".claude",
|
|
3920
|
+
".agents": ".codex",
|
|
3921
|
+
// Copilot's project surfaces live under `.github/` (and VS Code's `.vscode/mcp.json`);
|
|
3922
|
+
// its user ones under `~/.copilot/`.
|
|
3923
|
+
".github": ".copilot",
|
|
3924
|
+
".vscode": ".copilot"
|
|
3925
|
+
};
|
|
3926
|
+
exports.ComponentKind = {
|
|
3927
|
+
SKILL: "SKILL",
|
|
3928
|
+
INTERFACE: "INTERFACE",
|
|
3929
|
+
RULE: "RULE",
|
|
3930
|
+
COMMAND: "COMMAND"
|
|
3931
|
+
};
|
|
3932
|
+
function userConfigRootFromPath(path) {
|
|
3933
|
+
const segments = path.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
3934
|
+
const knownRoot = segments.find((segment) => USER_CONFIG_ROOTS.includes(segment));
|
|
3935
|
+
if (knownRoot) {
|
|
3936
|
+
return knownRoot;
|
|
3937
|
+
}
|
|
3938
|
+
const aliasedRoot = segments.map((segment) => USER_CONFIG_ROOT_ALIASES[segment]).find((root) => root !== void 0);
|
|
3939
|
+
return aliasedRoot ?? "unknown";
|
|
3940
|
+
}
|
|
3941
|
+
function installationRootExternalKey(installationId, configRoot) {
|
|
3942
|
+
return `runtime-install:${installationId}/${configRoot}`;
|
|
3943
|
+
}
|
|
3944
|
+
function requireValue(value, field2) {
|
|
3945
|
+
if (value.length === 0) {
|
|
3946
|
+
throw new Error(`${field2} is required`);
|
|
3947
|
+
}
|
|
3948
|
+
return value;
|
|
3949
|
+
}
|
|
3950
|
+
function normalizeRepositoryRelativePath(path) {
|
|
3951
|
+
const slashPath = path.replaceAll("\\", "/");
|
|
3952
|
+
if (slashPath.startsWith("/") || /^[A-Za-z]:\//.test(slashPath)) {
|
|
3953
|
+
throw new Error("sourcePath must be repository-relative");
|
|
3954
|
+
}
|
|
3955
|
+
const normalized = node_path_1.posix.normalize(slashPath).replace(/^\.\//, "");
|
|
3956
|
+
if (normalized === "." || normalized === ".." || normalized.startsWith("../")) {
|
|
3957
|
+
throw new Error("sourcePath must be repository-relative");
|
|
3958
|
+
}
|
|
3959
|
+
return requireValue(normalized, "sourcePath");
|
|
3960
|
+
}
|
|
3961
|
+
function nativeKeyForSkillPath(path) {
|
|
3962
|
+
const normalized = path.replaceAll("\\", "/");
|
|
3963
|
+
for (const marker of SKILLS_DIR_MARKERS) {
|
|
3964
|
+
const segment = normalized.split(marker)[1]?.split("/")[0];
|
|
3965
|
+
if (segment && segment.length > 0) {
|
|
3966
|
+
return segment;
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
return null;
|
|
3970
|
+
}
|
|
3971
|
+
function nativeKeyUnderLayoutRoot(path, rootPattern, extensionPattern) {
|
|
3972
|
+
const normalized = path.replaceAll("\\", "/");
|
|
3973
|
+
const match = rootPattern.exec(normalized);
|
|
3974
|
+
const rest = match?.[1];
|
|
3975
|
+
if (!rest || rest.split("/").includes("..")) {
|
|
3976
|
+
return null;
|
|
3977
|
+
}
|
|
3978
|
+
const stripped = rest.replace(extensionPattern, "");
|
|
3979
|
+
return stripped.length > 0 ? stripped : null;
|
|
3980
|
+
}
|
|
3981
|
+
function nativeKeyForRulePath(path) {
|
|
3982
|
+
return nativeKeyUnderLayoutRoot(path, RULE_PATH_RE, /\.(mdc|md|rules)$/i) ?? copilotNativeKey(path, COPILOT_INSTRUCTION_PATH_RE, /\.instructions\.md$/i);
|
|
3983
|
+
}
|
|
3984
|
+
function nativeKeyForCommandPath(path) {
|
|
3985
|
+
return nativeKeyUnderLayoutRoot(path, COMMAND_PATH_RE, /\.(md|mdc|toml)$/i) ?? copilotNativeKey(path, COPILOT_PROMPT_PATH_RE, /\.prompt\.md$/i);
|
|
3986
|
+
}
|
|
3987
|
+
function copilotNativeKey(path, rootPattern, compoundExtension) {
|
|
3988
|
+
if (!compoundExtension.test(path.split("#", 1)[0] ?? "")) {
|
|
3989
|
+
return null;
|
|
3990
|
+
}
|
|
3991
|
+
const key = nativeKeyUnderLayoutRoot(path, rootPattern, compoundExtension);
|
|
3992
|
+
return key === null ? null : key.split("/").pop() ?? null;
|
|
3993
|
+
}
|
|
3994
|
+
function field(value) {
|
|
3995
|
+
return `${Buffer.byteLength(value, "utf8")}:${value}`;
|
|
3996
|
+
}
|
|
3997
|
+
function serializeComponentIdentity(input) {
|
|
3998
|
+
const values = [
|
|
3999
|
+
requireValue(input.installationRootExternalKey, "installationRootExternalKey"),
|
|
4000
|
+
requireValue(input.installableKind, "installableKind"),
|
|
4001
|
+
normalizeRepositoryRelativePath(input.sourcePath),
|
|
4002
|
+
requireValue(input.nativeKey, "nativeKey")
|
|
4003
|
+
];
|
|
4004
|
+
return Buffer.from(`1|${values.map(field).join("|")}`, "utf8");
|
|
4005
|
+
}
|
|
4006
|
+
function buildComponentReference(input) {
|
|
4007
|
+
const digest = (0, node_crypto_1.createHash)("sha256").update(serializeComponentIdentity(input)).digest("base64url");
|
|
4008
|
+
return `${REFERENCE_PREFIX}${digest}`;
|
|
4009
|
+
}
|
|
4010
|
+
function validateComponentReference(value) {
|
|
4011
|
+
return REFERENCE_PATTERN.test(value);
|
|
4012
|
+
}
|
|
4013
|
+
var mcp_launch_identity_js_1 = require_mcp_launch_identity();
|
|
4014
|
+
Object.defineProperty(exports, "buildMcpFamilyCanonicalKey", { enumerable: true, get: function() {
|
|
4015
|
+
return mcp_launch_identity_js_1.buildMcpFamilyCanonicalKey;
|
|
4016
|
+
} });
|
|
4017
|
+
Object.defineProperty(exports, "foldMcpName", { enumerable: true, get: function() {
|
|
4018
|
+
return mcp_launch_identity_js_1.foldMcpName;
|
|
4019
|
+
} });
|
|
4020
|
+
Object.defineProperty(exports, "hashMcpLaunchIdentity", { enumerable: true, get: function() {
|
|
4021
|
+
return mcp_launch_identity_js_1.hashMcpLaunchIdentity;
|
|
4022
|
+
} });
|
|
4023
|
+
Object.defineProperty(exports, "launchContainsCredentials", { enumerable: true, get: function() {
|
|
4024
|
+
return mcp_launch_identity_js_1.launchContainsCredentials;
|
|
4025
|
+
} });
|
|
4026
|
+
Object.defineProperty(exports, "maskMcpLaunchForDisplay", { enumerable: true, get: function() {
|
|
4027
|
+
return mcp_launch_identity_js_1.maskMcpLaunchForDisplay;
|
|
4028
|
+
} });
|
|
4029
|
+
Object.defineProperty(exports, "MCP_LAUNCH_IDENTITY_ALGORITHM", { enumerable: true, get: function() {
|
|
4030
|
+
return mcp_launch_identity_js_1.MCP_LAUNCH_IDENTITY_ALGORITHM;
|
|
4031
|
+
} });
|
|
4032
|
+
Object.defineProperty(exports, "MCP_MISSING_LAUNCH_SERIALIZED", { enumerable: true, get: function() {
|
|
4033
|
+
return mcp_launch_identity_js_1.MCP_MISSING_LAUNCH_SERIALIZED;
|
|
4034
|
+
} });
|
|
4035
|
+
Object.defineProperty(exports, "normalizeMcpToolNames", { enumerable: true, get: function() {
|
|
4036
|
+
return mcp_launch_identity_js_1.normalizeMcpToolNames;
|
|
4037
|
+
} });
|
|
4038
|
+
Object.defineProperty(exports, "projectMcpLaunchIdentity", { enumerable: true, get: function() {
|
|
4039
|
+
return mcp_launch_identity_js_1.projectMcpLaunchIdentity;
|
|
4040
|
+
} });
|
|
4041
|
+
Object.defineProperty(exports, "projectMcpMissingLaunchIdentity", { enumerable: true, get: function() {
|
|
4042
|
+
return mcp_launch_identity_js_1.projectMcpMissingLaunchIdentity;
|
|
4043
|
+
} });
|
|
4044
|
+
Object.defineProperty(exports, "serializeMcpLaunchIdentity", { enumerable: true, get: function() {
|
|
4045
|
+
return mcp_launch_identity_js_1.serializeMcpLaunchIdentity;
|
|
4046
|
+
} });
|
|
4047
|
+
var npx_package_js_1 = require_npx_package();
|
|
4048
|
+
Object.defineProperty(exports, "PACKAGE_FIELD_MAX", { enumerable: true, get: function() {
|
|
4049
|
+
return npx_package_js_1.PACKAGE_FIELD_MAX;
|
|
4050
|
+
} });
|
|
4051
|
+
Object.defineProperty(exports, "LOCAL_BIN_PACKAGE_VERSION_SOURCE", { enumerable: true, get: function() {
|
|
4052
|
+
return npx_package_js_1.LOCAL_BIN_PACKAGE_VERSION_SOURCE;
|
|
4053
|
+
} });
|
|
4054
|
+
Object.defineProperty(exports, "isExactNpmVersion", { enumerable: true, get: function() {
|
|
4055
|
+
return npx_package_js_1.isExactNpmVersion;
|
|
4056
|
+
} });
|
|
4057
|
+
Object.defineProperty(exports, "isNodeModulesBinCommand", { enumerable: true, get: function() {
|
|
4058
|
+
return npx_package_js_1.isNodeModulesBinCommand;
|
|
4059
|
+
} });
|
|
4060
|
+
Object.defineProperty(exports, "npxExecBin", { enumerable: true, get: function() {
|
|
4061
|
+
return npx_package_js_1.npxExecBin;
|
|
4062
|
+
} });
|
|
4063
|
+
Object.defineProperty(exports, "npxPackageSpecs", { enumerable: true, get: function() {
|
|
4064
|
+
return npx_package_js_1.npxPackageSpecs;
|
|
4065
|
+
} });
|
|
4066
|
+
Object.defineProperty(exports, "packageNameFromSpec", { enumerable: true, get: function() {
|
|
4067
|
+
return npx_package_js_1.packageNameFromSpec;
|
|
4068
|
+
} });
|
|
4069
|
+
Object.defineProperty(exports, "pinnedPackageVersionFromNpx", { enumerable: true, get: function() {
|
|
4070
|
+
return npx_package_js_1.pinnedPackageVersionFromNpx;
|
|
4071
|
+
} });
|
|
4072
|
+
Object.defineProperty(exports, "pinnedPackageVersionFromSpec", { enumerable: true, get: function() {
|
|
4073
|
+
return npx_package_js_1.pinnedPackageVersionFromSpec;
|
|
4074
|
+
} });
|
|
4075
|
+
var mcp_package_identity_js_1 = require_mcp_package_identity();
|
|
4076
|
+
Object.defineProperty(exports, "McpPackageEcosystem", { enumerable: true, get: function() {
|
|
4077
|
+
return mcp_package_identity_js_1.McpPackageEcosystem;
|
|
4078
|
+
} });
|
|
4079
|
+
Object.defineProperty(exports, "resolveLocalBinPackageIdentity", { enumerable: true, get: function() {
|
|
4080
|
+
return mcp_package_identity_js_1.resolveLocalBinPackageIdentity;
|
|
4081
|
+
} });
|
|
4082
|
+
Object.defineProperty(exports, "resolveMcpPackageIdentity", { enumerable: true, get: function() {
|
|
4083
|
+
return mcp_package_identity_js_1.resolveMcpPackageIdentity;
|
|
4084
|
+
} });
|
|
4085
|
+
var mcp_provenance_js_1 = require_mcp_provenance();
|
|
4086
|
+
Object.defineProperty(exports, "classifyMcpProvenance", { enumerable: true, get: function() {
|
|
4087
|
+
return mcp_provenance_js_1.classifyMcpProvenance;
|
|
4088
|
+
} });
|
|
4089
|
+
Object.defineProperty(exports, "displayPublisherName", { enumerable: true, get: function() {
|
|
4090
|
+
return mcp_provenance_js_1.displayPublisherName;
|
|
4091
|
+
} });
|
|
4092
|
+
Object.defineProperty(exports, "EMPTY_NPM_PUBLISHER", { enumerable: true, get: function() {
|
|
4093
|
+
return mcp_provenance_js_1.EMPTY_NPM_PUBLISHER;
|
|
4094
|
+
} });
|
|
4095
|
+
Object.defineProperty(exports, "isNpmRegistryPublisher", { enumerable: true, get: function() {
|
|
4096
|
+
return mcp_provenance_js_1.isNpmRegistryPublisher;
|
|
4097
|
+
} });
|
|
4098
|
+
var mcp_server_name_js_1 = require_mcp_server_name();
|
|
4099
|
+
Object.defineProperty(exports, "mcpServerNameMatchesToolSegment", { enumerable: true, get: function() {
|
|
4100
|
+
return mcp_server_name_js_1.mcpServerNameMatchesToolSegment;
|
|
4101
|
+
} });
|
|
4102
|
+
Object.defineProperty(exports, "mcpServerToolSegmentForms", { enumerable: true, get: function() {
|
|
4103
|
+
return mcp_server_name_js_1.mcpServerToolSegmentForms;
|
|
4104
|
+
} });
|
|
4105
|
+
var catalog_text_js_1 = require_catalog_text();
|
|
4106
|
+
Object.defineProperty(exports, "parseFrontmatterDescription", { enumerable: true, get: function() {
|
|
4107
|
+
return catalog_text_js_1.parseFrontmatterDescription;
|
|
4108
|
+
} });
|
|
4109
|
+
Object.defineProperty(exports, "parseFrontmatterField", { enumerable: true, get: function() {
|
|
4110
|
+
return catalog_text_js_1.parseFrontmatterField;
|
|
4111
|
+
} });
|
|
4112
|
+
Object.defineProperty(exports, "usableCatalogText", { enumerable: true, get: function() {
|
|
4113
|
+
return catalog_text_js_1.usableCatalogText;
|
|
4114
|
+
} });
|
|
4115
|
+
var skill_source_redaction_js_1 = require_skill_source_redaction();
|
|
4116
|
+
Object.defineProperty(exports, "COMPONENT_INSPECTION_TEXT_MAX_BYTES", { enumerable: true, get: function() {
|
|
4117
|
+
return skill_source_redaction_js_1.COMPONENT_INSPECTION_TEXT_MAX_BYTES;
|
|
4118
|
+
} });
|
|
4119
|
+
Object.defineProperty(exports, "COMPONENT_SOURCE_REDACTION_PLACEHOLDER", { enumerable: true, get: function() {
|
|
4120
|
+
return skill_source_redaction_js_1.COMPONENT_SOURCE_REDACTION_PLACEHOLDER;
|
|
4121
|
+
} });
|
|
4122
|
+
Object.defineProperty(exports, "SNAPSHOT_INSPECTION_TEXT_MAX_BYTES", { enumerable: true, get: function() {
|
|
4123
|
+
return skill_source_redaction_js_1.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES;
|
|
4124
|
+
} });
|
|
4125
|
+
Object.defineProperty(exports, "capComponentTextBytes", { enumerable: true, get: function() {
|
|
4126
|
+
return skill_source_redaction_js_1.capComponentTextBytes;
|
|
4127
|
+
} });
|
|
4128
|
+
Object.defineProperty(exports, "componentSourceContainsRedactableSecret", { enumerable: true, get: function() {
|
|
4129
|
+
return skill_source_redaction_js_1.componentSourceContainsRedactableSecret;
|
|
4130
|
+
} });
|
|
4131
|
+
Object.defineProperty(exports, "fitSnapshotInspectionTextBudget", { enumerable: true, get: function() {
|
|
4132
|
+
return skill_source_redaction_js_1.fitSnapshotInspectionTextBudget;
|
|
4133
|
+
} });
|
|
4134
|
+
Object.defineProperty(exports, "prepareComponentInspectionText", { enumerable: true, get: function() {
|
|
4135
|
+
return skill_source_redaction_js_1.prepareComponentInspectionText;
|
|
4136
|
+
} });
|
|
4137
|
+
Object.defineProperty(exports, "redactComponentSource", { enumerable: true, get: function() {
|
|
4138
|
+
return skill_source_redaction_js_1.redactComponentSource;
|
|
4139
|
+
} });
|
|
4140
|
+
}
|
|
4141
|
+
});
|
|
4
4142
|
|
|
5
4143
|
// src/install/plugin-hooks.ts
|
|
6
4144
|
import {
|
|
@@ -33,18 +4171,16 @@ var HOOK_INPUT_ALLOWLIST_MAX_BYTES = 4 * 1024;
|
|
|
33
4171
|
var HOOK_INPUT_FULL_MAX_BYTES = 256 * 1024;
|
|
34
4172
|
var HOOK_INPUT_MCP_MAX_BYTES = 4 * 1024;
|
|
35
4173
|
var GZIP_MIN_BYTES = 32 * 1024;
|
|
36
|
-
var PACKAGE_VERSION = "1.
|
|
4174
|
+
var PACKAGE_VERSION = "1.4.1";
|
|
37
4175
|
var NPX_PACKAGE_SPEC = `@ev-ai/agent-hook@${PACKAGE_VERSION}`;
|
|
38
4176
|
var HOOK_STATUS_MESSAGE = "ev-ai runtime report";
|
|
39
4177
|
var PLUGIN_ROOT_VARIABLE = {
|
|
40
4178
|
claude: "CLAUDE_PLUGIN_ROOT",
|
|
41
4179
|
cursor: "CURSOR_PLUGIN_ROOT",
|
|
42
|
-
codex: "PLUGIN_ROOT"
|
|
4180
|
+
codex: "PLUGIN_ROOT",
|
|
4181
|
+
copilot: "PLUGIN_ROOT"
|
|
43
4182
|
};
|
|
44
4183
|
|
|
45
|
-
// src/collectors/sys.ts
|
|
46
|
-
var BYTES_PER_MB = 1024 * 1024;
|
|
47
|
-
|
|
48
4184
|
// src/shared/file-logger.ts
|
|
49
4185
|
var LOG_MAX_BYTES = 1024 * 1024;
|
|
50
4186
|
var LOG_LINE_SLACK_BYTES = 8 * 1024;
|
|
@@ -53,6 +4189,531 @@ var LOG_PURGE_AFTER_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
|
53
4189
|
var HOOK_CONFIG_FILE_MAX_BYTES = 1024 * 1024;
|
|
54
4190
|
var RUN_LOG_WINDOWS_FILE_MAX_BYTES = 64 * 1024;
|
|
55
4191
|
|
|
4192
|
+
// src/collectors/identity/cursor-cloud-metadata.ts
|
|
4193
|
+
var CURSOR_OWNER_UNVERIFIED_BOOT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
4194
|
+
var CURSOR_OWNER_EMPTY_TTL_MS = 10 * 60 * 1e3;
|
|
4195
|
+
var CURSOR_OWNER_FORBIDDEN_TTL_MS = 60 * 60 * 1e3;
|
|
4196
|
+
var CURSOR_OWNER_ERROR_TTL_MS = 60 * 1e3;
|
|
4197
|
+
|
|
4198
|
+
// src/collectors/sys.ts
|
|
4199
|
+
var BYTES_PER_MB = 1024 * 1024;
|
|
4200
|
+
|
|
4201
|
+
// src/hook/sanitizeHookInput.ts
|
|
4202
|
+
var STRING_TRUNCATE_MARKER = "\u2026[truncated]\u2026";
|
|
4203
|
+
var STRING_TRUNCATE_MARKER_BYTES = Buffer.byteLength(STRING_TRUNCATE_MARKER, "utf8");
|
|
4204
|
+
|
|
4205
|
+
// ../../common/repo-manifest/src/index.ts
|
|
4206
|
+
var import_micromatch = __toESM(require_micromatch());
|
|
4207
|
+
var EXCLUDE_PATTERNS = [
|
|
4208
|
+
"**/node_modules/**",
|
|
4209
|
+
"**/dist/**",
|
|
4210
|
+
"**/build/**",
|
|
4211
|
+
"**/.git/**",
|
|
4212
|
+
"**/.trash/**",
|
|
4213
|
+
// Claude runtime cache (changelog, model catalog).
|
|
4214
|
+
"**/.claude/cache/**",
|
|
4215
|
+
"**/.codex/skills/.system/**",
|
|
4216
|
+
"**/vendor/**",
|
|
4217
|
+
"**/.yarn/**",
|
|
4218
|
+
"**/coverage/**",
|
|
4219
|
+
"**/.next/**"
|
|
4220
|
+
];
|
|
4221
|
+
var EXCLUDED_DIR_MATCHERS = EXCLUDE_PATTERNS.map(
|
|
4222
|
+
(pattern) => import_micromatch.default.matcher(pattern, { dot: true })
|
|
4223
|
+
);
|
|
4224
|
+
|
|
4225
|
+
// src/collectors/userSpec/files.ts
|
|
4226
|
+
var USER_SPEC_TEXT_MAX_LENGTH = 100 * 1024;
|
|
4227
|
+
|
|
4228
|
+
// src/collectors/userSpec/layout.ts
|
|
4229
|
+
var RUNNER_LAYOUT = {
|
|
4230
|
+
claude: {
|
|
4231
|
+
shared: {
|
|
4232
|
+
skillRoots: [".claude/skills"],
|
|
4233
|
+
dirs: [
|
|
4234
|
+
{ dir: ".claude/agents", kind: "SUBAGENT", extensions: [".md"] },
|
|
4235
|
+
{ dir: ".claude/commands", kind: "COMMAND", extensions: [".md"] },
|
|
4236
|
+
{ dir: ".claude/rules", kind: "RULE", extensions: [".mdc", ".md"] }
|
|
4237
|
+
],
|
|
4238
|
+
// Claude's memory walk runs to the filesystem root, so a `~/CLAUDE.md`
|
|
4239
|
+
// covering every tree under home is in context and no project anchor
|
|
4240
|
+
// collects it (the parent walk stops before home).
|
|
4241
|
+
memory: [["CLAUDE.md"], ["CLAUDE.local.md"], [".claude/CLAUDE.md"]],
|
|
4242
|
+
// `remote-settings.json` is deliberately absent: it is the cached
|
|
4243
|
+
// server-managed payload, so it belongs to `managed` (which probes and
|
|
4244
|
+
// parses it) rather than to the operator's own settings.
|
|
4245
|
+
settings: [".claude/settings.json", ".claude/settings.local.json", ".claude/hooks.json"]
|
|
4246
|
+
},
|
|
4247
|
+
// The only field where the two scopes name different files rather than one
|
|
4248
|
+
// scope adding to the other: user MCP servers live in `~/.claude.json`,
|
|
4249
|
+
// project ones in a checked-in `.mcp.json` at the tree root.
|
|
4250
|
+
homeOnly: { mcpJson: [".claude.json"], plugins: "claude", managed: "claude" },
|
|
4251
|
+
projectOnly: { mcpJson: [".mcp.json", "mcp.json"] }
|
|
4252
|
+
},
|
|
4253
|
+
cursor: {
|
|
4254
|
+
shared: {
|
|
4255
|
+
skillRoots: [".cursor/skills"],
|
|
4256
|
+
dirs: [
|
|
4257
|
+
{ dir: ".cursor/agents", kind: "SUBAGENT", extensions: [".md"] },
|
|
4258
|
+
{ dir: ".cursor/commands", kind: "COMMAND", extensions: [".md"] },
|
|
4259
|
+
{ dir: ".cursor/rules", kind: "RULE", extensions: [".mdc", ".md"] }
|
|
4260
|
+
],
|
|
4261
|
+
memory: [["AGENTS.md"]],
|
|
4262
|
+
// Dedicated hooks file plus sandbox / permissions posture. CLI permissions
|
|
4263
|
+
// live in `cli-config.json` at home and `cli.json` at a project anchor —
|
|
4264
|
+
// see the scope deltas; Cursor never reads `cli-config.json` at project
|
|
4265
|
+
// scope.
|
|
4266
|
+
settings: [".cursor/hooks.json", ".cursor/sandbox.json", ".cursor/permissions.json"],
|
|
4267
|
+
mcpJson: [".cursor/mcp.json"]
|
|
4268
|
+
},
|
|
4269
|
+
// `skills-cursor` is the IDE-managed product-internal skills dir and never
|
|
4270
|
+
// appears in a repo; `.cursor/AGENTS.md` is a home-only memory location.
|
|
4271
|
+
homeOnly: {
|
|
4272
|
+
skillRoots: [".cursor/skills-cursor"],
|
|
4273
|
+
memory: [[".cursor/AGENTS.md"]],
|
|
4274
|
+
settings: [".cursor/cli-config.json"],
|
|
4275
|
+
plugins: "cursor",
|
|
4276
|
+
managed: "cursor"
|
|
4277
|
+
},
|
|
4278
|
+
projectOnly: { skillRoots: [".agents/skills"], settings: [".cursor/cli.json"] }
|
|
4279
|
+
},
|
|
4280
|
+
codex: {
|
|
4281
|
+
shared: {
|
|
4282
|
+
skillRoots: [".agents/skills", ".codex/skills"],
|
|
4283
|
+
dirs: [
|
|
4284
|
+
{ dir: ".codex/agents", kind: "SUBAGENT", extensions: [".toml", ".md"] },
|
|
4285
|
+
{ dir: ".codex/prompts", kind: "COMMAND", extensions: [".md"] },
|
|
4286
|
+
{ dir: ".codex/rules", kind: "RULE", extensions: [".md", ".rules"] }
|
|
4287
|
+
],
|
|
4288
|
+
memory: [["AGENTS.override.md", "AGENTS.md"]],
|
|
4289
|
+
// `managed_config.toml` is deliberately absent: it carries org defaults,
|
|
4290
|
+
// so it is probed by `managed` rather than counted as user settings.
|
|
4291
|
+
settings: [".codex/hooks.json", ".codex/config.toml"],
|
|
4292
|
+
mcpToml: [".codex/config.toml"]
|
|
4293
|
+
},
|
|
4294
|
+
homeOnly: { memory: [[".codex/AGENTS.override.md", ".codex/AGENTS.md"]], managed: "codex" }
|
|
4295
|
+
},
|
|
4296
|
+
// GitHub Copilot (CLI + VS Code). Mirrors REPO_GITHUB_COPILOT in
|
|
4297
|
+
// common/platform-component-ownership: project surfaces under `.github/`,
|
|
4298
|
+
// user ones under `~/.copilot/`. `dirs` cannot differ by scope, so both trees
|
|
4299
|
+
// are listed; the one that does not apply at a scope simply never exists.
|
|
4300
|
+
// `.github/hooks/*.json` is a directory of hook files, which `settings` (a
|
|
4301
|
+
// file list) cannot express — left for a later pass, like `plugins` / `managed`.
|
|
4302
|
+
//
|
|
4303
|
+
// Copilot also reads other runners' files: `.claude/skills` and
|
|
4304
|
+
// `.agents/skills` (Copilot CLI, and VS Code local sessions, which also read
|
|
4305
|
+
// `~/.claude/skills`), plus `AGENTS.md`, `CLAUDE.md` and `.claude/CLAUDE.md`
|
|
4306
|
+
// in the repo. Listing them here is what lets a Copilot-only machine report
|
|
4307
|
+
// them; `local-spec-owner.ts` attributes them to Copilot as well.
|
|
4308
|
+
// Sources: GitHub "Creating agent skills" and "Adding custom instructions"
|
|
4309
|
+
// for Copilot CLI, and VS Code "Agent skills" and "MCP servers".
|
|
4310
|
+
copilot: {
|
|
4311
|
+
shared: {
|
|
4312
|
+
skillRoots: [".claude/skills", ".agents/skills"],
|
|
4313
|
+
dirs: [
|
|
4314
|
+
{ dir: ".github/agents", kind: "SUBAGENT", extensions: [".md"] },
|
|
4315
|
+
// Copilot prompt files are `<name>.prompt.md`, run as `/<name>`.
|
|
4316
|
+
{ dir: ".github/prompts", kind: "COMMAND", extensions: [".prompt.md"] },
|
|
4317
|
+
// Copilot only loads `<name>.instructions.md` here; repo-syncer names the rule `<name>`.
|
|
4318
|
+
{ dir: ".github/instructions", kind: "RULE", extensions: [".instructions.md"] },
|
|
4319
|
+
{ dir: ".copilot/agents", kind: "SUBAGENT", extensions: [".md"] },
|
|
4320
|
+
// User-level instruction files (`~/.copilot/instructions/**`).
|
|
4321
|
+
{ dir: ".copilot/instructions", kind: "RULE", extensions: [".instructions.md"] }
|
|
4322
|
+
],
|
|
4323
|
+
memory: [],
|
|
4324
|
+
settings: []
|
|
4325
|
+
},
|
|
4326
|
+
homeOnly: {
|
|
4327
|
+
skillRoots: [".copilot/skills"],
|
|
4328
|
+
memory: [[".copilot/copilot-instructions.md"]],
|
|
4329
|
+
settings: [".copilot/config.json"],
|
|
4330
|
+
mcpJson: [".copilot/mcp-config.json"]
|
|
4331
|
+
},
|
|
4332
|
+
projectOnly: {
|
|
4333
|
+
skillRoots: [".github/skills"],
|
|
4334
|
+
memory: [
|
|
4335
|
+
[".github/copilot-instructions.md"],
|
|
4336
|
+
["AGENTS.md"],
|
|
4337
|
+
["CLAUDE.md"],
|
|
4338
|
+
[".claude/CLAUDE.md"]
|
|
4339
|
+
],
|
|
4340
|
+
settings: [".github/copilot/settings.json"],
|
|
4341
|
+
// VS Code's workspace file keys servers under `servers`, not `mcpServers`.
|
|
4342
|
+
mcpJson: [".github/mcp.json", ".vscode/mcp.json"]
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4345
|
+
};
|
|
4346
|
+
function concatOptional(shared, delta) {
|
|
4347
|
+
if (!shared && !delta) {
|
|
4348
|
+
return void 0;
|
|
4349
|
+
}
|
|
4350
|
+
return [...shared ?? [], ...delta ?? []];
|
|
4351
|
+
}
|
|
4352
|
+
function layoutForScope(runner, delta = {}) {
|
|
4353
|
+
const { shared } = runner;
|
|
4354
|
+
return {
|
|
4355
|
+
skillRoots: [...shared.skillRoots, ...delta.skillRoots ?? []],
|
|
4356
|
+
dirs: shared.dirs,
|
|
4357
|
+
memory: [...shared.memory, ...delta.memory ?? []],
|
|
4358
|
+
settings: [...shared.settings, ...delta.settings ?? []],
|
|
4359
|
+
mcpJson: concatOptional(shared.mcpJson, delta.mcpJson),
|
|
4360
|
+
mcpToml: concatOptional(shared.mcpToml, delta.mcpToml),
|
|
4361
|
+
plugins: delta.plugins ?? shared.plugins,
|
|
4362
|
+
managed: delta.managed ?? shared.managed
|
|
4363
|
+
};
|
|
4364
|
+
}
|
|
4365
|
+
function layoutsForScope(scope) {
|
|
4366
|
+
return Object.fromEntries(
|
|
4367
|
+
Object.entries(RUNNER_LAYOUT).map(([runner, entry]) => [
|
|
4368
|
+
runner,
|
|
4369
|
+
layoutForScope(entry, entry[scope])
|
|
4370
|
+
])
|
|
4371
|
+
);
|
|
4372
|
+
}
|
|
4373
|
+
var PLATFORM_USER_LAYOUT = layoutsForScope("homeOnly");
|
|
4374
|
+
var PLATFORM_PROJECT_LAYOUT = layoutsForScope("projectOnly");
|
|
4375
|
+
function uniqueRels(rels) {
|
|
4376
|
+
return [...new Set(rels)];
|
|
4377
|
+
}
|
|
4378
|
+
function userScopePathsFromLayouts(layouts) {
|
|
4379
|
+
const skills = [];
|
|
4380
|
+
const subagents = [];
|
|
4381
|
+
const commands = [];
|
|
4382
|
+
const rules = [];
|
|
4383
|
+
const memory = [];
|
|
4384
|
+
const settings = [];
|
|
4385
|
+
const mcp = [];
|
|
4386
|
+
for (const layout of layouts) {
|
|
4387
|
+
skills.push(...layout.skillRoots);
|
|
4388
|
+
for (const entry of layout.dirs) {
|
|
4389
|
+
if (entry.kind === "SUBAGENT") {
|
|
4390
|
+
subagents.push(entry.dir);
|
|
4391
|
+
} else if (entry.kind === "COMMAND") {
|
|
4392
|
+
commands.push(entry.dir);
|
|
4393
|
+
} else {
|
|
4394
|
+
rules.push(entry.dir);
|
|
4395
|
+
}
|
|
4396
|
+
}
|
|
4397
|
+
memory.push(...layout.memory.flat());
|
|
4398
|
+
settings.push(...layout.settings);
|
|
4399
|
+
mcp.push(...layout.mcpJson ?? [], ...layout.mcpToml ?? []);
|
|
4400
|
+
}
|
|
4401
|
+
return {
|
|
4402
|
+
skills: uniqueRels(skills),
|
|
4403
|
+
subagents: uniqueRels(subagents),
|
|
4404
|
+
commands: uniqueRels(commands),
|
|
4405
|
+
rules: uniqueRels(rules),
|
|
4406
|
+
memory: uniqueRels(memory),
|
|
4407
|
+
settings: uniqueRels(settings),
|
|
4408
|
+
mcp: uniqueRels(mcp)
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
var USER_SCOPE_PATHS = userScopePathsFromLayouts(
|
|
4412
|
+
Object.values(PLATFORM_USER_LAYOUT)
|
|
4413
|
+
);
|
|
4414
|
+
|
|
4415
|
+
// src/collectors/userSpec/mcp-attributes.ts
|
|
4416
|
+
var import_composition_identity = __toESM(require_dist(), 1);
|
|
4417
|
+
var NPX_PACKAGE_ATTRIBUTE_KEYS = [
|
|
4418
|
+
"package_name",
|
|
4419
|
+
"package_spec",
|
|
4420
|
+
"package_version",
|
|
4421
|
+
"package_version_source"
|
|
4422
|
+
];
|
|
4423
|
+
var TOOL_LIST_RAW_KEYS = [
|
|
4424
|
+
{ raw: "tools", attr: "tools" },
|
|
4425
|
+
{ raw: "autoApprove", attr: "auto_approve" },
|
|
4426
|
+
{ raw: "auto_approve", attr: "auto_approve" },
|
|
4427
|
+
{ raw: "alwaysAllow", attr: "always_allow" },
|
|
4428
|
+
{ raw: "always_allow", attr: "always_allow" },
|
|
4429
|
+
{ raw: "enabledTools", attr: "enabled_tools" },
|
|
4430
|
+
{ raw: "enabled_tools", attr: "enabled_tools" },
|
|
4431
|
+
{ raw: "disabledTools", attr: "disabled_tools" },
|
|
4432
|
+
{ raw: "disabled_tools", attr: "disabled_tools" }
|
|
4433
|
+
];
|
|
4434
|
+
var TOOL_LIST_ATTRS = new Set(TOOL_LIST_RAW_KEYS.map((entry) => entry.attr));
|
|
4435
|
+
var ENABLED_RAW_KEYS = ["enabled", "disabled"];
|
|
4436
|
+
var SCALAR_RAW_KEYS = [
|
|
4437
|
+
"serverUrl",
|
|
4438
|
+
"auth",
|
|
4439
|
+
"bearer_token_env_var",
|
|
4440
|
+
"default_tools_approval_mode",
|
|
4441
|
+
"defaultToolsApprovalMode",
|
|
4442
|
+
"env_vars",
|
|
4443
|
+
"env_http_headers",
|
|
4444
|
+
"http_headers"
|
|
4445
|
+
];
|
|
4446
|
+
var MCP_SERVER_READ_KEYS = /* @__PURE__ */ new Set([
|
|
4447
|
+
"type",
|
|
4448
|
+
"command",
|
|
4449
|
+
"url",
|
|
4450
|
+
"args",
|
|
4451
|
+
"env",
|
|
4452
|
+
"envVars",
|
|
4453
|
+
"headers",
|
|
4454
|
+
...ENABLED_RAW_KEYS,
|
|
4455
|
+
...SCALAR_RAW_KEYS,
|
|
4456
|
+
...TOOL_LIST_RAW_KEYS.map((entry) => entry.raw)
|
|
4457
|
+
]);
|
|
4458
|
+
var DERIVED_KEYS = /* @__PURE__ */ new Set([
|
|
4459
|
+
"transport",
|
|
4460
|
+
"command_or_url",
|
|
4461
|
+
"args",
|
|
4462
|
+
"env_var_names",
|
|
4463
|
+
"headers_present",
|
|
4464
|
+
"auth",
|
|
4465
|
+
"bearer_token_env_var",
|
|
4466
|
+
"default_tools_approval_mode",
|
|
4467
|
+
"env_http_header_names",
|
|
4468
|
+
...NPX_PACKAGE_ATTRIBUTE_KEYS,
|
|
4469
|
+
...TOOL_LIST_ATTRS,
|
|
4470
|
+
...[...TOOL_LIST_ATTRS].map((attr) => `${attr}_truncated`)
|
|
4471
|
+
]);
|
|
4472
|
+
|
|
4473
|
+
// src/collectors/permission-key.ts
|
|
4474
|
+
var PATH_PLACEHOLDER = "<path>";
|
|
4475
|
+
var PATH_CONTINUATION_PATTERN = new RegExp(
|
|
4476
|
+
`${PATH_PLACEHOLDER}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,
|
|
4477
|
+
"g"
|
|
4478
|
+
);
|
|
4479
|
+
|
|
4480
|
+
// src/collectors/userSpec/settings.ts
|
|
4481
|
+
var SETTINGS_JSON_MAX_BYTES = 16 * 1024;
|
|
4482
|
+
|
|
4483
|
+
// src/collectors/userSpec/mcp-config-file.ts
|
|
4484
|
+
var AUTH_TABLE = {
|
|
4485
|
+
CLIENT_ID: "keep",
|
|
4486
|
+
CLIENT_SECRET: "secret",
|
|
4487
|
+
scopes: "string_list",
|
|
4488
|
+
redirectPort: "keep"
|
|
4489
|
+
// source-only
|
|
4490
|
+
};
|
|
4491
|
+
var OAUTH_TABLE = {
|
|
4492
|
+
clientId: "keep",
|
|
4493
|
+
client_id: "keep",
|
|
4494
|
+
clientSecret: "secret",
|
|
4495
|
+
client_secret: "secret",
|
|
4496
|
+
callbackPort: "keep",
|
|
4497
|
+
callback_port: "keep",
|
|
4498
|
+
// source-only
|
|
4499
|
+
callback_url: "url",
|
|
4500
|
+
// source-only
|
|
4501
|
+
redirectUri: "url",
|
|
4502
|
+
// source-only
|
|
4503
|
+
redirect_uri: "url",
|
|
4504
|
+
// source-only
|
|
4505
|
+
authServerMetadataUrl: "url",
|
|
4506
|
+
auth_server_metadata_url: "url",
|
|
4507
|
+
// source-only
|
|
4508
|
+
authorizationUrl: "url",
|
|
4509
|
+
tokenUrl: "url",
|
|
4510
|
+
issuer: "url",
|
|
4511
|
+
// source-only
|
|
4512
|
+
registrationUrl: "url",
|
|
4513
|
+
// source-only
|
|
4514
|
+
clientMetadataUrl: "url",
|
|
4515
|
+
// source-only
|
|
4516
|
+
scopes: { by: { string: "keep", array: "string_list" } },
|
|
4517
|
+
scope: "keep",
|
|
4518
|
+
// source-only
|
|
4519
|
+
oauthScopes: "string_list",
|
|
4520
|
+
// source-only
|
|
4521
|
+
audiences: "string_list",
|
|
4522
|
+
enabled: "keep",
|
|
4523
|
+
allowPrivateNetwork: "keep",
|
|
4524
|
+
// source-only
|
|
4525
|
+
authorizationResponseIssParameterSupported: "keep",
|
|
4526
|
+
// source-only
|
|
4527
|
+
tokenParamName: "keep"
|
|
4528
|
+
};
|
|
4529
|
+
var MCP_CONFIG_SANDBOX_TABLE = {
|
|
4530
|
+
filesystem: {
|
|
4531
|
+
object: {
|
|
4532
|
+
allowWrite: "path",
|
|
4533
|
+
denyRead: "path",
|
|
4534
|
+
denyWrite: "path"
|
|
4535
|
+
}
|
|
4536
|
+
},
|
|
4537
|
+
network: {
|
|
4538
|
+
object: {
|
|
4539
|
+
allowedDomains: "string_list",
|
|
4540
|
+
deniedDomains: "string_list"
|
|
4541
|
+
}
|
|
4542
|
+
}
|
|
4543
|
+
};
|
|
4544
|
+
var DEV_TABLE = {
|
|
4545
|
+
watch: "path",
|
|
4546
|
+
debug: { object: { type: "keep", debugpyPath: "path" } }
|
|
4547
|
+
};
|
|
4548
|
+
var REQUEST_OPTIONS_TABLE = {
|
|
4549
|
+
headers: "secret_map",
|
|
4550
|
+
proxy: "url",
|
|
4551
|
+
caBundlePath: "path",
|
|
4552
|
+
timeout: "keep",
|
|
4553
|
+
verifySsl: "keep",
|
|
4554
|
+
noProxy: "string_list",
|
|
4555
|
+
extraBodyProperties: "omit",
|
|
4556
|
+
clientCertificate: { object: { cert: "omit", key: "omit", passphrase: "secret" } }
|
|
4557
|
+
};
|
|
4558
|
+
var TIMEOUT_TABLE = { startup: "keep", catalog: "keep", execution: "keep" };
|
|
4559
|
+
var CODEX_TOOL_TABLE = { approval_mode: "keep", output_token_limit: "keep" };
|
|
4560
|
+
var TRANSPORT_TABLE = {
|
|
4561
|
+
type: "transport_type",
|
|
4562
|
+
command: "command",
|
|
4563
|
+
args: "args",
|
|
4564
|
+
cwd: "path",
|
|
4565
|
+
env: "secret_map",
|
|
4566
|
+
url: "url",
|
|
4567
|
+
headers: "secret_map"
|
|
4568
|
+
};
|
|
4569
|
+
var TOOL_LIST_ALIASES = Object.fromEntries(
|
|
4570
|
+
TOOL_LIST_RAW_KEYS.map(({ raw }) => [raw, "tool_list"])
|
|
4571
|
+
);
|
|
4572
|
+
var MCP_CONFIG_SERVER_KEY_TREATMENT = {
|
|
4573
|
+
...TOOL_LIST_ALIASES,
|
|
4574
|
+
// Identity / transport / enablement
|
|
4575
|
+
type: "transport_type",
|
|
4576
|
+
transportType: "keep",
|
|
4577
|
+
// source-only
|
|
4578
|
+
transport: { by: { string: "keep", object: { object: TRANSPORT_TABLE } } },
|
|
4579
|
+
disabled: "keep",
|
|
4580
|
+
enabled: "keep",
|
|
4581
|
+
required: "keep",
|
|
4582
|
+
remote: "keep",
|
|
4583
|
+
// source-only
|
|
4584
|
+
remoteConfigured: "keep",
|
|
4585
|
+
// source-only
|
|
4586
|
+
source: "keep",
|
|
4587
|
+
// source-only
|
|
4588
|
+
version: "keep",
|
|
4589
|
+
gallery: { by: { boolean: "keep", string: "url" } },
|
|
4590
|
+
description: "omit",
|
|
4591
|
+
name: "keep",
|
|
4592
|
+
serverName: "keep",
|
|
4593
|
+
// source-only
|
|
4594
|
+
faviconUrl: "url",
|
|
4595
|
+
// source-only
|
|
4596
|
+
sourceFile: "path",
|
|
4597
|
+
sourceSlug: "keep",
|
|
4598
|
+
environment_id: "keep",
|
|
4599
|
+
protocol: "keep",
|
|
4600
|
+
pool: "keep",
|
|
4601
|
+
codemode: "keep",
|
|
4602
|
+
trust: "keep",
|
|
4603
|
+
alwaysLoad: "keep",
|
|
4604
|
+
deferTools: "keep",
|
|
4605
|
+
// source-only
|
|
4606
|
+
supports_parallel_tool_calls: "keep",
|
|
4607
|
+
tool_input_schema_max_bytes: "keep",
|
|
4608
|
+
startup_readiness: "keep",
|
|
4609
|
+
extension: "omit",
|
|
4610
|
+
// source-only
|
|
4611
|
+
metadata: "omit",
|
|
4612
|
+
// source-only
|
|
4613
|
+
settings: "omit",
|
|
4614
|
+
// source-only
|
|
4615
|
+
// stdio / process
|
|
4616
|
+
command: {
|
|
4617
|
+
by: {
|
|
4618
|
+
string: "command",
|
|
4619
|
+
array: "args",
|
|
4620
|
+
// Zed legacy `command: { path, args, env }`.
|
|
4621
|
+
object: { object: { path: "command", args: "args", env: "secret_map" } }
|
|
4622
|
+
}
|
|
4623
|
+
},
|
|
4624
|
+
args: "args",
|
|
4625
|
+
env: "secret_map",
|
|
4626
|
+
environment: "secret_map",
|
|
4627
|
+
env_vars: {
|
|
4628
|
+
list: {
|
|
4629
|
+
by: { string: "env_name", object: { object: { name: "env_name", source: "keep" } } }
|
|
4630
|
+
}
|
|
4631
|
+
},
|
|
4632
|
+
envVars: "secret_map",
|
|
4633
|
+
envFile: "path",
|
|
4634
|
+
cwd: "path",
|
|
4635
|
+
watchPaths: "path",
|
|
4636
|
+
dev: { object: DEV_TABLE },
|
|
4637
|
+
sandboxEnabled: "keep",
|
|
4638
|
+
sandbox: { object: MCP_CONFIG_SANDBOX_TABLE },
|
|
4639
|
+
// Remote / HTTP
|
|
4640
|
+
url: "url",
|
|
4641
|
+
serverUrl: "url",
|
|
4642
|
+
httpUrl: "url",
|
|
4643
|
+
tcp: "url",
|
|
4644
|
+
// source-only
|
|
4645
|
+
headers: "secret_map",
|
|
4646
|
+
http_headers: "secret_map",
|
|
4647
|
+
env_http_headers: "env_name_map",
|
|
4648
|
+
bearer_token_env_var: "env_name",
|
|
4649
|
+
headersHelper: "helper_command",
|
|
4650
|
+
http_headers_helper: "helper_command",
|
|
4651
|
+
apiKey: "secret",
|
|
4652
|
+
// source-only
|
|
4653
|
+
requestOptions: { object: REQUEST_OPTIONS_TABLE },
|
|
4654
|
+
// source-only
|
|
4655
|
+
auth: { by: { string: "mode", object: { object: AUTH_TABLE } } },
|
|
4656
|
+
oauth: { by: { boolean: "keep", object: { object: OAUTH_TABLE } } },
|
|
4657
|
+
oauthClientId: "keep",
|
|
4658
|
+
oauthClientSecret: "secret",
|
|
4659
|
+
oauthResource: "url",
|
|
4660
|
+
oauth_resource: "url",
|
|
4661
|
+
oauthScopes: "string_list",
|
|
4662
|
+
scopes: { by: { string: "keep", array: "string_list" } },
|
|
4663
|
+
oauthPublicClient: "keep",
|
|
4664
|
+
// source-only
|
|
4665
|
+
oauthGrantType: "keep",
|
|
4666
|
+
// source-only
|
|
4667
|
+
authProviderType: "keep",
|
|
4668
|
+
targetAudience: "keep",
|
|
4669
|
+
targetServiceAccount: "keep",
|
|
4670
|
+
// Tool filtering / approval
|
|
4671
|
+
tools: {
|
|
4672
|
+
by: {
|
|
4673
|
+
array: "tool_list",
|
|
4674
|
+
boolean: "tool_list",
|
|
4675
|
+
string: "tool_list",
|
|
4676
|
+
object: { map: { object: CODEX_TOOL_TABLE } }
|
|
4677
|
+
}
|
|
4678
|
+
},
|
|
4679
|
+
includeTools: "tool_list",
|
|
4680
|
+
excludeTools: "tool_list",
|
|
4681
|
+
omit_tools_from: "tool_list",
|
|
4682
|
+
default_tools_approval_mode: "keep",
|
|
4683
|
+
defaultToolsApprovalMode: "keep",
|
|
4684
|
+
// Timeouts
|
|
4685
|
+
timeout: { by: { number: "keep", object: { object: TIMEOUT_TABLE } } },
|
|
4686
|
+
startup_timeout_sec: "keep",
|
|
4687
|
+
startup_timeout_ms: "keep",
|
|
4688
|
+
tool_timeout_sec: "keep",
|
|
4689
|
+
connectionTimeout: "keep"
|
|
4690
|
+
// source-only
|
|
4691
|
+
};
|
|
4692
|
+
|
|
4693
|
+
// src/collectors/userSpec/npx-package.ts
|
|
4694
|
+
var import_composition_identity4 = __toESM(require_dist(), 1);
|
|
4695
|
+
|
|
4696
|
+
// src/collectors/userSpec/local-bin-package.ts
|
|
4697
|
+
var import_composition_identity3 = __toESM(require_dist(), 1);
|
|
4698
|
+
|
|
4699
|
+
// src/collectors/userSpec/install-state.ts
|
|
4700
|
+
import { closeSync, constants, fstatSync, openSync, readSync, statSync } from "node:fs";
|
|
4701
|
+
var import_composition_identity2 = __toESM(require_dist(), 1);
|
|
4702
|
+
var INSTALL_STATE_MAX_BYTES = 16 * 1024 * 1024;
|
|
4703
|
+
var OPEN_FLAGS = constants.O_RDONLY | (process.platform === "win32" ? 0 : constants.O_NONBLOCK);
|
|
4704
|
+
|
|
4705
|
+
// src/collectors/userSpec/local-bin-package.ts
|
|
4706
|
+
var MANIFEST_MAX_BYTES = 1024 * 1024;
|
|
4707
|
+
|
|
4708
|
+
// src/collectors/userSpec/mcp.ts
|
|
4709
|
+
var MCP_CONFIG_TEXT_MAX_BYTES = 64 * 1024;
|
|
4710
|
+
|
|
4711
|
+
// src/collectors/userSpec/budget.ts
|
|
4712
|
+
var USER_SPEC_MAX_BYTES = 2 * 1024 * 1024;
|
|
4713
|
+
|
|
4714
|
+
// src/shared/git-config.ts
|
|
4715
|
+
var GIT_CONFIG_CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
4716
|
+
|
|
56
4717
|
// src/config/hook-config.ts
|
|
57
4718
|
var HOOK_CONFIG_FETCHED_AT_BUMP_MS = 24 * 60 * 60 * 1e3;
|
|
58
4719
|
var HOOK_CONFIG_FILE_MAX_BYTES2 = 1024 * 1024;
|
|
@@ -120,6 +4781,16 @@ function desiredCodexHookGroups(command) {
|
|
|
120
4781
|
SubagentStop: [commandHook()]
|
|
121
4782
|
};
|
|
122
4783
|
}
|
|
4784
|
+
var COPILOT_WIRED_HOOK_EVENTS = [
|
|
4785
|
+
"SessionStart",
|
|
4786
|
+
"UserPromptSubmit",
|
|
4787
|
+
"PreToolUse",
|
|
4788
|
+
"PostToolUse",
|
|
4789
|
+
"SubagentStart",
|
|
4790
|
+
"SubagentStop",
|
|
4791
|
+
"Stop",
|
|
4792
|
+
"SessionEnd"
|
|
4793
|
+
];
|
|
123
4794
|
var CURSOR_WIRED_HOOK_EVENTS = [
|
|
124
4795
|
"sessionStart",
|
|
125
4796
|
"beforeSubmitPrompt",
|
|
@@ -137,6 +4808,8 @@ var CURSOR_WIRED_HOOK_EVENTS = [
|
|
|
137
4808
|
// src/install/plugin-hooks.ts
|
|
138
4809
|
var PLUGIN_HOOK_ENTRY = "dist/launcher.mjs";
|
|
139
4810
|
var PLUGIN_PACKAGE_FILE = "package.json";
|
|
4811
|
+
var PLUGIN_COLLECTOR_URL_MCP_SCRIPT = "scripts/collector-url-mcp.mjs";
|
|
4812
|
+
var PLUGIN_RUN_NODE_SCRIPT = "scripts/run-node.cmd";
|
|
140
4813
|
function pluginLauncherPosixCommand(runner) {
|
|
141
4814
|
return `node "\${${PLUGIN_ROOT_VARIABLE[runner]}}/${PLUGIN_HOOK_ENTRY}" --runner ${runner} ; exit 0`;
|
|
142
4815
|
}
|
|
@@ -145,7 +4818,7 @@ function claudePluginCommand() {
|
|
|
145
4818
|
}
|
|
146
4819
|
function cursorPluginCommand() {
|
|
147
4820
|
const root = `\${${PLUGIN_ROOT_VARIABLE.cursor}}`;
|
|
148
|
-
return `"${root}
|
|
4821
|
+
return `"${root}/${PLUGIN_RUN_NODE_SCRIPT}" "${root}/${PLUGIN_HOOK_ENTRY}" --runner cursor ; exit 0`;
|
|
149
4822
|
}
|
|
150
4823
|
function pluginLauncherCodexWindowsCommand() {
|
|
151
4824
|
const variable = PLUGIN_ROOT_VARIABLE.codex;
|
|
@@ -157,6 +4830,16 @@ function pluginLauncherCodexCommand() {
|
|
|
157
4830
|
commandWindows: pluginLauncherCodexWindowsCommand()
|
|
158
4831
|
};
|
|
159
4832
|
}
|
|
4833
|
+
function toWindowsPath(relativePath) {
|
|
4834
|
+
return relativePath.replaceAll("/", "\\");
|
|
4835
|
+
}
|
|
4836
|
+
function copilotPluginCommand() {
|
|
4837
|
+
const variable = PLUGIN_ROOT_VARIABLE.copilot;
|
|
4838
|
+
return {
|
|
4839
|
+
posix: pluginLauncherPosixCommand("copilot"),
|
|
4840
|
+
powershell: `node "\${${variable}}\\${toWindowsPath(PLUGIN_HOOK_ENTRY)}" --runner copilot; exit 0`
|
|
4841
|
+
};
|
|
4842
|
+
}
|
|
160
4843
|
var CLAUDE_HOOK_TIMEOUT_SECONDS = 5;
|
|
161
4844
|
var CLAUDE_SESSION_START_TIMEOUT_SECONDS = 10;
|
|
162
4845
|
function buildClaudePluginHooks(command) {
|
|
@@ -190,6 +4873,21 @@ function buildCursorPluginHooks(command) {
|
|
|
190
4873
|
}
|
|
191
4874
|
return { version: 1, hooks };
|
|
192
4875
|
}
|
|
4876
|
+
function buildCopilotPluginHooks(command) {
|
|
4877
|
+
const hooks = {};
|
|
4878
|
+
for (const eventName of COPILOT_WIRED_HOOK_EVENTS) {
|
|
4879
|
+
const timeout = isSessionStartEvent(eventName) ? CLAUDE_SESSION_START_TIMEOUT_SECONDS : CLAUDE_HOOK_TIMEOUT_SECONDS;
|
|
4880
|
+
hooks[eventName] = [
|
|
4881
|
+
{
|
|
4882
|
+
type: "command",
|
|
4883
|
+
bash: commandForEvent(eventName, command.posix),
|
|
4884
|
+
powershell: commandForEvent(eventName, command.powershell),
|
|
4885
|
+
timeoutSec: timeout
|
|
4886
|
+
}
|
|
4887
|
+
];
|
|
4888
|
+
}
|
|
4889
|
+
return { version: 1, hooks };
|
|
4890
|
+
}
|
|
193
4891
|
function buildCodexPluginHooks(command) {
|
|
194
4892
|
return { hooks: desiredCodexHookGroups(command) };
|
|
195
4893
|
}
|
|
@@ -198,13 +4896,15 @@ var MARKETPLACE_NAME = "ev-ai-marketplace";
|
|
|
198
4896
|
var MARKETPLACE_PLUGIN_DIRS = {
|
|
199
4897
|
claude: "plugins/claude",
|
|
200
4898
|
cursor: "plugins/cursor",
|
|
201
|
-
codex: "plugins/codex"
|
|
4899
|
+
codex: "plugins/codex",
|
|
4900
|
+
copilot: "plugins/copilot"
|
|
202
4901
|
};
|
|
203
4902
|
function marketplacePluginHookPaths(marketplaceRoot) {
|
|
204
4903
|
return {
|
|
205
4904
|
claude: join(marketplaceRoot, MARKETPLACE_PLUGIN_DIRS.claude, "hooks/hooks.json"),
|
|
206
4905
|
cursor: join(marketplaceRoot, MARKETPLACE_PLUGIN_DIRS.cursor, "hooks/hooks.json"),
|
|
207
|
-
codex: join(marketplaceRoot, MARKETPLACE_PLUGIN_DIRS.codex, "hooks/hooks.json")
|
|
4906
|
+
codex: join(marketplaceRoot, MARKETPLACE_PLUGIN_DIRS.codex, "hooks/hooks.json"),
|
|
4907
|
+
copilot: join(marketplaceRoot, MARKETPLACE_PLUGIN_DIRS.copilot, "hooks/hooks.json")
|
|
208
4908
|
};
|
|
209
4909
|
}
|
|
210
4910
|
var PLUGIN_PAYLOAD_FILES = [
|
|
@@ -222,6 +4922,7 @@ function writeMarketplacePluginHooks(marketplaceRoot) {
|
|
|
222
4922
|
writeJson(paths.claude, buildClaudeMarketplacePluginHooks());
|
|
223
4923
|
writeJson(paths.cursor, buildCursorPluginHooks(cursorPluginCommand()));
|
|
224
4924
|
writeJson(paths.codex, buildCodexPluginHooks(pluginLauncherCodexCommand()));
|
|
4925
|
+
writeJson(paths.copilot, buildCopilotPluginHooks(copilotPluginCommand()));
|
|
225
4926
|
return paths;
|
|
226
4927
|
}
|
|
227
4928
|
function pluginPackageManifest(packageRoot) {
|
|
@@ -257,7 +4958,8 @@ function expectedMarketplacePluginHooks() {
|
|
|
257
4958
|
return {
|
|
258
4959
|
claude: buildClaudeMarketplacePluginHooks(),
|
|
259
4960
|
cursor: buildCursorPluginHooks(cursorPluginCommand()),
|
|
260
|
-
codex: buildCodexPluginHooks(pluginLauncherCodexCommand())
|
|
4961
|
+
codex: buildCodexPluginHooks(pluginLauncherCodexCommand()),
|
|
4962
|
+
copilot: buildCopilotPluginHooks(copilotPluginCommand())
|
|
261
4963
|
};
|
|
262
4964
|
}
|
|
263
4965
|
export {
|
|
@@ -266,14 +4968,18 @@ export {
|
|
|
266
4968
|
MARKETPLACE_NAME,
|
|
267
4969
|
MARKETPLACE_PLUGIN_DIRS,
|
|
268
4970
|
MARKETPLACE_PLUGIN_NAME,
|
|
4971
|
+
PLUGIN_COLLECTOR_URL_MCP_SCRIPT,
|
|
269
4972
|
PLUGIN_HOOK_ENTRY,
|
|
270
4973
|
PLUGIN_PACKAGE_FILE,
|
|
271
4974
|
PLUGIN_PAYLOAD_FILES,
|
|
4975
|
+
PLUGIN_RUN_NODE_SCRIPT,
|
|
272
4976
|
buildClaudeMarketplacePluginHooks,
|
|
273
4977
|
buildClaudePluginHooks,
|
|
274
4978
|
buildCodexPluginHooks,
|
|
4979
|
+
buildCopilotPluginHooks,
|
|
275
4980
|
buildCursorPluginHooks,
|
|
276
4981
|
claudePluginCommand,
|
|
4982
|
+
copilotPluginCommand,
|
|
277
4983
|
copyMarketplacePluginPayload,
|
|
278
4984
|
cursorPluginCommand,
|
|
279
4985
|
expectedMarketplacePluginHooks,
|