luckerr 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +267 -0
  2. package/README.zh-CN.md +237 -0
  3. package/dashboard/app.css +3022 -0
  4. package/dashboard/dist/app.js +30137 -0
  5. package/dashboard/dist/app.js.map +1 -0
  6. package/dashboard/dist/vendor-hljs.css +10 -0
  7. package/dashboard/dist/vendor-uplot.css +1 -0
  8. package/dashboard/index.html +19 -0
  9. package/data/deepseek-tokenizer.json.gz +0 -0
  10. package/dist/cli/acp-EOOAI4F5.js +712 -0
  11. package/dist/cli/acp-EOOAI4F5.js.map +1 -0
  12. package/dist/cli/chat-7J6GJXL2.js +51 -0
  13. package/dist/cli/chat-7J6GJXL2.js.map +1 -0
  14. package/dist/cli/chunk-2425HK6U.js +54 -0
  15. package/dist/cli/chunk-2425HK6U.js.map +1 -0
  16. package/dist/cli/chunk-25T6CVUP.js +172 -0
  17. package/dist/cli/chunk-25T6CVUP.js.map +1 -0
  18. package/dist/cli/chunk-2UQP6H6T.js +31 -0
  19. package/dist/cli/chunk-2UQP6H6T.js.map +1 -0
  20. package/dist/cli/chunk-56OAJILV.js +47 -0
  21. package/dist/cli/chunk-56OAJILV.js.map +1 -0
  22. package/dist/cli/chunk-5FTI4KXH.js +150 -0
  23. package/dist/cli/chunk-5FTI4KXH.js.map +1 -0
  24. package/dist/cli/chunk-5TWQD73O.js +2846 -0
  25. package/dist/cli/chunk-5TWQD73O.js.map +1 -0
  26. package/dist/cli/chunk-653BOCMK.js +40 -0
  27. package/dist/cli/chunk-653BOCMK.js.map +1 -0
  28. package/dist/cli/chunk-6ALJTWWQ.js +2663 -0
  29. package/dist/cli/chunk-6ALJTWWQ.js.map +1 -0
  30. package/dist/cli/chunk-6DRKA2IL.js +341 -0
  31. package/dist/cli/chunk-6DRKA2IL.js.map +1 -0
  32. package/dist/cli/chunk-6LV63NJV.js +634 -0
  33. package/dist/cli/chunk-6LV63NJV.js.map +1 -0
  34. package/dist/cli/chunk-74EX7SUH.js +25293 -0
  35. package/dist/cli/chunk-74EX7SUH.js.map +1 -0
  36. package/dist/cli/chunk-74U5RKTX.js +60611 -0
  37. package/dist/cli/chunk-74U5RKTX.js.map +1 -0
  38. package/dist/cli/chunk-ANJSUESV.js +143 -0
  39. package/dist/cli/chunk-ANJSUESV.js.map +1 -0
  40. package/dist/cli/chunk-DB2Z3DKZ.js +54 -0
  41. package/dist/cli/chunk-DB2Z3DKZ.js.map +1 -0
  42. package/dist/cli/chunk-DDIH3ZAA.js +400 -0
  43. package/dist/cli/chunk-DDIH3ZAA.js.map +1 -0
  44. package/dist/cli/chunk-ELN3Z3B2.js +621 -0
  45. package/dist/cli/chunk-ELN3Z3B2.js.map +1 -0
  46. package/dist/cli/chunk-F6BSQJGV.js +200 -0
  47. package/dist/cli/chunk-F6BSQJGV.js.map +1 -0
  48. package/dist/cli/chunk-FET2UAG5.js +246 -0
  49. package/dist/cli/chunk-FET2UAG5.js.map +1 -0
  50. package/dist/cli/chunk-FFJ342IJ.js +190 -0
  51. package/dist/cli/chunk-FFJ342IJ.js.map +1 -0
  52. package/dist/cli/chunk-GB3247B6.js +130 -0
  53. package/dist/cli/chunk-GB3247B6.js.map +1 -0
  54. package/dist/cli/chunk-HC2J4U3G.js +373 -0
  55. package/dist/cli/chunk-HC2J4U3G.js.map +1 -0
  56. package/dist/cli/chunk-HRUZAIHQ.js +42 -0
  57. package/dist/cli/chunk-HRUZAIHQ.js.map +1 -0
  58. package/dist/cli/chunk-J3ZJFUDL.js +308 -0
  59. package/dist/cli/chunk-J3ZJFUDL.js.map +1 -0
  60. package/dist/cli/chunk-J5XJHLWM.js +55 -0
  61. package/dist/cli/chunk-J5XJHLWM.js.map +1 -0
  62. package/dist/cli/chunk-JFGLMRZ6.js +160 -0
  63. package/dist/cli/chunk-JFGLMRZ6.js.map +1 -0
  64. package/dist/cli/chunk-JMBMLOBP.js +26 -0
  65. package/dist/cli/chunk-JMBMLOBP.js.map +1 -0
  66. package/dist/cli/chunk-JMWHXZEL.js +551 -0
  67. package/dist/cli/chunk-JMWHXZEL.js.map +1 -0
  68. package/dist/cli/chunk-KEQGPJBO.js +209 -0
  69. package/dist/cli/chunk-KEQGPJBO.js.map +1 -0
  70. package/dist/cli/chunk-M4K6U37F.js +232 -0
  71. package/dist/cli/chunk-M4K6U37F.js.map +1 -0
  72. package/dist/cli/chunk-MIJI2WMN.js +95 -0
  73. package/dist/cli/chunk-MIJI2WMN.js.map +1 -0
  74. package/dist/cli/chunk-MPAO3JNR.js +128 -0
  75. package/dist/cli/chunk-MPAO3JNR.js.map +1 -0
  76. package/dist/cli/chunk-PZOFBEDC.js +873 -0
  77. package/dist/cli/chunk-PZOFBEDC.js.map +1 -0
  78. package/dist/cli/chunk-RAILYQLN.js +46 -0
  79. package/dist/cli/chunk-RAILYQLN.js.map +1 -0
  80. package/dist/cli/chunk-RR35VQVT.js +90 -0
  81. package/dist/cli/chunk-RR35VQVT.js.map +1 -0
  82. package/dist/cli/chunk-RRA7VPW4.js +417 -0
  83. package/dist/cli/chunk-RRA7VPW4.js.map +1 -0
  84. package/dist/cli/chunk-RU36QVN3.js +452 -0
  85. package/dist/cli/chunk-RU36QVN3.js.map +1 -0
  86. package/dist/cli/chunk-RUBIINXR.js +1819 -0
  87. package/dist/cli/chunk-RUBIINXR.js.map +1 -0
  88. package/dist/cli/chunk-S4XVGLRW.js +499 -0
  89. package/dist/cli/chunk-S4XVGLRW.js.map +1 -0
  90. package/dist/cli/chunk-TUK7OWJA.js +51 -0
  91. package/dist/cli/chunk-TUK7OWJA.js.map +1 -0
  92. package/dist/cli/chunk-VALDDV76.js +580 -0
  93. package/dist/cli/chunk-VALDDV76.js.map +1 -0
  94. package/dist/cli/chunk-WQOGPYGN.js +11390 -0
  95. package/dist/cli/chunk-WQOGPYGN.js.map +1 -0
  96. package/dist/cli/chunk-WREKDFXT.js +34320 -0
  97. package/dist/cli/chunk-WREKDFXT.js.map +1 -0
  98. package/dist/cli/chunk-Y7XQU2EL.js +270 -0
  99. package/dist/cli/chunk-Y7XQU2EL.js.map +1 -0
  100. package/dist/cli/chunk-YBVCZJU4.js +54 -0
  101. package/dist/cli/chunk-YBVCZJU4.js.map +1 -0
  102. package/dist/cli/chunk-YLIHDXUQ.js +749 -0
  103. package/dist/cli/chunk-YLIHDXUQ.js.map +1 -0
  104. package/dist/cli/chunk-YV5XXFD7.js +767 -0
  105. package/dist/cli/chunk-YV5XXFD7.js.map +1 -0
  106. package/dist/cli/chunk-ZRCNIYRQ.js +101 -0
  107. package/dist/cli/chunk-ZRCNIYRQ.js.map +1 -0
  108. package/dist/cli/code-CRKVCMFZ.js +155 -0
  109. package/dist/cli/code-CRKVCMFZ.js.map +1 -0
  110. package/dist/cli/commands-QLMD3T7B.js +356 -0
  111. package/dist/cli/commands-QLMD3T7B.js.map +1 -0
  112. package/dist/cli/commit-53PP32NC.js +293 -0
  113. package/dist/cli/commit-53PP32NC.js.map +1 -0
  114. package/dist/cli/desktop-R6W5CLJ5.js +1046 -0
  115. package/dist/cli/desktop-R6W5CLJ5.js.map +1 -0
  116. package/dist/cli/devtools-YECO25QO.js +3719 -0
  117. package/dist/cli/devtools-YECO25QO.js.map +1 -0
  118. package/dist/cli/diff-LYNRCJZE.js +166 -0
  119. package/dist/cli/diff-LYNRCJZE.js.map +1 -0
  120. package/dist/cli/doctor-5IBP4R5J.js +28 -0
  121. package/dist/cli/doctor-5IBP4R5J.js.map +1 -0
  122. package/dist/cli/events-QN6KLN2V.js +340 -0
  123. package/dist/cli/events-QN6KLN2V.js.map +1 -0
  124. package/dist/cli/index.js +3500 -0
  125. package/dist/cli/index.js.map +1 -0
  126. package/dist/cli/mcp-FGKEH7RG.js +277 -0
  127. package/dist/cli/mcp-FGKEH7RG.js.map +1 -0
  128. package/dist/cli/mcp-browse-YCND4NWT.js +178 -0
  129. package/dist/cli/mcp-browse-YCND4NWT.js.map +1 -0
  130. package/dist/cli/mcp-inspect-V34J3VX5.js +143 -0
  131. package/dist/cli/mcp-inspect-V34J3VX5.js.map +1 -0
  132. package/dist/cli/package.json +3 -0
  133. package/dist/cli/prompt-I775PNKT.js +16 -0
  134. package/dist/cli/prompt-I775PNKT.js.map +1 -0
  135. package/dist/cli/prune-sessions-KGIIYD3P.js +44 -0
  136. package/dist/cli/prune-sessions-KGIIYD3P.js.map +1 -0
  137. package/dist/cli/replay-RDXLUAOE.js +292 -0
  138. package/dist/cli/replay-RDXLUAOE.js.map +1 -0
  139. package/dist/cli/run-RCAC2RYW.js +223 -0
  140. package/dist/cli/run-RCAC2RYW.js.map +1 -0
  141. package/dist/cli/server-FFU6TLYJ.js +3658 -0
  142. package/dist/cli/server-FFU6TLYJ.js.map +1 -0
  143. package/dist/cli/sessions-QT26MQAE.js +107 -0
  144. package/dist/cli/sessions-QT26MQAE.js.map +1 -0
  145. package/dist/cli/setup-VV4WKXHV.js +767 -0
  146. package/dist/cli/setup-VV4WKXHV.js.map +1 -0
  147. package/dist/cli/stats-JVZPQWAN.js +15 -0
  148. package/dist/cli/stats-JVZPQWAN.js.map +1 -0
  149. package/dist/cli/update-KYI3OVJP.js +15 -0
  150. package/dist/cli/update-KYI3OVJP.js.map +1 -0
  151. package/dist/cli/version-ANYORXTI.js +34 -0
  152. package/dist/cli/version-ANYORXTI.js.map +1 -0
  153. package/dist/index.d.ts +2557 -0
  154. package/dist/index.js +15000 -0
  155. package/dist/index.js.map +1 -0
  156. package/package.json +106 -0
@@ -0,0 +1,2663 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __cr } from 'node:module'; if (typeof globalThis.require === 'undefined') { globalThis.require = __cr(import.meta.url); }
3
+ import {
4
+ __commonJS,
5
+ __toESM
6
+ } from "./chunk-TUK7OWJA.js";
7
+
8
+ // node_modules/picomatch/lib/constants.js
9
+ var require_constants = __commonJS({
10
+ "node_modules/picomatch/lib/constants.js"(exports, module) {
11
+ "use strict";
12
+ var WIN_SLASH = "\\\\/";
13
+ var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
14
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
15
+ var DOT_LITERAL = "\\.";
16
+ var PLUS_LITERAL = "\\+";
17
+ var QMARK_LITERAL = "\\?";
18
+ var SLASH_LITERAL = "\\/";
19
+ var ONE_CHAR = "(?=.)";
20
+ var QMARK = "[^/]";
21
+ var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
22
+ var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
23
+ var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
24
+ var NO_DOT = `(?!${DOT_LITERAL})`;
25
+ var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
26
+ var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
27
+ var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
28
+ var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
29
+ var STAR = `${QMARK}*?`;
30
+ var SEP = "/";
31
+ var POSIX_CHARS = {
32
+ DOT_LITERAL,
33
+ PLUS_LITERAL,
34
+ QMARK_LITERAL,
35
+ SLASH_LITERAL,
36
+ ONE_CHAR,
37
+ QMARK,
38
+ END_ANCHOR,
39
+ DOTS_SLASH,
40
+ NO_DOT,
41
+ NO_DOTS,
42
+ NO_DOT_SLASH,
43
+ NO_DOTS_SLASH,
44
+ QMARK_NO_DOT,
45
+ STAR,
46
+ START_ANCHOR,
47
+ SEP
48
+ };
49
+ var WINDOWS_CHARS = {
50
+ ...POSIX_CHARS,
51
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
52
+ QMARK: WIN_NO_SLASH,
53
+ STAR: `${WIN_NO_SLASH}*?`,
54
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
55
+ NO_DOT: `(?!${DOT_LITERAL})`,
56
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
57
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
58
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
59
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
60
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
61
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
62
+ SEP: "\\"
63
+ };
64
+ var POSIX_REGEX_SOURCE = {
65
+ __proto__: null,
66
+ alnum: "a-zA-Z0-9",
67
+ alpha: "a-zA-Z",
68
+ ascii: "\\x00-\\x7F",
69
+ blank: " \\t",
70
+ cntrl: "\\x00-\\x1F\\x7F",
71
+ digit: "0-9",
72
+ graph: "\\x21-\\x7E",
73
+ lower: "a-z",
74
+ print: "\\x20-\\x7E ",
75
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
76
+ space: " \\t\\r\\n\\v\\f",
77
+ upper: "A-Z",
78
+ word: "A-Za-z0-9_",
79
+ xdigit: "A-Fa-f0-9"
80
+ };
81
+ module.exports = {
82
+ DEFAULT_MAX_EXTGLOB_RECURSION,
83
+ MAX_LENGTH: 1024 * 64,
84
+ POSIX_REGEX_SOURCE,
85
+ // regular expressions
86
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
87
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
88
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
89
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
90
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
91
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
92
+ // Replace globs with equivalent patterns to reduce parsing time.
93
+ REPLACEMENTS: {
94
+ __proto__: null,
95
+ "***": "*",
96
+ "**/**": "**",
97
+ "**/**/**": "**"
98
+ },
99
+ // Digits
100
+ CHAR_0: 48,
101
+ /* 0 */
102
+ CHAR_9: 57,
103
+ /* 9 */
104
+ // Alphabet chars.
105
+ CHAR_UPPERCASE_A: 65,
106
+ /* A */
107
+ CHAR_LOWERCASE_A: 97,
108
+ /* a */
109
+ CHAR_UPPERCASE_Z: 90,
110
+ /* Z */
111
+ CHAR_LOWERCASE_Z: 122,
112
+ /* z */
113
+ CHAR_LEFT_PARENTHESES: 40,
114
+ /* ( */
115
+ CHAR_RIGHT_PARENTHESES: 41,
116
+ /* ) */
117
+ CHAR_ASTERISK: 42,
118
+ /* * */
119
+ // Non-alphabetic chars.
120
+ CHAR_AMPERSAND: 38,
121
+ /* & */
122
+ CHAR_AT: 64,
123
+ /* @ */
124
+ CHAR_BACKWARD_SLASH: 92,
125
+ /* \ */
126
+ CHAR_CARRIAGE_RETURN: 13,
127
+ /* \r */
128
+ CHAR_CIRCUMFLEX_ACCENT: 94,
129
+ /* ^ */
130
+ CHAR_COLON: 58,
131
+ /* : */
132
+ CHAR_COMMA: 44,
133
+ /* , */
134
+ CHAR_DOT: 46,
135
+ /* . */
136
+ CHAR_DOUBLE_QUOTE: 34,
137
+ /* " */
138
+ CHAR_EQUAL: 61,
139
+ /* = */
140
+ CHAR_EXCLAMATION_MARK: 33,
141
+ /* ! */
142
+ CHAR_FORM_FEED: 12,
143
+ /* \f */
144
+ CHAR_FORWARD_SLASH: 47,
145
+ /* / */
146
+ CHAR_GRAVE_ACCENT: 96,
147
+ /* ` */
148
+ CHAR_HASH: 35,
149
+ /* # */
150
+ CHAR_HYPHEN_MINUS: 45,
151
+ /* - */
152
+ CHAR_LEFT_ANGLE_BRACKET: 60,
153
+ /* < */
154
+ CHAR_LEFT_CURLY_BRACE: 123,
155
+ /* { */
156
+ CHAR_LEFT_SQUARE_BRACKET: 91,
157
+ /* [ */
158
+ CHAR_LINE_FEED: 10,
159
+ /* \n */
160
+ CHAR_NO_BREAK_SPACE: 160,
161
+ /* \u00A0 */
162
+ CHAR_PERCENT: 37,
163
+ /* % */
164
+ CHAR_PLUS: 43,
165
+ /* + */
166
+ CHAR_QUESTION_MARK: 63,
167
+ /* ? */
168
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
169
+ /* > */
170
+ CHAR_RIGHT_CURLY_BRACE: 125,
171
+ /* } */
172
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
173
+ /* ] */
174
+ CHAR_SEMICOLON: 59,
175
+ /* ; */
176
+ CHAR_SINGLE_QUOTE: 39,
177
+ /* ' */
178
+ CHAR_SPACE: 32,
179
+ /* */
180
+ CHAR_TAB: 9,
181
+ /* \t */
182
+ CHAR_UNDERSCORE: 95,
183
+ /* _ */
184
+ CHAR_VERTICAL_LINE: 124,
185
+ /* | */
186
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
187
+ /* \uFEFF */
188
+ /**
189
+ * Create EXTGLOB_CHARS
190
+ */
191
+ extglobChars(chars) {
192
+ return {
193
+ "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
194
+ "?": { type: "qmark", open: "(?:", close: ")?" },
195
+ "+": { type: "plus", open: "(?:", close: ")+" },
196
+ "*": { type: "star", open: "(?:", close: ")*" },
197
+ "@": { type: "at", open: "(?:", close: ")" }
198
+ };
199
+ },
200
+ /**
201
+ * Create GLOB_CHARS
202
+ */
203
+ globChars(win32) {
204
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
205
+ }
206
+ };
207
+ }
208
+ });
209
+
210
+ // node_modules/picomatch/lib/utils.js
211
+ var require_utils = __commonJS({
212
+ "node_modules/picomatch/lib/utils.js"(exports) {
213
+ "use strict";
214
+ var {
215
+ REGEX_BACKSLASH,
216
+ REGEX_REMOVE_BACKSLASH,
217
+ REGEX_SPECIAL_CHARS,
218
+ REGEX_SPECIAL_CHARS_GLOBAL
219
+ } = require_constants();
220
+ exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
221
+ exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
222
+ exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
223
+ exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
224
+ exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
225
+ exports.isWindows = () => {
226
+ if (typeof navigator !== "undefined" && navigator.platform) {
227
+ const platform = navigator.platform.toLowerCase();
228
+ return platform === "win32" || platform === "windows";
229
+ }
230
+ if (typeof process !== "undefined" && process.platform) {
231
+ return process.platform === "win32";
232
+ }
233
+ return false;
234
+ };
235
+ exports.removeBackslashes = (str) => {
236
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
237
+ return match === "\\" ? "" : match;
238
+ });
239
+ };
240
+ exports.escapeLast = (input, char, lastIdx) => {
241
+ const idx = input.lastIndexOf(char, lastIdx);
242
+ if (idx === -1) return input;
243
+ if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
244
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
245
+ };
246
+ exports.removePrefix = (input, state = {}) => {
247
+ let output = input;
248
+ if (output.startsWith("./")) {
249
+ output = output.slice(2);
250
+ state.prefix = "./";
251
+ }
252
+ return output;
253
+ };
254
+ exports.wrapOutput = (input, state = {}, options = {}) => {
255
+ const prepend = options.contains ? "" : "^";
256
+ const append = options.contains ? "" : "$";
257
+ let output = `${prepend}(?:${input})${append}`;
258
+ if (state.negated === true) {
259
+ output = `(?:^(?!${output}).*$)`;
260
+ }
261
+ return output;
262
+ };
263
+ exports.basename = (path, { windows } = {}) => {
264
+ const segs = path.split(windows ? /[\\/]/ : "/");
265
+ const last = segs[segs.length - 1];
266
+ if (last === "") {
267
+ return segs[segs.length - 2];
268
+ }
269
+ return last;
270
+ };
271
+ }
272
+ });
273
+
274
+ // node_modules/picomatch/lib/scan.js
275
+ var require_scan = __commonJS({
276
+ "node_modules/picomatch/lib/scan.js"(exports, module) {
277
+ "use strict";
278
+ var utils = require_utils();
279
+ var {
280
+ CHAR_ASTERISK,
281
+ /* * */
282
+ CHAR_AT,
283
+ /* @ */
284
+ CHAR_BACKWARD_SLASH,
285
+ /* \ */
286
+ CHAR_COMMA,
287
+ /* , */
288
+ CHAR_DOT,
289
+ /* . */
290
+ CHAR_EXCLAMATION_MARK,
291
+ /* ! */
292
+ CHAR_FORWARD_SLASH,
293
+ /* / */
294
+ CHAR_LEFT_CURLY_BRACE,
295
+ /* { */
296
+ CHAR_LEFT_PARENTHESES,
297
+ /* ( */
298
+ CHAR_LEFT_SQUARE_BRACKET,
299
+ /* [ */
300
+ CHAR_PLUS,
301
+ /* + */
302
+ CHAR_QUESTION_MARK,
303
+ /* ? */
304
+ CHAR_RIGHT_CURLY_BRACE,
305
+ /* } */
306
+ CHAR_RIGHT_PARENTHESES,
307
+ /* ) */
308
+ CHAR_RIGHT_SQUARE_BRACKET
309
+ /* ] */
310
+ } = require_constants();
311
+ var isPathSeparator = (code) => {
312
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
313
+ };
314
+ var depth = (token) => {
315
+ if (token.isPrefix !== true) {
316
+ token.depth = token.isGlobstar ? Infinity : 1;
317
+ }
318
+ };
319
+ var scan = (input, options) => {
320
+ const opts = options || {};
321
+ const length = input.length - 1;
322
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
323
+ const slashes = [];
324
+ const tokens = [];
325
+ const parts = [];
326
+ let str = input;
327
+ let index = -1;
328
+ let start = 0;
329
+ let lastIndex = 0;
330
+ let isBrace = false;
331
+ let isBracket = false;
332
+ let isGlob = false;
333
+ let isExtglob = false;
334
+ let isGlobstar = false;
335
+ let braceEscaped = false;
336
+ let backslashes = false;
337
+ let negated = false;
338
+ let negatedExtglob = false;
339
+ let finished = false;
340
+ let braces = 0;
341
+ let prev;
342
+ let code;
343
+ let token = { value: "", depth: 0, isGlob: false };
344
+ const eos = () => index >= length;
345
+ const peek = () => str.charCodeAt(index + 1);
346
+ const advance = () => {
347
+ prev = code;
348
+ return str.charCodeAt(++index);
349
+ };
350
+ while (index < length) {
351
+ code = advance();
352
+ let next;
353
+ if (code === CHAR_BACKWARD_SLASH) {
354
+ backslashes = token.backslashes = true;
355
+ code = advance();
356
+ if (code === CHAR_LEFT_CURLY_BRACE) {
357
+ braceEscaped = true;
358
+ }
359
+ continue;
360
+ }
361
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
362
+ braces++;
363
+ while (eos() !== true && (code = advance())) {
364
+ if (code === CHAR_BACKWARD_SLASH) {
365
+ backslashes = token.backslashes = true;
366
+ advance();
367
+ continue;
368
+ }
369
+ if (code === CHAR_LEFT_CURLY_BRACE) {
370
+ braces++;
371
+ continue;
372
+ }
373
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
374
+ isBrace = token.isBrace = true;
375
+ isGlob = token.isGlob = true;
376
+ finished = true;
377
+ if (scanToEnd === true) {
378
+ continue;
379
+ }
380
+ break;
381
+ }
382
+ if (braceEscaped !== true && code === CHAR_COMMA) {
383
+ isBrace = token.isBrace = true;
384
+ isGlob = token.isGlob = true;
385
+ finished = true;
386
+ if (scanToEnd === true) {
387
+ continue;
388
+ }
389
+ break;
390
+ }
391
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
392
+ braces--;
393
+ if (braces === 0) {
394
+ braceEscaped = false;
395
+ isBrace = token.isBrace = true;
396
+ finished = true;
397
+ break;
398
+ }
399
+ }
400
+ }
401
+ if (scanToEnd === true) {
402
+ continue;
403
+ }
404
+ break;
405
+ }
406
+ if (code === CHAR_FORWARD_SLASH) {
407
+ slashes.push(index);
408
+ tokens.push(token);
409
+ token = { value: "", depth: 0, isGlob: false };
410
+ if (finished === true) continue;
411
+ if (prev === CHAR_DOT && index === start + 1) {
412
+ start += 2;
413
+ continue;
414
+ }
415
+ lastIndex = index + 1;
416
+ continue;
417
+ }
418
+ if (opts.noext !== true) {
419
+ const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
420
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
421
+ isGlob = token.isGlob = true;
422
+ isExtglob = token.isExtglob = true;
423
+ finished = true;
424
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
425
+ negatedExtglob = true;
426
+ }
427
+ if (scanToEnd === true) {
428
+ while (eos() !== true && (code = advance())) {
429
+ if (code === CHAR_BACKWARD_SLASH) {
430
+ backslashes = token.backslashes = true;
431
+ code = advance();
432
+ continue;
433
+ }
434
+ if (code === CHAR_RIGHT_PARENTHESES) {
435
+ isGlob = token.isGlob = true;
436
+ finished = true;
437
+ break;
438
+ }
439
+ }
440
+ continue;
441
+ }
442
+ break;
443
+ }
444
+ }
445
+ if (code === CHAR_ASTERISK) {
446
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
447
+ isGlob = token.isGlob = true;
448
+ finished = true;
449
+ if (scanToEnd === true) {
450
+ continue;
451
+ }
452
+ break;
453
+ }
454
+ if (code === CHAR_QUESTION_MARK) {
455
+ isGlob = token.isGlob = true;
456
+ finished = true;
457
+ if (scanToEnd === true) {
458
+ continue;
459
+ }
460
+ break;
461
+ }
462
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
463
+ while (eos() !== true && (next = advance())) {
464
+ if (next === CHAR_BACKWARD_SLASH) {
465
+ backslashes = token.backslashes = true;
466
+ advance();
467
+ continue;
468
+ }
469
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
470
+ isBracket = token.isBracket = true;
471
+ isGlob = token.isGlob = true;
472
+ finished = true;
473
+ break;
474
+ }
475
+ }
476
+ if (scanToEnd === true) {
477
+ continue;
478
+ }
479
+ break;
480
+ }
481
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
482
+ negated = token.negated = true;
483
+ start++;
484
+ continue;
485
+ }
486
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
487
+ isGlob = token.isGlob = true;
488
+ if (scanToEnd === true) {
489
+ while (eos() !== true && (code = advance())) {
490
+ if (code === CHAR_LEFT_PARENTHESES) {
491
+ backslashes = token.backslashes = true;
492
+ code = advance();
493
+ continue;
494
+ }
495
+ if (code === CHAR_RIGHT_PARENTHESES) {
496
+ finished = true;
497
+ break;
498
+ }
499
+ }
500
+ continue;
501
+ }
502
+ break;
503
+ }
504
+ if (isGlob === true) {
505
+ finished = true;
506
+ if (scanToEnd === true) {
507
+ continue;
508
+ }
509
+ break;
510
+ }
511
+ }
512
+ if (opts.noext === true) {
513
+ isExtglob = false;
514
+ isGlob = false;
515
+ }
516
+ let base = str;
517
+ let prefix = "";
518
+ let glob = "";
519
+ if (start > 0) {
520
+ prefix = str.slice(0, start);
521
+ str = str.slice(start);
522
+ lastIndex -= start;
523
+ }
524
+ if (base && isGlob === true && lastIndex > 0) {
525
+ base = str.slice(0, lastIndex);
526
+ glob = str.slice(lastIndex);
527
+ } else if (isGlob === true) {
528
+ base = "";
529
+ glob = str;
530
+ } else {
531
+ base = str;
532
+ }
533
+ if (base && base !== "" && base !== "/" && base !== str) {
534
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
535
+ base = base.slice(0, -1);
536
+ }
537
+ }
538
+ if (opts.unescape === true) {
539
+ if (glob) glob = utils.removeBackslashes(glob);
540
+ if (base && backslashes === true) {
541
+ base = utils.removeBackslashes(base);
542
+ }
543
+ }
544
+ const state = {
545
+ prefix,
546
+ input,
547
+ start,
548
+ base,
549
+ glob,
550
+ isBrace,
551
+ isBracket,
552
+ isGlob,
553
+ isExtglob,
554
+ isGlobstar,
555
+ negated,
556
+ negatedExtglob
557
+ };
558
+ if (opts.tokens === true) {
559
+ state.maxDepth = 0;
560
+ if (!isPathSeparator(code)) {
561
+ tokens.push(token);
562
+ }
563
+ state.tokens = tokens;
564
+ }
565
+ if (opts.parts === true || opts.tokens === true) {
566
+ let prevIndex;
567
+ for (let idx = 0; idx < slashes.length; idx++) {
568
+ const n = prevIndex ? prevIndex + 1 : start;
569
+ const i = slashes[idx];
570
+ const value = input.slice(n, i);
571
+ if (opts.tokens) {
572
+ if (idx === 0 && start !== 0) {
573
+ tokens[idx].isPrefix = true;
574
+ tokens[idx].value = prefix;
575
+ } else {
576
+ tokens[idx].value = value;
577
+ }
578
+ depth(tokens[idx]);
579
+ state.maxDepth += tokens[idx].depth;
580
+ }
581
+ if (idx !== 0 || value !== "") {
582
+ parts.push(value);
583
+ }
584
+ prevIndex = i;
585
+ }
586
+ if (prevIndex && prevIndex + 1 < input.length) {
587
+ const value = input.slice(prevIndex + 1);
588
+ parts.push(value);
589
+ if (opts.tokens) {
590
+ tokens[tokens.length - 1].value = value;
591
+ depth(tokens[tokens.length - 1]);
592
+ state.maxDepth += tokens[tokens.length - 1].depth;
593
+ }
594
+ }
595
+ state.slashes = slashes;
596
+ state.parts = parts;
597
+ }
598
+ return state;
599
+ };
600
+ module.exports = scan;
601
+ }
602
+ });
603
+
604
+ // node_modules/picomatch/lib/parse.js
605
+ var require_parse = __commonJS({
606
+ "node_modules/picomatch/lib/parse.js"(exports, module) {
607
+ "use strict";
608
+ var constants = require_constants();
609
+ var utils = require_utils();
610
+ var {
611
+ MAX_LENGTH,
612
+ POSIX_REGEX_SOURCE,
613
+ REGEX_NON_SPECIAL_CHARS,
614
+ REGEX_SPECIAL_CHARS_BACKREF,
615
+ REPLACEMENTS
616
+ } = constants;
617
+ var expandRange = (args, options) => {
618
+ if (typeof options.expandRange === "function") {
619
+ return options.expandRange(...args, options);
620
+ }
621
+ args.sort();
622
+ const value = `[${args.join("-")}]`;
623
+ try {
624
+ new RegExp(value);
625
+ } catch (ex) {
626
+ return args.map((v) => utils.escapeRegex(v)).join("..");
627
+ }
628
+ return value;
629
+ };
630
+ var syntaxError = (type, char) => {
631
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
632
+ };
633
+ var splitTopLevel = (input) => {
634
+ const parts = [];
635
+ let bracket = 0;
636
+ let paren = 0;
637
+ let quote = 0;
638
+ let value = "";
639
+ let escaped = false;
640
+ for (const ch of input) {
641
+ if (escaped === true) {
642
+ value += ch;
643
+ escaped = false;
644
+ continue;
645
+ }
646
+ if (ch === "\\") {
647
+ value += ch;
648
+ escaped = true;
649
+ continue;
650
+ }
651
+ if (ch === '"') {
652
+ quote = quote === 1 ? 0 : 1;
653
+ value += ch;
654
+ continue;
655
+ }
656
+ if (quote === 0) {
657
+ if (ch === "[") {
658
+ bracket++;
659
+ } else if (ch === "]" && bracket > 0) {
660
+ bracket--;
661
+ } else if (bracket === 0) {
662
+ if (ch === "(") {
663
+ paren++;
664
+ } else if (ch === ")" && paren > 0) {
665
+ paren--;
666
+ } else if (ch === "|" && paren === 0) {
667
+ parts.push(value);
668
+ value = "";
669
+ continue;
670
+ }
671
+ }
672
+ }
673
+ value += ch;
674
+ }
675
+ parts.push(value);
676
+ return parts;
677
+ };
678
+ var isPlainBranch = (branch) => {
679
+ let escaped = false;
680
+ for (const ch of branch) {
681
+ if (escaped === true) {
682
+ escaped = false;
683
+ continue;
684
+ }
685
+ if (ch === "\\") {
686
+ escaped = true;
687
+ continue;
688
+ }
689
+ if (/[?*+@!()[\]{}]/.test(ch)) {
690
+ return false;
691
+ }
692
+ }
693
+ return true;
694
+ };
695
+ var normalizeSimpleBranch = (branch) => {
696
+ let value = branch.trim();
697
+ let changed = true;
698
+ while (changed === true) {
699
+ changed = false;
700
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
701
+ value = value.slice(2, -1);
702
+ changed = true;
703
+ }
704
+ }
705
+ if (!isPlainBranch(value)) {
706
+ return;
707
+ }
708
+ return value.replace(/\\(.)/g, "$1");
709
+ };
710
+ var hasRepeatedCharPrefixOverlap = (branches) => {
711
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
712
+ for (let i = 0; i < values.length; i++) {
713
+ for (let j = i + 1; j < values.length; j++) {
714
+ const a = values[i];
715
+ const b = values[j];
716
+ const char = a[0];
717
+ if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
718
+ continue;
719
+ }
720
+ if (a === b || a.startsWith(b) || b.startsWith(a)) {
721
+ return true;
722
+ }
723
+ }
724
+ }
725
+ return false;
726
+ };
727
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
728
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
729
+ return;
730
+ }
731
+ let bracket = 0;
732
+ let paren = 0;
733
+ let quote = 0;
734
+ let escaped = false;
735
+ for (let i = 1; i < pattern.length; i++) {
736
+ const ch = pattern[i];
737
+ if (escaped === true) {
738
+ escaped = false;
739
+ continue;
740
+ }
741
+ if (ch === "\\") {
742
+ escaped = true;
743
+ continue;
744
+ }
745
+ if (ch === '"') {
746
+ quote = quote === 1 ? 0 : 1;
747
+ continue;
748
+ }
749
+ if (quote === 1) {
750
+ continue;
751
+ }
752
+ if (ch === "[") {
753
+ bracket++;
754
+ continue;
755
+ }
756
+ if (ch === "]" && bracket > 0) {
757
+ bracket--;
758
+ continue;
759
+ }
760
+ if (bracket > 0) {
761
+ continue;
762
+ }
763
+ if (ch === "(") {
764
+ paren++;
765
+ continue;
766
+ }
767
+ if (ch === ")") {
768
+ paren--;
769
+ if (paren === 0) {
770
+ if (requireEnd === true && i !== pattern.length - 1) {
771
+ return;
772
+ }
773
+ return {
774
+ type: pattern[0],
775
+ body: pattern.slice(2, i),
776
+ end: i
777
+ };
778
+ }
779
+ }
780
+ }
781
+ };
782
+ var getStarExtglobSequenceOutput = (pattern) => {
783
+ let index = 0;
784
+ const chars = [];
785
+ while (index < pattern.length) {
786
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
787
+ if (!match || match.type !== "*") {
788
+ return;
789
+ }
790
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
791
+ if (branches.length !== 1) {
792
+ return;
793
+ }
794
+ const branch = normalizeSimpleBranch(branches[0]);
795
+ if (!branch || branch.length !== 1) {
796
+ return;
797
+ }
798
+ chars.push(branch);
799
+ index += match.end + 1;
800
+ }
801
+ if (chars.length < 1) {
802
+ return;
803
+ }
804
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
805
+ return `${source}*`;
806
+ };
807
+ var repeatedExtglobRecursion = (pattern) => {
808
+ let depth = 0;
809
+ let value = pattern.trim();
810
+ let match = parseRepeatedExtglob(value);
811
+ while (match) {
812
+ depth++;
813
+ value = match.body.trim();
814
+ match = parseRepeatedExtglob(value);
815
+ }
816
+ return depth;
817
+ };
818
+ var analyzeRepeatedExtglob = (body, options) => {
819
+ if (options.maxExtglobRecursion === false) {
820
+ return { risky: false };
821
+ }
822
+ const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
823
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
824
+ if (branches.length > 1) {
825
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
826
+ return { risky: true };
827
+ }
828
+ }
829
+ for (const branch of branches) {
830
+ const safeOutput = getStarExtglobSequenceOutput(branch);
831
+ if (safeOutput) {
832
+ return { risky: true, safeOutput };
833
+ }
834
+ if (repeatedExtglobRecursion(branch) > max) {
835
+ return { risky: true };
836
+ }
837
+ }
838
+ return { risky: false };
839
+ };
840
+ var parse = (input, options) => {
841
+ if (typeof input !== "string") {
842
+ throw new TypeError("Expected a string");
843
+ }
844
+ input = REPLACEMENTS[input] || input;
845
+ const opts = { ...options };
846
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
847
+ let len = input.length;
848
+ if (len > max) {
849
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
850
+ }
851
+ const bos = { type: "bos", value: "", output: opts.prepend || "" };
852
+ const tokens = [bos];
853
+ const capture = opts.capture ? "" : "?:";
854
+ const PLATFORM_CHARS = constants.globChars(opts.windows);
855
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
856
+ const {
857
+ DOT_LITERAL,
858
+ PLUS_LITERAL,
859
+ SLASH_LITERAL,
860
+ ONE_CHAR,
861
+ DOTS_SLASH,
862
+ NO_DOT,
863
+ NO_DOT_SLASH,
864
+ NO_DOTS_SLASH,
865
+ QMARK,
866
+ QMARK_NO_DOT,
867
+ STAR,
868
+ START_ANCHOR
869
+ } = PLATFORM_CHARS;
870
+ const globstar = (opts2) => {
871
+ return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
872
+ };
873
+ const nodot = opts.dot ? "" : NO_DOT;
874
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
875
+ let star = opts.bash === true ? globstar(opts) : STAR;
876
+ if (opts.capture) {
877
+ star = `(${star})`;
878
+ }
879
+ if (typeof opts.noext === "boolean") {
880
+ opts.noextglob = opts.noext;
881
+ }
882
+ const state = {
883
+ input,
884
+ index: -1,
885
+ start: 0,
886
+ dot: opts.dot === true,
887
+ consumed: "",
888
+ output: "",
889
+ prefix: "",
890
+ backtrack: false,
891
+ negated: false,
892
+ brackets: 0,
893
+ braces: 0,
894
+ parens: 0,
895
+ quotes: 0,
896
+ globstar: false,
897
+ tokens
898
+ };
899
+ input = utils.removePrefix(input, state);
900
+ len = input.length;
901
+ const extglobs = [];
902
+ const braces = [];
903
+ const stack = [];
904
+ let prev = bos;
905
+ let value;
906
+ const eos = () => state.index === len - 1;
907
+ const peek = state.peek = (n = 1) => input[state.index + n];
908
+ const advance = state.advance = () => input[++state.index] || "";
909
+ const remaining = () => input.slice(state.index + 1);
910
+ const consume = (value2 = "", num = 0) => {
911
+ state.consumed += value2;
912
+ state.index += num;
913
+ };
914
+ const append = (token) => {
915
+ state.output += token.output != null ? token.output : token.value;
916
+ consume(token.value);
917
+ };
918
+ const negate = () => {
919
+ let count = 1;
920
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
921
+ advance();
922
+ state.start++;
923
+ count++;
924
+ }
925
+ if (count % 2 === 0) {
926
+ return false;
927
+ }
928
+ state.negated = true;
929
+ state.start++;
930
+ return true;
931
+ };
932
+ const increment = (type) => {
933
+ state[type]++;
934
+ stack.push(type);
935
+ };
936
+ const decrement = (type) => {
937
+ state[type]--;
938
+ stack.pop();
939
+ };
940
+ const push = (tok) => {
941
+ if (prev.type === "globstar") {
942
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
943
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
944
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
945
+ state.output = state.output.slice(0, -prev.output.length);
946
+ prev.type = "star";
947
+ prev.value = "*";
948
+ prev.output = star;
949
+ state.output += prev.output;
950
+ }
951
+ }
952
+ if (extglobs.length && tok.type !== "paren") {
953
+ extglobs[extglobs.length - 1].inner += tok.value;
954
+ }
955
+ if (tok.value || tok.output) append(tok);
956
+ if (prev && prev.type === "text" && tok.type === "text") {
957
+ prev.output = (prev.output || prev.value) + tok.value;
958
+ prev.value += tok.value;
959
+ return;
960
+ }
961
+ tok.prev = prev;
962
+ tokens.push(tok);
963
+ prev = tok;
964
+ };
965
+ const extglobOpen = (type, value2) => {
966
+ const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
967
+ token.prev = prev;
968
+ token.parens = state.parens;
969
+ token.output = state.output;
970
+ token.startIndex = state.index;
971
+ token.tokensIndex = tokens.length;
972
+ const output = (opts.capture ? "(" : "") + token.open;
973
+ increment("parens");
974
+ push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
975
+ push({ type: "paren", extglob: true, value: advance(), output });
976
+ extglobs.push(token);
977
+ };
978
+ const extglobClose = (token) => {
979
+ const literal = input.slice(token.startIndex, state.index + 1);
980
+ const body = input.slice(token.startIndex + 2, state.index);
981
+ const analysis = analyzeRepeatedExtglob(body, opts);
982
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
983
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
984
+ const open = tokens[token.tokensIndex];
985
+ open.type = "text";
986
+ open.value = literal;
987
+ open.output = safeOutput || utils.escapeRegex(literal);
988
+ for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
989
+ tokens[i].value = "";
990
+ tokens[i].output = "";
991
+ delete tokens[i].suffix;
992
+ }
993
+ state.output = token.output + open.output;
994
+ state.backtrack = true;
995
+ push({ type: "paren", extglob: true, value, output: "" });
996
+ decrement("parens");
997
+ return;
998
+ }
999
+ let output = token.close + (opts.capture ? ")" : "");
1000
+ let rest;
1001
+ if (token.type === "negate") {
1002
+ let extglobStar = star;
1003
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
1004
+ extglobStar = globstar(opts);
1005
+ }
1006
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
1007
+ output = token.close = `)$))${extglobStar}`;
1008
+ }
1009
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
1010
+ const expression = parse(rest, { ...options, fastpaths: false }).output;
1011
+ output = token.close = `)${expression})${extglobStar})`;
1012
+ }
1013
+ if (token.prev.type === "bos") {
1014
+ state.negatedExtglob = true;
1015
+ }
1016
+ }
1017
+ push({ type: "paren", extglob: true, value, output });
1018
+ decrement("parens");
1019
+ };
1020
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
1021
+ let backslashes = false;
1022
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
1023
+ if (first === "\\") {
1024
+ backslashes = true;
1025
+ return m;
1026
+ }
1027
+ if (first === "?") {
1028
+ if (esc) {
1029
+ return esc + first + (rest ? QMARK.repeat(rest.length) : "");
1030
+ }
1031
+ if (index === 0) {
1032
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
1033
+ }
1034
+ return QMARK.repeat(chars.length);
1035
+ }
1036
+ if (first === ".") {
1037
+ return DOT_LITERAL.repeat(chars.length);
1038
+ }
1039
+ if (first === "*") {
1040
+ if (esc) {
1041
+ return esc + first + (rest ? star : "");
1042
+ }
1043
+ return star;
1044
+ }
1045
+ return esc ? m : `\\${m}`;
1046
+ });
1047
+ if (backslashes === true) {
1048
+ if (opts.unescape === true) {
1049
+ output = output.replace(/\\/g, "");
1050
+ } else {
1051
+ output = output.replace(/\\+/g, (m) => {
1052
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
1053
+ });
1054
+ }
1055
+ }
1056
+ if (output === input && opts.contains === true) {
1057
+ state.output = input;
1058
+ return state;
1059
+ }
1060
+ state.output = utils.wrapOutput(output, state, options);
1061
+ return state;
1062
+ }
1063
+ while (!eos()) {
1064
+ value = advance();
1065
+ if (value === "\0") {
1066
+ continue;
1067
+ }
1068
+ if (value === "\\") {
1069
+ const next = peek();
1070
+ if (next === "/" && opts.bash !== true) {
1071
+ continue;
1072
+ }
1073
+ if (next === "." || next === ";") {
1074
+ continue;
1075
+ }
1076
+ if (!next) {
1077
+ value += "\\";
1078
+ push({ type: "text", value });
1079
+ continue;
1080
+ }
1081
+ const match = /^\\+/.exec(remaining());
1082
+ let slashes = 0;
1083
+ if (match && match[0].length > 2) {
1084
+ slashes = match[0].length;
1085
+ state.index += slashes;
1086
+ if (slashes % 2 !== 0) {
1087
+ value += "\\";
1088
+ }
1089
+ }
1090
+ if (opts.unescape === true) {
1091
+ value = advance();
1092
+ } else {
1093
+ value += advance();
1094
+ }
1095
+ if (state.brackets === 0) {
1096
+ push({ type: "text", value });
1097
+ continue;
1098
+ }
1099
+ }
1100
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
1101
+ if (opts.posix !== false && value === ":") {
1102
+ const inner = prev.value.slice(1);
1103
+ if (inner.includes("[")) {
1104
+ prev.posix = true;
1105
+ if (inner.includes(":")) {
1106
+ const idx = prev.value.lastIndexOf("[");
1107
+ const pre = prev.value.slice(0, idx);
1108
+ const rest2 = prev.value.slice(idx + 2);
1109
+ const posix = POSIX_REGEX_SOURCE[rest2];
1110
+ if (posix) {
1111
+ prev.value = pre + posix;
1112
+ state.backtrack = true;
1113
+ advance();
1114
+ if (!bos.output && tokens.indexOf(prev) === 1) {
1115
+ bos.output = ONE_CHAR;
1116
+ }
1117
+ continue;
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
1123
+ value = `\\${value}`;
1124
+ }
1125
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
1126
+ value = `\\${value}`;
1127
+ }
1128
+ if (opts.posix === true && value === "!" && prev.value === "[") {
1129
+ value = "^";
1130
+ }
1131
+ prev.value += value;
1132
+ append({ value });
1133
+ continue;
1134
+ }
1135
+ if (state.quotes === 1 && value !== '"') {
1136
+ value = utils.escapeRegex(value);
1137
+ prev.value += value;
1138
+ append({ value });
1139
+ continue;
1140
+ }
1141
+ if (value === '"') {
1142
+ state.quotes = state.quotes === 1 ? 0 : 1;
1143
+ if (opts.keepQuotes === true) {
1144
+ push({ type: "text", value });
1145
+ }
1146
+ continue;
1147
+ }
1148
+ if (value === "(") {
1149
+ increment("parens");
1150
+ push({ type: "paren", value });
1151
+ continue;
1152
+ }
1153
+ if (value === ")") {
1154
+ if (state.parens === 0 && opts.strictBrackets === true) {
1155
+ throw new SyntaxError(syntaxError("opening", "("));
1156
+ }
1157
+ const extglob = extglobs[extglobs.length - 1];
1158
+ if (extglob && state.parens === extglob.parens + 1) {
1159
+ extglobClose(extglobs.pop());
1160
+ continue;
1161
+ }
1162
+ push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
1163
+ decrement("parens");
1164
+ continue;
1165
+ }
1166
+ if (value === "[") {
1167
+ if (opts.nobracket === true || !remaining().includes("]")) {
1168
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
1169
+ throw new SyntaxError(syntaxError("closing", "]"));
1170
+ }
1171
+ value = `\\${value}`;
1172
+ } else {
1173
+ increment("brackets");
1174
+ }
1175
+ push({ type: "bracket", value });
1176
+ continue;
1177
+ }
1178
+ if (value === "]") {
1179
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
1180
+ push({ type: "text", value, output: `\\${value}` });
1181
+ continue;
1182
+ }
1183
+ if (state.brackets === 0) {
1184
+ if (opts.strictBrackets === true) {
1185
+ throw new SyntaxError(syntaxError("opening", "["));
1186
+ }
1187
+ push({ type: "text", value, output: `\\${value}` });
1188
+ continue;
1189
+ }
1190
+ decrement("brackets");
1191
+ const prevValue = prev.value.slice(1);
1192
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
1193
+ value = `/${value}`;
1194
+ }
1195
+ prev.value += value;
1196
+ append({ value });
1197
+ if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
1198
+ continue;
1199
+ }
1200
+ const escaped = utils.escapeRegex(prev.value);
1201
+ state.output = state.output.slice(0, -prev.value.length);
1202
+ if (opts.literalBrackets === true) {
1203
+ state.output += escaped;
1204
+ prev.value = escaped;
1205
+ continue;
1206
+ }
1207
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1208
+ state.output += prev.value;
1209
+ continue;
1210
+ }
1211
+ if (value === "{" && opts.nobrace !== true) {
1212
+ increment("braces");
1213
+ const open = {
1214
+ type: "brace",
1215
+ value,
1216
+ output: "(",
1217
+ outputIndex: state.output.length,
1218
+ tokensIndex: state.tokens.length
1219
+ };
1220
+ braces.push(open);
1221
+ push(open);
1222
+ continue;
1223
+ }
1224
+ if (value === "}") {
1225
+ const brace = braces[braces.length - 1];
1226
+ if (opts.nobrace === true || !brace) {
1227
+ push({ type: "text", value, output: value });
1228
+ continue;
1229
+ }
1230
+ let output = ")";
1231
+ if (brace.dots === true) {
1232
+ const arr = tokens.slice();
1233
+ const range = [];
1234
+ for (let i = arr.length - 1; i >= 0; i--) {
1235
+ tokens.pop();
1236
+ if (arr[i].type === "brace") {
1237
+ break;
1238
+ }
1239
+ if (arr[i].type !== "dots") {
1240
+ range.unshift(arr[i].value);
1241
+ }
1242
+ }
1243
+ output = expandRange(range, opts);
1244
+ state.backtrack = true;
1245
+ }
1246
+ if (brace.comma !== true && brace.dots !== true) {
1247
+ const out = state.output.slice(0, brace.outputIndex);
1248
+ const toks = state.tokens.slice(brace.tokensIndex);
1249
+ brace.value = brace.output = "\\{";
1250
+ value = output = "\\}";
1251
+ state.output = out;
1252
+ for (const t of toks) {
1253
+ state.output += t.output || t.value;
1254
+ }
1255
+ }
1256
+ push({ type: "brace", value, output });
1257
+ decrement("braces");
1258
+ braces.pop();
1259
+ continue;
1260
+ }
1261
+ if (value === "|") {
1262
+ if (extglobs.length > 0) {
1263
+ extglobs[extglobs.length - 1].conditions++;
1264
+ }
1265
+ push({ type: "text", value });
1266
+ continue;
1267
+ }
1268
+ if (value === ",") {
1269
+ let output = value;
1270
+ const brace = braces[braces.length - 1];
1271
+ if (brace && stack[stack.length - 1] === "braces") {
1272
+ brace.comma = true;
1273
+ output = "|";
1274
+ }
1275
+ push({ type: "comma", value, output });
1276
+ continue;
1277
+ }
1278
+ if (value === "/") {
1279
+ if (prev.type === "dot" && state.index === state.start + 1) {
1280
+ state.start = state.index + 1;
1281
+ state.consumed = "";
1282
+ state.output = "";
1283
+ tokens.pop();
1284
+ prev = bos;
1285
+ continue;
1286
+ }
1287
+ push({ type: "slash", value, output: SLASH_LITERAL });
1288
+ continue;
1289
+ }
1290
+ if (value === ".") {
1291
+ if (state.braces > 0 && prev.type === "dot") {
1292
+ if (prev.value === ".") prev.output = DOT_LITERAL;
1293
+ const brace = braces[braces.length - 1];
1294
+ prev.type = "dots";
1295
+ prev.output += value;
1296
+ prev.value += value;
1297
+ brace.dots = true;
1298
+ continue;
1299
+ }
1300
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1301
+ push({ type: "text", value, output: DOT_LITERAL });
1302
+ continue;
1303
+ }
1304
+ push({ type: "dot", value, output: DOT_LITERAL });
1305
+ continue;
1306
+ }
1307
+ if (value === "?") {
1308
+ const isGroup = prev && prev.value === "(";
1309
+ if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1310
+ extglobOpen("qmark", value);
1311
+ continue;
1312
+ }
1313
+ if (prev && prev.type === "paren") {
1314
+ const next = peek();
1315
+ let output = value;
1316
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1317
+ output = `\\${value}`;
1318
+ }
1319
+ push({ type: "text", value, output });
1320
+ continue;
1321
+ }
1322
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1323
+ push({ type: "qmark", value, output: QMARK_NO_DOT });
1324
+ continue;
1325
+ }
1326
+ push({ type: "qmark", value, output: QMARK });
1327
+ continue;
1328
+ }
1329
+ if (value === "!") {
1330
+ if (opts.noextglob !== true && peek() === "(") {
1331
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1332
+ extglobOpen("negate", value);
1333
+ continue;
1334
+ }
1335
+ }
1336
+ if (opts.nonegate !== true && state.index === 0) {
1337
+ negate();
1338
+ continue;
1339
+ }
1340
+ }
1341
+ if (value === "+") {
1342
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1343
+ extglobOpen("plus", value);
1344
+ continue;
1345
+ }
1346
+ if (prev && prev.value === "(" || opts.regex === false) {
1347
+ push({ type: "plus", value, output: PLUS_LITERAL });
1348
+ continue;
1349
+ }
1350
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1351
+ push({ type: "plus", value });
1352
+ continue;
1353
+ }
1354
+ push({ type: "plus", value: PLUS_LITERAL });
1355
+ continue;
1356
+ }
1357
+ if (value === "@") {
1358
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1359
+ push({ type: "at", extglob: true, value, output: "" });
1360
+ continue;
1361
+ }
1362
+ push({ type: "text", value });
1363
+ continue;
1364
+ }
1365
+ if (value !== "*") {
1366
+ if (value === "$" || value === "^") {
1367
+ value = `\\${value}`;
1368
+ }
1369
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1370
+ if (match) {
1371
+ value += match[0];
1372
+ state.index += match[0].length;
1373
+ }
1374
+ push({ type: "text", value });
1375
+ continue;
1376
+ }
1377
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
1378
+ prev.type = "star";
1379
+ prev.star = true;
1380
+ prev.value += value;
1381
+ prev.output = star;
1382
+ state.backtrack = true;
1383
+ state.globstar = true;
1384
+ consume(value);
1385
+ continue;
1386
+ }
1387
+ let rest = remaining();
1388
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1389
+ extglobOpen("star", value);
1390
+ continue;
1391
+ }
1392
+ if (prev.type === "star") {
1393
+ if (opts.noglobstar === true) {
1394
+ consume(value);
1395
+ continue;
1396
+ }
1397
+ const prior = prev.prev;
1398
+ const before = prior.prev;
1399
+ const isStart = prior.type === "slash" || prior.type === "bos";
1400
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
1401
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1402
+ push({ type: "star", value, output: "" });
1403
+ continue;
1404
+ }
1405
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1406
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1407
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1408
+ push({ type: "star", value, output: "" });
1409
+ continue;
1410
+ }
1411
+ while (rest.slice(0, 3) === "/**") {
1412
+ const after = input[state.index + 4];
1413
+ if (after && after !== "/") {
1414
+ break;
1415
+ }
1416
+ rest = rest.slice(3);
1417
+ consume("/**", 3);
1418
+ }
1419
+ if (prior.type === "bos" && eos()) {
1420
+ prev.type = "globstar";
1421
+ prev.value += value;
1422
+ prev.output = globstar(opts);
1423
+ state.output = prev.output;
1424
+ state.globstar = true;
1425
+ consume(value);
1426
+ continue;
1427
+ }
1428
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1429
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1430
+ prior.output = `(?:${prior.output}`;
1431
+ prev.type = "globstar";
1432
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1433
+ prev.value += value;
1434
+ state.globstar = true;
1435
+ state.output += prior.output + prev.output;
1436
+ consume(value);
1437
+ continue;
1438
+ }
1439
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1440
+ const end = rest[1] !== void 0 ? "|$" : "";
1441
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1442
+ prior.output = `(?:${prior.output}`;
1443
+ prev.type = "globstar";
1444
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1445
+ prev.value += value;
1446
+ state.output += prior.output + prev.output;
1447
+ state.globstar = true;
1448
+ consume(value + advance());
1449
+ push({ type: "slash", value: "/", output: "" });
1450
+ continue;
1451
+ }
1452
+ if (prior.type === "bos" && rest[0] === "/") {
1453
+ prev.type = "globstar";
1454
+ prev.value += value;
1455
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1456
+ state.output = prev.output;
1457
+ state.globstar = true;
1458
+ consume(value + advance());
1459
+ push({ type: "slash", value: "/", output: "" });
1460
+ continue;
1461
+ }
1462
+ state.output = state.output.slice(0, -prev.output.length);
1463
+ prev.type = "globstar";
1464
+ prev.output = globstar(opts);
1465
+ prev.value += value;
1466
+ state.output += prev.output;
1467
+ state.globstar = true;
1468
+ consume(value);
1469
+ continue;
1470
+ }
1471
+ const token = { type: "star", value, output: star };
1472
+ if (opts.bash === true) {
1473
+ token.output = ".*?";
1474
+ if (prev.type === "bos" || prev.type === "slash") {
1475
+ token.output = nodot + token.output;
1476
+ }
1477
+ push(token);
1478
+ continue;
1479
+ }
1480
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1481
+ token.output = value;
1482
+ push(token);
1483
+ continue;
1484
+ }
1485
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1486
+ if (prev.type === "dot") {
1487
+ state.output += NO_DOT_SLASH;
1488
+ prev.output += NO_DOT_SLASH;
1489
+ } else if (opts.dot === true) {
1490
+ state.output += NO_DOTS_SLASH;
1491
+ prev.output += NO_DOTS_SLASH;
1492
+ } else {
1493
+ state.output += nodot;
1494
+ prev.output += nodot;
1495
+ }
1496
+ if (peek() !== "*") {
1497
+ state.output += ONE_CHAR;
1498
+ prev.output += ONE_CHAR;
1499
+ }
1500
+ }
1501
+ push(token);
1502
+ }
1503
+ while (state.brackets > 0) {
1504
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1505
+ state.output = utils.escapeLast(state.output, "[");
1506
+ decrement("brackets");
1507
+ }
1508
+ while (state.parens > 0) {
1509
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1510
+ state.output = utils.escapeLast(state.output, "(");
1511
+ decrement("parens");
1512
+ }
1513
+ while (state.braces > 0) {
1514
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1515
+ state.output = utils.escapeLast(state.output, "{");
1516
+ decrement("braces");
1517
+ }
1518
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1519
+ push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
1520
+ }
1521
+ if (state.backtrack === true) {
1522
+ state.output = "";
1523
+ for (const token of state.tokens) {
1524
+ state.output += token.output != null ? token.output : token.value;
1525
+ if (token.suffix) {
1526
+ state.output += token.suffix;
1527
+ }
1528
+ }
1529
+ }
1530
+ return state;
1531
+ };
1532
+ parse.fastpaths = (input, options) => {
1533
+ const opts = { ...options };
1534
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1535
+ const len = input.length;
1536
+ if (len > max) {
1537
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1538
+ }
1539
+ input = REPLACEMENTS[input] || input;
1540
+ const {
1541
+ DOT_LITERAL,
1542
+ SLASH_LITERAL,
1543
+ ONE_CHAR,
1544
+ DOTS_SLASH,
1545
+ NO_DOT,
1546
+ NO_DOTS,
1547
+ NO_DOTS_SLASH,
1548
+ STAR,
1549
+ START_ANCHOR
1550
+ } = constants.globChars(opts.windows);
1551
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
1552
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1553
+ const capture = opts.capture ? "" : "?:";
1554
+ const state = { negated: false, prefix: "" };
1555
+ let star = opts.bash === true ? ".*?" : STAR;
1556
+ if (opts.capture) {
1557
+ star = `(${star})`;
1558
+ }
1559
+ const globstar = (opts2) => {
1560
+ if (opts2.noglobstar === true) return star;
1561
+ return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1562
+ };
1563
+ const create = (str) => {
1564
+ switch (str) {
1565
+ case "*":
1566
+ return `${nodot}${ONE_CHAR}${star}`;
1567
+ case ".*":
1568
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1569
+ case "*.*":
1570
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1571
+ case "*/*":
1572
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1573
+ case "**":
1574
+ return nodot + globstar(opts);
1575
+ case "**/*":
1576
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1577
+ case "**/*.*":
1578
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1579
+ case "**/.*":
1580
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1581
+ default: {
1582
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1583
+ if (!match) return;
1584
+ const source2 = create(match[1]);
1585
+ if (!source2) return;
1586
+ return source2 + DOT_LITERAL + match[2];
1587
+ }
1588
+ }
1589
+ };
1590
+ const output = utils.removePrefix(input, state);
1591
+ let source = create(output);
1592
+ if (source && opts.strictSlashes !== true) {
1593
+ source += `${SLASH_LITERAL}?`;
1594
+ }
1595
+ return source;
1596
+ };
1597
+ module.exports = parse;
1598
+ }
1599
+ });
1600
+
1601
+ // node_modules/picomatch/lib/picomatch.js
1602
+ var require_picomatch = __commonJS({
1603
+ "node_modules/picomatch/lib/picomatch.js"(exports, module) {
1604
+ "use strict";
1605
+ var scan = require_scan();
1606
+ var parse = require_parse();
1607
+ var utils = require_utils();
1608
+ var constants = require_constants();
1609
+ var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1610
+ var picomatch2 = (glob, options, returnState = false) => {
1611
+ if (Array.isArray(glob)) {
1612
+ const fns = glob.map((input) => picomatch2(input, options, returnState));
1613
+ const arrayMatcher = (str) => {
1614
+ for (const isMatch of fns) {
1615
+ const state2 = isMatch(str);
1616
+ if (state2) return state2;
1617
+ }
1618
+ return false;
1619
+ };
1620
+ return arrayMatcher;
1621
+ }
1622
+ const isState = isObject(glob) && glob.tokens && glob.input;
1623
+ if (glob === "" || typeof glob !== "string" && !isState) {
1624
+ throw new TypeError("Expected pattern to be a non-empty string");
1625
+ }
1626
+ const opts = options || {};
1627
+ const posix = opts.windows;
1628
+ const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
1629
+ const state = regex.state;
1630
+ delete regex.state;
1631
+ let isIgnored = () => false;
1632
+ if (opts.ignore) {
1633
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1634
+ isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
1635
+ }
1636
+ const matcher = (input, returnObject = false) => {
1637
+ const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
1638
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
1639
+ if (typeof opts.onResult === "function") {
1640
+ opts.onResult(result);
1641
+ }
1642
+ if (isMatch === false) {
1643
+ result.isMatch = false;
1644
+ return returnObject ? result : false;
1645
+ }
1646
+ if (isIgnored(input)) {
1647
+ if (typeof opts.onIgnore === "function") {
1648
+ opts.onIgnore(result);
1649
+ }
1650
+ result.isMatch = false;
1651
+ return returnObject ? result : false;
1652
+ }
1653
+ if (typeof opts.onMatch === "function") {
1654
+ opts.onMatch(result);
1655
+ }
1656
+ return returnObject ? result : true;
1657
+ };
1658
+ if (returnState) {
1659
+ matcher.state = state;
1660
+ }
1661
+ return matcher;
1662
+ };
1663
+ picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
1664
+ if (typeof input !== "string") {
1665
+ throw new TypeError("Expected input to be a string");
1666
+ }
1667
+ if (input === "") {
1668
+ return { isMatch: false, output: "" };
1669
+ }
1670
+ const opts = options || {};
1671
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
1672
+ let match = input === glob;
1673
+ let output = match && format ? format(input) : input;
1674
+ if (match === false) {
1675
+ output = format ? format(input) : input;
1676
+ match = output === glob;
1677
+ }
1678
+ if (match === false || opts.capture === true) {
1679
+ if (opts.matchBase === true || opts.basename === true) {
1680
+ match = picomatch2.matchBase(input, regex, options, posix);
1681
+ } else {
1682
+ match = regex.exec(output);
1683
+ }
1684
+ }
1685
+ return { isMatch: Boolean(match), match, output };
1686
+ };
1687
+ picomatch2.matchBase = (input, glob, options) => {
1688
+ const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
1689
+ return regex.test(utils.basename(input));
1690
+ };
1691
+ picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
1692
+ picomatch2.parse = (pattern, options) => {
1693
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
1694
+ return parse(pattern, { ...options, fastpaths: false });
1695
+ };
1696
+ picomatch2.scan = (input, options) => scan(input, options);
1697
+ picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
1698
+ if (returnOutput === true) {
1699
+ return state.output;
1700
+ }
1701
+ const opts = options || {};
1702
+ const prepend = opts.contains ? "" : "^";
1703
+ const append = opts.contains ? "" : "$";
1704
+ let source = `${prepend}(?:${state.output})${append}`;
1705
+ if (state && state.negated === true) {
1706
+ source = `^(?!${source}).*$`;
1707
+ }
1708
+ const regex = picomatch2.toRegex(source, options);
1709
+ if (returnState === true) {
1710
+ regex.state = state;
1711
+ }
1712
+ return regex;
1713
+ };
1714
+ picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1715
+ if (!input || typeof input !== "string") {
1716
+ throw new TypeError("Expected a non-empty string");
1717
+ }
1718
+ let parsed = { negated: false, fastpaths: true };
1719
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1720
+ parsed.output = parse.fastpaths(input, options);
1721
+ }
1722
+ if (!parsed.output) {
1723
+ parsed = parse(input, options);
1724
+ }
1725
+ return picomatch2.compileRe(parsed, options, returnOutput, returnState);
1726
+ };
1727
+ picomatch2.toRegex = (source, options) => {
1728
+ try {
1729
+ const opts = options || {};
1730
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1731
+ } catch (err) {
1732
+ if (options && options.debug === true) throw err;
1733
+ return /$^/;
1734
+ }
1735
+ };
1736
+ picomatch2.constants = constants;
1737
+ module.exports = picomatch2;
1738
+ }
1739
+ });
1740
+
1741
+ // node_modules/picomatch/index.js
1742
+ var require_picomatch2 = __commonJS({
1743
+ "node_modules/picomatch/index.js"(exports, module) {
1744
+ "use strict";
1745
+ var pico = require_picomatch();
1746
+ var utils = require_utils();
1747
+ function picomatch2(glob, options, returnState = false) {
1748
+ if (options && (options.windows === null || options.windows === void 0)) {
1749
+ options = { ...options, windows: utils.isWindows() };
1750
+ }
1751
+ return pico(glob, options, returnState);
1752
+ }
1753
+ Object.assign(picomatch2, pico);
1754
+ module.exports = picomatch2;
1755
+ }
1756
+ });
1757
+
1758
+ // src/config.ts
1759
+ import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "fs";
1760
+ import { homedir } from "os";
1761
+ import { dirname, join } from "path";
1762
+
1763
+ // src/cli/ui/theme/tokens.ts
1764
+ function card(fg, tone) {
1765
+ return {
1766
+ user: { color: fg.meta, glyph: "\u25C7" },
1767
+ reasoning: { color: tone.accent, glyph: "\u25C6" },
1768
+ streaming: { color: tone.brand, glyph: "\u25C8" },
1769
+ task: { color: tone.warn, glyph: "\u25B6" },
1770
+ tool: { color: tone.info, glyph: "\u25A3" },
1771
+ plan: { color: tone.accent, glyph: "\u229E" },
1772
+ diff: { color: tone.ok, glyph: "\xB1" },
1773
+ error: { color: tone.err, glyph: "\u2716" },
1774
+ warn: { color: tone.warn, glyph: "\u26A0" },
1775
+ usage: { color: fg.meta, glyph: "\u03A3" },
1776
+ subagent: { color: tone.violet, glyph: "\u232C" },
1777
+ approval: { color: tone.warn, glyph: "?" },
1778
+ search: { color: tone.info, glyph: "\u2299" },
1779
+ memory: { color: fg.meta, glyph: "\u2311" },
1780
+ ctx: { color: tone.brand, glyph: "\u25D4" },
1781
+ doctor: { color: fg.meta, glyph: "\u2695" },
1782
+ branch: { color: tone.violet, glyph: "\u2387" }
1783
+ };
1784
+ }
1785
+ function defineTheme(base) {
1786
+ return { ...base, card: card(base.fg, base.tone) };
1787
+ }
1788
+ var githubDark = defineTheme({
1789
+ fg: {
1790
+ strong: "#e6edf3",
1791
+ body: "#c9d1d9",
1792
+ sub: "#8b949e",
1793
+ meta: "#6e7681",
1794
+ faint: "#484f58"
1795
+ },
1796
+ tone: {
1797
+ brand: "#79c0ff",
1798
+ accent: "#d2a8ff",
1799
+ violet: "#b395f5",
1800
+ ok: "#7ee787",
1801
+ warn: "#f0b07d",
1802
+ err: "#ff8b81",
1803
+ info: "#79c0ff"
1804
+ },
1805
+ toneActive: {
1806
+ brand: "#a5d6ff",
1807
+ accent: "#e2c5ff",
1808
+ violet: "#c8aaff",
1809
+ ok: "#a8f5ad",
1810
+ warn: "#ffc99e",
1811
+ err: "#ffaba3",
1812
+ info: "#a5d6ff"
1813
+ },
1814
+ surface: {
1815
+ bg: "#0a0c10",
1816
+ bgInput: "#0d1015",
1817
+ bgCode: "#06080c",
1818
+ bgElev: "#11141a"
1819
+ }
1820
+ });
1821
+ var dark = defineTheme({
1822
+ fg: {
1823
+ strong: "#f4f7fb",
1824
+ body: "#d8dee9",
1825
+ sub: "#a7b1c2",
1826
+ meta: "#778294",
1827
+ faint: "#4d5666"
1828
+ },
1829
+ tone: {
1830
+ brand: "#7dd3fc",
1831
+ accent: "#c084fc",
1832
+ violet: "#a78bfa",
1833
+ ok: "#86efac",
1834
+ warn: "#fbbf24",
1835
+ err: "#f87171",
1836
+ info: "#60a5fa"
1837
+ },
1838
+ toneActive: {
1839
+ brand: "#bae6fd",
1840
+ accent: "#e9d5ff",
1841
+ violet: "#ddd6fe",
1842
+ ok: "#bbf7d0",
1843
+ warn: "#fde68a",
1844
+ err: "#fecaca",
1845
+ info: "#bfdbfe"
1846
+ },
1847
+ surface: {
1848
+ bg: "#0b1020",
1849
+ bgInput: "#111827",
1850
+ bgCode: "#080c16",
1851
+ bgElev: "#151d2f"
1852
+ }
1853
+ });
1854
+ var light = defineTheme({
1855
+ fg: {
1856
+ strong: "#111827",
1857
+ body: "#1f2937",
1858
+ sub: "#4b5563",
1859
+ meta: "#6b7280",
1860
+ faint: "#9ca3af"
1861
+ },
1862
+ tone: {
1863
+ brand: "#2563eb",
1864
+ accent: "#7c3aed",
1865
+ violet: "#6d28d9",
1866
+ ok: "#15803d",
1867
+ warn: "#b45309",
1868
+ err: "#dc2626",
1869
+ info: "#0369a1"
1870
+ },
1871
+ toneActive: {
1872
+ brand: "#1d4ed8",
1873
+ accent: "#6d28d9",
1874
+ violet: "#5b21b6",
1875
+ ok: "#166534",
1876
+ warn: "#92400e",
1877
+ err: "#b91c1c",
1878
+ info: "#075985"
1879
+ },
1880
+ surface: {
1881
+ bg: "#ffffff",
1882
+ bgInput: "#f8fafc",
1883
+ bgCode: "#f3f4f6",
1884
+ bgElev: "#eef2f7"
1885
+ }
1886
+ });
1887
+ var tokyoNight = defineTheme({
1888
+ fg: {
1889
+ strong: "#c0caf5",
1890
+ body: "#a9b1d6",
1891
+ sub: "#9aa5ce",
1892
+ meta: "#565f89",
1893
+ faint: "#414868"
1894
+ },
1895
+ tone: {
1896
+ brand: "#7aa2f7",
1897
+ accent: "#bb9af7",
1898
+ violet: "#9d7cd8",
1899
+ ok: "#9ece6a",
1900
+ warn: "#e0af68",
1901
+ err: "#f7768e",
1902
+ info: "#2ac3de"
1903
+ },
1904
+ toneActive: {
1905
+ brand: "#a9c7ff",
1906
+ accent: "#d7b9ff",
1907
+ violet: "#c6a0f6",
1908
+ ok: "#b9f27c",
1909
+ warn: "#ffd089",
1910
+ err: "#ff9cac",
1911
+ info: "#7dcfff"
1912
+ },
1913
+ surface: {
1914
+ bg: "#1a1b26",
1915
+ bgInput: "#1f2335",
1916
+ bgCode: "#16161e",
1917
+ bgElev: "#24283b"
1918
+ }
1919
+ });
1920
+ var githubLight = defineTheme({
1921
+ fg: {
1922
+ strong: "#1f2328",
1923
+ body: "#24292f",
1924
+ sub: "#57606a",
1925
+ meta: "#6e7781",
1926
+ faint: "#8c959f"
1927
+ },
1928
+ tone: {
1929
+ brand: "#0969da",
1930
+ accent: "#8250df",
1931
+ violet: "#6639ba",
1932
+ ok: "#1a7f37",
1933
+ warn: "#9a6700",
1934
+ err: "#cf222e",
1935
+ info: "#0969da"
1936
+ },
1937
+ toneActive: {
1938
+ brand: "#0550ae",
1939
+ accent: "#6639ba",
1940
+ violet: "#512a97",
1941
+ ok: "#116329",
1942
+ warn: "#7d4e00",
1943
+ err: "#a40e26",
1944
+ info: "#0550ae"
1945
+ },
1946
+ surface: {
1947
+ bg: "#ffffff",
1948
+ bgInput: "#f6f8fa",
1949
+ bgCode: "#f6f8fa",
1950
+ bgElev: "#eaeef2"
1951
+ }
1952
+ });
1953
+ var highContrast = defineTheme({
1954
+ fg: {
1955
+ strong: "#ffffff",
1956
+ body: "#f5f5f5",
1957
+ sub: "#d4d4d4",
1958
+ meta: "#bdbdbd",
1959
+ faint: "#8a8a8a"
1960
+ },
1961
+ tone: {
1962
+ brand: "#00e5ff",
1963
+ accent: "#ff4dff",
1964
+ violet: "#b388ff",
1965
+ ok: "#00ff66",
1966
+ warn: "#ffdd00",
1967
+ err: "#ff4d4d",
1968
+ info: "#4da3ff"
1969
+ },
1970
+ toneActive: {
1971
+ brand: "#80f2ff",
1972
+ accent: "#ff99ff",
1973
+ violet: "#d0b3ff",
1974
+ ok: "#80ffb3",
1975
+ warn: "#ffee80",
1976
+ err: "#ff9999",
1977
+ info: "#99c9ff"
1978
+ },
1979
+ surface: {
1980
+ bg: "#000000",
1981
+ bgInput: "#0a0a0a",
1982
+ bgCode: "#050505",
1983
+ bgElev: "#141414"
1984
+ }
1985
+ });
1986
+ var THEMES = {
1987
+ default: githubDark,
1988
+ dark,
1989
+ light,
1990
+ "tokyo-night": tokyoNight,
1991
+ "github-dark": githubDark,
1992
+ "github-light": githubLight,
1993
+ "high-contrast": highContrast
1994
+ };
1995
+ var DEFAULT_THEME_NAME = "default";
1996
+ function isThemeName(value) {
1997
+ return Object.prototype.hasOwnProperty.call(THEMES, value);
1998
+ }
1999
+ function resolveThemeName(value) {
2000
+ if (!value || value === "auto") return DEFAULT_THEME_NAME;
2001
+ return isThemeName(value) ? value : DEFAULT_THEME_NAME;
2002
+ }
2003
+ function listThemeNames() {
2004
+ return Object.keys(THEMES);
2005
+ }
2006
+ var DEFAULT_THEME = THEMES[DEFAULT_THEME_NAME];
2007
+ var activeTheme = DEFAULT_THEME;
2008
+ var activeThemeVersion = 0;
2009
+ function setActiveTheme(theme) {
2010
+ const previousTheme = activeTheme;
2011
+ activeTheme = theme;
2012
+ activeThemeVersion += 1;
2013
+ const version = activeThemeVersion;
2014
+ return () => {
2015
+ if (activeThemeVersion !== version || activeTheme !== theme) return;
2016
+ activeTheme = previousTheme;
2017
+ activeThemeVersion += 1;
2018
+ };
2019
+ }
2020
+ function proxyTokens(select) {
2021
+ const target = select(DEFAULT_THEME);
2022
+ return new Proxy(target, {
2023
+ get(_target, prop) {
2024
+ return select(activeTheme)[prop];
2025
+ },
2026
+ getOwnPropertyDescriptor(_target, prop) {
2027
+ return Reflect.getOwnPropertyDescriptor(select(activeTheme), prop);
2028
+ },
2029
+ has(_target, prop) {
2030
+ return prop in select(activeTheme);
2031
+ },
2032
+ ownKeys() {
2033
+ return Reflect.ownKeys(select(activeTheme));
2034
+ }
2035
+ });
2036
+ }
2037
+ var FG = proxyTokens((theme) => theme.fg);
2038
+ var TONE = proxyTokens((theme) => theme.tone);
2039
+ var TONE_ACTIVE = proxyTokens((theme) => theme.toneActive);
2040
+ var SURFACE = proxyTokens((theme) => theme.surface);
2041
+ var CARD = proxyTokens((theme) => theme.card);
2042
+ var USD_TO_CNY = 7.2;
2043
+ var SYMBOL = { USD: "$", CNY: "\xA5" };
2044
+ function formatBalance(amount, currency, opts) {
2045
+ const cur = currency ?? "CNY";
2046
+ const sym = SYMBOL[cur];
2047
+ const digits = opts?.fractionDigits ?? 2;
2048
+ const body = sym ? `${sym}${amount.toFixed(digits)}` : `${cur} ${amount.toFixed(digits)}`;
2049
+ return opts?.label ? `w ${body}` : body;
2050
+ }
2051
+ function formatCost(costUsd, currency, fractionDigits = 4) {
2052
+ const cur = currency ?? "CNY";
2053
+ const amount = cur === "CNY" ? costUsd * USD_TO_CNY : costUsd;
2054
+ return formatBalance(amount, cur, { fractionDigits });
2055
+ }
2056
+ function balanceColor(amount, currency) {
2057
+ const cny = (currency ?? "CNY") === "USD" ? amount * USD_TO_CNY : amount;
2058
+ if (cny < 5) return TONE.err;
2059
+ if (cny < 20) return TONE.warn;
2060
+ return TONE.brand;
2061
+ }
2062
+
2063
+ // src/index/config.ts
2064
+ var import_picomatch = __toESM(require_picomatch2(), 1);
2065
+ var DEFAULT_INDEX_EXCLUDES = {
2066
+ dirs: [
2067
+ "node_modules",
2068
+ ".git",
2069
+ ".hg",
2070
+ ".svn",
2071
+ "dist",
2072
+ "build",
2073
+ "out",
2074
+ ".next",
2075
+ ".nuxt",
2076
+ "target",
2077
+ ".venv",
2078
+ "venv",
2079
+ "__pycache__",
2080
+ ".pytest_cache",
2081
+ ".mypy_cache",
2082
+ ".cache",
2083
+ "coverage",
2084
+ ".turbo",
2085
+ ".vercel",
2086
+ ".luckerr"
2087
+ ],
2088
+ files: [
2089
+ "package-lock.json",
2090
+ "yarn.lock",
2091
+ "pnpm-lock.yaml",
2092
+ "Cargo.lock",
2093
+ "poetry.lock",
2094
+ "Pipfile.lock",
2095
+ "go.sum",
2096
+ ".DS_Store"
2097
+ ],
2098
+ exts: [
2099
+ ".png",
2100
+ ".jpg",
2101
+ ".jpeg",
2102
+ ".gif",
2103
+ ".webp",
2104
+ ".bmp",
2105
+ ".ico",
2106
+ ".tiff",
2107
+ ".woff",
2108
+ ".woff2",
2109
+ ".ttf",
2110
+ ".otf",
2111
+ ".eot",
2112
+ ".zip",
2113
+ ".tar",
2114
+ ".gz",
2115
+ ".bz2",
2116
+ ".xz",
2117
+ ".rar",
2118
+ ".7z",
2119
+ ".exe",
2120
+ ".dll",
2121
+ ".so",
2122
+ ".dylib",
2123
+ ".bin",
2124
+ ".class",
2125
+ ".jar",
2126
+ ".war",
2127
+ ".wasm",
2128
+ ".o",
2129
+ ".obj",
2130
+ ".lib",
2131
+ ".a",
2132
+ ".pyc",
2133
+ ".pyo",
2134
+ ".mp3",
2135
+ ".mp4",
2136
+ ".wav",
2137
+ ".ogg",
2138
+ ".webm",
2139
+ ".mov",
2140
+ ".avi",
2141
+ ".pdf",
2142
+ ".sqlite",
2143
+ ".db"
2144
+ ]
2145
+ };
2146
+ var DEFAULT_MAX_FILE_BYTES = 256 * 1024;
2147
+ var DEFAULT_RESPECT_GITIGNORE = true;
2148
+ function defaultIndexConfig() {
2149
+ return {
2150
+ excludeDirs: [...DEFAULT_INDEX_EXCLUDES.dirs],
2151
+ excludeFiles: [...DEFAULT_INDEX_EXCLUDES.files],
2152
+ excludeExts: [...DEFAULT_INDEX_EXCLUDES.exts],
2153
+ excludePatterns: [],
2154
+ respectGitignore: DEFAULT_RESPECT_GITIGNORE,
2155
+ maxFileBytes: DEFAULT_MAX_FILE_BYTES
2156
+ };
2157
+ }
2158
+ function resolveIndexConfig(user) {
2159
+ const d = defaultIndexConfig();
2160
+ if (!user) return d;
2161
+ return {
2162
+ excludeDirs: Array.isArray(user.excludeDirs) ? [...user.excludeDirs] : d.excludeDirs,
2163
+ excludeFiles: Array.isArray(user.excludeFiles) ? [...user.excludeFiles] : d.excludeFiles,
2164
+ excludeExts: Array.isArray(user.excludeExts) ? user.excludeExts.map((e) => e.toLowerCase()) : d.excludeExts,
2165
+ excludePatterns: Array.isArray(user.excludePatterns) ? [...user.excludePatterns] : [],
2166
+ respectGitignore: typeof user.respectGitignore === "boolean" ? user.respectGitignore : d.respectGitignore,
2167
+ maxFileBytes: typeof user.maxFileBytes === "number" && user.maxFileBytes > 0 ? user.maxFileBytes : d.maxFileBytes
2168
+ };
2169
+ }
2170
+ function compileFilters(cfg) {
2171
+ const matcher = cfg.excludePatterns.length === 0 ? () => false : (0, import_picomatch.default)(cfg.excludePatterns, { dot: true });
2172
+ return {
2173
+ dirSet: new Set(cfg.excludeDirs),
2174
+ fileSet: new Set(cfg.excludeFiles),
2175
+ extSet: new Set(cfg.excludeExts.map((e) => e.toLowerCase())),
2176
+ patternMatch: matcher,
2177
+ respectGitignore: cfg.respectGitignore,
2178
+ maxFileBytes: cfg.maxFileBytes
2179
+ };
2180
+ }
2181
+
2182
+ // src/config.ts
2183
+ var BUILTIN_TYPE_DOCS = {
2184
+ user: "role / skills / preferences",
2185
+ feedback: "corrections or confirmed approaches",
2186
+ project: "facts / decisions about the current work",
2187
+ reference: "pointers to external systems the user uses"
2188
+ };
2189
+ function loadMemoryTypeRegistry(cfg = readConfig()) {
2190
+ const out = [];
2191
+ for (const name of ["user", "feedback", "project", "reference"]) {
2192
+ out.push({ name, builtin: true, description: BUILTIN_TYPE_DOCS[name] });
2193
+ }
2194
+ const seen = new Set(out.map((e) => e.name));
2195
+ for (const raw of cfg.memory?.customTypes ?? []) {
2196
+ if (!raw || typeof raw.name !== "string") continue;
2197
+ const name = raw.name.trim();
2198
+ if (!name || !/^[a-zA-Z][a-zA-Z0-9_-]{0,31}$/.test(name)) continue;
2199
+ if (seen.has(name)) continue;
2200
+ seen.add(name);
2201
+ const entry = { name, builtin: false };
2202
+ if (typeof raw.description === "string") entry.description = raw.description;
2203
+ if (raw.priority === "low" || raw.priority === "medium" || raw.priority === "high") {
2204
+ entry.priority = raw.priority;
2205
+ }
2206
+ if (raw.expires === "project_end") entry.expires = raw.expires;
2207
+ out.push(entry);
2208
+ }
2209
+ return out;
2210
+ }
2211
+ function memoryTypeDefaults(typeName, cfg = readConfig()) {
2212
+ const found = loadMemoryTypeRegistry(cfg).find((e) => e.name === typeName);
2213
+ if (!found) return {};
2214
+ const out = {};
2215
+ if (found.priority) out.priority = found.priority;
2216
+ if (found.expires) out.expires = found.expires;
2217
+ return out;
2218
+ }
2219
+ var DEFAULT_OLLAMA_URL = "http://localhost:11434";
2220
+ var DEFAULT_EMBED_MODEL = "nomic-embed-text";
2221
+ var DEFAULT_TIMEOUT_MS = 3e4;
2222
+ function defaultConfigPath() {
2223
+ return join(homedir(), ".luckerr", "config.json");
2224
+ }
2225
+ function readConfig(path = defaultConfigPath()) {
2226
+ try {
2227
+ const raw = readFileSync(path, "utf8");
2228
+ const parsed = JSON.parse(raw);
2229
+ if (parsed && typeof parsed === "object") return parsed;
2230
+ } catch {
2231
+ }
2232
+ return {};
2233
+ }
2234
+ function writeConfig(cfg, path = defaultConfigPath()) {
2235
+ mkdirSync(dirname(path), { recursive: true });
2236
+ writeFileSync(path, JSON.stringify(cfg, null, 2), "utf8");
2237
+ try {
2238
+ chmodSync(path, 384);
2239
+ } catch {
2240
+ }
2241
+ }
2242
+ function loadLanguage(path = defaultConfigPath()) {
2243
+ return readConfig(path).lang;
2244
+ }
2245
+ function mcpEnvFor(serverName, cfg) {
2246
+ if (!serverName) return void 0;
2247
+ const entry = cfg.mcpEnv?.[serverName];
2248
+ if (!entry) return void 0;
2249
+ const filtered = {};
2250
+ for (const [k, v] of Object.entries(entry)) {
2251
+ if (typeof v === "string" && v.length > 0) filtered[k] = v;
2252
+ }
2253
+ return Object.keys(filtered).length > 0 ? filtered : void 0;
2254
+ }
2255
+ function saveLanguage(lang, path = defaultConfigPath()) {
2256
+ const cfg = readConfig(path);
2257
+ cfg.lang = lang;
2258
+ writeConfig(cfg, path);
2259
+ }
2260
+ function loadApiKey(path = defaultConfigPath()) {
2261
+ if (process.env.DEEPSEEK_API_KEY) return process.env.DEEPSEEK_API_KEY;
2262
+ return readConfig(path).apiKey;
2263
+ }
2264
+ function loadProviderApiKey(providerId, envKey, path = defaultConfigPath()) {
2265
+ if (process.env[envKey]) return process.env[envKey];
2266
+ const cfg = readConfig(path);
2267
+ if (cfg.providerKeys?.[providerId]) return cfg.providerKeys[providerId];
2268
+ if (process.env.DEEPSEEK_API_KEY) return process.env.DEEPSEEK_API_KEY;
2269
+ return cfg.apiKey;
2270
+ }
2271
+ function loadBaseUrl(path = defaultConfigPath()) {
2272
+ if (process.env.DEEPSEEK_BASE_URL) return process.env.DEEPSEEK_BASE_URL;
2273
+ return readConfig(path).baseUrl;
2274
+ }
2275
+ function loadProviderBaseUrl(providerId, path = defaultConfigPath()) {
2276
+ if (process.env.DEEPSEEK_BASE_URL) return process.env.DEEPSEEK_BASE_URL;
2277
+ const cfg = readConfig(path);
2278
+ if (cfg.providerBaseUrls?.[providerId]) return cfg.providerBaseUrls[providerId];
2279
+ return cfg.baseUrl;
2280
+ }
2281
+ function saveBaseUrl(url, path = defaultConfigPath()) {
2282
+ const cfg = readConfig(path);
2283
+ const trimmed = url.trim();
2284
+ if (trimmed) {
2285
+ cfg.baseUrl = trimmed;
2286
+ } else {
2287
+ cfg.baseUrl = void 0;
2288
+ }
2289
+ writeConfig(cfg, path);
2290
+ }
2291
+ function searchEnabled(path = defaultConfigPath()) {
2292
+ const env = process.env.LUCKERR_SEARCH;
2293
+ if (env === "off" || env === "false" || env === "0") return false;
2294
+ const cfg = readConfig(path).search;
2295
+ if (cfg === false) return false;
2296
+ return true;
2297
+ }
2298
+ function webSearchEngine(path = defaultConfigPath()) {
2299
+ const cfg = readConfig(path).webSearchEngine;
2300
+ if (cfg === "searxng") return "searxng";
2301
+ return "mojeek";
2302
+ }
2303
+ function webSearchEndpoint(path = defaultConfigPath()) {
2304
+ const cfg = readConfig(path).webSearchEndpoint;
2305
+ if (cfg && typeof cfg === "string") return cfg;
2306
+ return "http://localhost:8080";
2307
+ }
2308
+ function saveApiKey(key, path = defaultConfigPath()) {
2309
+ const cfg = readConfig(path);
2310
+ cfg.apiKey = key.trim();
2311
+ writeConfig(cfg, path);
2312
+ }
2313
+ function findProjectKey(cfg, rootDir) {
2314
+ const projects = cfg.projects;
2315
+ if (!projects) return void 0;
2316
+ if (Object.hasOwn(projects, rootDir)) return rootDir;
2317
+ if (process.platform !== "win32") return void 0;
2318
+ const lower = rootDir.toLowerCase();
2319
+ for (const k of Object.keys(projects)) {
2320
+ if (k.toLowerCase() === lower) return k;
2321
+ }
2322
+ return void 0;
2323
+ }
2324
+ function loadProjectShellAllowed(rootDir, path = defaultConfigPath()) {
2325
+ const cfg = readConfig(path);
2326
+ const key = findProjectKey(cfg, rootDir);
2327
+ if (key === void 0) return [];
2328
+ return cfg.projects?.[key]?.shellAllowed ?? [];
2329
+ }
2330
+ function addProjectShellAllowed(rootDir, prefix, path = defaultConfigPath()) {
2331
+ const trimmed = prefix.trim();
2332
+ if (!trimmed) return;
2333
+ const cfg = readConfig(path);
2334
+ if (!cfg.projects) cfg.projects = {};
2335
+ const key = findProjectKey(cfg, rootDir) ?? rootDir;
2336
+ if (!cfg.projects[key]) cfg.projects[key] = {};
2337
+ const existing = cfg.projects[key].shellAllowed ?? [];
2338
+ if (existing.includes(trimmed)) return;
2339
+ cfg.projects[key].shellAllowed = [...existing, trimmed];
2340
+ writeConfig(cfg, path);
2341
+ }
2342
+ function removeProjectShellAllowed(rootDir, prefix, path = defaultConfigPath()) {
2343
+ const trimmed = prefix.trim();
2344
+ if (!trimmed) return false;
2345
+ const cfg = readConfig(path);
2346
+ const key = findProjectKey(cfg, rootDir);
2347
+ if (key === void 0) return false;
2348
+ const existing = cfg.projects?.[key]?.shellAllowed ?? [];
2349
+ if (!existing.includes(trimmed)) return false;
2350
+ const next = existing.filter((p) => p !== trimmed);
2351
+ if (!cfg.projects) cfg.projects = {};
2352
+ if (!cfg.projects[key]) cfg.projects[key] = {};
2353
+ cfg.projects[key].shellAllowed = next;
2354
+ writeConfig(cfg, path);
2355
+ return true;
2356
+ }
2357
+ function clearProjectShellAllowed(rootDir, path = defaultConfigPath()) {
2358
+ const cfg = readConfig(path);
2359
+ const key = findProjectKey(cfg, rootDir);
2360
+ if (key === void 0) return 0;
2361
+ const existing = cfg.projects?.[key]?.shellAllowed ?? [];
2362
+ if (existing.length === 0) return 0;
2363
+ if (!cfg.projects) cfg.projects = {};
2364
+ if (!cfg.projects[key]) cfg.projects[key] = {};
2365
+ cfg.projects[key].shellAllowed = [];
2366
+ writeConfig(cfg, path);
2367
+ return existing.length;
2368
+ }
2369
+ function loadProjectPathAllowed(rootDir, path = defaultConfigPath()) {
2370
+ const cfg = readConfig(path);
2371
+ const key = findProjectKey(cfg, rootDir);
2372
+ if (key === void 0) return [];
2373
+ return cfg.projects?.[key]?.pathAllowed ?? [];
2374
+ }
2375
+ function addProjectPathAllowed(rootDir, prefix, path = defaultConfigPath()) {
2376
+ const trimmed = prefix.trim();
2377
+ if (!trimmed) return;
2378
+ const cfg = readConfig(path);
2379
+ if (!cfg.projects) cfg.projects = {};
2380
+ const key = findProjectKey(cfg, rootDir) ?? rootDir;
2381
+ if (!cfg.projects[key]) cfg.projects[key] = {};
2382
+ const existing = cfg.projects[key].pathAllowed ?? [];
2383
+ if (existing.includes(trimmed)) return;
2384
+ cfg.projects[key].pathAllowed = [...existing, trimmed];
2385
+ writeConfig(cfg, path);
2386
+ }
2387
+ function loadEditMode(path = defaultConfigPath()) {
2388
+ const v = readConfig(path).editMode;
2389
+ if (v === "auto" || v === "yolo") return v;
2390
+ return "review";
2391
+ }
2392
+ function saveEditMode(mode, path = defaultConfigPath()) {
2393
+ const cfg = readConfig(path);
2394
+ cfg.editMode = mode;
2395
+ writeConfig(cfg, path);
2396
+ }
2397
+ function editModeHintShown(path = defaultConfigPath()) {
2398
+ return readConfig(path).editModeHintShown === true;
2399
+ }
2400
+ function mouseClipboardHintShown(path = defaultConfigPath()) {
2401
+ return readConfig(path).mouseClipboardHintShown === true;
2402
+ }
2403
+ function loadReasoningEffort(path = defaultConfigPath()) {
2404
+ const v = readConfig(path).reasoningEffort;
2405
+ return v === "high" ? "high" : "max";
2406
+ }
2407
+ function loadTheme(path = defaultConfigPath()) {
2408
+ const value = readConfig(path).theme;
2409
+ if (value === "auto") return "auto";
2410
+ if (typeof value === "string" && isThemeName(value)) return value;
2411
+ return void 0;
2412
+ }
2413
+ function resolveThemePreference(configTheme, envTheme) {
2414
+ if (configTheme && configTheme !== "auto") return configTheme;
2415
+ return resolveThemeName(envTheme);
2416
+ }
2417
+ function saveTheme(theme, path = defaultConfigPath()) {
2418
+ const cfg = readConfig(path);
2419
+ cfg.theme = theme;
2420
+ writeConfig(cfg, path);
2421
+ }
2422
+ function saveReasoningEffort(effort, path = defaultConfigPath()) {
2423
+ const cfg = readConfig(path);
2424
+ cfg.reasoningEffort = effort;
2425
+ writeConfig(cfg, path);
2426
+ }
2427
+ function loadWorkspaceDir(path = defaultConfigPath()) {
2428
+ const v = readConfig(path).workspaceDir;
2429
+ return typeof v === "string" && v.trim() ? v : void 0;
2430
+ }
2431
+ function saveWorkspaceDir(dir, path = defaultConfigPath()) {
2432
+ const cfg = readConfig(path);
2433
+ const trimmed = dir.trim();
2434
+ if (trimmed) cfg.workspaceDir = trimmed;
2435
+ else cfg.workspaceDir = void 0;
2436
+ writeConfig(cfg, path);
2437
+ }
2438
+ function loadEditor(path = defaultConfigPath()) {
2439
+ const v = readConfig(path).editor;
2440
+ return typeof v === "string" && v.trim() ? v : void 0;
2441
+ }
2442
+ function saveEditor(editor, path = defaultConfigPath()) {
2443
+ const cfg = readConfig(path);
2444
+ const trimmed = editor.trim();
2445
+ if (trimmed) cfg.editor = trimmed;
2446
+ else cfg.editor = void 0;
2447
+ writeConfig(cfg, path);
2448
+ }
2449
+ function loadRecentWorkspaces(path = defaultConfigPath()) {
2450
+ const v = readConfig(path).recentWorkspaces;
2451
+ return Array.isArray(v) ? v.filter((s) => typeof s === "string") : [];
2452
+ }
2453
+ var MAX_RECENT_WORKSPACES = 8;
2454
+ function pushRecentWorkspace(dir, path = defaultConfigPath()) {
2455
+ const trimmed = dir.trim();
2456
+ if (!trimmed) return;
2457
+ const cfg = readConfig(path);
2458
+ const list = (cfg.recentWorkspaces ?? []).filter((s) => s !== trimmed);
2459
+ list.unshift(trimmed);
2460
+ cfg.recentWorkspaces = list.slice(0, MAX_RECENT_WORKSPACES);
2461
+ writeConfig(cfg, path);
2462
+ }
2463
+ function loadPreset(path = defaultConfigPath()) {
2464
+ return readConfig(path).preset;
2465
+ }
2466
+ function savePreset(preset, path = defaultConfigPath()) {
2467
+ const cfg = readConfig(path);
2468
+ cfg.preset = preset;
2469
+ writeConfig(cfg, path);
2470
+ }
2471
+ function loadIndexUserConfig(path = defaultConfigPath()) {
2472
+ return readConfig(path).index ?? {};
2473
+ }
2474
+ function loadIndexConfig(path = defaultConfigPath()) {
2475
+ return resolveIndexConfig(readConfig(path).index);
2476
+ }
2477
+ function loadSemanticEmbeddingUserConfig(path = defaultConfigPath()) {
2478
+ return normalizeSemanticEmbeddingUserConfig(readConfig(path).semantic);
2479
+ }
2480
+ function saveSemanticEmbeddingConfig(user, path = defaultConfigPath()) {
2481
+ const cfg = readConfig(path);
2482
+ cfg.semantic = normalizeSemanticEmbeddingUserConfig(user);
2483
+ writeConfig(cfg, path);
2484
+ }
2485
+ function resolveSemanticEmbeddingConfig(path = defaultConfigPath()) {
2486
+ const user = loadSemanticEmbeddingUserConfig(path);
2487
+ const provider = user.provider ?? "ollama";
2488
+ if (provider === "openai-compat") {
2489
+ const baseUrl = user.openaiCompat?.baseUrl?.trim() ?? "";
2490
+ const apiKey = user.openaiCompat?.apiKey?.trim() ?? "";
2491
+ const model = user.openaiCompat?.model?.trim() ?? "";
2492
+ if (!baseUrl) throw new Error("OpenAI-compatible embeddings require an API URL.");
2493
+ requireValidUrl(baseUrl, "OpenAI-compatible API URL");
2494
+ if (!apiKey) throw new Error("OpenAI-compatible embeddings require an API key.");
2495
+ if (!model) throw new Error("OpenAI-compatible embeddings require a model.");
2496
+ return {
2497
+ provider,
2498
+ baseUrl,
2499
+ apiKey,
2500
+ model,
2501
+ extraBody: normalizeExtraBody(user.openaiCompat?.extraBody),
2502
+ timeoutMs: DEFAULT_TIMEOUT_MS
2503
+ };
2504
+ }
2505
+ return {
2506
+ provider: "ollama",
2507
+ baseUrl: user.ollama?.baseUrl?.trim() || process.env.OLLAMA_URL || DEFAULT_OLLAMA_URL,
2508
+ model: user.ollama?.model?.trim() || process.env.LUCKERR_EMBED_MODEL || DEFAULT_EMBED_MODEL,
2509
+ timeoutMs: DEFAULT_TIMEOUT_MS
2510
+ };
2511
+ }
2512
+ function redactSemanticEmbeddingConfig(user) {
2513
+ const normalized = normalizeSemanticEmbeddingUserConfig(user);
2514
+ return {
2515
+ provider: normalized.provider ?? "ollama",
2516
+ ollama: {
2517
+ baseUrl: normalized.ollama?.baseUrl?.trim() || process.env.OLLAMA_URL || DEFAULT_OLLAMA_URL,
2518
+ model: normalized.ollama?.model?.trim() || process.env.LUCKERR_EMBED_MODEL || DEFAULT_EMBED_MODEL
2519
+ },
2520
+ openaiCompat: {
2521
+ baseUrl: normalized.openaiCompat?.baseUrl?.trim() ?? "",
2522
+ apiKey: normalized.openaiCompat?.apiKey ? redactKey(normalized.openaiCompat.apiKey) : "",
2523
+ apiKeySet: Boolean(normalized.openaiCompat?.apiKey?.trim()),
2524
+ model: normalized.openaiCompat?.model?.trim() ?? "",
2525
+ extraBody: normalizeExtraBody(normalized.openaiCompat?.extraBody)
2526
+ }
2527
+ };
2528
+ }
2529
+ function markEditModeHintShown(path = defaultConfigPath()) {
2530
+ const cfg = readConfig(path);
2531
+ if (cfg.editModeHintShown === true) return;
2532
+ cfg.editModeHintShown = true;
2533
+ writeConfig(cfg, path);
2534
+ }
2535
+ function markMouseClipboardHintShown(path = defaultConfigPath()) {
2536
+ const cfg = readConfig(path);
2537
+ if (cfg.mouseClipboardHintShown === true) return;
2538
+ cfg.mouseClipboardHintShown = true;
2539
+ writeConfig(cfg, path);
2540
+ }
2541
+ function isPlausibleKey(key) {
2542
+ const trimmed = key.trim();
2543
+ if (trimmed.length < 16) return false;
2544
+ return !/\s/.test(trimmed);
2545
+ }
2546
+ function redactKey(key) {
2547
+ if (!key) return "";
2548
+ if (key.length <= 12) return "****";
2549
+ return `${key.slice(0, 6)}\u2026${key.slice(-4)}`;
2550
+ }
2551
+ function normalizeSemanticEmbeddingUserConfig(cfg) {
2552
+ return {
2553
+ provider: cfg?.provider === "openai-compat" ? "openai-compat" : "ollama",
2554
+ ollama: {
2555
+ baseUrl: normalizeOptionalString(cfg?.ollama?.baseUrl),
2556
+ model: normalizeOptionalString(cfg?.ollama?.model)
2557
+ },
2558
+ openaiCompat: {
2559
+ baseUrl: normalizeOptionalString(cfg?.openaiCompat?.baseUrl),
2560
+ apiKey: normalizeOptionalString(cfg?.openaiCompat?.apiKey),
2561
+ model: normalizeOptionalString(cfg?.openaiCompat?.model),
2562
+ extraBody: normalizeExtraBody(cfg?.openaiCompat?.extraBody)
2563
+ }
2564
+ };
2565
+ }
2566
+ function normalizeOptionalString(value) {
2567
+ const trimmed = value?.trim();
2568
+ return trimmed ? trimmed : void 0;
2569
+ }
2570
+ function normalizeExtraBody(value) {
2571
+ if (value === void 0) return {};
2572
+ if (!isPlainObject(value)) {
2573
+ throw new Error("Semantic embedding extraBody must be a JSON object.");
2574
+ }
2575
+ return { ...value };
2576
+ }
2577
+ function requireValidUrl(value, label) {
2578
+ try {
2579
+ new URL(value);
2580
+ } catch {
2581
+ throw new Error(`${label} must be a valid URL.`);
2582
+ }
2583
+ }
2584
+ function isPlainObject(value) {
2585
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
2586
+ const proto = Object.getPrototypeOf(value);
2587
+ return proto === Object.prototype || proto === null;
2588
+ }
2589
+
2590
+ export {
2591
+ THEMES,
2592
+ DEFAULT_THEME_NAME,
2593
+ isThemeName,
2594
+ resolveThemeName,
2595
+ listThemeNames,
2596
+ setActiveTheme,
2597
+ FG,
2598
+ TONE,
2599
+ TONE_ACTIVE,
2600
+ SURFACE,
2601
+ CARD,
2602
+ formatBalance,
2603
+ formatCost,
2604
+ balanceColor,
2605
+ require_picomatch2 as require_picomatch,
2606
+ DEFAULT_INDEX_EXCLUDES,
2607
+ DEFAULT_MAX_FILE_BYTES,
2608
+ DEFAULT_RESPECT_GITIGNORE,
2609
+ defaultIndexConfig,
2610
+ resolveIndexConfig,
2611
+ compileFilters,
2612
+ loadMemoryTypeRegistry,
2613
+ memoryTypeDefaults,
2614
+ defaultConfigPath,
2615
+ readConfig,
2616
+ writeConfig,
2617
+ loadLanguage,
2618
+ mcpEnvFor,
2619
+ saveLanguage,
2620
+ loadApiKey,
2621
+ loadProviderApiKey,
2622
+ loadBaseUrl,
2623
+ loadProviderBaseUrl,
2624
+ saveBaseUrl,
2625
+ searchEnabled,
2626
+ webSearchEngine,
2627
+ webSearchEndpoint,
2628
+ saveApiKey,
2629
+ loadProjectShellAllowed,
2630
+ addProjectShellAllowed,
2631
+ removeProjectShellAllowed,
2632
+ clearProjectShellAllowed,
2633
+ loadProjectPathAllowed,
2634
+ addProjectPathAllowed,
2635
+ loadEditMode,
2636
+ saveEditMode,
2637
+ editModeHintShown,
2638
+ mouseClipboardHintShown,
2639
+ loadReasoningEffort,
2640
+ loadTheme,
2641
+ resolveThemePreference,
2642
+ saveTheme,
2643
+ saveReasoningEffort,
2644
+ loadWorkspaceDir,
2645
+ saveWorkspaceDir,
2646
+ loadEditor,
2647
+ saveEditor,
2648
+ loadRecentWorkspaces,
2649
+ pushRecentWorkspace,
2650
+ loadPreset,
2651
+ savePreset,
2652
+ loadIndexUserConfig,
2653
+ loadIndexConfig,
2654
+ loadSemanticEmbeddingUserConfig,
2655
+ saveSemanticEmbeddingConfig,
2656
+ resolveSemanticEmbeddingConfig,
2657
+ redactSemanticEmbeddingConfig,
2658
+ markEditModeHintShown,
2659
+ markMouseClipboardHintShown,
2660
+ isPlausibleKey,
2661
+ redactKey
2662
+ };
2663
+ //# sourceMappingURL=chunk-6ALJTWWQ.js.map